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 ignore Window activate ?

How to ignore Window activate ?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 2 Posters 5 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.
  • R Offline
    R Offline
    rrrado
    wrote on last edited by
    #1

    My application creates modeless dialog (in separate thread). The problem is that after creating of window system activates it and will put it foreground. How to create it without setting it active ? How to restrict this window so that could be activated only by user ? I tried to do this :

    OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
    {
    if (nState == WA_ACTIVE)
    if (pWndOther)
    ::SetActiveWindow(pWndOther->m_hWnd);
    }

    But pWndOther is always NULL. Any ideas ? Thank you


    rrrado

    I 2 Replies Last reply
    0
    • R rrrado

      My application creates modeless dialog (in separate thread). The problem is that after creating of window system activates it and will put it foreground. How to create it without setting it active ? How to restrict this window so that could be activated only by user ? I tried to do this :

      OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
      {
      if (nState == WA_ACTIVE)
      if (pWndOther)
      ::SetActiveWindow(pWndOther->m_hWnd);
      }

      But pWndOther is always NULL. Any ideas ? Thank you


      rrrado

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

      First create the Dialog that you want with the resource editor. BE CAREFULL YOU MUST REMOVE THE "Visible" style from ("More Styles") in the dialog properties. OR YOU WILL GET A CRASH.!! Then you must Create a new Class Inherited from CDialog. Lets say CUpdateDialog :: public CDialog with a resource template.. (the dialog editor); then Create a variable (Object) of the new class. Lest say CUpdateDlg m_UpdateDlg; then go .... m_UpdateDlg.Create (IDD_UPDATEDIALOG,this); // This will actuallly do the trick! m_UpdateDlg.ShowWindow (SW_SHOWNOACTIVATE);

      1 Reply Last reply
      0
      • R rrrado

        My application creates modeless dialog (in separate thread). The problem is that after creating of window system activates it and will put it foreground. How to create it without setting it active ? How to restrict this window so that could be activated only by user ? I tried to do this :

        OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
        {
        if (nState == WA_ACTIVE)
        if (pWndOther)
        ::SetActiveWindow(pWndOther->m_hWnd);
        }

        But pWndOther is always NULL. Any ideas ? Thank you


        rrrado

        I Offline
        I Offline
        imsniper
        wrote on last edited by
        #3

        Sorry about previews post... You must also disable the "Desabled" style from "More Styles" in the resource editor and use this m_UpdateDlg.ShowWindow (SW_SHOWNA); m_UpdateDlg.ModifyStyle (WS_DISABLED,NULL,0); instead of m_UpdateDlg.ShowWindow (SW_SHOWNOACTIVATE);

        R 1 Reply Last reply
        0
        • I imsniper

          Sorry about previews post... You must also disable the "Desabled" style from "More Styles" in the resource editor and use this m_UpdateDlg.ShowWindow (SW_SHOWNA); m_UpdateDlg.ModifyStyle (WS_DISABLED,NULL,0); instead of m_UpdateDlg.ShowWindow (SW_SHOWNOACTIVATE);

          R Offline
          R Offline
          rrrado
          wrote on last edited by
          #4

          Thank you very much ! :rose: I also have idea about DISABLED, but i didn't try it, i thought it won't work :) BTW your solution works so that it won't steal focus, but anyway will create window in z-order higher than parent window (althought it is created like child of desktop window). So I improved that to this :

          	m\_dlg.Create(IDD\_MANUAL,CWnd::FromHandle(GetDesktopWindow()));
          	::SetWindowPos(m\_dlg.m\_hWnd,AfxGetMainWnd()->m\_hWnd,0,0,0,0,SWP\_NOMOVE|SWP\_NOACTIVATE|SWP\_NOSIZE|SWP\_SHOWWINDOW);
          	m\_dlg.ModifyStyle(WS\_DISABLED,0);
          

          thank you again


          rrrado

          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