Focus & Always-On-Top :: MFC

This is a discussion on Focus & Always-On-Top :: MFC within the Windows Programming forums, part of the Platform Specific Boards category; Hi. I have question questions that are related: focus and always-on-top. Focus: I have a modal dialog box with an ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    Focus & Always-On-Top :: MFC

    Hi.

    I have question questions that are related: focus and always-on-top.

    Focus: I have a modal dialog box with an edit box. When the program first initialized the dialog box, I would like the the edit box to be in focus. Okay, there is no problem. The solution is to set the edit box to focus on InitDialog(). I am having a problem setting the edit box focus if the program is no longer in focus and then regains focus. I overloaded OnSetFocus in the dialog box and called SetFocus() for the edit box, but that does not work. For some reason, OnSetFocus() never gets called even if the program loses focus and then focuses again. What do I have to overload to catch the program regaining focus so I can focus the edit box?

    My second question is about always-on-top. I would like to add a feature to have the program always be on top. Is there a flag I need to add in main frame?

    Thanks,
    Kuphryn

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Overload WM_ACTIVATE in the dialog and call SetFocus () in it.

    For moving the window in Z order see SetWindowPos () and
    wndTopMost flag.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Hey, thanks!

    Your solution works perfectly. Thanks again.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing focus in an MFC Application
    By rangalo in forum Windows Programming
    Replies: 2
    Last Post: 06-20-2005, 06:21 AM
  2. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  3. Release MFC Programs & Dynamic MFC DLL :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2002, 06:42 PM
  4. Beginning MFC (Prosise) Part III - Now What? :: C++
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 03-03-2002, 05:58 PM
  5. Stack functions as arrays instead of node pointers
    By sballew in forum C Programming
    Replies: 8
    Last Post: 12-04-2001, 10:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21