📄 tongxunlu.c.bak
字号:
/*
** $Id: helloworld.c,v 1.17 2004/06/10 06:12:53 weiym Exp $
**
** Listing 2.1
**
** helloworld.c: Sample program for MiniGUI Programming Guide
** The first MiniGUI application.
**
** Copyright (C) 2003 Feynman Software.
**
** License: GPL
*/
#include <stdio.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/mywindows.h>
#include <minigui/control.h>
#include <minigui/mgext.h>
#include "kb.c"
#include "../common.h"
#define IDC_CLOSE 0X0011
#define IDC_TX_CALL 1401
#define IDC_TX_SURE 1402
#define IDC_TX_UP 1403
#define IDC_TX_DOWN 1404
#define IDC_TX_ADD 1405
#define IDC_TX_DELETE 1406
#define IDC_TX_LOOKUP 1407
#define IDC_TX_REWORK 1408
#define IDC_TX_EIDET1 1409
#define IDC_TX_STATICHXM 1439
#define IDC_TX_STATICSJ 1440
#define IDC_TX_STATICZD 1441
#define IDC_TX_STATICBZ 1442 /*姓名、手机、宅电、备注4个静态框的IDC*/
#define IDC_TX_N 1443
#define IDC_TX_M 1444
#define IDC_TX_H 1445
#define IDC_TX_B 1446 /*姓名、手机、宅电、备注4个信息的显示*/
#define IDC_TX_PROMPTINFO 1447
#define IDC_TX_STATICHSRXM 1448 /*摸态窗口中要输入姓名的静态框*/
#define IDC_TX_FINDNAME 1449
#define IDC_TX_FIND 1450 /*通讯录弹出窗口的查找按钮*/
#define IDC_TX_CANCLE 1451 /*通讯录弹出窗口的取消按钮*/
#define IDC_TX_KEYBORD 1452 /*通讯录弹出窗口的软键盘按钮*/
#define IDC_TX_KB 1453 /*软键盘ID*/
static HWND TN,THDF,THMF,TRM,FN;
static int flat=0; /*判断光标的标志位*/
static int temp=0; /*总记录数*/
static int temp1=0; /*当前记录数*/
static int mark=0; /*标记:用来控制 SAVE键 只能在 ADD键触发后才可以使用*/
struct book /*定义通讯录结构体*/
{
char id[500];
char name[50];
char hdf[20];
char hmf[20];
char remark[500];
};
struct book note[500];/*定义结构体类型数组*/
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription:点击主页面的通讯录初始窗口
*******************************************************************************/
static void ShowUserInfo(HWND hWnd)
{
FILE *fp;
int k;
if((fp = fopen("./note","r"))== NULL)
{
MessageBox (hWnd, "Auto-Initialize!", "HINT!",MB_OK | MB_ICONEXCLAMATION);
fp = fopen("./note","w");
strcpy(note[0].name,"急救");
strcpy(note[0].hdf,"120");
strcpy(note[0].hmf,"********");
strcpy(note[0].remark,"Welcome Use Our Product");
fwrite(¬e[0],sizeof(struct book),1,fp);
temp=0;
temp1=0;
}
else
{
while(!feof(fp))
{
k=fread(¬e[temp],sizeof(struct book),1,fp);
temp++;
}
temp-=2;
}
fclose(fp);
SendMessage (TN, MSG_SETTEXT, 0, (LPARAM)note[0].name);
SendMessage (THDF, MSG_SETTEXT, 0, (LPARAM)note[0].hdf);
SendMessage (THMF, MSG_SETTEXT, 0, (LPARAM)note[0].hmf);
SendMessage (TRM, MSG_SETTEXT, 0, (LPARAM)note[0].remark);
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription:点击ADD键 4个单行文本框清空功能模块
*******************************************************************************/
static void AddUserInfo(HWND hWnd)
{
SendMessage (TN, MSG_SETTEXT, 0, (LPARAM)"");
SendMessage (THDF, MSG_SETTEXT, 0, (LPARAM)"");
SendMessage (THMF, MSG_SETTEXT, 0, (LPARAM)"");
SendMessage (TRM, MSG_SETTEXT, 0, (LPARAM)"");
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription: 点击SAVE添加到通讯录功能模块
*******************************************************************************/
static void SaveUserInfo(HWND hWnd)
{
{
temp++;
GetWindowText(TN,note[temp].name,50);
GetWindowText(THDF,note[temp].hdf,20);
GetWindowText(THMF,note[temp].hmf,20);
GetWindowText(TRM,note[temp].remark,100);
}
temp1=temp;
MessageBox (hWnd, "Succeed!", "HINT!",MB_OK | MB_ICONEXCLAMATION);
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription: 点击显示上一条记录功能模块
*******************************************************************************/
static void UpUserInfo(HWND hWnd)
{
if(temp1>0)
{
temp1--;
SendMessage (TN, MSG_SETTEXT, 0, (LPARAM)note[temp1].name);
SendMessage (THDF, MSG_SETTEXT, 0, (LPARAM)note[temp1].hdf);
SendMessage (THMF, MSG_SETTEXT, 0, (LPARAM)note[temp1].hmf);
SendMessage (TRM, MSG_SETTEXT, 0, (LPARAM)note[temp1].remark);
}
else
MessageBox (hWnd, "Frist Record!", "HINT!",MB_OK | MB_ICONEXCLAMATION);
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription: 点击显示下一条记录功能模块
*******************************************************************************/
static void DownUserInfo(HWND hWnd)
{
if(temp1<temp)
{
temp1++;
//printf("%d\n",temp);
SendMessage (TN, MSG_SETTEXT, 0, (LPARAM)note[temp1].name);
SendMessage (THDF, MSG_SETTEXT, 0, (LPARAM)note[temp1].hdf);
SendMessage (THMF, MSG_SETTEXT, 0, (LPARAM)note[temp1].hmf);
SendMessage (TRM, MSG_SETTEXT, 0, (LPARAM)note[temp1].remark);
}
else
MessageBox (hWnd, "Last Record!", "HINT!",MB_OK | MB_ICONEXCLAMATION);
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription: 点击修改记录功能模块
*******************************************************************************/
static void ModUserInfo(HWND hWnd)
{
GetWindowText(TN,note[temp1].name,50);
GetWindowText(THDF,note[temp1].hdf,20);
GetWindowText(THMF,note[temp1].hmf,20);
GetWindowText(TRM,note[temp1].remark,100);
MessageBox (hWnd, "Done!", "HINT!",MB_OK | MB_ICONEXCLAMATION);
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription:删除记录功能模块
*******************************************************************************/
static void DeleteUserInfo(HWND hWnd)
{ int i;
{
if(temp1<temp)
{
for(i=temp1;i<temp;i++)
{
note[temp1]=note[temp1+1];
}
temp--;
}
else
{
temp--;
temp1--;
}
SendMessage (TN, MSG_SETTEXT, 0, (LPARAM)note[temp1].name);
SendMessage (THDF, MSG_SETTEXT, 0, (LPARAM)note[temp1].hdf);
SendMessage (THMF, MSG_SETTEXT, 0, (LPARAM)note[temp1].hmf);
SendMessage (TRM, MSG_SETTEXT, 0, (LPARAM)note[temp1].remark);
}
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription: 关闭通讯录主界面时回写功能模块
*******************************************************************************/
static void SaveFile()
{
int i;
FILE *fp;
if((fp = fopen("./note","w"))!= NULL)
{
for(i=0;i<=temp;i++)
{
fwrite(¬e[i],sizeof(struct book),1,fp);
}
}
fclose(fp);
}
/*******************************************************************************
* File Name: tongxunlu.c
* Copy Right: GaoHaibo
* Author: GaoHaibo
* Function discription: 在输入需要查找的名后进行查找
*******************************************************************************/
static void FindUserInfo()
{
int result;
int i=0;
char fname[50]={0};
char mk[5]={":"}; /* 冒号数组*/
char fresult[70]={0}; /*查找结果的保存的数组*/
GetWindowText(FN,fname,50);
for(i=0;i<=temp;i++)
{
result = strcmp(note[i].name,fname);
if(result==0)
{
strcat(fresult,note[i].name);
strcat(fresult,mk);
strcat(fresult,note[i].hdf);
MessageBox (0, fresult, "HINT!",MB_OK | MB_ICONEXCLAMATION);
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -