Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 60491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:10:13+00:00 2026-05-10T18:10:13+00:00

I have been reading the MSDN documentation on subclassing and I have been successful

  • 0

I have been reading the MSDN documentation on subclassing and I have been successful in handling events in a subclass

My issue is with passing messages back to the original WndProc.

As an example, if I have a window, with a sub-classed groupbox control and a button as a child of that groupbox, I want to handle the button event in the original window procedure, not the subclassed groupbox procedure.

Essentially, I want an empty subclass procedure:

LRESULT FAR PASCAL SubClassFunc(HWND hwnd,                         UINT uMsg,                 WPARAM wParam,                 LPARAM lParam) {     return CallWindowProc(oldProc, hwnd, uMsg, wParam, lParam); } 

Where oldProc is:

FARPROC oldProc = (FARPROC)SetClassLong(group_box, GCL_WDPROC, (DWORD)SubCLassFunc); 

And where the window and groupbox and button are:

HWND window = CreateWindowEx(     WS_EX_WINDOWEDGE,      appname,     TEXT('Subclass Test'),     WS_VISIBLE |WS_OVERLAPPEDWINDOW,     CW_USEDEFAULT,     CW_USEDEFAULT,     300,     400,     NULL,     NULL,     hInstance,     0);  HWND group_box = CreateWindowEx(     0,     TEXT('BUTTON'),     TEXT('Group Box'),     WS_CHILD | WS_VISIBLE | BS_GROUPBOX,     8,     8,     275,     350,     window,     NULL,     hInstance,     0);  HWND push_button = CreateWindowEx(     0,     TEXT('BUTTON'),     TEXT('Push Button'),     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_VCENTER,     50,     100,     100,     25,     group_box,     (HMENU)PUSH_BUTTON,     hInstance,     0); 

I can handle the button events in the SubClassFunc, but what I want to do is pass them back to the window WndProc. It seems that CallWindowProc isn’t doing this, or I may be totally wrong in how CallWindowProc works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:10:14+00:00Added an answer on May 10, 2026 at 6:10 pm

    The button notifications are sent to the button’s parent, which is the group box. Because you’ve subclassed the group box, your SubClassFunc receives these messages, which then passes them to the group box’s original window procedure using CallWindowProc.

    If you want the button notifications to go to the parent window (i.e, window in your code), you could either set the button’s parent to window instead of group_box, or use PostMessage from within SubClassFunc to post the message (WM_COMMAND or WM_NOTIFY as appropriate) to window.

    Also, I see that you’re using SetClassLong to set the window procedure. What this does is replace the window procedure for the entire BUTTON class, but only for windows that are subsequently created. Any BUTTON windows created before calling SetClassLong will not be subclassed. You may want to consider using SetWindowLong instead, to subclass individual windows rather than the entire class.

    Edit: The group box’s original window procedure doesn’t send WM_COMMAND messages to its parent. This is explained in Charles Petzold’s Programming Windows book:

    The group box, which has the BS_GROUPBOX style, is an oddity in the button class. It neither processes mouse or keyboard input, nor sends WM_COMMAND messages to its parent.

    You should find that button notifications don’t get through to window even if you don’t subclass the group box.

    I hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading the proper article in MSDN, Strong-Named Assemblies and a related
I have been reading about try/finally on MSDN and found out following code. They
I have been reading an article about Lockless Programming in MSDN. It says :
I have been reading through the C++ FAQ and was curious about the friend
I have been reading about the differences between Table Variables and Temp Tables and
I have been reading through the CodePlex supported open source licenses, i couldn't quite
I have been reading up on this, and it seems that if you use
On Stackers' recommendation, I have been reading Crockford's excellent Javascript: The Good Parts .
OK, I have just been reading and trying for the last hour to import
I have been hearing and reading about Agile for years. I own a book

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.