See this example. The button borders aren't drawn so it just looks like a black square. Click on it somewhere around the middle to see it update and fail to send an updated paint message:
Code: Select all
#ButtonGadget=1
Structure G_State
*oldWndProc
EndStructure
Global g_State.G_State
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
Protected paint.PAINTSTRUCT
Protected fill.RECT
Select uMsg
Case #WM_PAINT
If hWnd=GadgetID(#ButtonGadget)
hDC=BeginPaint_(hWnd,@paint)
SetRect_(@fill.RECT,10,10,70,70)
FillRect_(hDC,@fill,GetStockObject_(#BLACK_BRUSH))
EndPaint_(hWnd,@paint)
ProcedureReturn 0
EndIf
EndSelect
ProcedureReturn CallWindowProc_(g_State\oldWndProc,hWnd,uMsg,wParam,lParam)
EndProcedure
OpenWindow(0,10,10,132,103,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ButtonGadget(#ButtonGadget,10,10,60,60,"")
g_State\oldWndProc=GetWindowLongPtr_(GadgetID(#ButtonGadget),#GWL_WNDPROC)
SetWindowLongPtr_(GadgetID(#ButtonGadget),#GWL_WNDPROC,@WinCallback())
Repeat
Until WaitWindowEvent(1)=#PB_Event_CloseWindow