While fiddling with GetModulehandle and GetModulehandleEx functions, I have realized that I cannot get icon be showed on title bar if I use GetModuleHandleEx
I made a modal dialog app using a resource file and using DialogBoxParam function:
WinMainCRTStartup proc
invoke GetModuleHandle,0
mov hInstance, rax
.if(rax == 0)
invoke ExitProcess,NULL
.endif
invoke GetCommandLine
mov CommandLine,rax
invoke InitCommonControls
mov icc.dwSize, sizeof INITCOMMONCONTROLSEX
mov icc.dwICC, ICC_COOL_CLASSES or ICC_STANDARD_CLASSES or ICC_WIN95_CLASSES
invoke InitCommonControlsEx, addr icc
invoke WinMain,hInstance, NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
ret
WinMainCRTStartup endp
WinMain proc hInst:HINSTANCE, hPrevInstance:HINSTANCE, lpCmdLine:LPSTR, nCmdShow:DWORD
invoke DialogBoxParam,hInst, IDD_DLG1, 0, addr DlgProc, NULL
invoke ExitProcess,NULL
WinMain endp
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_INITDIALOG
invoke LoadIcon,hInstance,10
invoke SendMessage,hWnd,WM_SETICON,ICON_SMALL,rax
ret TRUE
.elseif uMsg==WM_COMMAND
; code of controls, buttons, checkboxes...
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,0
ret
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
end
In the code above I have used GetModuleHandle and I can see the icon on title bar. Bu if I change GetModuleHandle to GetModuleHandleEx I cannot get icon on title bar:
invoke GetModuleHandleEx,0,0,hInstance
.if(rax {} 0)
invoke ExitProcess,NULL
.endif
* I am using latest MASM64 SDK
* I have GetModulehandleEx 's flag parameters
* I have attached sources