WM_CREATE not received in dialog's controls

Hello,

I am trying to make a 3d visualization panel deriving th CButton class. For 
that, I need to initializa som stuff after the control (inside a dialog) has 
a valid HWND but before it paints itself for the first time.

At first I done it programatically creating the control and placing the 
3d-initialization code inside the WM_CREATE, and it worked right.

But I want to create the control from a resource ID, not programatically, to 
avoid the need of positioning and sizing tasks. And there lays the problem: I 
use DDX_Control to associate the resource ID and the member variable for the 
control; but the execution flow didn't reach the handler for WM_CREATE, so 
the initialization code is not executed, and the progam crashes on the first 
WM_PAINT.

I would really appreciate some help on the method to achieve initialization 
while creating the control from a resource ID.

Best regards,

David
0
David4882 (672)
11/26/2006 1:12:01 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1004 Views

Similar Articles

[PageSpeed] 43

David wrote:
> Hello,
> 
> I am trying to make a 3d visualization panel deriving th CButton class. For 
> that, I need to initializa som stuff after the control (inside a dialog) has 
> a valid HWND but before it paints itself for the first time.
> 
> At first I done it programatically creating the control and placing the 
> 3d-initialization code inside the WM_CREATE, and it worked right.
> 
> But I want to create the control from a resource ID, not programatically, to 
> avoid the need of positioning and sizing tasks. And there lays the problem: I 
> use DDX_Control to associate the resource ID and the member variable for the 
> control; but the execution flow didn't reach the handler for WM_CREATE, so 
> the initialization code is not executed, and the progam crashes on the first 
> WM_PAINT.
> 
> I would really appreciate some help on the method to achieve initialization 
> while creating the control from a resource ID.

Try overriding PreSubclassWindow in your CButton derived class.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
11/26/2006 2:13:12 AM
That's right.  The window is created long before it is bound to the variable that connects
it to a message map.  Use PreSubclassWindow for initialization of controls.

The WM_PAINT must *always* be robust enough to not crash!  Always.  If it crashes, you
have to recode it so that it will not crash, no matter what happens.  This means whatever
it depends on has to be initialized in the constructor, and anything else will set values
that allow the WM_PAINT handler to do something meaningful.  But it must NEVER be the case
that the code can crash, ever.
					joe

On Sat, 25 Nov 2006 17:12:01 -0800, David <David@discussions.microsoft.com> wrote:

>Hello,
>
>I am trying to make a 3d visualization panel deriving th CButton class. For 
>that, I need to initializa som stuff after the control (inside a dialog) has 
>a valid HWND but before it paints itself for the first time.
>
>At first I done it programatically creating the control and placing the 
>3d-initialization code inside the WM_CREATE, and it worked right.
>
>But I want to create the control from a resource ID, not programatically, to 
>avoid the need of positioning and sizing tasks. And there lays the problem: I 
>use DDX_Control to associate the resource ID and the member variable for the 
>control; but the execution flow didn't reach the handler for WM_CREATE, so 
>the initialization code is not executed, and the progam crashes on the first 
>WM_PAINT.
>
>I would really appreciate some help on the method to achieve initialization 
>while creating the control from a resource ID.
>
>Best regards,
>
>David
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
11/26/2006 6:27:04 AM
Thank you for the replies. That method certainly worked. 

Regards,

David
0
David4882 (672)
11/28/2006 12:35:01 PM
Reply:

Similar Artilces:

Sending and receiving
I can receive e-mail but cannot send. I've checked my settings - they are the same as Outlook, which I used on my old XP computer. This is a new Win 7 computer. Copy and paste the entire error message for analysis please . ... . "Railroad Henry (not John)" <RailroadHenrynotJohn@discussions.microsoft.com> wrote in message news:120A3A4D-6860-46AC-A94E-C7CB0AB7AD34@microsoft.com... > I can receive e-mail but cannot send. I've checked my settings - they are > the > same as Outlook, which I used on my old XP computer. This is a new Win 7 > compu...

