Hmm, ich weiß gar nicht warum es beim ButtonGadget funktioniert.
Normalerweise brauch man noch Set- / ReleaseCapture(). Liegt wohl and den Styles. Egal, so gehts:
Code: Alles auswählen
#GRIDSIZE = 10
Procedure WindowCallback(hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_PAINT
hdc = BeginPaint_(hwnd, ps.PAINTSTRUCT)
For x = 0 To WindowWidth(0) Step #GRIDSIZE
For y = 0 To WindowHeight(0) Step #GRIDSIZE
SetPixel_(hdc, x, y, 0)
Next
Next
EndPaint_(hwnd, ps)
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure GagdetProc(hWnd, uMsg, wParam, lParam)
Shared lpPrevFunc
Static bDragging, MTX, MTY
Select uMsg
Case #WM_LBUTTONDOWN
MTX = lParam & $FFFF
MTY = lParam>>16
bDragging = 1
SetCapture_(hwnd)
ProcedureReturn 0
Case #WM_MOUSEMOVE
If bDragging
GetCursorPos_(cpt.POINT)
ScreenToClient_(WindowID(0), cpt)
GetClientRect_(hWnd, crc.RECT)
MoveWindow_(hWnd, (cpt\x-MTX)/#GRIDSIZE*#GRIDSIZE, (cpt\y-MTY)/#GRIDSIZE*#GRIDSIZE, crc\right, crc\bottom, 1)
EndIf
Case #WM_LBUTTONUP
bDragging = 0
ReleaseCapture_()
ProcedureReturn 0
EndSelect
ProcedureReturn CallWindowProc_(lpPrevFunc, hWnd, uMsg, wParam, lParam)
EndProcedure
CreateImage(1, 100, 20)
StartDrawing(ImageOutput(1))
Box(0,0,100,20,$FF00FF)
StopDrawing()
OpenWindow(0, 0, 0, 420, 320, "void", #WS_OVERLAPPEDWINDOW | 1)
ImageGadget(0, 100, 100, 120, 30,ImageID(1))
lpPrevFunc = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @GagdetProc())
SetWindowCallback(@WindowCallback())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend