简体   繁体   中英

Owned windows on Windows Mobile

Developing for WM 6, I call CreateWindow with hWndParent set to the window I want to be the owner. I do not set the WS_CHILD style, but the window created becomes a child window nevertheless. What is the proper way of doing this?

The MSDN article for CreateWindow mentions this behavior for WinCE 1.0:

Windows CE 1.0 does not support owned windows, except for dialog boxes. If the hwndParent parameter is not NULL, the window is implicitly given the WS_CHILD style.

Or, maybe, is all of the MSDN WinCE documentation wrong when it says that CreateWindow does create owned windows and CreateDialog* functions end up calling CreateWindow, as Hans Passant's comment implies?

The proper way of doing this is to give the window the WS_POPUP style, as outlined in Microsoft's Window Relationship Fundamentals document for WinCE 3.0:

You can create an owner/owned window relationship between top-level windows when you create a window with the WS_POPUP style. Because top-level windows do not have parent windows, the window that you specify as the parent window when you call the CreateWindow function becomes the owner window of the new window.

If you're passing WS_OVERLAPPED as the style, it'll turn on WS_CHILD for you. What styles are you passing during creation?

You probably want to pass 0 for the style.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM