From e3204070c260b03222af41701b6e2682aaad68ac Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Wed, 5 Mar 2014 15:32:59 +0400 Subject: [PATCH] win32 fixes --- src/dlangui/graphics/images.d | 7 ++++++ src/dlangui/platforms/windows/win32fonts.d | 4 ++++ src/dlangui/platforms/windows/winapp.d | 26 +++++++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/dlangui/graphics/images.d b/src/dlangui/graphics/images.d index 9e745dae..96d446a0 100644 --- a/src/dlangui/graphics/images.d +++ b/src/dlangui/graphics/images.d @@ -63,6 +63,13 @@ class ImageCache { foreach (item; _map) item.cleanup(); } + + this() { + Log.i("Creating ImageCache"); + } + ~this() { + Log.i("Destroying ImageCache"); + } } /// load and decode image from file to ColorDrawBuf, returns null if loading or decoding is failed diff --git a/src/dlangui/platforms/windows/win32fonts.d b/src/dlangui/platforms/windows/win32fonts.d index cbf68667..835e877a 100644 --- a/src/dlangui/platforms/windows/win32fonts.d +++ b/src/dlangui/platforms/windows/win32fonts.d @@ -298,9 +298,13 @@ class Win32FontManager : FontManager { /// initialize in constructor this() { + Log.i("Creating Win32FontManager"); instance = this; init(); } + ~this() { + Log.i("Destroying Win32FontManager"); + } /// initialize font manager by enumerating of system fonts bool init() { diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index 673cb2b4..471af750 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -132,7 +132,7 @@ int DLANGUIWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, { Runtime.initialize(); result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow); - Runtime.terminate(); + //Runtime.terminate(); } catch (Throwable e) // catch any uncaught exceptions { @@ -174,10 +174,9 @@ int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int { setFileLogger(std.stdio.File("ui.log", "w")); setLogLevel(LogLevel.Trace); - + Log.d("myWinMain()"); string basePath = exePath(); Log.i("Current executable: ", exePath()); - string cmdline = fromStringz(lpCmdLine); Log.i("Command line: ", cmdline); string[] args = splitCmdLine(cmdline); @@ -185,19 +184,21 @@ int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int _cmdShow = iCmdShow; _hInstance = hInstance; - Log.d("Inside myWinMain"); - string appName = "HelloWin"; - Win32Platform platform = new Win32Platform(); if (!platform.registerWndClass()) { - MessageBoxA(null, "This program requires Windows NT!", appName.toStringz, MB_ICONERROR); + MessageBoxA(null, "This program requires Windows NT!", "DLANGUI App".toStringz, MB_ICONERROR); return 0; } Platform.setInstance(platform); + Win32FontManager fontMan = new Win32FontManager(); FontManager.instance = fontMan; - return UIAppMain(args); + + Log.i("Entering UIAppMain: ", args); + int result = UIAppMain(args); + Log.i("UIAppMain returned ", result); + return result; } @@ -224,10 +225,15 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_WINDOWPOSCHANGED: { WINDOWPOS * pos = cast(WINDOWPOS*)lParam; - window.onResize(pos.cx, pos.cy); + GetClientRect(hwnd, &rect); + int dx = rect.right - rect.left; + int dy = rect.bottom - rect.top; + //window.onResize(pos.cx, pos.cy); + window.onResize(dx, dy); } return 0; - + case WM_ERASEBKGND: + return 1; case WM_PAINT: { hdc = BeginPaint(hwnd, &ps);