Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form with MaxWidth/MaxHeight maximizes
Message
From
13/02/2014 10:24:14
 
 
To
13/02/2014 10:13:42
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01594236
Message ID:
01594240
Views:
106
>I have a form class for which I've set MaxWidth and MaxHeight. When I click the maximize button in the form, it properly maximizes to the size I've specified.
>However, the form runs inside a top-level window. If the top-level window is minimized and then restored while my form is maximized, when it reappears, my form now fills the top-level window, ignoring MaxWidth and MaxHeight. The same thing happens if I maximize the top-level window while my form is maximized.
>Anybody run into this? Have any ideas how to prevent it?
>Tamar

On windows where I've needed a hard size I've used a DLL to subclass the window, intercepting and altering the WM_SIZING message that is sent continually as the user resizes a window, which allows the program to alter the size and affix it to a maximum or minimum). I have invoked this as some startup code in Init() which registers the thisForm.hwnd, and the min and max widths and heights.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632646%28v=vs.85%29.aspx

In VFP, you can BINDEVENT() to the WM_SIZE message to physically receive the window after the sizing event is completed, to restore it to what size it should've been:
* In the form's Init()
#define WM_SIZE 0x0005
BINDEVENT(thisForm.hwnd, WM_SIZE, thisForm, "onSize")


* Your onSize() method:
LPARAMETERS hwnd, message, wParam, lParam
LOCAL lnWidth, lnHeight

    * The low-order word of lParam specifies the new width of the client area.
    lnWidth = BITAND(lParam, 0xffff)

    * The high-order word of lParam specifies the new height of the client area.
    lnHeight = BITRSHIFT(lParam, 16)

    IF lnWidth > thisForm.maxWidth
        thisForm.width = thisForm.maxWidth
    ENDIF

    IF lnHeight > thisForm.maxHeight
        thisForm.height = thisForm.maxHeight
    ENDIF
Hope this helps.


-----
Edit: I just noticed that the width and height are the client area values. You may need to add in SYSMETRIC() functions to get it to the size of your form (2x window borders, and for height add in title bar height (and optional menu height)). Or, rather than using lnWidth use thisForm.width, and rather than lnHeight use thisForm.height, however those values may not be correct in a condition like this. It depends on how Microsoft programmed Visual FoxPro to record and report on its height and width parameters (which could be out of sync with the actual width and height depending on a few things).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform