Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
AnswerRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Michael Bookatz23-Oct-08 6:49
Michael Bookatz23-Oct-08 6:49 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
vigylant23-Oct-08 6:53
vigylant23-Oct-08 6:53 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Michael Bookatz23-Oct-08 6:58
Michael Bookatz23-Oct-08 6:58 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
vigylant23-Oct-08 7:02
vigylant23-Oct-08 7:02 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely23-Oct-08 7:02
Dan Neely23-Oct-08 7:02 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Michael Bookatz23-Oct-08 7:06
Michael Bookatz23-Oct-08 7:06 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Anthony Mushrow23-Oct-08 12:42
professionalAnthony Mushrow23-Oct-08 12:42 
AnswerRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dave Kreskowiak23-Oct-08 7:55
mveDave Kreskowiak23-Oct-08 7:55 
The way you're post suggests it, you can't. You have no control over how the code of another app runs, and for the most part, how a foreign window behaves.

But, as the other poster said, it is possible to host the window of another app in your own application and control the mouse visibility in your own window. Though, using this technique can cause problems for the app being hosted. You may run into drawing problems in the hosted app, or other issues.

You need to create a window in your app, like a Panel control in a form. Just keep it a light-weight control. Then you need to get the window handle of the main window of the application and call a Win32 function called SetParent to change that window's parent to your Panel control's window. For example:
[DllImport("user32.dll", EntryPoint = "SetParent", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent);

private void button1_Click(object sender, EventArgs e)
{
    Process p = Process.Start("Notepad.exe");
    p.WaitForInputIdle();
    SetParent(p.MainWindowHandle, panel1.Handle);
}



A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008




GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely23-Oct-08 8:24
Dan Neely23-Oct-08 8:24 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dave Kreskowiak23-Oct-08 9:11
mveDave Kreskowiak23-Oct-08 9:11 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely24-Oct-08 7:00
Dan Neely24-Oct-08 7:00 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
DaveyM6923-Oct-08 8:37
professionalDaveyM6923-Oct-08 8:37 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Giorgi Dalakishvili23-Oct-08 8:56
mentorGiorgi Dalakishvili23-Oct-08 8:56 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
DaveyM6923-Oct-08 9:27
professionalDaveyM6923-Oct-08 9:27 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Giorgi Dalakishvili23-Oct-08 9:30
mentorGiorgi Dalakishvili23-Oct-08 9:30 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dave Kreskowiak23-Oct-08 9:13
mveDave Kreskowiak23-Oct-08 9:13 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely23-Oct-08 10:02
Dan Neely23-Oct-08 10:02 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dave Kreskowiak23-Oct-08 10:47
mveDave Kreskowiak23-Oct-08 10:47 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely23-Oct-08 11:31
Dan Neely23-Oct-08 11:31 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dave Kreskowiak23-Oct-08 12:18
mveDave Kreskowiak23-Oct-08 12:18 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
DaveyM6923-Oct-08 23:20
professionalDaveyM6923-Oct-08 23:20 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely24-Oct-08 2:12
Dan Neely24-Oct-08 2:12 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
DaveyM6924-Oct-08 5:04
professionalDaveyM6924-Oct-08 5:04 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely24-Oct-08 6:57
Dan Neely24-Oct-08 6:57 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
DaveyM6924-Oct-08 5:08
professionalDaveyM6924-Oct-08 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.