1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| HWND WGL_CreateWindow (IN DWORD dwExStyle, IN DWORD dwStyle,
IN long x, IN long y, IN long nWidth, IN long nHeight,
IN HWND hWndParent, IN HMENU CtrlID) { // dllexport
HWND hWnd = 0;
HWND hTemp = CreateWindowEx(dwExStyle, GLImageClassName, $NULL, dwStyle, 0, 0, 0, 0, hWndParent, CtrlID, zInstance(), NULL);
if (hTemp) {
HDC glDC = (HDC) ZI_GetProperty(hTemp, ZI_GLDC);
HGLRC glRC = (HGLRC) ZI_GetProperty(hTemp, ZI_GLRC);
PIXELFORMATDESCRIPTOR pfd = { 0 };
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_SUPPORT_GDI | PFD_SUPPORT_COMPOSITION;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cAlphaBits = 1;
pfd.cDepthBits = 24; // 16;
pfd.iLayerType = PFD_MAIN_PLANE;
InitMultisample(glDC, &pfd);
if (gI.arbMultisampleFormat) {
WCHAR szWindowClass[] = L"GL_CHARTCTRL";
WNDCLASSEX wcx = {0};
wcx.cbSize = sizeof(wcx);
long IsInitialized = GetClassInfoEx(zInstance(), szWindowClass, &wcx);
if (!IsInitialized) {
wcx.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
wcx.lpfnWndProc = GL_WindowProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = Extend_cbWndExtra * sizeof(LONG_PTR);
wcx.hInstance = zInstance();
wcx.hIcon = NULL;
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground = NULL;
wcx.lpszMenuName = NULL;
wcx.lpszClassName = szWindowClass;
wcx.hIconSm = NULL;
if (RegisterClassEx(&wcx)) { IsInitialized = TRUE; }
}
if (IsInitialized) {
hWnd = CreateWindowEx(dwExStyle,
szWindowClass,// Make it an OpenGL control
$NULL, // Currently not used
dwStyle, // window style
x, // initial x position
y, // initial y position
nWidth, // Calculate Window Width
nHeight, // Calculate Window Height
hWndParent, // parent window handle
CtrlID, // ControlID
zInstance(), // program instance handle
NULL); // creation parameters
if (hWnd) {
glDC = GetDC(hWnd);
if (SetPixelFormat(glDC, gI.arbMultisampleFormat, &pfd)) {
DestroyWindow(hTemp);
glRC = wglCreateContext(glDC);
wglMakeCurrent(glDC, glRC);
ZI_SetProperty(hWnd, ZI_GLDC, (LONG_PTR) glDC);
ZI_SetProperty(hWnd, ZI_GLRC, (LONG_PTR) glRC);
} else {
DestroyWindow(hWnd);
MoveWindow(hTemp, x, y, nWidth, nHeight, 0);
hWnd = hTemp;
}
}
}
} else {
MoveWindow(hTemp, x, y, nWidth, nHeight, 0);
hWnd = hTemp;
}
}
return hWnd;
} |
Partager