📄 se.c
字号:
/*
** $Id: dialogbox.c,v 1.3 2003/06/13 06:50:39 weiym Exp $
**
** Listing 4.1
**
** dialogbox.c: Sample program for MiniGUI Programming Guide
** Usage of DialogBoxIndirectParam
**
** Copyright (C) 2003 Feynman Software.
**
** License: GPL
*/
#include <stdio.h>
#include<stdlib.h>
#include <sqlite3.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#define IDC_PROMPTINFO 100
#define IDC_PROGRESS 110
#define BTN_ADD 120
#define BTN_DEL 130
#define BTN_SER 140
#define BTN_NAME 150
#define IDC_T 170
#define BTN_OK 160
static BITMAP bmp;
void FindData(HWND hdlg)
{
char stuname[20],sql[50];
int i,j,nrows,ncols;
char *a;
char **result;
sqlite3 *db=NULL;
int rc=0;
char *zerr;
//打开数据库
rc=sqlite3_open("phone.db",&db);
if(rc)
{
sqlite3_close(db);
}
GetWindowText(GetDlgItem(hdlg,IDC_PROGRESS),stuname,20);
//准备SQL语句
sprintf(sql,"select * from student where name='%s';",stuname);
//查询
rc=sqlite3_get_table(db,sql,&result,&nrows,&ncols,&zerr);
//分析结果表并处理
if(nrows<=0)
{
MessageBox(hdlg,"不好意思,查不到!","Message",MB_OK);
}
else
{
printf("row=%d,cols=%d\n",nrows,ncols);
for(i=0;i<=nrows;i++)
{
for(j=0;j<ncols;j++)
{
a=result[i*ncols+j];
printf("%s\n",a);
SetWindowText(GetDlgItem(hdlg,IDC_T),a);
}
}
}
//释放结果表空间
sqlite3_free_table(result);
//关闭数据库
sqlite3_close(db);
}
static DLGTEMPLATE DlgInitProgress3 =
{
WS_BORDER | WS_CAPTION,
WS_EX_NONE,
60, 60, 320, 240,
"通讯录",
0, 0,
7, NULL,
0
};
static CTRLDATA CtrlInitProgress3 [] =
{
{
"static",
WS_VISIBLE | SS_SIMPLE,
10, 10, 380, 16,
IDC_PROMPTINFO,
"通讯录---查询号码",
0
},
{
CTRL_EDIT,
WS_VISIBLE,
150, 70, 100, 25,
//200,100,240,25,
IDC_PROGRESS,
0,
0
},
{
CTRL_EDIT,
WS_VISIBLE,
150,100,100,25,
IDC_T,
0,
0
},
/*{
"progressbar",
WS_VISIBLE,
10, 40, 380, 20,
IDC_PROGRESS,
NULL,
0
},*/
{
"button",
WS_TABSTOP | WS_VISIBLE| BS_DEFPUSHBUTTON,
10, 70, 100, 25,
BTN_NAME,
"姓名",
0
},
{
"button",
WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
10, 100, 100, 25,
BTN_ADD,
"号码",
0
},
{
"button",
WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
150, 160, 100, 25,
IDOK,
"返回",
0
},
{
"button",
WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
10, 160, 100, 25,
BTN_OK,
"确定",
0
}
};
static int InitDialogBoxProc3 (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
switch (message) {
case MSG_INITDIALOG:
return 1;
case MSG_ERASEBKGND:
hdc = GetClientDC(hDlg);
LoadBitmap (HDC_SCREEN, &bmp, "bk2.jpg");
FillBoxWithBitmap(hdc,0,0,320,240,&bmp);
Rectangle(hdc,0,0,320,240);
ReleaseDC(hdc);
return 0;
case MSG_COMMAND:
switch (wParam)
{
case BTN_OK://添加按钮
FindData(hDlg);
break;
case IDOK:
case IDCANCEL:
EndDialog (hDlg, wParam);
break;
}
break;
}
return DefaultDialogProc (hDlg, message, wParam, lParam);
}
void InitDialogBox5 (HWND hWnd)
{
DlgInitProgress3.controls = CtrlInitProgress3;
DialogBoxIndirectParam (&DlgInitProgress3, hWnd, InitDialogBoxProc3, 0L);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -