MFC Window without Title Bar

CoderSource.net
MFC Window without Title Bar - Article by vamsi
Rating:

Date: 11/19/2004 12:00:00 AM

   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;


You Can Rate this Article, if you are Logged In      
 

More Links from CoderSource.net:

 
Refer to a Friend:

Your Details:

Name:     e-mail:

Friend Details:

Name:    e-mail:    


MENU
Home
MFC 
C++
.Net
WIN32
Programming
Forum
My Articles
Add to Google
Add to My Yahoo!
Welcome to Codersource.Net Login | Register | Faq  

SEARCH
Google
 

NOTES:


Thanks for visiting our CoderSource.net. This site will be improved with more articles. Interested visitors can also submit their articles through the Submit Article link.Your article will also be published after due consideration by the editor. 

© Copyright 2003. All rights on content reserved by CoderSource.net. Contact    About Us