diff --git a/dlangui.sln b/dlangui.sln
index 4858cd93..7cd6439d 100644
--- a/dlangui.sln
+++ b/dlangui.sln
@@ -1,7 +1,14 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "dlangui", "dlangui.visualdproj", "{C86D169D-B8C0-4947-8B9D-84F656A87F4C}"
+Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "dlangui", "dlanguilib.visualdproj", "{5FF17402-9997-4D0E-8068-6D84B8769D98}"
+EndProject
+Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "example1", "examples\example1\example1.visualdproj", "{68C78CC1-6176-4C60-B4B6-520475C26D23}"
+ ProjectSection(ProjectDependencies) = postProject
+ {5FF17402-9997-4D0E-8068-6D84B8769D98} = {5FF17402-9997-4D0E-8068-6D84B8769D98}
+ EndProjectSection
+EndProject
+Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "example2", "examples\example2\example2.visualdproj", "{4B9651D1-BF43-47BD-9FA4-B1DAF9E7197D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -9,10 +16,18 @@ Global
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {C86D169D-B8C0-4947-8B9D-84F656A87F4C}.Debug|Win32.ActiveCfg = Debug|Win32
- {C86D169D-B8C0-4947-8B9D-84F656A87F4C}.Debug|Win32.Build.0 = Debug|Win32
- {C86D169D-B8C0-4947-8B9D-84F656A87F4C}.Release|Win32.ActiveCfg = Release|Win32
- {C86D169D-B8C0-4947-8B9D-84F656A87F4C}.Release|Win32.Build.0 = Release|Win32
+ {5FF17402-9997-4D0E-8068-6D84B8769D98}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5FF17402-9997-4D0E-8068-6D84B8769D98}.Debug|Win32.Build.0 = Debug|Win32
+ {5FF17402-9997-4D0E-8068-6D84B8769D98}.Release|Win32.ActiveCfg = Release|Win32
+ {5FF17402-9997-4D0E-8068-6D84B8769D98}.Release|Win32.Build.0 = Release|Win32
+ {68C78CC1-6176-4C60-B4B6-520475C26D23}.Debug|Win32.ActiveCfg = Debug|Win32
+ {68C78CC1-6176-4C60-B4B6-520475C26D23}.Debug|Win32.Build.0 = Debug|Win32
+ {68C78CC1-6176-4C60-B4B6-520475C26D23}.Release|Win32.ActiveCfg = Release|Win32
+ {68C78CC1-6176-4C60-B4B6-520475C26D23}.Release|Win32.Build.0 = Release|Win32
+ {4B9651D1-BF43-47BD-9FA4-B1DAF9E7197D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4B9651D1-BF43-47BD-9FA4-B1DAF9E7197D}.Debug|Win32.Build.0 = Debug|Win32
+ {4B9651D1-BF43-47BD-9FA4-B1DAF9E7197D}.Release|Win32.ActiveCfg = Release|Win32
+ {4B9651D1-BF43-47BD-9FA4-B1DAF9E7197D}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/dlangui.visualdproj b/dlanguilib.visualdproj
similarity index 93%
rename from dlangui.visualdproj
rename to dlanguilib.visualdproj
index a577e04a..3422d465 100644
--- a/dlangui.visualdproj
+++ b/dlanguilib.visualdproj
@@ -1,9 +1,9 @@
- {C86D169D-B8C0-4947-8B9D-84F656A87F4C}
+ {5FF17402-9997-4D0E-8068-6D84B8769D98}
0
0
- 0
+ 1
2
0
0
@@ -42,7 +42,7 @@
0
0
0
- 2.043
+ 2
0
0
0
@@ -69,7 +69,7 @@
Unicode
0
0
- 0
+ 1
@@ -83,11 +83,11 @@
- ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib
- 3rdparty/libpng/lib
+
+
- $(OutDir)\$(ProjectName).exe
+ $(OutDir)\$(ProjectName).lib
1
@@ -97,8 +97,8 @@
0
0
- 0
- 2
+ 1
+ 0
0
0
0
@@ -160,7 +160,7 @@
0
0
-
+ Unicode
0
0
0
@@ -177,11 +177,11 @@
- ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib
+
- $(OutDir)\$(ProjectName).exe
+ $(OutDir)\$(ProjectName).lib
1
@@ -198,6 +198,7 @@
+
@@ -274,7 +275,5 @@
-
-
diff --git a/examples/example1/example1.visualdproj b/examples/example1/example1.visualdproj
new file mode 100644
index 00000000..6a6bd692
--- /dev/null
+++ b/examples/example1/example1.visualdproj
@@ -0,0 +1,194 @@
+
+ {68C78CC1-6176-4C60-B4B6-520475C26D23}
+
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ $(DMDInstallDir)windows\bin\dmd.exe
+ ../../src ../../3rdparty
+
+ $(ConfigurationName)
+ $(OutDir)
+
+
+ 0
+
+
+
+
+ 0
+
+
+ 1
+ $(IntDir)\$(TargetName).json
+ 0
+
+ 0
+ Unicode
+ 0
+ 0
+ 0
+
+
+
+ 0
+
+ 1
+ $(VisualDInstallDir)cv2pdb\cv2pdb.exe
+ 0
+ 0
+ 0
+
+
+
+ phobos.lib ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib dlangui.lib
+ ../../Debug ../../3rdparty/win32/lib
+
+
+ $(OutDir)\$(ProjectName).exe
+ 1
+
+
+
+ *.obj;*.cmd;*.build;*.json;*.dep
+
+
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2.043
+ 0
+ 0
+ 0
+ $(DMDInstallDir)windows\bin\dmd.exe
+
+
+ $(ConfigurationName)
+ $(OutDir)
+
+
+ 0
+
+
+
+
+ 0
+
+
+ 1
+ $(IntDir)\$(TargetName).json
+ 0
+
+ 0
+ Unicode
+ 0
+ 0
+ 0
+
+
+
+ 0
+
+ 0
+ $(VisualDInstallDir)cv2pdb\cv2pdb.exe
+ 0
+ 0
+ 0
+
+
+
+ ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib
+
+
+
+ $(OutDir)\$(ProjectName).exe
+ 1
+
+
+
+ *.obj;*.cmd;*.build;*.json;*.dep
+
+
+
+
+
diff --git a/examples/example1/winmain.d b/examples/example1/winmain.d
new file mode 100644
index 00000000..c9d8a504
--- /dev/null
+++ b/examples/example1/winmain.d
@@ -0,0 +1,66 @@
+module winmain;
+pragma(lib, "dlangui.lib");
+
+import dlangui.platforms.common.platform;
+import dlangui.widgets.widget;
+import dlangui.core.logger;
+import dlangui.graphics.fonts;
+import std.stdio;
+
+version(Windows) {
+ import win32.windows;
+ import dlangui.platforms.windows.winapp;
+ /// workaround for link issue when WinMain is located in library
+ extern (Windows)
+ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine, int nCmdShow)
+ {
+ return DLANGUIWinMain(hInstance, hPrevInstance,
+ lpCmdLine, nCmdShow);
+ }
+}
+
+class TestWidget : Widget {
+ public override void onDraw(DrawBuf buf) {
+ super.onDraw(buf);
+ FontRef font1;
+ FontRef font2;
+ Log.d("Testing opAssign");
+ font1 = font2;
+ Log.d("Testing copy constructor");
+ FontRef font3 = font2;
+ Log.d("On draw: getting font");
+ FontRef font = FontManager.instance.getFont(32, 400, false, FontFamily.SansSerif, "Arial");
+ Log.d("Got font, drawing text");
+ font.drawText(buf, _pos.left + 5, _pos.top + 5, "Text"d, 0x0000FF);
+ Log.d("Text is drawn successfully");
+ }
+}
+
+extern (C) int UIAppMain() {
+ Log.d("Some debug message");
+ Log.e("Sample error #", 22);
+
+ Window window = Platform.instance().createWindow("My Window", null);
+ Widget myWidget = new TestWidget();
+ window.mainWidget = myWidget;
+ window.show();
+ window.windowCaption = "New Window Caption";
+
+
+
+ Log.d("Before getFont");
+ FontRef font = FontManager.instance.getFont(32, 400, false, FontFamily.SansSerif, "Arial");
+ Log.d("After getFont");
+ assert(!font.isNull);
+ int[] widths;
+ dchar[] text = cast(dchar[])"Test string"d;
+ Log.d("Calling measureText");
+ int charsMeasured = font.measureText(text, widths, 1000);
+ assert(charsMeasured > 0);
+ int w = widths[charsMeasured - 1];
+ Log.d("Measured string: ", charsMeasured, " chars, width=", w);
+ Glyph * g = font.getCharGlyph('A');
+ Log.d("Char A glyph: ", g.blackBoxX, "x", g.blackBoxY);
+ return Platform.instance().enterMessageLoop();
+}
diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d
index 758314b8..fc6dbc81 100644
--- a/src/dlangui/platforms/windows/winapp.d
+++ b/src/dlangui/platforms/windows/winapp.d
@@ -112,10 +112,9 @@ class Win32Platform : Platform {
}
}
-extern (Windows)
-int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow)
-{
+extern(Windows)
+int DLANGUIWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine, int nCmdShow) {
int result;
void exceptionHandler(Throwable e) {
@@ -131,7 +130,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
catch (Throwable e) // catch any uncaught exceptions
{
MessageBox(null, toUTF16z(e.toString()), "Error",
- MB_OK | MB_ICONEXCLAMATION);
+ MB_OK | MB_ICONEXCLAMATION);
result = 0; // failed
}