Pass child window messages to main program wndproc

Vd3 21 Reputation points
2021-01-25T09:20:21.697+00:00

This is my gui structure (pseudocode):

WNDCLASS.lpfnWndProc = WindowProcessMessages; // all my messages are processed here
HWND main = CreateWindow() //this is my main window, a 500x500 box, messages are processed in WindowProcessMessages
HWND groupBox  = CreateWindow(BS_GROUPBOX, main) //groupbox is a child of main
HWND button = CreateWindow("Button", groupbox) //button is a child of groupbox

However when I try to catch button click event in WindowProcessMessages It doesn't work. So I tried to use SetWindowLongPtr(button, GWLP_WNDPROC, WindowProcessMessages). Now the button doesn't even show up! Any ideas? or is this simply not possible and I misunderstood SetWindowLongPtr with GWLP_WNDPROC?
My goal is to have button click event in WindowProcessMessages. Thanks!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,428 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,542 questions
{count} votes

Accepted answer
  1. Petrus 【KIM】 456 Reputation points
    2021-01-25T09:41:47.087+00:00

    Groupbox is static control

    Your button must be a child of main window.

    HWND button = CreateWindow("Button", main) //button is not a child of groupbox

    https://stpetrus27.wordpress.com/2018/06/04/vc-vc-dialog-without-the-resource-file/

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful