Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1801498
  • 博文数量: 290
  • 博客积分: 10653
  • 博客等级: 上将
  • 技术积分: 3178
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 23:08
文章存档

2013年(6)

2012年(15)

2011年(25)

2010年(86)

2009年(52)

2008年(66)

2007年(40)

分类: C/C++

2008-10-28 20:12:20

#include<windows.h>
#include "resource.h"

BOOL CALLBACK DlgProc(HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowcmd)
{

    hInstance=GetModuleHandle(NULL);
    DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG),NULL,DlgProc);
    return 0;
}
BOOL CALLBACK DlgProc(HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam)
{
    TCHAR    szUserName[256]=" ";
    TCHAR    szPassword[256]=" ";
    TCHAR    szUN[9]="kanghtta";
    TCHAR    szPW[8]="7126630";
    int count,i;
    HWND    hUser,hPasd;
    switch(message)
        {
        case WM_CLOSE:
            EndDialog(hDlg,NULL);
            break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {

            case    ID_OK:
        
                    hUser =    GetDlgItem(hDlg,IDC_USERNAME);
                    hPasd = GetDlgItem(hDlg,IDC_PASSWARD);
                    count = GetWindowTextLength(hUser);
                    GetWindowText(hUser,szUserName,count+1);
                    for(i = 0; i<=count; i++)
                    {
                        if(szUserName[i]!=szUN[i])
                        {
                            MessageBox(hDlg,TEXT("用户名错误,请重新输入"),TEXT("错误"),MB_OK);
                            break;
                        
                        }
                    }
                    count = GetWindowTextLength(hPasd);
                    GetWindowText(hPasd,szPassword,count+1);
                    if(count==0)
                        MessageBox(hDlg,TEXT("密码不能为空"),TEXT("错误"),MB_OK);
                    else
                    {
                    for(i = 0; i<=count; i++)
                    {
                    if(szPassword[i]!=szPW[i])
                        {
                            MessageBox(hDlg,TEXT("密码错误,请重新输入"),TEXT("错误"),MB_OK);
                            break;
                        }    
                    }
                    }
                    if(i>=count&&count!=0)
                    MessageBox(hDlg,TEXT("登陆成功"),TEXT("欢迎使用"),MB_OK);
                    else    
                    break;
                
                    
                

            case    ID_CANCEL:
                EndDialog(hDlg,NULL);
                break;
            
                

            }
        }
    return FALSE;
}

 

阅读(1660) | 评论(0) | 转发(0) |
0

上一篇:第一个窗口程序

下一篇:你是最美的

给主人留下些什么吧!~~