|
Hi All,
I am trying to draw a rectangle and then draw a circle within the rectangle. At this point I have the rectangle drawing but the circle. The circle within the rectangle is going to move based on motion of the mouse. I am going to try to take the input of the mouse and make those my X and Y coordinates. If anyone has any experience with either have 2 paint event handlers or with having to update the circle depending on location, it would be great! Any sample code and guidance would be greatly appreciated! See below for event handlers. I am developing use C# and Visual Studio 2005.
<br />
private static void f1_paint(object sender, PaintEventArgs e)<br />
{<br />
Graphics dc = e.Graphics;<br />
Pen p = new Pen(Color.White, 3);<br />
dc.DrawRectangle(p, 478, 10, 487, 352);<br />
p.Dispose();<br />
}<br />
private static void f2_paint(object sender, PaintEventArgs e)<br />
{<br />
Graphics dc = e.Graphics;<br />
Pen o = new Pen(Color.Orange, 5);<br />
dc.DrawEllipse(o, 717, 176, 5, 5);<br />
o.Dispose();<br />
}<br />
<br />
this.Paint += new PaintEventHandler(f2_paint);<br />
Thanks,
Laura
|
|
|
|
|
Don't use a timer. Use the MouseEnter, MouseMove and MouseLeave events to trigger the update the control. Those events give you a MouseEventArgs object that contains the coordinates of the mouse pointer. Store the coordinates in member variables so that you can use them in the paint event.
There is no use in having more than one paint event handler for a control. They will just run after each other, so you can just put all the code in the same event handler.
laura1316 wrote: //In timer function will take in mouse input and update circle so need to call f2_paint.
this.Paint += new PaintEventHandler(f2_paint);
That will not call the event handler, it will instead add another event handler to the event. If you do that in a timer event, you soon will have thousands of event handlers in the paint event, each one drawing the same thing on top of the other.
When you need the control to be redrawn, just call the Invalidate method of the control. This will cause a paint event.
---
single minded; short sighted; long gone;
|
|
|
|
|
hi all i am looking for help plz i am writing a program with c# that makes MDI tab page browsing and i want after i close a form to remove it's tab.i know how to remove the tab.All i want is to enter to the code of the closing button of the form to add the code that remove the tab.Thanks in advance
Best Wishes
|
|
|
|
|
Register to the Form.Closing or Form.FormClosing event.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
plz can u tell me step by step i mean i want to put this code in the function that close the form
//Destroy the corresponding Tabpage when closing MDI child form
this.tabPag.Dispose();
//If no Tabpage left
if (!tabCtrl.HasChildren)
{
tabCtrl.Visible = false;
}
where to put it??????? ( sorry i am new in programming
Best Wishes
|
|
|
|
|
mezo_22 wrote: sorry i am new in programming
Hey, it's okay buddy, I'm one as well.. "just a couple of decades though"
You should be putting this code in your tab closing triggering button (ie. if your closing the tab pages using a button each time, then each one of these buttons should check first if there's still more tab pages on this tab control and close the current one if there's still some, otherwise, the whole application should be put to an end.. you know "Application.Exit()"..
I hope this was useful
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Event Handling in Windows Forms[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I'm trying to hide the console window of a process that I start from my app.
I'm using FindWindow like this:
[DllImport("user32.dll")]
public static extern int FindWindow(string szClass, string szTitle);
but calls to
int win = FindWindow(MyConsoleAppClass, null);
or
int win = FindWindow(null, "MyConsoleApp.exe");
return 0.
Any ideas as to what am I doing wrong?
thanx
|
|
|
|
|
I think this will help:
If szClass is NULL FindWindow will search for the window by the szTitle (window's title) only. This is useful if the class of a particular window is variable.
more information: http://pinvoke.net/default.aspx/user32.FindWindow
|
|
|
|
|
Is there a way to remove the files click once places into the project? I am not going to use this feature and would like to remove the files (.pfx, .manifest) safely if I can or should I be concerned? Thanks!
Tim
|
|
|
|
|
What is in your project is irrelevant, you don't deploy the project anyhow, right ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm working on a program that compares lines from two .txt files line by line.
It compares the first line of the first file then first line of the second file and so on.
But when the two files have different number of lines the program will fall.
How to solve this problem.
C#
|
|
|
|
|
You can simply do it by checking the line you get first from the stream before comparing it with what so ever, sorry but not sure how to do it in c#, however you have to look for the "end of file" escape character, we use EOF in c++..
while(youStreamReader.ReadLine() != EOF)
dadadadada...
Another alternative is that you can read the entire file contents once before starting the comparison process and determine the number of lines "using the end of line escape character which you have to find out " and use this number in your loop to break it later.. hope this was of some help.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
When two lines do not match, you need to search ahead in both files, to see if either file has a line ahead that matches ( or better matches ) the current one. A brute force approach here is going to be very expensive, I would think.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
My name is Nabeel Younus. I am doing research work fingerprint. I am looking for someone which can help in this context. I am also working but finding some problems.
So if someone has worked in it plz tell me. Perhaps I will be able to get some kind of help? Now-a-days I have been stuck on finding the corepoint in fingerprint.
I will be really grateful for favor
|
|
|
|
|
Great, I was going to write an article dealing with fingerprint implementation, laser applications, security and alarm systems but I dont think I still have time to do this at least not this month .. I'm using Graule SDK, try googling for that or you can wait for my article;)
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello everyone
I have a Windows Application which connects the user to a remote database. I created a Web Service to detect the use's IP address. Everything works fine. The strange problem appears when I try to send the detected user's IP address back to the Windows Application. For some reason when it comes to the point that I calculate the use IP Number, the XML doesn't like the number. This is the PHP code that is calculating the IP Number:
$IPnumb = ($ips[3]+$ips[2]*256+$ips[1]*256*256+$ips[0]*256*256*256);
I have played around with it and it appears that $ips[0]*256*25*256 creates a number bigger than the XML likes. Just for a test reason I changed that and managed to find out the threshold number is $ips[0]*256*25*170.
The actual number would be 192*256*256*170 = 2139095040.
The Error Message:
There is an error in XML document (1, 497).
I was wondering if anyone else has such an experince and if anyone knows what I can do to solve this problem? Maybe it is not the XML problem and it is rather a problem of my Windows Application developed in C#. On the Windows Application ends there isn't much to talk about except that the value from the Web Service is assigned to a variable (Int32).
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
XML doesn't care what you put into it. You're crossing the threshhold of the value that can be held in a variable along the way, I'd say.
I'd pass it as a string, and pass it as an actual IP address.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
When I import csv in dataset with is own schema, it's imported under another table as new table or it's imported in the same table in new columns and in this case the first data row is taken as column name. In the solution, I don't want to put my columns name in the csv.
Thanks for your help.
Dave
This is the part of the code;
The xsd for schema is created with vs2005
sql_select = "select * from [" + filetable + "]";
obj_oledb_da = new System.Data.Odbc.OdbcDataAdapter(sql_select, conn);
//Fill dataset with the records from CSV file
obj_oledb_da.Fill(ds, "ITEMS");
conn.Close();
|
|
|
|
|
sorry, but this's really funny, why dont you spare your time and search the message board for "csv" and choose one of the million posts that have been posted regarding csv. I just cant believe what's this fuss lately regarding csv!!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
Unfortunately, I did not find the same problem or situation on Google or posts.
But thanks for the precious time and answer.
|
|
|
|
|
Sorry maybe you should post it again today or choose a different time "you know, different time, different people, different answers!"
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi everyone
Can anyone plz tell me how to display a message from the task bar in the form of a balloon. You know like when it pops up from the task bar when u are informed to get the windows updated or when u close the messenger window and it says that it’s still running. I’m working in Windows Server 2000 SP 4 right now.
I'm workin in a C# windows application
Thanks in advance.
Rocky
|
|
|
|
|
To display an icon in the system tray use the NotifyIcon component. If you're using Fraemwork > 1.1 you can use its BalloonTipText and BalloonTipTitle properties to display a balloon tip.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
well I'm using .Net 2.0 and I've already tried using NotifyIcon but it's not working. Probably I'm missing a trick here.
I've just made a new form for testing its functionality and I've coded like this
form1_Load()<br />
{<br />
NotifyIcon n = new NotifyIcon();<br />
n.BaloonTipText="This is the text";<br />
n.BaloonTipTitle="This is the title";<br />
n.ShowBaloonTip(5000);<br />
}
so now pz tell me what to do.
what I wanna do is to use this baloon tip to show an alert in my application and when the user clicks the baloon, it should open a new form.
Rocky
|
|
|
|