Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 examples don't show the title #29

Open
Lokathor opened this issue Feb 14, 2021 · 2 comments
Open

Win32 examples don't show the title #29

Lokathor opened this issue Feb 14, 2021 · 2 comments
Labels
bug Something isn't working Windows Issues for the Windows operating system

Comments

@Lokathor
Copy link
Member

The win32 examples that handle the WM_NCCREATE event without using DefWindowProcW don't have their non-client area drawn properly, which means that they don't get the title text drawn.

@Lokathor Lokathor added bug Something isn't working Windows Issues for the Windows operating system labels Feb 14, 2021
@RestedWicked
Copy link

Hello, I've been following your tutorial and this has been bugging me.
After reading up, various sources say to either set the return of WM_NCCREATE into DefWindowProcW or just not handle it.

I haven't gotten to the OpenGL part of the tutorial.
but

        WM_NCCREATE => {
            println!("NC Create");
            return DefWindowProcW(hwnd, msg, wparam, lparam);
        }
        WM_CREATE => {
            println!("Create");
            let createstruct: *mut CREATESTRUCTW = lparam as *mut _;
            if createstruct.is_null() {
                return 0;
            }
            let ptr = (*createstruct).lpCreateParams as *mut i32;
            return set_window_userdata(hwnd, ptr).is_ok() as LRESULT;
        }

this works with no errors.

alternatively this also works.

        WM_NCCREATE => {
            println!("NC Create");
            let createstruct: *mut CREATESTRUCTW = lparam as *mut _;
            if createstruct.is_null() {
                return 0;
            }
            let ptr = (*createstruct).lpCreateParams as *mut i32;
            let _ = set_window_userdata(hwnd, ptr).is_ok(); 
            return DefWindowProcW(hwnd, msg, wparam, lparam);
        }
        WM_CREATE => {
            println!("Create");
        }

let _ = set_window_userdata(hwnd, ptr).is_ok(); I am not entirely sure what the ramifications, ignoring this result has, so I went with the first version.

@Lokathor
Copy link
Member Author

Oh, yeah, that all sounds right. Either I learned about this by the end of the tutorial, or maybe after I wrote the tutorial. The gitbook search is pretty bad so i can't tell if this gets talked about eventually.

If you get to the end of the tutorial and it still hasn't mentioned this, then feel free to open a PR and I can get it merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Windows Issues for the Windows operating system
Projects
None yet
Development

No branches or pull requests

2 participants