User Tools

Site Tools


docking_20a_20dialogue_20box_20on_20the_20toolbar

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

docking_20a_20dialogue_20box_20on_20the_20toolbar [2018/03/31 13:19]
127.0.0.1 external edit
docking_20a_20dialogue_20box_20on_20the_20toolbar [2018/04/17 15:52] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, December 2006//\\ \\ **DO NOT USE THE CODE IN THIS ARTICLE, IT HAS BEEN REPORTED THAT IT CAN MAKE YOUR PROGRAM UNSTABLE**\\ \\  A normal dialogue box is free to be moved anywhere on the desktop. This article describes how to '​dock'​ a dialogue box to a program'​s toolbar and fix it there so it tracks window movements etc.\\ \\  The first step is to create the toolbar. This is done conventionally,​ except that space must be made on the toolbar for where the dialogue box will eventually be placed. This can easily be achieved by including a suitable number of '​separators':​\\ \\  //by Richard Russell, December 2006//\\ \\ **DO NOT USE THE CODE IN THIS ARTICLE, IT HAS BEEN REPORTED THAT IT CAN MAKE YOUR PROGRAM UNSTABLE**\\ \\  A normal dialogue box is free to be moved anywhere on the desktop. This article describes how to '​dock'​ a dialogue box to a program'​s toolbar and fix it there so it tracks window movements etc.\\ \\  The first step is to create the toolbar. This is done conventionally,​ except that space must be made on the toolbar for where the dialogue box will eventually be placed. This can easily be achieved by including a suitable number of '​separators':​\\ \\ 
 +<code bb4w>
         INSTALL @lib$+"​WINLIB"​         INSTALL @lib$+"​WINLIB"​
         nbutts% = 12         nbutts% = 12
Line 8: Line 9:
         buttid%() = 100,​0,​0,​0,​0,​0,​0,​0,​0,​0,​0,​101         buttid%() = 100,​0,​0,​0,​0,​0,​0,​0,​0,​0,​0,​101
         htoolbar% = FN_createtoolbar(nbutts%,​button%(),​buttid%())         htoolbar% = FN_createtoolbar(nbutts%,​button%(),​buttid%())
 +</​code>​
 Here ten separators (indicated by **buttid%** values of 0) are included between two conventional buttons. The dialogue box will eventually be placed in this gap.\\ \\  Step two is to create the dialogue box. Again this is done conventionally,​ with the exception of an extra statement to make the dialogue box a //child window//:\\ \\  Here ten separators (indicated by **buttid%** values of 0) are included between two conventional buttons. The dialogue box will eventually be placed in this gap.\\ \\  Step two is to create the dialogue box. Again this is done conventionally,​ with the exception of an extra statement to make the dialogue box a //child window//:\\ \\ 
 +<code bb4w>
         INSTALL @lib$+"​WINLIB2"​         INSTALL @lib$+"​WINLIB2"​
         dlg% = FN_newdialog("",​ 0, 0, 48, 16, 8, 1000)         dlg% = FN_newdialog("",​ 0, 0, 48, 16, 8, 1000)
Line 15: Line 18:
         PROC_radiobutton(dlg%,​ "",​ 502, 20, 2, 13, 13, 0)         PROC_radiobutton(dlg%,​ "",​ 502, 20, 2, 13, 13, 0)
         PROC_radiobutton(dlg%,​ "",​ 503, 35, 2, 13, 13, 0)         PROC_radiobutton(dlg%,​ "",​ 503, 35, 2, 13, 13, 0)
 +</​code>​
 For the purpose of illustration the dialogue box contains three radiobuttons.\\ \\  Finally the toolbar is given the WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles and the dialogue box is docked to the toolbar:\\ \\  For the purpose of illustration the dialogue box contains three radiobuttons.\\ \\  Finally the toolbar is given the WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles and the dialogue box is docked to the toolbar:\\ \\ 
 +<code bb4w>
         PROC_showdialog(dlg%)         PROC_showdialog(dlg%)
         SYS "​GetWindowLong",​ htoolbar%, -16 TO ws%         SYS "​GetWindowLong",​ htoolbar%, -16 TO ws%
Line 21: Line 26:
         SYS "​SetParent",​ !dlg%, htoolbar%         SYS "​SetParent",​ !dlg%, htoolbar%
         SYS "​SetWindowPos",​ !dlg%, 0, 30, 0, 0, 0, 1         SYS "​SetWindowPos",​ !dlg%, 0, 30, 0, 0, 0, 1
 +</​code>​
 The value in the **SetWindowPos** call (30 in this case) should be adjusted so that the dialogue box is positioned correctly.\\ \\  The only complication,​ as so often, is if you need this to work with different DPI (dots per inch) settings. If the DPI changes the size of the dialogue box will also change, but the size of the toolbar won't. Therefore the dialogue box may no longer fit.\\ \\  The most straightforward solution, in this case, is probably to design two (or more) different dialogue boxes for the different DPI values you want to support (96 dpi and 120 dpi will cover most eventualities). So if the above code works correctly at 96 dpi then making the following changes should probably be about right for 120 dpi:\\ \\  The value in the **SetWindowPos** call (30 in this case) should be adjusted so that the dialogue box is positioned correctly.\\ \\  The only complication,​ as so often, is if you need this to work with different DPI (dots per inch) settings. If the DPI changes the size of the dialogue box will also change, but the size of the toolbar won't. Therefore the dialogue box may no longer fit.\\ \\  The most straightforward solution, in this case, is probably to design two (or more) different dialogue boxes for the different DPI values you want to support (96 dpi and 120 dpi will cover most eventualities). So if the above code works correctly at 96 dpi then making the following changes should probably be about right for 120 dpi:\\ \\ 
 +<code bb4w>
         dlg% = FN_newdialog("",​ 0, 0, 36, 12, 8, 1000)         dlg% = FN_newdialog("",​ 0, 0, 36, 12, 8, 1000)
         dlg%!16 = &​568800C4 : REM Make dialogue box a child window         dlg%!16 = &​568800C4 : REM Make dialogue box a child window
Line 27: Line 34:
         PROC_radiobutton(dlg%,​ "",​ 502, 15, 2, 10, 10, 0)         PROC_radiobutton(dlg%,​ "",​ 502, 15, 2, 10, 10, 0)
         PROC_radiobutton(dlg%,​ "",​ 503, 27, 2, 10, 10, 0)         PROC_radiobutton(dlg%,​ "",​ 503, 27, 2, 10, 10, 0)
 +</​code>​
docking_20a_20dialogue_20box_20on_20the_20toolbar.txt ยท Last modified: 2018/04/17 15:52 by tbest3112