Solved

Trying to use CreateWindowEx

Posted on 1997-07-17
2
237 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 91
Creating Labels and Frequency list style reports in SAS code 9 92
Path of Workbook 3 61
Message not shown 5 33
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

11 Experts available now in Live!

Get 1:1 Help Now