2

I've inherited a project that presents users a set of tabs, each of which contains a view that displays multiple components. In some of these tabs, we want to prevent users from moving the components displayed in the tab.

We have an object that inherits from CMFCTabCtrl to manage our tabs, which contains a collection of CWnd objects that represent each of our tabs. We also have an object that manages the views associated with each of these tabs, and activates those views when the relevant tab is activated.

The components all share a base object which inherits from CWnd, which defines the various handlers for the messages defined in the inherited message map.

What would be the correct/best way to prevent a user from dragging those components around?

Thanks!

BobbyA
  • 2,090
  • 23
  • 41
  • It is not clear for me what you want to do! Do you want to disable the drag&drop Features inside CMFCTabCtrl? – xMRi Oct 01 '13 at 06:34
  • xMRi - I'm not sure? Sorry, I'm pretty new to MFC. I don't want to change the behavior of dragging and dropping the tabs themselves, if that's what you're referring to. In a given tab window there will be one or more windows (components). I don't want users to be able to modify the size or location of those windows after they're opened. – BobbyA Oct 01 '13 at 13:58
  • If you can imagine the new tab page in Chrome or Firefox, where you see various boxes that represent websites you've recently visited, that's sort of like my setup. When you navigate to that tab, you can drag those boxes around. I want to disable that behavior in my project. – BobbyA Oct 01 '13 at 14:01

3 Answers3

1

One solution is to remove the titlebar style from the component CWnds. Without a titlebar the user cannot drag the window.

Another approach is to handle the WM_NCHITEST message in the component CWnds. If you return appropriate values the user's mouse will not be recognized as on the titlebar when they click.

ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15
  • This is what I was looking for, thanks! I'll try this when I start developing the solution, and will mark it as answered if it works. – BobbyA Sep 30 '13 at 18:38
0

Moving of the components is not a feature of Windows that is turned on by default. The code for moving the components exists in your project. That code has to be disabled in those cases where you want it disabled.

I assume that by components you mean controls and some such, and not child windows, like in MDI type of applications.

Dialecticus
  • 16,400
  • 7
  • 43
  • 103
  • The ability to drag windows around is not turned on by default? This doesn't seem right. These components are CWND objects, if that makes things clearer. – BobbyA Sep 30 '13 at 16:22
0

Try and set CMFCTabCtrl::m_bActivateOnBtnUp to TRUE. This might deactive the Drag&Droip stuff.

xMRi
  • 14,982
  • 3
  • 26
  • 59