I want to make a floating window like the Find Window with notepad. It is to remain on top of the main window but also allow the main window to be the active window. It should also be hidden when the main window is minimized. I have tried using the WM_WINDOWPOSCHANGING message to see when either window is becoming the top window but the WINDOWPOS.hwndInsertAfter member does not contain HWND_TOP as expected.
Thanks for your time and consideration.
Darrel
AFAIK the Find window for notepad is just a normal modeless dialog with notepad as the owner window. A quick and dirty example:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
include \masm32\include\masm32rt.inc
; This extends the dialog macros to do modeless dialogs.
;
CallModelessDialog MACRO Instance,Parent,DlgProc,lParamInit
invoke CreateDialogIndirectParam,Instance,esi,Parent,
ADDR DlgProc,lParamInit
push eax ;; preserve return value
invoke GlobalFree,esi ;; free memory
pop eax ;; restore return value
pop edi
pop esi
ENDM
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.data
hInst dd 0
hMainDlg dd 0
hChildDlg dd 0
msg MSG <>
.code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
ChildDialogProc proc hDlg:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg == WM_INITDIALOG
.elseif uMsg == WM_CLOSE
invoke DestroyWindow, hDlg
.endif
xor eax, eax
ret
ChildDialogProc endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
MainDialogProc proc hDlg:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg == WM_INITDIALOG
Dialog "Child Dialog","MS Sans Serif",10, \
WS_OVERLAPPED or WS_SYSMENU or DS_CENTER or WS_VISIBLE, \
0,0,0,120,90,1024
CallModelessDialog hInst,hDlg,ChildDialogProc,NULL
mov hChildDlg, eax
.elseif uMsg == WM_CLOSE
invoke DestroyWindow, hDlg
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,0
.endif
xor eax, eax
ret
MainDialogProc endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
invoke GetModuleHandle, 0
mov hInst, eax
; A modeless dialog must include the WS_VISIBLE style to be visible.
;
Dialog "Main Dialog","MS Sans Serif",10, \
WS_OVERLAPPEDWINDOW or DS_CENTER or WS_VISIBLE, \
0,0,0,200,150,1024
CallModelessDialog hInst,0,MainDialogProc,0
mov hMainDlg, eax
msgLoop:
invoke GetMessage,ADDR msg,0,0,0
.IF (eax != 0)
invoke IsDialogMessage,hMainDlg,ADDR msg
.IF (eax == 0)
invoke IsDialogMessage,hChildDlg,ADDR msg
.ENDIF
jmp msgLoop
.ENDIF
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
Thanks
Michael,
Thanks for the "CallModelessDialog" macro, I would be more than pleased to add it to the DIALOGS include file if its OK with you.
QuoteI would be more than pleased to add it to the DIALOGS include file if its OK with you.
Sure. Starting with the CallModalDialog macro and having to change 29 characters was hard work :)
Gratsie,
The deed is done. :bg
I would also suggest using SetWindowPos on child widow with SWP_NOACTIVATE flag