Page 1 of 1

Microsoft : Working With Window Frames Sadly, not with double glazing Rate Topic: -----

#1 Martyn.Rae  Icon User is offline

  • The programming dinosaur
  • member icon

Reputation: 540
  • View blog
  • Posts: 1,406
  • Joined: 22-August 09

Posted 25 March 2010 - 10:38 AM

Microsoft : Working With Window Frames

Introduction

This tutorial looks at the various options we can use to create a variety of window frames. I shall not be covering the window class extensions in this tutorial but deal with the specific frame types, including titlebars, system menu, minimum, maximum, normalize and close buttons.

The standard frame window

The standard frame window is created using the WS_OVERLAPPEDWINDOW as the window style. This is equivalent to the following flags WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX as the window style. In other words, it is there to simply same typing :yes:

Removing features from the frame window

If you want a window that sizes and has a titlebar, but you do not want the user to be able to minimize the window, then you would say:

    window_handle = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,    
                                   window_class_name,    
                                   L"Frame Window",   
                                   WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME |
                                   WS_SYSMENU | WS_MAXIMIZEBOX,   
                                   W_USEDEFAULT, CW_USEDEFAULT, 640, 480,  
                                   NULL, NULL, instance_handle, NULL);



If you want a window that sizes and has a titlebar, but you do not want the user to be able to minimize or maximize the window, then you would say:

    window_handle = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,    
                                   window_class_name,    
                                   L"Frame Window",   
                                   WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU,   
                                   W_USEDEFAULT, CW_USEDEFAULT, 640, 480,  
                                   NULL, NULL, instance_handle, NULL);



If you want a window that sizes and has a titlebar, but you do not want the user to be able to minimize, maximize or close the window (using the mouse - ALT-F4 will still work), then you would say:

    window_handle = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,    
                                   window_class_name,    
                                   L"Frame Window",   
                                   WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME,   
                                   W_USEDEFAULT, CW_USEDEFAULT, 640, 480,  
                                   NULL, NULL, instance_handle, NULL);



Creating a window that cannot be sized

There are two other styles that you can specify when creating a window WS_BORDER and WS_DLGFRAME. These styles are identical in that they look the same and the window that's created cannot be sized.

    window_handle = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,    
                                   window_class_name,    
                                   L"Frame Window",   
                                   WS_DLGFRAME | WS_CAPTION,   
                                   CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,  
                                   NULL, NULL, instance_handle, NULL);



Managing your own frame window

There are occasions where displaying a caption is not desirable and therefore having that area at the top of the frame is a waste of space. To manage your own frame window real estate is somewhat difficult, but nethertheless can be achieved. I am not going to go into great detail about how you do this in this tutorial. What I will do however, is to point you in the right direction. To display a frame window without the area used for the caption requires you process WM_NCPAINT messages.

Dynamically changing the features on a frame

You can change the window styles dynamically, by using the GetWindowLongPtr and SetWindowLongPtr functions using the GWL_STYLE parameter.

This post has been edited by Martyn.Rae: 25 March 2010 - 10:48 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1