BBC BASIC for Windows
« Resizing a dialog box »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:56pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Resizing a dialog box  (Read 568 times)
KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Resizing a dialog box
« Thread started on: Apr 9th, 2015, 4:27pm »

I'm sorry to keep asking questions to which everyone else appears to know the answer, but ...

I have a dialog box which is docked inside a window. For various reasons I need to resize the window and the accompanying dialog box and then to resize one or two of the items, including the group box, to fit the new dialog box size.

I can't find a command to resize or even move dialog box items. I'm guessing that I would need to delete and then recreate these items with the new dimensions, but I can't even find a command to do that.

Anyone? Please?
User IP Logged

rtr2
Guest
xx Re: Resizing a dialog box
« Reply #1 on: Apr 9th, 2015, 9:39pm »

on Apr 9th, 2015, 4:27pm, KenDown wrote:
For various reasons I need to resize the window and the accompanying dialog box and then to resize one or two of the items, including the group box, to fit the new dialog box size.

Firstly, remember that Windows automatically resizes dialogue boxes, and their controls, according to the current DPI (Dots Per Inch) setting. You can easily get into trouble if you try to do you own resizing, especially if you don't correctly take the DPI into account.

So whilst you certainly can resize the contents of a dialogue box - the controls are windows like any other - before attempting to do that check that your existing code works as you expect when run with different DPI settings (96, 120 and 144 are common - the laptop I am using to type this is 144 DPI natively). You may get an unpleasant surprise!

As a general rule as soon as you try to do something that Windows does not expect you to do - and it certainly does not expect you to resize the contents of a dialogue box - it rapidly becomes difficult and risky. Perhaps a bit of lateral thinking will come up with an alternative, and more conventional, solution.

Richard.
User IP Logged

sveinioslo
Developer

member is offline

Avatar




PM


Posts: 64
xx 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
 
User IP Logged

rtr2
Guest
xx 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls