OPTIONS "C_CALL LABELCHECK WINFUNC NOSOURCE"
LIBRARY rexxgui
DO
FUNCDEF("SetROP2", "32, void, 32u", "gdi32")
FUNCDEF("GetDC", "void, void", "user32")
FUNCDEF("ReleaseDC", "32, void, void", "user32")
FUNCDEF("Rectangle", "32, void, 32, 32, 32, 32", "gdi32")
FUNCDEF("SetCapture", "void, void", "user32")
FUNCDEF("ReleaseCapture", "32,", "user32")
rect = "32,32,32,32"
point = "32,32"
FUNCDEF("GetWindowRect", "32, void, struct RECT stor", "user32")
FUNCDEF("ScreenToClient", "32, void, struct POINT dual", "user32")
FUNCDEF("IntersectRect", "32, struct RECT stor, struct RECT, struct RECT", "user32")
CATCH FAILURE
CONDITION("M")
RETURN
END
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')
isdragging = 0
again:
DO FOREVER
guigetmsg()
IF EXISTS('GuiObject') == 0 THEN DO
IF EXISTS('GuiSignal') THEN DO
END
END
CATCH SYNTAX
CONDITION('M')
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_lbuttondown:
rubberband.1 = ARG(2)
rubberband.2 = ARG(2)
rubberband.3 = ARG(3)
rubberband.4 = ARG(3)
drawselectionbox(guiwindow, rubberband.)
setcapture(guiwindow)
isdragging = 1
RETURN ""
wm_lbuttonup:
IF isdragging \= 1 THEN RETURN ""
drawselectionbox(guiwindow, rubberband.)
isdragging = 0
releasecapture()
temp = rubberband.2
rubberband.2 = rubberband.3
rubberband.3 = temp
IF rubberband.1 > rubberband.3 THEN DO
temp = rubberband.3
rubberband.3 = rubberband.1
rubberband.1 = temp
END
IF rubberband.2 > rubberband.4 THEN DO
temp = rubberband.4
rubberband.4 = rubberband.2
rubberband.2 = temp
END
guisay("Selected area:" || '0D0A'x || "X =" rubberband.1 || '0D0A'x || "Y =" rubberband.2 || '0D0A'x || "Width =" rubberband.3 - rubberband.1 || '0D0A'x || "Height =" rubberband.4 - rubberband.2)
guiinfo('CHILD', guiwindow, 'FindControlsWithinBox')
RETURN ""
wm_mousemove:
IF isdragging = 1 THEN DO
drawselectionbox(guiwindow, rubberband.)
rubberband.2 = ARG(2)
rubberband.4 = ARG(3)
drawselectionbox(guiwindow, rubberband.)
END
RETURN ""
drawselectionbox: USE ARG window, rect.
hdc = getdc(window)
setrop2(hdc, 7)
rectangle(hdc, rect.1, rect.3, rect.2, rect.4)
releasedc(window, hdc)
RETURN
findcontrolswithinbox:
child = ARG(1)
getwindowrect(child, childrect)
screentoclient(guiwindow, childrect)
temp.1 = childrect.3
temp.2 = childrect.4
screentoclient(guiwindow, temp)
childrect.3 = temp.1
childrect.4 = temp.2
IF intersectrect(temp, rubberband, childrect) == 1 THEN guisay("Control" ARG(2) "is within the selection box.")
RETURN 1
|
|