Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resizable dialog, resizable controls, splitters
#1
Functions to automatically resize dialog controls when user resizes dialog or drags splitter.

Shows how to make dialog resizable.
Function DT_AutoSizeControls: Moves or resizes dialog controls when you resize the dialog.
Control class QM_Splitter. Resizes adjacent controls when user drags splitter. And class DlgSplitter.

Note: if you already have function DT_AutoSizeControls, delete it.

Nov 8 2010:
Added class DlgSplitter.
Now you can get/set splitter position from code.
Fixed 1 bug.

2013-10-28:
Some small changes.

Upgrading: delete old folder (probably named "Resizable dialog, resizable controls, splitters") and import this file. Restart QM.

Keywords: separator, divider, mouse, move, border, child, window, vertical, horizontal


Attached Files
.qml   Resizable dialog, resizable controls, splitters.qml (Size: 17.91 KB / Downloads: 1,542)
#2
this is OFF THE HOOK!
Bless you Gintaras for putting this much programming power in the hands of mere mortals!!
Big Grin
Stuart
#3
Hi Gintaras,
I have been having so much fun setting up my dialogs with splitters. I was wondering if there was a way to snap the splitters back to their original position (with appropriate resetting of the size of the associated dialog elements). Similar is there a way to set them at certain different positions by a command (e.g. max expand, min, 10%, 90%, etc). I have been doing it by moving the mouse to a Splitter Acc position then doing a lef+, mou+, lef- which is not the ideal way of doing it.

Thanks, Stuart
#4
Now possible. Download new version.
#5
Double the fun!!!!
(and workflow efficiency!!!!!!! For my user base!)
Thanks again!!!,
Stuart
#6
Hi Gintaras,
Since I started using the new splitters, one of the objects started to "misbehave". It is a SysTabControl32 multi-tab control with each tab bringing up a different webpage. When you move the splitter around, you get multiple versions of the tab once you go to a different tab than the original. This is a simplified version. Does this have a simple solution? What's weird is that this was working properly with the previous splitter version (not on this exact dialog code, so there may be a variation that is causing the problem not related to the update).

Thanks for any insight!
Stuart

Function MultiTabBrowserWithSplitters
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 565 386 "My Web Browser"
;4 SysTabControl32 0x54000040 0x0 2 20 302 362 ""
;5 Button 0x54032000 0x0 458 4 48 14 "GO"
;6 Button 0x54032000 0x0 512 4 48 14 "BACK"
;8 QM_Splitter 0x54030000 0x0 300 12 10 362 ""
;3 ActiveX 0x54030000 0x0 310 20 248 362 "SHDocVw.WebBrowser"
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "" "" ""

str controls = "3"
str ax3SHD

if(!ShowDialog("MultiTabBrowserWithSplitters" &MultiTabBrowserWithSplitters &controls)) ret

ret
;messages
DlgSplitter ds.Init(hDlg 8)
sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser c
,c._getcontrol(id(3 hDlg))    
,;int- t_hdlg; t_hdlg=hDlg
,c._setevents("c_DWebBrowserEvents2")    
,c.Navigate("www.google.com"); err


,int+ htb=id(4 hDlg)    
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="Google"
,SendMessage htb WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="Yahoo"
,SendMessage htb WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="QuickMacros.Com"
,SendMessage htb WINAPI.TCM_INSERTITEMA 2 &ti
,SelectTab htb 2 ;;none
,goto g11
,case WM_DESTROY
,,rset ds.GetPos "splitter" "\test\MultiTabBrowserWithSplitters" ;;save splitter pos
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
c._getcontrol(id(3 hDlg))
sel wParam
,case 5 ;;Go
,str a.getwintext(id(4 hDlg))
,c.Navigate(a); err
,
,case 6
,c.GoBack; err

,case IDOK
,but 5 hDlg ;;on Enter press GO
,ret 0 ;;disable closing on Enter
,case IDCANCEL
,ifk(Z) ret 0 ;;disable closing on Esc
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case WINAPI.TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)
,out _i
,;int htb=id(4 hDlg)
,RECT rct; GetClientRect htb &rct
,SendMessage htb TCM_ADJUSTRECT 0 &rct
,MapWindowPoints htb hDlg +&rct 2
,int t=CreateControl(0 "ActiveX" "SHDocVw.WebBrowser" 0 rct.left rct.top rct.right-rct.left rct.bottom-rct.top hDlg 100+3)
,BringWindowToTop t
,sel _i
,,case 0; _s="http://www.Google.com"; _s.setwintext(t)
,,case 1; _s="http://www.yahoo.com/"; _s.setwintext(t)
,,case 2; _s="http://www.quickmacros.com/"; _s.setwintext(t)    
,;g11
,DT_Page hDlg _i
#7
Do you hide current ActiveX control when create new (CreateControl)?

Also, to reduce flickering, ActiveX must have WS_CLIPCHILDREN style.

