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

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1996
  3. // All Rights Reserved
  4. // OCLVer.cpp
  5.  
  6. // this is the OCL Version Logo
  7. // we place the template stuff here
  8.  
  9. /*
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  16.  *    endorse or promote products derived from this software
  17.  *    without specific prior written permission.
  18.  * 3. See OCL.INF for a detailed copyright notice.
  19.  *
  20.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  21.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  24.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30.  * SUCH DAMAGE.
  31.  */
  32.  
  33. // $Header: W:/Projects/OCL/Source/rcs/OCL.cpp 1.50 1996/08/11 23:49:09 B.STEIN Release $
  34.  
  35.  
  36. #define __OCL_SOURCE__
  37.  
  38. #define OINCL_OSTRING
  39. #define OINCL_BASE
  40.  
  41. #include <ocl.hpp>
  42. #include <OMessage.hpp>
  43.  
  44.  
  45. OString OCL::transport;
  46. OString OCL::MSGFILE("OCL0001.MSG");
  47.  
  48.  
  49. OString& OCL::Version()
  50. {
  51.  return(OCL::Version(OCL::transport));
  52. }
  53.  
  54.  
  55. OString& OCL::Version(OString& str)
  56. {
  57.  OMessage copyright(OCL_COPYRIGHT, OCL::MSGFILE);
  58.  
  59. #ifdef __BCPLUSPLUS__
  60.    OMessage compiler(OCL_BORLAND, OCL::MSGFILE);
  61. #elif __WATCOM_CPLUSPLUS__
  62.    OMessage compiler(OCL_WATCOM, OCL::MSGFILE);
  63. #elif ((__IBMCPP__) && (__IBMCPP__ == 300))
  64.    OMessage compiler(OCL_VA, OCL::MSGFILE);
  65. #elif __IBMCPP__
  66.    OMessage compiler(OCL_CSET, OCL::MSGFILE);
  67. #elif __HIGHC__
  68.    OMessage compiler(OCL_METAWARE, OCL::MSGFILE);
  69. #elif __EMX__
  70.    OMessage compiler(OCL_EMX, OCL::MSGFILE);
  71. #endif  
  72.  
  73.  str << OMessage(OCL_VER_MSG, OCL::MSGFILE, compiler, copyright).getText();
  74.  return(str);
  75. }
  76.  
  77.  
  78. OString& OCL::error(ULONG x)
  79. {
  80.  return(OCL::transport << OMessage(x, OCL::MSGFILE).getText());
  81. }
  82.  
  83.  
  84. OString& OCL::apierror(ULONG x, APIRET rc)
  85. {
  86.  OString apimessage(OMessage((ULONG)rc).getText());
  87.  
  88.  return(OCL::transport <<  OMessage(x, OCL::MSGFILE, apimessage.getText()).getText());
  89. }
  90.  
  91.  
  92. // Enable/Disable DialogItems
  93.  
  94. void OCL::disableDialogItem(HWND hwnd, ULONG usDialogIDs[], ULONG usItemCount, ULONG ulStyle)
  95. {
  96. ULONG  usTemp;
  97.  
  98. if(ulStyle&WS_DISABLED)
  99.     for(usTemp=0; usTemp<usItemCount; usTemp++)
  100.        WinEnableWindow(WinWindowFromID(hwnd, usDialogIDs[usTemp]), FALSE);
  101. else
  102.     for(usTemp=0; usTemp<usItemCount; usTemp++)
  103.        WinEnableWindow(WinWindowFromID(hwnd, usDialogIDs[usTemp]), TRUE);
  104. if(ulStyle&WS_VISIBLE)
  105.     for(usTemp=0; usTemp<usItemCount; usTemp++)
  106.        WinSetWindowPos(WinWindowFromID(hwnd, usDialogIDs[usTemp]), 0, 0, 0, 0, 0, SWP_SHOW);
  107. else
  108.     for(usTemp=0; usTemp<usItemCount; usTemp++)
  109.        WinSetWindowPos(WinWindowFromID(hwnd, usDialogIDs[usTemp]), 0, 0, 0, 0, 0, SWP_HIDE);
  110. return;
  111. }
  112.  
  113.  
  114.  
  115. // DialogItem unsichtbar machen
  116.  
  117.  
  118. void OCL::hideDialogItem(HWND hwnd, ULONG usDialogIDs[], ULONG usItemCount)
  119. {
  120.  ULONG  usTemp;
  121.  
  122.  for(usTemp=0; usTemp<usItemCount; usTemp++)
  123.    WinSetWindowPos(WinWindowFromID(hwnd, usDialogIDs[usTemp]), 0, 0, 0, 0, 0, SWP_HIDE);
  124.  return;
  125. }
  126.  
  127.  
  128. // DialogItem sichtbar machen
  129.  
  130. void OCL::showDialogItem(HWND hwnd, ULONG usDialogIDs[], ULONG usItemCount)
  131. {
  132.  ULONG  usTemp;
  133.  
  134.  for(usTemp=0; usTemp<usItemCount; usTemp++)
  135.    WinSetWindowPos(WinWindowFromID(hwnd, usDialogIDs[usTemp]), 0, 0, 0, 0, 0, SWP_SHOW);
  136.  return;
  137. }
  138.  
  139.  
  140. // Desktop-ID wiederherstellen
  141.  
  142. BOOL OCL::saveID(PCH DESK)
  143. {
  144.  HOBJECT hObject;
  145.  
  146.  hObject=WinQueryObject((PCH) DESK);
  147.  if (hObject==NULLHANDLE)
  148.    return(FALSE);
  149.  if ((WinSetObjectData(hObject, "OBJECTID=<WP_DESKTOP>")==TRUE))
  150.    return(TRUE);
  151.  else
  152.    return(FALSE);
  153. }
  154.  
  155.  
  156. void OCL::disableControls(HWND hwnd, ULONG usDialogIDs[], ULONG count)
  157. {
  158.  disableDialogItem(hwnd, usDialogIDs, count/sizeof(ULONG), WS_VISIBLE | WS_DISABLED);
  159. }
  160.  
  161. void OCL::enableControls(HWND hwnd, ULONG usDialogIDs[], ULONG count)
  162. {
  163.  disableDialogItem(hwnd, usDialogIDs, count/sizeof(ULONG), WS_VISIBLE | 0);
  164. }
  165.  
  166. void OCL::hideControls(HWND hwnd, ULONG usDialogIDs[], ULONG count)
  167. {
  168.  hideDialogItem(hwnd, usDialogIDs, count/sizeof(ULONG));
  169. }
  170.  
  171. void OCL::showControls(HWND hwnd, ULONG usDialogIDs[], ULONG count)
  172. {
  173.  showDialogItem(hwnd, usDialogIDs, count/sizeof(ULONG));
  174. }
  175.  
  176.  
  177. APIRET OCL::startSession(STARTDATA *SessionData)
  178. {
  179.  ULONG       SessID;
  180.  PID            Pid;
  181.  CHAR         ObjBuf[100];
  182.  APIRET       rc;
  183.  STARTDATA StartData;
  184.  
  185.  memset(&StartData, 0, sizeof(StartData));
  186.  
  187.  StartData.Length = sizeof(STARTDATA);
  188.  if (SessionData->Related == 0)
  189.     StartData.Related = SSF_RELATED_INDEPENDENT;
  190.  else
  191.     StartData.Related = SessionData->Related;
  192.  if (SessionData->FgBg == 0)
  193.     StartData.FgBg = SSF_FGBG_FORE;
  194.  else
  195.     StartData.FgBg = SessionData->FgBg;
  196.  StartData.TraceOpt = SSF_TRACEOPT_NONE;
  197.  StartData.PgmTitle = SessionData->PgmTitle;
  198.  StartData.PgmName = SessionData->PgmName;
  199.  StartData.TermQ = 0;
  200.  StartData.Environment = 0;
  201.  StartData.InheritOpt = SSF_INHERTOPT_PARENT;
  202.  if (SessionData->SessionType == 0)
  203.     StartData.SessionType = SSF_TYPE_DEFAULT;
  204.  else
  205.     StartData.SessionType = SessionData->SessionType;
  206.  StartData.IconFile = 0;
  207.  StartData.PgmHandle = 0;
  208.  if (SessionData->PgmControl == 0)
  209.     StartData.PgmControl = SSF_CONTROL_VISIBLE;
  210.  else
  211.     StartData.PgmControl = SessionData -> PgmControl;
  212.  StartData.InitXPos = 50;
  213.  StartData.InitYPos = 50;
  214.  StartData.InitXSize = 400;
  215.  StartData.InitYSize = 400;
  216.  StartData.Reserved = 0;
  217.  StartData.ObjectBuffer = ObjBuf;
  218.  StartData.ObjectBuffLen = 100;
  219.  StartData.PgmInputs = SessionData->PgmInputs;
  220.  
  221.  rc = DosStartSession(&StartData, &SessID, &Pid);
  222.  
  223.  return (APIRET) rc;
  224. }
  225. // end of source
  226.