Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window without wndproc

Tags:

c++

windows

I am curious it is possible to create a window without using WndProc.

So I would like to register the window-class with the lpfnWndProc field set to NULL; And using the msg ( that is given by TranslateMessage(&msg) ) in my own way.

Is there any disadvantages of this?

Thanks ahead, and sorry for my grammar.

Edit #1: Okay, I have a window, but I am wrong somewhere.

 MSG msg;
    while(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) {
        if (msg.message == WM_QUIT) return false;
        else {
                TranslateMessage(&msg);
                switch (msg.message) {
                case WM_CREATE:
                    createContext();
                    break;
                default:
                    DispatchMessage(&msg);
                    break;
                }
        }
    } 
    return true;

The createContext is not getting called. Why? Where I am wrong? Yeah, maybe the WM_CREATE message is to be sent to WndProc (DefWindowProc now), but are there any way to get it outside from the WndProc?


2 Answers

AFAIK, you can't set it to NULL. However, you'll notice that DefWindowProc's signature matches the WindowProc callback's signature. Simply give it DefWindowProc if you'd like a reasonable default.

like image 162
André Caron Avatar answered Sep 02 '26 11:09

André Caron


Sorry that makes no sense. Without the wndproc how can you even get hold of the message?

A window without a window proc is not a window!

like image 35
David Heffernan Avatar answered Sep 02 '26 13:09

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!