refactor: 重构代码以提取配置和全局变量

- 将 Windows 消息常量和 UI 配置常量分别提取到 globals.h 和 config.h 头文件中,提高可维护性
- 将全局变量和控件定义从 main.c 移至独立的 globals.c 源文件,实现关注点分离
- 更新 Makefile 以包含新的源文件 globals.c
- 在 ui.c 和 main.c 中引用 config.h,使用配置常量替代硬编码的 UI 参数
This commit is contained in:
2026-03-18 21:01:50 +08:00
parent 7db190306c
commit 7fac2aab35
7 changed files with 82 additions and 45 deletions
+28
View File
@@ -0,0 +1,28 @@
#ifndef CONFIG_H
#define CONFIG_H
// ============================================================================
// UI的配置常量
// ============================================================================
// 对话框设置
#define UI_DLG_SIZE "500x400"
// 列表控件设置
#define UI_LIST_ITEM_PADDING "5x5"
#define UI_LIST_BACKCOLOR "255 255 255"
// 按钮设置
#define UI_BTN_RASTERSIZE "100x32"
// 布局间隙和边距
#define UI_VBOX_GAP "5"
#define UI_VBOX_MARGIN "0x0"
#define UI_VBOX_ALL_MARGIN "10x10"
#define UI_VBOX_ALL_GAP "5"
#define UI_HBOX_GAP "10"
#define UI_HBOX_MARGIN "10x10"
#define UI_HBOX_ALIGNMENT "ACENTER"
#endif // CONFIG_H
+10
View File
@@ -3,6 +3,16 @@
#include <iup.h>
// 定义 Windows 消息常量
#ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDATA 0x0049
#endif
// 消息过滤器常量
#ifndef MSGFLT_ADD
#define MSGFLT_ADD 1
#endif
// 注册表路径常量
#define REG_PATH_SYS L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
#define REG_PATH_USER L"Environment"