NewAccount.cpp
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:7k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #define LOGIN_BUTTON_COUNT 3
  3. #define LOGIN_INPUT_COUNT 2
  4. #define LOGIN_IMAGE_COUNT 4
  5. CNewAccount::CNewAccount()
  6. {
  7. }
  8. CNewAccount::~CNewAccount()
  9. {
  10. }
  11. VOID CNewAccount::Create(CWHWilImageData* pxImage)
  12. {
  13. /* INT nLoop;
  14. // Buttons
  15. BUTTONINFO LoginProcBtnInfo[] = {
  16. { IMG_IDX_BTN_NEW, POS_BTN_NEW_X, POS_BTN_NEW_Y, LOGBTN_WIDTH, LOGBTN_HEIGHT}, // OK Button
  17. { IMG_IDX_BTN_CHGPASS, POS_BTN_CHG_X, POS_BTN_CHG_Y, LOGBTN_WIDTH, LOGBTN_HEIGHT}, // New Account
  18. { IMG_IDX_BTN_OK, POS_BTN_OK_X, POS_BTN_OK_Y, LOGBTN_WIDTH, LOGBTN_HEIGHT} // Change Password
  19. };
  20. // EditBox State
  21. INPUTSTATE LoginInputState[] =  {
  22. { LGM_INPUT_ID, POS_ID_INS_X, POS_ID_INS_Y, 126, 15, 0, 10, ""}, // Input ID in Login
  23. { LGM_INPUT_PASSWORD, POS_PASS_INS_X, POS_PASS_INS_Y, 126, 15, 0, 10, ""} // Input Password In Login
  24. };
  25. _LOGINIMAGEINFO LoginImageInfo[] = {
  26. {IMG_IDX_ID, POS_ID_TITLE_X, POS_ID_TITLE_Y},
  27. {IMG_IDX_PASS, POS_PASS_TITLE_X, POS_PASS_TITLE_Y},
  28. {IMG_IDX_ID_INS, POS_ID_INS_X, POS_ID_INS_Y},
  29. {IMG_IDX_PASS_INS, POS_PASS_INS_X, POS_PASS_INS_Y}
  30. };
  31. m_pxImage = pxImage;
  32. for(nLoop = 0 ; nLoop < LOGIN_INPUT_COUNT ; nLoop ++)
  33. memcpy(&m_xInputState[nLoop],&LoginInputState[nLoop],sizeof(INPUTSTATE));
  34. for(nLoop = 0 ; nLoop < LOGIN_BUTTON_COUNT ; nLoop ++)
  35. m_xButtons[nLoop].SetBtn(&LoginProcBtnInfo[nLoop]);
  36. for(nLoop = 0 ; nLoop < LOGIN_IMAGE_COUNT ; nLoop ++)
  37. m_xInputImg[nLoop] = LoginImageInfo[nLoop];*/
  38. }
  39. HRESULT CNewAccount::OnKeyDown(WPARAM wParam, LPARAM lParam)
  40. {
  41. /* if (wParam == VK_RETURN || wParam == VK_TAB)
  42. { SetFocusBefore();
  43. switch(m_nUserState)
  44. { case  LGM_INPUT_ID:
  45. { m_nUserState = LGM_INPUT_PASSWORD;
  46. break;
  47. }
  48. case LGM_INPUT_PASSWORD:
  49. { if( ( lstrlen( m_xInputState[LGM_INPUT_ID-1].szData) >= LIMIT_USERID ) 
  50. && lstrlen( m_xInputState[LGM_INPUT_PASSWORD-1].szData ) )
  51. {
  52. g_xClientSocket.OnLogin(m_xInputState[LGM_INPUT_ID-1].szData,m_xInputState[LGM_INPUT_PASSWORD-1].szData);
  53. return 0L;
  54. }
  55. m_nUserState = LGM_INPUT_ID;
  56. break;
  57. }
  58. }
  59. SetFocusAfter();
  60. }*/
  61. return 0;
  62. }
  63. HRESULT CNewAccount::OnButtonDown(WPARAM wParam, LPARAM lParam)
  64. {
  65. /* INT i;
  66. RECT tRect;
  67. m_fIsButtonDown = TRUE;
  68. for( i = LGM_INPUT_ID-1 ; i < LGM_INPUT_PASSWORD; i ++)
  69. { SetRect(&tRect
  70. ,m_xInputState[i].Left,m_xInputState[i].Top
  71. ,m_xInputState[i].Left+m_xInputState[i].Width,m_xInputState[i].Top+m_xInputState[i].Height);
  72. if( IsInRect( tRect, LOWORD( lParam ), HIWORD( lParam ) ) )
  73. { SetFocusBefore();
  74. m_nUserState = i+1;
  75. SetFocusAfter();
  76. }
  77. }
  78. // Image Button Down Check
  79. for ( i = BTN_NEW_ID; i <= BTN_OK_ID ; i++)
  80. { if (m_xButtons[i].CheckMouseOn( LOWORD( lParam ), HIWORD( lParam ) ) )
  81. m_xButtons[i].m_nState = BUTTON_STATE_DOWN;
  82. else
  83. m_xButtons[i].m_nState = BUTTON_STATE_UP;
  84. }*/
  85. return 0;
  86. }
  87. HRESULT CNewAccount::OnButtonDown(POINT ptMouse)
  88. {
  89. m_fIsButtonDown = TRUE;
  90. return 0;
  91. }
  92. HRESULT CNewAccount::OnButtonUp(WPARAM wParam, LPARAM lParam)
  93. {
  94. /* INT i;
  95. m_fIsButtonDown = FALSE;
  96. for(i = BTN_NEW_ID; i <= BTN_OK_ID; i++)
  97. { m_xButtons[i].m_nState = BUTTON_STATE_UP;
  98. if( m_xButtons[i].CheckMouseOn( LOWORD( lParam ), HIWORD( lParam ) ) )
  99. { switch(m_xButtons[i].m_nButtonID)
  100. { case IMG_IDX_BTN_NEW:
  101. {
  102. //m_nProgress = PRG_NEW_ACCOUNT; - > New Account肺 逞扁绰 窃荐
  103. SetFocusBefore();
  104. SetWindowText(g_xChatEditBox.GetSafehWnd(),NULL);
  105. m_nUserState = LGM_INPUT_USER_ID;
  106. SetFocusAfter();
  107. break;
  108. }
  109. case IMG_IDX_BTN_CHGPASS:
  110. { // 烙矫肺 辆丰滚瓢栏肺 捞侩
  111. // Avi 包访 窃荐 辆丰 窍绰 内靛
  112. // break; 
  113. }
  114. // case BTN_EXIT:
  115. {
  116. SendMessage(g_xMainWnd.GetSafehWnd(), WM_DESTROY, NULL, NULL);
  117. return 0L;break;
  118. }
  119. case IMG_IDX_BTN_OK:
  120. {
  121. SendMessage(g_xChatEditBox.GetSafehWnd(),WM_CHAR,VK_RETURN,0);
  122. g_xClientSocket.OnLogin(m_xInputState[LGM_INPUT_ID-1].szData,m_xInputState[LGM_INPUT_PASSWORD-1].szData);
  123. break;
  124. }
  125. }// switch
  126. }// if
  127. }// for*/
  128. return 0;
  129. }
  130. HRESULT CNewAccount::OnButtonUp(POINT ptMouse)
  131. {
  132. return 0;
  133. }
  134. LRESULT CNewAccount::OnMouseMove(WPARAM wParam, LPARAM lParam)
  135. {
  136. /* INT i;
  137. if(!m_fIsButtonDown)
  138. {
  139. for( i = BTN_NEW_ID ; i <= BTN_OK_ID ; i ++)
  140. {
  141. if (m_xButtons[i].CheckMouseOn(LOWORD(lParam), HIWORD(lParam)))
  142. m_xButtons[i].m_nState = BUTTON_STATE_ON;
  143. else
  144. m_xButtons[i].m_nState = BUTTON_STATE_UP;
  145. }
  146. }
  147. */
  148. return 0;
  149. }
  150. VOID CNewAccount::Render(INT nLoopTime)
  151. {
  152. /* if(m_fIsActive)
  153. {
  154. int i;
  155. char Pass[16]="";
  156. MoveWindow(g_xChatEditBox.GetSafehWnd(), 
  157. g_xMainWnd.m_rcWindow.left + m_xInputState[m_nUserState-1].Left +5,
  158. g_xMainWnd.m_rcWindow.top + m_xInputState[m_nUserState-1].Top + 5 , m_xInputState[m_nUserState-1].Width, m_xInputState[m_nUserState-1].Height, TRUE);
  159. // Draw ID & Pass Image
  160. for( i = IMG_IDX_ID-1 ; i < IMG_IDX_PASS_INS ; i ++)
  161. {
  162. m_pxImage->NewSetIndex(m_xInputImg[i].nImgIdx);
  163. g_xMainWnd.DrawWithImageForComp(m_xInputImg[i].Left , m_xInputImg[i].Top,
  164. m_pxImage->m_lpstNewCurrWilImageInfo->shWidth,
  165. m_pxImage->m_lpstNewCurrWilImageInfo->shHeight,
  166. (WORD*)(m_pxImage->m_pbCurrImage));
  167. }
  168. // Draw Button Image
  169. for ( i = BTN_NEW_ID ; i <=  BTN_OK_ID ; i++)
  170. {
  171. m_pxImage->NewSetIndex(m_xButtons[i].m_nButtonID + m_xButtons[i].m_nState - 1 );
  172. g_xMainWnd.DrawWithImageForComp(m_xButtons[i].m_Rect.left, m_xButtons[i].m_Rect.top, 
  173. m_xButtons[i].m_Rect.right - m_xButtons[i].m_Rect.left, 
  174. m_xButtons[i].m_Rect.bottom - m_xButtons[i].m_Rect.top, (WORD*)(m_pxImage->m_pbCurrImage));
  175. }
  176. // Write ID & Password
  177. memset(Pass,'*',strlen(m_xInputState[1].szData));
  178. g_xMainWnd.PutsHan(NULL, m_xInputState[0].Left+7, m_xInputState[0].Top+6, RGB(5,5,5), RGB(0,0,0), m_xInputState[0].szData);
  179. g_xMainWnd.PutsHan(NULL, m_xInputState[1].Left+7, m_xInputState[1].Top+6, RGB(5,5,5), RGB(0,0,0), Pass);
  180. }*/
  181. }
  182. VOID CNewAccount::SetFocusBefore(VOID)
  183. {
  184. INT nTemp;
  185. nTemp =  m_nUserState - 1;
  186. if(g_xChatEditBox.m_szInputMsg[0]!=NULL)
  187. lstrcpy(m_xInputState[nTemp].szData , g_xChatEditBox.m_szInputMsg);
  188. else
  189. GetWindowText(g_xChatEditBox.GetSafehWnd(),m_xInputState[nTemp].szData ,m_xInputState[nTemp].nSize);
  190. ZeroMemory(g_xChatEditBox.m_szInputMsg,sizeof(g_xChatEditBox.m_szInputMsg));
  191. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
  192. g_xChatEditBox.SetSelectAll();
  193. }
  194. VOID CNewAccount::SetFocusAfter(VOID)
  195. {
  196. CHAR cChr;
  197. INT nTemp;
  198. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_SHOW);
  199. nTemp = m_nUserState - 1;
  200. g_xChatEditBox.SetLimitText(m_xInputState[nTemp].nSize);
  201. if( m_nUserState != LGM_INPUT_PASSWORD )
  202. cChr = NULL;
  203. else
  204. cChr = '*';
  205. SendMessage(g_xChatEditBox.GetSafehWnd(),EM_SETPASSWORDCHAR,(WPARAM)cChr,0);
  206. SetWindowText(g_xChatEditBox.GetSafehWnd(), m_xInputState[nTemp].szData);
  207. SetFocus(g_xChatEditBox.GetSafehWnd());
  208. g_xChatEditBox.SetSelectAll();
  209. }