现在的位置: 首页 > 综合 > 正文

EndDialog(hwnd, IDOK); if(IDOK==returncode)

2013年10月04日 ⁄ 综合 ⁄ 共 1042字 ⁄ 字号 评论关闭
void Dlg1_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
    switch(id)
    {
	case IDOK:
		{
		PUserInfo puser1;
        puser1=(PUserInfo)GetWindowLong(hwnd,GWL_USERDATA);		
		/*
		char buf[256];
		wsprintf(buf,"%d,%d,%d",sizeof(puser1),sizeof(puser1->userName),sizeof(puser1->passWord));
		MessageBox(hwnd,buf,"",MB_OK);
		//*/
		GetDlgItemText(hwnd,IDC_USERNAME,puser1->userName,sizeof(puser1->userName));
		GetDlgItemText(hwnd,IDC_PASSWORD,puser1->passWord,sizeof(puser1->passWord));
		EndDialog(hwnd, IDOK);
		}
        break;
	case IDCANCEL:
		{
		EndDialog(hwnd, IDCANCEL);
		}
        break;
	default:
		break;
    }
}


        case IDC_OK:
		{
			//MessageBox(hwnd,TEXT("欢迎访问如鹏网 www.RuPeng.com 大学生计算机学习社区"),TEXT("问好"),MB_OK);
			HINSTANCE hInstance;
			hInstance=(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE);
			//DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, Dlg1_Proc);	
			UserInfo user1={"yzk","12345"};
			int returncode=DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,Dlg1_Proc,(long)&user1);
			if(IDOK==returncode)
			{
			MessageBox(hwnd,user1.userName,user1.passWord,MB_OK);
			} 
			else if(IDCANCEL==returncode)
			{
				MessageBox(hwnd,user1.userName,"取消",MB_OK);
			}

		}
        break;

抱歉!评论已关闭.