Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello,

I'm writing a remote client/server application in C# Windows.Forms,

I have a client that shows the "stream" in pictures of the running server in a picturebox located on the client form.

When i click on the image viewed in the picturebox on client side, i want it to click on that posistion on the server side.

Can somebody help me with this, with some code examples/clear instructions ?

Thank You

What I have tried:

What I have tried:

I tried alot: I'm able to click, but always end in clicking wrong then the actual clicked position.

I tried different formulas find on the internet to recalculate the actual posistion, for example:
Point point = e.Location;

double pixelwidth = ReceiveImagePB.Image.Width;
double pixelheight = ReceiveImagePB.Image.Height;

double xPos = ReceiveImagePB.Size.Width * point.X / pixelwidth;
double yPos = ReceiveImagePB.Size.Height * point.Y / pixelheight;

string xposition = "X:" + xPos;
string yposition = "Y:" + yPos;
Posted
Updated 24-Feb-17 16:58pm
v2
Comments
Philippe Mori 14-Feb-17 20:20pm    
You need to ensure that coordinates in e.Location are relative to the control that contains the bitmap and that the bitmap fully cover the control. So at each step compare actual values with expected ones...

1 solution

Well i got a solution: the code i used for the mouse click did not work correctly, i wrote something easy to simulate the mouseclick and now it works perfect.

Thanks for the effort Philippe Mori.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900