Splitter window and formview
I have created an application where the main view is split, the left side being of type CFormView and the right being the original view. I chose the form view since I need a large area to place buttons and labels, and such things as a dialog bar I don't think would suffice.
My goal is to be able to handle the button messages in that view, so I can create a drag and drop environment from the form view to the regular view for drawing purposes. The problem, as many have discovered is that the button messages cannot be handled in the formview. Is there an alternate view that I can use to embed the buttons, or perhaps another implementation that would meet my requirements?
Thanks
[711 byte] By [
hjames5] at [2007-11-19 7:05:39]

# 3 Re: Splitter window and formview
I should be more specific, I would like to be able to handle mouse messages such as left button down and move so I can have the drag and drop capability. I added these handlers using the wizard to the formview class, but if I put a breakpoint in and debug, they don't get called when I click in the formview area of the window.
void CControlView::OnBnClickedTestbutton()
{
// TODO: Add your control notification handler code here
//((CButton *)(GetDlgItem(IDC_TESTBUTTON)))->SetState(false);
}
void CControlView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//CRect rect;
//for (int i=0; i < 1; i++) {
//GetItemRect(i, rect);
//if (rect.PtInRect(point)) {
PostMessage(WM_COMMAND, IDC_TESTBUTTON);
m_dragMode = TRUE;
m_point = point;
return;
//}
//}
CFormView::OnLButtonDown(nFlags, point);
}
void CControlView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_dragMode && abs(m_point.x-point.x)+abs(m_point.y-point.y)>=3) {
PostMessage(WM_COMMAND, ID_START_DRAG);
m_dragMode = FALSE;
}
CFormView::OnMouseMove(nFlags, point);
}
Here is the .h file for my formview:
#pragma once
// CControlView form view
class CControlView : public CFormView
{
DECLARE_DYNCREATE(CControlView)
protected:
CControlView(); // protected constructor used by dynamic creation
virtual ~CControlView();
public:
enum { IDD = IDD_CONTROLVIEW };
BOOL m_dragMode;
CPoint m_point;
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedTestbutton();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
};
# 6 Re: Splitter window and formview
Thanks for the example, it is very helpful. This is the functionality that I need, except that when I click on a button, I would like to drag a bitmap instead of the button (this I know how to do) and I should be able to drop it onto the other view of my split application. In the example, the button (or bitmap) can only be moved inside its own view.
What is the easiest way let the user drag over the entire application window, but only allow dropping in one of the views?
Thanks for your help thusfar