Dirt
Dirt

Reputation: 331

How to hide mdi child windows in C using win32 api?

I am updating an old application written in win32 in C and the requirement is to hide the mdi child windows based on some flags. I tried several methods but to no avail.

I tried ShowWindow with SW_HIDE but that doesn't work. The window just remains there blank (and generates no paint message). The same happens with SetWindowPos with SWP_HIDEWINDOW as one of the flags. SetWindowLong with ~WS_VISIBLE is the worst of the lot. It neither blanks the client area nor generates paint message, thus smearing it when other windows are moved over it.

Is it even possible to do it? If so, how?

PS: I did see a Delphi question here with the same requirement but I don't know Delphi and couldn't make out anything.

Upvotes: 1

Views: 467

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596387

As was explained in earlier discussions, such as this one:

How to hide a MDI Child form in Delphi

MDI is simply not designed to allow child windows to be hidden, and Delphi's VCL has internal logic to prevent user code from trying to make that mistake. Trying to circumvent that logic causes unwanted side effects due to MDI's limitations.

In short, to "hide" an MDI child window, you have to destroy it, and then re-create it when you want to "show" it again. That is the only reliable option that MDI supports.

Upvotes: 1

Related Questions