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. Window focus problems

Window focus problems

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
2 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.
  • P Offline
    P Offline
    paulb
    wrote on last edited by
    #1

    I have a dialog based app which is launching a process and then waiting for it to finish. The problem is that if I click on the parent window before the child process window displays then it seems to get the focus and is on top of the child window when it finally does display. How can I make it so that child window will always be displayed on top of the launching app's window? regardless of mouse clicks or anything else the user might do (I don't have access to the source code for the child process, so can't make any mods there)

    A 1 Reply Last reply
    0
    • P paulb

      I have a dialog based app which is launching a process and then waiting for it to finish. The problem is that if I click on the parent window before the child process window displays then it seems to get the focus and is on top of the child window when it finally does display. How can I make it so that child window will always be displayed on top of the launching app's window? regardless of mouse clicks or anything else the user might do (I don't have access to the source code for the child process, so can't make any mods there)

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      Make your child dialog as modeless and then add the following codes in your child dialog initDialog handler

      CRect rect;
      
      // get the current window size and position
      GetWindowRect( rect );
      
      // now change the size, position, and Z order 
      // of the window.
      ::SetWindowPos(
      	m\_hWnd ,        // handle to window
      	HWND\_TOPMOST,   // placement-order handle
      	rect.left,      // horizontal position
      	rect.top,       // vertical position
      	rect.Width(),	// width
      	rect.Height(),  // height
      	SWP\_SHOWWINDOW  // window-positioning options
      );
      

      It basically set your child windows on top most in the z-order of the windows. Hope this helps. Sonork 100.41263:Anthony_Yio

      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