右键单击MDI子窗口标题栏 [英] Right click on MDI child window title bar

查看:89
本文介绍了右键单击MDI子窗口标题栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用MDI子窗口来创建供其他应用程序使用的GUI对象.窗口标题文本被视为对象的一部分,并存储在文档中. MFC框架使用文档文件名来覆盖标题文本,但是我设法通过使用OnDocumentEvent()来还原标题文本.现在,我希望能够运行一个对话框来编辑某些鼠标操作(例如在窗口标题栏上双击或右键单击.我尝试了OnNcRButtonDown(),但是它从未被调用,除了单击工作区和窗口边框之间的窄带(2或3像素)之外.感谢您提供有关如何诱使标题栏本身单击的任何想法.

如果相关,我将在Windows 7下使用VS 2010 Pro 4.0进行开发.

解决方案

这应该可以帮助您:
WM_NCHITTEST [
毫无疑问,这对于熟悉MFC应用程序的人来说都是显而易见的东西,但是如果有人遇到相关问题,我将在这里说明:

您的MDI视图窗口不是主框架的子窗口,而是中间框架窗口的子窗口.通常通过在应用程序InitInstance()中调用AddDocTemplate并传递新的CMultiDocTemplate来动态创建此框架窗口. CMultiDocTemplate的构造函数的第三个参数定义MDI子视图框架窗口的类.标准的是CMDIChildWnd,它在大多数情况下都可以工作,但是如果您想做任何花哨的事情,要处理子帧的消息,您需要从CMDIChildWnd派生自己的类,并将其传递给CMultiDocTemplate的构造函数. /blockquote>

My app uses MDI child windows to create GUI objects that are used by another app. The window title texts are considered part of the object and are stored in the document. The MFC framework ovewrites the title text with the document file name, but I managed to foil that by using OnDocumentEvent() to restore the proper text. Now I want to be able to run a dialog to edit the text on some mouse action, e.g. double-click or right-click, on the window title bar. I tried OnNcRButtonDown() but it never gets called, except for clicks on the narrow (2 or 3 pixels) strip between the client area and the window border. Grateful for any ideas on how to trap clicks on the title bar itself.

In case it''s relevant, I''m developing with VS 2010 Pro 4.0 under Windows 7.

解决方案

This should help you out:
WM_NCHITTEST[^]

You should call the default implementation/windows procedure and inspect the result

Regards
Espen Harlinn


Thanks for that hint, Espen, which ultimately led me to the answer...

I tried what you said, which didn''t really get me anywhere, as the result of the base class call to OnNcHitTest() returned a value of 18 = HTBORDER = "In the border of a window that does not have a sizing border". This just confirmed what I knew already. However, it did give me the idea of using Spy++, which showed plenty of WM_NCHITTEST messages, only they were being sent to the _parent_ of my view window.

This is no doubt all pretty obvious stuff to people who are familiar with MFC apps, but I''ll spell it out here in case anyone else has a related problem:

Your MDI view window is not a child of the main frame, but of an intermediate frame window. This frame window is created dynamically, typically by a call in the app InitInstance() to AddDocTemplate, passing a new CMultiDocTemplate. The third argument to the constructor of CMultiDocTemplate defines the class for your MDI child view frame windows. The standard one is CMDIChildWnd, which works in most cases, but if you want to do any fancy stuff, to process the messages for the child frame you need to derive your own class from CMDIChildWnd and pass that instead to the constructor of CMultiDocTemplate.


这篇关于右键单击MDI子窗口标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