The MASM Forum

General => The Campus => Topic started by: ragdog on July 20, 2014, 07:45:31 PM

Title: Set Window forground
Post by: ragdog on July 20, 2014, 07:45:31 PM
Hello

I have a little question  8)

I have 2 dialogs (windows) i call the second window with
invoke CreateDialogParam,hInstance,IDD_DIALOG2,hWnd,addr DlgProc2,0

and is this called wish i by activate (by click)  the Main dialog set to forground
   .elseif uMsg==WM_ACTIVATE
mov    eax,wParam
.if eax==WA_ACTIVE || eax==WA_CLICKACTIVE

INVOKE  BringWindowToTop, hWnd
                INVOKE  SetForegroundWindow, hWnd
.endif


Have your any idea?
Title: Re: Set Window forground
Post by: dedndave on July 20, 2014, 09:29:41 PM
SetForegroundWindow doesn't always do what you think it ought to do   :redface:

in the past, i have used this code - see if it works for you...
    xor     ecx,ecx
    INVOKE  SetWindowPos,hWnd,HWND_TOPMOST,ecx,ecx,ecx,ecx,SWP_NOMOVE or SWP_NOSIZE
    xor     ecx,ecx
    INVOKE  SetWindowPos,hWnd,HWND_NOTOPMOST,ecx,ecx,ecx,ecx,SWP_NOMOVE or SWP_NOSIZE
Title: Re: Set Window forground
Post by: ragdog on July 20, 2014, 09:38:40 PM
SetForegroundWindow doesn't always do what you think it ought to do   :redface:

Right dave i have try many apis but without good results
You code works not
Title: Re: Set Window forground
Post by: dedndave on July 20, 2014, 10:04:23 PM
then - something happens after that to set the foreground window
it may be a control or group of controls
look over the order of events - place the SetWindowPos calls after whatever it is   :P
Title: Re: Set Window forground
Post by: dedndave on July 20, 2014, 10:42:08 PM
so - you want the "main" dialog to be the foreground window after the child dialog is created ???

i guess i don't understand what you're after - it works as expected, here
Title: Re: Set Window forground
Post by: qWord on July 20, 2014, 11:12:31 PM
What about removing WS_EX_TOPMOST style from the main dialog (or using this style also for the child dialog),  setting the hWndParent of the child dialog to zero and also remove the WM_ACTIVATE handler?


Regardless that, the second dialog (DlgProc2) must be destroyed using DestroyWindow() instead of EndDialog().
Title: Re: Set Window forground
Post by: ragdog on July 26, 2014, 03:59:39 AM
Thank you i try it