After opening other FF forms via WM_COMMAND responding to menu selections, I wanted to be sure my main form (non MDI app) is the top most window and not whatever other window(s) I may have had open. After the series of SELECT/CASE statements and right after the END SELECT I put the following:
BringWindowToTop (hWndForm)
ShowWindow (hWndForm, %SW_RESTORE)
SetForegroundWindow (hWndForm)
where hWndForm is the window handle from the WM_COMMAND function declaration.
Needless to say, this is not working. Any ideas?
I once used this:
SETWINDOWPOS hWndForm, %HWND_TOPMOST,0,0,0,0,%SWP_NOMOVE OR %SWP_NOSIZE
To remove the 'topmost' feature of the form:
SETWINDOWPOS hWndForm, %HWND_NOTOPMOST,0,0,0,0,%SWP_NOMOVE OR %SWP_NOSIZE
Kind regards
Eddy
If I were to guess, when you open your other Forms you are setting your hWndForm as the owner window.
ie:
Form2_Show hWndForm, %FALSE
or
Form2_Show hWndForm, %TRUE
Because Form2 has an owner then I am pretty sure that the owner form will not be able to move ahead of its owed windows in the zorder.
You could try displaying the Forms using the Desktop as the owner window. Then I think it will work. In this case, you could even set the WS_EX_TOPMOST windowstyle rather than doing the BringWindowToTop stuff.
Form2_Show %HWND_DESKTOP, %FALSE
Quote
If I were to guess, when you open your other Forms you are setting your hWndForm as the owner window.
ie:
Form2_Show hWndForm, %FALSE
or
Form2_Show hWndForm, %TRUE
Because Form2 has an owner then I am pretty sure that the owner form will not be able to move ahead of its owed windows in the zorder.
You could try displaying the Forms using the Desktop as the owner window. Then I think it will work. In this case, you could even set the WS_EX_TOPMOST windowstyle rather than doing the BringWindowToTop stuff.
Form2_Show %HWND_DESKTOP, %FALSE
Using this approach, it didn't matter if I used the desktop handle or not. The main form was on top when the child forms closed although it was not activated or had focus and took a mouse click. I did remove all the code I had used and posted earlier. My main form opens child forms in both modal and non-modal mode and that didn't effect anything. Of course if one wanted to access any other open windows on the desktop, the main form had to be minimized first.
One thing I noticed is that if I open Form2 non-modal and then close it the main form has focus. If Form2 opens another form modal and then that form (Form3) is closed and then Form2 is closed, the main form does not have focus.
So this is almost my desired result. If I could have my main form back on top without using the WS_EX_TOPMOST windowstyle that would be perfect. I'll have to experiment some more....Does conversion to a MDI app make sense?
Using %HWND_DESKTOP without WS_EX_TOPMOST does work when I change the right parts of the code;-) Now, my main form is on top and activated after every child form spawned closes! I'm thankful to continue in the non MDI design with the flexibility provided. I'm getting to the point where I can use NotePad to open a form, change the name references around, save it under the desired new form name and FF imports it perfectly.... 8) I hope I not missing some FF feature that does that....