📄 mywincepro.cpp
字号:
if (NewPosY < 0) NewPosY = 0;
SetWindowPos(hDlg, 0, NewPosX, NewPosY,
0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
return TRUE;
case WM_COMMAND:
switch(wParam){
case IDSave: //save the file
{
GetDlgItemText(hDlg,IDC_EditFile,FileContent,1024);
GetDlgItemText(hDlg,IDC_FileName,FileName,150);
assert(dbname.writeFilename(FileName));
DialogBox(hInst, (LPCTSTR)IDD_PASSWORD, MyhWnd, (DLGPROC)Password);
File file;
file.FileCreate(FileName);
file.FileWrite(FileContent);
file.getFileTimeInfo();
assert(dbft.writeFiletime(file.fileCreateTime));
updateflagsinceopen=1; // update 过了
SYSTEMTIME st;
FileTimeToSystemTime(&file.fileCreateTime,&st);
TCHAR y[20];
TCHAR m[20];
TCHAR d[20];
TCHAR h[20];
TCHAR mi[20];
TCHAR se[20];
_itot(st.wYear,y,10);
_itot(st.wMonth,m,10);
_itot(st.wDay,d,10);
_itot(st.wHour,h,10);
_itot(st.wMinute,mi,10);
_itot(st.wSecond,se,10);
TCHAR totalTime[150];
wcscat(totalTime,L"Current Time:");
wcscat(totalTime,y);
wcscat(totalTime,TEXT("/"));
wcscat(totalTime,m);
wcscat(totalTime,TEXT("/"));
wcscat(totalTime,d);
wcscat(totalTime,TEXT("/ "));
wcscat(totalTime,h);
wcscat(totalTime,TEXT(":"));
if(st.wMinute<10){
wcscat(totalTime,TEXT("0"));
}
wcscat(totalTime,mi);
wcscat(totalTime,TEXT(" "));
wcscat(totalTime,se);
wcscat(totalTime,TEXT("'"));
MessageBox(NULL,totalTime, L"File createTime year RESULT",MB_OK);
EndDialog(hDlg, LOWORD(wParam));
}
break;
case IDEditCancel: //cancel
EndDialog(hDlg, LOWORD(wParam));
break;
}
}
return FALSE;
}
LRESULT CALLBACK SearchFile(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
RECT rt, rt1;
int DlgWidth, DlgHeight; // dialog width and height in pixel units
int NewPosX, NewPosY;
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
// if the About box is larger than the physical screen
if (NewPosX < 0) NewPosX = 0;
if (NewPosY < 0) NewPosY = 0;
SetWindowPos(hDlg, 0, NewPosX, NewPosY,
0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
return TRUE;
case WM_COMMAND:
switch(wParam){
case IDGO:
{
int flag=0;
int openflag=0;
GetDlgItemText(hDlg,IDC_Bynam,SearchName,50);
GetDlgItemText(hDlg,IDC_Y,SearchYear,20); //把edit box当中的内容拷入数组
GetDlgItemText(hDlg,IDC_Month,SearchMonth,20);
GetDlgItemText(hDlg,IDC_Day,SearchDay,20);
GetDlgItemText(hDlg,IDC_Hour,SearchHour,20);
GetDlgItemText(hDlg,IDC_Minute,SearchMinute,20);
LPTSTR emp=new TCHAR[5];
wcscpy(emp,L"");
if(wcscmp(SearchName,emp)!=0){ //按照名字搜索
flag=1;
int loopName = dbname.prgPropVal[0].val.iVal;
for(int i=1;i<=loopName;i++){
if(wcscmp(dbname.prgPropVal[loopName].val.lpwstr,SearchName)==0){
if(wcscmp(dbpw.prgPropVal[loopName].val.lpwstr,L"0")==0){ //用户没有设密码,可以直接打开
openflag=1;
}else{ //但如果设置了
DialogBox(hInst, (LPCTSTR)IDD_CHECK, MyhWnd, (DLGPROC)PasswordCheck);
if(wcscmp(pword,dbpw.prgPropVal[loopName].val.lpwstr)==0){
openflag=1;
}else{
openflag=2;
}
}
}
}
if(openflag==1){
File f;
f.FileCreate(FileName);
f.FileRead();
MessageBox(NULL,f.BuffFileRead, L"search RESULT",MB_OK); //展示文件内容
wcscpy(FileNameAfterSearch,FileName);
DialogBox(hInst, (LPCTSTR)IDD_transmitOpt, MyhWnd, (DLGPROC)SendFile2);
}else if(openflag==2){
MessageBox(NULL,L"invalid password!", L"open RESULT",MB_OK); //展示文件内容
}
}
if(flag!=1){
/*
int openflagsearch=0; //time数据库没有被打开 ,显示0
int updateflagsinceopen=0; //表示自从打开过以后并没有改变,显示0
*/
assert(dbft.readDB());
assert(dbname.readDB());
int resultRow=0;
int loopTime = dbft.prgPropVal[0].val.iVal;
SYSTEMTIME st;
for(int i=1;i<=loopTime;i++){
FileTimeToSystemTime(&dbft.prgPropVal[loopTime].val.filetime,&st);
if(wcscmp(&st.wYear,SearchYear)==0&&wcscmp(&st.wMonth,SearchMonth)==0
&&wcscmp(&st.wDay,SearchDay)==0||(wcscmp(&st.wHour,SearchHour)==0
&&wcscmp(&st.wMinute,SearchMinute)==0)){
resultRow=loopTime;
if(i==loopTime){
MessageBox(NULL,L"not found!!", L"search RESULT",MB_OK);
}
}
}
if(resultRow!=0){ //如果找到了则按照row打开
File file;
file.FileCreate(dbname.prgPropVal[resultRow].val.lpwstr);
file.FileRead();
MessageBox(NULL,file.BuffFileRead, L"search RESULT",MB_OK);
DialogBox(hInst, (LPCTSTR)IDD_transmitOpt, MyhWnd, (DLGPROC)SendFile2);
}
}
EndDialog(hDlg, LOWORD(wParam));
break;
}
case IDsearchCANCEL:
EndDialog(hDlg, LOWORD(wParam));
break;
}
}
return FALSE;
}
LRESULT CALLBACK SendFile(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
RECT rt, rt1;
int DlgWidth, DlgHeight; // dialog width and height in pixel units
int NewPosX, NewPosY;
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
// if the About box is larger than the physical screen
if (NewPosX < 0) NewPosX = 0;
if (NewPosY < 0) NewPosY = 0;
SetWindowPos(hDlg, 0, NewPosX, NewPosY,
0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
return TRUE;
case WM_COMMAND:
switch(wParam){
case IDSend:
{
GetDlgItemText(hDlg,IDC_EDITsendfilename,SendName,50);
SocketServer(SendName);
}
break;
case IDSendCancel: //cancel
EndDialog(hDlg, LOWORD(wParam));
break;
}
}
return FALSE;
}
LRESULT CALLBACK SendFile2(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
RECT rt, rt1;
int DlgWidth, DlgHeight; // dialog width and height in pixel units
int NewPosX, NewPosY;
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
// if the About box is larger than the physical screen
if (NewPosX < 0) NewPosX = 0;
if (NewPosY < 0) NewPosY = 0;
SetWindowPos(hDlg, 0, NewPosX, NewPosY,
0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
return TRUE;
case WM_COMMAND:
switch(wParam){
case IDOK: //如果确定要以红外线传送搜索到的文件
SocketServer(FileNameAfterSearch);
break;
case IDC_ModifyFile:
break;
case IDC_DeleteFile:
DeleteFile(FileNameAfterSearch);
break;
case IDCANCEL: //cancel
EndDialog(hDlg, LOWORD(wParam));
break;
}
}
return FALSE;
}
LRESULT CALLBACK Password(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
RECT rt, rt1;
int DlgWidth, DlgHeight; // dialog width and height in pixel units
int NewPosX, NewPosY;
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
// if the About box is larger than the physical screen
if (NewPosX < 0) NewPosX = 0;
if (NewPosY < 0) NewPosY = 0;
SetWindowPos(hDlg, 0, NewPosX, NewPosY,
0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
return TRUE;
case WM_COMMAND:
switch(wParam){
case IDOK:
{
LPTSTR emp=new TCHAR[10];
LPTSTR pw=new TCHAR[100];
wcscpy(emp,L"");
GetDlgItemText(hDlg,IDC_PW,pw,100);
if(wcscmp(pw,emp)==0){ //用户没有输入密码
dbpw.writeFilename(L"0");
}else if(wcslen(pw)<8){
MessageBox(NULL,L"Password at least 8 bits", L"Message:",MB_OK);
DialogBox(hInst, (LPCTSTR)IDD_PASSWORD, MyhWnd, (DLGPROC)Password);
}else if(wcslen(pw)>10){
MessageBox(NULL,L"Password no longer than 10 bits", L"Message:",MB_OK);
DialogBox(hInst, (LPCTSTR)IDD_PASSWORD, MyhWnd, (DLGPROC)Password);
}else{
dbpw.writeFilename(pw);
}
}
EndDialog(hDlg, LOWORD(wParam));
break;
}
}
return FALSE;
}
LRESULT CALLBACK PasswordCheck(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
RECT rt, rt1;
int DlgWidth, DlgHeight; // dialog width and height in pixel units
int NewPosX, NewPosY;
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
// if the About box is larger than the physical screen
if (NewPosX < 0) NewPosX = 0;
if (NewPosY < 0) NewPosY = 0;
SetWindowPos(hDlg, 0, NewPosX, NewPosY,
0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
return TRUE;
case WM_COMMAND:
switch(wParam){
case IDCHECKOK:
GetDlgItemText(hDlg,IDC_PASSWORDCHECK,pword,100);
EndDialog(hDlg, LOWORD(wParam));
break;
case IDCHECKCANCEL: //cancel
EndDialog(hDlg, LOWORD(wParam));
break;
}
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -