15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


How to add a pop-up menu to the MDIChildWnd's title bar

Srinivas Vanga -- srini@concentra.com
Friday, September 06, 1996


Environment : VC++ 4.2, Win 95

Hi there,

I want to add a pop-up menu (on the R-click) to the Document frame
window's (MDIChildWnd) Title bar area. 

my problem here is catching the event. I've tried to add R-click handler 
on the client frame window class (derived class from CMDIChildWnd). Apparently, 
this handler is not getting called no matter where you click on the frame.

Any clues....

Thanks in advance

srinivas vanga
Concentra Corporation
srini@concentra.com
(617) 229-4684



 



CraigTT@ccmail01.PE-Nelson.COM
Saturday, September 07, 1996

[Mini-digest: 3 responses]

If you're clicking in the title bar, are you trying to get the
WM_NCRBUTTONDOWN message?  This is a nonclient area of the window.

Tim Craig

______________________________ Reply Separator _________________________________
Subject: How to add a pop-up menu to the MDIChildWnd's title bar
Author:  mfc-l@netcom.com at SMTPLINK-PEN
Date:    9/7/96 4:35 AM


Received: by ccmail from lax.PE-Nelson.COM 
>From owner-mfc-l@majordomo.netcom.com
X-Envelope-From: owner-mfc-l@majordomo.netcom.com
Received: from majordomo.netcom.com (listless.netcom.com) by lax.PE-Nelson.COM 
(5.65c/IDA/PE-Nelson)
    id AA03763; Sat, 7 Sep 1996 04:32:53 -0700
Received: by majordomo.netcom.com (8.7.5/8.7.3/(NETCOM MLS v1.01)) id WAA07964; 
Fri, 6 Sep 1996 22:53:26 -0700 (PDT)
Date: Fri, 6 Sep 1996 12:31:52 -0500
Message-Id: <9609061731.AA30180@wyndham.concentra.com> 
From: Srinivas Vanga 
To: mfc-l@netcom.com
Subject: How to add a pop-up menu to the MDIChildWnd's title bar 
Sender: owner-mfc-l@majordomo.netcom.com
Errors-To: owner-mfc-l@majordomo.netcom.com 
Precedence: bulk
Reply-To: mfc-l@netcom.com  
Environment : VC++ 4.2, Win 95
     
Hi there,
     
I want to add a pop-up menu (on the R-click) to the Document frame 
window's (MDIChildWnd) Title bar area. 
     
my problem here is catching the event. I've tried to add R-click handler 
on the client frame window class (derived class from CMDIChildWnd). Apparently, 
this handler is not getting called no matter where you click on the frame.
     
Any clues....
     
Thanks in advance
     
srinivas vanga
Concentra Corporation
srini@concentra.com
(617) 229-4684
     
     
-----From: Jim Leavitt 

Srinivas:
1)  Use class wizard to expand your message filter to "window"
2)  Handle the WM_NCRBUTTONDOWN message. 
3)  Check for nHitTest == HTCAPTION
sample...
void CChildFrame::OnNcRButtonDown(UINT nHitTest, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if (nHitTest == HTCAPTION)
		AfxMessageBox("Pop up Menu Now");
	// if you want to call the base class...
CMDIChildWnd::OnNcRButtonDown(nHitTest, point);

}
Looks like a good idea for my app too. 
Jim Leavitt
jimll@halcyon.com

-----From: Mike Blaszczak 

According to the documentation, the caption is a part of the non client
area of your window. (I don't know what you mean by a "click handler",
since there no "clicked" messages in Windows: there's just double-clicked
messages.  So, I'll assume you meant WM_RBUTTONDOWN.) As such, you won't
get a WM_RBUTTONDOWN when somebody clicks on the caption. Instead, you'll
get a WM_NCRBUTTONDOWN message.

Since WM_NC messages aren't that popular, they're not directly supported
by ClassWizard.  You can add an ON_WM_NCRBUTTONDOWN() handler to your
message map, like this:

BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
   //{{AFX_MSG_MAP(CChildFrame)
      // NOTE - the ClassWizard will add and remove mapping macros here.
      //    DO NOT EDIT what you see in these blocks of generated code !
   //}}AFX_MSG_MAP
   ON_WM_NCRBUTTONDOWN()
END_MESSAGE_MAP()


and then, go and add a handler for it:

void CChildFrame::OnNcRButtonDown( UINT nHitTest, CPoint point )
{
   if (nHitTest == HTCAPTION)
      TRACE2("Somebody clicked IN THE CAPTION at (%d,%d)\n", point.x, point.y);
   else
      TRACE2("Somebody clicked out of the caption at (%d,%d)\n",
         point.x, point.y);
}

You'll have to add a declaration for this guy in your hader file, of course:

class CChildFrame : public CMDIChildWnd
{
   // ... other stuff ...
protected:
   //{{AFX_MSG(CChildFrame)
   // NOTE - the ClassWizard will add and remove member functions here.
   //    DO NOT EDIT what you see in these blocks of generated code!
   //}}AFX_MSG
   afx_msg void OnNcRButtonDown( UINT nHitTest, CPoint point );
   DECLARE_MESSAGE_MAP()
};

but that should do what you wanted.

.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.




rkumar@mail.cswl.com
Tuesday, September 10, 1996

     
     Provide WM_CONTEXTMENU a handler for ur frame windowand add the            
     following code to your CChildFrame::PreTranslateMessage
 
                
                if(pMsg->message == WM_NCRBUTTONDOWN)

                {
                        CRect rect;
                        GetClientRect(rect);
                        ClientToScreen(rect);

                        CPoint point = rect.TopLeft();
                        point.Offset(5, 5);
                        OnContextMenu(NULL, point);

                        return TRUE;
                }


The WM_NCRBUTTONDOWN message is posted when the user presses the right mouse 
button while the cursor is within the nonclient area of a window. 


______________________________ Reply Separator _________________________________
Subject: How to add a pop-up menu to the MDIChildWnd's title bar
Author:  mfc-l@netcom.com at internet
Date:    07/09/96 4:53 AM


     
Environment : VC++ 4.2, Win 95
     
Hi there,
     
I want to add a pop-up menu (on the R-click) to the Document frame 
window's (MDIChildWnd) Title bar area. 
     
my problem here is catching the event. I've tried to add R-click handler 
on the client frame window class (derived class from CMDIChildWnd). Apparently, 
this handler is not getting called no matter where you click on the frame.
     
Any clues....
     
Thanks in advance
     
srinivas vanga
Concentra Corporation
srini@concentra.com
(617) 229-4684
     
     
     
     





| Вернуться в корень Архива |