Window with no menu and no caption 
Author Message
 Window with no menu and no caption

Any tips or Web sites on how to do this?  Basically I want a little window
on the screen that has no caption and no menu.  I'm just gonna write some
text to it.  My first attempt at this went like:

BOOL CMyWnd::Create( void ) // CMyWnd is derived from CWnd
{
    const char *pszClassName = AfxRegisterWndClass(NULL);

    return CWnd::CreateEx(0, pszClassName, _T(""), WS_POPUP | WS_VISIBLE,
CRect(0, 600, 1023, 700), CWnd::GetDesktopWindow(), 1234);

Quote:
}

Then I had this in the application:

BOOL CMyApp::InitInstance()
{
    CMyWnd  *pWnd = new CMyWnd;

    pWnd->Create();

    m_pMainWnd = pWnd;

    return TRUE;

Quote:
}

When I run the code, it fails in the CreateEx() code with an error 1401
"Invalid menu handle."

Having not created this type of code with MFC (I've mainly stuck with the
Doc/View, and dialog-only applications), am I missing something obvious?

Thanks,
David



Sun, 11 Sep 2005 17:55:38 GMT  
 Window with no menu and no caption
See KB article

    Q131368 - HOWTO: Create MFC Applications that Do Not Have a Menu Bar

--
Cheers
Check Abdoul [ VC++ MVP ]
-----------------------------------



Quote:
> Any tips or Web sites on how to do this?  Basically I want a little window
> on the screen that has no caption and no menu.  I'm just gonna write some
> text to it.  My first attempt at this went like:

> BOOL CMyWnd::Create( void ) // CMyWnd is derived from CWnd
> {
>     const char *pszClassName = AfxRegisterWndClass(NULL);

>     return CWnd::CreateEx(0, pszClassName, _T(""), WS_POPUP | WS_VISIBLE,
> CRect(0, 600, 1023, 700), CWnd::GetDesktopWindow(), 1234);
> }

> Then I had this in the application:

> BOOL CMyApp::InitInstance()
> {
>     CMyWnd  *pWnd = new CMyWnd;

>     pWnd->Create();

>     m_pMainWnd = pWnd;

>     return TRUE;
> }

> When I run the code, it fails in the CreateEx() code with an error 1401
> "Invalid menu handle."

> Having not created this type of code with MFC (I've mainly stuck with the
> Doc/View, and dialog-only applications), am I missing something obvious?

> Thanks,
> David



Sun, 11 Sep 2005 18:24:40 GMT  
 Window with no menu and no caption
Nothing looks obviously wrong.

On a related note, its trivial to make a CFrameWnd without a caption/Menu.

--
Ajay Kalra [MVP - VC++]



Quote:
> Any tips or Web sites on how to do this?  Basically I want a little window
> on the screen that has no caption and no menu.  I'm just gonna write some
> text to it.  My first attempt at this went like:

> BOOL CMyWnd::Create( void ) // CMyWnd is derived from CWnd
> {
>     const char *pszClassName = AfxRegisterWndClass(NULL);

>     return CWnd::CreateEx(0, pszClassName, _T(""), WS_POPUP | WS_VISIBLE,
> CRect(0, 600, 1023, 700), CWnd::GetDesktopWindow(), 1234);
> }

> Then I had this in the application:

> BOOL CMyApp::InitInstance()
> {
>     CMyWnd  *pWnd = new CMyWnd;

>     pWnd->Create();

>     m_pMainWnd = pWnd;

>     return TRUE;
> }

> When I run the code, it fails in the CreateEx() code with an error 1401
> "Invalid menu handle."

> Having not created this type of code with MFC (I've mainly stuck with the
> Doc/View, and dialog-only applications), am I missing something obvious?

> Thanks,
> David



Sun, 11 Sep 2005 18:33:16 GMT  
 Window with no menu and no caption
Thanks.

Actually all that was needed was to change the last parameter to CreateEx()
from 1234 to 0.  Everything's good to go now!  I did have to supply a white
brush to AfxRegisterWndClass(), however.


Quote:
> See KB article

>     Q131368 - HOWTO: Create MFC Applications that Do Not Have a Menu Bar

> --
> Cheers
> Check Abdoul [ VC++ MVP ]



Sun, 11 Sep 2005 18:57:28 GMT  
 Window with no menu and no caption
Wonder why that is? Why should the ID be 0?

--
Ajay Kalra [MVP - VC++]



Quote:
> Thanks.

> Actually all that was needed was to change the last parameter to
CreateEx()
> from 1234 to 0.  Everything's good to go now!  I did have to supply a
white
> brush to AfxRegisterWndClass(), however.



> > See KB article

> >     Q131368 - HOWTO: Create MFC Applications that Do Not Have a Menu Bar

> > --
> > Cheers
> > Check Abdoul [ VC++ MVP ]



Sun, 11 Sep 2005 19:10:11 GMT  
 Window with no menu and no caption
There must be something in the internals of creating a window that tries to
use the ID as a menu handle if it is non-zero.


Quote:
> Wonder why that is? Why should the ID be 0?

> --
> Ajay Kalra [MVP - VC++]




Sun, 11 Sep 2005 21:18:57 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Creating a window with no system menu but a close button and caption.!!HELP

2. Getting window handle without matching window caption text

3. Window Caption in Windows 2000

4. Changing Window Caption for Child Window

5. Maximizing Frame Window: Caption bar w/out window borders

6. How to change caption of a menu item

7. Modifying popup menu captions

8. Dynamic change menu item caption

9. Dynamically change caption of a menu

10. CMenu menu item dynamic caption change

11. Menu Caption

12. how to change menu caption dynamicly

 

 
Powered by phpBB® Forum Software