Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Maximized window covers the taskbar.

1,053 views
Skip to first unread message

qWake

unread,
Jun 16, 2004, 4:58:17 PM6/16/04
to
This C++ code creates a window that alternates between maximized and
restored at the click of the mouse. Problem is: the maximized format
overlaps the taskbar. The only apparent solution is to enable the caption
and sysmenu options at creation time. Is there a way to have a caption-less
window that does not cover up the task bar when it becomes maximized? The
right behaviour can probably be programmed, but there should be a way to
just tell Windows to just stop doing that...

------

#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;
}


Tim Robinson

unread,
Jun 16, 2004, 5:59:04 PM6/16/04
to
qWake wrote:
[...]

> CreateWindowEx(0, "TEST", "", 0
> | WS_VISIBLE
> | WS_SIZEBOX
> | WS_POPUP
> // | WS_CAPTION
> // | WS_SYSMENU
> , 100, 100, 400, 300, 0, 0, inst, 0);
[...]

Use WS_OVERLAPPED instead of WS_POPUP.

--
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/


qWake

unread,
Jun 16, 2004, 7:24:21 PM6/16/04
to
"Tim Robinson" <tim.at.gaat.f...@invalid.com> wrote in message
news:2jbvd3F...@uni-berlin.de...


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...


r_z_...@pen_fact.com

unread,
Jun 17, 2004, 2:23:12 PM6/17/04
to


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

0 new messages