⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档.txt

📁 这是一个用c语言和MiniGUI工具编写的数据采集服务器程序
💻 TXT
字号:
static void fill_boxes (HWND hDlg, const char* path)
{
struct dirent* dir_ent;
DIR* dir;
struct stat ftype;
char fullpath [PATH_MAX + 1];
SendDlgItemMessage (hDlg, IDL_DIR, LB_RESETCONTENT, 0, (LPARAM)0);
SendDlgItemMessage (hDlg, IDL_FILE, LB_RESETCONTENT, 0, (LPARAM)0);
SetWindowText (GetDlgItem (hDlg, IDC_PATH), path);
if ((dir = opendir (path)) == NULL)
return;
while ( (dir_ent = readdir ( dir )) != NULL ) {
/* Assemble full path name. */
strncpy (fullpath, path, PATH_MAX);
strcat (fullpath, "/");
strcat (fullpath, dir_ent->d_name);
if (stat (fullpath, &ftype) < 0 ) {
continue;
}
if (S_ISDIR (ftype.st_mode))
SendDlgItemMessage (hDlg, IDL_DIR, LB_ADDSTRING, 0, (LPARAM)dir_ent->d_name);
else if (S_ISREG (ftype.st_mode)) {
/* 使用检查框的列表框,需要使用下面的结构 */
LISTBOXITEMINFO lbii;
lbii.string = dir_ent->d_name;
lbii.cmFlag = CMFLAG_BLANK;
lbii.hIcon = 0;
SendDlgItemMessage (hDlg, IDL_FILE, LB_ADDSTRING, 0, (LPARAM)&lbii);
}
}
closedir (dir);
}
static void dir_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
/* 用户双击目录名或者按下 ENTER 键时,进入对应的目录 */
if (nc == LBN_DBLCLK || nc == LBN_ENTER) {
int cur_sel = SendMessage (hwnd, LB_GETCURSEL, 0, 0L);
if (cur_sel >= 0) {
char cwd [MAX_PATH + 1];
char dir [MAX_NAME + 1];
GetWindowText (GetDlgItem (GetParent (hwnd), IDC_PATH), cwd, MAX_PATH);
SendMessage (hwnd, LB_GETTEXT, cur_sel, (LPARAM)dir);
if (strcmp (dir, ".") == 0)
return;
strcat (cwd, "/");
strcat (cwd, dir);
/* 重新填充两个列表框 */
fill_boxes (GetParent (hwnd), cwd);
}
}
}
static void file_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
/* Do nothing */
}
static void prompt (HWND hDlg)
{
int i;
char files [1024] = "你选择要删除的文件是:\n";
/* 获取所有勾选的文件 */
for (i = 0; i < SendDlgItemMessage (hDlg, IDL_FILE, LB_GETCOUNT, 0, 0L); i++) {
char file [MAX_NAME + 1];
int status = SendDlgItemMessage (hDlg, IDL_FILE, LB_GETCHECKMARK, i, 0);
if (status == CMFLAG_CHECKED) {
SendDlgItemMessage (hDlg, IDL_FILE, LB_GETTEXT, i, (LPARAM)file);
strcat (files, file);
strcat (files, "\n");
}
}
/* 提示用户 */
MessageBox (hDlg, files, "确认删除", MB_OK | MB_ICONINFORMATION);
/* 在这里把那些文件真正删除! */
}
static int DelFilesBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case MSG_INITDIALOG:
{
char cwd [MAX_PATH + 1];
SetNotificationCallback (GetDlgItem (hDlg, IDL_DIR), dir_notif_proc);
SetNotificationCallback (GetDlgItem (hDlg, IDL_FILE), file_notif_proc);
fill_boxes (hDlg, getcwd (cwd, MAX_PATH));
return 1;
}
case MSG_COMMAND:
switch (wParam) {
case IDOK:
prompt (hDlg);
case IDCANCEL:
EndDialog (hDlg, wParam);
break;
}
break;
}
return DefaultDialogProc (hDlg, message, wParam, lParam);
}
int MiniGUIMain (int argc, const char* argv[])
{
#ifdef _MGRM_PROCESSES
JoinLayer(NAME_DEF_LAYER , "listbox" , 0 , 0);
#endif
DlgDelFiles.controls = CtrlDelFiles;
DialogBoxIndirectParam (&DlgDelFiles, HWND_DESKTOP, DelFilesBoxProc, 0L);
return 0;
}
#ifndef _MGRM_PROCESSES
#include <minigui/dti.c>
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -