News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Set Window forground

Started by ragdog, July 20, 2014, 07:45:31 PM

Previous topic - Next topic

ragdog

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?

dedndave

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

ragdog

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

dedndave

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

dedndave

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

qWord

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().
MREAL macros - when you need floating point arithmetic while assembling!

ragdog