Bitte einfach die Board-Suche nutzen.
Beispielsweise ein Beispielcode aus dem Jahre 2010:
http://www.purebasic.fr/english/viewtop ... 93#p338593
Code ein wenig geändert:
Code: Alles auswählen
Global x,y,buttonW,buttonH,borderW
Procedure WndProc(hwnd, uMsg, wParam, lParam)
GetWindowRect_(WindowID(1),r.RECT)
;x = r\right - (buttonW*5) - borderW ;5 = for Max & Restore & Min and 2 more buttons
x = r\left
y = r\top
If OSVersion() <= #PB_OS_Windows_XP
y = y + 5
Else
;x = x + 10
;x = x - 400
EndIf
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
Case #WM_GETMINMAXINFO
*pMinMax.MINMAXINFO = lParam
*pMinMax\ptMinTrackSize\x=buttonW*5
Case #WM_SIZE,#WM_MOVE,#WM_PAINT
If GetWindowState(1) = #PB_Window_Maximize
ResizeWindow(2,x,y+4,buttonW*2,buttonH)
Else
ResizeWindow(2,x,y,buttonW*2,buttonH)
EndIf
EndSelect
ProcedureReturn result
EndProcedure
UsePNGImageDecoder()
LoadImage(0, "C:\abc\state1.png") ;24 x 24 pixel Button state 1
LoadImage(1, "C:\abc\state2.png") ;24 x 24 pixel Button state 2
buttonW = GetSystemMetrics_(#SM_CXSIZE)
buttonH = GetSystemMetrics_(#SM_CYSIZE)
borderW = GetSystemMetrics_(#SM_CXBORDER)
OpenWindow(1,0,0,600,400,"Add Button to Title Bar", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
OpenWindow(2,0,0,buttonW*2,buttonH,"",#WS_POPUP,WindowID(1))
SetWindowColor(2,#Red)
SetWindowLong_(WindowID(2),#GWL_EXSTYLE,GetWindowLong_(WindowID(2),#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(WindowID(2),#Red,0,#LWA_COLORKEY)
ImageGadget(10,2,0,30,20,ImageID(0))
ImageGadget(11,28,0,30,20,ImageID(0))
SetWindowCallback(@WndProc())
SetActiveWindow(1)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Q = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 10
Debug "Button 10 Pressed"
Case 11
Debug "Button 11 Pressed"
EndSelect
SetActiveWindow(1)
Case #WM_MOUSEMOVE
GetCursorPos_(@p.POINT)
If p\x >= x+5 And p\x <= x+30 And p\y >= y+4 And p\y <=y+25
SetGadgetState(10,ImageID(1))
Else
SetGadgetState(10,ImageID(0))
EndIf
If p\x >= x+35 And p\x <= x+55 And p\y >= y+4 And p\y <=y+25
SetGadgetState(11,ImageID(1))
Else
SetGadgetState(11,ImageID(0))
EndIf
EndSelect
Until Q =1
End
PS: Pfad zur Grafiken vorher anpassen.