Răsfoiți Sursa

回车登录

sat23 3 ani în urmă
părinte
comite
24b0679075

+ 26 - 3
AutoCompilation/AutoCompilation/CLoginDlg.cpp

@@ -23,15 +23,38 @@ BOOL CLoginDlg::OnInitDialog(HWND hWnd, LPARAM lParam)
 	return 0;
 }
 
+void CLoginDlg::OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags)
+{
+	if (nChar == VK_RETURN)
+	{
+		OnLogin();
+	}
+
+	SetMsgHandled(FALSE);
+}
+
 void CLoginDlg::OnLogin()
 {
-	SMessageBox(NULL, _T("登录按钮"), _T("haha"), MB_OK | MB_ICONEXCLAMATION);
-	EndDialog(IDOK);
+	SEdit* pAccount = FindChildByName2<SEdit>(_T("edit_accout"));
+	SEdit* pPssword = (SEdit*)FindChildByName(_T("edit_password"));
+	if (pAccount && pPssword)
+	{
+		SStringT strAccount = pAccount->GetWindowTextW();
+		SStringT strPassword = pPssword->GetWindowTextW();
+
+		if ( strAccount.Compare(_T("admin")) == 0 && strPassword.Compare(_T("123456")) == 0 )
+		{
+			EndDialog(IDOK);
+		}
+		else
+		{
+			SMessageBox(NULL, _T("账号或密码错误"), _T("提示"), MB_ICONERROR);
+		}
+	}
 }
 
 void CLoginDlg::OnLoginCancel()
 {
-	//SMessageBox(NULL, _T("这是按钮"), _T("haha"), MB_OK | MB_ICONEXCLAMATION);
 	PostQuitMessage(0);
 }
 

+ 2 - 1
AutoCompilation/AutoCompilation/CLoginDlg.h

@@ -13,7 +13,7 @@ public:
 	void OnCommand(UINT uNotifyCode, int nID, HWND wndCtl);
 	int OnCreate(LPCREATESTRUCT lpCreateStruct);
 	BOOL OnInitDialog(HWND wndFocus, LPARAM lInitParam);
-
+	void OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags);
 protected:
 	void OnLanguage(int nID);
 	void OnLogin();
@@ -28,6 +28,7 @@ protected:
 
 	//HostWndÕæÊµ´°¿ÚÏûÏ¢´¦Àí
 	BEGIN_MSG_MAP_EX(CLoginDlg)
+		MSG_WM_KEYDOWN(OnKeyDown)
 		MSG_WM_CREATE(OnCreate)
 		MSG_WM_INITDIALOG(OnInitDialog)
 		MSG_WM_CLOSE(OnClose)

BIN
AutoCompilation/AutoCompilation/MainDlg.cpp


BIN
AutoCompilation/AutoCompilation/MainDlg.h


BIN
AutoCompilation/AutoCompilation/res/resource.h


BIN
AutoCompilation/AutoCompilation/res/soui_res.rc2


+ 10 - 13
AutoCompilation/AutoCompilation/uires/xml/dlg_login.xml

@@ -1,21 +1,18 @@
-<SOUI name="mainWindow" title="@string/title" bigIcon="ICON_LOGO:32" smallIcon="ICON_LOGO:16" margin="5,5,5,5"  resizable="0" wndType="normal"
-appWnd="1"
-translucent="1" 
->
+<SOUI name="mainWindow" title="@string/title" bigIcon="ICON_LOGO:32" smallIcon="ICON_LOGO:16" margin="5,5,5,5"  resizable="0" wndType="normal" appWnd="1" translucent="1"  >
   <root skin="_skin.sys.wnd.bkgnd" cache="1"  width="300" height="200" >
     <caption pos="0,0,-0,30" show="1" font="adding:0">
       <icon pos="10,8" src="ICON_LOGO:16"/>
       <text pos="29,9">@string/title</text>
-      <imgbtn name="btn_close" skin="_skin.sys.btn.close"    pos="-45,0" tip="close" animate="1"/>
-      <imgbtn name="btn_restore" skin="_skin.sys.btn.restore"  pos="-83,0" show="0" animate="1" />
+      <imgbtn name="btn_close" skin="_skin.sys.btn.close" pos="-45,0" tip="close" animate="1"/>
+      <imgbtn name="btn_restore" skin="_skin.sys.btn.restore" pos="-83,0" show="0" animate="1" />
     </caption>
     <window pos="5,[2,-5,-5">
-        <text pos="%30,%35" offset="-0.5,-0.5">账号</text>
-		<edit pos="[10,{-6,@120,@30" readOnly="0" cueText="请输入账号"></edit>
-        <text pos="%30,%50" offset="-0.5,-0.5">密码</text>
-		<edit pos="[10,{-6,@120,@30" readOnly="0" password="1">请输入密码</edit>
-		<button pos="%45,%60" inset="4,4,4,4" name="btn_login" offset="-1.1,0" text="登录"/>
-		<button pos="%75,%60" inset="4,4,4,4" name="btn_cancel" offset="-1.1,0" text="取消"/>
+      <text pos="%30,%30" offset="-0.5,-0.5">账号</text>
+      <edit pos="[10,{-6,@120,@30" name="edit_accout" readOnly="0" cueText="请输入账号"></edit>
+      <text pos="%30,%45" offset="-0.5,-0.5">密码</text>
+      <edit pos="[10,{-6,@120,@30" readOnly="0" name="edit_password" password="1">请输入密码</edit>
+      <button pos="%50,%60,@80,@30" name="btn_login" offset="-1.1,0" text="登录"/>
+      <button pos="%85,%60,@80,@30" name="btn_cancel" offset="-1.1,0" text="取消"/>
     </window>
   </root>
-</SOUI>
+</SOUI>