PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Martin Francom on July 19, 2012, 04:21:10 PM

Title: Screen Resolution Problems
Post by: Martin Francom on July 19, 2012, 04:21:10 PM
Paul,
    I have a couple of problems with the program window being displayed correctly at the screen resolution set on the monitor.   
    1) I have the size of the main programs window to be a height of 782 and width 1092.   I would think if the monitors resolution was set to 1280x800  that the program should fix nicely.  But it does not... the program is displayed much, much bigger that what would fit on the monitor.
    Why does FF361 generated program have this problem?  What can I do about it?  How do I get the program to display properly?   This was not a problem with FF35.

    2) The program is also displayed different on a 32bit Win7 computer than on a 64bit Win7 computer.  See images.  Note the improper display of the left column of buttons on the image of the 32bit computer.   
What's up with this and how do I correct it?

Title: Re: Screen Resolution Problems
Post by: Martin Francom on July 19, 2012, 05:23:23 PM
More finding that make this even more curious...
I tested the program on a Vista Computer where the screen resolution was set to 1280 by 1024 and the program's main window displayed properly.

I increase the resolution on my ASUS 64bit with ViewSonic monitor to 1920x1080 and then the program displayed and fit properly on the monitor.

I increase the resolution on my 32bit DELL Laptop to 1920x1200 and the program display properly  except for the left had column of button was not displaying properly. Still had the problem illustrated by the the attached images above.

I don't understand why I am getting such varied results.  Quite aggravating.  I would have thought that a FF program designed for a specific resolution would display the same way on all computers set to the specific resolution.  Apparently not.   
Any explanation why this is so?
Title: Re: Screen Resolution Problems
Post by: Paul Squires on July 19, 2012, 07:42:02 PM
Hi Marty,

Two things:
Use the latest FF3 (3.61) http://www.planetsquires.com/protect/forum/index.php?topic=3097.msg23133#msg23133

Read the Help file topic called "High DPI Aware"

