| | |
Problem with 2 forms
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
I like to write a screen capture utility. Plan : have a master control form, let it make a second transparant form on wich a selection rect can be drawn, copy the screen under the rectangle to a Bitmap with Grapics.CopyFromScreen.
Here is the essential code I have so far:
The only thing I wanted to do here is switching between the two forms, by clicking a button in Master and clicking on Transparant.
The problem is that Transparant sometimes thinks that the TaskBar is the main screen and I can't figure out why.
Anyone any suggestions? Is my basic strategy totally wrong?
Here is the essential code I have so far:
C# Syntax (Toggle Plain Text)
public partial class Master : Form { private Form Foil; public Master() { InitializeComponent(); Foil = new TransparantFoil(this); Foil.Hide(); } private void Button_Click(object sender, EventArgs e) { this.Hide(); Foil.Show(); } } public partial class TransparantFoil : Form { private Form _master; public TransparantFoil(Form M) { InitializeComponent();//WindowState= Maximized Opacity=0.4 _master = M; } private void TransparantFoil_Click(object sender, EventArgs e) { this.Hide(); _master.Show(); } }
The only thing I wanted to do here is switching between the two forms, by clicking a button in Master and clicking on Transparant.
The problem is that Transparant sometimes thinks that the TaskBar is the main screen and I can't figure out why.
Anyone any suggestions? Is my basic strategy totally wrong?
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
Logic looks ok to me, my only question is is "_master" always what you think it should be? Im wondering if perhaps instead of overriding the creation it somehow isnt using it so _master ends up null or something and that perhaps this is causing the effect you see
Last edited by LizR; Dec 21st, 2008 at 10:17 am.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
LizR, I tried your suggestion and tested on null, but it never occurred. Finally I found that the location property of a form is relative to the container in which it is created. I still can explain it but if I swap lines 14 and 15 in the code above it seems to work!
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
I knew the location would likely be relative, but that didnt sound like the behavior you got. Let alone swapping the show and hide round.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
I think the second form gets teh coordinates of the hidden form as its base. And Hide means to me something like put the location of this form into oblivion(screen coordinates of millions and more or something like that)
So when master form is Hidden first teh Transparent form tries his best and shows itself in the Taskbar.
So when master form is Hidden first teh Transparent form tries his best and shows itself in the Taskbar.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
![]() |
Similar Threads
- Form without action "imitate" of other Form (which do have action) ??? (JavaScript / DHTML / AJAX)
- Side-by-side forms? (HTML and CSS)
- Form Problem (ColdFusion)
- Forms in Random access files (Visual Basic 4 / 5 / 6)
- Problem with two forms (Visual Basic 4 / 5 / 6)
- Problem with Forms (PHP)
- Problem with forms (PHP)
- MDI forms and their Children (Visual Basic 4 / 5 / 6)
- How to use two forms in asp (ASP)
Other Threads in the C# Forum
- Previous Thread: Pascal's Triangle
- Next Thread: Return True/False if Process is Running
| Thread Tools | Search this Thread |
.net access algorithm angle array asp.net barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ image index input install java label leak libraries list listbox loop mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml






