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 required (i.e. red if a negative number otherwise 
black).

Can anyone shed soem light on this for me.

TIA Ali Grey
0
agrey12 (6)
10/5/2003 6:53:14 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
1486 Views

Similar Articles

[PageSpeed] 8

"Ali Grey" <agrey12@aol.com> wrote in message
news:uyosvH3iDHA.1676@TK2MSFTNGP09.phx.gbl...
> 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 required (i.e. red if a negative number otherwise
> black).
>
> Can anyone shed soem light on this for me.

I suspect that you are arriving late to the party. By the time you subclass
the control, the WM_CREATE message has already come and gone.
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
10/5/2003 7:49:43 PM
I subclass the edit OnInitDialog. When should I be subclassing it in 
order to trap the WM_CREATE? it does not exist during the dialog OnCreate
()

Cheers Ali
"Jeff Partch [MVP]" <jeffp@mvps.org> wrote in
news:#GkyTn3iDHA.1004@TK2MSFTNGP09.phx.gbl: 

> "Ali Grey" <agrey12@aol.com> wrote in message
> news:uyosvH3iDHA.1676@TK2MSFTNGP09.phx.gbl...
>> 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 required (i.e. red if a negative number
>> otherwise black).
>>
>> Can anyone shed soem light on this for me.
> 
> I suspect that you are arriving late to the party. By the time you
> subclass the control, the WM_CREATE message has already come and gone.

0
TheOne (15)
10/6/2003 5:26:32 PM
I'm pretty sure there's no way to receive WM_CREATE for a subclass of a
dialog control. The only two ways I can think of are: 1) to call Create[Ex]
on a member CEdit derived class -- I think you'll get WM_CREATE that way,
but of course if you CreateEx the thing there's no reason not to start out
with the styles you need. 2) RegisterClass[Ex] a custom WNDCLASS[EX] based
on EDIT that you put on your dialog template -- in which case you'll
definately get WM_CREATE in your registered WindowProc (not the CWnd
override), but not in through the message-map of your MFC subclass IIRC.
-- 
Jeff Partch [VC++ MVP]

"The One" <TheOne@nowhere.com> wrote in message
news:Xns940CBC7CF432ETheOnenowhere@207.46.248.16...
> I subclass the edit OnInitDialog. When should I be subclassing it in
> order to trap the WM_CREATE? it does not exist during the dialog OnCreate
> ()
>
> Cheers Ali
> "Jeff Partch [MVP]" <jeffp@mvps.org> wrote in
> news:#GkyTn3iDHA.1004@TK2MSFTNGP09.phx.gbl:
>
> > "Ali Grey" <agrey12@aol.com> wrote in message
> > news:uyosvH3iDHA.1676@TK2MSFTNGP09.phx.gbl...
> >> 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 required (i.e. red if a negative number
> >> otherwise black).
> >>
> >> Can anyone shed soem light on this for me.
> >
> > I suspect that you are arriving late to the party. By the time you
> > subclass the control, the WM_CREATE message has already come and gone.
>


0
jeffp (1711)
10/6/2003 6:07:52 PM
One option is to destroy the control in OnInitDialog after obtaining its size and location
and then dynamically create it with the speficied size/location. This will force a
WM_CREATE.

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"The One" <TheOne@nowhere.com> wrote in message
news:Xns940CBC7CF432ETheOnenowhere@207.46.248.16...
| I subclass the edit OnInitDialog. When should I be subclassing it in
| order to trap the WM_CREATE? it does not exist during the dialog OnCreate
| ()
|
| Cheers Ali
| "Jeff Partch [MVP]" <jeffp@mvps.org> wrote in
| news:#GkyTn3iDHA.1004@TK2MSFTNGP09.phx.gbl:
|
| > "Ali Grey" <agrey12@aol.com> wrote in message
| > news:uyosvH3iDHA.1676@TK2MSFTNGP09.phx.gbl...
| >> 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 required (i.e. red if a negative number
| >> otherwise black).
| >>
| >> Can anyone shed soem light on this for me.
| >
| > I suspect that you are arriving late to the party. By the time you
| > subclass the control, the WM_CREATE message has already come and gone.
|

