Announcement

Collapse
No announcement yet.

Wrong screen resolution problem

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

  • #21
    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.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #22
      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.
      Do not go quiet into that good night,
      ... Rage, rage against the dark.

      Comment


      • #23
        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?
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #24
          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
          Do not go quiet into that good night,
          ... Rage, rage against the dark.

          Comment

          Working...
          X