Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
2.8 KiB

  1. /**************************************************/
  2. /* */
  3. /* */
  4. /* EudcEditor Utillity funcs */
  5. /* */
  6. /* */
  7. /* Copyright (c) 1997-1999 Microsoft Corporation. */
  8. /**************************************************/
  9. #include "stdafx.h"
  10. #include "eudcedit.h"
  11. #include "util.h"
  12. /****************************************/
  13. /* */
  14. /* Output Message function */
  15. /* */
  16. /****************************************/
  17. int
  18. OutputMessageBox(
  19. HWND hWnd,
  20. UINT TitleID,
  21. UINT MessgID,
  22. BOOL OkFlag)
  23. {
  24. CString TitleStr, MessgStr;
  25. int mResult;
  26. TitleStr.LoadString( TitleID);
  27. MessgStr.LoadString( MessgID);
  28. if( OkFlag){
  29. mResult = ::MessageBox( hWnd, MessgStr, TitleStr,
  30. MB_OK | MB_ICONEXCLAMATION);
  31. }else{
  32. mResult = ::MessageBox( hWnd, MessgStr, TitleStr,
  33. MB_YESNOCANCEL | MB_ICONQUESTION);
  34. }
  35. return mResult;
  36. }
  37. #ifdef BUILD_ON_WINNT
  38. int
  39. OutputMessageBoxEx(
  40. HWND hWnd,
  41. UINT TitleID,
  42. UINT MessgID,
  43. BOOL OkFlag,
  44. ...)
  45. {
  46. CString TitleStr, MessgStr;
  47. int mResult;
  48. va_list argList;
  49. LPTSTR MessageBody;
  50. va_start(argList, OkFlag);
  51. TitleStr.LoadString( TitleID);
  52. MessgStr.LoadString( MessgID);
  53. ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_STRING,
  54. MessgStr,0,0,(LPTSTR)&MessageBody,0,&argList);
  55. if( MessageBody ) {
  56. if( OkFlag){
  57. mResult = ::MessageBox( hWnd, MessageBody, TitleStr,
  58. MB_OK | MB_ICONEXCLAMATION);
  59. }else{
  60. mResult = ::MessageBox( hWnd, MessageBody, TitleStr,
  61. MB_YESNOCANCEL | MB_ICONQUESTION);
  62. }
  63. ::LocalFree(MessageBody);
  64. }
  65. return mResult;
  66. }
  67. #endif // BUILD_ON_WINNT
  68. /****************************************/
  69. /* */
  70. /* Get String from resource */
  71. /* */
  72. /****************************************/
  73. void
  74. GetStringRes(
  75. LPTSTR lpStr,
  76. UINT sID)
  77. {
  78. CString cStr;
  79. int StrLength;
  80. TCHAR *Swap;
  81. cStr.LoadString( sID);
  82. StrLength = cStr.GetLength();
  83. Swap = cStr.GetBuffer(StrLength + 1);
  84. lstrcpy( lpStr, Swap);
  85. cStr.ReleaseBuffer();
  86. return;
  87. }
  88. /****************************************/
  89. /* */
  90. /* Convert String from resource */
  91. /* */
  92. /****************************************/
  93. void
  94. ConvStringRes(
  95. LPTSTR lpStr,
  96. CString String)
  97. {
  98. TCHAR *Swap;
  99. int StrLength = String.GetLength();
  100. Swap = String.GetBuffer(StrLength + 1);
  101. lstrcpy( lpStr, Swap);
  102. String.ReleaseBuffer();
  103. return;
  104. }
  105. #ifndef UNICODE
  106. char * Mystrrchr(char *pszString, char ch)
  107. {
  108. CHAR *p1, *p2;
  109. p1 = NULL;
  110. for (p2 = pszString; *p2; p2=CharNext(p2))
  111. {
  112. if (*p2 == ch)
  113. {
  114. p1 = p2;
  115. }
  116. }
  117. return (p1);
  118. }
  119. char * Mystrchr(char *pszString, char ch)
  120. {
  121. CHAR *p;
  122. for (p = pszString; *p; p=CharNext(p))
  123. {
  124. if (*p == ch)
  125. {
  126. return (p);
  127. }
  128. }
  129. return (NULL);
  130. }
  131. #endif