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. Iterate through controls on Dialog Box

Iterate through controls on Dialog Box

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
4 Posts 3 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.
  • M Offline
    M Offline
    Mandar D Sahasrabuddhe
    wrote on last edited by
    #1

    Hi, I am doing GUI programming using Win32 SDK (no MFC). I have a dialog box with 2 text fields, 2 static (labels) and 2 buttons. I wish resize the dialolg box and move / resize the 6 controls on it. Can anyone suggest how to get handles to all the 6 child windows to do SetWindowPos for each? I have tried using GetWindow with GW_CHILD and GW_HWNDNEXT. However I can get only the text boxes on the dialog box. Moreover, I have noticed that the while loop to enumerate child windows goes into infinite loop. Please suggest some solution.

    4 L M 3 Replies Last reply
    0
    • M Mandar D Sahasrabuddhe

      Hi, I am doing GUI programming using Win32 SDK (no MFC). I have a dialog box with 2 text fields, 2 static (labels) and 2 buttons. I wish resize the dialolg box and move / resize the 6 controls on it. Can anyone suggest how to get handles to all the 6 child windows to do SetWindowPos for each? I have tried using GetWindow with GW_CHILD and GW_HWNDNEXT. However I can get only the text boxes on the dialog box. Moreover, I have noticed that the while loop to enumerate child windows goes into infinite loop. Please suggest some solution.

      4 Offline
      4 Offline
      4apai
      wrote on last edited by
      #2

      if u have command identifiers of each control you can use GetDlgItem to get handle. if u dont - then enumarate windows using FindWindow+FindWindowEx 4apai There're no impossible tasks. There're tasks that required infinite period of execution time.

      1 Reply Last reply
      0
      • M Mandar D Sahasrabuddhe

        Hi, I am doing GUI programming using Win32 SDK (no MFC). I have a dialog box with 2 text fields, 2 static (labels) and 2 buttons. I wish resize the dialolg box and move / resize the 6 controls on it. Can anyone suggest how to get handles to all the 6 child windows to do SetWindowPos for each? I have tried using GetWindow with GW_CHILD and GW_HWNDNEXT. However I can get only the text boxes on the dialog box. Moreover, I have noticed that the while loop to enumerate child windows goes into infinite loop. Please suggest some solution.

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

        What about EnumWindows and EnumChildWindows? regards

        1 Reply Last reply
        0
        • M Mandar D Sahasrabuddhe

          Hi, I am doing GUI programming using Win32 SDK (no MFC). I have a dialog box with 2 text fields, 2 static (labels) and 2 buttons. I wish resize the dialolg box and move / resize the 6 controls on it. Can anyone suggest how to get handles to all the 6 child windows to do SetWindowPos for each? I have tried using GetWindow with GW_CHILD and GW_HWNDNEXT. However I can get only the text boxes on the dialog box. Moreover, I have noticed that the while loop to enumerate child windows goes into infinite loop. Please suggest some solution.

          M Offline
          M Offline
          Mandar D Sahasrabuddhe
          wrote on last edited by
          #4

          Hi, Thanks for the replies. I finally managed to achieve the functionality using GetWindow itself. The problem was, I initially did a SetWindowPos immediately after acquiring the window handle to the child control. This changed the Z-order of the windows and because of which it went into infinite loop. I have now implemented following solution: 1. Collect all the child window handles in a container such as list 2. Iterate through the list applying the modifications to each of the window using the window handles. This iteration has to be done using reverse_iterator. I suspect that this is essential because the first child of the parent window is the control with highest tab index, or highest Z-order. So to maintain the tab order, one has to do reverse-iteration. [Kindly confirm :)] Rgds, Mandar Wish you all a Very Happy New Year!

          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