Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How come I can WM_CLOSE an out-of-process Notepad but can't get it to display a WM_CHAR?

How come I can WM_CLOSE an out-of-process Notepad but can't get it to display a WM_CHAR?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    glyfyx
    wrote on last edited by
    #1

    In my simple win32 pgm I launch Notepad, CreateProcess("c:\\winnt\\notepad.exe"... then get a handle to it, hwndTarget = FindWindow(NULL, TEXT("Untitled - Notepad")); then close it with no problem, SendMessage(hwndTarget, WM_CLOSE, 0, 0); But if instead of closing it I try to Post/Send it a character to display PostMessage (hwndTarget, WM_CHAR, 'x', 1) ; SendMessage (hwndTarget, WM_CHAR, 'z', 1) ; it doesn't work. So I'm missing something here, but don't know what it is. Thanks for any assistance! glyfyx

    D G 2 Replies Last reply
    0
    • G glyfyx

      In my simple win32 pgm I launch Notepad, CreateProcess("c:\\winnt\\notepad.exe"... then get a handle to it, hwndTarget = FindWindow(NULL, TEXT("Untitled - Notepad")); then close it with no problem, SendMessage(hwndTarget, WM_CLOSE, 0, 0); But if instead of closing it I try to Post/Send it a character to display PostMessage (hwndTarget, WM_CHAR, 'x', 1) ; SendMessage (hwndTarget, WM_CHAR, 'z', 1) ; it doesn't work. So I'm missing something here, but don't know what it is. Thanks for any assistance! glyfyx

      D Offline
      D Offline
      Dr Emmett Brown
      wrote on last edited by
      #2

      The problem is that you're sending the messages to the main window. Maybe the edit control that processes the chars is a child window of the main. You can find it with spy++. Hope it helps

      rotter The metaller programmer

      1 Reply Last reply
      0
      • G glyfyx

        In my simple win32 pgm I launch Notepad, CreateProcess("c:\\winnt\\notepad.exe"... then get a handle to it, hwndTarget = FindWindow(NULL, TEXT("Untitled - Notepad")); then close it with no problem, SendMessage(hwndTarget, WM_CLOSE, 0, 0); But if instead of closing it I try to Post/Send it a character to display PostMessage (hwndTarget, WM_CHAR, 'x', 1) ; SendMessage (hwndTarget, WM_CHAR, 'z', 1) ; it doesn't work. So I'm missing something here, but don't know what it is. Thanks for any assistance! glyfyx

        G Offline
        G Offline
        glyfyx
        wrote on last edited by
        #3

        Thanks rotter - I believe that's it! I used Spy++ (for the first time!) and found what looks very much like a child window and its handle under Notepad. Now what I have to do is figure out how to obtain the child's handle in my code then send WH_CHAR to it. Big help - thanks! glyfyx

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups