how do i achieve this?
Printable View
how do i achieve this?
There should be events that fires when the form is minimized or maximized.
simply do this
VB Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As _ System.EventArgs) Handles MyBase.Resize MsgBox(Me.WindowState.ToString) End Sub
well though pirate ty ill try it right now
i am using a notify icon that is always in the systray and i want that when i double click it will show back the form..(im using C# but i think it's easy to see):
this is the code i've put in the double click of the notify icon...the problem is that i only seem to can put the form back to the maximized state , i cant put it as normal..anyone knows why? it just shows up in systray but i can do nothing with it..Code:private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) {
if (this.WindowState == FormWindowState.Minimized) {
this.WindowState = FormWindowState.Maximized;
this.Show();
this.ShowInTaskbar = true;
this.TopLevel = true;
}
}
You're getting maximized form ,because you are using "Maximized" method to show your form , rather use "Normal" method as so :
Code:private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) {
if (this.WindowState == FormWindowState.Minimized) {
this.WindowState = FormWindowState.Normal;
this.Show();
this.ShowInTaskbar = true;
this.TopLevel = true;
}
}
lol read the post carefully i said i couldnt put normal so i tryed maximized because that was working lol but i want it normal
:rolleyes: Did you try the code I posted , it shows your form in normal size . That was your question I guess .Quote:
Originally posted by PT Exorcist
lol read the post carefully i said i couldnt put normal so i tryed maximized because that was working lol but i want it normal
Quote:
problem is that i only seem to can put the form back to the maximized state , i cant put it as normal..anyone knows why? it just shows up in systray but i can do nothing with it..
put this.Show(); before
this.WindowState = FormWindowState.Normal;
This won't make any difference. a good technique is to set the properties of a from first and then use show method .Quote:
Originally posted by Lunatic3
put this.Show(); before
this.WindowState = FormWindowState.Normal;
The problem already solved I guess :D .
Did you test what i said?????!!!!!
We are not talking about a GOOD technique here, we are talking about a method that does not work properly and the solution of it, that for me was putting
this.show;
before
this.WindowState = FormWindowState.Normal;
Yes I did . It results the same thing . :pQuote:
Originally posted by Lunatic3
Did you test what i said?????!!!!!
We are not talking about a GOOD technique here, we are talking about a method that does not work properly and the solution of it, that for me was putting
this.show;
before
this.WindowState = FormWindowState.Normal;
pirate is right, the result is the same thing...strange "bug" of this..how da hell i am suposed to put the form back again without putting max state?
......
Simply by using my code :p lol
lol...ive already said ive tried that code and still doesnt work..but as u want that i put that again i've put ur code again and still doesnt work..it shows in the tray but the interface of the program itself isnt showed up
..
You're missing something in your code I'm sure!:p .I've tried my code it's just working fine
try this !Quote:
Originally posted by Pirate
You're missing something in your code I'm sure!:p .I've tried my code it's just working fine
jsut 5 min ago i copy pasted ur code and the result was that extrange "bug"...
:confused:
What bug did you get ? :rolleyes:Quote:
Originally posted by PT Exorcist
jsut 5 min ago i copy pasted ur code and the result was that extrange "bug"...
:confused:
i only see the program in the taskbar and when i click it nothing happens..
lol , do you call this a bug ?? The program is running fine , and stop posting bull**** .Quote:
Originally posted by PT Exorcist
i only see the program in the taskbar and when i click it nothing happens..
First:
Pirate's code works for me fine :)
Second:
I am sorry, I was wrong, what i said was about VB.NET and I thought it might be the same for C#, but it wasn't.
Third:
Try this and see what i meant:
VB Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() nt1.Visible = True End If End Sub Private Sub nt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles nt1.MouseDown Me.WindowState = FormWindowState.Normal Me.Show() nt1.Visible = False End Sub
VB Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() nt1.Visible = True End If End Sub Private Sub nt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles nt1.MouseDown Me.Show() Me.WindowState = FormWindowState.Normal nt1.Visible = False End Sub
Your're right Lunatic3 . I was coding in C# when I tried setting the "Normal" method before "show" . That's weird :rolleyes: . I thought they are similar but it seems not at least in some controls.Quote:
Originally posted by Lunatic3
First:
Pirate's code works for me fine :)
Second:
I am sorry, I was wrong, what i said was about VB.NET and I thought it might be the same for C#, but it wasn't.
Third:
Try this and see what i meant:
VB Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() nt1.Visible = True End If End Sub Private Sub nt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles nt1.MouseDown Me.Show() Me.WindowState = FormWindowState.Normal nt1.Visible = False End Sub