Author |
Topic: Resizing a dialog box (Read 570 times) |
|
sveinioslo
Developer
member is offline


Posts: 64
|
 |
Re: Resizing a dialog box
« Reply #2 on: Jul 22nd, 2015, 10:18pm » |
|
There is no ready made command to resize or move the dialog items, but that does not mean you can't make one yourself. Even if we are not supposed to alter the dialog or its content, there may very well be circumstances where that is the needed or easiest. I believe in the programmer's freedom to decide. All you have to do is to manipulate the dialog template and then close and open it again. You can move and resize as you see fit, windows will not protest as long as the values are within reason. Possible downside is that you need to re-initialize the content of some items.
I added a few lines to the DLGDEMO.bbc from the examples folder to show you the steps needed. The demo is only altering the x values, but you can easily modify it to use the y values also. Note: demo only tested in version 5.95a
Svein
Code: REM. Program to demonstrate a Dialogue Box
INSTALL @lib$+"WINLIB2"
BS_DEFPUSHBUTTON = &1
CB_ADDSTRING = &143
CB_SETCURSEL = &14E
CBS_DROPDOWNLIST = &3
ES_AUTOHSCROLL = &80
ES_NUMBER = &2000
LB_ADDSTRING = &180
LB_GETCURSEL = &188
UDM_SETRANGE = &465
UDS_ALIGNRIGHT = &4
UDS_AUTOBUDDY = &10
UDS_SETBUDDYINT = &2
WS_CHILD = &40000000
WS_GROUP = &20000
WS_VISIBLE = &10000000
dlg%=FN_newdialog("Dialogue box", 20, 20, 160, 128, 8, 560)
Adr0%=(dlg%!12+4) AND -3 : REM adr of groupbox ........................
PROC_groupbox(dlg%, "Group box", 0, 4, 4, 152, 96, WS_GROUP)
PROC_editbox(dlg%, "Text box", 101, 12, 20, 64, 12, ES_AUTOHSCROLL)
PROC_editbox(dlg%, "123456", 102, 82, 20, 64, 12, ES_NUMBER)
PROC_dlgctrl(dlg%, "", 109, 0, 0, 12, 12, WS_VISIBLE OR WS_CHILD OR \
\ UDS_AUTOBUDDY OR UDS_ALIGNRIGHT OR UDS_SETBUDDYINT, "msctls_updown32")
Adr1%=(dlg%!12+4) AND -3 : REM adr of combobox ........................
PROC_combobox(dlg%, "", 103, 12, 40, 64, 60, CBS_DROPDOWNLIST)
Adr2%=(dlg%!12+4) AND -3 : REM adr of listbox .........................
PROC_listbox(dlg%, "", 104, 82, 40, 64, 48, 0)
PROC_radiobutton(dlg%, "Radiobutton 1", 105, 12, 64, 64, 10, 0)
PROC_radiobutton(dlg%, "Radiobutton 2", 106, 12, 82, 64, 10, 0)
PROC_checkbox(dlg%, "Checkbox", 107, 82, 82, 64, 10, 0)
PROC_pushbutton(dlg%, "OK", 1, 12, 108, 56, 14, WS_GROUP OR BS_DEFPUSHBUTTON)
PROC_pushbutton(dlg%, "Cancel", 2, 92, 108, 56, 14, 0)
PROC_showdialog(dlg%)
ON CLOSE PROC_closedialog(dlg%):QUIT
ON ERROR PROC_closedialog(dlg%):PRINT'REPORT$:END
PROC_fill : REM Initialise the content ..............
Click%=0
ON SYS Click% = @wparam% : RETURN
Step%=10 : X%=0 : REM ...............................
REPEAT
MOUSE x,y,b:WHILE b:MOUSE x,y,b:WAIT 0:ENDWHILE : REM just to prevent moving the dialog from blocking this demo
REM manipulate template values --------------------
X%+=Step%
IF X%>90 OR X%<10 THEN Step%=-Step%
Adr1%!12=(60<<16) OR 64+X% : REM combobox cx% '(cy%<<16) OR cx%'
Adr2%!8 =(40<<16) OR 82+X% : REM listbox x%
Adr2%!12=(48<<16) OR 64+X% : REM listbox cx%
Adr0%!12=(96<<16) OR 152+X%*2 : REM groupbox cx%
dlg%!30 =(128<<16)OR 160+X%*2 : REM dialog cx%
PROC_closedialog(dlg%) : PROC_showdialog(dlg%)
PROC_fill : REM Re-initialise the content
REM -----------------------------------------------
WAIT 50
click%=0
SWAP Click%, click%
UNTIL click%=1 OR click%=2 OR !dlg%=0
IF click%=1 THEN
PRINT "OK pressed, settings were:"'
DIM text% 255
SYS "GetDlgItemText", !dlg%, 101, text%, 255
PRINT "Text box contained """$$text%""""
SYS "GetDlgItemInt", !dlg%, 102, 0, 1 TO Val%
PRINT "Number box contained ";Val%
SYS "GetDlgItemText", !dlg%, 103, text%, 255
PRINT "Combobox selection was """$$text%""""
SYS "SendDlgItemMessage", !dlg%, 104, LB_GETCURSEL, 0, 0 TO sel%
PRINT "Listbox selection index was ";sel%
SYS "IsDlgButtonChecked", !dlg%, 105 TO rb1%
IF rb1% PRINT "Radiobutton 1 was checked" ELSE PRINT "Radiobutton 2 was checked"
SYS "IsDlgButtonChecked", !dlg%, 107 TO cb%
IF cb% PRINT "Checkbox was checked" ELSE PRINT "Checkbox was not checked"
ELSE
PRINT "Cancel pressed"
ENDIF
PROC_closedialog(dlg%)
END
DEF PROC_fill
SYS "SendDlgItemMessage", !dlg%, 103, CB_ADDSTRING, 0, "Combobox 1"
SYS "SendDlgItemMessage", !dlg%, 103, CB_ADDSTRING, 0, "Combobox 2"
SYS "SendDlgItemMessage", !dlg%, 103, CB_ADDSTRING, 0, "Combobox 3"
SYS "SendDlgItemMessage", !dlg%, 103, CB_ADDSTRING, 0, "Combobox 4"
SYS "SendDlgItemMessage", !dlg%, 103, CB_SETCURSEL, 0, 0
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 0"
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 1"
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 2"
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 3"
SYS "CheckRadioButton", !dlg%, 105, 106, 105
SYS "SendDlgItemMessage", !dlg%, 109, UDM_SETRANGE, 0, 999
ENDPROC
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Resizing a dialog box
« Reply #3 on: Jul 22nd, 2015, 11:27pm » |
|
on Jul 22nd, 2015, 10:18pm, sveinioslo wrote:| All you have to do is to manipulate the dialog template and then close and open it again. |
|
That is not 'resizing' dialogue box controls, it is opening a new dialogue box which has controls that are a different size! You can do that, but it is not what the OP asked for.
But the fundamental point remains: whilst it may be technically possible to do what the OP wants, it is contrary to the 'spirit' of Windows and should not be attempted. Programming the Windows GUI is all about uniformity and conforming to standards (remember the Windows 95 logo program, which allowed a software vendor to use the logo only if his GUI adhered to the rules).
Richard.
|
|
Logged
|
|
|
|
|