Form Resizing and DPI aware

Started by Richard Kelly, December 03, 2012, 12:09:42 AM

Previous topic - Next topic

Richard Kelly

I'm using Win 7 with DPI set to 125%. I have a form imported from FF 3.51 that I had the min/max set to the form's size to prevent any user resizing. FF 3.61 shows the form adjusted for my current DPI and that is all and good. When I run the application, the min/max values are not adjusted for my DPI settings so the form actually runs at the 96 dpi settings and is clipped both horizontally and vertically. Of course, removing the min/max values allows the form to display as it shows on the designer.

How do I set min/max so my form min/max sizes work without regard to DPI settings? Should I set my DPI to 96 or 100% for development sessions? I've been using the "normal" 96 dpi setting for running FF when I'm designing and then testing on higher dpi settings to see that all still looks acceptable. Those min/max values just need to be scaled.

For a bit of theorizing, I took the form's BAS file in the release folder and made the following changes:


       Case %WM_GETMINMAXINFO
          ' Do not process this message for MDI Child forms because it will interfere
  ' with the maximizing of the child form.
          If ( GetWindowLong(hWndForm, %GWL_EXSTYLE) And %WS_EX_MDICHILD ) <> %WS_EX_MDICHILD Then
             DefWindowProc hWndForm, wMsg, wParam, lParam
             Local FLY_pMinMaxInfo As MINMAXINFO Ptr
             FLY_pMinMaxInfo = lParam
             @FLY_pMinMaxInfo.ptMinTrackSize.x = AfxScaleX(403)
             @FLY_pMinMaxInfo.ptMinTrackSize.y = AfxScaleY(427)
             @FLY_pMinMaxInfo.ptMaxTrackSize.x = AfxScaleX(403)
             @FLY_pMinMaxInfo.ptMaxTrackSize.y = AfxScaleY(427)
             Function = 0: Exit Function
          End If


I simply changed the min/max x/y values that were hard coded as 403/427 and used AfxScaleX/AfxScaleY. Then I fired up PB10 and compiled the application directly and ran it. The form size is now perfectly proportional.

My only annoying problem with FF is that it always show me in the designer based on current DPI settings. I would like to design at 96 dpi and have options to take a peek at other dpi settings. Run time is always DPI aware.

Rick Kelly

Paul Squires

Hi Rick, nice catch - thanks! I am modifying the generated code to add the AfxScale functions to the hardcoded values.

I intend to soon generate a new FF release that incorporates all of the recent changes and bug fixes.

Thanks!
Paul Squires
PlanetSquires Software

Richard Kelly

Your are welcome. Good news on the FF 3.61 official release. I'm just going to remove the min/max values for now and restore them when the new release arrives. :)

Rick Kelly