Win32: Subclassing EDIT

Started by
4 comments, last by Mayrel 22 years, 5 months ago
Hullo. I''m having some kind of problem subclassing EDIT. I''m using a class (EditBox, in this case) that does a CreateWindow using the "EDIT" window class. For reasons that I cannot figure out, the program crashes (with a GPF) when I create an instance of this class. For some reason, I''m not given the option of debugging, so I can''t find out where it''s going wrong. I''ve tried replacing the window class with "COMBOBOX", "SCROLLBAR", STATIC", and "BUTTON", and it works just fine with those (but, of course, I don''t want any of those controls for my EditBox). So, has anyone seen this before? And, more importantly, does anyone know what''s going wrong? All your bases belong to us (I know. It''s irony.)
CoV
Advertisement
Why do you not have the option of debugging?

Check all return values. It''s probably something simple
I don''t have the option of debugging because unstead of jumping into the debugger like it normally does when there''s an error, the program just ends.

I''ve checked return values. However, I can''t actually figure out where the problem occurs: I can display diagnostic messages and see how far through the problem I get, but depending the point at which the program crashes out is dependent upon where I put the messages.

All your bases belong to us (I know. It''s irony.)
CoV
Put a breakpoint and trace through your program, that way, you''ll be in the debugger.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Can you post the piece of code that is giving you problems? If you don''t know, just post the line where you are creating the edit control.
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
I don't have it with me right now, but I can bring it in.

The only problem is that I've no idea where the problem really is. My CreateWindowEx() call is just a normal call to CreateWindowEx() with nothing magical going on. Something like:

      m_hWnd = CreateWindowEx(exStyle, "EDIT", text, style, x, y, cx, cy, m_hWndParent,                         NULL, g_hInstance, NULL);      


The odd thing is that it works fine with my own window class or any of the other standard classes I've tested it with (BUTTON, SCOLLBAR, COMBOBOX and STATIC, so far).



As an aside, do the standard controls - tabstrips or group boxes, say - have window classes associated with them, or am I obliged to use MFC (which I don't really want to do)?

All your bases belong to us (I know. It's irony.)

Edited by - Mayrel on November 22, 2001 9:01:22 AM

Edit: Forgot a parameter.

Edited by - Mayrel on November 22, 2001 9:02:22 AM
CoV

This topic is closed to new replies.

Advertisement