I believe that code in your program may be using the AfxScaleX and AfxScaleY functions when you are trying to position controls/child windows using absolute pixel locations.
Title: Re: Screen Resolution Problems
Post by: Martin Francom on July 19, 2012, 10:00:40 PM
Paul,
   Thanks for the reply.  I verified that I am using FF 3.61  (At least that's what FF Help/About screen reports.  Also, I have downloaded Jose's WinAPI's from the link you have provided.  And I have read the Topic "HIGH DPI Aware"  from the FF Help - User Reference Guide.

    I have done a Search In Files (Entire Project) for  "SetWindowPos"  I have found a number of them.  I have made the changes, such as:

SetWindowPos gMenu, %HWND_TOP, AfxScaleX(0), AfxScaleY(0), nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW

SetWindowPos HWND_FORMLOGON, %HWND_TOP, AfxScaleX(nMenuWidth-20) , AfxScaleY(0), rc.nRight-nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW

Paul,  to get the two windows to align I have to add and subtract  a fug factor.
This is the code for the Img64b2.jpg    The Left Column form is 80 wide but I had to add 20 to get it to display correctly on the 64bit Asus computer.

   GetClientRect HWND_FRMMAIN, rc
   ' Display the left hand side menu. This menu pane is always a fixed
   ' width no matter what size the form is.
   Local nMenuWidth As Long
   nMenuWidth = 100

   If sMenu <> gMenu Then
      SetWindowPos gMenu, %HWND_TOP, AfxScaleX(0), AfxScaleY(0), nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW
'    ' Hide the other non active menus
      If HWND_formCntrls1 <> gMenu Then ShowWindow HWND_formCntrls1, %SW_HIDE
      If HWND_formCntrls2 <> gMenu Then ShowWindow HWND_formCntrls2, %SW_HIDE
     ' If HWND_formCntrls3 <> gMenu Then ShowWindow HWND_formCntrls3, %SW_HIDE
     ' If HWND_formCntrls4 <> gMenu Then ShowWindow HWND_formCntrls4, %SW_HIDE
      sMenu = gMenu
   End If
   
   If sScreen = gScreen Then done = 0 : Exit Function
   sScreen = gScreen
   ' Show the right pane window. This pane will start at the right edge of the
   ' menu pane and extend to the right edge of the main form.
   Select Case gScreen
      Case 1   'HWND_FORMLOGON      : ShowWindow HWND_FORMLOGON, %SW_HIDE
         SetWindowPos HWND_FORMLOGON, %HWND_TOP, AfxScaleX(nMenuWidth -20) , AfxScaleY(0), rc.nRight-nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW
      Case 2   'HWND_FORMRX         : ShowWindow HWND_FORMRX, %SW_HIDE
         SetWindowPos HWND_FORMRX, %HWND_TOP, AfxScaleX(nMenuWidth - 20) , AfxScaleY(0), rc.nRight-nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW     



I shouldn't have to add/subtract a fug factor, should I ?

Now look at Img32b2.jpg. This is from my 32 bit Dell Laptop.  Note how the two forms that should meet are off.  And the left column button form is truncated.

Any ideas or suggestions?     If it would help, I could write a simple demo program and see if the same behavior is seen.


Title: Re: Screen Resolution Problems
Post by: Martin Francom on July 20, 2012, 03:54:01 AM
Paul,  I have create a very simple FF project that demonstrates the problem that I am having.  When I compile and run the program the main screen does not a get built the way I would expect.

I have attached screen print of the running program to illustrate the problem. 
Also attached in the zipped up FF361 project.  In the event you have the time to
take a look.   

You help is always appreciated.  Thanks...

Title: Re: Screen Resolution Problems
Post by: Paul Squires on July 20, 2012, 01:35:21 PM
Hi Marty,

There is more to the High DPI issues than simply changing the calls to SetWindowPos. Anywhere in your program where you are using an absolute, literal numeric value, you will need to scale it. Here is a prime example that I immediately saw in your FormRX code:

    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5


The values 16, 5, need to be scaled. AfxScaleX/AfxScaleY.

Here is another:

    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10

Those two 10's need to be scaled.

In your frmMain code under ShowMainFormPanes your trouble is most likely with the nMenuWidth variable which you arbitrarily set to be 100 pixels. Well, a 100 pixels may work fine on a standard 96 DPI display but it will need to be scaled when the resolutions change.

   Local nMenuWidth As Long
   nMenuWidth = AfxScaleX(100)

Once you scale the nMenuWidth you need to modify your SetWindowPos calls.

   Select Case gScreen
      Case 1   'HWND_FORMLOGON      : ShowWindow HWND_FORMLOGON, %SW_HIDE
         SetWindowPos HWND_FORMLOGON, %HWND_TOP, nMenuWidth-AfxScaleX(20) , 0, rc.nRight-nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW
      Case 2   'HWND_FORMRX         : ShowWindow HWND_FORMRX, %SW_HIDE
         SetWindowPos HWND_FORMRX, %HWND_TOP, nMenuWidth , 0, rc.nRight-nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW     


Notice that I scaled the "20" but didn't bother to scale the "0". No need to scale the "0" because anything multiplied by zero is still zero. I also did not scale the rc coordinates because the GetClientRect will already give you scaled amounts.

I bet if you go through your entire pharmacy program that you will find countless areas that need to be fixed. I had to fix a lot in the FireFly application itself in order to make it high dpi resolution aware.

There is no quick fix to this problem. Going back over an older program specifically designed at 96 DPI is a lot of work. Creating new programs from scratch is so much easier.
Title: Re: Screen Resolution Problems
Post by: Martin Francom on July 20, 2012, 02:51:40 PM
Paul,  Thanks.... looks like I have some work ahead of me.

Just so I understand, 
   pTop and pBottom need to be scaled but pLeft and pRight do not.
   Why don't pLeft and pRight need to be scaled?
   How do I know when AfxscaleX or AfxScaleY  are to be used? 
      Are AfxScaleX always used on "Top" values and AfxScaleY always used on "Bottom" values    and never used for "Left" or "Right" values ?
     
      Does it matter where I scale?   ie:

    pTop    = AfxScaleX (pTop    + 16)
    pBottom = AfxScaleY (pBottom - 5)
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
       

or like this:


    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    RoundRect hDC, pLeft, AfxScaleX(pTop), pRight, AfxScaleY(pBottom), 10, 10
 

why won't I need to scale all the values?  Like this:

    RoundRect hDC, AfxScaleX(pLeft), AfxScaleX(pTop), AfxScaleY(pRight), AfxScaleY(pBottom), AfxScaleX(10), AfxScaleY(10)
     

Other than when the value is zero, Is there any time that I would not scale those values?

If those values always need to be scaled when using FF361, is there any reason that
FireFly could not automatically add the scaler to those values when it does the code generation?

Why would writing a new program from scratch be easier?  If I used the same commands in the program wouldn't I still have to scale their variables?

Title: Re: Screen Resolution Problems
Post by: Martin Francom on July 20, 2012, 03:45:25 PM
Paul,  I gotten it working properly on both my 32bit Dell Laptop and my 64bit ASUS Desktop.   
    I put the scaler on Top, Bottom, Left and Right values.  Also, I had values set on the frmMain for  MinWidth, MinHeight, MaxWidth and MaxHeight    I needed to remove those values and then the problem was fixed.   And fortunately I did not have to tract down any other areas where value need to be scaled.  Running the program now everything looks correct. 

    Thanks again for the help!  You and FireFly are very much appreciated.   
Title: Re: Screen Resolution Problems
Post by: Paul Squires on July 20, 2012, 03:48:40 PM
Quote from: Marty Francom on July 20, 2012, 02:51:40 PM
Just so I understand, 
   pTop and pBottom need to be scaled but pLeft and pRight do not.
No, your pTop, PBottom, pLeft and pRight are okay because they come from the FF_Control_GetLoc/GetSize functions that internally call Windows API that already return the correctly scaled pixel location.

It is adding those scalar numeric values that need to be scaled. ie. the +16, -5, +5, -5

As I said in my previous post:
Quote
The values 16, 5, need to be scaled. AfxScaleX/AfxScaleY.

Here is what it should look like:

    pTop    = pTop    + AfxScaleY(16)
    pBottom = pBottom - AfxScaleY(5)
    pLeft   = pLeft   + AfxScaleX(5)
    pRight  = pRight  - AfxScaleX(5)



Quote
   How do I know when AfxscaleX or AfxScaleY  are to be used? 
You need to know why scaling is necessary...then it becomes crystal clear when to use it.


    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
Should be:
    RoundRect hDC, pLeft, pTop, pRight, pBottom, AfxScaleX(10), AfxScaleY(10)
       

Quote
If those values always need to be scaled when using FF361, is there any reason that
FireFly could not automatically add the scaler to those values when it does the code generation?
FireFly can't read the programmer's mind. There are times when scaling should be used and other times when it shouldn't. Only the programmer can make those decisions.

Quote
Why would writing a new program from scratch be easier?  If I used the same commands in the program wouldn't I still have to scale their variables?
It is a lot easier to make the decisions about when to apply the scaling code as you are writing your code than having to go back over thousands of lines of code after the fact.
Title: Re: Screen Resolution Problems
Post by: Martin Francom on July 20, 2012, 08:30:00 PM
Paul,
    I tried adding the Scaler to the other values as you suggested and the result was much worse.  The image  ImgWithScaler.jpg  has the Scaler applied to all values as the code snippet shows:

Function FORMRX_WM_PAINT ( _
                         hWndForm      As Dword _  ' handle of Form
                         ) As Long
                         
                         
    Local hDC      As Dword
    Local hDC_Save As Dword
    Local hBrush   As Dword
    Local ps1      As PAINTSTRUCT
   
    Local pTop     As Long
    Local pLeft    As Long
    Local pBottom  As Long
    Local pRight   As Long


    hDC = BeginPaint(hWndForm,ps1)
   
    hDC_Save = SaveDC( hDC )


   
    'RX
    FF_Control_GetLoc (HWND_FORMRX_FRAME5, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME5, pRight, pBottom)
    pRight  = pRight  + pLeft - AfxScaleX(1)
    pBottom = pBottom + pTop  - AfxScaleX(1)
     
    pTop    = pTop    + AfxScaleX(16)
    pBottom = pBottom - AfxScaleY(5)
    pLeft   = pLeft   + AfxScaleX(5)
    pRight  = pRight  - AfxScaleY(5)

    hBrush = CreateSolidBrush( Rgb(166,166,255) )  'periwinkle
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, AfxScaleX(10), AfxScaleY(10)
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   

    'PATIENT
    FF_Control_GetLoc (HWND_FORMRX_FRAME4, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME4, pRight, pBottom)
    pRight  = pRight  + pLeft - AfxScaleX(1)
    pBottom = pBottom + pTop - AfxScaleX(1)
     
    pTop    = pTop - AfxScaleX(16)
    pBottom = pBottom - AfxScaleY(5)
    pLeft   = pLeft + AfxScaleX(5)
    pRight  = pRight - AfxScaleY(5)

    hBrush = CreateSolidBrush( Rgb(190,255,255) ) 'light teal
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, AfxScaleX(10), AfxScaleY(10)
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   
   
    EndPaint hWndForm, ps1
   
    RestoreDC hDC, hDC_Save

End Function



The image  ImgWithOutScaler.jpg  shows the screen with out the scaler applied the functions in the following code:

Function FORMRX_WM_PAINT ( _
                         hWndForm      As Dword _  ' handle of Form
                         ) As Long
                         
                         
    Local hDC      As Dword
    Local hDC_Save As Dword
    Local hBrush   As Dword
    Local ps1      As PAINTSTRUCT
   
    Local pTop     As Long
    Local pLeft    As Long
    Local pBottom  As Long
    Local pRight   As Long


    hDC = BeginPaint(hWndForm,ps1)
   
    hDC_Save = SaveDC( hDC )


   
    'RX
    FF_Control_GetLoc (HWND_FORMRX_FRAME5, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME5, pRight, pBottom)
    pRight  = pRight  + pLeft - 1
    pBottom = pBottom + pTop  - 1
     
    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    hBrush = CreateSolidBrush( Rgb(166,166,255) )  'periwinkle
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   

    'PATIENT
    FF_Control_GetLoc (HWND_FORMRX_FRAME4, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME4, pRight, pBottom)
    pRight  = pRight  + pLeft - 1
    pBottom = pBottom + pTop  - 1
     
    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    hBrush = CreateSolidBrush( Rgb(190,255,255) ) 'light teal
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   

                         
    'DOCTOR
    FF_Control_GetLoc (HWND_FORMRX_FRAME2, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME2, pRight, pBottom)
    pRight  = pRight  + pLeft - 1
    pBottom = pBottom + pTop  - 1
     
    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    hBrush = CreateSolidBrush( Rgb(230,180,130) ) 'light buff tan
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   
   
   
    'DRUG
    FF_Control_GetLoc (HWND_FORMRX_FRAME3, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME3, pRight, pBottom)
    pRight  = pRight  + pLeft - 1
    pBottom = pBottom + pTop  - 1
     
    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    hBrush = CreateSolidBrush( Rgb(200,255,180) ) 'buff light green
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   
   
   
    'RX FILL
    FF_Control_GetLoc (HWND_FORMRX_FRAME7, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME7, pRight, pBottom)
    pRight  = pRight  + pLeft - 1
    pBottom = pBottom + pTop  - 1
     
    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    hBrush = CreateSolidBrush( Rgb(218,191,165) ) 'buff
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   
   
   
    'PRICE
    FF_Control_GetLoc (HWND_FORMRX_FRAME1, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME1, pRight, pBottom)
    pRight  = pRight  + pLeft - 1
    pBottom = pBottom + pTop  - 1
     
    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    hBrush = CreateSolidBrush( Rgb(225,179,253) ) 'light purple
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   
   
    'Button Frame
    FF_Control_GetLoc (HWND_FORMRX_FRAME8, pLeft, pTop)
    FF_Control_GetSize (HWND_FORMRX_FRAME8, pRight, pBottom)
    pRight  = pRight  + pLeft - 1
    pBottom = pBottom + pTop  - 1
     
    pTop    = pTop    + 16
    pBottom = pBottom - 5
    pLeft   = pLeft   + 5
    pRight  = pRight  - 5

    hBrush = CreateSolidBrush( Rgb(205,238,145) ) '
    hBrush = SelectObject( hDC, hBrush )
    ' left,top,right,bottom,cornerwidth,cornerheight
    RoundRect hDC, pLeft, pTop, pRight, pBottom, 10, 10
    ' Delete the brush. Must put the old brush back into the hDC
    ' because you can not delete a brush if it is already in selected.
    DeleteObject SelectObject( hDC, hBrush )   

   
   
    EndPaint hWndForm, ps1
   
    RestoreDC hDC, hDC_Save

End Function



The only area that I found the I needed the scaler function with in the function that displays the forms.   I don't know why that is,  I am just reporting my observations:

Function ShowMainFormPanes() As Long

   ' Move the panes into position depending on which left menu
   ' pane is active.
   Local rc As Rect
   Local wk As Long 
   Static sMenu As Long
   Static sScreen As Long
   Static done As Long
   If done <> 0 Then Exit Function
   done = 1
   
   GetClientRect HWND_FRMMAIN, rc
   ' Display the left hand side menu. This menu pane is always a fixed
   ' width no matter what size the form is.
   Local nMenuWidth As Long
   nMenuWidth = 80

   If sMenu <> gMenu Then
      SetWindowPos gMenu, %HWND_TOP, AfxScaleX(0), AfxScaleY(0), AfxScaleX(nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
'    ' Hide the other non active menus
      If HWND_formCntrls1 <> gMenu Then ShowWindow HWND_formCntrls1, %SW_HIDE
      If HWND_formCntrls2 <> gMenu Then ShowWindow HWND_formCntrls2, %SW_HIDE
     ' If HWND_formCntrls3 <> gMenu Then ShowWindow HWND_formCntrls3, %SW_HIDE
     ' If HWND_formCntrls4 <> gMenu Then ShowWindow HWND_formCntrls4, %SW_HIDE
      sMenu = gMenu
   End If
   
   If sScreen = gScreen Then done = 0 : Exit Function
   sScreen = gScreen
   ' Show the right pane window. This pane will start at the right edge of the
   ' menu pane and extend to the right edge of the main form.
   Select Case gScreen
      Case 1   'HWND_FORMLOGON      : ShowWindow HWND_FORMLOGON, %SW_HIDE
         SetWindowPos HWND_FORMLOGON, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 2   'HWND_FORMRX         : ShowWindow HWND_FORMRX, %SW_HIDE
         SetWindowPos HWND_FORMRX, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW     
      Case 3   'HWND_FORMConfigInfo : ShowWindow HWND_FORMConfigInfo, %SW_HIDE
         SetWindowPos HWND_FORMConfigInfo, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 4   'HWND_FORMPATINFO    : ShowWindow HWND_FORMPATINFO, %SW_HIDE
         SetWindowPos HWND_FORMPATINFO, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 5   'HWND_FORMPatScripts : ShowWindow HWND_FORMPatScripts, %SW_HIDE
         SetWindowPos HWND_FORMPatScripts, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 6   'HWND_FORMDOCINFO    : ShowWindow HWND_FORMDOCINFO, %SW_HIDE
         SetWindowPos HWND_FORMDOCINFO, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 7   'HWND_FORMDocScripts : ShowWindow HWND_FORMDocScripts, %SW_HIDE
         SetWindowPos HWND_FORMDocScripts, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 8   'HWND_FORMDRUGINFO   : ShowWindow HWND_FORMDRUGINFO, %SW_HIDE
         SetWindowPos HWND_FORMDRUGINFO, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 9   'HWND_FORMDocScripts : ShowWindow HWND_FORMDocScripts, %SW_HIDE
         SetWindowPos HWND_FORMDRUGScripts, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 10   'HWND_FormDrugCmpd   : ShowWindow HWND_FormDrugCmpd, %SW_HIDE
         SetWindowPos HWND_FormDrugCmpd, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 11   'HWND_FORMSIGINFO    : ShowWindow HWND_FORMSIGINFO, %SW_HIDE
         SetWindowPos HWND_FORMSIGINFO, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 12   'HWND_FORMPRICETABLE : ShowWindow HWND_FORMPRICETABLE, %SW_HIDE
         SetWindowPos HWND_FORMPRICETABLE, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 13   'HWND_FORMINSURANCE  : ShowWindow HWND_FORMINSURANCE, %SW_HIDE
         SetWindowPos HWND_FORMINSURANCE, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 14   'HWND_FORMREPORTS    : ShowWindow HWND_FORMREPORTS, %SW_HIDE
         SetWindowPos HWND_FORMREPORTS, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 15   'HWND_FORMCLAIMS1    : ShowWindow HWND_FORMCLAIMS1, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMS1, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 16   'HWND_FORMCLAIMS2    : ShowWindow HWND_FORMCLAIMS2, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMS2, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 17   'HWND_FORMCLAIMS3    : ShowWindow HWND_FORMCLAIMS3, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMS3, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 18   'HWND_FORMCLAIMS4    : ShowWindow HWND_FORMCLAIMS4, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMS4, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 19   'HWND_FORMCLAIMS5    : ShowWindow HWND_FORMCLAIMS5, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMS5, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 20   'HWND_FORMCLAIMS6    : ShowWindow HWND_FORMCLAIMS6, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMS6, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 21   'HWND_FORMCLAIMR1    : ShowWindow HWND_FORMCLAIMR1, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMR1, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 22   'HWND_FORMCLAIMR2    : ShowWindow HWND_FORMCLAIMR2, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMR2, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
      Case 23   'HWND_FORMCLAIMR3    : ShowWindow HWND_FORMCLAIMR3, %SW_HIDE
         SetWindowPos HWND_FORMCLAIMR3, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), AfxScaleX(rc.nRight-nMenuWidth), AfxScaleY(rc.nBottom), %SWP_SHOWWINDOW
         
   End Select
   
  ' If sScreen = gScreen Then done = 0 : Exit Function
  ' SetWindowPos gScreen, %HWND_TOP, AfxScaleX(nMenuWidth) , AfxScaleY(0), rc.nRight-nMenuWidth, rc.nBottom, %SWP_SHOWWINDOW
   
   
   ' Hide the other non active right panes
   Select Case sScreen
      Case HWND_FORMLOGON      : ShowWindow HWND_FORMLOGON, %SW_HIDE
      Case HWND_FORMRX         : ShowWindow HWND_FORMRX, %SW_HIDE
      Case HWND_FORMConfigInfo : ShowWindow HWND_FORMConfigInfo, %SW_HIDE
      Case HWND_FORMPATINFO    : ShowWindow HWND_FORMPATINFO, %SW_HIDE
      Case HWND_FORMPatScripts : ShowWindow HWND_FORMPatScripts, %SW_HIDE
      Case HWND_FORMDOCINFO    : ShowWindow HWND_FORMDOCINFO, %SW_HIDE
      Case HWND_FORMDocScripts : ShowWindow HWND_FORMDocScripts, %SW_HIDE
      Case HWND_FORMDRUGINFO   : ShowWindow HWND_FORMDRUGINFO, %SW_HIDE
      Case HWND_FORMDocScripts : ShowWindow HWND_FORMDocScripts, %SW_HIDE
      Case HWND_FormDrugCmpd   : ShowWindow HWND_FormDrugCmpd, %SW_HIDE
      Case HWND_FORMSIGINFO    : ShowWindow HWND_FORMSIGINFO, %SW_HIDE
      Case HWND_FORMPRICETABLE : ShowWindow HWND_FORMPRICETABLE, %SW_HIDE
      Case HWND_FORMINSURANCE  : ShowWindow HWND_FORMINSURANCE, %SW_HIDE
      Case HWND_FORMREPORTS    : ShowWindow HWND_FORMREPORTS, %SW_HIDE
      Case HWND_FORMCLAIMS1    : ShowWindow HWND_FORMCLAIMS1, %SW_HIDE
      Case HWND_FORMCLAIMS2    : ShowWindow HWND_FORMCLAIMS2, %SW_HIDE
      Case HWND_FORMCLAIMS3    : ShowWindow HWND_FORMCLAIMS3, %SW_HIDE
      Case HWND_FORMCLAIMS4    : ShowWindow HWND_FORMCLAIMS4, %SW_HIDE
      Case HWND_FORMCLAIMS5    : ShowWindow HWND_FORMCLAIMS5, %SW_HIDE
      Case HWND_FORMCLAIMS6    : ShowWindow HWND_FORMCLAIMS6, %SW_HIDE
      Case HWND_FORMCLAIMR1    : ShowWindow HWND_FORMCLAIMR1, %SW_HIDE
      Case HWND_FORMCLAIMR2    : ShowWindow HWND_FORMCLAIMR2, %SW_HIDE
      Case HWND_FORMCLAIMR3    : ShowWindow HWND_FORMCLAIMR3, %SW_HIDE
   End Select
   sScreen = gScreen
   'set the background color to use for all Disabled TextBoxes
   ghBrushDisabled = CreateSolidBrush( %RGB_HoneyDew )
   done = 0
   
End Function



Way I have it in the image ImgWithOutScaler.jpg  seems to work correctly  so I guess for now I will leave the code the way I have it.   I have tried setting the DPI in the Display setting from 100 to125 to 150  and this code seems to play will with those settings.

Paul, is there some other way I can test my program to see if breaks under different display setting.  Have tried only the default monitor resolution.  I will try some other setting there to see if it breaks.

Paul, any idea why the AfxScaleX/AfxScaleY  were not needed and caused problems in the Function FORMRX_WM_PAINT  ? 
Title: Re: Screen Resolution Problems
Post by: José Roca on July 21, 2012, 01:14:32 AM
It depends of which functions do you use. The old FF_ functions, such FF_Control_GetSize, return the values scaled; therefore, you don't have to scale them. If you were using pWindow.GetHeight / pWindow.GetWidth, that return the result unscaled, then you will have to scale them.
Title: Re: Screen Resolution Problems
Post by: Richard Kelly on July 21, 2012, 03:14:34 PM
I'm getting ready to start a new project. I set my options for form/control(s) resizing and plan on using the font upgrade feature. Beyond that I don't usually concern myself with positioning after I've designed the form and placed my controls. Are there now additional resolution related things I have to be thinking about? If I set my main form size to say, 1024x768 does that size get automatically adjusted based on the current screen resolution? My development computer is win 7x64 professional running 1920x1200 on a 30 in LCD monitor. Will that have any impact on on my app's look and feel?

Rick
Title: Re: Screen Resolution Problems
Post by: José Roca on July 21, 2012, 06:24:40 PM
Screen resolution and High DPI are different animals. The program will be scaled if you set a DPI higher than 96; otherwise not.