home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ocl150a.zip / OCL / Source / OMsgs.cpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  4KB  |  162 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OMsgs.cpp
  5.  
  6. /*
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  13.  *    endorse or promote products derived from this software
  14.  *    without specific prior written permission.
  15.  * 3. See OCL.INF for a detailed copyright notice.
  16.  *
  17.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  */
  29.  
  30.  
  31. // $Header: W:/Projects/OCL/Source/rcs/OMsgs.cpp 1.50 1996/08/11 23:49:23 B.STEIN Release $
  32.  
  33. #define __OCL_SOURCE__
  34.  
  35. #define OINCL_OSTRING
  36. #define OINCL_BASE
  37.  
  38. #include <ocl.hpp>
  39. #include <OMsgs.hpp>
  40. #include <OMessage.hpp>
  41.  
  42.  
  43. OMsgs::OMsgs(const HMODULE moduleHandle, const HWND parent, const HWND owner)
  44.   : Parent(parent),
  45.     Owner(owner)
  46. {
  47.  handle = moduleHandle;
  48. }
  49.  
  50.  
  51. OMsgs::~OMsgs()
  52.   {}
  53.  
  54.  
  55. PSZ OMsgs::isOfType() const
  56.  return("OMsgs"); 
  57. }
  58.  
  59.  
  60. void OMsgs::setResource(const HMODULE moduleHandle)
  61. {
  62.  handle = moduleHandle; 
  63. }
  64.  
  65.  
  66. void OMsgs::info(const ULONG msgID)
  67. {
  68.  if (loadString(msgID, 2*CCHMAXPATH, Msg))
  69.    info(OCL::error(100), Msg);
  70. }
  71.  
  72.  
  73. void OMsgs::info(const ULONG titleID, const ULONG msgID)
  74. {
  75.  if ((loadString(msgID, 2*CCHMAXPATH, Msg)) && (loadString(titleID, 60, Title)))
  76.    info(Title, Msg);
  77. }
  78.  
  79.  
  80. void OMsgs::info(PCSZ msg)
  81. {
  82.  info(OCL::error(100), msg);
  83. }
  84.  
  85.  
  86. void OMsgs::info(PCSZ title, PCSZ msg)
  87. {
  88.  WinMessageBox(Parent, Owner, (PCH) msg, (PCH) title, 0,
  89.                MB_OK | MB_MOVEABLE | MB_INFORMATION);
  90. }
  91.  
  92.  
  93. void OMsgs::error(const ULONG msgID)
  94. {
  95.  if (loadString(msgID, 2*CCHMAXPATH, Msg))
  96.    error(OCL::error(101), Msg);
  97. }
  98.  
  99. void OMsgs::error(const ULONG titleID, const ULONG msgID)
  100. {
  101.  if ((loadString(msgID, 2*CCHMAXPATH, Msg)) && (loadString(titleID, 60, Title)))
  102.    error(Title, Msg);
  103. }
  104.  
  105.  
  106. void OMsgs::error(PCSZ msg)
  107. {
  108.  error(OCL::error(101), msg);
  109. }
  110.  
  111.  
  112. void OMsgs::error(PCSZ title, PCSZ msg)
  113. {
  114.  WinMessageBox(Parent, Owner, (PCH) msg, (PCH) title, 0,
  115.                MB_OK | MB_MOVEABLE | MB_CUAWARNING);
  116. }
  117.  
  118.  
  119. BOOL OMsgs::ask(const ULONG titleID, const ULONG msgID)
  120. {
  121.  if ((loadString(msgID, 2*CCHMAXPATH, Msg)) && (loadString(titleID, 60, Title)))
  122.    return(ask(Title, Msg));
  123.  else
  124.    return(FALSE);
  125. }
  126.  
  127.  
  128. BOOL OMsgs::ask(PCSZ title, PCSZ msg)
  129. {
  130.  return(WinMessageBox(Parent, Owner, (PCH)msg, (PCH)title,
  131.         0, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1)==MBID_YES);
  132. }
  133.  
  134.  
  135.  
  136. BOOL OMsgs::loadString(const ULONG resID, const ULONG Size, PSZ str)
  137. {
  138.  return(WinLoadString(OApp::current().anchor(), handle, resID, Size, str)!=0);
  139. }
  140.  
  141.  
  142. void OMsgs::beeper()
  143. {
  144.  DosBeep(100, 100);
  145.  DosBeep(200, 100);
  146.  DosBeep(300, 100);
  147. }
  148.  
  149.  
  150. PSZ OMsgs::message()
  151. {
  152.  return((PSZ)Msg);
  153. }
  154.  
  155. PSZ OMsgs::title()
  156. {
  157.  return((PSZ)Title);
  158. }
  159.  
  160. // end of source
  161.