problem with SendMessage

This is a discussion on problem with SendMessage within the Windows Programming forums, part of the Platform Specific Boards category; First I Get notepad's handle HANDLE hNote = FindWindow(....) Now Question is PostMessage(hNote,WM_KEYDOWN,0x31,0x470001); is success but When i use SendMessage(hNote,WM_KEYDOWN,0x31,0x470001); ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    2

    problem with SendMessage

    First I Get notepad's handle

    HANDLE hNote = FindWindow(....)

    Now Question is

    PostMessage(hNote,WM_KEYDOWN,0x31,0x470001);

    is success

    but

    When i use

    SendMessage(hNote,WM_KEYDOWN,0x31,0x470001);

    it's does not work

    i want to know why

    thank you

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Because you are posting your message to a window in a different process... SendMessage wait's for the function to return, it can't know where to return to across isolated processes thus the call fails. PostMessage does not wait for the function to return so it can succeed across the process boundary.

    FWIW... if you are sending WM_KEYDOWN... don't forget to also send WM_KEYUP as any subsequent WM_KEYDOWN messages will either be ignored (creating a dead key) or cause errors in the target process.
    Last edited by CommonTater; 02-15-2011 at 09:35 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21