42 using namespace vlMFC;
47 CString MFCWindow::mClassName;
84 dispatchDestroyEvent();
87 int MFCWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
89 if (CWnd::OnCreate(lpCreateStruct) == -1)
99 if (mClassName.IsEmpty())
100 mClassName = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS, LoadCursor(
NULL, IDC_ARROW),
NULL, LoadIcon(
NULL, IDI_WINLOGO));
102 CreateEx(WS_EX_APPWINDOW|WS_EX_ACCEPTFILES,
103 mClassName, L
"MFCWindow",
104 (parent?WS_CHILD:WS_OVERLAPPEDWINDOW) | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
106 parent?parent->m_hWnd:
NULL, NULL, NULL);
108 return initWin32GLContext(share_context?share_context->
hglrc():
NULL, title, fmt, x, y, width, height);
111 void MFCWindow::destroyGLContext()
118 if ( wglDeleteContext(mHGLRC) == FALSE )
120 MessageBox( L
"OpenGL context creation failed.\n" 121 L
"The handle either doesn't specify a valid context or the context is being used by another thread.", L
"MFCWindow::destroyGLContext() error!", MB_OK);
134 void MFCWindow::OnDestroy()
136 dispatchDestroyEvent();
140 void MFCWindow::OnPaint()
142 if (hwnd() && hdc() && hglrc())
143 dispatchUpdateEvent();
159 void MFCWindow::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
161 unsigned short unicode_out = 0;
164 dispatchKeyPressEvent(unicode_out, key_out);
167 void MFCWindow::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
169 unsigned short unicode_out = 0;
172 dispatchKeyReleaseEvent(unicode_out, key_out);
175 void MFCWindow::countAndCapture()
178 if (mMouseDownCount == 1)
179 ::SetCapture(hwnd());
182 void MFCWindow::countAndRelease()
185 if (mMouseDownCount <= 0)
192 void MFCWindow::OnLButtonDblClk(UINT nFlags, CPoint point)
195 dispatchMouseDownEvent(
LeftButton, point.x, point.y );
198 void MFCWindow::OnLButtonDown(UINT nFlags, CPoint point)
201 dispatchMouseDownEvent(
LeftButton, point.x, point.y );
204 void MFCWindow::OnLButtonUp(UINT nFlags, CPoint point)
207 dispatchMouseUpEvent(
LeftButton, point.x, point.y );
210 void MFCWindow::OnMButtonDblClk(UINT nFlags, CPoint point)
213 dispatchMouseDownEvent(
MiddleButton, point.x, point.y );
216 void MFCWindow::OnMButtonDown(UINT nFlags, CPoint point)
219 dispatchMouseDownEvent(
MiddleButton, point.x, point.y );
222 void MFCWindow::OnMButtonUp(UINT nFlags, CPoint point)
228 void MFCWindow::OnMouseMove(UINT nFlags, CPoint point)
230 dispatchMouseMoveEvent( point.x, point.y );
233 BOOL MFCWindow::OnMouseWheel(UINT nFlags,
short zDelta, CPoint pt)
235 dispatchMouseWheelEvent (zDelta/120);
239 void MFCWindow::OnRButtonDblClk(UINT nFlags, CPoint point)
242 dispatchMouseDownEvent(
RightButton, point.x, point.y );
245 void MFCWindow::OnRButtonDown(UINT nFlags, CPoint point)
248 dispatchMouseDownEvent(
RightButton, point.x, point.y );
251 void MFCWindow::OnRButtonUp(UINT nFlags, CPoint point)
254 dispatchMouseUpEvent(
RightButton, point.x, point.y );
257 void MFCWindow::OnDropFiles(HDROP hDrop)
259 int count = DragQueryFile(hDrop, 0xFFFFFFFF, 0, 0);
260 const int char_count = 1024;
261 std::vector<String> files;
262 for(
int i=0; i<count; ++i)
264 wchar_t file_path[char_count];
265 memset(file_path, 0, char_count);
266 DragQueryFile(hDrop,i,file_path,char_count);
267 files.push_back(file_path);
269 dispatchFileDroppedEvent(files);
272 void MFCWindow::OnSize (UINT nType,
int cx,
int cy)
274 CWnd::OnSize(nType, cx, cy);
276 if (0 >= cx || 0 >= cy || nType == SIZE_MINIMIZED)
279 framebuffer()->setWidth(cx);
280 framebuffer()->setHeight(cy);
281 dispatchResizeEvent(cx, cy);
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Visualization Library main namespace.
The OpenGLContextFormat class encapsulates the settings of an OpenGL rendering context.
VLWIN32_EXPORT void translateKeyEvent(WPARAM wParam, LPARAM lParam, unsigned short &unicode_out, vl::EKey &key_out)
The MFC bindings namespace.
The MFCWindow class is an MFC CWnd with the functionalities of a Win32Context.