MFC Window without Title Bar by vamsi

   In this Program the Create Api Call to create the window takes the third parameter that is window style as WS_POPUP, which is responsible for creating the window without any title bar.

   Since there is no title bar there won’t be any close button, so in order to exit the application I used PostQuitMessage Api call in OnRButtonDown event of the window, which posts the WM_QUITMESSAGE to the Message queue so that when ever user presses right button on the window the application will exit. Generally we see some funny games without any title bar where this code can be used.

An Win 32 Application , Source Code is as follows………..


 Source.cpp

 //Creating a Window without any Title Bar such that it just appears as your desktop
 #include <afxwin.h> 
class CMyFrame : public CFrameWnd
{
   public:    
   CMyFrame()
   {
    //Call to create a Window without any titlebar
    Create(NULL,"",WS_POPUP);   
   }
  void OnRButtonDown()
  {   
    PostQuitMessage(1);
  }
  DECLARE_MESSAGE_MAP()
  };
  BEGIN_MESSAGE_MAP(CMyFrame,CFrameWnd)
   ON_WM_RBUTTONDOWN()
  END_MESSAGE_MAP() 
  class CMyApp :public CWinApp
  {
    CMyFrame *frameWndObj;
   public:
    BOOL InitInstance()
    {
      frameWndObj = new CMyFrame();
      m_pMainWnd = frameWndObj;
     //shows the window with maximum size.
     m_pMainWnd->ShowWindow(3);
     return 1;
     }
  };
 CMyApp anApp;