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. How to prevent window to get focus

How to prevent window to get focus

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelptutorial
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.
  • A Offline
    A Offline
    AnTri
    wrote on last edited by
    #1

    Hey, please help me. I've got a SDI-App with a non modal dialog. The dialogs only task is to choose parameter (e.g. in a listbox) for my application. After selecting an item in the listbox (on dialog) the focus should move to my a control (choosen by listbox) in my cformview(e.g. CEdit - Control). I handle the OnLvnItemChangedList message in my dialog. In this function I post a message (WM_SETFOCUS) to my (formview) window. But the focus returns immediately back to my dialog. When I set the focus to my mainwnd (by mouseclick) the focus is in the right control. But how can I set the focus to my mainfrm automatically? Thanx for your help

    I 1 Reply Last reply
    0
    • A AnTri

      Hey, please help me. I've got a SDI-App with a non modal dialog. The dialogs only task is to choose parameter (e.g. in a listbox) for my application. After selecting an item in the listbox (on dialog) the focus should move to my a control (choosen by listbox) in my cformview(e.g. CEdit - Control). I handle the OnLvnItemChangedList message in my dialog. In this function I post a message (WM_SETFOCUS) to my (formview) window. But the focus returns immediately back to my dialog. When I set the focus to my mainwnd (by mouseclick) the focus is in the right control. But how can I set the focus to my mainfrm automatically? Thanx for your help

      I Offline
      I Offline
      includeh10
      wrote on last edited by
      #2

      if u set focus to parent formview, the parent will set focus to its child which has focus before the parent gets focus automatically - so ur dialog gets focus back. in ur function - OnLvnItemChangedList - u should tell formview where to send focus. i.e. post a message to formview with wParam==control's ID, so in formview, u send focus to the control.

      A 1 Reply Last reply
      0
      • I includeh10

        if u set focus to parent formview, the parent will set focus to its child which has focus before the parent gets focus automatically - so ur dialog gets focus back. in ur function - OnLvnItemChangedList - u should tell formview where to send focus. i.e. post a message to formview with wParam==control's ID, so in formview, u send focus to the control.

        A Offline
        A Offline
        AnTri
        wrote on last edited by
        #3

        I tried your suggestion, but with partial success. When my dialog has the focus before I select an item on the listbox it works fine, but if the focus is on my formview or mainfrm and I select on item, the focus wents to my formview for a second and then switched back to my dialog...

        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