0
ajaykalra (6842)
10/8/2003 10:55:39 PM
Reply:

Similar Artilces:

Custom Drawing CEdit : Subclassing
Hello experts, My objective is simple, but I'm not entirely sure what needs tweaking. I am using MSVC 6, and I would like to subclass the CEdit box so that it appears as the color-picker editbox of a PropertyGrid. There is a color box followed by three values. Like this: [###] 255; 192; 192 Where ### is just a color box representation of the value. So thus far, I've made a masked CEdit box, where I can edit the numbers (or click a button that visually sets the numbers from a different window), and I'm happy with that - but what I would like to do next is to subclass the dra...

Help with subclassing a RichEditCtrl
Hi folks, I could use some help. As a side project I am trying to write a DLL that will extend the functionality of an existing application that I do not have source code for, i.e., some autocompletion functionality, word lookup, etc. In the actual DLL, I am going to have to inject it into the existing app and then use FindWindow or something like that to subclass the existing RichEditCtrl. I need to be able to process the WM_CHAR and WM_KEYDOWN messages only. I started out by creating my own sample project using a RichEditCtrl in my project to code my object. I've now moved everythin...

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...

Subclassing CWinThread
I created a subclass of CWinThread - no big deal! Now, what I would like to do is use that subclass as a base class for a couple of other, more specialized classes. How can I do this? If I create a subclass as a generic C++ class, then I'm running into the assertion, "Invalid Address specified to RtlValidateHeap( 00940000, 0042DBA0 )" when I post the quit message to the thread. I assume this might have something to do with the virtual/non-virtual constructor combination of the MFC class and the generic C++ class. Any thoughts? Create more subclasses of CWinThread, then ...

Subclassing TreeView
I created a class derived from a TreeView (ShellTree) that displays the Shell directory structure . I changed the LeftView class so that it is derived from my ShellTree class, and everything works as expected, except I cannot add any TreeView specific message handlers to my LeftView class any more eg. NM_DBLCLICK. Basically in a nutshell what i want to do is display the directory name (which is stored in a variable in the ShellTree class) when the LeftView is Double clicked Check out http://www.codeproject.com/treectrl/enumdeskclones.asp Which isn't perfect.. but is a good star...

Subclassing a subclass of CDialog, for cross-platform compilation
Hi people, I've been working on porting an app from PC to Mac. What I'm trying to do, is separate out the PC specific components into it's own subclass. So there are the PC specific functions like PCAppDlg::OnBtnClicked1, and mac specific functions like MacAppDlg::BlaBlaBla. Of course the Mac subclass doesn't compile on the PC, and the same the other way around. I've had to write my own CDialog wrapper for Mac but that's another story. Now anyhow, this leads me to a question. How to subclass a subclass? Specifically, how does the message maps work? Will there be any p...

Subclassing
Hello, Im very new to c++ programming so pardon me if this is a dumb question and my bad english. I made a subclass from CListBox. I want to handle all the list controls derived from this class on one function, for example, void CListBox_SC::OnRButtonUp(UINT nFlags, CPoint point) { ..... } on this function I want to manage the OnRButtonUp event, and with a switch or if statement, select the code to execute. The following does work: SetCurSel(ItemFromPoint(point, ifp)); but the following comparison is never true, (IDC_LST_TIPO is a resource for one of the ListBoxes) UINT currLst = It...

Subclassing dynamically created controls
I have a created an edit box dynamically using the Create function in a class derived from CTreeView ( Explorer Style - CLeftView ). Now I want to change the color of the edit box . I guess I need to subclass this window using SubClassWindow( ) . I have derived a class from CEdit and using the derived class to create the control . Can anyone please help me how to Subclass the edit control so I can change its background colour . Thanks in advance . Sujay -- Sujay Ghosh Bangalore, INDIA Sujay Ghosh wrote: > I have a created an edit box dynamically using the Create function in a ...

Notification when a window is subclassed
Is there a way for an application to be notified when one of it's windows is being subclassed? The scenario am dealing with is that I subclass a window to take a crack at a few messages. But the implementation of one of the messages that am not interested in and hence destined for the OriginalWndProc is seeming to subclass the Window once again. I am kinda lost at this point, because neither am I getting those select messages anymore nor am I being notified that the Window was further subclassed after I did. Any suggestions? Ranjit What kinda of window? When are you subclassing it? Th...

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 ...

