01-26-2009, 09:12 AM
Function dlg_draw_focus_rect
Function DragDrawFocusRect
Function DDFR_Proc
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str rea3
if(!ShowDialog("dlg_draw_focus_rect" &dlg_draw_focus_rect &controls)) ret
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 RichEdit20A 0x54233044 0x200 20 20 96 48 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030006 "*" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,
,case WM_SETCURSOR
,;if(DragDrawFocusRect(hDlg wParam lParam)) ret DT_Ret(hDlg 1)
,if(DragDrawFocusRect(hDlg wParam lParam 3)) ret DT_Ret(hDlg 1)
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Function DragDrawFocusRect
;/
function! hDlg wParam lParam [idCtrl]
;Draws focus rectangle in your dialog.
;Call this function in your dialog function, on WM_SETCURSOR.
;If it returns not 0, execute this code: ret DT_Ret(hDlg 1)
;hDlg, wParam, lParam - hDlg, wParam, lParam.
;idCtrl - id of control in which to draw. If omitted or 0, draws in dialog.
;EXAMPLE
,;case WM_SETCURSOR
,;if(DragDrawFocusRect(hDlg wParam lParam)) ret DT_Ret(hDlg 1)
type DFR_DATA hwnd dc POINT'p RECT'r
DFR_DATA d
if(lParam&0xffff!=HTCLIENT or lParam>>16!=WM_LBUTTONDOWN) ret
d.hwnd=iif(idCtrl id(idCtrl hDlg) hDlg); if(wParam!=d.hwnd) ret
d.dc=GetDC(d.hwnd)
xm d.p d.hwnd 1
Drag hDlg &DDFR_Proc &d
ReleaseDC(d.hwnd d.dc)
ret 1
Function DDFR_Proc
;/
function button DFR_DATA&d
DrawFocusRect d.dc &d.r ;;erase prev rect
if(button) ret
POINT p; xm p d.hwnd 1
RECT r
r.left=d.p.x; r.top=d.p.y
r.right=p.x; r.bottom=p.y
if(r.right<r.left) _i=r.right; r.right=r.left; r.left=_i
if(r.bottom<r.top) _i=r.bottom; r.bottom=r.top; r.top=_i
DrawFocusRect d.dc &r
d.r=r