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

模拟服务器

开发平台:

C/C++

  1. //---------------------------------------------------------------------------
  2. // Sword3 Engine (c) 1999-2000 by Kingsoft
  3. //
  4. // File: KWin32Wnd.h.cpp
  5. // Date: 2000.08.08
  6. // Code: WangWei(Daphnis)
  7. // Desc: Window Functions
  8. //---------------------------------------------------------------------------
  9. #include "KWin32.h"
  10. #include "KDebug.h"
  11. #include "KDDraw.h"
  12. #include "KWin32Wnd.h"
  13. //---------------------------------------------------------------------------
  14. static HWND g_hWndMain = NULL;
  15. static HWND g_hWndDraw = NULL;
  16. //---------------------------------------------------------------------------
  17. // 函数: GetMainHWnd
  18. // 功能: 取得主窗口句柄
  19. // 参数: void
  20. // 返回: 主窗口句柄(有可能为NULL)
  21. //---------------------------------------------------------------------------
  22. HWND g_GetMainHWnd(void)
  23. {
  24. return g_hWndMain;
  25. }
  26. //---------------------------------------------------------------------------
  27. // 函数: SetMainHWnd
  28. // 功能: 设置主窗口句柄
  29. // 参数: hWnd 主窗口句柄
  30. // 返回: void
  31. //---------------------------------------------------------------------------
  32. void g_SetMainHWnd(HWND hWnd)
  33. {
  34. g_hWndMain = hWnd;
  35. }
  36. //---------------------------------------------------------------------------
  37. // 函数: GetDrawHWnd
  38. // 功能: 取得绘图窗口句柄
  39. // 参数: void
  40. // 返回: 窗口句柄(有可能为NULL)
  41. //---------------------------------------------------------------------------
  42. HWND g_GetDrawHWnd(void)
  43. {
  44. return g_hWndDraw;
  45. }
  46. //---------------------------------------------------------------------------
  47. // 函数: SetDrawHWnd
  48. // 功能: 设置绘图窗口句柄
  49. // 参数: hWnd 窗口句柄
  50. // 返回: void
  51. //---------------------------------------------------------------------------
  52. void g_SetDrawHWnd(HWND hWnd)
  53. {
  54. g_hWndDraw = hWnd;
  55. }
  56. //---------------------------------------------------------------------------
  57. // 函数: Get Client Rect
  58. // 功能: 取得窗口客户坐标矩形
  59. // 参数: lpRect 矩形区域
  60. // 返回: void
  61. //---------------------------------------------------------------------------
  62. void g_GetClientRect(LPRECT lpRect)
  63. {
  64. if (g_pDirectDraw->GetScreenMode() == FULLSCREEN)
  65. {
  66. lpRect->left = 0;
  67. lpRect->top = 0;
  68. lpRect->right = g_pDirectDraw->GetScreenWidth();
  69. lpRect->bottom = g_pDirectDraw->GetScreenHeight();
  70. }
  71. else
  72. {
  73. GetClientRect(g_hWndDraw, lpRect);
  74. }
  75. }
  76. //---------------------------------------------------------------------------
  77. // 函数: Client To Screen
  78. // 功能: 客户坐标-屏幕坐标
  79. // 参数: lpRect
  80. // 返回: void
  81. //---------------------------------------------------------------------------
  82. void g_ClientToScreen(LPRECT lpRect)
  83. {
  84. if (g_pDirectDraw->GetScreenMode() == WINDOWMODE)
  85. {
  86. ClientToScreen(g_hWndDraw, (LPPOINT)lpRect);
  87. ClientToScreen(g_hWndDraw, (LPPOINT)lpRect + 1);
  88. }
  89. }
  90. //---------------------------------------------------------------------------
  91. // 函数: Screen To Client
  92. // 功能: 屏幕坐标-客户坐标
  93. // 参数: lpRect
  94. // 返回: void
  95. //---------------------------------------------------------------------------
  96. void g_ScreenToClient(LPRECT lpRect)
  97. {
  98. if (g_pDirectDraw->GetScreenMode() == WINDOWMODE)
  99. {
  100. ScreenToClient(g_hWndDraw, (LPPOINT)lpRect);
  101. ScreenToClient(g_hWndDraw, (LPPOINT)lpRect + 1);
  102. }
  103. }
  104. //---------------------------------------------------------------------------
  105. void g_ScreenToClient(LPPOINT lpPoint)
  106. {
  107. if (g_pDirectDraw->GetScreenMode() == WINDOWMODE)
  108. ScreenToClient(g_hWndDraw, lpPoint);
  109. }