Results 1 to 6 of 6

Thread: DIALOG maximum size

  1. #1
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    46
    Posts
    247
    Rep Power
    34

    DIALOG maximum size

    Is there an easy way to set the maximum size of a dialog. I found DIALOG SET MINSIZE for minimum size, but couldn't find anything for maximum size...

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,817
    Blog Entries
    3
    Rep Power
    695

    Re: DIALOG maximum size

    Hi,

    there is no such a functionality directly available, but you can try following approach:
    - process WM_SIZING message
    - overlap RECT structure over it
    - trim width/height to maximum allowed values

    Just one personal side note from my side - I do not like programs limiting maximum window size. I have bought video editing software, which does not allow to resize window over 1024x768, it is locked to this resolution even when clicking maximize. You can imagine on big screen this can be big trouble for user.


    Here is the code:
    [code=thinbasic]
    ' Limiting maximum dialog size
    ' Created by Petr Schreiber

    USES "UI"

    ' -- ID numbers of controls
    Begin Const
    %btnClose = 1000
    %lblStatus
    End Const

    ' -- Create dialog here
    FUNCTION TBMAIN()
    LOCAL hDlg AS DWORD

    %maxWidth = 400
    %maxHeight = 300
    DIALOG New 0, "Resize to no more than 400x300 units",-1,-1, 160, 120, _
    %WS_POPUP Or %WS_VISIBLE Or _
    %WS_CLIPCHILDREN Or %WS_CAPTION OR _
    %WS_SYSMENU Or %WS_MINIMIZEBOX or %WS_THICKFRAME, 0 To hDlg

    ' -- Place controls here
    CONTROL ADD LABEL, hDlg, %lblStatus, "Resize!", 5, 5, 100, 28
    CONTROL ADD BUTTON, hDlg, %btnClose, "Click to close", 95, 100, 60, 14, CALL btnCloseProc

    DIALOG SHOW MODAL hDlg, CALL dlgProc

    END FUNCTION

    ' -- Callback for dialog
    CALLBACK FUNCTION dlgProc()
    ' -- Test for messages
    SELECT CASE CBMSG

    CASE %WM_INITDIALOG
    ' -- Put code to be executed after dialog creation here

    CASE %WM_COMMAND

    ' -- Essential message for managing dialog size
    CASE %WM_SIZING
    dim lp as RECT at cblparam
    dim currentWidth as long = (lp.nRight-lp.nLeft)
    dim currentHeight as long = (lp.nBottom-lp.nTop)
    dim maximumWidth, maximumHeight as long

    ' -- Convert units to pixels
    dialog units cbhndl, %maxWidth, %maxHeight to pixels maximumWidth, maximumHeight

    if currentWidth > maximumWidth or currentHeight > maximumHeight then
    lp.nRight = lp.nLeft + min(currentWidth , maximumWidth)
    lp.nBottom = lp.nTop + min(currentHeight , maximumHeight)
    end if

    currentWidth = (lp.nRight-lp.nLeft)
    currentHeight = (lp.nBottom-lp.nTop)

    dim currentWidthU as long
    dim currentHeightU as long

    dialog pixels cbhndl, currentWidth, currentHeight to units currentWidthU, currentHeightU


    control set text cbhndl, %lblStatus, STRFORMAT$("W:{1}/{2} u, H{3}/{4} u", currentWidthU, %maxWidth, currentHeightU, %maxHeight)

    CASE %WM_CLOSE
    ' -- Put code to be executed before dialog end here

    END SELECT

    END FUNCTION

    ' -- Callback for close button
    CALLBACK FUNCTION btnCloseProc()

    IF CBMSG = %WM_COMMAND THEN
    IF CBCTLMSG = %BN_CLICKED THEN
    ' -- Closes the dialog
    DIALOG END CBHNDL
    END IF
    END IF

    END FUNCTION
    [/code]
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    46
    Posts
    247
    Rep Power
    34

    Re: DIALOG maximum size

    Hi Petr,

    Many thanks for your example!

    Just one personal side note from my side - I do not like programs limiting maximum window size. I have bought video editing software, which does not allow to resize window over 1024x768, it is locked to this resolution even when clicking maximize. You can imagine on big screen this can be big trouble for user.
    You are absolutely right about this, but in some rare cases I will need this.

    BTW I didn't know %WM_SIZING exists. Is there a list available with all %WM parameters?

    Martin

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,817
    Blog Entries
    3
    Rep Power
    695

    Re: DIALOG maximum size

    Hi Martin,

    I must admit I did not used WM_SIZING in this way before too.
    Here is a script, which will save to file list of all WM_ equates UI module supports now:
    [code=thinbasic]
    uses "UI", "console", "File"

    DIM allEquates AS STRING
    DIM Equate() AS STRING
    DIM i AS LONG
    DIM sOut AS STRING

    printl "Retrieving equates..."

    '---Get a string with equates separated by $TAB
    allEquates = APP_ListEquates

    '---Parse string into an array
    PARSE allEquates, Equate, $TAB

    '---Creates output buffer
    FOR i = 1 TO UBOUND(Equate(1))
    IF LEFT$(Equate(i), 4) = "%WM_" THEN sOut += Equate(i) + $CRLF
    NEXT
    printl "Saving equates..."

    '---Save buffer into .INC file
    File_Save(APP_SourcePath & "WM_Equates.txt", sOut)
    printl "Done..."
    waitkey
    [/code]

    Documentation on these can be found on MS website for example here:
    http://msdn.microsoft.com/en-us/library/dd469354(VS.85).aspx


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  5. #5
    Member
    Join Date
    Mar 2009
    Location
    Netherlands
    Age
    46
    Posts
    247
    Rep Power
    34

    Re: DIALOG maximum size

    Thanks again Petr!

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,311
    Blog Entries
    2
    Rep Power
    10

    Re: DIALOG maximum size

    Quote Originally Posted by Petr Schreiber
    Just one personal side note from my side - I do not like programs limiting maximum window size. I have bought video editing software, which does not allow to resize window over 1024x768, it is locked to this resolution even when clicking maximize. You can imagine on big screen this can be big trouble for user.
    I think this quote from Petr is important.
    Programs limiting how windows can size is something to avoid as much as possible.
    Minimum size can be understandable (in my opinion) if minimum dimensions are very little but not max size unless there is a valid reason of course.

    Programmers have to design their applications in such a way applications react correctly regardless window sizing.
    Programmers have also to consider there are multi-monitor situations where a window can span over more than one monitor.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Similar Threads

  1. Confusion with DIALOG GET/SET CLIENT, DESKTOP GET SIZE and DIALOG SET LOC
    By Michael Hartlef in forum UI (User Interface)
    Replies: 3
    Last Post: 03-10-2008, 19:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •