Click here to Skip to main content
15,887,214 members
Articles / Desktop Programming / Win32
Tip/Trick

All about owned windows

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
6 Jul 2011CPOL1 min read 18.3K   11
This tip, taken from MSDN tells the basic of ownership in windows.
Ownership is a pretty important concept when it comes to windows and I had a pretty hard time finding this info in MSDN; so just posting it here for those who are as bad as me at searching information.

An overlapped or pop-up window can be owned by another overlapped or pop-up window. Being owned places several constraints on a window.

An owned window is always above its owner in the z-order.
The system automatically destroys an owned window when its owner is destroyed.
An owned window is hidden when its owner is minimized.
Only an overlapped or pop-up window can be an owner window; a child window cannot be an owner window. An application creates an owned window by specifying the owner's window handle as the hwndParent parameter of CreateWindowEx when it creates a window with the WS_OVERLAPPED or WS_POPUP style. The hwndParent parameter must identify an overlapped or pop-up window. If hwndParent identifies a child window, the system assigns ownership to the top-level parent window of the child window. After creating an owned window, an application cannot transfer ownership of the window to another window.

Dialog boxes and message boxes are owned windows by default. An application specifies the owner window when calling a function that creates a dialog box or message box.

An application can use the GetWindow function with the GW_OWNER flag to retrieve a handle to a window's owner.

Here is a link to a nice blog about parent and owner:
http://blogs.msdn.com/b/oldnewthing/archive/2010/03/15/9978691.aspx[^]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Kotha Technologies
Bangladesh Bangladesh
If you are not in - you are out !
- Chapter 1

Comments and Discussions

 
QuestionA little bit of correction Pin
Javene Mcgowan28-Feb-23 10:49
Javene Mcgowan28-Feb-23 10:49 
AnswerRe: A little bit of correction Pin
Mukit, Ataul12-Jun-23 22:44
Mukit, Ataul12-Jun-23 22:44 
GeneralRe: A little bit of correction Pin
Javene Mcgowan15-Jun-23 16:10
Javene Mcgowan15-Jun-23 16:10 
GeneralRe: A little bit of correction Pin
Mukit, Ataul15-Jun-23 18:34
Mukit, Ataul15-Jun-23 18:34 
GeneralRe: A little bit of correction Pin
Javene Mcgowan16-Jun-23 6:58
Javene Mcgowan16-Jun-23 6:58 
GeneralRe: A little bit of correction Pin
Mukit, Ataul17-Jun-23 19:12
Mukit, Ataul17-Jun-23 19:12 
GeneralRe: A little bit of correction Pin
Javene Mcgowan18-Jun-23 3:20
Javene Mcgowan18-Jun-23 3:20 
GeneralRe: A little bit of correction Pin
Mukit, Ataul18-Jun-23 7:57
Mukit, Ataul18-Jun-23 7:57 
GeneralRe: A little bit of correction Pin
Javene Mcgowan18-Jun-23 17:56
Javene Mcgowan18-Jun-23 17:56 
Happy you ask. It is in test and develop stage now. As I am still adding features, redesigning and testing for errors as I use it to build my apps.

I mainly work with CodeBlocks; but my library would be compatible with MSVC. And I have indeed used it in MSVC. I also started writing my library from writing Android Cpp programs on my Android phone. So it is compitable with Linux and Android; except for the win32 component.

I strive for fast code and low memory footprint. And my code is meant to be a drop in solution. Each component can be used on its own. My win32 library is mostly wrappers around the win32 api. Some of it such as Jav::win32::Process had to be abstracted thoroughly.

If you would like a copy, you can link me at d.master51@yahoo.com.

Here is a synapsis of my entire library.

include
   jav
      config
         compiler.h
         types.h
         native_type.h
      console
         screen.h
         keyboard.h
      File
         Buffer.h
         File.h
      mem
         AutoMemory.h
         AutoMemory.inl
         AutoObject.h
         safe_pointer.h
         safe_pointer.inl
     graphics
         graphics.h
         Png.h
         Png_loader.h
         Align.h
         gif.h
      string
         builder.h
         char.h
         charconv.h
         numconv.h
         compare.h
         compare.inl
         cstring.h
         cstring.inl
         MultiString.h
         parser.h
         unicode.h
      test
         assert.h
         report.h
         type_name.h
      sfml
         TextBox.h
      win32
          config
            target_win_xp
            target_win_vista
            target_win_7
            target_win_8
            target_win_10
         graphics
            gdi.h
            AppContext.h
            Canvas.h
         Window
             Content.h
             Window.h
             SimpleWindow.h
         widgets
            TextView_v3
               TextView.h
               CharObject.h
               Spannable.h
               TextViewCanvas.h
            widgets.h
            widgets_ex.h
            custom_events.h
            Ruler.h
            TabsBarEx.h
            TextView.h
            Toast.h
            ToolTipEx.h
         win32.h
         window.h
         widgets.h
         AutoComObject.h
         debug.h
         dir.h
         dlg.h
         DLL.h
         graphics.h
         GUID.h
         thread.h
         process.h
         registry
         res.h
         util.h
      bits.h
      bits.inl
      config.h
      console.h
      dir.h
      endian.h
      error.h
      file.h
      IterWrap.h
      ptr.h
      string.h
      test.h
      time.h
      util.h
      win32.h

GeneralRe: A little bit of correction Pin
Mukit, Ataul19-Jun-23 19:22
Mukit, Ataul19-Jun-23 19:22 
GeneralRe: A little bit of correction Pin
Javene Mcgowan20-Jun-23 16:38
Javene Mcgowan20-Jun-23 16:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.