Board index » cppbuilder » ZOrder of Forms
Chris
![]() CBuilder Developer |
ZOrder of Forms2006-04-26 02:18:47 AM cppbuilder36 Hi I'm struggling a bit with the window ZOrder in my app. The problem is that I need to display a window non-modally but this window occasionally shows modal forms. The non-modal form also must have a task bar button so that the user can easily switch between the main screen and the non-modal form. So to recap: Form1 (Main Form with taskbar button) Form2 (Non-Modal Form with taskbar button) Form3 (Modal Form called from Form2) If the user has all three screens open and is working in Form3 then the ZOrder (visually) looks like Form1 Form2 Form3 and there are two buttons on the task bar (Form1 , Form2). If the user swaps to another application and then back to mine by clicking on the taskbar buttons all works well if he uses Form1's taskbar button, i.e. the forms are still 'stacked' in the same order as when he left, but if he clicks on Form2's taskbar button then Form2 (which is disabled because Form3 is modal) comes to the front and hence the app appears to have locked (clicking between the taskbar buttons does bring the forms back into the 'correct' order eventually). i.e. Form1 Form3 Form2 To see this in action create a new application with three forms, add a button to form1 and 2. In Form1::ButtonClick Form2->Show(); In Form2::ButtonClick Form3->ShowModal(); I use the following to create the taskbar button in form2 void __fastcall TForm2::CreateParams(TCreateParams &Params) { TForm::CreateParams(Params); Params.ExStyle |= WS_EX_APPWINDOW; } Running the app and following the above and you should see the problem. I think that a solution might be to somehow disable Form2 from reacting to any clicks on it's taskbar button if it is disabled and instead pass the message (or whatever) on to Form1's taskbar button. An alternate solution was to remove the taskbar button of Form2 before showing Form3, I tried using this: long exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); SetWindowLong(hwnd, GWL_EXSTYLE, exstyle & ~WS_EX_APPWINDOW); But unfortunately this didn't work. Anyone able to help? Best regards Chris |