-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path537main.cpp
More file actions
208 lines (174 loc) · 6.88 KB
/
537main.cpp
File metadata and controls
208 lines (174 loc) · 6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
537 USB Disk Manager
Version 1.0 Beta
537main.cpp
Copyright (C) 537 Studio. 2024. All rights reserved.
*/
//EGE库API文档:https://xege.org/manual/api/index.htm
#include <iostream>
#include <string>
#include <sstream>
#include <windows.h>
#include <shellapi.h>
#include "537UDM.h"
#include "include/graphics.h"
#include "include/ege/sys_edit.h"
#include "include/gif.h"
#include "include/wronginfo.h"
#include "include/deviceinfo.h"
#include "include/dpi.h"
#include "include/file.h"
#include "include/netpp.h"
#include "resource.h"
using namespace std;
int main(){
fShowConsoleWindow;//显示命令行窗口
if(GetDeviceInfo()!=0){//获取设备信息失败
get_system_info_failed();
}
// 获取屏幕宽度和高度
scr.width = GetSystemMetrics(SM_CXSCREEN);
wcout<<L"Get screen width: "<<scr.width<<L"px\n";
scr.height = GetSystemMetrics(SM_CYSCREEN);
wcout<<L"Get screen height: "<<scr.height<<L"px\n\n";
taskbar.hwnd=::FindWindow("Shell_TrayWnd","");//获取任务栏hwnd信息
wcout<<L"Get taskbar hwnd: "<<taskbar.hwnd<<L"\n";
::GetWindowRect(taskbar.hwnd,&taskbar.rect);//获取任务栏窗口rect信息
wcout<<L"Get taskbar rect\n";
taskbar.x=taskbar.rect.left;//计算任务栏窗口x坐标
wcout<<L"Taskbar's x: "<<taskbar.x<<L"\n";
taskbar.y=taskbar.rect.top;//计算任务栏窗口y坐标
wcout<<L"Taskbar's y: "<<taskbar.y<<L"\n";
taskbar.width=taskbar.rect.right-taskbar.rect.left;//计算任务栏窗口宽度
wcout<<L"Taskbar's width: "<<taskbar.width<<L"\n";
taskbar.height=taskbar.rect.bottom-taskbar.rect.top;//计算任务栏窗口高度
wcout<<L"Taskbar's height: "<<taskbar.height<<L"\n\n";
mainwindow.width=WINDOW_MAIN_SIZE_WIDTH;//主窗口宽度
wcout<<L"Main window's width: "<<mainwindow.width<<L"\n";
mainwindow.height=WINDOW_MAIN_SIZE_HEIGHT;//主窗口高度
wcout<<L"Main window's height: "<<mainwindow.height<<L"\n";
mainwindow.x=scr.width-mainwindow.width;//主窗口x坐标
wcout<<L"Main window's x: "<<mainwindow.x<<L"\n";
mainwindow.y=scr.height-mainwindow.height-taskbar.height;//主窗口y坐标
wcout<<L"Main window's y: "<<mainwindow.y<<L"\n\n";
setcaption(APP_NAME_EN_L);//设置窗口标题
wcout<<L"Set window title: "<<APP_NAME_EN_L<<L"\n";
setinitmode(0,mainwindow.x,mainwindow.y);//设置初始化窗口位置在屏幕右下角
wcout<<L"Set window location: "<<mainwindow.x<<L", "<<mainwindow.y<<L"\n";
initgraph(WINDOW_MAIN_SIZE_WIDTH*dpi,WINDOW_MAIN_SIZE_HEIGHT*dpi,0);//创建窗口
wcout<<L"Create window\n";
setrendermode(RENDER_MANUAL);//设置手动渲染模式,需要调用delay_fps()/delay_ms()等函数时才会更新窗口,可减少闪烁
wcout<<L"Set render mode\n";
ege_enable_aa(true);//开启窗口抗锯齿
wcout<<L"Enable aa\n\n";
GetDPI();//获取系统DPI
EnableHighDPI();//尝试启用更高DPI
mainwindow.hwnd=getHWnd();//获取主窗口句柄
wcout<<L"Get HWnd: "<<mainwindow.hwnd<<"\n";
mainwindow.hinstance=getHInstance();//获取主进程实例句柄
wcout<<L"Get HInstance: "<<mainwindow.hinstance<<"\n";
mainwindow.hdc=getHDC();//获取图形接口设备上下文句柄
wcout<<L"Get HDC: "<<mainwindow.hdc<<"\n\n";
settextjustify(LEFT_TEXT,CENTER_TEXT);//设置文本上下左右居中
wcout<<L"Set text location mode: "<<LEFT_TEXT<<", "<<CENTER_TEXT<<"\n";
setbkmode(TRANSPARENT);//设置文本输出带透明背景
wcout<<L"Set background mode: "<<TRANSPARENT<<"\n";
setcolor(EGERGBA(255,255,255,100));//前景色
wcout<<L"Set color: "<<255<<L", "<<255<<L", "<<255<<L", "<<100<<L"\n";
setfillcolor(EGERGB(1,182,19));
wcout<<L"Set fill color: "<<1<<L", "<<182<<L", "<<19<<L"\n\n";
PIMAGE FTSLOGO=newimage();
if(getimage(FTSLOGO,L"./resource/537logo.png")!=grOk){
//读取图片文件失败
wcout<<L"Load FTSLOGO failed.\n";
file_lost(INFO_IMAGE,L"FTSLOGO");
}else{
wcout<<L"Load FTSLOGO successed.\n";
}
putimage_withalpha(NULL,FTSLOGO,5,5,100,100,0,0,743,743);
wcout<<L"Put FTSLOGO to: "<<L"x="<<5<<L" y="<<5<<L" width="<<100<<L" height="<<100<<L"\n\n";
outtextxy(110*dpi,15*dpi,DriveLetter);
wcout<<L"Output Drive Letter\n";
outtextxy(110*dpi,35*dpi,VolumeName);
wcout<<L"Output Volume Name\n";
outtextxy(110*dpi,55*dpi,FileSystemName);
wcout<<L"Output File System Name\n";
char space[MAX_PATH]={};
strcpy(space,FreeSpaceStr);
strcat(space," / ");
strcat(space,TotalSpaceStr);
outtextxy(110,75,space);
wcout<<L"Output Drive Letter\n\n";
delay_ms(20);
ege_fillrect(0*dpi,200*dpi,400*dpi,200*dpi);
putimage_withalpha(NULL,FTSLOGO,75,250,100,100,0,0,743,743);
wcout<<L"Put FTSLOGO2 to: "<<75<<L", "<<250<<L"\n\n";
delay_ms(1000);
wcout<<L"Paused 1 second\n\n";
for(int i=0;i<=100;i++){
setfillcolor(EGERGBA(0,122,255,i));
wcout<<L"Set fill color: RGBA(0,122,255,"<<i<<L")\n";
ege_fillrect(0,200,400,200);
delay_ms(20);
}
sys_edit editBox;
editBox.create(1); //创建,false表示单行,true表示多行
editBox.setreadonly(false); //设置输入框允许输入
editBox.move(100, 100); //设置位置
editBox.size(200,100); //设置尺寸
editBox.setmaxlen(20); //设置允许输入的字符数
editBox.setfont(20*dpi,8*dpi,L"微软雅黑");
editBox.visible(true); //设置可见性
editBox.settext("");
editBox.setfocus(); //设置获取焦点
wcout<<L"\nCreate editbox\n\n";
//outtextrect(110,50,200,30,"This is a test. Just show the ege text out.");
delimage(FTSLOGO);
Gif gif(L"resource/loader1.gif");
wcout<<L"Load GIF\n";
gif.setPos(30,150);
wcout<<L"Set GIF pos: 30,150\n";
gif.setSize(48,48);
wcout<<L"Set GIF size: 48,48\n";
gif.info();//控制台输出Gif图像信息
gif.play();
wcout<<L"Draw GIF...\n\n";
for(int i=0;i<=100;i++,delay_fps(60)) {
gif.draw();
}
wstring directoryPath=L"."; // 表示当前目录
vector<wstring> exeFiles;
// 扫描当前目录及其所有子目录
wcout<<L"Scanning EXE files...\n";
ScanDirectoryForExe(directoryPath, exeFiles);
// 打印所有找到的.exe文件路径
for(const auto& file:exeFiles){
std::wcout << file << std::endl;
}
/*
setbkcolor();//背景色
setbkcolor_f();//清屏背景色
setfillcolor();//填充色
setfontbkcolor();//文本背景色
ege_setalpha();//设置统一透明度
*/
/*
setfillcolor(EGERGB(255,255,255));
while(true){
if (keystate(key_mouse_l)) { // 鼠标左键按下了
std::wcout<<"鼠标左键按下\n";
//获取鼠标当前位置坐标,放在变量mouse_x和mouse_y中
int mouse_x,mouse_y;
mousepos(&mouse_x,&mouse_y);
//在鼠标当前位置画一个半径为100的圆
fillcircle(mouse_x,mouse_y,20);
}
}
*/
//NewHttpServe();
//StartHttpServe(GoString{"https://192.168.1.1:5376",24},256);
//ReadFromHttpConn(128,GoString{"https://sean537.github.io/index.html",36});
fgetch;//等待用户输入
closegraph();//关闭绘图窗口
return 0;
}