Remove Window Icon [Solved]
BlitzMax Forums/MaxGUI Module/Remove Window Icon [Solved]
| ||
... |
| ||
Anyone knows how to remove the default window icon when using CreateWindow? Nothing specified in the manual re that part. |
| ||
You need to use the OS API, as the window decoration (icon, caption text, border etc.) is managed by that. For Windows there seems to be two ways: Use SendMessage with a null icon parameter: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632643(v=vs.85).aspx Or SetWindowLong: http://stackoverflow.com/a/10833540 |
| ||
Thanks Kryzon. I know I have checked on this before here and found the solution but with the tons of info and discussions here I seem to get lost sometimes. :-) |
| ||
If you have MinGW you can also use windres and make a resource object with the icon, which in turn can be baked into the executable. Any MaxGUI window will then use that icon. |
| ||
hey grable, my problem is taking it out. Maybe I should create a resource file with a null value for the icon, just like Kryzon suggested. |
| ||
Ah, my mistake. You can try this, but it will remove the other buttons as well: SetWindowLongA( hwnd, GWL_STYLE, GetWindowLongA( hwnd, GWL_STYLE) & ~WS_SYSMENU)Or change it into a toolwindow, though it wont look like or behave like a normal window any longer: SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA( hwnd, GWL_EXSTYLE) | WS_EX_TOOLWINDOW)Other then that, you would have to resort to overriding the NC region of the window and draw the titlebar yourself. EDIT: Found this when searching https://stackoverflow.com/questions/3096359/wpf-remove-system-menu-icon-from-modal-window-but-not-main-app-window#3364875 EDIT2: Couldnt get it to work after all, had a typo.. but the below works to an extent: Local exstyle:Int = GetWindowLongA( hwnd, GWL_EXSTYLE) ' SetWindowLongA( hwnd, GWL_EXSTYLE, exstyle | WS_EX_DLGMODALFRAME) SetWindowLongA( hwnd, GWL_EXSTYLE, exstyle | WS_EX_TOOLWINDOW) SendMessageA( hwnd, WM_SETICON, ICON_SMALL, 0) SendMessageA( hwnd, WM_SETICON, ICON_BIG, 0) SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED) Note that im on Windows 10, so this might work differently on other versions. |
| ||
Thanks grable. It doesn't seem to be working, I'm using Win7. The window title icon is what I'm after not the app btw. I guess that will be the small part? |
| ||
All 3 options worked for me, and the two top ones arent anything special so should work on versions >= win2k. If they dont for you, try forcing an update of the frame by using that last line with SetWindowPos. The window title icon is what I'm after not the app btw. I guess that will be the small part? Yes, the titlebar icon is what it removes.Im not sure how windows handles small/big, it might make a small one out of a big one or vica versa of one of them is set. Youd have to test with a custom icon to notice i guess. EDIT: Note that the original link uses WS_EX_DLGMODALFRAME, which did nothing for me. So i used WS_EX_TOOLWINDOW instead which did. |
| ||
Thanks. would you mind posting your bmx source? Maybe I'm just doing something wrong. |
| ||
I tried a NULL icon on the manifest but it won't compile. |
| ||
I tested this on a window created by Graphics, and since it isnt resizable it works differently than with windows created by MaxGUI. And there is also some flags that are cached by windows which means they cannot be changed after a window has been created (like WS_EX_DLGMODALFRAME) And a bunch of other arbitrary rules about dialogs vs windows sigh... What it boils down to is that a change to MaxGUI is required for no icon AND having all the other buttons intact. Specifically the flag WS_EX_DLGMODALFRAME must be used on creation. If you dont mind having no min&max buttons, you can use the MaxGUI window flag WINDOW_TOOL (didnt know MaxGUI had this hehe) But after some fussing about, i managed to fool MaxGUI into the proper behaviour, though it might cause issues because of the hidden parent window. The code below, forces MaxGUI to create the second window as a Dialog window, which has no icon. It also hides the first window but still allows it to appear on the taskbar, since Dialogs dont show up there. SuperStrict Import MaxGUI.Drivers Local hidden:TGadget = CreateHiddenWindow("hidden") 'NOTE: WINDOW_CENTER doesnt appear to work Local w:TGadget = CreateWindow( "test", 300,300, 640,480, hidden, WINDOW_TITLEBAR | WINDOW_RESIZABLE) While WaitEvent() Select CurrentEvent.ID Case EVENT_WINDOWCLOSE Exit EndSelect Wend End Function CreateHiddenWindow:TGadget( title:String = Null) Local win:TGadget = CreateWindow( title, 0,0,0,0, Null, WINDOW_HIDDEN) Local hwnd:Int = win.Query(QUERY_HWND) ShowWindow( hwnd, SW_SHOW) Return win EndFunction EDIT: Oh, and heres the testbed i used if you want to continue trying yourself ;) |
| ||
thanks grable, the first example did it! awesome, problem solved :D |
| ||
Happy to help :) Note that i simplified the sample above, dont need that SetWindowLong after all. |
| ||
ok got it thanks. :) |
| ||
Nice stuff grable. |