Skip to content

Commit

Permalink
💾 📝 Feat, Chore: Merge pull request #63 from Crequency/dev=main
Browse files Browse the repository at this point in the history
[Pull Request] 安装包项目调整
  • Loading branch information
Dynesshely authored Aug 12, 2022
2 parents ba4fc71 + 54c4b36 commit d51834f
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 89 deletions.
201 changes: 136 additions & 65 deletions KitX Installer/Installer for Windows/KitX Installer for Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#include "framework.h"
#include "KitX Installer for Windows.h"

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

#define MAX_LOADSTRING 100

#define ScreenX GetSystemMetrics(SM_CXSCREEN)
#define ScreenY GetSystemMetrics(SM_CYSCREEN)

// 全局变量:
HINSTANCE hInst; // 当前实例
WCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本
Expand All @@ -15,12 +20,15 @@ WCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);

void DrawBackground(HDC* hdc);
void DrawRectangle(HDC* hdc, int x, int y, int width, int height, int thinkness);


int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
Expand All @@ -33,7 +41,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
MyRegisterClass(hInstance);

// 执行应用程序初始化:
if (!InitInstance (hInstance, nCmdShow))
if (!InitInstance(hInstance, nCmdShow))
{
return FALSE;
}
Expand All @@ -52,7 +60,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
}
}

return (int) msg.wParam;
return (int)msg.wParam;
}


Expand All @@ -68,17 +76,18 @@ ATOM MyRegisterClass(HINSTANCE hInstance)

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_KITXINSTALLERFORWINDOWS));
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_KITXINSTALLERFORWINDOWS);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_KITXINSTALLERFORWINDOWS));
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = nullptr;
/*wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_KITXINSTALLERFORWINDOWS);*/
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

return RegisterClassExW(&wcex);
}
Expand All @@ -95,20 +104,70 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
hInst = hInstance; // 将实例句柄存储在全局变量中

HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);

if (!hWnd)
{
return FALSE;
}
hInst = hInstance; // 将实例句柄存储在全局变量中

HWND hWnd = CreateWindowW(szWindowClass, L"KitX Installer | KitX 安装向导",
WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME ^ WS_MAXIMIZEBOX,
(ScreenX - 800) / 2, (ScreenY - 600) / 2, 800, 600,
nullptr, nullptr, hInstance, nullptr);

btn_confirm_install = CreateWindow(
L"BUTTON", // Predefined class; Unicode assumed
L"Install | 安装", // Button text
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles
340, // x position
500, // y position
120, // Button width
30, // Button height
hWnd, // Parent window
NULL, // No menu.
(HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
NULL); // Pointer not needed.

edit_install_path = CreateWindow(
L"edit", L"C:\\Program Files\\Crequency\\KitX\\", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,
230, 450, 340, 30, hWnd, NULL, NULL, NULL);


LOGFONT lf;//声明一个逻辑字体,因为创建太痛苦了,15个字段都要设置,要人的命
HFONT hFont;//这里是我们创建的字体哦
GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);//得到设备字体,同时填充逻辑字体结构,这样大大减少了代码DEFAULT_GUI_FONT 这个API上有的,还有SYSTEM_FONT 自己去查查

lf.lfHeight = 14;

//开始创建字体,很简单,创建一个逻辑字体就可以
hFont = CreateFontIndirect(&lf);//哈哈,这里就是上面的那个结构
SendMessage(btn_confirm_install, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE); //这样的就设置控件的字体了啊
DeleteObject(GetStockObject(DEFAULT_GUI_FONT));

LOGFONT font;
font.lfHeight = 24;
font.lfWidth = 0;
font.lfEscapement = 0;
font.lfOrientation = 0;
font.lfWeight = FW_REGULAR;
font.lfItalic = false;
font.lfUnderline = false;
font.lfStrikeOut = false;
font.lfEscapement = 0;
font.lfOrientation = 0;
font.lfOutPrecision = OUT_DEFAULT_PRECIS;
font.lfClipPrecision = CLIP_STROKE_PRECIS | CLIP_MASK | CLIP_TT_ALWAYS | CLIP_LH_ANGLES;
font.lfQuality = ANTIALIASED_QUALITY;
font.lfPitchAndFamily = VARIABLE_PITCH | FF_DONTCARE;

HFONT heFont = ::CreateFontIndirect(&font);
SendMessage(edit_install_path, WM_SETFONT, (WPARAM)heFont, TRUE);

if (!hWnd)
{
return FALSE;
}

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

return TRUE;
return TRUE;
}

//
Expand All @@ -125,56 +184,68 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
// 分析菜单选择:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
break;
case WM_PAINT:
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
// TODO: 在此处添加使用 hdc 的任何绘图代码...

// 绘制背景
/*for (int i = 0; i < rand() % 30 + 10; ++i)
DrawBackground(&hdc);*/

EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// “关于”框的消息处理程序。
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
void DrawBackground(HDC* hdc)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
DrawRectangle(hdc, rand() % 700, rand() % 500, rand() % 100 + 30, rand() % 100 + 30, rand() % 30);
}

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
void DrawRectangle(HDC* hdc, int x, int y, int width, int height, int thinkness)
{
Rectangle(*hdc, x, y, x + width, y + height);
if (thinkness > 1)
{
for (int i = 0; i < thinkness; ++i)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
Rectangle(*hdc, x + i, y + i, x + width - i, y + height - i);
}
break;
}
return (INT_PTR)FALSE;
}



























Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
Expand Down
41 changes: 18 additions & 23 deletions KitX Installer/Installer for Windows/Resource.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 使用者 KitX Installer for Windows.rc

#define IDS_APP_TITLE 103

#define IDR_MAINFRAME 128
#define IDD_KITXINSTALLERFORWINDOWS_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDI_KITXINSTALLERFORWINDOWS 107
#define IDI_SMALL 108
#define IDC_KITXINSTALLERFORWINDOWS 109
#define IDC_MYICON 2
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
// 新对象的下一组默认值
// 供 KitX Installer for Windows.rc 使用
//
#define IDC_MYICON 2
#define IDD_KITXINSTALLERFORWINDOWS_DIALOG 102
#define IDS_APP_TITLE 103
#define IDM_ABOUT 104
#define IDI_KITXINSTALLERFORWINDOWS 107
#define IDI_SMALL 108
#define IDC_KITXINSTALLERFORWINDOWS 109
#define IDR_MAINFRAME 128
#define IDC_STATIC -1

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_NO_MFC 130
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
Binary file modified KitX Installer/Installer for Windows/small.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions KitX.sln
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,42 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installer for Windows", "In
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KitX Installer for Windows", "KitX Installer\Installer for Windows\KitX Installer for Windows.vcxproj", "{9C055D1B-B410-49A2-A81E-342E1D5956FF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{72B86499-F876-4E0D-A215-2E1420848906}"
ProjectSection(SolutionItems) = preProject
.github\FUNDING.yml = .github\FUNDING.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".gitlab", ".gitlab", "{06EA8A93-DD6A-41B4-817D-07A66AD7812A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "issue_templates", "issue_templates", "{B41024AB-010C-4C4D-A307-7C6D8BB3380F}"
ProjectSection(SolutionItems) = preProject
.gitlab\issue_templates\bug-report.md = .gitlab\issue_templates\bug-report.md
.gitlab\issue_templates\feature-request.md = .gitlab\issue_templates\feature-request.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{04F558D1-BD80-41FC-8ABD-B7B968F7F5AE}"
ProjectSection(SolutionItems) = preProject
.github\ISSUE_TEMPLATE\---bug-report.md = .github\ISSUE_TEMPLATE\---bug-report.md
.github\ISSUE_TEMPLATE\---feature-request.md = .github\ISSUE_TEMPLATE\---feature-request.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PULL_REQUEST_TEMPLATE", "PULL_REQUEST_TEMPLATE", "{1A935375-BE26-480F-A31A-844CB8E48C84}"
ProjectSection(SolutionItems) = preProject
.github\PULL_REQUEST_TEMPLATE\pull_request_template.md = .github\PULL_REQUEST_TEMPLATE\pull_request_template.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{1B6E60B1-8E92-48F8-A90A-642049A9E046}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-loaders.yml = .github\workflows\build-loaders.yml
.github\workflows\build-plugins.yml = .github\workflows\build-plugins.yml
.github\workflows\build.yml = .github\workflows\build.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "merge_request_templates", "merge_request_templates", "{58B96215-FDBA-4FEA-ABD4-E4C7D66D2AE9}"
ProjectSection(SolutionItems) = preProject
.gitlab\merge_request_templates\default.md = .gitlab\merge_request_templates\default.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -242,6 +278,13 @@ Global
{8D00A21D-EF71-4CD2-BC63-CD97C9687695} = {B3D8D064-E8B8-4673-A6C0-F6392DC2A444}
{61142209-2848-4FE6-8688-147830C105FC} = {2A5D8B91-A9CA-40FF-B821-5CE45A27312E}
{9C055D1B-B410-49A2-A81E-342E1D5956FF} = {61142209-2848-4FE6-8688-147830C105FC}
{72B86499-F876-4E0D-A215-2E1420848906} = {F9F655A9-54A3-4E3C-853F-EFA24615ED67}
{06EA8A93-DD6A-41B4-817D-07A66AD7812A} = {F9F655A9-54A3-4E3C-853F-EFA24615ED67}
{B41024AB-010C-4C4D-A307-7C6D8BB3380F} = {06EA8A93-DD6A-41B4-817D-07A66AD7812A}
{04F558D1-BD80-41FC-8ABD-B7B968F7F5AE} = {72B86499-F876-4E0D-A215-2E1420848906}
{1A935375-BE26-480F-A31A-844CB8E48C84} = {72B86499-F876-4E0D-A215-2E1420848906}
{1B6E60B1-8E92-48F8-A90A-642049A9E046} = {72B86499-F876-4E0D-A215-2E1420848906}
{58B96215-FDBA-4FEA-ABD4-E4C7D66D2AE9} = {06EA8A93-DD6A-41B4-817D-07A66AD7812A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {09BBC227-F41B-4D10-9E38-0EEE07ED17BC}
Expand Down

0 comments on commit d51834f

Please sign in to comment.