...
Code:
Copy      Help
;3 ActiveX 0x56030000 0x0 310 20 248 362 "SHDocVw.WebBrowser"
...
Code:
Copy      Help
,;hid id(103 hDlg); err
,DestroyWindow id(103 hDlg)
,int t=CreateControl(0 "ActiveX" "SHDocVw.WebBrowser" WS_CLIPCHILDREN rct.left rct.top rct.right-rct.left rct.bottom-rct.top hDlg 100+3)
...
#8
Hi Gintaras,
Thanks for your rapid response. I think I am in a bit over my head here.
I had taken the the code from[quote]dlg_tabbed_web_browser
http://www.quickmacros.com/forum/showthr...p?tid=3111

but since I wasn't filling it from an array made from a folder full of htm's, I decided to just directly code the url links. BUT I left out the part about first hiding all current tabs and THEN unhiding the selected tab if the control is already created. I was just making a new control each time. Not good!
I am still a bit confused about how to accomplish this. The splitters have funny behavior with this mtultibrowser tabs. Sometimes, they always grab onto the tab control but only sometimes grab onto the actual browser window within it. And after switching tabs, sometimes will fill in the new size of the control (after using the splitter to enlarge/shrink), even if it didn't drag to that new size when first dragging the splitter. I think this may be all solved by managing the tabs like in your original dialog (hide all, unhide selected rather than new control each time without hiding previous) but I am not sure I can figure it out by myself.
Thanks,
Stuart
#9
You create/destroy controls at run time.
Splitter manages only those controls that were beside it when dragging first time.
Call AttachControls.

Code:
Copy      Help
,;hid id(103 hDlg); err
,DestroyWindow id(103 hDlg)
,int t=CreateControl(0 "ActiveX" "SHDocVw.WebBrowser" WS_CLIPCHILDREN rct.left rct.top rct.right-rct.left rct.bottom-rct.top hDlg 100+3)
,ds.AttachControls(1)
#10
thanks again for the code tips on this problem...
I am confused in your reply about
Code:
Copy      Help
id(103 hDlg)
there is no control 103. I think you may be referring to SECOND "SHDocVw.WebBrowser". id(3 hDlg) is actually an ActiveX control I use in the real dialog not for additional web-browsing but to display PDF's and folder contents (which I use setwintext to display into that ActiveX element). It has been behaving fine with the splitters as it is not multi-tab. The multi-tab element in this case is control 4, a SysTabControl32 which I have created an ActiveX "SHDocVw.WebBrowser for separately in the tab controls in message3.

Sorry for the confusion. I hope this helps.

Stuart
#11
int t=CreateControl(... 100+3)
#12
:oops:
#13
everythings's working perfectly now. THanks for helping me work through this!!!
and for the update on the Splitters.qml

Stuart
#14
Hi Gintaras,
I have been trying to add a toolbar with several buttons to a splitter (like child id 2207 in the Quick Macros program (Find, Output, Tips, Bookmarks and Saved Searches) but I can't seem to get a toolbar in a dialog to be in a specific location other than as the top row.
I have tried to modify "Explorer style dialog with treeview, listview, toolbar, statusbar" ....ie DEX_Main and Dialog_rebar_toolbars from the Resources/QM Extensions but for some reason the toolbar seems to want to stay on top...I want to be able to set the attributes of the toolbar (location and orientation (horizontal/vertical), specifically) and have the whole group of buttons slide back and forth with the adjacent splitter.

Do you think you could give a simpler example than DEX_Main of adding a toolbar and setting some of its attribtes (size, location, etc).

Thanks so much,
Stuart
#15
Need to set some common control styles.

Google for CCS_NOPARENTALIGN or similar, now I don't remember.

Without learning: Move mouse over a QM toolbar and look in QM status bar. Use same style in dialog definition.
#16
This doesn't seem to be documented, but this worked for me to resize something horizontal and vertically. "3svh" didn't work, so I just started playing around.

DT_AutoSizeControls hDlg message "3sv 3sh"

-jim
#17
In a dialog resizing elements using this method, how do you maintain the percentage of the column widths in a QM_Grid?

-jim
#18
On Windows Vista/7 can check: dialog editor -> grid properties -> more style -> auto size columns.
On older windows need to resize explicitly on WM_SIZE.

Function dlg_grid_auto_resize
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str qmg3x
if(!ShowDialog("dlg_grid_auto_resize" &dlg_grid_auto_resize &controls)) ret

;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x0 0 0 217 120 "Dialog"
;3 QM_Grid 0x56031041 0x0 0 0 216 114 "0x0,0,0,0,0x0[]A,,,[]B,,,"
;END DIALOG
;DIALOG EDITOR: "" 0x2030304 "*" "" ""

ret
;messages
DlgGrid g.Init(hDlg 3)
DT_AutoSizeControls hDlg message "3s"
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_SIZE
,g.ColumnsWidthAdjust
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)