Marlon
Marlon

Reputation: 2139

Windows handle if a control is set to visible = false (.NET)

Quick question, do controls in .NET have handles (hWnd) if they are set to invisible?

Marlon

Upvotes: 1

Views: 948

Answers (2)

Hans Passant
Hans Passant

Reputation: 941257

The handle is created when the Visible property becomes true. If it was set to true in the form constructor, the most common case for controls, that will happen when the form is created, right before the Load event. Setting Visible to false again doesn't destroy the handle.

Upvotes: 1

JaredPar
JaredPar

Reputation: 754545

If a .Net Control already had a handle then setting it to Visible=false will not remove it. It is possible though to see a .Net Control without a handle. Handles are created on demand in WinForms and it's possible to see the lack of a handle before an operation has forced it into existence.

Upvotes: 2

Related Questions