CEDit creation through Dialog-Resource, OnNcPaint not called, why ?
-
I have a dialog with about 15 edit controls. The controls are a subclass I've made of
CEdit
,CMyEdit
for the matter. 2 out of the 15CMyEdit
controls don't have theirOnNcPaint
override called, for no apparent reason. all edit-boxes are declared the same way in the resource-editor, no special handling of any of them not in resources nor in code. I've tried overridingOnCreate
,OnNcCreate
(addedON_WM_XXX
ofcourse) andCreate
itself but none of them are ever called. What am I missing out ? p.s. - what I need is a 'point of intervention' during the creation/post-creation of the edit-control during which the control is already sized and positioned correctly.**** -
I have a dialog with about 15 edit controls. The controls are a subclass I've made of
CEdit
,CMyEdit
for the matter. 2 out of the 15CMyEdit
controls don't have theirOnNcPaint
override called, for no apparent reason. all edit-boxes are declared the same way in the resource-editor, no special handling of any of them not in resources nor in code. I've tried overridingOnCreate
,OnNcCreate
(addedON_WM_XXX
ofcourse) andCreate
itself but none of them are ever called. What am I missing out ? p.s. - what I need is a 'point of intervention' during the creation/post-creation of the edit-control during which the control is already sized and positioned correctly.****ohadp wrote: 2 out of the 15 CMyEdit controls don't have their OnNcPaint override called, for no You have most probably made some silly error. Check and recheck! You will want to make sure they are attached to the correct kind of variable in the h-file, and that the resource IDs don't clash. ohadp wrote: p.s. - what I need is a 'point of intervention' during the creation/post-creation of the edit-control during which the control is already sized and positioned correctly. Perhaps
PreSubclassWindow
? -
ohadp wrote: 2 out of the 15 CMyEdit controls don't have their OnNcPaint override called, for no You have most probably made some silly error. Check and recheck! You will want to make sure they are attached to the correct kind of variable in the h-file, and that the resource IDs don't clash. ohadp wrote: p.s. - what I need is a 'point of intervention' during the creation/post-creation of the edit-control during which the control is already sized and positioned correctly. Perhaps
PreSubclassWindow
?I've checked all the resource-ids/etc, all looks ok.
PreSubclassWindow
is interesting but problematic. The reason is that if I do my things insidePreSubclassWindow ``my control isn't subclassed yet, and so it's message-handlers aren't called when messages arrive :-) So I'll a little condition to the situation I was persuing earlier. What I need is an intervention-point during which the control is sized, and subclassed. Something like `PostSubclass`, or `PostCreate`, or anything of that kind :-)``
-
I've checked all the resource-ids/etc, all looks ok.
PreSubclassWindow
is interesting but problematic. The reason is that if I do my things insidePreSubclassWindow ``my control isn't subclassed yet, and so it's message-handlers aren't called when messages arrive :-) So I'll a little condition to the situation I was persuing earlier. What I need is an intervention-point during which the control is sized, and subclassed. Something like `PostSubclass`, or `PostCreate`, or anything of that kind :-)``
ohadp wrote: I've checked all the resource-ids/etc, all looks ok. Then, you might want to tear down the project, perhaps by removing all the controls that works. Set a breakpoint in some function you know will be called in the class of the offending controls (such as
PreSubclassWindow
:-)) and verify that the controls are really subclassed. ohadp wrote: PreSubclassWindow is interesting but problematic. The reason is that if I do my things inside PreSubclassWindow my control isn't subclassed yet, and so it's message-handlers aren't called when messages arrive To be sure I've not gone completely crazy (which I still won't outrule, however), I tested with a subclassedCEdit
, instantiated from a resource template, mapped to a control variable of my class. As expected,PreSubclassWindow
is called after the control is created, and so you do have access to the control size and position. Of course, the handlers of the subclass aren't called before or during this call, thus the namePreSubclassWindow
:-) Now, asPreSubclassWindow
is a member of your class, you have full access to all other class members of the instance at this time of the execution, so I'm slightly baffled as to why you would need to know that the subclassing is finished - for all practical purposes, it is at this stage. -
ohadp wrote: I've checked all the resource-ids/etc, all looks ok. Then, you might want to tear down the project, perhaps by removing all the controls that works. Set a breakpoint in some function you know will be called in the class of the offending controls (such as
PreSubclassWindow
:-)) and verify that the controls are really subclassed. ohadp wrote: PreSubclassWindow is interesting but problematic. The reason is that if I do my things inside PreSubclassWindow my control isn't subclassed yet, and so it's message-handlers aren't called when messages arrive To be sure I've not gone completely crazy (which I still won't outrule, however), I tested with a subclassedCEdit
, instantiated from a resource template, mapped to a control variable of my class. As expected,PreSubclassWindow
is called after the control is created, and so you do have access to the control size and position. Of course, the handlers of the subclass aren't called before or during this call, thus the namePreSubclassWindow
:-) Now, asPreSubclassWindow
is a member of your class, you have full access to all other class members of the instance at this time of the execution, so I'm slightly baffled as to why you would need to know that the subclassing is finished - for all practical purposes, it is at this stage.The deal is that during initialization, I want to trigger my version of
OnWindowPosChanging
. I can fake a direct call to it fromPreSubclassWindow
, yes, but it's a little unorthodox so I was looking for a cleaner way to do it. I guess that's just what I'll do then, thanks for the tips. -
The deal is that during initialization, I want to trigger my version of
OnWindowPosChanging
. I can fake a direct call to it fromPreSubclassWindow
, yes, but it's a little unorthodox so I was looking for a cleaner way to do it. I guess that's just what I'll do then, thanks for the tips.If you want a slightly cleaner architecture, put the code in a separate function and call it from both
OnWindowPosChanging
andPreSubclassWindow
.