Window Relationships

Window relationships define how windows interact with each other-on the screen and through messages. There are parent-child window relationships and window-owner relationships.

The parent-child relationship determines where and how windows appear when drawn on the screen. It also determines what happens to a window when a related window is destroyed or hidden. The parent-child rules apply to all windows at all times and cannot be modified.

Ownership determines how windows communicate using messages. Cooperating windows define and carry out their rules of ownership. Although some windows (such as windows of the preregistered public window class, WC_FRAME) have very complex rules of ownership, the application usually defines the ownership rules. The following figure represents the logical relationship of the windows in two applications.

                          Desktop Window
                               ┌─┐
         Application 1         │ │          Application 2
┌─  ──  ──  ──  ──  ──  ──  ─┐ │ │ ┌─  ──  ──  ──  ──  ──  ──  ─┐
             ┌───────────────┴─┘ └─┴──────────────┐
│            │ ┌─────────────┬─────┬────────────┐ │             │
             │ │                                │ │
│       Main Window 1        │     │      Main Window 2         │
             │ │                                │ │
│     ┌──────┘ └──────┐      │     │     ┌──────┘ └──────┐      │
      │ ┌───────────┐ │                  │ ┌───────────┐ │
│     │ │           │ │      │     │     │ │           │ │      │
      │ │           └─┘                  └─┘           └─┘
│    Child         Child     │     │    Child         Child     │
   Window 1.1    Window 1.2           Window 2.1    Window 2.2
│     │ │                    │     │                            │
      └─┘
│    Child                   │     │                            │
  Window 1.1.1
└─  ──  ──  ──  ──  ──  ──  ─┘     └─  ──  ──  ──  ──  ──  ──  ─┘

Typical Window Relationships


[Back: Desktop Window and Desktop-Object Window]
[Next: Parent-Child Relationship]