C # Form.Hide () vs. Form.Opacity = 0

I was wondering if there are any errors in order to make the form completely transparent (and not hide it). For example, I know that these are things that took me by surprise, hiding the form:

  • If the form is hidden, you cannot interact with its controls (you cannot add HTML to the web browser control, you cannot click a button, etc.).
  • Changing the WindowState window (minimizing, maximizing, etc.) of the window while it is hidden will cause the window to appear outside the area of ​​your workspace when the form is shown again.

Does anyone encounter similar problems (or completely different?) When using a form with transparency equal to 0 (completely transparent)?

+4
source share
2 answers

From the votes for my comment, I think I will send it as an answer. I would not encourage using Form.Opacity = 0 . Despite the fact that you can disable the form to prevent accidental interaction, I would think that the transparent form overlays other windows and confuses the user about why he cannot interact with the windows behind your transparent one.

As for getcha for Form.Hide() , I usually queued the form's response so that when the form returns to the view (or visibility), it goes through the queue for processing actions (i.e. changing the FormState). Changing the shape while hiding it can also really confuse the user.

+1
source

If you no longer need a form, hide it. But if you still have a task or timers working in the form you want to save, or you want to save user input, then you will achieve to set the opacity to 0%. This is what I do when I want the form to be hidden, but still active:

 frmMain.Opacity = 0; // To make it invisible. frmMain.VisibleInTaskbar = false; // To make the taskbar entry of the form disappear, and to make sure that the WindowState isn't changed. frmMain.Enabled = false; // To make sure the user doesn't type something in the form, or presses a button (by pressing enter) by accident. 
+1
source

All Articles