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]
# 1 Re: Splitter window and formview
what button messages are you talking about ?
kirants at 2007-11-11 0:28:37 >
# 2 Re: Splitter window and formview
you're not doing something right. the buttons can be absolutelly handled in a CFormView derived. post the project.
Alin at 2007-11-11 0:29: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);
};
hjames5 at 2007-11-11 0:30:38 >
# 4 Re: Splitter window and formview
attached is a very simple example on how to drag a button on a CFormView. You can pick up from here...
Alin at 2007-11-11 0:31:47 >
# 5 Re: Splitter window and formview
of course the handlers do not get called. they belong to the view, rather than the button. all this handlers should be implemeted in your CButton derived class.
Alin at 2007-11-11 0:32:46 >
# 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
hjames5 at 2007-11-11 0:33:46 >
# 7 Re: Splitter window and formview
Does anyone have a take on a good way to accomplish what I have discribed above? I am not sure how to restrict dragging to the app window only, and then to only allow for dropping of the bitmap in one of the views.

If anyone knows a relevant tutorial, I would appreciate a link. I have searched around but haven't found anything too similar to the functionality I am looking for.

Thanks
hjames5 at 2007-11-11 0:34:50 >