Hiding Received Items on Purchase Orders
Is there a way to hide already received items on a PO? That is, can a revised PO be printed that only shows remaining open items (backorders). On that same note, is there a way to print out a "Receiver" or "Check-in Sheet" for my staff to check in orders against, as opposed to the actual purchase order, which shows more information than I'd like shown... Thanks for any input!! ...

Using ME to change controls
I am using the following Me statement in the click event on a button. It does change the MyControl visible to Yes. However, when I close the form and open the form the MyControl stays No. How can I keep it or set it permanent to visible True? Can it be done? I hope it can be permanent. Please help. Is it because the Form that has the MyControl is locked when open and does not let these changes to be save? Me.MyControl.Visible = True ...

Preventing changes to received messages
Outlook allows me to modify a received message's body and subject field. So if Bob sends me an email, I can open it, change the body's content, save it, and it looks like that's how I received it. Then if I print or forward it, it looks like Bob sent me something he in reality didn't. Is there a way to disable that? Can the integrity of a received message be protected? Can this be done without digital signitures? Hi, I do not think that is possible !!! Sorry for that . Hope this helps !!! With Regards, Sudharson.AN "Hall" <hall@garp.org> wrote in mes...

Send/Receive failure
Hey all - I work for a school district that is running Outlook 2000 SR-1 and an old version of Outlook Express. Every time a user clicks on send/receive it times out and says that server such and such can't be found.... But if we close down that "error" box and click on send/receive again it works. Every time! Anyone have an idea why it "dies" on the 1st attempt and then is successful on the 2nd? I can't see any setting in either version that would make this happen. Thanks. Jim D. ...

Include this account when receiving mail or synchronizing
Hello, In OE I have the option to check mark "Include this account when receiving mail or synchronizing". Where does OL has this option? Thanks, AJS Tools-> Options-> tab Mail Setup-> button Send/Receive...-> button Edit... -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://www.msoutlook.info/ Real World Questions, Real World Answers ----- "AJS" <newsgroup@sorga.com> wrote in message news:#0XRNuWrJHA.3992@TK2MSFTNGP04.phx.gbl... > ...

unable to receive email from a certain user
I have a problem where I am not receiving email from a certain user within our organization. I am able to receive all other mail, from other users, but when this user sends me mail.. I never get it. It shows as sent from the sender, and I dont have any rules in place that would be moving it from the inbox. Any thoughts?! Please help!! -Justin is the user able to reply to mail sent 'from' you? have they got the correct spelling of your name etc? "Justin" <jhenretta@pwlink.com> wrote in message news:066801c3aeed$4bd6db00$a101280a@phx.gbl... > I have a problem wh...

Receiving emails ... or rather NOT receiving
I get to message #5 and won't download. I now have over 200 emails waiting to be downloaded to my Inbox behind email #5. Anybody know how to remove this #5 email that is blocking everything else????? Logon to your mail server's Webmail page and delete the offending message from there. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "Lynda" <Lynda@discussions.microsoft.com> wrote in message news:794E9864-FEAD-4C19-B958-293595B19762@microsoft.com... >I get to message #5 and won't download. I now have over 200 emails ...

Tab control questions
Using Office 2003 and Windows XP; When using a tab control: 1) Does it wrap automatically so that the tabs are more than one layer deep if additional tabs are inserted? 2) Is there a way to control when the tabs wrap to a second row or where the break will occur or is this just automatic (i.e. whenever it runs out of room)? 3) I'm sure I won't get anywhere near it, but what is the limit on the number of tabs? Thanks in advance. On Dec 17, 10:45 am, XP <X...@discussions.microsoft.com> wrote: > Using Office 2003 and Windows XP; > > When using a tab control: > ...

WM_CREATE for a subclass
Hi All, I am fairly new to C++, although I have developed OO windows applications in the past using CTD and Power Builder. I am developeing an edit class based on a CEdit. I am trying to trap the WM_CREATE message to modify the style of the window (i.e. to make is multiline). For some reason the control does not appear to be getting the WM_CREATE message ( or at least it is not implementing the handler I have for it). At present I create an edit control on a form and the Subclass the edit. This appears to work as my user defined menu is used and my color modifications appear as requir...

