| |
|
|
| TrackMenu SubClass OwnerDraw [...]
Andreas Miethe
Ist auf die Schnelle zusammenkopiert, also noch nicht ganz ausgereift. 'Header-Dateien
$H windows.ph
$H messages.ph
Declare Ende&
Declare Rect1#,hIcon1&,lpmis#,Size#
Dim Rect1#,16
Dim lpmis#,24
Dim Size#,8
Declare MyItem#[3]'reicht für 4 Einträge
Struct Item = Eintrag&,Icon&
Dim MyItem#[],Item
Var Text$ = "Info"
Var Text2$ = "Beenden"
MyItem#[0].Eintrag& = Addr(Text$)
MyItem#[1].Eintrag& = Addr(Text2$)
MyItem#[0].Icon& = ~LoadIcon(%hInstance,"A")
MyItem#[1].Icon& = ~LoadIcon(%hInstance,"Eimer")
Proc Menue
CreateMenu
AppendMenu 101, "Info"
~ModifyMenu(&hMenu,101,~MF_BYCOMMAND | ~MF_OWNERDRAW,101,MyItem#[0])
AppendMenu 103, "Beenden"
~ModifyMenu(&hMenu,103,~MF_BYCOMMAND | ~MF_OWNERDRAW,103,MyItem#[1])
Return @TrackMenu()
EndProc
Windowstyle 26 + 512
WindowTitle "Test"
Window 0,0-640,480
SubClass %HWnd, 1
Whilenot Ende&
Waitinput
If %MousePressed = 2'Rechter Mausbutton gedrückt
Menue()
If (%MenuItem = 101)
@Messagebox("Programmiert in XProfan 11","Hinweis",64)
ElseIf (%MenuItem = 103)
Ende&=1
EndIf
Endif
Endwhile
Dispose Rect1#,lpmis#,Size#
End
SubClassProc
If SubClassMessage(%hWnd,~WM_MEASUREITEM)
lpmis# = &slParam
~GetTextExtentPoint32(%hdc,Long(Long(&slParam,20),0),Len(String$(Long(Long(&slParam,20),0),0)),Size#)
Long lpmis#,12 = Long(Size#,0)
Set("WinProc", 0)
ElseIf SubClassMessage(%hWnd,~WM_DRAWITEM)
IF Long(&slParam,16) & 1'wenn selektiert
~SetTextColor(Long(&slParam,24),$FFFFFF)
~SetBkColor(Long(&slParam,24),$8000)
Else
~SetTextColor(Long(&slParam,24),0)
~SetBkColor(Long(&slParam,24),$FCFDC8)
EndIf
'Rechteck für die Ausgabe ermitteln
Long Rect1#,0 = Long(&slParam,28)'X
Long Rect1#,4 = Long(&slParam,32)'Y
Long Rect1#,8 = Long(&slParam,36)'Breite
Long Rect1#,12 =Long(&slParam,40)'Höhe
'Ausgabe
~ExtTextOut(Long(&slParam,24),Long(&slParam,28)+20,Long(&slParam,32),~ETO_OPAQUE,Rect1#,Long(Long(&slParam,44),0),Len(String$(Long(Long(&slParam,44),0),0)) ,0)
~DrawIconEx(Long(&slParam,24),0,Long(&slParam,32),Long(Long(&slParam,44),4),13,13,0,0,~DI_NORMAL)
Set("WinProc", 0)
EndIf
EndProc
|
|
|
| |
|
|