943,648 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 7876
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 15th, 2009
0

Activate form2 when form1 activates(Back to front)

Expand Post »
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
c# Syntax (Toggle Plain Text)
  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.
Reputation Points: 25
Solved Threads: 0
Junior Poster in Training
ambarisha.kn is offline Offline
66 posts
since Jun 2008
Jan 16th, 2009
1

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

Can i maybe give you a new approach ???

Ive done this like this

in the formload of form1
C# Syntax (Toggle Plain Text)
  1. this.Tag = form2;

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

C# Syntax (Toggle Plain Text)
  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

C# Syntax (Toggle Plain Text)
  1. form2.close(); // If you want to close it
  2. form2.WindowState = FormWindowState.Minimized;

Happy coding my friend ...
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 16th, 2009
0

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

Indead cVz, if you can do it the easy way, why do it the hard way.
Reputation Points: 2023
Solved Threads: 644
Senior Poster
ddanbe is online now Online
3,736 posts
since Oct 2008
Jan 17th, 2009
0

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

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.
Reputation Points: 25
Solved Threads: 0
Junior Poster in Training
ambarisha.kn is offline Offline
66 posts
since Jun 2008
Jan 17th, 2009
0

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

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.
Reputation Points: 2023
Solved Threads: 644
Senior Poster
ddanbe is online now Online
3,736 posts
since Oct 2008
Jan 18th, 2009
0

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

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.
Reputation Points: 25
Solved Threads: 0
Junior Poster in Training
ambarisha.kn is offline Offline
66 posts
since Jun 2008
Jan 19th, 2009
0

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

Just minimize and maximize the form you want on top ...l it will work ...
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 19th, 2009
0

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

@cVz:
I didnt get you, will u please explain in brief.

Click to Expand / Collapse  Quote originally posted by cVz ...
Just minimize and maximize the form you want on top ...l it will work ...
Reputation Points: 25
Solved Threads: 0
Junior Poster in Training
ambarisha.kn is offline Offline
66 posts
since Jun 2008
Jan 19th, 2009
0

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

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.
Reputation Points: 25
Solved Threads: 0
Junior Poster in Training
ambarisha.kn is offline Offline
66 posts
since Jun 2008
Jan 19th, 2009
0

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

You have your form declaration here
c# Syntax (Toggle Plain Text)
  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
c# Syntax (Toggle Plain Text)
  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.
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: time complexity
Next Thread in C# Forum Timeline: can C# perform command prompt lines





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC