Main problem is the ImageGadget will not fill the window as it is.
Am I just asking too much of ImageGadget?
Code: Select all
Dim mousePoint.POINT(1)
GetCursorPos_(mousePoint(1))
x = mousePoint(1)\x
y = mousePoint(1)\y
myX = 400
myY = 300
;
wnd = OpenWindow(0, x-myx/2, y-myy/2, myx, myy, "", #PB_Window_BorderLess)
GetCursorPos_(mousePoint(1))
ImageGadget(1, 0, 0, myx, myy, 0, #PB_Image_Border)
FrameGadget(2, 0, 0, myX+8, myY+8, "")
ResizeGadget(1, #PB_Ignore, #PB_Ignore, 500, 400)
CreateImage(0, myX, myY)
Debug "Gadget bounds: " + Str(GadgetX(1)) + ", " + Str(GadgetY(1)) + ", " + Str(GadgetWidth(1)) + ", " + Str(GadgetHeight(1))
HDC = GetDC_(0)
AddWindowTimer(0, 100, 10)
PointColor = GetPixel_(HDC, x, y)
hdcImage = StartDrawing(ImageOutput(0))
If hdcImage
x - myX/10
If x < 0 : x = 0 : EndIf
y - myY/10
If y < 0 : y = 0 : EndIf
StretchBlt_(hdcImage, 0, 0, myX, myY, HDC, x, y, myX/5, myY/5, #SRCCOPY)
StopDrawing()
SetGadgetState(0, ImageID(0))
; The next line tied to "SendMessage WM_NCLBUTTONDOWN, HTCAPTION" line allows dragging window.
SetWindowLong_(GadgetID(1), #GWL_STYLE, GetWindowLong_(GadgetID(1), #GWL_STYLE) &~#SS_NOTIFY)
SetForegroundWindow_(WindowID(0))
SetActiveWindow_(WindowID(0))
SetActiveWindow(0)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Timer
If GetForegroundWindow_() = WindowID(0)
If EventTimer() = 100
x = DesktopMouseX()
y = DesktopMouseY()
GetCursorPos_(mousePoint(1))
PointColor = GetPixel_(HDC, x, y)
hdcImage = StartDrawing(ImageOutput(0))
If hdcImage
Xold = x
Yold = y
x - myX/10
If x < 0 : x = 0 : EndIf
y - myY/10
If y < 0 : y = 0 : EndIf
StretchBlt_(hdcImage, 0, 0, myX, myY, HDC, DesktopMouseX() - myX/10 - 40, DesktopMouseY() - myY/10 - 80, myX/5, myY/5, #SRCCOPY)
Result.d = DrawText(10, 20, "Mouse: " + Str(x) + ", " + Str(y))
StopDrawing()
SetGadgetState(1, ImageID(0))
EndIf
EndIf
Else
Event = #PB_Event_CloseWindow
EndIf
Case #WM_LBUTTONUP ; Only detected if double clicked on magnivur
Event = #PB_Event_CloseWindow
Case #WM_LBUTTONDOWN ;, Window dragging dependant on "Left Button Down"
; The next line tied to "SetWindowLong_GetWindowLong" line allows dragging window.
SendMessage_(wnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
Case #WM_KEYDOWN
Debug "Keyd"
; Case #WM_KEYUP
; Event = #PB_Event_CloseWindow
; Debug "Keyu"
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf



