maintest.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
源码类别:

模拟服务器

开发平台:

C/C++

  1. // MainTest.cpp : Defines the entry point for the application.
  2. //
  3. #include "MainTest.h"
  4. int APIENTRY WinMain(HINSTANCE hInstance,
  5.                      HINSTANCE hPrevInstance,
  6.                      LPSTR     lpCmdLine,
  7.                      int       nCmdShow)
  8. {
  9.   // TODO: Place code here.
  10. KMyApp MyApp;
  11. if (MyApp.Init(hInstance))
  12. MyApp.Run();
  13. return 0;
  14. }
  15. KMyApp::KMyApp()
  16. {
  17. pIme = new CIme;
  18. }
  19. BOOL KMyApp::GameInit()
  20. {
  21. m_Draw.Mode(FALSE, 640, 480);
  22. if (!g_InitEngine())
  23. return FALSE;
  24. m_Font.Load("\font\lb20.fnt");
  25. m_Font.SetColor(0xFF,0x99,00);
  26. m_Font.SetLine(640,20);
  27. m_Canvas.Init(640, 480);
  28. pIme->EnableIme(); 
  29. return TRUE;
  30. }
  31. BOOL KMyApp::GameExit()
  32. {
  33.    return TRUE;
  34. }
  35. BOOL KMyApp::GameLoop()
  36. {
  37. GetUserInput();
  38. Paint();
  39. return TRUE;
  40. }
  41. void KMyApp::GetUserInput()
  42. {
  43. m_Keyboard.UpdateState();
  44. m_Mouse.UpdateState();}
  45. void KMyApp::Paint()
  46. {
  47. m_Canvas.FillCanvas(0xFFFF);
  48.     if (pIme->GetImeName())
  49. {
  50. m_Font.DrawText( 5,10,pIme->GetImeName());
  51. m_Font.DrawText(150,10, pIme->IfImeSharp()? "全角" : "半角");
  52. m_Font.DrawText(200,10,pIme->IfImeSymbol()? "中文标点" : "英文标点");
  53. char *szCompStr, *szCompReadStr, *szCandList;
  54. int ImeCurPos;
  55. pIme->GetImeInput(&szCompStr, &szCompReadStr,&ImeCurPos, &szCandList );
  56. m_Font.DrawText(0,50,szCompStr);
  57. m_Font.DrawText(0,100,szCompReadStr);
  58.   m_Font.DrawText(0,150,szCandList);
  59.   char szText[1024]  ;
  60. char* pszText;
  61. int MaxCount=100 ;
  62. int TextCursor ;
  63. pszText=szText;
  64. pIme->GetText(pszText,&MaxCount);
  65. TextCursor=pIme->GetCursorPos(); 
  66. m_Font.DrawText(0,200,szText); 
  67. m_Canvas.DrawLine(ImeCurPos*10,50,ImeCurPos*10,70,0x0000); 
  68. m_Canvas.DrawLine(TextCursor*10,200,TextCursor*10,220,0x0000); 
  69. }
  70.   m_Canvas.UpdateScreen();
  71. }
  72. LRESULT KMyApp::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  73. {
  74.  switch( uMsg ){
  75.   case WM_KEYDOWN:
  76. switch( wParam ){
  77. case VK_F1:
  78. if( pIme )pIme->NextIme();
  79. break;
  80. case VK_F2:
  81. if( pIme )pIme->SharpIme(GetActiveWindow());
  82. break;
  83. case VK_F3:
  84. if( pIme )pIme->SymbolIme(GetActiveWindow());
  85. break;
  86. case VK_F4:
  87. case VK_F5:
  88. if( pIme )pIme->EnableIme();
  89. break;
  90. case VK_F6:
  91. if( pIme )pIme->DisableIme();
  92. break;
  93. case VK_ESCAPE:
  94. PostMessage( hWnd, WM_CLOSE, 0, 0 );
  95. break;
  96. }
  97.    default:
  98.   if (!pIme->WndMsg(hWnd,uMsg,wParam,lParam))
  99.   return  KWin32App::MsgProc( hWnd, uMsg, wParam, lParam );
  100.   break;
  101. }
  102. return 0;
  103. }