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. One-click close inactive child modeless dialog

One-click close inactive child modeless dialog

Scheduled Pinned Locked Moved C / C++ / MFC
learningc++performance
1 Posts 1 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.
  • T Offline
    T Offline
    Tadeusz Westawic
    wrote on last edited by
    #1

    I am self-taught in C++ and this is as deep as I've ever been in messaging. I have a modeless parent dialog maintaining a typed ptr list of modeless child dialog pointers. The children are all of the same class and hold memory and file resources (sets of parts and subassembly populations). The parent modeless supervises set operations on the children: unary transforms such as rotations, and binary operations such as set intersection, etc. So the parent is usually holding a kind of focus on one or two of the child operands. I have been several days now, learning different ways that the parent dialog can crash via a null position pointer in the collection class operations, or crash via a pointer to a deleted child. I'm not crying about it, I needed the knowlege, anyway. At this point my code no longer crashes but I have to perform two mouse clicks to close an inactive child; first click activates and second click closes ("close" means user clicked the X-button in the menu bar). The activation click causes the parent to lose its hold on current operands. Here are my event captures:

    int CPop::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
    {
    // If user moused sys menu bar, let OnSysCommand() handle it.

    if(nHitTest != HTSYSMENU)
    	{
    	GetParent()->PostMessageW(WMU\_POP\_TO\_POPMAN\_CHILD\_M\_ACTIVE, (WPARAM)0, m\_ptoken);
    	}
    //	Don't call base.
    //return CDialog::OnMouseActivate(pDesktopWnd, MY\_nHitTest, message);
    
    //	Tell Wnd to ignore MA message.
    return MA\_ACTIVATEANDEAT;
    }
    

    void CPop::OnSysCommand(UINT nID, LPARAM lParam)
    {
    // The one and only way to close a child Pop without closing parent.

    if((0xfff0 & nID) == SC\_CLOSE)
    	{
    	OnClose();
    	}
    else
    	{
    	GetParent()->PostMessageW(WMU\_POP\_TO\_POPMAN\_CHILD\_M\_ACTIVE, (WPARAM)0, m\_ptoken);
    	//	Don't call base.
    	//CDialog::OnSysCommand(nID, lParam);
    	}
    }
    

    I saw a #define HTCLOSE in winuser but it is not listed in the docs for OnMouseActivate(). Of course I tried it but it is unreliable. Child acivation causes the parent to lose "currency" of previously activated children, a real pia. I would like to know a method for one-click closing an inactive child. Just point me to an article if there is one.

    Tadeusz Westawic Sum quid sum.

    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