基于单文档的OCX控件,应用范围是WEB发布显示工业监控软件界面
class CActiveToolBar : public CToolBar { LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); public: BOOL Create(CWnd* pParentWnd); };
BOOL CActiveToolBar::Create(CWnd* pParentWnd) { if (!CToolBar::Create(pParentWnd) || !LoadToolBar(IDR_MAINFRAME)) return FALSE; SetBarStyle(GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED); return TRUE; }
LRESULT CActiveToolBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { MSG msg; msg.hwnd = m_hWnd; msg.message = message; msg.wParam = wParam; msg.lParam = lParam; GetCursorPos(&msg.pt); FilterToolTipMessage(&msg); return CToolBar::WindowProc(message,wParam,lParam); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_ToolBar.Create(this)) { TRACE0("Failed to create toolbar "); return -1; } return 0; }
void MyMiniDrawCtrl::OnDocumentNameChanged() { GetDocTemplate()->OpenDocumentFile(m_documentName); SetModifiedFlag(); }
MyMiniDrawCtrl::MyMiniDrawCtrl() { InitializeIIDs(&IID_DMyMiniDraw, &IID_DMyMiniDrawEvents); // TODO: Initialize your control's instance data here. SetInitialSize(200, 200); AddDocTemplate(new CActiveXDocTemplate( RUNTIME_CLASS(CMinidrawDoc), //改为你的文档类 RUNTIME_CLASS(CMainFrame), //改为你的框架类 RUNTIME_CLASS(CMinidrawView))); //改为你的视图类 }