2

I'm developing a custom form that provides more options to customize the appearance of the form.I have override the wndproc and calculated the size of the form.While the form's BorderStyle is set to the FormBorderStyle.SizeableToolWindow,the size of the form will decreases.I have no idea about the SizeableToolWindow and i have done some calculation but it fails,Is there any way to fix in the generic way.

if (this.WindowState == FormWindowState.Maximized)
        {
            ///<summary>
            /// local variable to store x-coordinate of native rectangle,rc.left is -8 when maximize the parent form and -6 when maximize the child form.
            ///</summary>
            int xcoordinate = IsMdiChild ? -6 : -8 ;
            rc.left -= xcoordinate;
            rc.right += xcoordinate;
            rc.bottom += xcoordinate;
        }
Sam10
  • 319
  • 2
  • 11
  • Of course the frame is thinner when you set `FormBorderStyle.SizeableToolWindow`. See the [SystemInformation](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.systeminformation) class, it references standard measures; for example `SystemInformation.FixedFrameBorderSize`. Note that these measures are *reliable* if the application behaves in a standard way (or it's your application). *Skinnable* applications bahave in a quite different manner. Don't forget about Windows 10's *invisible* border. – Jimi May 21 '19 at 13:22
  • Hi Jimi,thanks for your valuable comments,I have did some changes in the code as you said but while i test in my secondary screen with the extend mode.it goes out of bounds.Should i consisder the screen and have to calculate. – Sam10 May 23 '19 at 11:33
  • 1
    You can read the current Screen measures correctly only if your app is DPIAware. If not, it's subject to virtualization. The System *translates* all measures to the default 96 DPI (non-DpiAware Win32 API calls included). See this (as a first step) to change the DPIAwareness status of your app: [How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?](https://stackoverflow.com/a/13228495/7444103) and see whether these notes about the Displays and VirtualScreen can help: [Using SetWindowPos with multiple monitors](https://stackoverflow.com/a/53026765/7444103). – Jimi May 23 '19 at 12:01
  • Hi jimi, i have given the dpi aware and there is problem im facing is only when borderStyle is set to sizablewindowtool and I have found issue is with the WM_GETMINMAXINFO,While removing the WM_GETMINMAXINFO its works fine.Im totally struck and i have no idea whats the problem with WM_GETMINMAXINFO. – Sam10 May 23 '19 at 13:24
  • 1
    Read the Remarks section about the [MINMAXINFO](https://learn.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-tagminmaxinfo) structure. Of course, I don't know how you're using the informations provided by the message. You can also read the track sizes using `SystemInformation.MaxWindowTrackSize`, `SystemInformation.MinWindowTrackSize` etc. – Jimi May 23 '19 at 14:08
  • hi jimi, i have come up with some issue, that while running the msdn form in the windows 7 the form maximize in the working area and didnt go behind the task bar.But while i maximize the form in the windows 10 the form goes in the task bar.Is this the behavior of the form.And how to restrict this. – Sam10 Jun 20 '19 at 11:38

0 Answers0