question

ChristKingKennedy-5906 avatar image
0 Votes"
ChristKingKennedy-5906 asked ·

form not visible

i have a windows application.
the form is not visible but the app reports that it is.
i have a timer event

 private void TmrDebug_Tick(object sender, EventArgs e)
 {
 System.Diagnostics.Debug.Print("Size(" + Width.ToString() + ", " + Height.ToString() + ")"
                                 + "Loc(" + Left.ToString() + ", " + Top.ToString() + ")"
                                 + "Visible:" + Visible.ToString() 
                                 + " State:" + WindowState.ToString());
 }

that reports every 500 ms and this is my screen shot

69563-screenshot-183.png

you can see the timer event reporting in the output window telling me that the form is visible
but it is NOT.

why is this happening?


dotnet-csharp
screenshot-183.png (830.0 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered ·

Hello,

The following has a Timer and a button in a standard windows form project. Click the button to toggle visible and in this example Visible is reported correctly.

 namespace WindowsFormsApp1
 {
     public partial class Form1 : Form
     {
         public Form1()
         {
             InitializeComponent();
             Shown += OnShown;
         }
    
         private bool _loaded;
         private void OnShown(object sender, EventArgs e)
         {
             _loaded = true;
         }
    
         private void Form1_VisibleChanged(object sender, EventArgs e)
         {
             if (_loaded)
             {
                 Debug.WriteLine($"{Visible}");
             }
                
         }
    
         private async void button1_Click(object sender, EventArgs e)
         {
             Visible = !Visible;
             await Task.Delay(2000);
             Visible = !Visible;
         }
    
           
     }
 }
· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

thank you for your comment.
I don't have a problem understanding the concept of a boolean variable named Visible.
this problem is not reasonable.
the app reports its visible and on the screen.... it should be but it is not.

your comment explains the way things should be in a reasonable world but i live in Bizarro-World where hackers play funny with my code and think its a joke. there is nothing wrong with my code. I am hacked and i hate that the cowards in my box are too scared to show themselves but laugh at 'dominant' they think they are.
i'm very much annoyed by their cowardice.

but again, thank you for your comment. I will mark it as correct.

0 Votes 0 ·
ChristKingKennedy-5906 avatar image
0 Votes"
ChristKingKennedy-5906 answered ·

ok.
I eventually pulled the wool out from in front of my eyes and noticed that the form's vertical location was WAY off below the screen.
what was happening was that I had a SaveFormat.txt file that sequentially resized and positioned the form but the form's SizeChanged() & LocationChanged() event handlers were playing funny with it until I added a boolean telling them to bolIgnoreChanges while the load formatting was happening.
I am way too paranoid, next I'll think the North Koreans hacked my 4th grade class-president election.

thank you for your attention

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.