Click here to Skip to main content
16,016,192 members
Home / Discussions / C#
   

C#

 
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 
I just tried it on my XP machine and it didn't show. The problem was Notepad remembers it's last size and location and it assumes that relative to the hwnd's top left.

Using SetWindowPos sorts it. This will make it the same size as the panel and at point 0,0.
private void button1_Click(object sender, EventArgs e) 
{
    Process p = Process.Start("Notepad.exe");
    p.WaitForInputIdle(); 
    SetParent(p.MainWindowHandle, panel1.Handle);
    SetWindowPos(
        p.MainWindowHandle,
        IntPtr.Zero,
        0, 0,
        panel1.Width, panel1.Height,
        0u);
}
[DllImport("user32.dll", EntryPoint = "SetParent", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent);

[DllImport("user32.dll")]
private static extern bool SetWindowPos(
    IntPtr hWnd,
    IntPtr hWndInsertAfter,
    int X, int Y,
    int cx, int cy,
    uint uFlags);


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

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 
AnswerRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Giorgi Dalakishvili23-Oct-08 8:57
mentorGiorgi Dalakishvili23-Oct-08 8:57 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
vigylant23-Oct-08 9:42
vigylant23-Oct-08 9:42 
Question/define project compiler not being recognized (vstudio 2005) Pin
dwolver23-Oct-08 5:10
dwolver23-Oct-08 5:10 
AnswerRe: /define project compiler not being recognized (vstudio 2005) Pin
Ennis Ray Lynch, Jr.23-Oct-08 7:14
Ennis Ray Lynch, Jr.23-Oct-08 7:14 
QuestionHow to adjust button's location Pin
Sokka9323-Oct-08 5:06
Sokka9323-Oct-08 5:06 
AnswerRe: How to adjust button's location Pin
Simon P Stevens23-Oct-08 5:29
Simon P Stevens23-Oct-08 5:29 
GeneralRe: How to adjust button's location Pin
Sokka9325-Oct-08 21:30
Sokka9325-Oct-08 21:30 
Questionsimple DataGridView question. Pin
zaboboa23-Oct-08 4:47
zaboboa23-Oct-08 4:47 
AnswerRe: simple DataGridView question. Pin
Ennis Ray Lynch, Jr.23-Oct-08 5:02
Ennis Ray Lynch, Jr.23-Oct-08 5:02 
GeneralRe: simple DataGridView question. Pin
zaboboa23-Oct-08 5:12
zaboboa23-Oct-08 5:12 
GeneralRe: simple DataGridView question. Pin
Ennis Ray Lynch, Jr.23-Oct-08 5:22
Ennis Ray Lynch, Jr.23-Oct-08 5:22 
Questionsending file through phone line Pin
Jassim Rahma23-Oct-08 4:47
Jassim Rahma23-Oct-08 4:47 
AnswerRe: sending file through phone line Pin
Ennis Ray Lynch, Jr.23-Oct-08 5:01
Ennis Ray Lynch, Jr.23-Oct-08 5:01 
AnswerRe: sending file through phone line Pin
#realJSOP23-Oct-08 6:06
professional#realJSOP23-Oct-08 6:06 
GeneralRe: sending file through phone line Pin
Jassim Rahma23-Oct-08 12:43
Jassim Rahma23-Oct-08 12:43 

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.