Thread: Window Wrapper Class, WM_NCCREATE never sent

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Window Wrapper Class, WM_NCCREATE never sent

    I've created a window wrapper class, that registers a new window class, and then creates a window. However, I am unable to call my window procedure, because the static message router function never receives the WM_NCCREATE message. I always wrap my windows in this way, and have never encountered this. The only difference this time is that the class is inherited from a more basic window wrapper class. However, I have stepped through the program, and I see no reason why the WM_NCCREATE message is not being received.

    If anyone has encountered something like this, give your input, and if you can be bothered going through my code, tell me and I'll post it.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The only obvious reason for not receiving WM_NCCREATE (or WM_CREATE) messages is window subclassing. In this case message handling is not initiated until after window creation so these messages, which are sent during system processing of CreateWindowEx, cannot be handled.

    If you're not doing that then posting/attaching your code may help us work through the problem with you.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Nope it's an entirely new window class. I've just found that using a normal function, ie, not a member of any class, as the window procedure, works fine. Anyway here's the code.

    Lol I just realized that the code is mostly based on the code from your site Ken.

    At the moment the code should work, because I changed the window class to use the non-member window procedure.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Ok this is really embarrasing. Don't bother checking the code it's fine. In the static window message router, there's an if statement to check validity of the class instance pointer:
    Code:
    CAppWnd *caw=NULL;
    .
    .
    .
    if (!caw)
      return 0;
    caw=(CAppWnd *)GetWindowLong(blah blah);
    As you can see, the check comes before it's even initialised properly.

    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Haha. Don't worry about it, Benny.

    I'd like to suggest that you make sure that you call DefWindowProc for messages sent before WM_NCCREATE, such as WM_NCCALCSIZE, to ensure default system processing of these messages.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Good idea, thanks for the help.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  2. how i create a window whith all it's elements
    By rasheed in forum Windows Programming
    Replies: 1
    Last Post: 05-31-2006, 06:53 PM
  3. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM
  4. Difficulty superclassing EDIT window class
    By cDir in forum Windows Programming
    Replies: 7
    Last Post: 02-21-2002, 05:06 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM