|
I am trying to show a small form when you hover over this label. A image is on this form and thats it (form is borderless). When you hover over the label it comes up, when you move the mouse left or right or up or down it moves with it. Problem is it keeps flashing! What am I doing wrong?
private void lbSig_MouseEnter(object sender, EventArgs e)
{
sigForm.Location = new Point(Cursor.Position.X, Cursor.Position.Y);
sigForm.Show();
}
private void lbSig_MouseLeave(object sender, EventArgs e)
{
sigForm.Hide();
}
private void lbSig_MouseMove(object sender, MouseEventArgs e)
{
sigForm.Location = Cursor.Position;
}
|
|
|
|
|
Hi Jacob,
I guess this is what is going on:
mouse enters label, sigForm gets shown at same location, on top of label, hence label fires MouseLeave, formsig gets hidden, hence mouse on top of label again, etc.
suggestion: remove the sigForm.Hide() and choose another way to terminate your magnifying glass or whatever it is you are doing.
|
|
|
|
|
Uhm... not really sure where to go from there on that one...
Let me give an example:
http://home.comcast.net/~littlemoe85/thumbhover/index.html
Now obviously that is for web design but I want the same effect in Windows.
You hover over a label, when you do a image comes up showing the users signature (which is saved in the database). The reason I am doing it in another form rather than drawing it on the current form is because where the label is positioned. The size of the images vary (which explains the popup rather than just resizing the panel or picturebox on the form). Doing it in another form shows it outside that parent form. Which means it can be shown ontop of the parent form and not cut any of the image off because it went to far to the right or whatever...
Any other ideas?
|
|
|
|
|
On the link you provided, I see both a tooltip and an enlarged image when hovering a thumbnail, however they both are NOT located at the hotspot of the cursor, so you never leave the thumbnail. Hence, change your MouseEnter handler to include:
sigForm.Location = new Point(Cursor.Position.X+3, Cursor.Position.Y+3);
or whatever you prefer that keeps sigForm away from the cursor position itself.
|
|
|
|
|
Duh! That makes sense. Since im hovering right where the cursor is it IS firing the MouseLeave. I should of caught that. Thanks for helping me out.. that worked perfect
|
|
|
|
|
And now for the advanced solution: make your sigForm a rectangle with a tiny hole in it, and make it appear so that the cursor points through the hole to the underlying label... That will keep you busy for a while, but I think it is doable (haven't seen it yet though).
|
|
|
|
|
Now that would be difficult... I mean you could make a oval transparent.. but it would still think its on the popup window right?
|
|
|
|
|
not necessarily. You could try and explain the form really isn't a solid rectangle, probably using regions (I haven't ever begun to try it). The easier way would probably be to keep the sigForm disabled, i.e. visible but not available for user interaction.
And then there is an alternative where you don't really put up a new Form, instead you paint things yourself on top of everything that is already on the screen, see e.g. the ControlPaint class; mind you, I haven't been very successful in using it, there seem to be lots of unwanted side effects.
|
|
|
|
|
Hello,
I've developed a client/server application and now I want to send an custom object through TCP/IP.
I've developed a solution for this, that worked, but I'm not shore it is the best. My solution was to convert the object to byte array and then send it to the server; the server convert the byte array to object and this is it!
Does C# have a pattern for this?
Cheer's,
Alex Manolescu.
|
|
|
|
|
What you've described is pretty much it. It's the way that most people would tackle it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks you for replay!
Cheer's,
Alex Manolescu.
|
|
|
|
|
That's pretty much how it's done. The magic phrase you're looking for is "binary serialization."
|
|
|
|
|
Thanks you for replay!
Cheer's,
Alex Manolescu.
|
|
|
|
|
Alex Manolescu wrote: Does C# have a pattern for this?
Note a pattern as such, there's serialization (binary, XML), transmission using the TcpClient[^].
You came to ask for a pattern - So I guess that you'd like to compare your solution to the design pattern. I have no design-pattern, but some questions to ponder over.
* Sometimes you want to try and connect in a different way. E.g., SQL Express usually babbles over TCP/IP, but it can also babble over pipes.
* Sometimes the data is sensitive. Have you considered encryption?
* Sometimes larger transmissions get interrupted for different reasons. Can you send the serialized object in multiple pieces, say, a 100? It would be nice if the sender than could send a list with the pieces it wants' and to resend them. That way you could also show a progres-indication of what's sent.
I are Troll
|
|
|
|
|
Thanks you for replay!
I just wanted to find the best way to do what I've describe, so encryption is not my priority now.. thanks anyway for sugestion
Cheer's,
Alex Manolescu.
|
|
|
|
|
Another approach would be to use the Memento[^] design pattern. You could create a data structure that represents the state of you class but is much more lightweight and send it (using binary serialization) instead. The receiver would then create a new object from the data structure.
|
|
|
|
|
Thanks you for replay!
I think i'll give it a try, and compare the performances. You have wake my interest for this pattern, you get a 5
Cheer's,
Alex Manolescu.
|
|
|
|
|
Take a look at protocol buffers too. Here[^] is a .NET implementation of that.
Best wishes,
Navaneeth
|
|
|
|
|
Yes! this is what I'm looking for
Thanks you Navaneeth!
I'll give it a try and see how it works.
Cheer's,
Alex Manolescu
|
|
|
|
|
I am writing a program that involves capturing an area of the screen and saving it as an image. I know that I can use g.CopyFromScreen, which uses three arguments: Point upperLeftSource, Point upperLeftDestination, and Size blockReigonSize. The first and last I understand, but the upperLeftDestination is something a mystery to me. Additionally, I have been unable to save the captured image. I know of a few different methods that I could use, but it seems to me that none of them allow you to say what it is that you want to save. I am fairly inexperienced, so reasonably simple answers would be great.
|
|
|
|
|
|
Actually, I'm using some of that code in my project. Thanks, though.
|
|
|
|
|
Hi,
In
Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockReigonSize)
a rectangle gets copied, its size is blockReigonSize, the rectangle gets copied from the screen starting at upperLeftSource(to the right and down), and it gets copied into the Graphics (which could have any size) starting at upperLeftDestination(also to the right and down).
|
|
|
|
|
According to MSDN[^] upperLeftDestination is the point at which you want to start copying into the graphics object - which makes sense. If it wasn't provided, then the copy would always take place at the top left corner of the graphics output - with it you can offset it by (say) 100 pixcels down, by 200 pixcels in.
To copy, display and save it:
Bitmap b = new Bitmap(picBig.Width, picBig.Height);
Graphics g = Graphics.FromImage(b);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), b.Size);
picBig.Image = b;
b.Save(@"C:\Screendump.bmp");
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Thank you. That's exactly what I needed to know. Well, almost. You see, I'm copying the image from a Shockwave Flash object, so axShockwaveFlash1.Image doesn't exist. What exactly is picBig?
|
|
|
|