BMK tweaks v2 : win32 res / icon / export saver
BlitzMax Forums/BlitzMax Module Tweaks/BMK tweaks v2 : win32 res / icon / export saver
| ||
0 - backup your BMK compiler 1 - download BMK tweak version 2: here (unzip in your Bmax folder) BMK source: here Features : ----------- - bmk SCR export : myproject.scr.bmx -> myproject.scr (not EXE) - new command: WinRes "myapp.rc" ' - new command: WinIcon (0) 'set window icon - added module : PUB.Win32Resource - added module doc resource file example: // RC file // 101 --> default icon index 101 ICON "myapp.ico" // win XP manifest 1 24 "myapp.manifest" // string table STRINGTABLE LANGUAGE 0x0000,0x0000 { 1, "my first app 2.0" } NON-MAXGUI WinRes "myApp.rc" Graphics 320,400 WinIcon Graphics 640,480 MAXGUI WinRes "myApp.rc" CreateWindow("My Window",40,40,320,240) |
| ||
@Mark A simplier solution exists for NON-MAXGUI version but a BRL mod should be modified. This solution is to register window class with a default icon: ' D3D7Graphics.bmx Function CreateHWND(width,height,fullscreen) Local hinst=GetModuleHandleA(0) Local wc:WNDCLASS=New WNDCLASS Local style,ex_style,hwnd // default icon (if exists) Local icon=LoadIconA(hinst,Byte Ptr(101));' default icon (if exists) wc.hicon=icon wc.hInstance=hinst wc.lpfnWndProc=WndProc wc.hCursor=LoadCursorA( Null,Byte Ptr IDC_ARROW ) wc.lpszClassName=DX_CLASS_NAME.ToCString() Local res=RegisterClassA( wc ) If Not res MemFree wc.lpszClassName Throw "Failed to register window class" EndIf Local wndTitle:Byte Ptr=AppTitle.ToCString() If fullscreen style=WS_VISIBLE|WS_POPUP hwnd=CreateWindowExA( 0,wc.lpszClassName,wndTitle,style,0,0,width,height,0,0,hinst,Null ) Else style=WS_VISIBLE|WS_CAPTION|WS_SYSMENU Local rect[]=[0,0,width,height] AdjustWindowRect rect,style,0 width=rect[2]-rect[0] height=rect[3]-rect[1] hwnd=CreateWindowExA( 0,wc.lpszClassName,wndTitle,style,CW_USEDEFAULT,CW_USEDEFAULT,width,height,0,0,hinst,Null ) EndIf MemFree wndTitle MemFree wc.lpszClassName If Not hwnd Throw "Failed to create window" Return hwnd End Function That's all for the moment. A DLL exporter would be nice :) |
| ||
You can also use this tool to add a manifest file in your exe by adding the following line in your rc file, 1 24 "myapp.manifest" |
| ||
Hello, iv'e gessed that there has to be an easier way to change the AppIcon during runtime :). With a little help by Suco-X we figured it out: Extern "win32" Function GetActiveWindow () Function SetClassLongA (hwnd,index,NewLong) Function ExtractIconA (hwnd,file:Byte Ptr,index) End Extern ?win32 Function SetAppIcon (file:String) If Not FileType (file) Notify "Icon "+file+" not found ..." Else Local hwnd = GetActiveWindow () Local icon = ExtractIconA (hwnd,file.ToCString(),0) SetClassLongA (hwnd,-14,icon) EndIf End Function ? Example: Global YourIcon:String = "blub.ico" test:tgadget = CreateWindow ("Test",200,200,300,200) SetAppIcon (YourIcon) While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End End Select Wend It only works with MaxGUI Windows on Windows machines. But it works !!! :) Maybe someone could port it to Linux or MacOs. greetz |
| ||
Does this solve the problem of not being able to change different windows' icons within the same MaxGUI app independently? |
| ||
no, im sorry, but every call of this function will change all icons of the current running application. It was only meant as a hint ;). Feel free to modify it... |
| ||
humm bug when doing in console , bmk makemods |
| ||
Do you use bmax 1.14 ? |