Xml Serializing subclass problem
Hi guys. I've come across a problem when I tried to serialize a class into xml, only to discover that the parent class's XML Serialization properties weren't included in the output xml. Actually, the class I'm serializing is two steps down in the inheritance ladder. It's got a parent class which also has a parent class :( All those classes in the hierarchy are Xml Serializable, and I'd think that it should be obvious that all attributes/properties of the parents should be serialized for any given subclass, no ? Here's the two classes, subclass first, parent class...

Subclassing problem???
Hi there, I've got: LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ switch(uMsg){ case WM_NCACTIVATE: if((BOOL)wParam==FALSE){ DefWindowProc(hwnd, uMsg, wParam, lParam); CreateText(hwnd); return TRUE; } case WM_NCPAINT: DefWindowProc(hwnd, uMsg, wParam, lParam); CreateText(hwnd); break; } DefWindowProc(hwnd, uMsg, wParam, lParam); } void CreateText(HWND hwnd){ HDC hDC = GetWindowDC(hwnd); int x,y; RECT rc1,rc2; GetWindowRect(hwnd, (LPRECT)&rc2 ); x = GetSystemMetrics(SM_CXSIZE) + GetSystemMetrics(SM_CXBORDE...

subclassing CStatic
Hi, I have subclassed a few CStatic ctrls so i can quickly change their font, BG and FG colors etc... I have also handled the CFormView's CtlColor message and painted the form white and text blue. The problem that im having is the subclassed objects are painting themselves the colors i specify, then the CFormView::OnCtlColor is painting them again. This isnt too much of a problem as i can simply exclude the subclassed items from the painting using: HBRUSH CSmartMXEditLangView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { // create white brush: m_DlgBrush.DeleteObject(); ...

VC
I need a way to come up with a simple (free) combobox activeX control I can use in a third party development tool. I tried just subclassing ComboBoxEx using the ActiveX control wizard in VC6. It clearly creates the control, but it doesn't seem to be created with the properties and methods (like AddItem/New) and when I plop on a VB6 form it doesn't look like a combobox. Granted I am newbie working way over my head, by why would the ActiveX control wizard ask me which control to inherit from if it isn't going to give me _roughly_ the same functionality? Can anyone point me in a di...

subclassing CComboBox
compiler: VC++ 6.0 SP 6, running XP Pro SP 2. I subclassed CComboBox into CMyComboBox, then setup up event handlers for several of the reflected events -- one being CBN_CLOSEUP reflected event. I have an object of type CMyComboBox in an MFC program, which also needs to catch the CBN_CLOSEUP event. I used ClassWizard to create all event handlers. Problem: The event handler in CMyComboBox works ok, but the handler in the application program never gets called. Is there a way around this problem? I tried posting a message to the parent window but that didn't seem to work either (pare...

Moving subclasses to different classes
I'm having trouble figuring out how to move subclasses to different classes (to re-assign budget categories to differnt umbrella budget areas). I see a "MOVE" button at the bottom of the list of Classes but can't figure out how to make it active. Anyone know the secret to moving classes without deleting them, recreating them under a new high level class, and re-assigning the transactions? Thanks in Advance!! Never mind -- you just delete the class and ask it to reassign things to a new subclass bucket. PRODUCT WISHLIST: Have the "MOVE" button active...

Subclassing AfxControlBar80su
I have a CDialogBar derived class which has a bitmap background texture. The parent's wndclass is AfxControlBar80su which still displays in gray. I'd like to give it the same background as the dialog bar and I thought it could be done by subclassing and handling the appropriate messages. But how can that be done? TIA, Hans Subclass CDialogBar and override OnPaint would be my first guess as to how to do it. The AfxControlBar80su is probably not relevant here. joe On Mon, 30 Jul 2007 01:16:15 +0200, Hans-J. Ude <news@hajue-ude.de> wrote: >I have a CDialogBar derived c...

