A Popup Window


A window is referred to as popup when it is relatively small, is equipped with a short than usual title bar, is equipped with only the System Close button on its title bar, and has thin borders. Such a window is usually used to accompany or assist another big window or the main window of an application. This means that a popup window is hardly used by itself or as the main frame of an application. Based on this description, there are some characteristics you should apply to the frame to make it appear as a popup window.


To create a popup window, it should have the WS_POPUPWINDOW and the WS_CAPTION styles. It should fit a relatively small rectangle. It may also have the WS_EX_TOOLWINDOW extended style.

In this exercise, to illustrate our point, we will create a frame-based application where a popup window is the main object.

Practical Learning Practical Learning: Introducing Tables

  1. Start Microsoft Visual C++ 5, 6, or .NET

  2. Create an Win32 Project in a folder called PopupWnd1. Create it as an Empty Project

  3. For this exercise, we will Use MFC In A Shared DLL. If you don't how to do this:
    in the main menu of MSVC 5 and 6, click Project -> Settings... and, in the Microsoft Foundation Classes combo box, select Use MFC in a Shared DLL
    in MSVC .NET, in the Solution Explorer, right-click the project name and click Properties. On the right side, find Use of MFC and click it to display its combo box. In the combo box, select Use MFC in a Shared DLL.

  4. Create a new C++ Source file and save it as Exercise

  5. In the empty file type:

    #include <afxwin.h>
    struct CFrameTest : public CFrameWnd
    		Create(NULL, "Windows Application Tester",
    			   CRect(400, 280, 580, 520), NULL, NULL,
    struct CAppTest : public CWinApp
    	BOOL InitInstance()
    		CFrameTest *Tester = new CFrameTest();
    		m_pMainWnd = Tester;
    		return TRUE;
    CAppTest theApp;
  6. Test the application

See Also:

Home Copyright © 2005-2010 FunctionX, Inc.