Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CEDit creation through Dialog-Resource, OnNcPaint not called, why ?

CEDit creation through Dialog-Resource, OnNcPaint not called, why ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ohadp
    wrote on last edited by
    #1

    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 15 CMyEdit controls don't have their OnNcPaint 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 overriding OnCreate, OnNcCreate (added ON_WM_XXX ofcourse) and Create 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.****

    J 1 Reply Last reply
    0
    • O ohadp

      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 15 CMyEdit controls don't have their OnNcPaint 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 overriding OnCreate, OnNcCreate (added ON_WM_XXX ofcourse) and Create 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.****

      J Offline
      J Offline
      Johan Rosengren
      wrote on last edited by
      #2

      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?

      O 1 Reply Last reply
      0
      • J Johan Rosengren

        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?

        O Offline
        O Offline
        ohadp
        wrote on last edited by
        #3

        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 inside PreSubclassWindow ``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 :-)``

        J 1 Reply Last reply
        0
        • O ohadp

          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 inside PreSubclassWindow ``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 :-)``

          J Offline
          J Offline
          Johan Rosengren
          wrote on last edited by
          #4

          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 subclassed CEdit, 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 name PreSubclassWindow :-) Now, as PreSubclassWindow 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.

          O 1 Reply Last reply
          0
          • J Johan Rosengren

            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 subclassed CEdit, 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 name PreSubclassWindow :-) Now, as PreSubclassWindow 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.

            O Offline
            O Offline
            ohadp
            wrote on last edited by
            #5

            The deal is that during initialization, I want to trigger my version of OnWindowPosChanging. I can fake a direct call to it from PreSubclassWindow, 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.

            J 1 Reply Last reply
            0
            • O ohadp

              The deal is that during initialization, I want to trigger my version of OnWindowPosChanging. I can fake a direct call to it from PreSubclassWindow, 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.

              J Offline
              J Offline
              Johan Rosengren
              wrote on last edited by
              #6

              If you want a slightly cleaner architecture, put the code in a separate function and call it from both OnWindowPosChanging and PreSubclassWindow.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups