Is this windows style possible?
BlitzMax Forums/MaxGUI Module/Is this windows style possible?
| ||
I don't know what it is, but I really like this look. Is it possible with MaxGUI?:![]() |
| ||
Do a search on the forum for manifest files. I can't recall how to do it exactly, but it's possible to make things look more like XP... |
| ||
The yourapp.exe.manifest solution doesn't do anything to the menus. |
| ||
Neither does any Windows XP skins ;) Those menus are "owner drawn", eg application specific. |
| ||
Owner drawn menus are relatively easy to do but there's the problem of making them platform independent. In Windows one has to set the menu property to "owner drawn" and than respond to messages like WM_DRAWITME and WM_MEASUREITEM. I am sure Macintosh is using something similar but differently so that owner drawn menus would require separate code for each platform. Also, note that menus can also be drawn as toolboxes on rebar, which is technique used in MS Office, but even then one has to use owner drawn technique to get the looks one wants. Barney |
| ||
looks to me like its using the winapi SetMenuItemBitmaps() |
| ||
Yes. You can use SetMenuItemBitmaps but then you have to create absolutely everything and in any case you have to look for the windows messages I've mentioned. Barney |
| ||
Hmmmm...for some reason I am having problems with LoadBitmap(). I tried both lpBitmapName$ and lpBitmapName$z: Extern "Win32" Function LoadBitmap:Int(hInstance,lpBitmapName$)="LoadBitmapA@8" Function SetMenuItemBitmaps:Int(hMenu,uPosition,uFlags,hBitmapUnchecked,hBitmapChecked)="SetMenuItemBitmaps@20" EndExtern I am trying to load a 16x16 bitmap. It always returns 0. |
| ||
Okay, I was able to load it with LoadImageA...not sure why LoadBitmap doesn't work. Still no visible effect when I try to set the menu image. root=WindowMenu(window) menu:TGadget=CreateMenu("File",0,root) submenu:TGadget=CreateMenu("Open...",MENU_OPEN,menu,KEY_O,MODIFIER_CONTROL) hmenu=QueryGadget(menu,QUERY_HWND) hbitmap=LoadImageA(Null,AppDir$+"\gfx\icon_new.bmp",0,0,0,$10) Notify SetMenuItemBitmaps(hmenu,0,1024,hbitmap,hbitmap) |
| ||
Here's an example. I can only get the menu handle by querying the root menu. I can load the bitmap successfully. However, SetMenuItemBitmaps always fails. Everything I have read indicates that this should work, unless Blitz is doing something weird internally:Extern "Win32" Function LoadImageA:Int(hInst%,filename$z,typ%,desiredX%,desiredY%,fuLoad%) Function LoadBitmap:Int(hInstance,lpBitmapName$)="LoadBitmapA@8" Function SetMenuItemBitmaps:Int(hMenu,uPosition,uFlags,hBitmapUnchecked,hBitmapChecked)="SetMenuItemBitmaps@20" EndExtern w=400 h=300 style=WINDOW_TITLEBAR+WINDOW_RESIZABLE+WINDOW_STATUS+WINDOW_MENU window:tgadget=CreateWindow("Menu Icons",(ClientWidth(Desktop())-w)/2,(ClientHeight(Desktop())-h)/2,w,h,Null,style) root:TGadget=WindowMenu(window) menu:TGadget=CreateMenu("File",0,root) menuitem:TGadget=CreateMenu("Open...",69,menu) UpdateWindowMenu window hbitmap=LoadImageA(Null,AppDir$+"\test.bmp",0,0,0,$10) If hbitmap hmenu=QueryGadget(root,QUERY_HWND) If hmenu result=SetMenuItemBitmaps(hmenu,1,1024,hbitmap,hbitmap) If Not result Notify "SetMenuItemBitmaps() failed." Else Notify "Failed to retrieve menu handle." EndIf Else Notify "LoadImageA() failed." EndIf Repeat Select WaitEvent() Case EVENT_WINDOWCLOSE End EndSelect Forever |
| ||
You can try win32 { GetMenu( hwnd ) } on a window Query(QUERY_HWND) to get the root menu. eg Local mainmenu=GetMenu(WindowMenu(window).query(QUERY_HWND)) The demo below works so shouldnt be to hard to change to suit multiple images etc The only problem is when you later come to UncheckMenu/CheckMenu. You'll loose the image totally so really its a little dodgey doing it this way. 'checkmenu image change 'by Birdie Strict Extern "win32" Function LoadImage_( hInst, fName$z, uType, dx, dy, fuLoad ) = "LoadImageA@24" Function SetMenuItemBitmaps( hMenu, uPosition, uFlags, hBitUnChecked, hBitChecked ) = "SetMenuItemBitmaps@20" Function GetMenu( hWnd ) = "GetMenu@4" Function GetSubMenu( hMenu, pos ) = "GetSubMenu@8" EndExtern Local window:TGadget = CreateWindow("Test",0,0,640,480,Desktop(),WINDOW_MENU|WINDOW_TITLEBAR|WINDOW_STATUS) Local file:TGadget = CreateMenu("&File",1,WindowMenu(window)) Local open:TGadget = CreateMenu("Open",101,file) CreateMenu("Save",102,file) CreateMenu("Exit",199,file) Local edit:TGadget = CreateMenu("Edit",201,WindowMenu(window)) CreateMenu("Paste",202,edit) UpdateWindowMenu WindowMenu(window) Local bi = loadimage_( 0,CurrentDir()+"/logo.bmp",0,0,0,$10 ) Local mainmenu=GetMenu(WindowMenu(window).query(QUERY_HWND)) AddImage mainmenu, bi While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End EndSelect Wend Function AddImage( root_menu, bitmap ) Local INDEX=0 Local sub_menu Local done = 0 Repeat sub_menu = GetSubMenu( root_menu, index ) If sub_menu AddImage sub_menu,bitmap EndIf If SetMenuItemBitmaps( root_menu, index, MF_BYPOSITION, bitmap, bitmap ) = 0 done = True EndIf index :+1 Until done EndFunction |
| ||
Thanks. The only problem now is that the menu items need to be spaced out more, because they are way too crowded with the icons. |
| ||
try using GetSystemMetrics(SM_CXMENUCHECK) for loading images the correct size. |
| ||
Any program that has icons in the menus has more spacing around the menu items. Looking at Paint Shop Pro, the icons they use are the same as standard toolbar icons (16x16). So you still need to space out the menus a bit. |