www.gusucode.com > 一个VC++登录窗口,类似QQ登录界面源码程序 > 一个VC++登录窗口,类似QQ登录界面/仿QQ登陆界面源代码/仿QQ登陆界面源代码/QQLogin.cpp
// QQLogin.cpp : implementation file // Download by http://www.codesc.net #include "stdafx.h" #include "QQLogin.h" # include "right.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CQQLogin dialog CQQLogin::CQQLogin(CWnd* pParent /*=NULL*/) : CDialog(CQQLogin::IDD, pParent) { width=332; height=492; bExtended=true; //{{AFX_DATA_INIT(CQQLogin) m_isHidden = FALSE; m_isTM = FALSE; //}}AFX_DATA_INIT } void CQQLogin::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CQQLogin) DDX_Control(pDX, IDC_STATIC11, m_static11); DDX_Control(pDX, IDC_STATIC10, m_static10); DDX_Control(pDX, IDC_STATIC9, m_static9); DDX_Control(pDX, IDC_STATIC2, m_static2); DDX_Control(pDX, IDC_STATIC8, m_static8); DDX_Control(pDX, IDC_STATIC3, m_static3); DDX_Control(pDX, IDC_STATIC4, m_static4); DDX_Control(pDX, IDC_STATIC5, m_static5); DDX_Control(pDX, IDC_STATIC6, m_static6); DDX_Control(pDX, IDC_STATIC7, m_static7); DDX_Control(pDX, IDC_STATIC1, m_static1); DDX_Check(pDX, IDC_CHECK1, m_isHidden); DDX_Check(pDX, IDC_CHECK2, m_isTM); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CQQLogin, CDialog) //{{AFX_MSG_MAP(CQQLogin) ON_BN_CLICKED(IDC_EXTEND, OnExtend) ON_WM_LBUTTONDOWN() ON_BN_CLICKED(IDC_CHECK1, OnHidden) ON_BN_CLICKED(IDC_CHECK2, OnTMStyle) ON_BN_CLICKED(IDABORT, OnAbort) ON_WM_ERASEBKGND() ON_BN_CLICKED(IDC_PWDCLEAR, OnPwdclear) ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditchangeCombo1) ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1) ON_BN_CLICKED(IDC_QQAPPLY, OnQqapply) ON_BN_CLICKED(IDC_MYBLOG, OnMyblog) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CQQLogin message handlers BOOL CQQLogin::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText("QQ登录系统测试1.0"); SetIcon(AfxGetApp()->LoadIcon(IDI_QQ), true); GetDlgItem(IDC_SEPERATOR)->ShowWindow(SW_HIDE); // TODO: Add extra initialization here /* DWORD dlgstyle=GetStyle(); dlgstyle|=DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU; SetWindowPos(NULL, 0, 0, 0, 0, dlgstyle); */ CComboBox *pBox=(CComboBox *)GetDlgItem(IDC_COMBO2); pBox->InsertString(0, "我知道你在等我!"); pBox->SetCurSel(0); pBox->InsertString(1, "我帅吗?"); pBox->InsertString(2, "我酷吗?"); pBox->InsertString(3, "你喜欢我吗?"); pBox=(CComboBox *)GetDlgItem(IDC_COMBO1); FILE *fp; char ch[10]; if(NULL==(fp=fopen("qq.dat", "r"))) { fp=fopen("qq.dat", "w+"); if(fp==NULL) { MessageBox("未找到QQ的号码文件,且问题无法解决", "阿帅友情提示", MB_OK); } fprintf(fp, "276490908\n"); } else { int j=0; while(!feof(fp)) { memset(ch, 0, sizeof(ch)); fscanf(fp, "%s\n", ch); CString str; str.Format("%s", ch); //MessageBox(str); pBox->InsertString(j, str); pBox->SetCurSel(j); j++; } fclose(fp); } extendDlg(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CQQLogin::OnExtend() { // TODO: Add your control notification handler code here PlaySound("FOLDER", AfxGetResourceHandle(), SND_RESOURCE|SND_ASYNC|SND_NODEFAULT); extendDlg(); } void CQQLogin::extendDlg() { if(bExtended==TRUE) { int x, y; CRect rline, rc; GetWindowRect(&rc); GetDlgItem(IDC_SEPERATOR)->GetWindowRect(&rline); x=GetSystemMetrics(SM_CXSCREEN)/2-width/2; y=GetSystemMetrics(SM_CYSCREEN)/2; this->MoveWindow(x, y-rline.top/2, width, (rline.top-rc.top), true); UpdateWindow(); bExtended=false; GetDlgItem(IDC_EXTEND)->SetWindowText("高级设置↓"); } else { GetDlgItem(IDC_EXTEND)->SetWindowText("高级设置↑"); int x, y; x=GetSystemMetrics(SM_CXSCREEN)/2-width/2; y=GetSystemMetrics(SM_CYSCREEN)/2-height/2; this->MoveWindow(x, y, width, height, TRUE); UpdateWindow(); bExtended=true; } } void CQQLogin::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDialog::OnLButtonDown(nFlags, point); } void CQQLogin::OnHidden() { // TODO: Add your control notification handler code here m_isHidden=true; } void CQQLogin::OnTMStyle() { // TODO: Add your control notification handler code here m_isTM=true; } void CQQLogin::OnAbort() { // TODO: Add your control notification handler code here if(MessageBox("为什么要放弃?请坚持!", "阿帅友情提示", MB_YESNO)==IDNO) { SendMessage(WM_CLOSE); if(hApply!=NULL) { TerminateProcess(hApply, 1); } if(hMyblog!=NULL) { TerminateProcess(hMyblog, 1); } CRight dlg; dlg.DoModal(); PostQuitMessage(1); } } void CQQLogin::OnOK() { // TODO: Add extra validation here GetDlgItem(IDC_COMBO1)->GetWindowText(szUser); GetDlgItem(IDC_EDIT1)->GetWindowText(szPwd); CDialog::OnOK(); } BOOL CQQLogin::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default CRect rc; GetClientRect(&rc); CBrush brush, *pOldbrush; brush.CreateSolidBrush(RGB(236, 246, 255)); pOldbrush=pDC->SelectObject(&brush); pDC->FillRect(&rc, &brush); pDC->SelectObject(pOldbrush); return true;//CDialog::OnEraseBkgnd(pDC); } void CQQLogin::OnPwdclear() { // TODO: Add your control notification handler code here GetDlgItem(IDC_EDIT1)->SetWindowText(NULL); GetDlgItem(IDC_EDIT1)->SetFocus(); } void CQQLogin::OnEditchangeCombo1() { // TODO: Add your control notification handler code here PlaySound("KEYCLICK", AfxGetResourceHandle(), SND_RESOURCE|SND_ASYNC|SND_NODEFAULT); } void CQQLogin::OnChangeEdit1() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. PlaySound("KEYCLICK", AfxGetResourceHandle(), SND_RESOURCE|SND_ASYNC|SND_NODEFAULT); // TODO: Add your control notification handler code here } void CQQLogin::OnQqapply() { // TODO: Add your control notification handler code here PROCESS_INFORMATION pi; STARTUPINFO si; //初始化变量 memset(&si,0,sizeof(si)); si.cb=sizeof(si); si.wShowWindow=SW_SHOW; si.dwFlags=STARTF_USESHOWWINDOW; //打开游览器程序 BOOL fRet=CreateProcess(NULL, "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE http://03xinxi.vicp.net", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); if(!fRet) {//创建失败,显示错误信息 MessageBox("奇怪,打不开游览器!且问题无法解决", "阿帅友情提示", MB_OK); return; } else { AfxMessageBox("CreateProcess成功"); hApply=pi.hProcess; } } void CQQLogin::OnMyblog() { // TODO: Add your control notification handler code here PROCESS_INFORMATION pi; STARTUPINFO si; //初始化变量 memset(&si,0,sizeof(si)); si.cb=sizeof(si); si.wShowWindow=SW_SHOW; si.dwFlags=STARTF_USESHOWWINDOW; //打开游览器程序 BOOL fRet=CreateProcess(NULL, "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE http://xuwenq.blogdriver.com/", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); if(!fRet) {//创建失败,显示错误信息 MessageBox("奇怪,打不开游览器!且问题无法解决", "阿帅友情提示", MB_OK); return; } else { hMyblog=pi.hProcess; } }