开发者

window without wndproc

开发者 https://www.devze.com 2023-02-09 16:20 出处:网络
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;

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 i开发者_StackOverflow社区s 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?


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.


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!


No, you'll break SendMessage(). Only PostMessage() can work. Supporting SendMessage is required.

0

精彩评论

暂无评论...
验证码 换一张
取 消