Solved

Trying to use CreateWindowEx

Posted on 1997-07-17
2
236 Views
Last Modified: 2013-11-20
I am trying to create a standard SDI window with CreateWindowEx.  I have registered a custom class and tried the following:

   CreateEx( WS_EX_CLIENTEDGE,
             NULL,
             theApp.m_NewMailWndClass,  // my own class
             "new window",
             WS_BORDER | WS_CHILD,
             rect,
             NULL,
             0);

I registered the class like this:
m_NewMailWndClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW));

The "rect" is set to 0,0,100,100 (I size it later)

CreateWindowEx fails (0)

Any suggestions?

I am calling this from an MFC-SDI window (toolbar button callback)
0
Comment
Question by:tdietz
2 Comments
 
LVL 4

Accepted Solution

by:
mbhakta earned 50 total points
ID: 1302653
Try using AfxRegisterClass() instead.  Also don't forget to use UnRegisterClass when window terminates.
0
 

Author Comment

by:tdietz
ID: 1302654
I have two comments, one to mbhakta and to tdietz.
To mbhakta : I was under the impression that the class is automatically unregistered.Is it not?
To tdietz : I am unable to guess as to what could be the cause.Can you call "GetLastError()" and find out?Will it give you some clue?

Regards,
Amaresh
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
haveThree challenge 22 100
zeroMAx challenge 20 77
matchUp  challenge 9 72
How to convert MFC::CString to UTF8 wchar_t* 10 102
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now