捕捉ON_WM_LBUTTONDOWN事件 [英] catching ON_WM_LBUTTONDOWN event

查看:477
本文介绍了捕捉ON_WM_LBUTTONDOWN事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个窗口,可以在函数OnLButtonDown(UINT,CPoint)中捕获ON_WM_LBUTTONDOWN消息.在该窗口中,我创建一个CStatic控件.很好地单击该控件,将我带入函数OnLButtonDown().但是,如果我在静态控件中创建一个窗口(使用CreateWindow()函数),则无法捕获鼠标单击.有什么想法吗?感谢您的帮助!



Nalek说,新窗口捕获了点击.我明白.但是他也许不太了解这个问题.当我单击空的静态控件时,单击到达父级控件.但是,如果静态控件不为空(即创建了另一个窗口),则父窗口不会处理该单击.

In my application I have a window for which I catch the ON_WM_LBUTTONDOWN message in the function OnLButtonDown( UINT, CPoint). In that window I create a CStatic control. Clicking on that control quiet well brings me into the function OnLButtonDown(). But if I create a window (with CreateWindow() function ) in the static control I am unable to catch the mouse click. Is there any ideas? thanks for help!



Nalek said, that the the new window catches the click. I understand. But he maybe didn''t understand the problem well. when I click on empty static control the click is reached to parent one. But if the static control is not empty (i.e. there is another window created) the click is not handled by the parent window.

推荐答案

因为单击将被捕获新窗口.

如果在上一个版本中需要它,则应将其通知回来.

加法1:
我认为情况恰恰相反;)

如果单击静态控件(例如在标签上),则父控件是处理该单击的控件,因此将触发OnLButtonDown.

来自 msdn [ CreateWindow() [
Because the click will be catched in the new window.

If you want it in the previous one, you should notify it back.

Addition 1:
I think it was more on the opposite way ;)

If you click in a static control (for example on a label), is the parent the one that handles the click, so OnLButtonDown will be triggered.

From msdn[^]

[quote]
A static control normally takes no input and provides no output; however, it can notify its parent of mouse clicks if it''s created with SS_NOTIFY style.
[/quote]

But if you use CreateWindow (...), it depends a lot on which kind of CWnd derived are you creating, that the previous behaviour stays or not.
For instance. A button is CWnd derived class, if you create a button but don''t implement the OnButtonClick it may happens that the parent doesn''t execute the OnLButtonDown.

Take a look to CreateWindow ()[^]

Endly, if you provide a bit more info about what are you creating and some relevant code snippets, you will probably get a better / more concrete answer to your problem.


这篇关于捕捉ON_WM_LBUTTONDOWN事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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