Click here to Skip to main content
16,020,669 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi forum,

I have developed an application in which several text box controls are added to panel2 of a split container. Each Text box behaves as a virtual monitor. I also add a button control to panel2 in runtime, which represents a separate application running on any one of the several actual monitors connected.
I adjust the size of each textbox according to the resolution of the monitors connected. When I resize the button according to the dimensions of textbox, the size of the application also increase in the same proportion on the actual monitor desktop.
My problem is that Location of the application on actual monitor is always wrong, when I move the button control on the textbox(virtual monitor). There is always some offset value by which application location on the monitors differs from the button position on the textbox(virtual monitor).
I will be highly thankful, if anyone can guide to solve this matter.

Thanking in anticipation
NamitaS

Source code in MouseMove_ event handler is posted below:
C#
protected virtual void MouseMoveEventHandler(object sender, MouseEventArgs e)
 {            
   if (
     !"Core.Windows.Forms.EditableControl"
     .Equals(sender.GetType().ToString()) &&
     _control_moving != null &&
      e.Button == MouseButtons.Left
       )
   {      
        _control_moving.Left = (_control_moving.Left + e.x) -      x_offset_on_client_control;
        _control_moving.Top = (_control_moving.Top + e.y)  - y_offset_on_client_control;

        // movement of the Media Player application
        // g_Obj is the handle to the corresponding Media Player App
        // cubeXres is the horizontal resolution of the actual monitor
        // cubeYres is the vertical resolution of the actual monitor
        // hSize is the width of the textbox(virtual monitor)
        // vSize is the height of the textbox(virtual monitor)
    
       Point mypoint = new Point((_control_moving.Left * (cubeXres / hSize)), (_control_moving.Top * (cubeYres / vSize)));
           
         g_Obj.Location = mypoint;                                     
   }
Posted
Updated 29-Apr-10 20:27pm
v2

1 solution

I am by no means sure that this is the solution to your problem but it may be the case that you need to convert mypoint to screen coordinates before assigning it to g_Obj.Location.

See PointToScreen[^].
 
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