win32 fixes

This commit is contained in:
Vadim Lopatin 2014-03-05 15:32:59 +04:00
parent 79a18449cd
commit e3204070c2
3 changed files with 27 additions and 10 deletions

View File

@ -63,6 +63,13 @@ class ImageCache {
foreach (item; _map) foreach (item; _map)
item.cleanup(); 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 /// load and decode image from file to ColorDrawBuf, returns null if loading or decoding is failed

View File

@ -298,9 +298,13 @@ class Win32FontManager : FontManager {
/// initialize in constructor /// initialize in constructor
this() { this() {
Log.i("Creating Win32FontManager");
instance = this; instance = this;
init(); init();
} }
~this() {
Log.i("Destroying Win32FontManager");
}
/// initialize font manager by enumerating of system fonts /// initialize font manager by enumerating of system fonts
bool init() { bool init() {

View File

@ -132,7 +132,7 @@ int DLANGUIWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
{ {
Runtime.initialize(); Runtime.initialize();
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow); result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
Runtime.terminate(); //Runtime.terminate();
} }
catch (Throwable e) // catch any uncaught exceptions 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")); setFileLogger(std.stdio.File("ui.log", "w"));
setLogLevel(LogLevel.Trace); setLogLevel(LogLevel.Trace);
Log.d("myWinMain()");
string basePath = exePath(); string basePath = exePath();
Log.i("Current executable: ", exePath()); Log.i("Current executable: ", exePath());
string cmdline = fromStringz(lpCmdLine); string cmdline = fromStringz(lpCmdLine);
Log.i("Command line: ", cmdline); Log.i("Command line: ", cmdline);
string[] args = splitCmdLine(cmdline); string[] args = splitCmdLine(cmdline);
@ -185,19 +184,21 @@ int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
_cmdShow = iCmdShow; _cmdShow = iCmdShow;
_hInstance = hInstance; _hInstance = hInstance;
Log.d("Inside myWinMain");
string appName = "HelloWin";
Win32Platform platform = new Win32Platform(); Win32Platform platform = new Win32Platform();
if (!platform.registerWndClass()) { 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; return 0;
} }
Platform.setInstance(platform); Platform.setInstance(platform);
Win32FontManager fontMan = new Win32FontManager(); Win32FontManager fontMan = new Win32FontManager();
FontManager.instance = fontMan; 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: case WM_WINDOWPOSCHANGED:
{ {
WINDOWPOS * pos = cast(WINDOWPOS*)lParam; 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; return 0;
case WM_ERASEBKGND:
return 1;
case WM_PAINT: case WM_PAINT:
{ {
hdc = BeginPaint(hwnd, &ps); hdc = BeginPaint(hwnd, &ps);