Posts: 32
Threads: 10
Joined: Apr 2006
How can I launch a Smart Dialog and then resize that active Smart Dialog? I want to use the mouse to resize the dialog by grabbing the border to resize. This would be similar to resizing Notepad. Can the dialog also contain an Edit Box control that also resizes proportionately when the dialog is resized?
Thanks,
Brad
Posts: 12,147
Threads: 143
Joined: Dec 2002
To make dialog resizable, in dialog editor add WS_THICKFRAME style. Also optionally WS_MINIMIZEBOX and WS_MAXIMIZEBOX.
Use this function to autosize dialog controls.
Function DT_AutoSizeControls
;/
function hDlg message $controls
;Moves or resizes dialog controls when you resize the dialog.
;Call this function from dialog function, before sel message.
;hDlg, message - hDlg, message.
;controls - space-separated list of controls.
;;;Syntax for a control: IdActionDirection
;;;;;Id - control id.
;;;;;Action - m (move) or s (resize).
;;;;;Direction - h (horizontally) or v (vertically) or none (horizontally and vertically).
;EXAMPLE
;;...
;;messages
;DT_AutoSizeControls hDlg message "1m 2m 3sh 4mv 5s"
;sel message
,;case WM_INITDIALOG
,;;...
type ASC_CONTROL hwnd !action !direction horz vert
ASC_CONTROL* p
int i j k x y
RECT r rc
sel message
,case WM_INITDIALOG
,GetClientRect hDlg &rc
,
,ARRAY(lpstr) a
,tok controls a
,p._new(a.len)
,SetProp hDlg "asc_controls" p
,
,for i 0 a.len
,,ASC_CONTROL& c=p[i]
,,lpstr s=a[i] ;;out s
,,j=val(s 0 k); s+k
,,c.hwnd=id(j hDlg); if(!c.hwnd) out "Warning: control %i not found." j; continue
,,c.action=s[0]; c.direction=s[1]
,,
,,GetWindowRect c.hwnd &r; MapWindowPoints 0 hDlg +&r 2
,,sel c.action
,,,case 'm' c.horz=rc.right-r.left; c.vert=rc.bottom-r.top
,,,case 's' c.horz=rc.right-r.right; c.vert=rc.bottom-r.bottom
,
,case WM_SIZE
,GetClientRect hDlg &rc
,
,p=+GetProp(hDlg "asc_controls")
,
,for i 0 p._len
,,&c=p[i]
,,j=0; sel(c.direction) case 'h' j|2; case 'v' j|1
,,sel c.action
,,,case 'm'
,,,x=rc.right-c.horz; y=rc.bottom-c.vert
,,,mov x y c.hwnd j; err
,,,
,,,case 's'
,,,GetWindowRect c.hwnd &r; MapWindowPoints 0 hDlg +&r 2
,,,x=rc.right-r.left-c.horz; y=rc.bottom-r.top-c.vert
,,,siz x y c.hwnd j; err
,
,case WM_DESTROY
,p=+RemoveProp(hDlg "asc_controls")
,p._delete
example
Function dlg_autosize_control
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 4 5"
str e3 c4Che e5
if(!ShowDialog("dlg_autosize_control" &dlg_autosize_control &controls)) ret
;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x0 0 0 219 132 "Dialog"
;1 Button 0x54030001 0x4 118 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;3 Edit 0x54030080 0x200 46 6 170 14 ""
;4 Button 0x54012003 0x0 4 102 48 12 "Check"
;5 Edit 0x54231044 0x200 120 56 96 48 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "*" "" ""
ret
;messages
DT_AutoSizeControls hDlg message "1m 2m 3sh 4mv 5s"
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 32
Threads: 10
Joined: Apr 2006
Thank you very much.
Just what I needed.
Posts: 1,006
Threads: 330
Joined: Mar 2007
|