📄 qw2.cpp
字号:
#include <windows.h>
#include "qw201.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static char szFileName[_MAX_PATH];//文件名
static char szTitleName[_MAX_FNAME + _MAX_EXT];
static char secret[16];
static char sec[16];//记录对话框中输入的密码
static char newsec[16];//记录新的密码
static HWND record[3],hwndList,hwndedit[24],hwndLabel[25],edit,hwndButton[4];
static WNDPROC fnOldScr[24];//记录编辑框消息处理函数的句柄
static int i=0,j,k,l;//j用于循环,i用于记录名片数,k用于记录列表框里的记录数,l用于记录编辑框标识值
static OPENFILENAME ofn;
static char file[10];
static char szBuffer[21];
static char findBuffer[21];
static char addBuffer[101];
static char findBuff[21];
static char wsprintfBuffer[100];
static HINSTANCE hins;
static HWND hwn;
void PopFileInitialize (HWND);
BOOL PopFileOpenDlg (HWND, PSTR, PSTR);
BOOL PopFileSaveDlg (HWND, PSTR, PSTR);
BOOL PopFileRead ( PSTR);
BOOL addPopFileWrite (PSTR);
BOOL delPopFileWrite (int ,PSTR);
LRESULT CALLBACK find(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK findother(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ScrollProc (HWND, UINT, WPARAM, LPARAM) ;
BOOL APIENTRY DlgProc (HWND, UINT, WPARAM, LPARAM);
BOOL APIENTRY noDlgProc (HWND, UINT, WPARAM, LPARAM);
BOOL APIENTRY secre(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
struct information
{
char name[21];
char workplace[201];
char hometel[101];
char worktel[101];
char freetel[101];
char bp[101];
char fax[101];
char email[101];
char web[101];
char oicq[101];
char workadd[201];
char homeadd[201];
char post[101];
char worksubstance[101];
char work[101];
char sex[10];
char age[10];
char blood[10];
char year[10];
char month[10];
char day[10];
char temperament[101];//性格
char like[101];
char note[201];
}informa[2001];
static struct information infor;
//函数:DoCaption
//作用:设置标题栏
void DoCaption (HWND hwnd, char *szTitleName)
{
char szCaption[64 + _MAX_FNAME + _MAX_EXT];
wsprintf (szCaption, "%s - %s", "名片管理程序", szTitleName[0] ? szTitleName : "宇光软件") ;
SetWindowText (hwnd, szCaption);
}
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
LRESULT CALLBACK qw(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
newsec[0]='\0';
FILE *fp;
if(fp=fopen("mpsec.qyg","rb"))
{fread(secret,sizeof(secret),1,fp);
for(int g=0;g<16;g++)
{if(secret[g]=='\0')
break;
else
secret[g]=~secret[g];
}
fclose(fp);
}
else
{
DialogBox(hInstance,(LPCTSTR)IDD_DIALOG5,NULL,(DLGPROC)noDlgProc);
return FALSE;
}
if(strcmp("qygmarryhnn?",secret))
{
if(DialogBox(hInstance,(LPCTSTR)IDD_DIALOG3,NULL,(DLGPROC)DlgProc))
{return FALSE;}
}
HACCEL hAccelTable;
hins=hInstance;
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
wcex.lpfnWndProc = (WNDPROC)qw;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance,(LPCTSTR)IDI_YGRJ);
wcex.hCursor = LoadCursor(hInstance,(LPCTSTR)IDC_QWCURSOR);
wcex.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH) ;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "128";
wcex.hIconSm = LoadIcon(hInstance,(LPCTSTR)IDI_QW);
if(!RegisterClassEx(&wcex)) return FALSE;
HMENU hMenu, hMenuPopup ;
hMenu = CreateMenu ();
hMenuPopup = LoadMenu (hInstance, "MenuWj") ; //加载菜单资源
//把菜单资源加载进创建的菜单中,并且用位图的形式显示,这就是自绘菜单的含义
AppendMenu (hMenu, MF_STRING| MF_POPUP, (int) hMenuPopup, "文件&f" );
hMenuPopup = LoadMenu (hInstance, "Menuss") ;
AppendMenu (hMenu, MF_STRING | MF_POPUP, (int) hMenuPopup, "搜索&s") ;
hMenuPopup = LoadMenu (hInstance, "menubz") ;
AppendMenu (hMenu, MF_STRING | MF_POPUP, (int) hMenuPopup, "帮助&h") ;
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDA_QWACC);
HWND hwnd;
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
"128",
"宇光名片管理程序",
WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX,
80,
57,
800,
510,
NULL,
hMenu,
hInstance,
NULL);
if(!hwnd) return FALSE;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
if (!TranslateAccelerator(hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
LRESULT CALLBACK qw( HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
HDC hdc ;
TEXTMETRIC tm ;
HINSTANCE hInstance;
hInstance=(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE);
hwn=hwnd;
switch (message)
{
case WM_CREATE :
hdc = GetDC (hwnd) ;
GetTextMetrics (hdc, &tm) ;
ReleaseDC (hwnd, hdc) ;
PopFileInitialize (hwnd);
//创建列表框,第一个参数"ListBox"表示将创建列表框
hwndList = CreateWindow ("ListBox", NULL,
WS_CHILD | WS_VISIBLE | LBS_NOTIFY|WS_VSCROLL|LBS_HASSTRINGS|WS_BORDER,
tm.tmAveCharWidth*3, tm.tmHeight * 1,
tm.tmAveCharWidth * 20 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 26,
hwnd, (HMENU) 30,
hins,NULL) ;
record[0] = CreateWindow ("static", "共",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*6, tm.tmHeight * 27,
tm.tmAveCharWidth * 3 ,
tm.tmHeight * 1,
hwnd,(HMENU) 31, hInstance, NULL) ;
record[1] = CreateWindow ("static", NULL,
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*9, tm.tmHeight * 27,
tm.tmAveCharWidth *5 ,
tm.tmHeight * 1,
hwnd,(HMENU) 32, hInstance, NULL) ;
record[2] = CreateWindow ("static","条名片",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*14, tm.tmHeight * 27,
tm.tmAveCharWidth *7 ,
tm.tmHeight * 1,
hwnd,(HMENU) 33, hInstance, NULL) ;
hwndButton[0] = CreateWindow ("button", "添加",
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
400, 430,
50, 25,
hwnd, (HMENU) 90,
hInstance, NULL) ;
hwndButton[1] = CreateWindow ("button", "删除",
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
465, 430,
50, 25,
hwnd, (HMENU) 91,
hInstance, NULL) ;
hwndButton[2] = CreateWindow ("button", "修改",
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
530, 430,
50, 25,
hwnd, (HMENU) 92,
hInstance, NULL) ;
hwndButton[3] = CreateWindow ("button", "清空",
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
595, 430,
50, 25,
hwnd, (HMENU) 93,
hInstance, NULL) ;
hwndLabel[0] = CreateWindow ("static", "姓名",//0
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 1,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 40, hInstance, NULL) ;//40
hwndedit[0] = CreateWindow ("edit", NULL,//0
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT| ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 1,
tm.tmAveCharWidth * 20 ,
tm.tmHeight * 1,
hwnd, (HMENU) 1,//1
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[1] = CreateWindow ("static", "工作单位",//1
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 3,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 41, hInstance, NULL) ;//41
hwndedit[1] = CreateWindow ("edit", NULL,//1
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |WS_BORDER | ES_LEFT | ES_MULTILINE| ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 3,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 3,
hwnd, (HMENU) 2,//2
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[2] = CreateWindow ("static", "家电话",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 7,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 42, hInstance, NULL) ;
hwndedit[2] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 7,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 3,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[3] = CreateWindow ("static", "单位电话",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 9,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 43, hInstance, NULL) ;
hwndedit[3] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 9,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 4,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[4] = CreateWindow ("static", "手机",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 11,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 44, hInstance, NULL) ;
hwndedit[4] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 11,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 5,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[5] = CreateWindow ("static", "BP",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 13,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 45, hInstance, NULL) ;//5
hwndedit[5] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT| ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 13,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 6,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[6] = CreateWindow ("static", "传真",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 15,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 46, hInstance, NULL) ;
hwndedit[6] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT| ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 15,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 7,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[7] = CreateWindow ("static", "E-mail",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 17,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 47, hInstance, NULL) ;
hwndedit[7] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 17,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 8,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[8] = CreateWindow ("static", "个人网页",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 19,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 48, hInstance, NULL) ;
hwndedit[8] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 19,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 9,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[9] = CreateWindow ("static", "OICQ/ICQ",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 21,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 49, hInstance, NULL) ;
hwndedit[9] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 21,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 10,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[10] = CreateWindow ("static", "单位地址",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*31, tm.tmHeight * 23,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 50, hInstance, NULL) ;
hwndedit[10] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL,
tm.tmAveCharWidth*41, tm.tmHeight * 23,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 3,
hwnd, (HMENU) 11,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[11] = CreateWindow ("static", "家住址",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*72, tm.tmHeight * 3,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 51, hInstance, NULL) ;
hwndedit[11] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL,
tm.tmAveCharWidth*82, tm.tmHeight * 3,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 3,
hwnd, (HMENU) 12,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[12] = CreateWindow ("static", "邮编",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*72, tm.tmHeight * 7,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 52, hInstance, NULL) ;
hwndedit[12] = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE |WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
tm.tmAveCharWidth*82, tm.tmHeight * 7,
tm.tmAveCharWidth * 25 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 1,
hwnd, (HMENU) 13,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL) ;
hwndLabel[13] = CreateWindow ("static", "业务",
WS_CHILD | WS_VISIBLE | SS_CENTER,
tm.tmAveCharWidth*72, tm.tmHeight * 9,
tm.tmAveCharWidth * 10 ,
tm.tmHeight * 1,
hwnd, (HMENU) 53, hInstance, NULL) ;
hwndedit[13] = CreateWindow ("edit", NULL,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -