Пример #1
0
QT_BEGIN_NAMESPACE

HPS qt_alloc_mem_ps(int w, int h, HPS compat = 0)
{
    HDC hdcCompat = NULLHANDLE;
    if (compat)
        hdcCompat = GpiQueryDevice(compat);

    static PCSZ hdcData[4] = { "Display", NULL, NULL, NULL };
    HDC hdc = DevOpenDC(0, OD_MEMORY, "*", 4, (PDEVOPENDATA) hdcData, hdcCompat);
    if (!hdc) {
        qWarning( "alloc_mem_dc: DevOpenDC failed with %08lX!", WinGetLastError(0));
        return NULLHANDLE;
    }
    SIZEL size = { w, h };
    HPS hps = GpiCreatePS(0, hdc, &size, PU_PELS | GPIA_ASSOC | GPIT_MICRO);
    if (hps == NULLHANDLE) {
        qWarning("alloc_mem_dc: GpiCreatePS failed wit %08lX!", WinGetLastError(0));
        return NULLHANDLE;
    }
    // @todo later
//  if (QColor::hPal()) {
//      GpiSelectPalette(hps, QColor::hPal());
//  } else {
        // direct RGB mode
        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
//  }
    return hps;
}
Пример #2
0
void XBitmap :: CheckFilterProfile () {
   if (NULL == __XBMFProfile__)  {
      XResourceLibrary*   lib = new XResourceLibrary ("OOLGLIB");
      XGLibProcProfInit* func = (XGLibProcProfInit*) lib->LoadFunction ("OOL_GLIB_INIT");
      XBitmapFilter     dummy;
      dummy.cbFix = 0;
      DosSleep(100);

      if (NULL != func) {
         ULONG rc;
         if (0 == (rc = func (NULL, 0, 0, 0))) {
            ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
            OOLThrow (GetLastErrorMessage (lib, &rc, &dummy), rc);
         }
         DosAllocMem ((PPVOID) &__XBMFProfile__, rc, PAG_READ | PAG_WRITE | PAG_COMMIT);

         __XBMFProfile__->cbFix = rc;
         if (BFE_OK != (rc = func (__XBMFProfile__, 0, 0, 0))) {
            ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
            OOLThrow (GetLastErrorMessage (lib, &rc, &dummy), rc);
         }
         lib->UnLoadFunction ((PFNWP) func);
      } else {
         ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
         OOLThrow("Could not load function \"OOL_GLIB_INIT\" from library \"OOLGLIB.DLL\".", error);
      }
      delete lib;
   }
}
Пример #3
0
void SetMatrix( PluginInstance *This, HPS hps, PRECTL rclWin, MATRIXLF* mtlf ) {
  if ( !This->hmf ) return;
  HAB hab=WinQueryAnchorBlock( This->hWnd );
  pprintf( szPPR, "Metafile rect (%d, %d) - (%d, %d)\n\r",
    This->rclMeta.xLeft, This->rclMeta.yBottom, This->rclMeta.xRight, This->rclMeta.yTop );
  pprintf( szPPR, "Window rect (%d, %d) - (%d, %d)\n\r",
    rclWin->xLeft, rclWin->yBottom, rclWin->xRight, rclWin->yTop );
  int dxMeta=This->rclMeta.xRight-This->rclMeta.xLeft;
  int dyMeta=This->rclMeta.yTop-This->rclMeta.yBottom;
  int dxWin=rclWin->xRight-rclWin->xLeft;
  int dyWin=rclWin->yTop-rclWin->yBottom;
  FIXED afxScale[2] = { (dxWin*0x10000)/dxMeta,
                        (dyWin*0x10000)/dyMeta };
  POINTL ptlScaleOffset = { rclWin->xLeft-This->rclMeta.xLeft,
                            rclWin->yBottom-This->rclMeta.yBottom };
  if ( GpiTranslate( hps, mtlf, TRANSFORM_REPLACE, &ptlScaleOffset ) ) {
//    pprintf( szPPR, "offset= (%12d,%12d)\n\r", ptlScaleOffset.x, ptlScaleOffset.y );
//    pprMatrix( szPPR, mtlf );
  } else {
    pprintf( szPPR, "GpiTranslate failed, Err=%x\n\r",
      WinGetLastError( hab ) );
  }
  ptlScaleOffset.x=rclWin->xLeft;
  ptlScaleOffset.y=rclWin->yBottom;
  if ( GpiScale( hps, mtlf, TRANSFORM_ADD, afxScale, &ptlScaleOffset ) ) {
//    pprintf( szPPR, "scale= (%12d,%12d)\n\r", afxScale[0], afxScale[1] );
//    pprMatrix( szPPR, mtlf );
  } else {
    pprintf( szPPR, "GpiScale failed, Err=%x\n\r",
      WinGetLastError( hab ) );
  }
}
Пример #4
0
void Draw( PluginInstance *This, HPS hps, BOOL fPrinting, BOOL fReset ) {
/*
  if (fPrinting) {
    // You do not normally print a streaming plugin. We will display a
    // bounding rectangle and a message string (if it fits)
    POINTL ptl = { 0, 0 };
    GpiMove(hps, &ptl);
    GpiSetColor(hps, CLR_BLACK);
    GpiBox(hps, DRO_OUTLINE, endPoint, 0L, 0L);
    ptl.x += 40;
    ptl.y = endPoint->y/4*3;
    char *msg = "NPDRAW Plugin";
    GpiCharStringAt(hps, &ptl, strlen(msg), msg);
    ptl.y = endPoint->y/4*2;
    msg = "does not print";
    GpiCharStringAt(hps, &ptl, strlen(msg), msg);
    ptl.y = endPoint->y/4;
    msg = "streaming data.";
    GpiCharStringAt(hps, &ptl, strlen(msg), msg);
  } else
*/
  {
    if ( This->hmf ) {
      LONG lSegCount=0;
      char szDesc[20];
      LONG opt[9]={0,LT_DEFAULT,0,LC_LOADDISC,RES_NORESET,
                   SUP_DEFAULT,CTAB_REPLACE,CREA_DEFAULT,
                   DDEF_DEFAULT};
      HAB hab=WinQueryAnchorBlock( This->hWnd );
      LONG lHits=GpiPlayMetaFile( hps, This->hmf, 9L, opt, &lSegCount,
        sizeof( szDesc ), szDesc );
      if ( lHits!=GPI_OK ) pprintf( szPPR, "GpiPlayMetaFile error %d (%s)\n\r", lHits, szDesc );
      else pprintf( szPPR, "GpiPlayMetaFile OK (%s)\n\r", szDesc );
      if ( fReset ) {
        pprintf( szPPR, "Reset hps\n\r" );
        MATRIXLF   matlfSaveTransform;
        if ( GpiQueryDefaultViewMatrix( hps, 9L, &matlfSaveTransform ) ) {
          if ( GpiResetPS( hps, GRES_ALL ) ) {
            if ( GpiSetDefaultViewMatrix( hps, 9L, &matlfSaveTransform, TRANSFORM_REPLACE ) ) {
//              pprintf( szPPR, "DefaultViewMatrix preserved:\n\r" );
//              pprMatrix( szPPR, &matlfSaveTransform );
            } else {
              pprintf( szPPR, "GpiSetDefaultViewMatrix failed, Err=%x\n\r",
                WinGetLastError( hab ) );
            }
          } else {
            pprintf( szPPR, "GpiResetPS failed, Err=%x\n\r",
              WinGetLastError( hab ) );
          }
        } else {
          pprintf( szPPR, "GpiQueryDefaultViewMatrix failed, Err=%x\n\r",
            WinGetLastError( hab ) );
        }
      }
    }
  }
}
void __glutOpenOS2Connection(char* display)
{
  static char *classname=NULL;
extern HAB   hab;      /* PM anchor block handle         */
ERRORID  erridErrorCode;/* last error id code */
int ii;

  /* Make sure we register the window only once. */
  if(classname)
    return;

  classname = "GLUT";

    if ( !WinRegisterClass( hab, /* PM anchor block handle     */
             classname,/* window class name          */
             GlutWindowProc,/* address of window procedure*/
             CS_SIZEREDRAW, /* |CS_SYNCPAINT size changes cause redrawing */
             0UL ) )        /* window data                  */
    {   erridErrorCode = WinGetLastError(hab);
        ii = erridErrorCode;
          return;
    }

  classname = "GLUTCHILD";

    if ( !WinRegisterClass( hab, /* PM anchor block handle     */
             classname,/* window class name          */
             GlutWindowChildProc,/* address of window procedure*/
             CS_SIZEREDRAW, /* size changes cause redrawing */
             0UL ) )        /* window data                  */
    {   erridErrorCode = WinGetLastError(hab);
        ii = erridErrorCode;
          return;
    }

  __glutScreenWidth     = GetSystemMetrics(SM_CXSCREEN);
  __glutScreenHeight    = GetSystemMetrics(SM_CYSCREEN);

  /* Set the root window to NULL because windows creates a top-level
     window when the parent is NULL.  X creates a top-level window
     when the parent is the root window. */
  __glutRoot            = NULLHANDLE;

  /* Set the display to 1 -- we shouldn't be using this anywhere
     (except as an argument to X calls). */
  __glutDisplay         = (Display*)1;

  /* There isn't any concept of multiple screens in Win32, therefore,
     we don't need to keep track of the screen we're on... it's always
     the same one. */
  __glutScreen          = 0;
}
Пример #6
0
//----------------------------------------------------------------------------
// NPP_SetWindow:
//----------------------------------------------------------------------------
NPError NP_LOADDS
NPP_SetWindow(NPP instance, NPWindow* window) {
  pprintf( szPPR, "NPP_SetWindow\n\r" );
  if ( instance == 0 ) return NPERR_INVALID_INSTANCE_ERROR;

  PluginInstance* This = (PluginInstance*) instance->pdata;

  //
  // *Developers*: Before setting fWindow to point to the
  // new window, you may wish to compare the new window
  // info to the previous window (if any) to note window
  // size changes, etc.
  //

  // if window handle changed
  if ( This->hWnd != (HWND)window->window ) {
    pprintf( szPPR, "HWND (hmf %x) changed, %x --> %x\n\r", This->hmf, (int)This->hWnd, (int)window->window );
    // remember the new window
    This->fWindow = window;
    if ( This->hWnd ) {
      // Remove the subclass for the old client window
      WinSubclassWindow(This->hWnd, This->lpfnOldWndProc);
    }
    // remember the new window handle
    This->hWnd = (HWND)This->fWindow->window;
    // subclass the window
    This->lpfnOldWndProc = WinSubclassWindow(This->hWnd, SubClassFunc);
    AssociateInstance( This->hWnd, This );
    /* paint a background for the drawing */
    WinQueryWindowRect( This->hWnd, &This->rclWnd );
//    WinFillRect( This->hps, &This->rclWnd, CLR_PALEGRAY );
    // destroy old PS and create new PS
    if ( This->hps ) GpiDestroyPS( This->hps );
    HDC hdc = WinQueryWindowDC( This->hWnd );
    if ( !hdc ) hdc = WinOpenWindowDC( This->hWnd );
    SIZEL siz={ 0, 0 };
    HAB hab=WinQueryAnchorBlock( This->hWnd );
    This->hps = GpiCreatePS( hab, hdc, &siz,
                                  PU_PELS | GPIT_NORMAL | GPIA_ASSOC );
    pprintf( szPPR, "GpiCreatePS, hdc=%x, hps=%x\n\r", (int)hdc, (int)This->hps );
    if ( !This->hps ) {
      pprintf( szPPR, "GpiCreatePS failed, Err=%x\n\r",
        WinGetLastError( hab ) );
    }
    SetTransform( This, This->hps, &This->rclWnd );
  } else { // check if window coordinates changed.
           //It may happens for full-screan
    RECTL rcl;
    WinQueryWindowRect( This->hWnd, &rcl );
    if ( memcmp( &This->rclWnd, &rcl, sizeof( rcl ) ) ) {
      pprintf( szPPR, "Rect (hmf %x) changed, ( %d, %d ) - ( %d, %d ) --> ( %d, %d ) - ( %d, %d )\n\r",
        This->hmf,
        This->rclWnd.xLeft, This->rclWnd.yBottom, This->rclWnd.xRight, This->rclWnd.yTop,
        rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop );
      memcpy( &This->rclWnd, &rcl, sizeof( rcl ) );
      SetTransform( This, This->hps, &This->rclWnd );
    }
  }
  return NPERR_NO_ERROR;
}
Пример #7
0
void XBitmap :: SetupExportFilter (const XWindow* owner, const char* filename, XBitmapFilter* params) {
   CheckFilterProfile ();

   if (NULL == owner)    OOLThrow("invalid parameters", 1);
   if (NULL == filename) OOLThrow("invalid parameters", 2);
   if (NULL == params)   OOLThrow("invalid parameters", 3);

   XResourceLibrary* lib = new XResourceLibrary ("OOLGLIB");
   XGLibProcSetup* func = (XGLibProcSetup*) lib->LoadFunction ("OOL_GLIB_EXP_SETUP");
   DosSleep(100);

   if (NULL != func) {
      ULONG rc;

      params->hab = XApplication :: GetApplication ()->GetAnchorBlock ();
      if (BFE_OK != (rc = func (owner->GetHandle (), filename, __XBMFProfile__, params)))
         OOLThrow (GetLastErrorMessage (lib, &rc, params), rc);

      lib->UnLoadFunction ((PFNWP) func);
   } else {
      ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
      OOLThrow("Could not load function \"OOL_GLIB_EXP_SETUP\" from library \"OOLGLIB.DLL\".", error);
   }

   delete lib;
}
Пример #8
0
static int is_windowed_app( void )
/********************************/
{
    #ifdef __NT__
        return( GetActiveWindow() != NULL );
    #elif defined(__OS2__)
        int             retval = 0;
        int             rc;
        HMQ             hMessageQueue = 0;
        HAB             AnchorBlock = 0;

        AnchorBlock = WinInitialize( 0 );
        if( AnchorBlock != 0 ) {
            hMessageQueue = WinCreateMsgQueue( AnchorBlock, 0 );
            if( hMessageQueue == 0 ) {
                rc = WinGetLastError( AnchorBlock );
                if( (rc & 0xFFFF) == PMERR_MSG_QUEUE_ALREADY_EXISTS ) {
                    retval = 1;
                }
            }
        }
        if( hMessageQueue != 0 ) {
            WinDestroyMsgQueue( hMessageQueue );
        }
        if( AnchorBlock != 0 ) {
            WinTerminate( AnchorBlock );
        }
        return( retval );
    #endif
}
Пример #9
0
/*@ XBitmap::Load(const char* filename, XBitmapFilter * params, BOOL releaseParams)
@group loading a bitmap
@remarks Load a bitmap from a file. <P><I>If this method is used, GBM.DLL and OLLGLIB.DLL must be in the LIBPATH.</I> <P>Due a bug (?) in OS/2-GPI you should specify params->cBitCount = BFP_BPP_TRUECOLOR if you want to modify or resave the bitmap.
@parameters    <t 'ø' c=2>
               øchar * fileName           øfilename of the file to load
               øXBitmapFilter * params    øfiletype specific filter informations. An initialized structure has to be created by XBitmap :: GetImportFilterStruct () or XGLibFileDialog. (default is NULL)
               øBOOL releaseParams        øfilter informations will be released after usages
               <\t>
@exceptions   If the method fails to create a new bitmap an exception of the type XException is thrown.
*/
void XBitmap :: Load (const char* filename, XBitmapFilter* params, BOOL releaseParams)
{
   if (hbm) GpiDeleteBitmap(hbm); hbm = NULLHANDLE;

   XResourceLibrary* lib = new XResourceLibrary ("OOLGLIB");
   XGLibProcIO* func = (XGLibProcIO*) lib->LoadFunction ("OOL_GLIB_IMP");
   DosSleep(100);

   if (NULL != func) {
      if (owner) hps = WinGetPS (owner->GetHandle());

      ULONG rc;
      if (NULL == params) params = GetImportFilterStruct (filename);
      params->hps = hps;
      params->hbm = hbm;
      params->hab = XApplication :: GetApplication ()->GetAnchorBlock ();
      if (BFE_OK != (rc = func (filename, __XBMFProfile__, params, 0))) {
         if (releaseParams) ReleaseFilterStruct (params);
         OOLThrow (GetLastErrorMessage (lib, &rc, params), rc);
      }
      hbm = params->hbm;
      if (releaseParams) ReleaseFilterStruct (params);
      lib->UnLoadFunction ((PFNWP) func);
   } else {
      if (releaseParams) ReleaseFilterStruct (params);
      ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
      OOLThrow("Could not load function \"OOL_GLIB_IMP\" from library \"OOLGLIB.DLL\".", error);
   }

   delete lib;
   XSize s;
   GetDimensions(&s);
   width = cx = s.GetWidth();
   height = cy = s.GetHeight();
}
Пример #10
0
/*@ XBitmap::Save(const char* filename, XBitmapFilter * params, BOOL releaseParams)
@group saving a bitmap
@remarks Save a bitmap from a file. <P><I>If this method is used, GBM.DLL and OLLGLIB.DLL must be in the LIBPATH.</I> <P>Due a bug (?) in OS/2-GPI the bitmap should be in 24-bit-format.
@parameters    <t 'ø' c=2>
               øchar * fileName           øfilename of the file to load
               øXBitmapFilter * params    øfiletype specific filter informations. An initialized structure has to be created by XBitmap :: GetImportFilterStruct () or XGLibFileDialog. (default is NULL)
               øBOOL releaseParams        øfilter informations will be released after usages
               <\t>
@exceptions   If the method fails to create a new bitmap an exception of the type XException is thrown.
*/
void XBitmap :: Save (const char* filename, XBitmapFilter* params, BOOL releaseParams)
{
   XResourceLibrary* lib = new XResourceLibrary ("OOLGLIB");
   XGLibProcIO* func = (XGLibProcIO*) lib->LoadFunction ("OOL_GLIB_EXP");
   DosSleep(100);

   if (NULL != func) {
      ULONG rc;
      if (NULL == params) params = GetExportFilterStruct (filename);
      params->hps = hps;
      params->hbm = hbm;
      params->hab = XApplication :: GetApplication ()->GetAnchorBlock ();
      if (BFE_OK != (rc = func (filename, __XBMFProfile__, params, 0))) {
         if (releaseParams) ReleaseFilterStruct (params);
         OOLThrow (GetLastErrorMessage (lib, &rc, params), rc);
      }
      if (releaseParams) ReleaseFilterStruct (params);
      lib->UnLoadFunction ((PFNWP) func);
   } else {
      if (releaseParams) ReleaseFilterStruct (params);
      ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
      OOLThrow("Could not load function \"OOL_GLIB_EXP\" from library \"OOLGLIB.DLL\".", error);
   }

   delete lib;
}
Пример #11
0
void SelectMetaFile( PluginInstance *This, HMF hmf ) {
  if ( This->hmf ) GpiDeleteMetaFile( This->hmf );
  This->hmf=hmf;
  HAB hab=WinQueryAnchorBlock( This->hWnd );
  HPS hps=This->hps;
  if ( !hps ) {
    pprintf( szPPR, "No hps ???\n\r" );
    return;
  }
  //calculate bounds
  HDC hdc = WinQueryWindowDC( This->hWnd );
  if ( !hdc ) hdc = WinOpenWindowDC( This->hWnd );
  GpiResetBoundaryData( hps );
  if ( GpiAssociate( hps, NULL ) ) {
    GpiSetDrawControl( hps, DCTL_BOUNDARY, DCTL_ON );
    Draw( This, hps, FALSE, FALSE );
    if ( GpiQueryBoundaryData( hps, &This->rclMeta ) && (This->rclMeta.xLeft<This->rclMeta.xRight) ) {
      if ( !GpiAssociate( hps, hdc ) ) pprintf( szPPR, "GpfAssociate( hps, hdc ) failed\n\r" );
      GpiSetDrawControl( hps, DCTL_BOUNDARY, DCTL_OFF );
      GpiResetPS( hps, GRES_ALL);
      SetTransform( This, hps, &This->rclWnd );
    } else {
      pprintf( szPPR, "GpiQueryBoundaryData failed, Err=%x\n\r",
        WinGetLastError( hab ) );
    }
  } else pprintf( szPPR, "GpfAssociate( hps, NULL ) failed\n\r" );
  // invalidate window to ensure a redraw
  WinInvalidateRect( This->hWnd, 0, TRUE );
}
UserData *Container::allocateRecords(short num)
{
    UserData *ud;
    PVOID     pv;
    LONG      additional_space = (LONG)(sizeof(UserData)-sizeof(RECORDCORE));
    
    pv = WinSendMsg(cont,CM_ALLOCRECORD,MPFROMLONG(additional_space),MPFROMSHORT((short)num));
    if (pv == NULL)
    {
        switch(WinGetLastError(hab))
        {
             case PMERR_INSUFFICIENT_MEMORY:
                 message("PMERR_INSUFFICIENT_MEMORY");
                 break;
             case PMERR_INVALID_PARAMETERS:
                 message("PMERR_INVALID_PARAMETERS");
                 break;
            // default:
                 // message("Unknown error in Container Allocation");
        }
        ud = NULL;
    }
    else
    {
        ud = (UserData*)PVOIDFROMMR(pv);
    }
                                
    return ud;
}
Пример #13
0
VOID PumpMessageQueue( VOID )
{
    char        class_name[80];
    QMSG        qmsg;
    ERRORID     err;
    ULONG       ulCount;

    for( ;; ) {
        DosWaitEventSem( PumpMessageSem, SEM_INDEFINITE_WAIT );
        DosResetEventSem( PumpMessageSem, &ulCount );
        WinThreadAssocQueue( GUIGetHAB(), GUIPMmq );
        while ( WinGetMsg( GUIGetHAB(), &qmsg, 0L, 0, 0 ) ) {
            WinQueryClassName( qmsg.hwnd, sizeof( class_name ), class_name );
            if (strcmp( class_name, "GUIClass" ) == 0 ||
                strcmp( class_name, "WTool" ) == 0) {
                WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 );
            } else {
                WinDispatchMsg( GUIGetHAB(), &qmsg );
            }
        }
        WinThreadAssocQueue( GUIGetHAB(), NULL );
        err = WinGetLastError( GUIGetHAB() );
        DosPostEventSem( PumpMessageDoneSem );
    }
}
Пример #14
0
XBitmapFilter* XBitmap :: GetExportFilterStruct (const char* filename) {
   XBitmapFilter* filter;
   XBitmapFilter dummy;
   dummy.cbFix = 0;
   CheckFilterProfile ();

   XResourceLibrary* lib = new XResourceLibrary ("OOLGLIB");
   XGLibProcFltInit* func = (XGLibProcFltInit*) lib->LoadFunction ("OOL_GLIB_EXP_INIT");
   DosSleep(100);

   if (NULL != func) {
      ULONG          rc;
      if (0 == (rc = func (filename, __XBMFProfile__, NULL, 0)))
         OOLThrow (GetLastErrorMessage (lib, &rc, &dummy), rc);
      DosAllocMem ((PPVOID) &filter, rc, PAG_READ | PAG_WRITE | PAG_COMMIT);

      filter->cbFix = rc;
      filter->hab = XApplication :: GetApplication ()->GetAnchorBlock ();
      if (BFE_OK != (rc = func (filename, __XBMFProfile__, filter, 0)))
         OOLThrow (GetLastErrorMessage (lib, &rc, filter), rc);

      lib->UnLoadFunction ((PFNWP) func);
   } else {
      ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
      OOLThrow("Could not load function \"OOL_GLIB_EXP_INIT\" from library \"OOLGLIB.DLL\".", error);
   }

   delete lib;
   return filter;
}
Пример #15
0
BOOL StartViewer(   char* pszParameters,
                    HWND hTerminateNotify,
                    HWND hAppWindow,
                    HAB hab )
{
  PROGDETAILS Details;
  char pszMessageCaption[ 1024 ];
  HAPP hApplication;
  BOOL result;

  Details.Length                      = sizeof(PROGDETAILS);
  Details.progt.progc                 = PROG_PM;
  Details.progt.fbVisible             = SHE_VISIBLE;
  Details.pszTitle                    = "Help Viewer";
  Details.pszExecutable               = pszViewerFilename;
  Details.pszParameters               = pszParameters;
  Details.pszStartupDir               = "";
  Details.pszIcon                     = NULL; // default app icon
  Details.pszEnvironment              = NULL;
  Details.swpInitial.fl               = SWP_ACTIVATE;
  Details.swpInitial.cy               = 0;
  Details.swpInitial.cx               = 0;
  Details.swpInitial.y                = 0;
  Details.swpInitial.x                = 0;
  Details.swpInitial.hwndInsertBehind = HWND_TOP;
  Details.swpInitial.hwnd             = hAppWindow;
  Details.swpInitial.ulReserved1      = 0;
  Details.swpInitial.ulReserved2      = 0;


  LogEvent( "Launching: %s %s", Details.pszExecutable, pszParameters );

  hApplication =
    WinStartApp( hTerminateNotify,    // window to be notified of termination
                 & Details,           // details
                 NULL,                // parameters - used Details
                 NULL,                // reserved
                 SAF_INSTALLEDCMDLINE ); // options

  if ( hApplication == NULL )
  {
    LogEvent( "  Failed to launch viewer, rc=%8X", WinGetLastError( hab ) );
    sprintf( pszMessageCaption, "Unable to start help viewer %s", pszViewerFilename );
    WinMessageBox( HWND_DESKTOP, // parent
                   hAppWindow,   // owner
                   pszMessageCaption,
                   "Help Error", // title
                   0,            // ID
                   MB_OK | MB_WARNING | MB_MOVEABLE );
    result = FALSE;
  }
  else
  {
    result = TRUE;
  }

  free( pszParameters );
  return result;
}
Пример #16
0
void menu_deactivate (struct _item *L)
{
    int   rc;
    
    rc = WinPostMsg (hwndFrame, WM_FLY_UNLOADMENU, MPFROMP(L), NULL);
    debug_tools ("rc = %d from WinPostMsg in menu_deactivate; error = %d\n",
                 rc, WinGetLastError (hab));
}
Пример #17
0
ZString ZProfile::getOs2Error () const const
{
  ZFUNCTRACE_DEVELOP ("getOs2Error()");

  ZString msg;
  ERRORID err = WinGetLastError (iHab);
  switch (ERRORIDSEV (err))
      {
      case 0x0000:
        msg = "No Error - ";
        break;
      case 0x0004:
        msg = "Warning - ";
        break;
      case 0x000C:
        msg = "Severe - ";
        break;
      case 0x0010:
        msg = "Unrecoverable - ";
        break;
      case 0x0008:
      default:
        msg = "Error - ";
        break;
      }                         // switch
  switch (ERRORIDERROR (err))
      {
      case 0x1124:
        msg += "User or system initialization file cannot be closed.";
        break;
      case 0x1115:
        msg += "An invalid initialization-file handle was specified.";
        break;
      case 0x1301:
        msg += "Unable to open initialization file.";
        break;
      case 0x1309:
        msg += "An error occurred during memory management.";
        break;
      case 0x1303:
        msg += "A parameter to the function contained invalid data.";
        break;
      case 0x1304:
        msg +=
          "The application name, key name or program handle was not found.";
        break;
      case 0x110B:
        msg += "The supplied buffer was not large enough for the data.";
        break;
      case 0x130C:
        msg += "The profile string is not a valid zero-terminated string.";
        break;
      default:
        msg += ZString::hex (ERRORIDERROR (err));
      }                         // switch
  return msg;
}                               // getOs2Error
Пример #18
0
ULONG   PM_Error(HAB hab, HWND hwndOwner, ULONG ulWindow, ULONG ulStyle, UCHAR *pucMsg, PSZ pszErrMod, LONG lErrLine)
{
ERRORID     erroridCode;                /* Returned by WinGetLastError() */
PERRINFO    pErrInfoBlk;                /* Pointer to ERRINFO structure that is filled
                                           by WinGetErrorInfo */
PSZ         pszOffset;                  /* Pointer to the current error message returned
                                           by WinGetErrorInfo */
USHORT      usResponse;                 /* Message box return value */
                                        /* If no special test is given, assume empty string */
if(!pucMsg) pucMsg="";
sprintf(ErrBuffer, "%s\n\nModule: %s\nLinenumber: %ld\nError reported by PM: ",
    pucMsg, pszErrMod, lErrLine);

                                        /* Get the last error set by a PM function */
erroridCode=WinGetLastError(hab);
sprintf(ErrBuffer, "%s%08lX", ErrBuffer, (ULONG)erroridCode);
                                        /* Get last error for the current thread. We loop
                                           until no more error is found, although errors
                                           arn't stacked (but things may change) */
pErrInfoBlk=WinGetErrorInfo(hab);
                                        /* Do as long as there is an errorinfo available */
while(pErrInfoBlk!=(PERRINFO)NULL)
    {
                                        /* Find offset in array of message offsets */
    pszOffset = ((PSZ)pErrInfoBlk) + pErrInfoBlk->offaoffszMsg;
                                        /* Address error message in array of messages and 
                                           append error message to source code linenumber */
    strcat(ErrBuffer, "\nInfo: ");
    strcat(ErrBuffer, (((PSZ)pErrInfoBlk) + *((PSHORT)pszOffset)));
    WinFreeErrorInfo(pErrInfoBlk);      /* Free resource segment */
    pErrInfoBlk=WinGetErrorInfo(hab);
    }
                                        /* Broaden titlebar by spaces to make message box wider */
memset(Titlebar, ' ', TITLEBAR_LENGTH);
Titlebar[TITLEBAR_LENGTH-1]='\0';
memcpy(Titlebar, "PC/2: PM Error Message Information", sizeof("PC/2: PM Error Message Information")-1);
                                        /* If the user requested not to be prompted, don't display the
                                           message if it is just an informational one (in the future we
                                           might log to file) */
if((pHP!=NULL) && (pHP->ulRuntimeFlag & NOPROMPT) && (ulStyle & MB_INFORMATION))
    return(MB_OK);
                                        /* Signal to user via speaker */
if((pHP!=NULL) && !(pHP->ulRuntimeFlag & NOPROMPT))
    {
    DosBeep(1000,100);
    DosBeep(300,100);
    DosBeep(1000,200);
    }
usResponse=WinMessageBox(
    HWND_DESKTOP,                       /* Parent window is DESKTOP */
    hwndOwner,                          /* Owner window */
    (PSZ)ErrBuffer,                     /* General_Error message */
    Titlebar,                           /* Title bar message */
    (USHORT)ulWindow,                   /* Message box identifier for help */
    (USHORT)ulStyle);                   /* Message box style */
return(usResponse);
}
Пример #19
0
VOID DispErrorMsg(HAB hab, HWND hwndFrame, PCH FileName, LONG LineNum)
{
    PERRINFO  pErrInfoBlk;
    PSZ       pszOffSet, pszErrMsg;
    ERRORID   ErrorId;
    PCH       ErrorStr;
    CHAR      szbuff[125];

    DosBeep(800,10);
#if defined(DEBUG)
    DosBeep(800,10);
    DosBeep(800,10);
    DosBeep(800,10);
    DosBeep(800,10);
    DosBeep(800,10);
#endif   /* defined(DEBUG) */

    if (!hab)
    {                                     /* Non-PM Error */
	WinLoadString( habMain,0, IDS_UNKNOWNMSG, sizeof(szbuff), (PSZ)szbuff);
	ErrorStr = (char*) malloc(strlen(szbuff)+strlen(FileName)+10);
	sprintf(ErrorStr, szbuff, FileName, LineNum);
	WinMessageBox(HWND_DESKTOP,         /* Parent window is desk top */
		      hwndFrame,            /* Owner window is our frame */
		      (PSZ)ErrorStr,        /* PMWIN Error message       */
		      szErrorTitle,         /* Title bar message         */
		      MSGBOXID,             /* Message identifier        */
		      MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL ); /* Flags */
	free(ErrorStr);
	return;
    }

    ErrorId = WinGetLastError(hab);

    if ((pErrInfoBlk = WinGetErrorInfo(hab)) != (PERRINFO)NULL)
    {
	pszOffSet = ((PSZ)pErrInfoBlk) + pErrInfoBlk->offaoffszMsg;
	pszErrMsg = ((PSZ)pErrInfoBlk) + *((PULONG)pszOffSet);

	WinLoadString( habMain,0, IDS_ERRORMSG, sizeof(szbuff), (PSZ)szbuff);
	ErrorStr = (char *)malloc(strlen(szbuff)+strlen(pszErrMsg)+strlen(FileName)+10);
	sprintf(ErrorStr, szbuff, pszErrMsg, FileName, LineNum);

	WinMessageBox(HWND_DESKTOP,         /* Parent window is desk top */
		      hwndFrame,            /* Owner window is our frame */
		      (PSZ)ErrorStr,        /* PMWIN Error message       */
		      szErrorTitle,         /* Title bar message         */
		      MSGBOXID,             /* Message identifier        */
		      MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL ); /* Flags */

	free(ErrorStr);

	WinFreeErrorInfo(pErrInfoBlk);
    }


}
Пример #20
0
ULONG HEAbout(HWND hwnd)
{
ULONG ulrc;

    ulrc = WinDlgBox(HWND_DESKTOP,hwnd,&WinDefDlgProc,NULLHANDLE,IDD_ABOUT,NULL);
    if (ulrc == DID_ERROR)
        {
        printf("DID_ERROR: %d,%8x\n",ulrc,WinGetLastError(WinQueryAnchorBlock(hwnd)));
        }
    return 0L;
}
Пример #21
0
int winmain()
{
HAB   hab = NULLHANDLE;
HMQ   hmq = NULLHANDLE;
QMSG  qmsg;
HWND  hwndFrame = NULLHANDLE;
HWND  hwndClient = NULLHANDLE;
ULONG ctlData = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX |
		FCF_TASKLIST;

	do	{
		if ((hab = WinInitialize(0)) == NULLHANDLE) break;
		if ((hmq = WinCreateMsgQueue(hab,0)) == NULLHANDLE) break;
		if (!WinRegisterClass(hab, APPCLASS,
			ClientWndProc, CS_SIZEREDRAW, 4)) break;


		// Register the HanMLE and HanInputAutomata window class
		if (!RegisterHanAutomataClass(hab)) break;
		if (!RegisterHanEntryFieldControl(hab)) break;
		if ((hwndFrame = WinCreateStdWindow(
					HWND_DESKTOP, WS_VISIBLE,
					&ctlData,
					APPCLASS,
					APPTITLE,
					0, NULLHANDLE,
					ID_APP,
					&hwndClient )) == NULLHANDLE )
			{
			printf("errorcode: %x\n",WinGetLastError(hab));
			break;
			}

		WinSetWindowPos(hwndFrame,NULLHANDLE,
				300,300,300,200,
				SWP_MOVE|SWP_SIZE);

		houtInit(hab,256);

		while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
			{
			WinDispatchMsg(hab, &qmsg);
			}

		houtClose();

		} while (FALSE);

	if (hmq != NULLHANDLE) WinDestroyMsgQueue(hmq);
	if (hab != NULLHANDLE) WinTerminate(hab);

	return 0;
}
Пример #22
0
void SetTransform( PluginInstance *This, HPS hps, PRECTL rclWin ) {
  if ( !This->hmf ) return;
  HAB hab=WinQueryAnchorBlock( This->hWnd );
  MATRIXLF mtlf;
  SetMatrix( This, hps, rclWin, &mtlf );
  if ( GpiSetDefaultViewMatrix( hps, 9L, &mtlf, TRANSFORM_REPLACE ) ) {
//    pprintf( szPPR, "GpiSetDefaultViewMatrix done\n\r" );
//    pprMatrix( szPPR, &mtlf );
  } else {
    pprintf( szPPR, "GpiSetDefaultViewMatrix failed, Err=%x\n\r",
      WinGetLastError( hab ) );
  }
}
Пример #23
0
char* XBitmap :: GetLastErrorMessage (XResourceLibrary* lib, ULONG* pRC, XBitmapFilter* params) {
   XGLibProcError*  func = (XGLibProcError*) lib->LoadFunction ("OOL_GLIB_ERR");
   DosSleep(100);

   if (NULL != func) {
      ULONG rc;
      if (BFE_OK != (rc = func (pRC, params, (PSZ) __XBMFErrorMsg__, 1024)))
         OOLThrow ("Could not recive last error message from OOLGLIB.", rc);
      lib->UnLoadFunction ((PFNWP) func);
   } else {
      ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
      OOLThrow("Could not load function \"OOL_GLIB_ERR\" from library \"OOLGLIB.DLL\".", error);
   }
   return (char*) __XBMFErrorMsg__;
}
int main ( int argc, char *argv[] )
{
   HAB       hab;                 // used as an anchor block
   BOOL    fSuccess;             // return TRUE/FALSE from API

   hab = WinInitialize ( 0 );

   fSuccess = WinDeregisterObjectClass ( "PileOf" );

   if ( fSuccess == FALSE )
   {
     printf ( "Unable to de-register object class PileOf, error: " );
     printf ( "%d\n", ERRORIDERROR ( WinGetLastError ( hab ) ) );
   }

   WinTerminate ( hab );

   return(0);
}
Пример #25
0
/*@ XBitmap::LoadBMP(const char* filename)
@group loading a bitmap
@remarks Load a bitmap from a file. This method works faster than Load() but can only load bitmpas in OS2-BMP format
@parameters   char * fileName   filename of the file to load
@exceptions   If the method fails to create a new bitmap an exception of the type XException is thrown.
*/
void XBitmap :: LoadBMP(const char* filename)
{
   if (hbm)
      GpiDeleteBitmap(hbm);
   hbm = 0;

   XFile file;
   PBITMAPFILEHEADER p;
   if (file.Open(filename, XFILE_FAIL_IF_NEW | XFILE_OPEN_EXISTING, XFILE_READONLY, XFILE_SHARE_DENYNONE ) == 0)
   {
      XFileInfo info;
      file.GetFileInfo(&info);
      file.Seek(0, XFILE_BEGIN);
      p = (PBITMAPFILEHEADER) malloc(info.GetFileSize());
      file.Read(p, info.GetFileSize());
      file.Close();
   }
   else
      OOLThrow( "couldnït open file!", -1);

   if (owner )
   {
      hps = WinGetPS(owner->GetHandle());
      hbm = GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) &p->bmp, CBM_INIT, (PBYTE) p + p->offBits, (PBITMAPINFO2) &p->bmp);
      if(hbm == 0)
         OOLThrow("error creating bitmap", 3);
   }
   else
      SetData((BITMAPINFOHEADER2 *) &p->bmp, p->offBits);
   free(p);
   XSize s;
   GetDimensions(&s);
   width = cx = s.GetWidth();
   height = cy = s.GetHeight();

   if (hbm == GPI_ERROR)
   {
      ULONG error = WinGetLastError(XApplication::GetApplication()->GetAnchorBlock());
      OOLThrow("couldnït load bitmap", error);
   }

   return;
}
Пример #26
0
void XBitmap::Load( const ULONG id, const XResourceLibrary * lib)
{
   if (hbm)
      GpiDeleteBitmap(hbm);
   if (owner && hps == 0)
      hps = WinGetPS(owner->GetHandle());
   hbm = GpiLoadBitmap(hps, lib->GetModuleHandle(), id, 0, 0);

   if (hbm == GPI_ERROR)
   {
       ULONG error = WinGetLastError(XApplication::GetApplication()->GetAnchorBlock());
      OOLThrow("couldnït load bitmap", error);
   }

   XSize s;
   GetDimensions(&s);
   width = cx = s.GetWidth();
   height = cy = s.GetHeight();
}
Пример #27
0
Dde_Server::Dde_Server ( HAB Anchor, HMODULE Library, HWND Owner, char *AppName ) :
   Ready(FALSE), Application(AppName) {

   if ( !WinRegisterClass ( Anchor, PSZ(DDESERVER_CLASS),
      Dde_Processor, 0, sizeof(PVOID) ) ) {

      ERRORID Error = WinGetLastError ( Anchor ) ;
      ResourceString Title ( Library, IDS_TITLE ) ;
      ResourceString Format ( Library, IDS_ERROR_WINREGISTERCLASS ) ;
      CHAR Message [200] ;
      sprintf ( Message, PCHAR(Format), DDESERVER_CLASS, Error ) ;
      Log ( "%s", Message ) ;
      WinMessageBox ( HWND_DESKTOP, Owner, PSZ(Message),
         PSZ(Title), 0, MB_ENTER | MB_ICONEXCLAMATION ) ;
      return ;

   } /* endif */

   Ready = TRUE ;
}
Пример #28
0
// initializes the window PS and the off-screen buffer
VOID InitPS( const HWND hwnd )
{
    SIZEL g = { 0, 0 };

    /* we are called before the global hwndFrame is valid */
    hwndFrame = WinQueryWindow ( hwnd , QW_PARENT) ;
    wcprintf("Muell: %x", WinGetLastError( hab ) );
    hdcGlob = WinOpenWindowDC( hwnd );
    hpsGlob = GpiCreatePS( hab, hdcGlob, &g, PU_ARBITRARY | GPIT_MICRO |
			   GPIA_ASSOC );
    /*
     * Create our off-screen 'buffer'.
     */
    // hdcGlob als letzten Parameter ist neu:
    hdcBufferGlob = DevOpenDC( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdcGlob );
    hpsBufferGlob = GpiCreatePS( hab, hdcBufferGlob, &g, PU_ARBITRARY |
				 GPIT_MICRO | GPIA_ASSOC );

    /* get the device resolutions  */
    DevQueryCaps( hdcGlob, CAPS_COLOR_PLANES, 1L, &cColorPlanes );
    DevQueryCaps( hdcGlob, CAPS_COLOR_BITCOUNT, 1L, &cColorBitCount );
}
/* ********************************************************************** */
VOID
ShowErrorWindow( PSZ  pszErrorMsg, BOOL bUseLastError )
{
  CHAR      acErrorBuffer[256] ;

  if ( bUseLastError ) {
      ERRORID   errorID = WinGetLastError( hab );

      sprintf( acErrorBuffer,
               "%s \n(code = 0x%lX)",
               pszErrorMsg,
               (ULONG) errorID );
      pszErrorMsg = (PSZ) acErrorBuffer ;
  }  /* end of if ( bUseLastError ) */

  WinMessageBox( HWND_DESKTOP,
                 HWND_DESKTOP,
                 pszErrorMsg ,
                 szErrorTitle ,
                 0,
                 MB_CUACRITICAL | MB_OK );

}
void OPMException::viewError()
{
 OString   err;
 PERRINFO  pErrInfoBlk;
 PSZ       pszOffset;
 CHAR      ErrBuffer[512];

 err <<  OMessage(190, OCL::MSGFILE);
 err +   "\n";
 err +   OMessage(191, OCL::MSGFILE, Source);
 sprintf(ErrBuffer, "%d", Line);
 err +   OMessage(192, OCL::MSGFILE, ErrBuffer);
 err +   OMessage(193, OCL::MSGFILE, isOfType());
 sprintf(ErrBuffer, "%d", rc);
 err +   OMessage(194, OCL::MSGFILE, ErrBuffer);
 sprintf(ErrBuffer, "%d", WinGetLastError(OApp::current().anchor()));
 err +   OMessage(197, OCL::MSGFILE, ErrBuffer);

 strcpy(ErrBuffer, "");

 while((pErrInfoBlk = WinGetErrorInfo(OApp::current().anchor())) != (PERRINFO)NULL)
  {
   pszOffset = ((PSZ)pErrInfoBlk) + pErrInfoBlk->offaoffszMsg;
   strcat(ErrBuffer, (((PSZ)pErrInfoBlk) + *((PSHORT)pszOffset)));
   WinFreeErrorInfo(pErrInfoBlk);
  }

 err +   OMessage(198, OCL::MSGFILE, ErrBuffer);

 if (!description) 
  description << OMessage(190, OCL::MSGFILE);

 err +   OMessage(195, OCL::MSGFILE, "\n", description);

 exMsg.error("Note!", err);
}