------
#include <windows.h>
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_LBUTTONDOWN:
ShowWindow(hwnd, IsZoomed(hwnd) ? SW_RESTORE : SW_MAXIMIZE);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE inst, HINSTANCE, LPSTR, int) {
WNDCLASSEX wc = {sizeof(wc), 0, WinProc, 0, 0, inst, 0, 0,
HBRUSH(COLOR_BACKGROUND), 0, "TEST", 0};
RegisterClassEx(&wc);
CreateWindowEx(0, "TEST", "", 0
| WS_VISIBLE
| WS_SIZEBOX
| WS_POPUP
// | WS_CAPTION
// | WS_SYSMENU
, 100, 100, 400, 300, 0, 0, inst, 0);
MSG msg;
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
Use WS_OVERLAPPED instead of WS_POPUP.
--
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/
Thanks, but WS_OVERLAPPED doesn't work either, it causes the title bar to
appear as if WS_CAPTION had been specified.
The kludge I use right now is to process the WM_GETMINMAXSIZE message, check
the size of the desktop, check the location of the taskbar and adjust the
maximum size and location according to the current settings. But it's still
a kludge, Windows should be doing all that automatically as it does for
other window styles. It looks like it just gets confused by the absence of
a caption bar and provides the wrong size information...
I suppose most folks can't use maximize and restore without the icons
that appear on the title bar. But your findings are still a bit
surprising.
If you want a slightly different approach, here are some functions I
use I use to maximize a window with or without hiding the task bar.
The first two are global function . The last is part of a class. All
three are mangled by my news client.
//
--------------------------------------------------------------------
// PFWHwndCheck
inline BOOL PFWHwndCheck( HWND hWnd )
{
// NOTE: The CE version of ::IsWindow hangs when hWnd =
INVALID_HWND_VALUE, which
// suggests that the CE versions of the Win32 functions are
sensitive, so this
// function should be called before any Win32 function that uses
an HWND
// TODO: Check source for GetSafeHwnd (in MFC) for ideas (Stefan
Ring,
// comp.os.ms-windows.programmer.win32, 30 Jul 00)
return ( hWnd != NULL && hWnd != INVALID_HWND_VALUE &&
::IsWindow( hWnd ) );
} // PFWHwndCheck
BOOL PFWTaskBarSetVisibility( BOOL bShow )
{
// NOTE: See 25 Jul 02 contribution form Jane Shaughnessy to
thread called
// "Class name for SIP button" in windowsce developer list. The
note says
// the class name for the SIP button is MS_SIPBUTTON, so perhaps
that info
// can be used to hide the button.
// TODO: Check this
// NOTE: Jim M (19 Oct 2000 contribution
// to "Full Screen" thread in
microsoft.public.windowsce.embedded.vc) points
// out that this method doesn't let the OS know the SIP is
hidden, so other
// apps don't know and are likely to appear in "almost" full
screen.
int nVis = bShow ? SW_SHOW : SW_HIDE;
#ifdef UNDER_CE
// Eric R. Balch (microsoft.public.vc.vcce 15 Jan 99) says next
line works for CE
HWND hWnd = ::FindWindow( _T( "HHTaskBar" ), NULL );
#else
// The following works on Window NT
// ( thanks to Shing Yip, comp.os.ms-windows.programmer.win32, 21
Jul 99)
HWND hWnd = ::FindWindow( _T( "Shell_TrayWnd" ), NULL );
#endif
if (PFWHwndCheck( hWnd ))
{
IGNORE_RETURN( ::ShowWindow( hWnd, nVis ) ); // Return
reflects previous state
// Update window whether hiding or showing (else Task bar may
show through, as it
// did on on Hitachi)
return ::UpdateWindow( hWnd ); // Uses Win32 function
}
else
return FALSE;
} // PFWTaskBarSetVisibility
// ----------------------------------------------------------
// Maximize
// I omitted the much larger section for Windows CE, especially Pocket
PC
BOOL ClsPFWindow::Maximize( BOOL bRedraw, BOOL bFull ) const
{
RECT rWork;
VERIFY( ::SystemParametersInfo( SPI_GETWORKAREA, 0, &rWork, 0 ) );
if (bFull)
{
rWork.bottom = ::GetSystemMetrics( SM_CYSCREEN );
IGNORE_RETURN( PFWTaskBarSetVisibility( FALSE ) );
}
else
{
IGNORE_RETURN( PFWTaskBarSetVisibility( TRUE ) );
}
// Need to resize window _after_ showing/hiding taskbar
return ::MoveWindow( m_hWnd, rWork.left, rWork.top, rWork.right,
rWork.bottom, bRedraw );
#endif
} // Maximize
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).
Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com