I m receiving my email but after received it is not in my inbox
When I open the outlook and click on send/receive, I receive all the emails, but I could not find the downloaded email anywhere. It's not in my inbox or any of the folders that I have created. The unread mail also does not change to reflect that new emails have arrived. Could some one help me out here. Thanking you in advance. If you check your whole folder tree (composed of multiple PSTs possibly), are any folders showing as bold? "INAVAB" <INAVAB@discussions.microsoft.com> wrote in message news:7708D9D4-47D5-44FD-9983-89F13F35BCEA@microsoft.com... > When I open...

Displaying bitmap image in CStatic control.
HI , I have created one dialog application, in that i have added one CStatic control. Then i have added below code in OnInitDialog() // Start CStatic *pStaPicHolder = (CStatic*)GetDlgItem(IDC_STATIC); if (NULL == pStaPicHolder) return; BOOL b = pStaPicHolder->ModifyStyle(~0, (DWORD)(SS_BITMAP, WS_CHILD | WS_VISIBLE)); //pHBitmap = LoadBitmap(theApp.GetResModuleHandle(), MAKEINTRESOURCE(nBitmapID)); HBITMAP pHBitmap1 = (HBITMAP)LoadImage(AfxGetInstanceHandle(), "BallaStream.Bmp", IMAGE_BITMAP, 90, 30, LR_LOADFROMFILE); if (NULL != pHBitmap1) { HBITMAP pBt = pStaPicH...

Pictures Received Are Garbled
Hi, I have been receiving emails with pictures from certain people, but the pictures are shown as text. As if I had opened a jpeg with a text editor. Not all pictures come in this way, only in emails from certain people. How do I (or they) make it stop? Marebear wrote: > Hi, > > I have been receiving emails with pictures from certain people, but the > pictures are shown as text. As if I had opened a jpeg with a text editor. > Not all pictures come in this way, only in emails from certain people. > > How do I (or they) make it stop? Anti-...

Problem with serial receive
I have a receive thread for a serial com port. I'm calling WaitCommEvent with an overlapped structure to get events. The event mask is EV_BREAK | EV_RXCHAR | EV_ERR. I also have an overlapped read operation to get receive input. Both events are setup with auto-reset. The port works fine until I get an error. When an error occurs on the receive line the read event is signaled and the call to GetOverlappedResult returns 995 Operation Aborted (the thread has not exited). I then get a WaitCommEvent signal. I call ClearCommError() which returns a CE_RXPARITY error. I thought ClearComm...

Cant send or receive emails
I've done something to my settings, and cannot send or receive emails. Can anyone tell me what to do? And I'm not a newby either, shame shame! thanks. Kari Error message? Version of Outlook? Type of mail account? Checked your mail account settings already? -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slipstreamed with Service Pack 1 ----- "Kari Jacob" <jacob52@optusnet.com.au> wrote in message news:549201c49180$ec8cfa40$a501280a@phx.gbl... > I've done something to my...

