06-12-2013, 04:24 AM
Function dialog_select_rectangle
Function DSR_Drag
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str sb3
rget sb3 "Wallpaper" "Control Panel\Desktop"
if(!ShowDialog("dialog_select_rectangle" &dialog_select_rectangle &controls)) ret
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Static 0x5400000E 0x0 0 0 16 16 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030506 "*" "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_LBUTTONDOWN goto dragCrop
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;dragCrop
type DSR2387 hwnd RECT'r __Hdc'hdc !notFirstTime
DSR2387 d.hwnd=id(3 hDlg)
POINT p; xm p d.hwnd 1; memcpy &d.r &p 8
d.hdc.Init(d.hwnd)
int ok=Drag(hDlg &DSR_Drag &d)
if(!ok or IsRectEmpty(&d.r)) ret
__MemBmp mb.Create(d.r.right-d.r.left d.r.bottom-d.r.top d.hdc d.r.left d.r.top)
SaveBitmap mb.bm "$temp$\crop.bmp"
run "$temp$\crop.bmp"
ret;/dialog_select_rectangle
function# button DSR2387&d
;Callback function for Drag.
;button - mouse button: 0 while dragging, 1 left up, 2 right up.
;param - param passed to Drag().
;Return:
;;;If button 0 (mouse move), return cursor handle, or 0 to not change cursor, or 1-3 to use standard cursors: 1 move, 2 copy, 3 no operation, 4,5 (QM 2.3.4) red and blue cross.
;;;Else (mouse button up), can return any value. Drag() returns it.
if(!d.notFirstTime) d.notFirstTime=1
else if(!IsRectEmpty(&d.r)) DrawFocusRect d.hdc &d.r ;;restore previous rect
sel button
,case 0
,POINT p; xm p d.hwnd 1; memcpy &d.r.right &p 8
,if(!IsRectEmpty(&d.r)) DrawFocusRect d.hdc &d.r ;;draw new rect
,ret 4
,
,case else
,ret button