class CTFMForm : public CDialogImpl<CTFMForm>
{
public:
enum { IDD = IDD_TFM };
BOOL PreTranslateMessage(MSG* pMsg)
{
return CWindow::IsDialogMessage(pMsg);
}
BEGIN_MSG_MAP(CTFMForm)
MESSAGE_HANDLER (WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER (WM_DESTROY, OnDestroy )
END_MSG_MAP()
public:
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
return 0;
}
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
bHandled = FALSE;
return 0;
}
};
#include <atlscrl.h>
class CTFMView : public CScrollWindowImpl<CTFMView>
{
public:
DECLARE_WND_CLASS(NULL)
BOOL PreTranslateMessage(MSG* pMsg)
{
pMsg;
return FALSE;
}
void DoPaint(CDCHandle dc)
{
//TODO: Add your drawing code here
}
BEGIN_MSG_MAP(CTFMView)
MESSAGE_HANDLER (WM_CREATE, OnCreate )
MESSAGE_HANDLER (WM_DESTROY, OnDestroy)
MESSAGE_HANDLER (WM_SIZE, OnSize )
CHAIN_MSG_MAP (CScrollWindowImpl<CTFMView>)
END_MSG_MAP()
public:
CTFMForm m_Form;
CSize m_FormSize;
public:
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
m_Form.Create(m_hWnd);
CRect rc;
m_Form.GetClientRect (&rc);
m_FormSize.cx = rc.Width();
m_FormSize.cy = rc.Height();
SetScrollSize(m_FormSize.cx, m_FormSize.cy);
bHandled = FALSE;
return 0;
}
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
bHandled = FALSE;
return 0;
}
LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
{
CSize size;
CSize newsize;
size.cx = GET_X_LPARAM(lParam);
size.cy = GET_Y_LPARAM(lParam);
if (::IsWindow (m_Form))
{
if (size.cx>m_FormSize.cx)
{
newsize.cx = size.cx;
}
else
{
newsize.cx = m_FormSize.cx;
}
if (size.cy>m_FormSize.cy)
{
newsize.cy = size.cy;
}
else
{
newsize.cy = m_FormSize.cy;
}
m_Form.SetWindowPos (0,0,0,newsize.cx,newsize.cy,SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}
bHandled = FALSE;
return 0;
}
};