Forum | | | | Detlef Jagolski | Hallo,
Frage an unsere Experten:
Eine Anwendung übergibt die Botschaft WM_MDISETMENU, um das Menü des MDI-Rahmenfensters (Multidokumentschnittstelle), das Pop-up-Menü des Fensters oder beide auszutauschen. Ist es möglich das Menü als Owner Draw festzulegen. Alle anderen Menüpunkte sind Owner Draw. Ich habe bisher keine API Funktion gefunden.
...und wenn ja, wie geht das... Gruß
Detlef KompilierenMarkierenSeparieren
Proc MDIChildProc
Parameters Wnd&, Message&, wParam&, lParam&
If Message& = ~WM_CREATE
EndIf
If Message& = ~WM_MDIACTIVATE
If wParam& = &FALSE
hChildMenu& = ~GetSubMenu(hMenu&,1)
hNewChildMenu& = MakeLong(hChildMenu&,~GetSubMenu(~GetMenu(Wnd&),1))
SendMessage(hWndClient&,~WM_MDISETMENU,0,hNewChildMenu&)
~DrawMenuBar(hNewChildMenu&)
………………………………………………..
EndIf
ElseIf Message& = ~WM_CLOSE
SendMessage(hWndClient&,~WM_MDIDESTROY,Wnd&,0)
cc& = cc& - 1
Else
Return ~DefMDIChildProc(Wnd&, Message&, wParam&, lParam&)
EndIf
EndProc
|
| | | XProfan X4, PRFellow, Profan2Cpp - Version 2.0c-pre5, Windows 11 | 24.08.2005 ▲ |
| |
| | | | | | | |
| | Detlef Jagolski | Hallo IF,
Also ich möchte alle Menüpunkte als Owner Draw mit Icon darstellen, nicht das Standard Menü. Da aber das Menü für die MDI Fenster vom System erstellt wird, kann ich diese Menüpunkte nicht ändern.
Gruß
Detlef |
| | | XProfan X4, PRFellow, Profan2Cpp - Version 2.0c-pre5, Windows 11 | 24.08.2005 ▲ |
| |
| | | Ok - das habe ich verstanden.
Frage1: Muß es gleich OD sein - weil schöne Icons bekommst Du auch ohne OD in die Menüpunkte... Frage2: Hast Du schon ein OD-Menü entwickelt?
Salve, iF. |
| | | | |
| | Detlef Jagolski | Hallo iF,
Frage1: Das soll es schon sein. Frage2: OD-Menu habe ich entwickelt. KompilierenMarkierenSeparierenStruct MenuItemInfo = cbSize&, fMask&, fType&, fState&, wID&, hSubMenu&, hbmpChecked&, hbmpUnchecked&, dwItemData&, dwTypeData&, cch&
Struct MeasureItemStruct = ~MEASUREITEMSTRUCT
Struct DrawItemStruct = ~DRAWITEMSTRUCT
Struct Rect = ~RECT
Struct Size = ~SIZE
Struct MenuData = MenuText$(255), IconIndex&, MenuPopUp&, MenuFont&, fType&
Struct ICONINFO = ~ICONINFO
Struct BITMAP = ~BITMAP
Declare MenuItemInfo#
Declare lpmis#
Declare lpdis#
Declare Rect#
Declare TRect#
Declare GRect#
Declare Size#
Declare MenuData#[150]
Declare MyMenuData#
Declare MenuText#
Declare IconName$
Declare hImagelist&
Declare hImagelist2&
Declare CheckedImage&
Declare hIcon&
Declare hIconGray&
Declare hDll&
Declare hBitmapDll&
Declare BitmapFile$
Declare Iczz%
Declare Iccnt%
Declare Menu%
Declare MenuDC&
Declare MenuIcon&
Declare dwCheckXY&
Declare nTextWidth&
Declare nTextHeight&
Declare nImageWidth&
Declare nImageHeight&
Declare wCheckX&
Declare Bitmap$
Declare XMbgBMP&
Declare XMBrush&
Declare ItemText$
Declare MenuPen&
Declare MenuFont&
Declare OldMenuPen&
Declare hOldFont&
Declare LeftItext$
Declare RightItext$
Declare Color_IconBack&
Declare Color_Line&
Declare Color_Selected&
Declare Color_FrameRect&
Declare S#
Declare ToolBar&
Declare ToolinfoButton#
Declare t#
Declare Text#
Declare TipControl&
Dim MenuItemInfo#,MenuItemInfo
Dim lpmis#,24
Dim lpdis#,DrawItemStruct
Dim Rect#,Rect
Dim TRect#,Rect
Dim GRect#,Rect
Dim Size#,Size
Dim MenuData#[],MenuData
Dim MyMenuData#,MenuData
Dim MenuText#,255
Menu% = 0
Proc CreateGrayscaleIcon
Parameters hIcon&
Declare IconInfo#
Declare IconInfo2#
Declare Bitmap#
Declare bRetValue&
Declare hMainDC&
Declare hMemDC1&
Declare hMemDC2&
Declare dwWidth&
Declare dwHeight&
Declare hOldBmp1&
Declare hOldBmp2&
Declare dwLoopY&
Declare dwLoopX&
Declare crPixel&
Declare byNewPixel&
Declare hGrayIcon&
Dim IconInfo#,ICONINFO
Dim IconInfo2#,ICONINFO
Dim Bitmap#,BITMAP
bRetValue& = ~GetIconInfo(hIcon&,IconInfo#)
Case bRetValue& = 0: Return 0
hMainDC& = ~GetDC(0)
hMemDC1& = ~CreateCompatibleDC(hMainDC&)
hMemDC2& = ~CreateCompatibleDC(hMainDC&)
~GetObject(IconInfo#.hbmColor&, SizeOf(Bitmap#), Bitmap#)
dwWidth& = IconInfo#.xHotspot& * 2
dwHeight& = IconInfo#.yHotspot& * 2
IconInfo2#.hbmColor& = ~CreateBitmap(dwWidth&, dwHeight&, Bitmap#.bmPlanes%,Bitmap#.bmBitsPixel%,0)
hOldBmp1& = ~SelectObject(hMemDC1&, IconInfo#.hbmColor&)
hOldBmp2& = ~SelectObject(hMemDC2&, IconInfo2#.hbmColor&)
~BitBlt(hMemDC2&,0,0,dwWidth&,dwHeight&,hMemDC1&,0,0,~SRCCOPY)
crPixel& = 0
byNewPixel& = 0
dwLoopY& = 0
Whileloop dwHeight&
dwLoopX& = 0
Whileloop dwWidth&
crPixel& = ~GetPixel(hMemDC1&,dwLoopX&,dwLoopY&)
byNewPixel& = (GetRValue(crPixel&) + GetGValue(crPixel&) + GetBValue(crPixel&)) / 3
~SetPixel(hMemDC2&,dwLoopX&,dwLoopY&,RGB(byNewPixel&,byNewPixel&,byNewPixel&))
Inc dwLoopX&
EndWhile
Inc dwLoopY&
EndWhile
~SelectObject(hMemDC1&, hOldBmp1&)
~SelectObject(hMemDC2&, hOldBmp2&)
IconInfo2#.hbmMask& = IconInfo#.hbmMask&
IconInfo2#.fIcon& = 1
hGrayIcon& = ~CreateIconIndirect(IconInfo2#)
~DeleteObject(IconInfo2#.hbmColor&)
~DeleteObject(IconInfo2#.hbmMask&)
~DeleteObject(IconInfo#.hbmColor&)
~DeleteObject(IconInfo#.hbmMask&)
~DeleteDC(hMemDC1&)
~DeleteDC(hMemDC2&)
~ReleaseDC(0,hMainDC&)
Dispose IconInfo#
Dispose IconInfo2#
Dispose Bitmap#
Return hGrayIcon&
EndProc
Proc MeasureItem
MenuDC& = ~GetDC(Wnd&)
lpmis# = lParam&
If Long(lpmis#,0) = ~ODT_MENU
MyMenuData# = Long(lParam&,20)
dwCheckXY& = ~GetMenuCheckMarkDimensions()
nImageWidth& = HiWord(dwCheckXY&)
nImageHeight& = LoWord(dwCheckXY&)
wCheckX& = HiWord(dwCheckXY&)+ 10
ItemText$ = MyMenuData#.MenuText$
MenuFont& = MyMenuData#.MenuFont&
hOldFont& = ~SelectObject(MenuDC&,MenuFont&)
~GetTextExtentPoint32(MenuDC&,Addr(ItemText$),Len(ItemText$),Size#)
If MyMenuData#.fType& = ~MFT_SEPARATOR
Case Int(Val($WinVer)) = 4: Long lpmis#,12 = Size#.cx& + wCheckX& + nImageWidth& + 45
Case Int(Val($WinVer)) = 4: Long lpmis#,16 = Size#.cy& + 10
Case Int(Val($WinVer)) = 5: Long lpmis#,12 = Size#.cx&
Case Int(Val($WinVer)) = 5: Long lpmis#,16 = Size#.cy& - 5
Else
Long lpmis#,12 = Size#.cx& + wCheckX& + nImageWidth& + 45
Long lpmis#,16 = Size#.cy& + 10
~SelectObject(%HDC,hOldFont&)
EndIf
Return 1
EndIf
EndProc
Proc DrawItem
lpdis# = lParam&
If Long(lpdis#,0) = ~ODT_MENU
MyMenuData# = Long(lpdis#,44)
nTextWidth& = wCheckX& + Long(lpdis#,28)
nTextHeight& = Long(lpdis#,32)
MenuIcon& = MyMenuData#.IconIndex&
ItemText$ = MyMenuData#.MenuText$
MenuFont& = MyMenuData#.MenuFont&
Long Rect#,0 = Long(lpdis#,28)
Long Rect#,4 = Long(lpdis#,32)
Long Rect#,8 = Long(lpdis#,36)
Long Rect#,12 = Long(lpdis#,40)
Long GRect#,0 = Long(lpdis#,28)
Long GRect#,4 = Long(lpdis#,32)
Long GRect#,8 = Long(lpdis#,36) - Long(Rect#,8) + 25
Long GRect#,12 = Long(lpdis#,40)
Long TRect#,0 = Long(lpdis#,28) + wCheckX& + 8
Long TRect#,4 = Long(lpdis#,32) + 4
Long TRect#,8 = Long(lpdis#,36) - 1
Long TRect#,12 = Long(lpdis#,40)
~FillRect(lpdis#.HDC&,GRect#,~CreateSolidBrush(Color_IconBack&))
If XMBrush&
~SelectObject(lpdis#.HDC&,XMBrush&)
~PatBlt(lpdis#.hdc&,nImageWidth& + 12,Long(lpdis#,32),Long(lpdis#,36),Long(lpdis#,40) - Long(lpdis#,32),~PATCOPY)
EndIf
If MyMenuData#.fType& = ~MFT_SEPARATOR
MenuPen& = ~CreatePen(~PS_SOLID,1,Color_Line&)
OldMenuPen& = ~SelectObject(lpdis#.HDC&,MenuPen&)
~MoveToEx(lpdis#.HDC&,Long(TRect#,0),Long(TRect#,4),0)
~LineTo(lpdis#.HDC&,Long(TRect#,8),Long(TRect#,4))
~SelectObject(lpdis#.HDC&,OldMenuPen&)
EndIf
If Long(lParam&,16) & ~ODS_GRAYED
~ImageList_Draw(hImagelist2&,MenuIcon&,lpdis#.HDC&,Long(lpdis#,28)+4,Long(lpdis#,32)+4,~ILD_TRANSPARENT)
~SetTextColor(lpdis#.HDC&,~GetSysColor(~COLOR_GRAYTEXT))
Else
If Long(lParam&,16) & ~ODS_SELECTED
~FillRect(lpdis#.HDC&,Rect#,~CreateSolidBrush(Color_Selected&))
~FrameRect(lpdis#.HDC&,Rect#,~CreateSolidBrush(Color_FrameRect&))
~SetBkColor(lpdis#.HDC&,RGB(128,128,255))
~ImageList_Draw(hImagelist&,MenuIcon&,lpdis#.HDC&,Long(lpdis#,28)+4,Long(lpdis#,32)+4,~ILD_TRANSPARENT)
Else
If XMBrush&
~SelectObject(lpdis#.HDC&,XMBrush&)
~PatBlt(lpdis#.hdc&,nImageWidth& + 12,Long(lpdis#,32),Long(lpdis#,36),Long(lpdis#,40) - Long(lpdis#,32),~PATCOPY)
Else
~FillRect(lpdis#.HDC&,Rect#,~GetSysColorBrush(~COLOR_MENU))
~FillRect(lpdis#.HDC&,GRect#,~CreateSolidBrush(Color_IconBack&))
EndIf
~ImageList_Draw(hImagelist&,MenuIcon&,lpdis#.HDC&,Long(lpdis#,28)+4,Long(lpdis#,32)+4,~ILD_TRANSPARENT)
EndIf
EndIf
If Long(lParam&,16) & ~ODS_DISABLED
~ImageList_Draw(hImagelist2&,MenuIcon&,lpdis#.HDC&,Long(lpdis#,28)+4,Long(lpdis#,32)+4,~ILD_TRANSPARENT)
~SetTextColor(lpdis#.HDC&,~GetSysColor(~COLOR_GRAYTEXT))
Else
~ImageList_Draw(hImagelist&,MenuIcon&,lpdis#.HDC&,Long(lpdis#,28)+4,Long(lpdis#,32)+4,~ILD_TRANSPARENT)
~SetTextColor(lpdis#.HDC&,~GetSysColor(~COLOR_MENUTEXT))
EndIf
If Long(lParam&,16) & ~ODS_CHECKED
~ImageList_Draw(hImagelist&,CheckedImage&,lpdis#.HDC&,Long(lpdis#,28)+4,Long(lpdis#,32)+4,~ILD_TRANSPARENT)
EndIf
hOldFont& = ~SelectObject(lpdis#.HDC&,MenuFont&)
~SetBkMode(lpdis#.HDC&,~TRANSPARENT)
IfNot MyMenuData#.fType& = ~MFT_SEPARATOR
LeftItext$ = Substr$(Itemtext$,1," ") + " "
RightItext$ = Trim$(Substr$(Itemtext$,2," ")) + " "
~DrawText(lpdis#.HDC&,Addr(LeftItext$),Len(LeftItext$),TRect#,~DT_LEFT)
IfNot RightItext$ = " "
~DrawText(lpdis#.HDC&,Addr(RightItext$),Len(RightItext$),TRect#,~DT_RIGHT)
EndIf
~SelectObject(lpdis#.HDC&,hOldFont&)
EndIf
EndIf
EndProc
Proc CreateImageList
Parameters IconFile$
IconFile$ = Upper$(IconFile$)
hDll& = UseDll(IconFile$)
Iccnt% = IconCount(IconFile$) + 1
hImagelist& = ~ImageList_Create(16,16,~ILC_COLOR32 | ~ILC_MASK,500,500)
hImagelist2& = ~ImageList_Create(16,16,~ILC_COLOR32 | ~ILC_MASK,500,500)
Clear Iczz%
WhileNot Iczz% = Iccnt%
IconName$ = "#" + Trim$(Str$(Iczz%))
hIcon& = ~LoadIcon(hDll&,Addr(IconName$))
~ImageList_AddIcon(hImagelist&,hIcon&)
CreateGrayscaleIcon hIcon&
hIconGray& = @&(0)
~ImageList_AddIcon(hImagelist2&,hIconGray&)
Inc Iczz%
Wend
FreeDLL hDll&
EndProc
Proc ChangeMenuItem
Parameters hMenu&, pMenu&, Index&, Font&
with MenuItemInfo#
.cbSize& = SizeOf(MenuItemInfo#)
.fMask& = ~MIIM_DATA | ~MIIM_TYPE | ~MIIM_ID
.dwTypeData& = MenuText#
.cch& = SizeOf(MenuText#)
endwith
~GetMenuItemInfo(hMenu&,pMenu&,~MF_BYPOSITION,MenuItemInfo#)
with MenuData#[Menu%]
.MenuText$ = String$(MenuText#,0)
.IconIndex& = Index&
.MenuPopUp& = ~GetSubMenu(hMenu&,pMenu&)
.MenuFont& = Font&
.fType& = MenuItemInfo#.fType&
endwith
If MenuItemInfo#.fType& = ~MFT_SEPARATOR
with MenuItemInfo#
.fType& = ~MFT_OWNERDRAW
.fMask& = ~MIIM_DATA | ~MIIM_TYPE
.dwItemData& = MenuData#[Menu%]
endwith
~SetMenuItemInfo(hMenu&,pMenu&,~MF_BYPOSITION,MenuItemInfo#)
Else
with MenuItemInfo#
.fType& = ~MFT_OWNERDRAW
.fMask& = ~MIIM_DATA | ~MIIM_TYPE
.dwItemData& = MenuData#[Menu%]
.dwTypeData& = MenuText#
endwith
~SetMenuItemInfo(hMenu&,pMenu&,~MF_BYPOSITION,MenuItemInfo#)
EndIf
Inc Menu%
EndProc
Proc SetCheckedImage
Parameters Checked&
CheckedImage& = Checked&
EndProc
Proc SetMenuColors
Parameters IconBackColor&, LineColor&, SelectedColor&, FrameRectColor&
Color_IconBack& = IconBackColor&
Color_Line& = LineColor&
Color_Selected& = SelectedColor&
Color_FrameRect& = FrameRectColor&
EndProc
Proc SetMenuStandardColors
Color_IconBack& = RGB(212,208,200)
Color_Line& = RGB(212,208,200)
Color_Selected& = RGB(128,128,255)
Color_FrameRect& = RGB(0,0,255)
EndProc
Proc SetMenuBitmap
Parameters BitmapFile$, Bitmap$
hBitmapDll& = UseDll(BitmapFile$)
If Bitmap$ <> ""
Case XMbgBmp& : ~DeleteObject(XMbgBmp&)
Case XMBrush& : ~DeleteObject(XMBrush&)
XMbgBMP& = Create("hPic",hBitmapDll&,Bitmap$)
XMBrush& = ~CreatePatternBrush(XMbgBmp&)
FreeDLL hBitmapDll&
EndIf
EndProc
Proc DisposeXPMenu
Dispose MenuItemInfo#
Dispose MenuText#
Dispose MenuData#[]
Dispose MyMenuData#
Dispose lpdis#
Dispose lpmis#
Dispose Rect#
Dispose GRect#
Dispose TRect#
Dispose Size#
~ImageList_Destroy(hImagelist&)
~ImageList_Destroy(hImagelist2&)
~DeleteDC(MenuDC&)
~DeleteObject(MenuPen&)
~DeleteObject(OldMenuPen&)
EndProc
|
| | | XProfan X4, PRFellow, Profan2Cpp - Version 2.0c-pre5, Windows 11 | 24.08.2005 ▲ |
| |
| | | Lol - jetzt hat es Klick bei mir gemacht.
Ich weiß zwar wonach Du suchst - Du möchtest so wie ich es verstanden habe Dein ODMenü als _default setzen - quasi einen Handletausch durchführen - ob dies so gedacht ist weiß ich leider nicht , aber...
Normalerweise sollte man ja das Menü refreshen nachdem die Message ankommt - nutze doch einfach diese Message als Indikator dafür das Du das Menü selbst austauscht... |
| | | | |
| | Detlef Jagolski | Hallo,
habe noch keine Lösung, brauche noch einen Tipp.
Gute Nacht |
| | | XProfan X4, PRFellow, Profan2Cpp - Version 2.0c-pre5, Windows 11 | 25.08.2005 ▲ |
| |
|
AntwortenThemenoptionen | 1.176 Betrachtungen |
ThemeninformationenDieses Thema hat 2 Teilnehmer: |