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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. button(visible&Enable) but CANNOT be pressed

button(visible&Enable) but CANNOT be pressed

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpvisual-studiocomjson
3 Posts 2 Posters 1 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.
  • F Offline
    F Offline
    fitatc
    wrote on last edited by
    #1

    :confused:My qustion is Why this happened??? if sibling window paint by Z-order according to MSDN doc, the button should not be painted after the dialog. http://msdn.microsoft.com/en-us/library/dd183426(VS.85).aspx[^] -------------------------------------------------------------- Do the follow simple step you will see the "magic" button: 1. Create MFC SDI project 2. At [resouce view], Add a dialog and set style child.(WS_CHILD) 3. Add this code to the *view.cpp to create to child window:

        #define BTN1 10101
        int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
        {
         if (CView::OnCreate(lpCreateStruct) == -1)
          return -1;
    
         // TODO:  ここに特定な作成コードを追加してください。
          m\_dlg.Create(CTestDlg::IDD, this);
         m\_dlg.ShowWindow(SW\_SHOW);
         RECT rect;
         rect.left = 10;
         rect.top = 100;
         rect.right = 110;
         rect.bottom = 125;
         m\_btn.Create(\_T("testBtn"), WS\_VISIBLE | BS\_PUSHBUTTON, rect, this, BTN1);
         return 0;
        }
    
       \* CTestDlg m\_dlg, CButton m\_btn is member of the CTestView
       \* Z-order can be checked either by Spy++ or GetWindow API
    

    You can fix the problem by add WS_CLIPSIBLINGS style of the button.

    m_btn.Create(_T("testBtn"), WS_VISIBLE | BS_PUSHBUTTON | WS_CLIPSIBLINGS, rect, this, BTN1);

    E 1 Reply Last reply
    0
    • F fitatc

      :confused:My qustion is Why this happened??? if sibling window paint by Z-order according to MSDN doc, the button should not be painted after the dialog. http://msdn.microsoft.com/en-us/library/dd183426(VS.85).aspx[^] -------------------------------------------------------------- Do the follow simple step you will see the "magic" button: 1. Create MFC SDI project 2. At [resouce view], Add a dialog and set style child.(WS_CHILD) 3. Add this code to the *view.cpp to create to child window:

          #define BTN1 10101
          int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
          {
           if (CView::OnCreate(lpCreateStruct) == -1)
            return -1;
      
           // TODO:  ここに特定な作成コードを追加してください。
            m\_dlg.Create(CTestDlg::IDD, this);
           m\_dlg.ShowWindow(SW\_SHOW);
           RECT rect;
           rect.left = 10;
           rect.top = 100;
           rect.right = 110;
           rect.bottom = 125;
           m\_btn.Create(\_T("testBtn"), WS\_VISIBLE | BS\_PUSHBUTTON, rect, this, BTN1);
           return 0;
          }
      
         \* CTestDlg m\_dlg, CButton m\_btn is member of the CTestView
         \* Z-order can be checked either by Spy++ or GetWindow API
      

      You can fix the problem by add WS_CLIPSIBLINGS style of the button.

      m_btn.Create(_T("testBtn"), WS_VISIBLE | BS_PUSHBUTTON | WS_CLIPSIBLINGS, rect, this, BTN1);

      E Offline
      E Offline
      Eric Haddan
      wrote on last edited by
      #2

      My guess is you should be creating the button in your m_dlg::OnCreate object, not in CTestView::OnCreate.

      F 1 Reply Last reply
      0
      • E Eric Haddan

        My guess is you should be creating the button in your m_dlg::OnCreate object, not in CTestView::OnCreate.

        F Offline
        F Offline
        fitatc
        wrote on last edited by
        #3

        thanks, Eric Haddan I use Button just to show the problem, it will be the same if two dialog created as child of CTestView The problem is: because sibling window paint in z-order(not as MSDN said), window in the lower order paint latter,makes window showed, but not active.

        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