Activate form2 when form1 activates(Back to front)

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 66
Reputation: ambarisha.kn is an unknown quantity at this point 
Solved Threads: 0
ambarisha.kn ambarisha.kn is offline Offline
Junior Poster in Training

Activate form2 when form1 activates(Back to front)

 
0
  #1
Jan 15th, 2009
I have 2 forms.
Form2 has no minimum, max, close icons.
Form2 have to control by form1.

i.e minimize of form1 becomes form2 minimize.
normal of form1 becomes form2 normal.
closing of form1 becomes form2 close.

All these are working.

but when form1 is behind the screen, i.e if form1 activates, form2 have to come front.

I have wrote activate event for this.
In this i have problem, if we use form activate event, when we click for minimize of form1, it calls form1 activate event and activates form2, but not minimize. It will go to infinite.

How to activate form2 when form1 activates, but when we minimize form1, form2 also have to minimize.

Form2= _rptForm
  1. protected override void WndProc(ref Message m)
  2. {
  3. if (m.Msg == 0x0112) // WM_SYSCOMMAND
  4. {
  5. if (m.WParam == new IntPtr(0xF020)) //SC_MINIMUM
  6. {
  7. _rptForm.WindowState = FormWindowState.Minimized;
  8. }
  9.  
  10. if (m.WParam == new IntPtr(0xF120)) //SC_RESTORE
  11. {
  12. _rptForm.WindowState = FormWindowState.Normal;
  13. }
  14.  
  15. m.Result = new IntPtr(0);
  16. }
  17. base.WndProc(ref m);
  18. }
  19.  
  20. private void DataBoxDlg_Activated(object sender, EventArgs e)
  21. {
  22.  
  23. _rptForm.Activate();
  24. }

Please change this code to work all which i mention above.
Ambarish
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 136
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Activate form2 when form1 activates(Back to front)

 
1
  #2
Jan 16th, 2009
Can i maybe give you a new approach ???

Ive done this like this

in the formload of form1
  1. this.Tag = form2;

now you can access form 2, so now you can say on a button -

  1. Form2.Show(); // If you want both to be active for use
  2. Form2.ShowDialog(); // If you want form1 to be disabled

Now you can also say this on a button on form1

  1. form2.close(); // If you want to close it
  2. form2.WindowState = FormWindowState.Minimized;

Happy coding my friend ...
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,042
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 308
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Postaholic

Re: Activate form2 when form1 activates(Back to front)

 
0
  #3
Jan 16th, 2009
Indead cVz, if you can do it the easy way, why do it the hard way.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 66
Reputation: ambarisha.kn is an unknown quantity at this point 
Solved Threads: 0
ambarisha.kn ambarisha.kn is offline Offline
Junior Poster in Training

Re: Activate form2 when form1 activates(Back to front)

 
0
  #4
Jan 17th, 2009
i dont have problem in minimizing,maximizing, Show and close. How to bring to front of the form2 when form1 activates.

I want only one operation.

When form1 is in normal state but behind another window, if we click that form1, form2 also have to come front along form1.


How to do this? Is it possible using tag itself. I dont have any buttons in the form.Please give me the solution for this.


Which event i have to call when form1 came front.

I want to do every operation of form1 reflects on form2.

minimize , maximize, normal, BringToFront, close etc...

All are working except Bring2Front.
Please suggest me the solution in simple way.
Last edited by ambarisha.kn; Jan 17th, 2009 at 4:12 am.
Ambarish
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,042
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 308
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Postaholic

Re: Activate form2 when form1 activates(Back to front)

 
0
  #5
Jan 17th, 2009
A Form has a TopMost property. I did not try it but if it is set to true the form shows above all other forms.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 66
Reputation: ambarisha.kn is an unknown quantity at this point 
Solved Threads: 0
ambarisha.kn ambarisha.kn is offline Offline
Junior Poster in Training

Re: Activate form2 when form1 activates(Back to front)

 
0
  #6
Jan 18th, 2009
But i want event, when form1 come to front, to make form2 as topmost.

Need Event of form1, to make form2 as topMost.
when form1 come front from back screen.
Last edited by ambarisha.kn; Jan 18th, 2009 at 9:42 pm.
Ambarish
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 136
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Activate form2 when form1 activates(Back to front)

 
0
  #7
Jan 19th, 2009
Just minimize and maximize the form you want on top ...l it will work ...
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 66
Reputation: ambarisha.kn is an unknown quantity at this point 
Solved Threads: 0
ambarisha.kn ambarisha.kn is offline Offline
Junior Poster in Training

Re: Activate form2 when form1 activates(Back to front)

 
0
  #8
Jan 19th, 2009
@cVz:
I didnt get you, will u please explain in brief.

Originally Posted by cVz View Post
Just minimize and maximize the form you want on top ...l it will work ...
Ambarish
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 66
Reputation: ambarisha.kn is an unknown quantity at this point 
Solved Threads: 0
ambarisha.kn ambarisha.kn is offline Offline
Junior Poster in Training

Re: Activate form2 when form1 activates(Back to front)

 
0
  #9
Jan 19th, 2009
I want form2 should be in top, when form1 is also in top of other windows. To do this which event i have to call??

i.e if i click form1, both forms have to appear if it is behind the other windows.
Ambarish
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 136
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Activate form2 when form1 activates(Back to front)

 
0
  #10
Jan 19th, 2009
You have your form declaration here
  1. Form2 F2 = new Form2();
  2. F2.Show();
  3. F2.WindowState = FormWindowState.Minimized;

then you have this on the FormWindows State changed or on a button click
  1. if (this.WindowState == FormWindowState.Normal)
  2. {
  3. F2.WindowState = FormWindowState.Normal;
  4. }

Hope it helps , mark as solved if it did... viola
Last edited by cVz; Jan 19th, 2009 at 3:31 am.
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum


Views: 3200 | Replies: 16
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC