Adding click/double-click events to static group box controls
Posted
by omatai
on Stack Overflow
See other posts from Stack Overflow
or by omatai
Published on 2010-03-29T22:37:50Z
Indexed on
2010/03/29
23:23 UTC
Read the original article
Hit count: 687
Having realised my own reasons were way too dubious, I've now gone about this a different way. But I'm still curious...
For reasons of nostalgia, familiarity and laziness, I'm coding a UI with MFC. For dubious reasons (as if those were not enough), I wanted to add a (double-)click event to a group box. Naturally, the group box contains things - in fact, it contains another static item, to which I can successfully add a (double-)click event handler.
Is there any reason I cannot get an event handler to work for clicks on my group box the same way I can do that for the simple text static item? No amount of clicking on, in or near the control fires the event.
Note - I've read through http://www.codeproject.com/KB/static/staticctrl_tut.aspx and tried responding to both ON_STN_... events and ON_BN_... messages, setting the notify style (BS_NOTIFY appears in the rc file)... and still I'm missing something - what is it? Is it even possible? Most of what I've googled suggests it is... but without clear answers for C++/MFC.
Since first posting this question, I've found reference to a WM_NCHITTEST message, and hints that you have to create a handler for this message to override the group box default behaviour of responding with HT_TRANSPARENT... despite having its transparent property in ClassWizard set to false. Hmmm. Can anyone confirm that this is indeed the key?
© Stack Overflow or respective owner