Skip to content

Commit

Permalink
update README. Add simple example.
Browse files Browse the repository at this point in the history
  • Loading branch information
whtiehack committed Sep 12, 2019
1 parent e4875d9 commit 4a0ba37
Show file tree
Hide file tree
Showing 15 changed files with 314 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
*.rar
*.zip
*.7z
*.dll
*.dll
/examples/simple/emptyProject/Debug/emptyProject.tlog/
*.log
/examples/simple/emptyProject/.vs/
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Lightweight, high performance and small executable file size Windows GUI library
> Visual Studio Resource Editor
> Other dialog box editor



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


#### windres.exe

This tool in `TDM-GCC-64/bin/windres.exe`,don't know where in MinGW.

# Usage

TODO
### Simple usage:

Generate x.syso file from rc or res file use `windres.exe` tool.

genereate syso:
`windres -i emptyProject/Debug/resource.res -O coff -o vsui.syso`

or

`windres -i ui/ui.rc -O coff -o ui.syso`

main.go
```go
package main

import "github.com/whtiehack/wingui"

func main() {
dlg, _ := wingui.NewDialog(101, 0, nil)
dlg.SetIcon(105)
btnok, _ := wingui.BindNewButton(1002, dlg)
btncancel, _ := wingui.BindNewButton(1003, dlg)
btnok.OnClicked = func() {
dlg.Close()
}
btncancel.OnClicked = btnok.OnClicked
dlg.Show()
// This invoke is optional.
wingui.SetCurrentDialog(dlg.Handle())
wingui.MessageLoop()
}


```


run:
`go run .`

Don't use `go run main.go`, because golang can't load x.syso files.




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

# Examples

Expand Down
Binary file added examples/simple/emptyProject/Debug/Resource.res
Binary file not shown.
Binary file added examples/simple/emptyProject/Resource.aps
Binary file not shown.
Binary file added examples/simple/emptyProject/Resource.rc
Binary file not shown.
31 changes: 31 additions & 0 deletions examples/simple/emptyProject/emptyProject.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2047
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "emptyProject", "emptyProject.vcxproj", "{A3B40728-4CC8-4051-8D67-8B97A314B696}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x64.ActiveCfg = Debug|x64
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x64.Build.0 = Debug|x64
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x86.ActiveCfg = Debug|Win32
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Debug|x86.Build.0 = Debug|Win32
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x64.ActiveCfg = Release|x64
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x64.Build.0 = Release|x64
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x86.ActiveCfg = Release|Win32
{A3B40728-4CC8-4051-8D67-8B97A314B696}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06694693-7882-40DE-8FEF-464F3650809B}
EndGlobalSection
EndGlobal
132 changes: 132 additions & 0 deletions examples/simple/emptyProject/emptyProject.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{A3B40728-4CC8-4051-8D67-8B97A314B696}</ProjectGuid>
<RootNamespace>emptyProject</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc" />
</ItemGroup>
<ItemGroup>
<Xml Include="manifest.xml" />
</ItemGroup>
<ItemGroup>
<Image Include="icon1.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
35 changes: 35 additions & 0 deletions examples/simple/emptyProject/emptyProject.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Xml Include="manifest.xml" />
</ItemGroup>
<ItemGroup>
<Image Include="icon1.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions examples/simple/emptyProject/emptyProject.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
Binary file added examples/simple/emptyProject/icon1.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions examples/simple/emptyProject/manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
21 changes: 21 additions & 0 deletions examples/simple/emptyProject/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 Resource.rc 使用
//
#define IDD_DIALOG1 101
#define IDI_ICON1 105
#define ID_OK 1002
#define ID_CANCEL 1003
#define IDC_STATIC -1

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40002
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
2 changes: 2 additions & 0 deletions examples/simple/generate_res.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
windres -i emptyProject/Debug/resource.res -O coff -o vsui.syso

18 changes: 18 additions & 0 deletions examples/simple/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import "github.com/whtiehack/wingui"

func main() {
dlg, _ := wingui.NewDialog(101, 0, nil)
dlg.SetIcon(105)
btnok, _ := wingui.BindNewButton(1002, dlg)
btncancel, _ := wingui.BindNewButton(1003, dlg)
btnok.OnClicked = func() {
dlg.Close()
}
btncancel.OnClicked = btnok.OnClicked
dlg.Show()
// This invoke is optional.
wingui.SetCurrentDialog(dlg.Handle())
wingui.MessageLoop()
}
Binary file added examples/simple/vsui.syso
Binary file not shown.

0 comments on commit 4a0ba37

Please sign in to comment.