subclassing a CTreeCtrl
All, I'm trying to subclass a CTreeCtrl control with a CHeaderCtrl derived class to obtain the result as in (http://users.pandora.be/bart.de.lathouwer/Untitled-1.jpg) I would subclass the CTreeCtrl derived class to be able to draw 'over' both the header and CTreeCtrl surface. When I subclass my CTreeCtrl derived class it reports that it is already attached. My Ctrl's live in a CWnd derived class. Question: What is the correct way to subclass my CTreeCtrl with my HeaderClass to be able to draw "over" both classes? If not possible what is an alternative? (apart from ...

Subclass question
Hi, I am writing an app in which I have a dialog bar (IDD_DLGBAR) at the top of the MDI frame window besides the standard toolbar. The dialog bar contains several controls. One of them is a combo box with id IDC_SEARCHBOX. I also created a class CSearchBox (derived from CComboBox) to process keyboard messages. My question is how do I link the combo box in the dialog bar with CSearchBox class so I can capture keyboard events (i.e., PreTranslateMessage)? Thanks in advance. >Hi, I am writing an app in which I have a dialog bar (IDD_DLGBAR) at the top >of the MDI frame window beside...

Subclass Help
During the desing of my app, I realized that I would need to have a combobox with a set of pre-defined values (collected from a database). This combobox will be used in many dialogs and for that, I decided to derive my own class. I want the combobox to be populated when created, but I can't figure out how to make it work with DDX. If I "create" it manually, I can do this in "OnCreate," but I'm attaching to a dialog. I don't know what gets called when DDX does the attaching. Any ideas? Thanks in advanced. Eddie. "Eddie Pazz" <drpazz@hotmail...

SHBrowseForFolder Subclassing.
I would like to change the name of the "cancel" button. Is that possible with Subclassing, Superclassing, etc.? ....Bruce Maybe this article can help you: http://www.codeproject.com/dialog/browse_for_folder_dialog.asp -- Mav Rossi "Bruce Arnold" <b_a_r_n_o_l_d@b_l_a_s_t.n_e_t> ha scritto nel messaggio news:cka5tv4rf6mq086b1nf6t6gom5rgds0a33@4ax.com... > I would like to change the name of the "cancel" button. Is that > possible with Subclassing, Superclassing, etc.? > ...Bruce > > And this too: http://www.codeproject.com/dialog/browse...

Re: Subclassing
Hi All I wish to create my own control for subclassing. The control will essentially contain some simple text and some minor graphics. No real control functionality is required. The question is should I derive this new control from an existing control, say CButton, or directly from CWnd? Thanks in advance LarryM wrote: > Hi All > > I wish to create my own control for subclassing. The control will > essentially > contain some simple text and some minor graphics. No real control > functionality is required. > > The question is should I derive this new control...

Subclassing controls
Hi! I'm trying to create a custom control with custom NC area, but there's an odd problem: When I create the control using .Create(...), its all fine, but when I subclass the control, the NC messages are never sent! Anyone knows why this happens?? Tnx... >I'm trying to create a custom control with custom NC area, but there's an >odd problem: >When I create the control using .Create(...), its all fine, >but when I subclass the control, the NC messages are never sent! Which WM_NC* messages in particular? Presumably the WM_NCCREATE message won't be caught...

questions of subclassing
hi all I derieved a button class called cmybutton, I want to replace all button in my application with cmybutton so I use subclass but the question is, if the button is created by my resource templates, it works, but failed in other resource templates such as Message Boxs' buttons. That is, if I use AfxmessageBox to display a dialog box, the buttons in the dialog didn't display it seems the subclassing doesn't work what can I do many thanks That's because you cannot subclass messagebox buttons. Subclassing in MFC works only because it is a fiction maintained by MFC ...

Subclassed CEdit needs OnClose
I have a subclassed CEdit control. I need to GetWindowText() just before the CEdit is destroyed, but can't figure out where to do this. I've tried OnDestroy() (doesn't get called), my destructor (the m_hWnd is no longer valid), OnClose() (doesn't get called), etc. Thanks, Steve Could you grab the text in a OnKillFocus() handler? That way you'd get a message when they move off of the control as well as when it is destroyed. Just a thought. Tom "Steve" <junk@bruff.com> wrote in message news:97327c0.0309251221.35c93d02@posting.google.com... > I have...