The information in this article applies to:
SUMMARYThe style of Viewer's main window can be changed using the Windows SetWindowLong() function. The prototype for SetWindowLong() is
where hwnd is the handle of the window, nOffset is the offset of the value
to change, and nVal is the new value for the offset. Further documentation
for the SetWindowLong() function can be found in the documentation for the
Windows 3.1 Software Development Kit (SDK). To change the window style, the
value -16 (which is the value of the Windows constant GWL_STYLE) should be
specified for nOffset. The possible values for nVal are combinations of:
These values would be combined simply by or'ing them together. Each call to
SetWindowLong() completely replaces the previous styles for the window with
the new styles specified in the nVal parameter. By default, the main Viewer
window has the styles WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN,
WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX
(that is, nVal=0x16CF0000).
To use SetWindowLong() from Viewer, it must be registered in the [CONFIG] section of the .MVP file as follows:
SetWindowLong() can then be called from anywhere within the title with
hwndApp as the first parameter, -16 as the second parameter, and the
appropriate new style value in the third parameter. Microsoft recommends
always including the WS_VISIBLE, WS_CLIPSIBLINGS, and WS_CLIPCHILDREN
styles in the new value. That means the value of nVal would always be at
least 0x16000000.
Note that SetWindowLong() is registered with the first parameter as an unsigned long (U) even though the SetWindowLong() function properly takes an HWND, which is an unsigned short int (u) in Windows 3.1, as the first parameter. SetWindowLong() must be registered this way if the internal hwndApp variable, which is an unsigned long, is to be passed to it. Because of the way arguments are passed, SetWindowLong() will still work correctly; the high word of hwndApp, which is zero-filled, will be ignored. However, if an unsigned short value will be passed to SetWindowLong(), then RegisterRoutine() must specify "u" for the first parameter. A Viewer title could obtain an unsigned short window handle by calling one of the Windows functions such as GetParent(). To remove the maximize box from the main Viewer window, the SetWindowLong() call would look as follows:
To cause the main window frame to be redrawn immediately after the change
to its style, you may need to call the Windows function SetWindowPos(). It
can be registered as follows
and then it can be called from anywhere within the title as follows:
The SetWindowPos() call above is equivalent to calling
SetWindowPos(hwndApp,0,0,0,0,0,SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE |
SWP_NOZORDER) using the Windows constants defined in the WINDOWS.H include
file from the Windows SDK.
MORE INFORMATION
The following list describes the styles mentioned above:
Additional query words: 2.00 2.00a
Keywords : |
Last Reviewed: December 23, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |