Ooops
October 27, 2021, 03:46:05

Author Topic: Remove icon from window titlebar?  (Read 818 times)

Offline chalky

  • Jr. Member
  • **
  • Posts: 88
Remove icon from window titlebar?
« on: June 14, 2021, 23:31:57 »
I am trying to remove an icon from a MaxGUI window during runtime. The reason for this is that I need to emulate the Notify/Proceed/Confirm requestors as they must be displayed while a clock is being continually updated in my main loop (since this is no longer executed while the requestors are displayed, the clock freezes). I know I could create the dialog window using the WINDOW_TOOL flag, but would prefer not to if possible. I have come up with the following code after searching the net for C++ examples:

Code: [Select]
Extern "win32"
Function GetWindowLong:Int(hWnd:Int,nIndex:Int)="GetWindowLongA@8"
Function SendMessageW:Int(hWnd:Int,MSG:Int,wParam:Int,lParam:Int)
Function SetWindowLong:Int(hWnd:Int,nIndex:Int,dwNewLong:Int)="SetWindowLongA@12"
Function SetWindowPos:Int(hWnd:Int,hAfter:Int,x:Int,y:Int,w:Int,h:Int,flags:Int)
End Extern

Const ICON_SMALL:Int=0
Const ICON_BIG:Int=1

Const GWL_EXSTYLE:Int=-20

Const SWP_NOSIZE:Int=1
Const SWP_NOMOVE:Int=2
Const SWP_NOZORDER:Int=4
Const SWP_FRAMECHANGED:Int=$20

Const WM_SETICON:Int=$80

Const WS_EX_DLGMODALFRAME:Int=$1

Function ccDelIcon(wHandle:Int)
Local exStyle:Int

exStyle=GetWindowLong(wHandle,GWL_EXSTYLE)
SetWindowLong(wHandle,GWL_EXSTYLE,exStyle|WS_EX_DLGMODALFRAME)
' remove icons
SendMessageW(wHandle,WM_SETICON,ICON_SMALL,Null)
SendMessageW(wHandle,WM_SETICON,ICON_BIG,Null)
' Update the window's non-client area to reflect the changes
SetWindowPos(wHandle,Null,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED)
EndFunction

This works perfectly if I compile and run it from within BLide (the dialog is displayed without an icon in the top left corner). However, as soon as I compile an external executable and run it, the dialog window 'inherits' the main window's icon (even if I specify group=Null in CreateWindow) - and the icon is no longer removed.

What am I missing in my code - or is what I'm trying to do not possible?

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal