Skip to content

Commit 4a0ba37

Browse files
committed
update README. Add simple example.
1 parent e4875d9 commit 4a0ba37

15 files changed

+314
-2
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
*.rar
44
*.zip
55
*.7z
6-
*.dll
6+
*.dll
7+
/examples/simple/emptyProject/Debug/emptyProject.tlog/
8+
*.log
9+
/examples/simple/emptyProject/.vs/

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Lightweight, high performance and small executable file size Windows GUI library
1111
1212
> Visual Studio Resource Editor
1313
14+
> Other dialog box editor
15+
1416

1517

1618

@@ -27,10 +29,57 @@ TDM-GCC
2729
http://tdm-gcc.tdragon.net/
2830

2931

32+
#### windres.exe
33+
34+
This tool in `TDM-GCC-64/bin/windres.exe`,don't know where in MinGW.
35+
3036
# Usage
3137

32-
TODO
38+
### Simple usage:
39+
40+
Generate x.syso file from rc or res file use `windres.exe` tool.
41+
42+
genereate syso:
43+
`windres -i emptyProject/Debug/resource.res -O coff -o vsui.syso`
44+
45+
or
46+
47+
`windres -i ui/ui.rc -O coff -o ui.syso`
48+
49+
main.go
50+
```go
51+
package main
52+
53+
import "github.com/whtiehack/wingui"
54+
55+
func main() {
56+
dlg, _ := wingui.NewDialog(101, 0, nil)
57+
dlg.SetIcon(105)
58+
btnok, _ := wingui.BindNewButton(1002, dlg)
59+
btncancel, _ := wingui.BindNewButton(1003, dlg)
60+
btnok.OnClicked = func() {
61+
dlg.Close()
62+
}
63+
btncancel.OnClicked = btnok.OnClicked
64+
dlg.Show()
65+
// This invoke is optional.
66+
wingui.SetCurrentDialog(dlg.Handle())
67+
wingui.MessageLoop()
68+
}
69+
70+
71+
```
72+
73+
74+
run:
75+
`go run .`
76+
77+
Don't use `go run main.go`, because golang can't load x.syso files.
78+
79+
80+
3381

82+
[More examples](https://github.com/whtiehack/wingui/tree/master/examples)
3483

3584
# Examples
3685

46.4 KB
Binary file not shown.
49.1 KB
Binary file not shown.
7.16 KB
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27703.2047
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "emptyProject", "emptyProject.vcxproj", "{A3B40728-4CC8-4051-8D67-8B97A314B696}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x64.ActiveCfg = Debug|x64
17+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x64.Build.0 = Debug|x64
18+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x86.ActiveCfg = Debug|Win32
19+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x86.Build.0 = Debug|Win32
20+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x64.ActiveCfg = Release|x64
21+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x64.Build.0 = Release|x64
22+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x86.ActiveCfg = Release|Win32
23+
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {06694693-7882-40DE-8FEF-464F3650809B}
30+
EndGlobalSection
31+
EndGlobal
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>15.0</VCProjectVersion>
23+
<ProjectGuid>{A3B40728-4CC8-4051-8D67-8B97A314B696}</ProjectGuid>
24+
<RootNamespace>emptyProject</RootNamespace>
25+
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
26+
</PropertyGroup>
27+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<PlatformToolset>v141</PlatformToolset>
32+
<CharacterSet>MultiByte</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35+
<ConfigurationType>Application</ConfigurationType>
36+
<UseDebugLibraries>false</UseDebugLibraries>
37+
<PlatformToolset>v141</PlatformToolset>
38+
<WholeProgramOptimization>true</WholeProgramOptimization>
39+
<CharacterSet>MultiByte</CharacterSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42+
<ConfigurationType>Application</ConfigurationType>
43+
<UseDebugLibraries>true</UseDebugLibraries>
44+
<PlatformToolset>v141</PlatformToolset>
45+
<CharacterSet>MultiByte</CharacterSet>
46+
</PropertyGroup>
47+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48+
<ConfigurationType>Application</ConfigurationType>
49+
<UseDebugLibraries>false</UseDebugLibraries>
50+
<PlatformToolset>v141</PlatformToolset>
51+
<WholeProgramOptimization>true</WholeProgramOptimization>
52+
<CharacterSet>MultiByte</CharacterSet>
53+
</PropertyGroup>
54+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55+
<ImportGroup Label="ExtensionSettings">
56+
</ImportGroup>
57+
<ImportGroup Label="Shared">
58+
</ImportGroup>
59+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
60+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
</ImportGroup>
65+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67+
</ImportGroup>
68+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
69+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70+
</ImportGroup>
71+
<PropertyGroup Label="UserMacros" />
72+
<PropertyGroup />
73+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<ClCompile>
75+
<WarningLevel>Level3</WarningLevel>
76+
<Optimization>Disabled</Optimization>
77+
<SDLCheck>true</SDLCheck>
78+
<ConformanceMode>true</ConformanceMode>
79+
</ClCompile>
80+
</ItemDefinitionGroup>
81+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
82+
<ClCompile>
83+
<WarningLevel>Level3</WarningLevel>
84+
<Optimization>Disabled</Optimization>
85+
<SDLCheck>true</SDLCheck>
86+
<ConformanceMode>true</ConformanceMode>
87+
</ClCompile>
88+
</ItemDefinitionGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
90+
<ClCompile>
91+
<WarningLevel>Level3</WarningLevel>
92+
<Optimization>MaxSpeed</Optimization>
93+
<FunctionLevelLinking>true</FunctionLevelLinking>
94+
<IntrinsicFunctions>true</IntrinsicFunctions>
95+
<SDLCheck>true</SDLCheck>
96+
<ConformanceMode>true</ConformanceMode>
97+
</ClCompile>
98+
<Link>
99+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
100+
<OptimizeReferences>true</OptimizeReferences>
101+
</Link>
102+
</ItemDefinitionGroup>
103+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
104+
<ClCompile>
105+
<WarningLevel>Level3</WarningLevel>
106+
<Optimization>MaxSpeed</Optimization>
107+
<FunctionLevelLinking>true</FunctionLevelLinking>
108+
<IntrinsicFunctions>true</IntrinsicFunctions>
109+
<SDLCheck>true</SDLCheck>
110+
<ConformanceMode>true</ConformanceMode>
111+
</ClCompile>
112+
<Link>
113+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
114+
<OptimizeReferences>true</OptimizeReferences>
115+
</Link>
116+
</ItemDefinitionGroup>
117+
<ItemGroup>
118+
<ClInclude Include="resource.h" />
119+
</ItemGroup>
120+
<ItemGroup>
121+
<ResourceCompile Include="Resource.rc" />
122+
</ItemGroup>
123+
<ItemGroup>
124+
<Xml Include="manifest.xml" />
125+
</ItemGroup>
126+
<ItemGroup>
127+
<Image Include="icon1.ico" />
128+
</ItemGroup>
129+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
130+
<ImportGroup Label="ExtensionTargets">
131+
</ImportGroup>
132+
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="源文件">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="头文件">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="资源文件">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="resource.h">
19+
<Filter>头文件</Filter>
20+
</ClInclude>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ResourceCompile Include="Resource.rc">
24+
<Filter>资源文件</Filter>
25+
</ResourceCompile>
26+
</ItemGroup>
27+
<ItemGroup>
28+
<Xml Include="manifest.xml" />
29+
</ItemGroup>
30+
<ItemGroup>
31+
<Image Include="icon1.ico">
32+
<Filter>资源文件</Filter>
33+
</Image>
34+
</ItemGroup>
35+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>
44.4 KB
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<dependency>
4+
<dependentAssembly>
5+
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
6+
</dependentAssembly>
7+
</dependency>
8+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
9+
<security>
10+
<requestedPrivileges>
11+
<requestedExecutionLevel
12+
level="asInvoker"
13+
uiAccess="false"/>
14+
</requestedPrivileges>
15+
</security>
16+
</trustInfo>
17+
</assembly>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//{{NO_DEPENDENCIES}}
2+
// Microsoft Visual C++ 生成的包含文件。
3+
// 供 Resource.rc 使用
4+
//
5+
#define IDD_DIALOG1 101
6+
#define IDI_ICON1 105
7+
#define ID_OK 1002
8+
#define ID_CANCEL 1003
9+
#define IDC_STATIC -1
10+
11+
// Next default values for new objects
12+
//
13+
#ifdef APSTUDIO_INVOKED
14+
#ifndef APSTUDIO_READONLY_SYMBOLS
15+
#define _APS_NO_MFC 1
16+
#define _APS_NEXT_RESOURCE_VALUE 106
17+
#define _APS_NEXT_COMMAND_VALUE 40002
18+
#define _APS_NEXT_CONTROL_VALUE 1004
19+
#define _APS_NEXT_SYMED_VALUE 101
20+
#endif
21+
#endif

examples/simple/generate_res.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
windres -i emptyProject/Debug/resource.res -O coff -o vsui.syso
2+

examples/simple/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import "github.com/whtiehack/wingui"
4+
5+
func main() {
6+
dlg, _ := wingui.NewDialog(101, 0, nil)
7+
dlg.SetIcon(105)
8+
btnok, _ := wingui.BindNewButton(1002, dlg)
9+
btncancel, _ := wingui.BindNewButton(1003, dlg)
10+
btnok.OnClicked = func() {
11+
dlg.Close()
12+
}
13+
btncancel.OnClicked = btnok.OnClicked
14+
dlg.Show()
15+
// This invoke is optional.
16+
wingui.SetCurrentDialog(dlg.Handle())
17+
wingui.MessageLoop()
18+
}

examples/simple/vsui.syso

47 KB
Binary file not shown.

0 commit comments

Comments
 (0)