can I resize a program window in Windows to be arbitrarily large?
it seems that the size of the window, e.g. of an open browser开发者_运维技巧, is capped based on the screen size or screen resolution or something along these lines. Is there a way to go around this and make the window arbitrarily tall?
Yes there is. You must override WM_GETMINMAXINFO. In your hook procedure you can set the maximum x/y:
MINMAXINFO* pmmi = (MINMAXINFO*)lParam;
pmmi->ptMaxTrackSize.x = desiredY;
pmmi->ptMaxTrackSize.y = desiredX;
To do this on another process you can use SetWindowsHookEx() with WH_GETMESSAGE.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hGUI = GUICreate("", 250, 100, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_THICKFRAME))
GUICtrlCreateLabel("", 0, 0, 250, 100, -1, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIRegisterMsg($WM_GETMINMAXINFO, "")
Exit
EndSwitch
WEnd
Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $wParam, $lParam
Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
DllStructSetData($minmaxinfo, 7, 250) ; min width
DllStructSetData($minmaxinfo, 8, 100) ; min height
DllStructSetData($minmaxinfo, 9, 3000) ; max width
DllStructSetData($minmaxinfo, 10, 3000) ; max height
Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_GETMINMAXINFO
If you are talking about your own application, you can probably render up to the 16 bit coordinates that are used for GDI sizing. Respond appropriately to WM_GETMINMAXINFO and others.
If you are talking about someone else's, there is no promise that they will render larger than the screen since would be wise to clip their painting to what is visible, and they may be further constrained by other factors (such as the size of a DirectX surface which is smaller than the GDI limit).
Likely if you are scraping you would be better to use MSAA or UIA to manipulate the window from outside and get its text.
Martyn
will (partially) answer my own question. It turns out that for the specific case of my own WinForms app it's just a matter of setting Form.MaximumSize to a big enough value and then increasing Form.ClientSize. I guess this MaximumSize property is a wrapper around the WM_GETMINMAXINFO hook mentioned in the other answers.
精彩评论