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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox

Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocsharpdebuggingjson
7 Posts 4 Posters 1 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi, I have a console application that spawns a childprocess I am initially able to get the MainFrame Window in the console app thru EnumThreadWindows Later I create a modeless Dialog in the childprocess for which I would like the to get the HWND handle I am running this code (both apps) under the Visual Studio debugger So I can see when the child process creates the modeless dialogbox I then step thru (under VS debugger) both GetWindow(MainFrame,GW_CHILD) and EnumChildWindows and neither API return anything

    B L L 3 Replies Last reply
    0
    • F ForNow

      Hi, I have a console application that spawns a childprocess I am initially able to get the MainFrame Window in the console app thru EnumThreadWindows Later I create a modeless Dialog in the childprocess for which I would like the to get the HWND handle I am running this code (both apps) under the Visual Studio debugger So I can see when the child process creates the modeless dialogbox I then step thru (under VS debugger) both GetWindow(MainFrame,GW_CHILD) and EnumChildWindows and neither API return anything

      B Offline
      B Offline
      Bram van Kampen
      wrote on last edited by
      #2

      What on Earth are you trying to Achieve! Writing a Console Program trying to spawn an MFC Wnd App is not really possible, or desirable! The only practical way this is possible is by the Console Program calling the Standard 'C' 'system(...)' function to launch the Windows App. If you are looking for tooling to restart a misbehaving Windows Program, you came to the right door. I have just that. The actual code is proprietary, but I can explain how it works. Regards, Bram. :)

      Bram van Kampen

      F 1 Reply Last reply
      0
      • B Bram van Kampen

        What on Earth are you trying to Achieve! Writing a Console Program trying to spawn an MFC Wnd App is not really possible, or desirable! The only practical way this is possible is by the Console Program calling the Standard 'C' 'system(...)' function to launch the Windows App. If you are looking for tooling to restart a misbehaving Windows Program, you came to the right door. I have just that. The actual code is proprietary, but I can explain how it works. Regards, Bram. :)

        Bram van Kampen

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        First of I apologize maybe I should spent more time looking up critical section As all it is thread synchronization I am a MainFrame assembler programmer by trade and was trying to learn new technology I picked windows I wrote a front end for this C console program originally the code was C then I re-wrote it in MFC C++ I am sure a more experienced C++ programmer could have done a better job. But this was my way of learning I created the Windows MFC C++ program with CreateProcess

        L 1 Reply Last reply
        0
        • F ForNow

          Hi, I have a console application that spawns a childprocess I am initially able to get the MainFrame Window in the console app thru EnumThreadWindows Later I create a modeless Dialog in the childprocess for which I would like the to get the HWND handle I am running this code (both apps) under the Visual Studio debugger So I can see when the child process creates the modeless dialogbox I then step thru (under VS debugger) both GetWindow(MainFrame,GW_CHILD) and EnumChildWindows and neither API return anything

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Without sight of your code it is anyone's guess what you are doing wrong.

          1 Reply Last reply
          0
          • F ForNow

            First of I apologize maybe I should spent more time looking up critical section As all it is thread synchronization I am a MainFrame assembler programmer by trade and was trying to learn new technology I picked windows I wrote a front end for this C console program originally the code was C then I re-wrote it in MFC C++ I am sure a more experienced C++ programmer could have done a better job. But this was my way of learning I created the Windows MFC C++ program with CreateProcess

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            ForNow wrote:

            I ended up having the debugging modeless dialog box HWND being returned to me from the SendMessage to the main window as both LRESULT and HWND are both 64 bits wide running 64 bit mode as I don't want the console program to sit around and wait for a response (and hold it up) I do a PostMessage from the console program Thanks

            I (like Bram) am confused as to what you are trying to do here. Or indeed what your point is of using a console application to launch a Windows application, to launch a modeless dialog.

            1 Reply Last reply
            0
            • F ForNow

              Hi, I have a console application that spawns a childprocess I am initially able to get the MainFrame Window in the console app thru EnumThreadWindows Later I create a modeless Dialog in the childprocess for which I would like the to get the HWND handle I am running this code (both apps) under the Visual Studio debugger So I can see when the child process creates the modeless dialogbox I then step thru (under VS debugger) both GetWindow(MainFrame,GW_CHILD) and EnumChildWindows and neither API return anything

              L Offline
              L Offline
              leon de boer
              wrote on last edited by
              #6

              I have three suggestion/comments: 1.) You said quote: "Later I create a modeless Dialog in the childprocess for which I would like the to get the HWND handle." Doesn't matter which create method you use you get the handle back right then ... so why don't you hold it?????? 2.) Like others I wonder why you are using MFC at all which will be problematic why would you not just use the WIN32 API. 3.) If GetWindow(MainFrame,GW_CHILD) and EnumChildWindows are returning false the your created window isn't parented to the window at all. It's most likely parented to the desktop and again go back to number 1 above show us the how you created the modeless dialog and check you gave it a parent. The key point here is a show use the lines of code around the modeless dialog creation call.

              In vino veritas

              F 1 Reply Last reply
              0
              • L leon de boer

                I have three suggestion/comments: 1.) You said quote: "Later I create a modeless Dialog in the childprocess for which I would like the to get the HWND handle." Doesn't matter which create method you use you get the handle back right then ... so why don't you hold it?????? 2.) Like others I wonder why you are using MFC at all which will be problematic why would you not just use the WIN32 API. 3.) If GetWindow(MainFrame,GW_CHILD) and EnumChildWindows are returning false the your created window isn't parented to the window at all. It's most likely parented to the desktop and again go back to number 1 above show us the how you created the modeless dialog and check you gave it a parent. The key point here is a show use the lines of code around the modeless dialog creation call.

                In vino veritas

                F Offline
                F Offline
                ForNow
                wrote on last edited by
                #7

                I did use GetWindow and got NULL. I was able to get Window Handle by doing a SendMessage to the other app as the return Value is From the other Window App (not Windows like PostMessage) I returned the dialog window in LRESULT Thanks

                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