running on XP

...and older versions


Code: Select all
; Yet another useless program by netmaestro
;
; because there just aren't enough useless programs
;
pathiconup$ = "d:\pencilup.ico" ; Put your own path here
pathicondn$ = "d:\pencildown.ico" ; put your own path here
Global pencilup=LoadImage_(GetModuleHandle_(0),pathiconup$,#IMAGE_ICON,0,0,#LR_LOADFROMFILE)
Global pencildown=LoadImage_(GetModuleHandle_(0),pathicondn$,#IMAGE_ICON,0,0,#LR_LOADFROMFILE)
Procedure ButtonAction()
SetGadgetText(0, GetGadgetText(0)+"Pencil... ")
EndProcedure
Procedure MouseOnButton()
GetCursorPos_(@pt.point)
If pt\x >= WindowX(0)+540 And pt\x <= WindowX(0)+560
If pt\y >=WindowY(0)+5 And pt\y <= WindowY(0)+25
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndIf
EndProcedure
Procedure ProcessTitleButtons()
If MouseOnButton()
While GetAsyncKeyState_(#VK_LBUTTON) & 32768
If MouseOnButton()
DrawIconEx_(GetWindowDC_(WindowID(0)), 540,7, pencildown, 18, 18, 0, #Null, #DI_NORMAL )
Else
DrawIconEx_(GetWindowDC_(WindowID(0)), 540,7, pencilup, 18, 18, 0, #Null, #DI_NORMAL )
EndIf
Delay(1)
Wend
While WindowEvent():Wend
If MouseOnButton()
ButtonAction()
EndIf
DrawIconEx_(GetWindowDC_(WindowID(0)), 540,7, pencilup, 18, 18, 0, #Null, #DI_NORMAL )
EndIf
EndProcedure
Procedure CallBack(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_PAINT,#WM_ACTIVATE,#WM_MOVE
DrawIconEx_(GetWindowDC_(WindowID(0)), 540,7, pencilup, 18, 18, 0, #Null, #DI_NORMAL )
Case #WM_SYSCOMMAND
ProcessTitleButtons()
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"TitleBarButton Example by netmaestro",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
SetWindowCallback(@CallBack())
CreateGadgetList(WindowID(0))
TextGadget(0,220,200,240,200,"")
Repeat : Until WaitWindowEvent() = #WM_CLOSE
End