mfc >> Window properties in MFC

by TF » Tue, 25 Jan 2005 22:50:27 GMT

I am attempting to set my main window (MFC generated) with certain
attributes. Here is the list.

1. Borderless
2. No title/caption bar
3. No resize
4. No taskbar button

So far, I have the border down to almost nothing, but as soon as it is
resized, it appears (once the scrollbars appear).

TF




mfc >> Window properties in MFC

by Frank Hickman [MVP] » Wed, 26 Jan 2005 15:21:37 GMT






Try adding this to your CMainFrame::OnCreate handler...

ModifyStyle( WS_SYSMENU| WS_BORDER| WS_CAPTION, 0 );
ModifyStyleEx( WS_EX_OVERLAPPEDWINDOW, 0 );

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.





mfc >> Window properties in MFC

by TF » Thu, 27 Jan 2005 06:49:42 GMT

I tried you reccomendation, and the title bar, taskbar button and close
button are all still there....Any other suggestions?

TF









Window properties in MFC

by TF » Fri, 28 Jan 2005 06:35:07 GMT

One of the problems is that my window is not a direct creation from Visual
Studio. I am caling CreateWindow() which returns a handle. How would I
call the ModfyStyle on that?

TF









Window properties in MFC

by Frank Hickman [MVP] » Fri, 28 Jan 2005 08:25:44 GMT





For that you can use the GetWindowLong/SetWindowLong APIs.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.




Window properties in MFC

by TF » Sat, 29 Jan 2005 03:51:18 GMT

None of this seems to be working. Could you send me, the entire piece of
sample code that you have working according to this. I would really
appreciate it. Thanks.

TF





Visual




Window properties in MFC

by Frank Hickman [MVP] » Sat, 29 Jan 2005 04:56:39 GMT





// You have to do all this to get what you want...
DWORD dwStyle= ::GetWindowLong( hWnd, GWL_STYLE );
dwStyle &= ~(WS_OVERLAPPEDWINDOW| WS_SYSMENU| WS_BORDER| WS_CAPTION);
::SetWindowLong( hWnd, GWL_STYLE, dwStyle );

DWORD dwExStyle= ::GetWindowLong( hWnd, GWL_EXSTYLE );
dwExStyle &= ~(WS_EX_OVERLAPPEDWINDOW);
::SetWindowLong( hWnd, GWL_EXSTYLE, dwExStyle );

WINDOWPLACEMENT wp;
::GetWindowPlacement( hWnd, &wp );
int x= wp.rcNormalPosition.left;
int y= wp.rcNormalPosition.top;
int cx= wp.rcNormalPosition.right - x;
int cy= wp.rcNormalPosition.bottom - y;
::SetWindowPos( hWnd, HWND_TOP, x, y, cx, cy, SWP_FRAMECHANGED );
// End added code...

As for not showing up on the task bar, the only thing I can think of is
maybe creating your window as a child window of the desktop.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.




Window properties in MFC

by Frank Hickman [MVP] » Sat, 29 Jan 2005 05:56:00 GMT








Oh, it should be placed between the CreateWindow call and the ShowWindow
call.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.





Window properties in MFC

by TF » Wed, 02 Feb 2005 00:28:41 GMT

Thanks Frank,

I actually got it working last week, more less by doind what it says
below. Although it did take me awhile to find the right place for it. The
sequence of function calls is not at all clear from the documentation.
There are many places where you can set the window styles, but only a few
places (in the sequence) that really have any impact.

TF







of