Announcement

Collapse
No announcement yet.

Wrong screen resolution problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • StanHelton
    replied
    Originally posted by Cliff Nichols View Post
    Maybe I am a little lost why so many controls (if I missed the post forgive me, but I don't see it), beyond that what you could try is AutoSize from William Burns (unfortunately I can not find it in the forums now, so the code I have is below)



    {code deleted -- see previous post}
    Hopefully it helps?

    Reason: Real-time process control tool with a live operator. Technical theatre application.


    Your code looks very interesting - like it will handle all the controls in any given app (if I read it right). I opted for a simpler solution using native PB functions and statements (see about 10 posts back for my solution code) based on the feedback I got from several folks to my original question. It turns out that PB natively supports all manner of resizing. All I had to do was find the current screen size and figure the ratio change from the design size. I used the ARRAY ASSIGN statement to load my array then cut-and-paste to get the LOOOONG list of controls into the statement. I've tested the algo down to 800x600 and it works, but this particular screen falls apart below 1024x768.

    This is another one I'm going to put into my personal #INCLUDE file for future projects, if you don't mind.

    I posted a link 4 posts back, it you want to see a screen shot.

    Thanks for that code snippet!

    Stan

    Leave a comment:


  • Cliff Nichols
    replied
    Maybe I am a little lost why so many controls (if I missed the post forgive me, but I don't see it), beyond that what you could try is AutoSize from William Burns (unfortunately I can not find it in the forums now, so the code I have is below)



    Code:
    'o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
    'o
    'o    AutoSize.Inc    by William Burns             last update: 04/16/2003
    'o
    'o    This code will automaticly adjust the size of each child control in a dialog
    'o    This should work with both SDK and DDT type windows.
    'o
    'o To use, add this command to the %WM_SIZE event in your main callback function:
    'o      AutoSizeMyControls hDlg, LPARAM, MyStyles  '<--- goes in the %WM_SIZE
    'o
    'o The third parameter (MyStyles) is to adjust sizing options.
    'o Use the OR command to combine a combination of:  (or just use 0 for none)
    'o    %NORESIZEBUT   'stops buttons from resizing (they will just move)
    'o    %NORESIZECBOX  'stops comboboxs from resizing (they will just move)
    'o    %NORESIZETBOX  'stops textboxs from resizing (they will just move)
    'o    %NORESIZELBOX  'stops listboxs from resizing (they will just move)
    'o    %NORESIZELAB   'stops labels and images from resizing (they will just move)
    'o    %NORESIZEFRAME 'stops frames from resizing (they will just move)
    'o    %ADDSPACETOP   'adds extra space to the TOP of dialog area
    'o    %ADDSPACEBOT   'adds extra space to the BOTTOM of dialog area
    'o    %ADDSPACERIGHT 'adds extra space on the RIGHT side of dialog area
    'o    %ADDSPACELEFT  'adds extra space on the LEFT side of dialog area
    'o    %SMARTSIZE     'tries to keep borders same as dialog grows otherwise borders grow portionaly to size
    'o
    'o
    'o
    'o Example:
    'o
    'o       SELECT CASE CBMSG
    'o          CASE %WM_SIZE
    'o             AutoSizeMyControls CBHNDL, CBLPARAM, %ADDSPACETOP OR %NORESIZEBUT OR %SMARTSIZE
    'o       END SELECT
    'o
    'o
    'o Note: to make a dialog sizeable you need to include the %WS_THICKFRAME style.  But, I would
    'o       also include  %WS_CAPTION %WS_MINIMIZEBOX %WS_MAXIMIZEBOX %WS_SYSMENU %WS_POPUP
    'o
    'o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "win32api.inc"                 'add win32api if not already added
    #ENDIF
    #IF NOT %DEF(%AUTOSIZE)
        %AUTOSIZE = 1
    #ENDIF
    %NORESIZEBUT   = 1         'stops buttons from resizing, they just move
    %NORESIZECBOX  = 2         'stops comboboxs from resizing, they just move
    %NORESIZETBOX  = 4         'stops textboxs from resizing, they just move
    %NORESIZELBOX  = 8         'stops listboxes from resizing, they just move
    %NORESIZELAB   = 16        'stops labels and images from resizing, they just move
    %NORESIZEFRAME = 32        'stops frames from resizing, they just move
    %ADDSPACETOP   = 512       'adds space to the TOP of dialog area
    %ADDSPACEBOT   = 1024      'adds space to the BOTTOM of dialog area
    %ADDSPACERIGHT = 2048      'adds space on the RIGHT side of dialog area
    %ADDSPACELEFT  = 4096      'adds space on the LEFT side of dialog area
    %SMARTSIZE     = 8192      'tries to keep borders same as dialog grows otherwise borders grow portionaly to size
    TYPE EachSizeControl       'used to store information about each control found
       hWnd     AS DWORD       'store the handle of each control
       xPrcnt   AS SINGLE      'xPos percentage
       yPrcnt   AS SINGLE      'yPos percentage
       xxPrcnt  AS SINGLE      'width percentage
       yyPrcnt  AS SINGLE      'height percentage
       zClsName AS ASCIIZ * 20 'store classname
    END TYPE
    GLOBAL gAllMyControls() AS EachSizeControl   'setup global array to hold our control sizing data
    GLOBAL gxMainDlgSize    AS DWORD             'store our main dialog width
    GLOBAL gyMainDlgSize    AS DWORD             'store our main dialog height
    GLOBAL ghMyWndMainDlg   AS LONG              'store main dialog handle
    GLOBAL gSizeFlags       AS LONG              'store option flags
    'o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
    FUNCTION InitChildEnumProc(BYVAL hWnd AS DWORD, BYVAL lParam AS DWORD) AS LONG
        ON ERROR GOTO ErrHandler
       LOCAL myRect         AS RECT
       LOCAL xPosOnScreen   AS DWORD
       LOCAL yPosOnScreen   AS DWORD
       LOCAL zBuff          AS ASCIIZ * 25
       IF GetParent(hWnd) = ghMyWndMainDlg THEN  'only grab controls we own
          IF GetWindowRect(hWnd, myRect) THEN    'get each control size
             GetClassName hWnd, BYVAL VARPTR(zBuff), SIZEOF(zBuff) 'used to determine what type control
             REDIM PRESERVE gAllMyControls(0 TO UBOUND(gAllMyControls(1)) + 1)  'increase array by 1
             gAllMyControls(UBOUND(gAllMyControls(1))).hWnd = hWnd
             gAllMyControls(UBOUND(gAllMyControls(1))).xPrcnt = (myRect.nLeft - LOWRD(lParam)) / gxMainDlgSize   'xPos
             gAllMyControls(UBOUND(gAllMyControls(1))).yPrcnt = (myRect.nTop - HIWRD(lParam)) / gyMainDlgSize    'yPos
             gAllMyControls(UBOUND(gAllMyControls(1))).xxPrcnt = (myRect.nRight - myRect.nLeft) / gxMainDlgSize  'width
             gAllMyControls(UBOUND(gAllMyControls(1))).yyPrcnt = (myRect.nBottom - myRect.nTop) / gyMainDlgSize  'height
             IF zBuff = "Button" AND ((GetWindowLong(hWnd,%GWL_STYLE) AND %BS_GROUPBOX) = %BS_GROUPBOX) THEN zBuff = "Frame"   'see if this Button is really a frame
             gAllMyControls(UBOUND(gAllMyControls(1))).zClsName = zBuff                                          'class name
    'MSGBOX zBuff
             IF zBuff = "ComboBox" THEN gAllMyControls(UBOUND(gAllMyControls(1))).yyPrcnt = .90  '90% set combobox tall enough to use
          END IF
       END IF
       FUNCTION = 1
        EXIT FUNCTION
    ErrHandler:
    '    StartTrace
    '    ErrorCheck ERR
    '    EndTrace
    END FUNCTION
    'o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
    FUNCTION SizeEachChildEnumProc(BYVAL hWnd AS DWORD, BYVAL lParam AS DWORD) AS LONG
        ON ERROR GOTO ErrHandler
       LOCAL myRect      AS RECT
       LOCAL iCounter    AS LONG
       LOCAL iFlag       AS LONG
       LOCAL xAdjust     AS LONG
       LOCAL yAdjust     AS LONG
       LOCAL sCName      AS STRING
       iFlag = %SWP_NOZORDER                                 'no zorder change flag
    'MSGBOX FUNCNAME$ + $CR + "Ubound = " + STR$(UBOUND(gAllMyControls(1))) + $CR + "Hwnd = " + STR$(GetParent(hWnd)) + $CR + "main = " + STR$(ghMyWndMainDlg)
       IF GetParent(hWnd) = ghMyWndMainDlg THEN              'only adjust controls we own
          FOR iCounter = 0 TO UBOUND(gAllMyControls(1))
    'MSGBOX gAllMyControls(iCounter).zClsName + STR$(LEN(gAllMyControls(iCounter).zClsName))
             IF gAllMyControls(iCounter).hWnd = hWnd THEN    'find the one we need
                myRect.nLeft   = LOWRD(lParam) * gAllMyControls(iCounter).xPrcnt  'x pos
                myRect.nTop    = HIWRD(lParam) * gAllMyControls(iCounter).yPrcnt  'y pos
                myRect.nRight  = LOWRD(lParam) * gAllMyControls(iCounter).xxPrcnt 'xx size
                myRect.nBottom = HIWRD(lParam) * gAllMyControls(iCounter).yyPrcnt 'yy size
    'MSGBOX "Hwnd Found" + $CR + "Left = " + STR$(myRect.nLeft) _
    '     + $CR + "Right = " + STR$(myRect.nRight) _
    '     + $CR + "Top = " + STR$(myRect.nTop) _
    '     + $CR + "Bottom = " + STR$(myRect.nBottom)
                IF (gSizeFlags AND %SMARTSIZE) = %SMARTSIZE THEN   '%SMARTSIZE adjustments
                   IF LOWRD(lParam) > gxMainDlgSize THEN xAdjust = (LOWRD(lParam) - gxMainDlgSize) * .05  '5% of dialog growth
                   IF HIWRD(lParam) > gyMainDlgSize THEN yAdjust = (HIWRD(lParam) - gyMainDlgSize) * .05
                   myRect.nLeft   = myRect.nLeft    - xAdjust
                   myRect.nTop    = myRect.nTop     - (yAdjust * .2)
                   myRect.nRight  = myRect.nRight   + (xAdjust * 1.2)
                   myRect.nBottom = myRect.nBottom  + (yAdjust * 1.2)
    'MSGBOX "SmartSize Found" + $CR + "Left = " + STR$(myRect.nLeft) _
    '     + $CR + "Right = " + STR$(myRect.nRight) _
    '     + $CR + "Top = " + STR$(myRect.nTop) _
    '     + $CR + "Bottom = " + STR$(myRect.nBottom)
                END IF
                IF (gAllMyControls(iCounter).zClsName = "Button" AND (gSizeFlags AND %NORESIZEBUT) = %NORESIZEBUT) _
                   OR (gAllMyControls(iCounter).zClsName = "ComboBox" AND (gSizeFlags AND %NORESIZECBOX) = %NORESIZECBOX) _
                   OR (gAllMyControls(iCounter).zClsName = "ListBox" AND (gSizeFlags AND %NORESIZELBOX) = %NORESIZELBOX) _
                   OR (gAllMyControls(iCounter).zClsName = "Static" AND (gSizeFlags AND %NORESIZELAB) = %NORESIZELAB) _
                   OR (gAllMyControls(iCounter).zClsName = "Frame" AND (gSizeFlags AND %NORESIZEFRAME) = %NORESIZEFRAME) _
                   OR (gAllMyControls(iCounter).zClsName = "Edit" AND (gSizeFlags AND %NORESIZETBOX) = %NORESIZETBOX)THEN 'dont resize just move
                   iFlag = iFlag OR %SWP_NOSIZE                 'dont resize, just move
                   'myRect.nLeft = myRect.nLeft + (xAdjust * 4)  'since we are not growing adjust spacing
                   'myRect.nTop = myRect.nTop   + (yAdjust * 2)  'since we are not growing adjust spacing
    'MSGBOX "iFlag = " + STR$(iFlag)
                END IF
                SetWindowPos hWnd, %HWND_NOTOPMOST, myRect.nLeft, myRect.nTop, myRect.nRight, myRect.nBottom, iFlag
                EXIT FOR    'found it, so no need to continue looking
             END IF
          NEXT iCounter
       END IF
       FUNCTION = %True         'return true to continue enum
        EXIT FUNCTION
    ErrHandler:
    '    StartTrace
    '    ErrorCheck ERR
    '    EndTrace
    END FUNCTION
    'o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
    FUNCTION AutoSizeMyControls(MyhWnd AS LONG, BYVAL lParam AS DWORD, MyStyles AS LONG) AS LONG
        ON ERROR GOTO ErrHandler
       LOCAL myRect   AS RECT
       LOCAL mylParam AS DWORD
       LOCAL iWidth   AS LONG
       LOCAL iHeight  AS LONG
       ghMyWndMainDlg = MyhWnd
       gSizeFlags = MyStyles
    'MSGBOX FUNCNAME$
       IF ISFALSE IsIconic(MyhWnd) THEN 'dont need to worry about minimized dialogs
          IF gxMainDlgSize THEN   'have we setup the controls yet?  If so, just resize each control
                FUNCTION = EnumChildWindows(MyhWnd, CODEPTR(SizeEachChildEnumProc), lParam)   'enum child objects and size them
                InvalidateRect MyhWnd, BYVAL 0, %TRUE     'now redraw window
          ELSE  'nope, first run, so init each control
             REDIM gAllMyControls(0:1)
             IF GetClientRect(MyhWnd, myRect) THEN        'get main dialog client size
                gxMainDlgSize = myRect.nRight
                gyMainDlgSize = myRect.nBottom
                GetWindowRect MyhWnd, myRect
                iWidth   = myRect.nRight - myRect.nLeft   'actual dialog width including scrollbars etc
                iHeight  = myRect.nBottom - myRect.nTop   'actual dialog height including caption, statusbar etc
                IF (MyStyles AND %ADDSPACETOP) = %ADDSPACETOP THEN       'add space at TOP
                   gyMainDlgSize  = gyMainDlgSize  + GetSystemMetrics(%SM_CYCAPTION)
                END IF
                IF (MyStyles AND %ADDSPACELEFT) = %ADDSPACELEFT THEN     'add space at LEFT side
                   gxMainDlgSize = gxMainDlgSize + GetSystemMetrics(%SM_CYVSCROLL)
                END IF
                mylParam = MAKDWD(myRect.nLeft + ((iWidth - gxMainDlgSize) * .5), myRect.nTop + ((iHeight - gyMainDlgSize) * .9))'pass enum proc xy info (topleft)
                IF (MyStyles AND %ADDSPACERIGHT) = %ADDSPACERIGHT THEN   'add space at RIGHT side
                   gxMainDlgSize = gxMainDlgSize + GetSystemMetrics(%SM_CYVSCROLL)
                END IF
                IF (MyStyles AND %ADDSPACEBOT) = %ADDSPACEBOT THEN       'add space at BOTTOM
                   gyMainDlgSize = gyMainDlgSize + GetSystemMetrics(%SM_CYHSCROLL)
                END IF
    'MSGBOX "Left = " + STR$(myRect.nLeft) _
    '     + $CR + "Right = " + STR$(myRect.nRight) _
    '     + $CR + "Top = " + STR$(myRect.nTop) _
    '     + $CR + "Bottom = " + STR$(myRect.nBottom)
                FUNCTION = EnumChildWindows(MyhWnd, CODEPTR(InitChildEnumProc), mylParam)     'enum child objects and build size info
    'MSGBOX "InitChildEnumProc"
                FUNCTION = EnumChildWindows(MyhWnd, CODEPTR(SizeEachChildEnumProc), lParam)   'enum child objects and size them
    'MSGBOX "SizeEachChildEnumProc"
                InvalidateRect MyhWnd, BYVAL 0, %TRUE  'now redraw window
             END IF   'GetClientRect worked?
          END IF   'first run?
       END IF   'IsIconic?
        EXIT FUNCTION
    ErrHandler:
    '    StartTrace
    '    ErrorCheck ERR
    '    EndTrace
    END FUNCTION
    'o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
    Hopefully it helps?

    Leave a comment:


  • StanHelton
    replied
    Michael Matthias said:
    >That's a nice looking screen.
    >I'm just glad I'm not te guy who has to deal with re-sizing it.

    Take pride in the fact that you are among those who led me to a workable solution.

    Leave a comment:


  • Michael Mattias
    replied
    Oh, my Goodness!

    That's a nice looking screen.

    I'm just glad I'm not te guy who has to deal with re-sizing it.

    Leave a comment:


  • StanHelton
    replied
    Okay. It you MUST ...

    http://stanhelton.com/images/OkHereItIs.jpg

    Leave a comment:


  • Michael Mattias
    replied
    Even given that explanation I am having trouble visualizing three hundred controls on a single screen.

    I simply MUST see a screen shot.

    Leave a comment:


  • StanHelton
    replied
    Originally posted by Michael Mattias View Post
    Three hundred controls?

    I think that is at least two or three screens worth.
    Normally I would agree with you completely, but ...

    It's a real-time monitor and control tool with a live operator. It is imperative that everything stays in proper proportions or it becomes a complete mess.

    They say the customer is always right... especially when he's paying cash.
    Last edited by StanHelton; 27 Feb 2008, 09:23 PM.

    Leave a comment:


  • Michael Mattias
    replied
    >but this particular screen has over 300 controls on it

    Three hundred controls?

    I think that is at least two or three screens worth.

    Leave a comment:


  • StanHelton
    replied
    Originally posted by Patrice Terrier View Post
    I understand your reaction. It's a good thing I'm not doing any serious image work with this app.

    Leave a comment:


  • Patrice Terrier
    replied
    I prefer working in Dialog Units so the pixels were giving me a headache

    Leave a comment:


  • StanHelton
    replied
    This is how I solved this particular problem

    Eric: 1024x1024 ? Oh My! I should have said 1280x1024.

    Wow! So many solutions to this problem! You guys are all really cool!

    I would post a screen shot, but this particular screen has over 300 controls on it and I've squeezed it as much as I can and still make sense of the thing for an end user. I will post a screen shot if you really want to see it. (Don't think it will impress anybody though. )

    Everybody seems to want to see the code. I won't trouble you with the code that DIDN'T work, but based on the suggestions I received, I began looking into the DESKTOP functions native to PB. I prefer working in Dialog Units so the pixels were giving me a headache. I discovered that PB will use Dialog Units to resize controls if you don't specify PIXELS in the DIALOG NEW statement. And I wanted a Cut-and-Paste solution for the control IDs because there are waaaay too many controls in this thing.

    I think I ended up with a pretty good solution. And maybe with this snippet I'll start giving back to the community for a change.

    Here's how I'm controlling the minimum resolution:
    Code:
    FUNCTION PBMAIN()
       LOCAL pxWidth AS LONG
       LOCAL pxHeight AS LONG
       LOCAL lRslt AS LONG
    
       DESKTOP GET SIZE TO pxWidth, pxHeight   ' Get the resolution of the current screen in PIXELS
       IF pxWidth < 1024 OR pxHeight < 768 THEN
          'lRslt is a dummy arg in this case
          lRslt = MSGBOX("You must set your screen resolution to 1024x768 or higher to use this program.", %MB_OK)
       ELSE
          'program code starts here
          
       END IF
    
    END FUNCTION
    And here's my solution for resizing the controls in the window:
    Code:
    CASE %WM_INITDIALOG
       ' Initialization handler for the Problem Window
       ' Fill the ShowScreenControls() array with VALID ProjectScreen id&s  (works for me with 344 controls)
       ARRAY ASSIGN ShowScreenControls() = %IDC_ShowTitle, _
                                           %IDC_txtR1CS_SequenceNumber, _
                                           %IDC_txtR1CS_SequenceNote, _
                                           ...
                                           ...
                                           ...
                                           %IDC_LABEL87
    
       ' Original Design w&h DUs:  846, 574
       DESKTOP GET LOC TO x&, y&  'get client area top left corner
       DIALOG SET LOC ShowScreen, x&, y&   'reposition the dialog to top left corner
    
       DESKTOP GET CLIENT TO pxWidth, pxHeight   'get client size & convert to DUs
       DIALOG PIXELS ShowScreen, pxWidth, pxHeight TO UNITS duWidth, duHeight  'convert pixels to dialog units
       DIALOG SET SIZE ShowScreen, duWidth, duHeight   'resize the dialog to fit available space
    
       'get ratio of size conversion
       wRatio = duWidth / 846
       hRatio = duHeight / 574
    
       'resize and reposition all the controls in the dialog
       FOR ControlPosSizeCheck = 0 TO ArrayUBOUND
          CONTROL GET LOC ShowScreen, ShowScreenControls(ControlPosSizeCheck) TO x&, y&
          x& = x& * wRatio
          y& = y& * hRatio
          CONTROL SET LOC ShowScreen, ShowScreenControls(ControlPosSizeCheck), x&, y&
    
          CONTROL GET SIZE ShowScreen, ShowScreenControls(ControlPosSizeCheck) TO wide&, high&
          wide& = wide& * wRatio
          high& = high& * hRatio
          CONTROL SET SIZE ShowScreen, ShowScreenControls(ControlPosSizeCheck), wide&, high&
       NEXT ControlPosSizeCheck
    Feel free to use it if it helps solve anybody else's problem with this sort of thing. I just noticed that I used "magic numbers" in the ratio formula. I'm going to try the DIALOG USER area to send these numbers. Don't have the code for that yet.

    Again: THANK YOU EVERYBODY! Your suggestions led me to a solution that works for me and is reusable.

    Sincerely,
    Stan

    Leave a comment:


  • Eric Pearson
    replied
    1024 x 1024?

    Leave a comment:


  • Patrice Terrier
    replied
    The solution would be to enum all the child controls and anchor them using the MoveWndow API on the current screen size, like when you resize a window by draging its border.

    I always design my window to work in the minimum 800x600 screen size then i use an anchor property to move the control while resizing the form.
    Last edited by Patrice Terrier; 29 Feb 2008, 03:53 AM. Reason: removed anchor source code

    Leave a comment:


  • Kev Peel
    replied
    What does the screen look like? Maybe someone would get an idea for an alternate screen if they saw what you are trying to do.

    A link to BMP or JPEG or PNG would be good, or post enough code that we could create the screen ourselves.
    :iagree:

    I second that. With some questions it's better to see image(s) of the app to enable us to provide design advice, suggestions, etc.

    Leave a comment:


  • Michael Mattias
    replied
    Then again, you could detect the resolution available at run time, and use/not use a pager control at that time.
    Oooh, oooh....that would be one heck of a demo, wouldn't it?

    Leave a comment:


  • Michael Mattias
    replied
    I suppose you could put all the controls into a pager control. But then when operating at "full vertical size available (1024)" it might look dopey because there is no reason to use a pager control.

    Then again, you could detect the resolution available at run time, and use/not use a pager control at that time.

    What does the screen look like? Maybe someone would get an idea for an alternate screen if they saw what you are trying to do.

    A link to BMP or JPEG or PNG would be good, or post enough code that we could create the screen ourselves.

    MCM

    Leave a comment:


  • Richard Angell
    replied
    Not all windows may lend themselves to the same identical resize scheme. Here's a snip of one that does handle a bunch of controls where in this case there are buttons at the top, right side, and a couple of rows between a left aligned listbox and a textbox. It maintains a minimum overall dialog size of ~800 x ~600. Let's face it there can be limits where allowing the user to size below the such a desired minimum would place controls out of the view.

    Code:
    CALLBACK FUNCTION MainDlgProc() 
        STATIC dw,dh,cw,ch        AS LONG
    
        SELECT CASE AS LONG CBMSG 
    
        CASE %WM_SIZE
                'need to check re-size action minimize, normal, maximize and adjust the screen.
                'we'll leave the buttons the same size, extend the file drop zone and thus have
                'a protected column of controls and drop zone on the right side of the main screen.
                'all that is left then is to size the listbox, it's label and move it's print button
                'Also just extend the direct text box to the right.   minimum resolution 800x600
    
                IF IsIconic(CBHNDL) THEN
                    EXIT FUNCTION   'it is minimized
                ELSEIF IsZoomed(CBHNDL) THEN
                    DIALOG SEND CBHNDL, %WM_SETREDRAW, 0, 0       ' Turn off redraw
                    DESKTOP GET CLIENT TO dw,dh
                    DIALOG SET SIZE CBHNDL,dw,dh
                    DIALOG GET CLIENT CBHNDL TO dw,dh
                ELSE
                    DIALOG SEND CBHNDL, %WM_SETREDRAW, 0, 0       ' Turn off redraw
                    DIALOG GET CLIENT CBHNDL TO dw,dh
                    IF dw < 794 OR  dh< 575 THEN                  ' maintain min dlg size limits
                        dw = 794
                        dh = 575
                        DIALOG SET CLIENT CBHNDL,dw,dh
                    END IF
                END IF
    
                CONTROL SET LOC CBHNDL, %ID_BTN_HELP            ,dw - 154 ,10
                CONTROL SET LOC CBHNDL, %ID_FRM_DROP            ,dw - 154 ,50
                CONTROL SET LOC CBHNDL, %ID_LB_FILES            ,dw - 159 ,66
                CONTROL SET LOC CBHNDL, %ID_BTN_RESET           ,dw - 154 ,dh - 290
                CONTROL SET LOC CBHNDL, %ID_BTN_PRACTICE        ,dw - 154 ,dh - 220
                CONTROL SET LOC CBHNDL, %ID_BTN_LINK2BROWSER    ,dw - 154 ,dh - 185
                CONTROL SET LOC CBHNDL, %ID_BTN_MAKELIST        ,dw - 154 ,dh - 130
                CONTROL SET LOC CBHNDL, %ID_BTN_QUIT            ,dw - 154 ,dh - 55
                CONTROL SET LOC CBHNDL, %ID_LINE3               ,dw - 154 ,dh - 240
                CONTROL SET LOC CBHNDL, %ID_LINE4               ,dw - 154 ,dh - 145
                CONTROL SET LOC CBHNDL, %ID_LINE5               ,dw - 154 ,dh - 70
    
                CONTROL SET SIZE CBHNDL, %ID_LBL_WORDLIST       ,dw - 184 ,20        'sizing
                CONTROL SET SIZE CBHNDL, %ID_LB_WORDS           ,dw - 184 ,dh - 225  'sizing
                CONTROL GET SIZE CBHNDL, %ID_LB_WORDS TO cw,ch
                CONTROL SET LOC CBHNDL, %ID_BTN_PRINT           ,dw - 274 ,30 + ch  'locating
    
                CONTROL SET LOC CBHNDL,%ID_BTN_WAV_BACK     ,10  , dh -193
                CONTROL SET LOC CBHNDL,%ID_BTN_WAV_RECORD       ,80  , dh -193
                CONTROL SET LOC CBHNDL,%ID_BTN_WAV_STOP         ,150  , dh -193
                CONTROL SET LOC CBHNDL,%ID_BTN_WAV_PLAY         ,220 , dh -193
                CONTROL SET LOC CBHNDL,%ID_BTN_WAV_NEXT         ,300 , dh -193
                CONTROL SET LOC CBHNDL,%ID_BTN_WAV_MULTIUSE     ,380 , dh -193
    
                CONTROL SET SIZE CBHNDL, %ID_TEB_WORDS          ,dw - 184 ,95       'sizing
                CONTROL SET LOC CBHNDL, %ID_TEB_WORDS           ,10  ,dh - 120
                CONTROL SET LOC CBHNDL, %ID_LBL_TEXTENTRY       ,10  ,dh - 143
                CONTROL SET LOC CBHNDL, %ID_BTN_SPEAK           ,160 ,dh - 143
                CONTROL SET LOC CBHNDL, %ID_BTN_TEXTSAVE        ,295 ,dh - 143
    
                CONTROL SEND CBHNDL,%ID_SBAR_1, CBMSG,CBWPARAM,CBLPARAM
    
                DIALOG SEND CBHNDL, %WM_SETREDRAW, 1, 0       ' Turn on redraw
                DIALOG REDRAW CBHNDL                          ' and redraw

    Leave a comment:


  • Richard Angell
    replied
    One consideration to keep in mind, if you have not already learned it: DIALOG NEW sets the client size of the dialog window, so you might want to DIALOG SET SIZE based on DESKTOP SIZE/CLIENT function returns during %WM_INITDIALOG. I've found working with PIXELS tends to be a lot easier for me than dialog units. When you go that route, then PBFORMS will size the controls in PIXELS as well, and you are redy to use any of the API's that also return pixels ... many do.

    If you can post the code, we can see your screen and give more educated hints and help though.

    Leave a comment:


  • StanHelton
    replied
    Thanks Michael.
    I will put those equates into my library of good things to know.

    Gosta:
    Yeah, I tried the VSCROLL. It really messed up the logo I have displayed on 2 of the screens though. This is another entry in my good things to know lib.

    Kev:
    Thanks for that code. I think I will stick that code (along with the equates) into my personal #INCLUDE file with all the stuff that HAS to be done every time from now on.

    Richard:
    Thank you. I started resizing and moving things around right after I posted my cry for help. This app has a lot of those non-text controls in it so I am squeezing ht x wd as you suggested. Thanks especially for the lead on the WM_SIZE forum.

    I've tried some new things (for me) graphically on this app so the text-only solutions won't work, but I think I'll find what I need in the WM_SIZE forum.

    As always this is the best place to get help whenever I need it. (Hopefully not being a pain.) Thank you to everybody who responded.

    Stan

    Leave a comment:


  • Richard Angell
    replied
    If it is a simple text only screen, setting the screen size along the lines Michael suggested is part of the equation, but you will also need to reset the text control size and/or location, et.al. for it and any other controls if any.

    It may mean that you are going to need to do several things. If you want to have a special size for just this client, then you will be adjusting only one copy of the program. However if you want it as an adjustable feature, then you should look into several of the resize topic posts in the forum %WM_SIZE.

    Come of the task can be automatic. For example, get the desktop or desktop client size (See the DESKTOP functions) and adjust accordingly. If you allow the client to resize downward from that initial size then you may need a minimum on-screen size, e.g. 800 x 600, 640 x 480.

    In resizing I typically look at what is being displayed. For example if I have a fair amount of buttons and some text/list/listview etc. typical controls then I will figure out relative positions based on their general location on the screen. Then the algo executed in the %WM_SIZE message will resize and relocate the controls accordingly.

    Controls such as buttons, radio buttons and checks. might get resized in a pinch with CONTROL SET SIZE, but mostly in my apps like this I've found I can usually squeeze the textually oriented controls height and width to get the shrink room. Resizing buttons and similar controls may require assigning a smaller font as MCM pointed out. Some buttons may end up getting spaced closer to each other in some cases, and often you can set their position relative to the side of a display ... anchor point in x and/or y for a new CONTROL SET LOC command or proportionately from such a side.

    If you could post the existing code that establishes your window or a screen shot and then folks could point you more clearly along the pathe they might take.

    Leave a comment:

Working...
X