MFC Extention DLL can't create a Dialog window from own resource
Hi there. I have MFC Extention DLL which has own CDialog derived class and resource associated with it. In another application I'm trying to create this dialog by exported function of the DLL. Unfortunately in my live project this trick doesn't work. But when I created thin test project using same DevEnv (VC++ 6 SP6) it is working just fine. When I run that exported function in my live project I get Debug Assertion in afxwin1.inl line 22. void CreateCitrixWindow() { AFX_MANAGE_STATE(AfxGetAppModuleState()); Sheet_Citrix* pCitrix = new Sheet_Citrix(); pCitrix->DoModal(); ...

Different field control sources for unbound form
Hi. I'm using Access 97. The short description of my problem is: I have an unbound form named Stats1. On the form I have 3 text boxes (AvgofR1, AvgofR2, and AvgofR3). There are 3 "total queries" (Q1, Q2, and Q3) that when run return an average in a field called AvgofR1 for query 1, AvgofR2 for query 2, and AvgofR3 for query 3. How do I get the value of AvgofR1 from query Q1 to appear in the text box AvgofR1, the value of AvgofR2 from query Q2 to appear in the text box AvgofR2, and the value of AvgofR3 from query Q3 to appear in the text box AvgofR3 on the unbound form Stats1...

Outlook 2000 Spam Control
I just received four SPAMS yesterday. I would like to have some basic spam control that automatically eleminates: Drugs Mortgages Penis enlargements Also do you have something similar to AOL's "Report Spam" where I can send the SPAM that does get through? Thanks very much, Tom The number one thing to do is remove your e-mail from your posts or hide it like most of us do. Spammers "harvest" e-mail addresses from these newsgroups and believe me, just filtering by those three keywords will only get maybe 5% of the spam. I have found that, aside from complicated ...

Receive email in real-time
We have several PCs in our company that are receiving Exchange email messages in real-time, whereas others have to click Send/Receive within MS Outlook to receive their email. How do I setup Exchange where all users can receive their email instantaneously on any machine in the organization onto which they logon. Thanks in advance, Mervin Williams Hi, You can't configure Exchange to not deliver emails instantly to Outlook users. This is an Outlook setting and will have to be configured here. Leif "Mervin Williams" <mwilliams@innovasolutions.net> skrev i en meddelel...

Garbage in title bar of "Printing" dialog?
I've got an MFC-based program (VC++) that has a strange problem. The "Printing" dialog has garbage for its title - not the dialog that asks you # of copies, but the one that says "Printing WHATEVER on the hp deskjet 960c on USB001 Page 1". Where is it getting this title from? I assume I'm not setting some member of a structure somewhere, but I don't know which one ... Thanks! Chris Chris Cooper wrote: | I've got an MFC-based program (VC++) that has a strange problem. The | "Printing" dialog has garbage for its title - not the dialog that as...

Formatting NULL values in Drop-Down control
I have a drop-down control that is being populated by an entire table (not a query). There are NULL values in the table which appear as blank spaces in the drop down. How can I format the drop down to put some static text in place of the empty space. (For example 'Available', or 'Not Defined'). In the combobox's Row Source, use a query to return the list and instead of the original field, use something like: Nz([OriginalField],"Available") jtertin wrote: >I have a drop-down control that is being populated by an entire table >(not a query). There are...

Send & Receive button doesn't work
I installed Office XP and the SP3 service pack. I can't get the "send and recieve" button to work in MS Outlook. Everytime I click it I get a error message "The operation failed. An object could not be found." I tried proposed resolution in from MS knowledge base article 312354 but it didn't fix the problem. Any suggestions on the fix? i'd follow the procedure for creating a new profile again first. if that fails, try a repair operation. "Tom" <anonymous@discussions.microsoft.com> wrote in message news:0b0d01c425ad$17305570$a401280a@...

Lookup value and control depends on lookup result
I have 1 qry & 1 form. Query named : QRY_bl_SalesInvoice BL no. Sales Invoice BL001 IV509999 BL002 (blank) BL003 IV507777 Under the FORM, drop-down box named “dropdownBL” is used by user to select BL no. under the qry on (a). Questions : How I set the following controls, Case 1 : If BL no. under the drop-down box “dropdownBL” after select = BL002 (with Sales Invoice=blank under the QRY) , then free to input on the field named “Sales Invoice" Case 2 : If BL no. under the drop-down box “dropdownBL” after select ...

Received Not Invoiced not = GL(205000-000-000 Received Not Invoic
I am working on some questions for an audit, and was asked why when we run an RNI report [Reports>Purchasing>Analysis>Received/Not Invoiced] for a specific date range, it doesn't match the [Summary Inquiry] numbers. Shouldn't you be able to run a report that selects the RNI from the POP tables for a specified date range and the GL20000 (acct code 20500-000-000) for the same date range and come up with the same result. I figured out the answer, never mind! "Rich" wrote: > I am working on some questions for an audit, and was asked why when we run an > RN...

New Messages "active x controls"
When clicking on new message, message pops up stating "your current settings probihibt Active X from appearing on your screen", why is this and how do you remove it? I've tried changing my settings and they are the same as everyone else? Could I have downloaded something? Did you install SP2 for Windows XP? -- *Emails sent to personal account will not be read due to virus security* "Doug" <anonymous@discussions.microsoft.com> wrote in message news:0c9501c49cd7$e6695160$a501280a@phx.gbl... > When clicking on new message, message pops up > stating ...