SDI工程,手动创建CGisShowTreate类,继承CWnd.
参见http://topic.csdn.net/u/20080919/22/beede080-e5ba-4e6a-a337-c72667e2c2f3.html?seed=1350084183
http://topic.csdn.net/u/20080920/18/35469eac-3b72-4da3-8e24-7b45dfafc905.html
都没有解决问题.
只从CWnd继承,不从CView或是CFrameWnd继承.
显示的窗体(没有最大化时),是正常显示,但是最大化后,除开原来显示的区域,其他区域像是死机的显示.而且鼠标响应消息只能在那些死机区域内响应,正常显示的区域不能响应,望高手指教,分不够在给.上面两个帖子都没有想要的答案.已经两天没解决了.急.
CMainFrame类下的两个虚函数(其中m_wndView是CTestView声明的对象 CTestView m_wndView,CTestView是从classwizard中从generic CWnd继承过来)
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// let the view have first crack at the command
if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE; // otherwise, do default handling
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
} BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
} 两个消息映射
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create a view to occupy the client area of the frame
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
} if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
} if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
} // TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar); return 0;
} void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
// forward focus to the view window
m_wndView.SetFocus();
} CTestView类
class CTestView : public CWnd
{
// Construction
public:
CTestView();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestView)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL public:
virtual ~CTestView(); // Generated message map functions
protected:
//{{AFX_MSG(CTestView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
HDC m_WindowDC;
}; .cpp文件中
BEGIN_MESSAGE_MAP(CTestView, CWnd)
//{{AFX_MSG_MAP(CTestView)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
两个虚函数
BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class if (!CWnd::PreCreateWindow(cs))
return FALSE; cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); return TRUE;
} BOOL CTestView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class if (!CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))
return FALSE; return TRUE;
}
参见http://topic.csdn.net/u/20080919/22/beede080-e5ba-4e6a-a337-c72667e2c2f3.html?seed=1350084183
http://topic.csdn.net/u/20080920/18/35469eac-3b72-4da3-8e24-7b45dfafc905.html
都没有解决问题.
只从CWnd继承,不从CView或是CFrameWnd继承.
显示的窗体(没有最大化时),是正常显示,但是最大化后,除开原来显示的区域,其他区域像是死机的显示.而且鼠标响应消息只能在那些死机区域内响应,正常显示的区域不能响应,望高手指教,分不够在给.上面两个帖子都没有想要的答案.已经两天没解决了.急.
CMainFrame类下的两个虚函数(其中m_wndView是CTestView声明的对象 CTestView m_wndView,CTestView是从classwizard中从generic CWnd继承过来)
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// let the view have first crack at the command
if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE; // otherwise, do default handling
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
} BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
} 两个消息映射
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create a view to occupy the client area of the frame
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
} if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
} if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
} // TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar); return 0;
} void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
// forward focus to the view window
m_wndView.SetFocus();
} CTestView类
class CTestView : public CWnd
{
// Construction
public:
CTestView();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestView)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL public:
virtual ~CTestView(); // Generated message map functions
protected:
//{{AFX_MSG(CTestView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
HDC m_WindowDC;
}; .cpp文件中
BEGIN_MESSAGE_MAP(CTestView, CWnd)
//{{AFX_MSG_MAP(CTestView)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
两个虚函数
BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class if (!CWnd::PreCreateWindow(cs))
return FALSE; cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); return TRUE;
} BOOL CTestView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class if (!CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))
return FALSE; return TRUE;
}
解决方案 »
- 关于在头文件中声明为static的函数,在源文件中还需要加static吗
- 新学IOCP ,求证一事..
- com控件怎么样处理键盘消息,?
- 如何在内存中形成链表
- 怎么得不到网络游戏窗体的句柄(仅限技术讨论)?
- 一个com类成员变量的问题(可能知道的人感觉很简单)
- ADSL和2000高服
- 关于在VC++6.0使用 _outp,_inp函数的问题!
- 请问梅杰主板SY-7VCA的驱动在什么地方有的下啊!谢谢!
- 这里有没有程序员是自考生?
- 求助!!!串口问题!!!!!急用!!!
- only static const integral data members can be initialized within a class,,大家帮忙看看~!
CVIEW 在处理消息的时候是要和FRAME想联系的
没看到你的完整的代码和跟踪一下的,谁也不好说
如楼上兄弟说的, 很多虚函数CVIEW都有自己的处理,
处理办法就是:
还是从CVIEW 里面继承一个VIEW,然后把你那个CWND 贴在VIEW 上面是一样的
你说的办法我试过了,还是一样的效果.
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
参数有问题,导致执行后,只有部分区域能够响应鼠标点击消息CMainFrame类
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
} if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
} if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
} // TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndToolBar, CPoint(200,200)); return 0;
}BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0); return TRUE;
}BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// let the view have first crack at the command
if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// otherwise, do default handling
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
m_wndView.SetFocus();
// TODO: Add your message handler code here
}CTestView类
BOOL CTestView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
if (!CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))
return FALSE;
return TRUE;
}BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
return TRUE;
}void CTestView::OnShowWindow(BOOL bShow, UINT nStatus)
{
CWnd::OnShowWindow(bShow, nStatus);
}void CTestView::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
}void CTestView::OnPaint()
{
CPaintDC dc(this); // device context for painting
}
/////////////////////////////////////////////////////////////////////////////
// CTestViewmessage handler
void CTestView::OnLButtonDown(UINT nFlags, CPoint point)
{
AfxMessageBox("CGisShowTreate::OnLButtonDown");
CWnd::OnLButtonDown(nFlags, point);
}void CTestView::OnLButtonUp(UINT nFlags, CPoint point)
{
AfxMessageBox("CGisShowTreate::OnLButtonUp");
CWnd::OnLButtonUp(nFlags,point);
}