NewMsgBox.cpp
上传用户:oldpeter23
上传日期:2013-01-09
资源大小:1111k
文件大小:4k
源码类别:

IP电话/视频会议

开发平台:

Visual C++

  1. //NetTalk
  2. /*------------------------------------------------------------------------------*
  3.  =============================
  4.    模块名称: NewMsgBox.cpp
  5.  =============================
  6.  
  7.  [版权]
  8.  
  9.    2000-2002  115软件工厂  版权所有
  10.                                               
  11. *------------------------------------------------------------------------------*/
  12. #include "wndx.h"
  13. #include "WndX.h"
  14. #include "NewMsgBox.h"
  15. #include <stdio.h>
  16. /*------------------------------------------------------------------------------*/
  17. CMsgBox::CMsgBox()
  18. {
  19. }
  20. /*------------------------------------------------------------------------------*/
  21. CMsgBox::~CMsgBox()
  22. {
  23. }
  24. /*------------------------------------------------------------------------------*/
  25. LRESULT CMsgBox::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
  26. {
  27. switch(uMsg)
  28. {
  29. case WM_INITDIALOG:
  30. return OnInitDialog();
  31. break;
  32. case WM_COMMAND:
  33. return OnCommand(wParam,lParam);
  34. case WM_ERASEBKGND:
  35. OnEraseBkgnd((HDC)wParam);
  36. return TRUE;
  37. default:
  38. return CGraphDlg::WndProc(uMsg,wParam,lParam);
  39. }
  40. return TRUE;
  41. }
  42. /*------------------------------------------------------------------------------*/
  43. BOOL CMsgBox::OnInitDialog()
  44. {
  45. CGraphDlg::OnInitDialog();
  46. SetWindowText(m_hWnd,m_szCap);
  47. SetDlgItemText(m_hWnd,IDC_TXT,m_szTxt);
  48. //make it topmost
  49. if(m_uType&MB_SYSTEMMODAL)
  50. SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
  51. if(m_uType&MB_YESNO)
  52. {
  53. SetDlgItemText(m_hWnd,IDC_OK,"是(&Y)");
  54. SetDlgItemText(m_hWnd,IDC_CANCEL,"否(&N)");
  55. }
  56. else
  57. if(m_uType&MB_OKCANCEL)
  58. {
  59. SetDlgItemText(m_hWnd,IDC_OK,"确定");
  60. SetDlgItemText(m_hWnd,IDC_CANCEL,"取消");
  61. }
  62. else
  63. {
  64. SetDlgItemText(m_hWnd,IDC_OK,"确定");
  65. ShowWindow(GetDlgItem(m_hWnd,IDC_CANCEL),SW_HIDE);
  66. }
  67. PlaySound(LPCTSTR(IDR_MSG),hInstX,SND_ASYNC|SND_RESOURCE);
  68. SetForegroundWindow(m_hWnd);
  69. SetActiveWindow(m_hWnd);
  70. return FALSE;
  71. }
  72. /*------------------------------------------------------------------------------*/
  73. int CMsgBox::MessageBox(HWND hWnd, char *pszTxt, char *pszCap,UINT utype,UINT uIcon)
  74. {
  75. CMsgBox mb;
  76. return mb.MsgBox(hWnd,pszTxt,pszCap,utype,uIcon);
  77. }
  78. /*------------------------------------------------------------------------------*/
  79. int CMsgBox::MessageBox(HWND hWnd,const int iTxtId,const int iCapId, UINT utype,UINT uIcon)
  80. {
  81. CMsgBox mb;
  82. return mb.MsgBox(hWnd,iTxtId,iCapId,utype,uIcon);
  83. }
  84. /*------------------------------------------------------------------------------*/
  85. int CMsgBox::MsgBox(HWND hWnd, int iTxtId, int iCapId, UINT utype,UINT uIcon)
  86. {
  87. LoadString(hInstX,iTxtId,m_szTxt,255);
  88. LoadString(hInstX,iCapId,m_szCap,127);
  89. m_uType=utype;
  90. m_uIcon=uIcon;
  91. return CGraphDlg::DoModal(LPCTSTR(IDD_MSGBOX),hWnd);
  92. }
  93. /*------------------------------------------------------------------------------*/
  94. int CMsgBox::MsgBox(HWND hWnd, char *pszTxt, char *pszCap, UINT utype,UINT uIcon)
  95. {
  96. strncpy(m_szTxt,pszTxt,255);
  97. strncpy(m_szCap,pszCap,127);
  98. m_uType=utype;
  99. m_uIcon=uIcon;
  100. return CGraphDlg::DoModal(LPCTSTR(IDD_MSGBOX),hWnd);
  101. }
  102. /*------------------------------------------------------------------------------*/
  103. BOOL CMsgBox::OnCommand(WPARAM wParam, LPARAM lParam)
  104. {
  105. CGraphDlg::OnCommand(wParam,lParam);
  106. switch(LOWORD(wParam))
  107. {
  108. case IDC_OK:
  109. {
  110. if(m_uType&MB_YESNO)
  111. {
  112. EndDialog(m_hWnd,IDYES);
  113. }
  114. else
  115. if(m_uType&MB_OKCANCEL)
  116. {
  117. EndDialog(m_hWnd,IDOK);
  118. }
  119. else
  120. EndDialog(m_hWnd,IDOK);
  121. }
  122. break;
  123. case IDC_CANCEL:
  124. {
  125. if(m_uType&MB_YESNO)
  126. {
  127. EndDialog(m_hWnd,IDNO);
  128. }
  129. else
  130. if(m_uType&MB_OKCANCEL)
  131. {
  132. EndDialog(m_hWnd,IDCANCEL);
  133. }
  134. }
  135. break;
  136. }
  137. return TRUE;
  138. }
  139. /*------------------------------------------------------------------------------*/
  140. void CMsgBox::OnEraseBkgnd(HDC hdc)
  141. {
  142. CGraphDlg::OnEraseBkgnd(hdc);
  143. DrawIcon(hdc,25,45,LoadIcon(hInstX,LPCTSTR(m_uIcon)));
  144. }