// gfddsfsd.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <string>
#define IDD_DIALOG1 102
#define IDD_DIALOG2 104
#define IDD_DIALOG3 105
#define IDI_ICON1 103
#define IDC_EDIT1 1000
#define IDC_EDIT2 1001
#define IDABOUT 3
HINSTANCE hinstance;
char* ID = "zhoulike";
char* PASS = "198929";
char idh[20];
char password[20];
int label;
bool cmp(char* ch1,char* ch2)
{
if(!strcmp(ID,ch1))
if(!strcmp(PASS,ch2))
return true;
return false;
}
bool CALLBACK dlgproc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HICON hicon;
bool rt;
HWND hdlg;
switch(uMsg){
case WM_INITDIALOG:
hicon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_ICON1));
SendMessage(hWnd,WM_SETICON,ICON_BIG,LPARAM(hicon));
return true;
case WM_CLOSE:
EndDialog(hWnd,NULL);
return true;
case WM_COMMAND:
switch(LOWORD(wParam)){
case IDC_EDIT1:
GetDlgItemText(hWnd,IDC_EDIT1,idh,20);
return true;
case IDC_EDIT2:
GetDlgItemText(hWnd,IDC_EDIT2,password,20);
return true;
case IDOK:
label++;
rt = cmp(idh,password);
if(rt){
EndDialog(hWnd,NULL);
DialogBoxParam(hinstance,MAKEINTRESOURCE(IDD_DIALOG2),NULL,DLGPROC(dlgproc),NULL);
return true;
}
else {
if(label >= 3){
MessageBox(hWnd,"连续3次输入错误....","啊哦",MB_OK);
hdlg = GetDlgItem(hWnd,IDC_EDIT1);
EnableWindow(hdlg,false);
hdlg = GetDlgItem(hWnd,IDC_EDIT2);
EnableWindow(hdlg,false);
hdlg = GetDlgItem(hWnd,IDOK);
EnableWindow(hdlg,false);
}
else MessageBox(hWnd,"用户名或密码错误","WARNING",MB_OK);
return true;
}
EndDialog(hWnd,NULL);
return true;
case IDCANCEL:
EndDialog(hWnd,NULL);
return true;
case IDABOUT:
DialogBoxParam(hinstance,MAKEINTRESOURCE(IDD_DIALOG3),hWnd,DLGPROC(dlgproc),NULL);
return true;
}
default:break;
}
return false;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
hinstance = GetModuleHandle(NULL);
DialogBoxParam(hinstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,DLGPROC(dlgproc),NULL);
return 0;
}
这是整个代码。红色部分就是有问题的地方了。对话框能进行其他的操作。就是不能移动,点X的时候也不会退出。好象是根本没有处理系统消息。。。。各位大侠帮帮忙啊。。。问题出在那啊。
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!