BOOL EXPENTRY HookInit(void)
{
   if (!loaded)
   {
      /* find desktop anchor */
      mainhab = WinQueryAnchorBlock(HWND_DESKTOP);

      /* setting hook */
      if(DosQueryModuleHandle("numcomma", &hmDll))
         return FALSE;
      return WinSetHook(mainhab, NULLHANDLE, HK_INPUT, (PFN)WinHookProc, hmDll);
   }
   return FALSE;
}
// try loading each plugin module.
// if opened sucessfully, call the plugin's CBZParseAttributes(hIni, keyValue, count) function
// the plugin is responsible for writing data to the ini file.
BOOL ApplyPreviewTheme(HWND hwndPreview, char themeFile[])
{
    HINI hIni;
    int count = 0;
    char szProfile[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH];

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "Profile",
                               NULL,
                               szProfile,
                               CCHMAXPATH))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Get Profile Filename", 0UL);
        return FALSE;
    }

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "BasePath",
                               NULL,
                               szPluginBase,
                               CCHMAXPATH))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Get BasePath", 0UL);
        return FALSE;
    }


    if ((hIni = PrfOpenProfile(WinQueryAnchorBlock(hwndPreview), szProfile)) == NULLHANDLE)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Open Profile", 0UL);
        return FALSE;
    }

    count = ApplyPreviewBlock(hwndPreview, themeFile, "TITLEBAR", szPluginBase, hIni, 0);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "FRAME", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "FRAMEBRDR", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "PUSHBUTTON", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "RADIOBUTTON", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "CHECKBOX", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "MINMAX", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "MENU", szPluginBase, hIni, count);
    //insert here!!!!
    PrfCloseProfile(hIni);
    return TRUE;
}
Beispiel #3
0
/*
 *   Modified by Chris Wohlgemuth 2001 for use with CandyFolder
 */
BOOL winhAssertWarp4Notebook(HWND hwndDlg,
                    USHORT usIdThreshold,    // in: ID threshold
                    ULONG ulDownUnits)       // in: dialog units or 0
{
    BOOL brc = FALSE;
    POINTL ptl;
    HAB hab = WinQueryAnchorBlock(hwndDlg);
    BOOL    fIsVisible = WinIsWindowVisible(hwndDlg);
    if (ulDownUnits) {
        ptl.x = 0;
        ptl.y = ulDownUnits;
        WinMapDlgPoints(hwndDlg, &ptl, 1, TRUE);
    }

    WinEnableWindowUpdate(hwndDlg, FALSE);

    if (cwQueryOSRelease()>=40) {
        HENUM henum = WinBeginEnumWindows(hwndDlg);
        HWND hwndItem;
        while ((hwndItem = WinGetNextWindow(henum))!=NULLHANDLE) {
            USHORT usId = WinQueryWindowUShort(hwndItem, QWS_ID);

            if (usId <= usIdThreshold) {
                // pushbutton to change:
              WinSetWindowBits(hwndItem, QWL_STYLE,
                        BS_NOTEBOOKBUTTON, BS_NOTEBOOKBUTTON);
                brc = TRUE;
            } else
                // no pushbutton to change: move downwards
                // if desired
                if (ulDownUnits)
                {
                    SWP swp;

                    WinQueryWindowPos(hwndItem, &swp);
                    WinSetWindowPos(hwndItem, 0,
                        swp.x,
                        swp.y - ptl.y,
                        0, 0,
                        SWP_MOVE);
                }
        }
        WinEndEnumWindows(henum);
    }
    if (fIsVisible)
        WinShowWindow(hwndDlg, TRUE);
    return (brc);
}
Beispiel #4
0
// tiles an image across preview window
BOOL DrawImage(PSPAINT * pPaint, HBITMAP hbm, short sState, PLUGINSHARE* pPluginData)
{
    SIZEL slHps;
    POINTL aptl[4];
    HDC hdc;
    HPS hps;
    HAB hab = WinQueryAnchorBlock(pPaint->hwnd);


    // setup source bitmap
    hdc = DevOpenDC(hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, NULLHANDLE);

    // create source hps
    slHps.cx = pPluginData->ulCx/2;
    slHps.cy = pPluginData->ulCy/5;
    hps = GpiCreatePS(hab,
                      hdc,
                      &slHps,
                      PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);

    // set bmp into hps
    GpiSetBitmap(hps, hbm);

    // initial blt location
    aptl[0].x = pPaint->rectlWindow.xLeft;
    //aptl[0].y = pPaint->rectlWindow.yBottom;
    aptl[0].y = pPaint->rectlWindow.yBottom-1;
    aptl[1].x = pPaint->rectlWindow.xRight;
    //aptl[1].y = pPaint->rectlWindow.yTop;
    aptl[1].y = pPaint->rectlWindow.yTop-1;
    aptl[2].x = 0;
    aptl[2].y = 0;
    aptl[3].x = slHps.cx;
    aptl[3].y = slHps.cy;
     // blt
     GpiBitBlt(pPaint->hps, hps, 4L, aptl, ROP_SRCCOPY, BBO_IGNORE);

    // clean up
    GpiSetBitmap(hps, NULLHANDLE);
    GpiDestroyPS(hps);
    DevCloseDC(hdc);

    return (TRUE);


}
/****************************************************************
 DefaultOutlineFont: Set an outline font which is sizeable.
****************************************************************/
void SetOutlineFont(HPS   hps,
                    short height)

{FONTMETRICS    fm[80];
 static FATTRS  fat;
 static LONG    cFonts=0;
 LONG           ltemp=0;
 SIZEF          size;
 int            i;
 
 if (height<=2)
   return;

 if (cFonts==0) {
    GpiLoadFonts(WinQueryAnchorBlock(HWND_DESKTOP),"helv");
    cFonts= GpiQueryFonts(hps,QF_PUBLIC|QF_PRIVATE,"Helv",&ltemp,
                  sizeof(FONTMETRICS),(PFONTMETRICS)0);
    if (cFonts>sizeof(fm)/sizeof(FONTMETRICS))
      cFonts=sizeof(fm)/sizeof(FONTMETRICS);
    GpiQueryFonts(hps,QF_PUBLIC|QF_PRIVATE,"Helv",&cFonts,
                  sizeof(FONTMETRICS),fm);
    for (i=0; (!(fm[i].fsDefn&FM_DEFN_OUTLINE)) &&     //find outline and
              (!(fm[i].fsType&FM_TYPE_KERNING))  &&    //kerned if can
              (i<cFonts); i++);
    if (i==cFonts)
      for (i=0; (!(fm[i].fsDefn&FM_DEFN_OUTLINE))&&  // Find outline atleast
                (i<cFonts); i++);
    if (i==cFonts)
      i=0;

    fat.usRecordLength =sizeof(FATTRS);
    fat.lMatch         =fm[i].lMatch;
    fat.lMatch         =0;
    fat.fsFontUse      = FATTR_FONTUSE_OUTLINE;
    strcpy(fat.szFacename,fm[i].szFacename);
   }

 GpiCreateLogFont(hps,(PSTR8)0,1,&fat);
 GpiSetBackMix(hps,(LONG)BM_LEAVEALONE);
 GpiSetCharSet(hps,1);
 size.cx = MAKEFIXED(height,0);
 size.cy = MAKEFIXED(height,0);
 GpiSetCharBox(hps,&size);
 GpiSetTextAlignment(hps,TA_NORMAL_HORIZ,TA_BOTTOM);
}
// Window - окно, которое надо проверить.
BYTE WindowTypes_WindowIsPresent( HWND Window )
{
 // Проверяем, есть ли вообще такое окно.
 if( Window == NULLHANDLE ) return 0;
 if( !WinIsWindow( WinQueryAnchorBlock( Window ), Window ) ) return 0;

 // Проверяем, видимо ли оно.
 if( !WinIsWindowVisible( Window ) ) return 0;

 // Узнаем размер окна.
 RECT Rectangle = {0}; WinQueryWindowRect( Window, &Rectangle );

 // Проверяем его.
 if( Rectangle.yTop <= 1 || Rectangle.xRight <= 1 ) return 0;

 // Возврат.
 return 1;
}
void InitRecorder(PRECORDER_PARM prec)
{
   SWP             swp;
   CHAR            szTemp[CCHMAXPATH];
   ULONG           dummy = errAEBadParm;

   if(prec->pmp->Profile.testrec_cx != 0)
   {
     WinSetWindowPos(prec->hwnd,
                     HWND_TOP,
                     prec->pmp->Profile.testrec_x,
                     prec->pmp->Profile.testrec_y,
                     prec->pmp->Profile.testrec_cx,
                     prec->pmp->Profile.testrec_cy,
                     SWP_MOVE | SWP_SIZE);
     WinSetWindowPos(prec->hwndStatus,
                     HWND_TOP,
                     prec->pmp->Profile.testrecStat_x,
                     prec->pmp->Profile.testrecStat_y,
                     prec->pmp->Profile.testrecStat_cx,
                     prec->pmp->Profile.testrecStat_cy,
                     SWP_MOVE | SWP_SIZE);
   }
   else
   {
    WinQueryTaskSizePos(WinQueryAnchorBlock(prec->hwnd),0,&swp);
    WinSetWindowPos(prec->hwnd,
                    HWND_TOP,
                    swp.x,
                    swp.y,
                    swp.cx,
                    swp.cy,
                    SWP_MOVE );
   }
   WinSetWindowULong(prec->hwnd, QWL_USER, (ULONG) prec );

   prec->pmp->hwndRecordEvent = prec->hwnd;

   prec->hwndStatus = WinWindowFromID(prec->hwnd, IDD_ODRECSTATUS);
   WinSetWindowText(prec->hwndStatus, "idle");
   prec->recording = FALSE;
   WinShowWindow(prec->hwnd,TRUE);
}
extern MRESULT EXPENTRY EntryField_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {

   static PWINDOWPROC DefaultProcessor = 0 ;

   switch ( msg ) {

      case WM_CREATE: {
         CLASSINFO ClassInfo ;
         WinQueryClassInfo ( WinQueryAnchorBlock(hwnd), WC_ENTRYFIELD, &ClassInfo ) ;
         DefaultProcessor = ClassInfo.pfnWindowProc ;
         break; }

      case WM_SETFOCUS: {
         Sys_SendMessage( hwnd, EM_SETSEL, MPFROM2SHORT(0,9999), 0 ) ;
         break; }

   } /* endswitch */

   return ( DefaultProcessor ? DefaultProcessor ( hwnd, msg, mp1, mp2 ) : 0 ) ;
}
BOOL EXPENTRY PGPDLLInit(HWND hwnd)
{
    hwndPGPClient = hwnd; /* save client hwnd so we can post msgs to it */

    if (!Hooked)
    {
        /* create unique message ids (can't use WM_USER in hooks) */
        hAtomTblSystem = WinQuerySystemAtomTable();
        srand((UINT)hwnd);
        sprintf(Global.szFloatToTop,"PGPToolsFloatToTop%d",rand());
        Global.wmu_FloatToTop = WinAddAtom(hAtomTblSystem, Global.szFloatToTop);
        if(DosQueryModuleHandle("pgptools", &hRessourceModule))
           return FALSE;
        hab = WinQueryAnchorBlock(hwnd);
        WinSetHook(hab, hmqType, HK_SENDMSG, (PFN)PGPHookSendMsg, hRessourceModule);
        Hooked = TRUE;
    }

    return TRUE;
}
Beispiel #10
0
SOM_Scope void   SOMLINK WPSamFM_wpclsInitData (M_WPSamF *somSelf)
{
    /* M_WPSamFData *somThis = M_WPSamFGetData (somSelf); */
    M_WPSamFMethodDebug ("M_WPSamF","WPSamFM_wpclsInitData");

    parent_wpclsInitData (somSelf);
    _clsQueryModuleHandle (somSelf);

    /* Get Class Title */
    if (!WinLoadString (WinQueryAnchorBlock (HWND_DESKTOP),
                        _clsQueryModuleHandle (somSelf),
                        IDS_TITLE_WPSAMF,
                        sizeof (szSamFClassTitle),
                        szSamFClassTitle))
        strcpy (szSamFClassTitle, _wpclsQueryTitle (somSelf));

    M_WPSamFMethodDebug ("M_WPSamF","WPSamFM_wpclsInitData Ende");

    return;
}
Beispiel #11
0
SOM_Scope BOOL   SOMLINK WPSamFolder_wpAddSettingsPages (WPSamF *somSelf,
                HWND hwndNotebook)
{
    PAGEINFO  pageinfo;
    CHAR      szPageName[CCHMAXPGNAME];

    /* WPSamFData *somThis = WPSamFGetData (somSelf); */
    WPSamFMethodDebug ("WPSamF","WPSamFolder_wpAddSettingsPages");

    memset ((PCH)&pageinfo,0,sizeof (PAGEINFO));
    WinLoadString (WinQueryAnchorBlock (HWND_DESKTOP), hmod,
                   IDS_WPSAMF_PG1, CCHMAXPGNAME, szPageName);
    pageinfo.cb                 = sizeof (PAGEINFO);
    pageinfo.hwndPage           = NULLHANDLE;
    pageinfo.usPageStyleFlags   = BKA_MAJOR;
    pageinfo.usPageInsertFlags  = BKA_FIRST;
    pageinfo.usSettingsFlags    = SETTINGS_PAGE_NUMBERS;
    pageinfo.pfnwp              = CtxtDlgProc;
    pageinfo.resid              = hmod;
    pageinfo.dlgid              = IDD_CONTEXTMENU;
    pageinfo.pszName            = szPageName;
    pageinfo.pCreateParams      = somSelf;
    pageinfo.idDefaultHelpPanel = PANEL_CONTEXTMENU;
    pageinfo.pszHelpLibraryName = HELPFILE;

    if (!_wpInsertSettingsPage (somSelf, hwndNotebook, &pageinfo))
       {
       DebugE (D_SOM, "_wpAddSettingsPages",
                "Failed to add Context_Menu settings page");
       return (FALSE);
       }

    if (!parent_wpAddSettingsPages (somSelf, hwndNotebook))
       {
       DebugE (D_SOM, "_wpAddSettingsPages",
                " Failed to add parent's settings pages");
       return (FALSE);
       }

    return TRUE;
}
//===========================================================================
//
// Parameters --------------------------------------------------------------
// HWND hwnd : window handle
// VOID
// Return value ------------------------------------------------------------
// BOOL : TRUE/FALSE (success/error)
// VOID
//===========================================================================
static
HWND initHelp(HWND hwnd) {
   HWND hHlp;
   CHAR buf[256];
   HELPINIT hi;
   memset(&hi, 0, sizeof(HELPINIT));
   hi.cb = sizeof(HELPINIT);
   hi.phtHelpTable = PHLPTBLFROMID(HLP_MAIN);
   hi.pszHelpWindowTitle = SZ_TITLE;
   hi.fShowPanelId = CMIC_HIDE_PANEL_ID;
   hi.pszHelpLibraryName = SZFILE_HLP;
   if (!(hHlp = WinCreateHelpInstance(WinQueryAnchorBlock(hwnd), &hi)))
      return NULLHANDLE;
   if (hi.ulReturnCode) {
      WinDestroyHelpInstance(hHlp);
      hHlp = NULLHANDLE;
   } else {
      WinAssociateHelpInstance(hHlp, hwnd);
   } /* endif */
   return hHlp;
}
Beispiel #13
0
static HWND GetDesktopHWND()
{
  HAB		hab;
  HWND		hwnd;
 
  hab = WinQueryAnchorBlock(HWND_DESKTOP);
  if ( hab == NULLHANDLE )
  {
    debug( "WinQueryAnchorBlock failed.");
    return FALSE;
  }
 
  hwnd = WinQueryDesktopWindow( hab, 0 );
  if ( hwnd == NULLHANDLE )
  {
    debug( "WinQueryDesktopWindow failed." );
    return FALSE;
  }
 
  return hwnd;
}
Beispiel #14
0
// Returns the top level parent of given window
//--------------------------------------------------------------------------------
HWND GetTopLevelWindow( HWND hwnd )
{
  HWND parent;
  HWND hDesktopWindow;
  HAB hab;

  hab = WinQueryAnchorBlock( hwnd );
  hDesktopWindow = WinQueryDesktopWindow( hab, NULLHANDLE );

  while( TRUE )
  {
    parent = WinQueryWindow( hwnd, QW_PARENT );
    if (    parent == hDesktopWindow
         || parent == NULLHANDLE )
      // this is a frame (top level) window
      break;
    hwnd = parent;
  }

  return hwnd;
}
Beispiel #15
0
BOOL clbCreateProc(HWND hwnd, PCLBOXCDATA pclcd, PCREATESTRUCT pc, ULONG style) {
   PCLBOX pclb;
   HPS hps;
   // allocate structure for caching some control data
   if (!(pclb = (PCLBOX)malloc(sizeof(CLBOX)))) return FALSE;
   memset((PVOID)pclb, 0, sizeof(CLBOX));
   // copy some data
   pclb->hab = WinQueryAnchorBlock(hwnd);
   pclb->hwnd = hwnd;
   pclb->fl = pc->flStyle;
   pclb->szl.cx = pc->cx;
   pclb->szl.cy = pc->cy;
   pclb->id = pc->id;
   pclb->hOwner = pc->hwndOwner;
   // Set color control
   if (!(hps = WinGetPS(hwnd))) goto error0;
   clbUpdColors(pclb, hps);
   if ((pclb->cyFont = stSizeFont(hps)) % 2) ++pclb->cyFont;
   WinReleasePS(hps);
   // Interprets controldata
   if (!clbSetCtlData(pclb, pclcd)) goto error0;
   if (clbSetText(pclb, pc->pszText, -1)) *pc->pszText = 0;
   // reset WC_STATIC style
   WinSetWindowBits(hwnd, QWL_STYLE, style, 0xffff);
   WinSetWindowPtr(hwnd, cbWCstc, (PVOID)pclb);
   if (pfnwpWCstc(hwnd, WM_CREATE, (MPARAM)pclcd, (MPARAM)pc)) goto error1;
   // If no CLBXS_CHECK style is set to checkon flags at 1
   if (!(pclb->fl & CLBXS_CHECK)) pclb->is.chkon = 1;
   if (!clbChilds(pclb, pc)) goto error2;
   if (!(pclb->fl & WS_DISABLED)) pclb->is.enbl = 1;
   return TRUE;

   error2:
      WinDestroyWindow(hwnd);
   error1:
      if (pclb->psz) free(pclb->psz);
   error0:
      free(pclb);
      return FALSE;
}
Beispiel #16
0
Datei: kva_wo.c Projekt: komh/kva
static MRESULT EXPENTRY woNewWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    switch( msg )
    {
        case WM_ERASEBACKGROUND :
        {
            HPS     hpsFrame = ( HPS )mp1;
            PRECTL  prcl = ( PRECTL )mp2;

            GpiCreateLogColorTable( hpsFrame, 0, LCOLF_RGB, 0, 0, NULL );
            WinFillRect( hpsFrame, prcl, m_hwvs.ulKeyColor);

            return FALSE;
        }

        case WM_SIZE :
        case WM_MOVE :
        // WinMapWindowPoints() sometimes does a wrong conversion on WM_MOVE.
        // For examples, minimizing and restoring a window of Qt4.
        // So we need to setup on WM_PAINT as well in order to work around
        // this problem.
        case WM_PAINT :
        {
            RECTL rcl;

            kvaAdjustDstRect( &m_hwvs.rctlSrcRect, &rcl );
            WinMapWindowPoints( hwnd, HWND_DESKTOP, ( PPOINTL )&rcl, 2 );
            if( !WinEqualRect( WinQueryAnchorBlock( hwnd ),
                               &rcl, &m_hwvs.rctlDstRect ))
            {
                m_hwvs.rctlDstRect = rcl;
                m_pfnHWVIDEOSetup( &m_hwvs );
            }
            break; // fall through to old window proc
        }
    }

    return m_pfnwpOld( hwnd, msg, mp1, mp2 );
}
Beispiel #17
0
//----------------------------------------------------------------------------
// NPP_DestroyStream:
//----------------------------------------------------------------------------
NPError NP_LOADDS
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason) {
  if ( instance == 0 ) return NPERR_INVALID_INSTANCE_ERROR;
  PluginInstance* This = (PluginInstance*) instance->pdata;

  if ( reason == NPRES_DONE && This->bufMeta ) {
    // create metafile from buffer

    // 1-st, create empty metafile
    HAB hab=WinQueryAnchorBlock( This->hWnd );
    DEVOPENSTRUC dop;
    dop.pszLogAddress = (PSZ) NULL;
    dop.pszDriverName = "DISPLAY";
    HDC hdcMeta = DevOpenDC( hab,
        OD_METAFILE,                 /* Metafile device context             */
        "*",                         /* Ignores OS2.INI                     */
        2L,                          /* Uses first two fields               */
        (PDEVOPENDATA) &dop,         /* Device information                  */
        (HDC) NULLHANDLE );          /* Compatible device context           */
    SIZEL sizlPage={ 0, 0 };
    HPS hpsMeta = GpiCreatePS( hab, hdcMeta, &sizlPage, PU_PELS | GPIA_ASSOC );
    GpiAssociate( hpsMeta, (HDC)NULLHANDLE );
    HMF hmf = DevCloseDC( hdcMeta );
    GpiDestroyPS( hpsMeta );

    // 2-nd, add real data
    GpiSetMetaFileBits( hmf, 0, This->offMeta, This->bufMeta );
    SelectMetaFile( This, hmf );
  }
  // delete buffer
  if ( This->bufMeta ) {
    free( This->bufMeta );
    This->bufMeta=NULL;
    This->cbMeta=0;
    This->offMeta=0;
  }
  return NPERR_NO_ERROR;
}
Beispiel #18
0
HBITMAP EXPENTRY sknLoadBitmap( HWND hwnd, PSZ pszFileName )
{
   HBITMAP         ret             = 0;

   SIZEL           sizl            = { 0, 0 };  /* use same page size as device */
   DEVOPENSTRUC    dop             = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
   HAB             hab             = WinQueryAnchorBlock(hwnd);
   HDC             hdc;
   HPS             hps;

   hdc  = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
   hps  = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC);

   if(hps)
   {
      ret = LoadBitmap(hab,hdc,hps,pszFileName);
      GpiDestroyPS(hps);
   }

   DevCloseDC(hdc);

   return ret;
}
// Frame_window - текстовое окно.
VOID Clipper_EndVIOMarkingAndCopyText( HWND Frame_window )
{
 // Узнаем окно картинки.
 HWND SysMenu_window = WinWindowFromID( Frame_window, FID_SYSMENU );

 // Если окна нет - возврат.
 if( !WinIsWindow( WinQueryAnchorBlock( SysMenu_window ), SysMenu_window ) ) return;

 // Если в меню есть строки для включения выделения:
 if( MenuItemIsPresent( SysMenu_window, SM_VIO_MARK ) &&
     MenuItemIsPresent( SysMenu_window, SM_VIO_MOUSE ) )
  {
   // Если обе строки меню для включения выделения выбраны:
   if( MenuItemIsChecked( SysMenu_window, SM_VIO_MARK ) &&
       MenuItemIsChecked( SysMenu_window, SM_VIO_MOUSE ) )
    {
     // Запоминаем выделенный текст. При этом строка для включения выделения должна перестать быть включенной.
     if( MenuItemIsPresent( SysMenu_window, SM_VIO_COPY ) )
      WinSendMsg( Frame_window, WM_SYSCOMMAND, (MPARAM) SM_VIO_COPY, MPFROM2SHORT( CMDSRC_MENU, 0 ) );

     // Выключаем выделение с помощью мыши.
     WinSendMsg( Frame_window, WM_SYSCOMMAND, (MPARAM) SM_VIO_MOUSE, MPFROM2SHORT( CMDSRC_MENU, 0 ) );
     WinSendMsg( SysMenu_window, MM_SETITEMATTR, MPFROM2SHORT( SM_VIO_MOUSE, INCLUDE_SUBMENUS ), MPFROM2SHORT( MIA_CHECKED, 0 ) );

     // Если строка меню для включения выделения все еще выбрана:
     if( MenuItemIsChecked( SysMenu_window, SM_VIO_MARK ) )
      {
       // Выключаем выделение с помощью клавиатуры.
       WinSendMsg( Frame_window, WM_SYSCOMMAND, (MPARAM) SM_VIO_MARK, MPFROM2SHORT( CMDSRC_MENU, 0 ) );
       WinSendMsg( SysMenu_window, MM_SETITEMATTR, MPFROM2SHORT( SM_VIO_MARK, INCLUDE_SUBMENUS ), MPFROM2SHORT( MIA_CHECKED, 0 ) );
      }
    }
  }

 // Возврат.
 return;
}
BOOL launchPad::lpBuildObjectList(char * chrFolderID)
{
  WPObject* wpObject;

  char chrText[200];  
  ULONG ul;

  SOMClass *folderClass;
  WPFolder *wpFolder;
  char chrPath[CCHMAXPATH];
  ULONG ulBufferSize;
  HINI hIni;
  char * memPtr;
  HOBJECT *hObjectArray;
  int a;
  LPObject *lpoTemp;
  WPObject * wpTempObject;


  /* Get toolbar folder */
  if(somIsObj(wpParentFolder)) {
    folderClass=wpParentFolder->somGetClass();
    if(somIsObj(folderClass))
      wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrFolderID, FALSE);
    if(!somIsObj(wpFolder))
      return FALSE;
  }
  
  /* Build ini name */
  ulBufferSize=sizeof(chrPath);
  wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
  strcat(chrPath,"\\objects.ini");/* Ini-File containing the hobjects */
  
  do{
    /* Open the ini-file */
    if((hIni=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),chrPath))==NULLHANDLE)
      break; 
 
    if(!PrfQueryProfileSize(hIni,"objects","handles", &ulBufferSize))
      break;

    if(ulBufferSize==0)
      break;/* No entries yet */

    if((memPtr=(char*)malloc(ulBufferSize))==NULL)
      break;
    
    ulNumObjects=ulBufferSize/sizeof(HOBJECT);    

    if(!PrfQueryProfileData(hIni,"objects","handles", memPtr, &ulBufferSize)){
      free(memPtr);
      break;
    }

    hObjectArray=(HOBJECT*)memPtr;
    ulBufferSize=ulNumObjects;
    for(a=0;a<ulBufferSize && lpoTemp; a++)
      {
        wpTempObject=((M_WPObject*)folderClass)->wpclsQueryObject(hObjectArray[a]);
        if(somIsObj(wpTempObject)) {
          if((lpoTemp=new LPObject(wpTempObject->wpQueryIcon()))!=NULL) {
            lpoTemp->wpObject=wpTempObject;
            wpTempObject->wpLockObject();
            lpoTemp->hObject=hObjectArray[a];
            //            lpoTemp->hPtr=wpTempObject->wpQueryIcon();
            /* Title of the object */
            strncpy(lpoTemp->chrName, wpTempObject->wpQueryTitle(),sizeof(lpoTemp->chrName));
            lpoTemp->lpParent=this;
            
            lpoTemp->lpoNext=lpoObjectList;
            lpoObjectList=lpoTemp;
          }
        }
        else {
          ulNumObjects--;
        }
      }/* for */
    
    free(hObjectArray);
    
    PrfCloseProfile(hIni);
    return TRUE;
  }while(TRUE);

  if(hIni)
    PrfCloseProfile(hIni);
  return FALSE;

}
void
FillMenu( HWND hwndMenu )
{
  char      szPidPath[1024];
  char      szBuffer[1024];
  char*     pBuf;
  QSPTRREC* pRecHead;
  QSPREC*   pApp;
  int       numItems, iCounter;
  PVOID     pBuffer;
  PSWBLOCK  pSB;
  TASKDATA* data;
  SHORT     id = ID_ITEM_FIRST;

  // Delete all current items
  numItems = LONGFROMMR( WinSendMsg( hwndMenu, MM_QUERYITEMCOUNT, 0, 0 ));

  while( numItems-- )
  {
    MENUITEM mi;
    SHORT    id = LONGFROMMR( WinSendMsg( hwndMenu,
                              MM_ITEMIDFROMPOSITION, MPFROMSHORT(0), 0 ));

    if( WinSendMsg( hwndMenu, MM_QUERYITEM,
                    MPFROM2SHORT( id, FALSE ), MPFROMP( &mi )))
    {
      if( mi.hItem )
      {
        data = (TASKDATA*)mi.hItem;

        free( data->szTitle );
        free( data );
      }
    }

    WinSendMsg( hwndMenu, MM_DELETEITEM,
                MPFROM2SHORT( id, FALSE ), 0 );
  }

  if( bType )
  {
    // Ctrl is pressed, get the processes in the system.
    pBuf = (char*)malloc( 0x8000 );

    // Get processes
    DosQuerySysState( QS_PROCESS, 0, 0, 0, (char*)pBuf, 0x8000 );

    // Point to first process
    pRecHead = (QSPTRREC*)pBuf;
    pApp = pRecHead->pProcRec;

    // While its a process record
    while( pApp->RecType == 1 )
    {
      // Get module name for process
      memset( szPidPath, 0, _MAX_PATH );
      DosQueryModuleName( pApp->hMte, 512, szPidPath );

      if( strlen( szPidPath ) == 0 )
      {
        // If no hit is the kernel
        if( pApp->type == 1 ) {
          sprintf( szPidPath, "VDM (%d)", pApp->pid );
        } else {
          strcpy ( szPidPath, "*SYSINIT" );
        }
      }
      else
      {
        // Else trim the path
        strcpy ( szBuffer, FileGetFileExt( szPidPath ));
        sprintf( szPidPath, "%s (%d)", szBuffer, pApp->pid );
      }

      // add to menu
      data = (TASKDATA*)malloc( sizeof( TASKDATA ));
      data->szTitle = strdup( szPidPath );
      data->hWindow = NULLHANDLE;
      data->pid = pApp->pid;

      switch( pApp->type ) {
        case  0: data->hIcon = ico_os2fs;  break;
        case  1: data->hIcon = ico_dos;    break;
        case  2: data->hIcon = ico_os2vio; break;
        case  3: data->hIcon = ico_pm;     break;
        case  4: data->hIcon = ico_detach; break;
        default: data->hIcon = NULLHANDLE; break;
      }

      winhInsertMenuItem( hwndMenu, MIT_END,
                          id++, szPidPath, MIS_OWNERDRAW, 0, data );
      // get next record
      pApp=(QSPREC *)((pApp->pThrdRec) + pApp->cTCB);
    }

    free(pBuf);
  }
  else
  {
    // Get number of items in switchlist
    numItems = WinQuerySwitchList( WinQueryAnchorBlock( hwndMenu ), NULL, 0 );

    // Get all items into buffer
    pBuffer = malloc(( numItems * sizeof(SWENTRY)) + sizeof(HSWITCH));

    WinQuerySwitchList( WinQueryAnchorBlock(hwndMenu),
                        (SWBLOCK*)pBuffer,
                        (numItems * sizeof(SWENTRY)) + sizeof(HSWITCH));

    pSB = (PSWBLOCK)(pBuffer);
    for( iCounter = 0; iCounter < numItems; iCounter++ )
    {
      // Should be JUMPABLE and VISIBLE to show in list
      if( pSB->aswentry[iCounter].swctl.uchVisibility == SWL_VISIBLE )
      {

        // Put in menu
        data = (TASKDATA*)malloc( sizeof( TASKDATA ));
        data->szTitle = strdup( pSB->aswentry[iCounter].swctl.szSwtitle );
        data->hWindow = pSB->aswentry[iCounter].swctl.hwnd;
        data->pid = pSB->aswentry[iCounter].swctl.idProcess;
        CleanString( data->szTitle );

        if( pSB->aswentry[iCounter].swctl.hwndIcon != NULLHANDLE ) {
          data->hIcon = pSB->aswentry[iCounter].swctl.hwndIcon;
        } else {
          data->hIcon = (HPOINTER)WinSendMsg( data->hWindow, WM_QUERYICON, 0, 0 );
        }

        winhInsertMenuItem( hwndMenu, MIT_END, id++,
                            pSB->aswentry[iCounter].swctl.szSwtitle,
                            MIS_OWNERDRAW, 0, data );
      }
    }
    free(pBuffer);
  }
}
Beispiel #22
0
static MRESULT EXPENTRY LinkLabelProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    linkData *ld = (linkData *)WinQueryWindowULong( hwnd, QWL_USER );
    switch ( msg )
    {
    case WM_PAINT:
    {
        FONTMETRICS fm;
        FATTRS fat;
        HPS hps;
        ULONG style;
        char *text = (char *)malloc( MAXTEXTLEN );
        WinQueryWindowText( hwnd, MAXTEXTLEN, text);
        hps = WinBeginPaint( hwnd , 0L , 0L );
        GpiQueryFontMetrics( hps , sizeof( FONTMETRICS ) , &fm );
        memset( &fat , 0 , sizeof( fat ) );
        fat.usRecordLength = sizeof( FATTRS );
        fat.lMatch = fm.lMatch;
        fat.fsSelection = FATTR_SEL_UNDERSCORE;
        strcpy( fat.szFacename , fm.szFacename );
        GpiDeleteSetId( hps , 1 );
        GpiCreateLogFont( hps , 0 , 1 , &fat );
        GpiSetCharSet( hps , 1 );
        WinQueryWindowRect( hwnd , &ld->textRect );
        style = WinQueryWindowULong( hwnd, QWL_STYLE );
        style &= DT_LEFT|DT_CENTER|DT_RIGHT|DT_TOP|DT_VCENTER|DT_BOTTOM;
        WinDrawText( hps, -1, text, &ld->textRect,
                     CLR_BLUE, SYSCLR_DIALOGBACKGROUND,
                     style | DT_ERASERECT | DT_UNDERSCORE );
        WinDrawText( hps, -1, text, &ld->textRect,
                     CLR_BLUE, SYSCLR_DIALOGBACKGROUND,
                     style | DT_QUERYEXTENT | DT_UNDERSCORE );
        WinEndPaint( hps );
        free( text );
    }
    return (MRESULT)FALSE;

    case WM_MOUSEMOVE:
    {
        if ( handPtr != NULLHANDLE )
        {
            POINTL ptl;
            ptl.x = SHORT1FROMMP( mp1 );
            ptl.y = SHORT2FROMMP( mp1 );
            if ( WinPtInRect( WinQueryAnchorBlock( hwnd ), &ld->textRect, &ptl) )
            {
                WinSetPointer( HWND_DESKTOP, handPtr );
                return (MRESULT)FALSE;
            }
        }
    }
    break;

    case WM_BUTTON1CLICK:
    {
        PROGDETAILS pd;
        char *text;
        POINTL ptl;

        if ( strcmp( browserExe, "" ) == 0 )  break;

        ptl.x = SHORT1FROMMP( mp1 );
        ptl.y = SHORT2FROMMP( mp1 );
        if ( !WinPtInRect( WinQueryAnchorBlock( hwnd ), &ld->textRect, &ptl) )
            break;

        if ( ld->url == NULL )
        {
            text = (char *)malloc( MAXTEXTLEN );
            WinQueryWindowText( hwnd, MAXTEXTLEN, text);
        }
        else  text = strdup( ld->url );

        pd.Length          = sizeof( PROGDETAILS );
        pd.progt.progc     = PROG_DEFAULT;
        pd.progt.fbVisible = SHE_VISIBLE;
        pd.pszTitle        = NULL;
        pd.pszExecutable   = browserExe;
        pd.pszParameters   = NULL;
        pd.pszStartupDir   = ( browserDir[0] == 0 ) ? NULL : browserDir;
        pd.pszIcon         = NULL;
        pd.pszEnvironment  = NULL;
        pd.swpInitial.fl   = SWP_ACTIVATE;
        pd.swpInitial.cy   = 0;
        pd.swpInitial.cx   = 0;
        pd.swpInitial.y    = 0;
        pd.swpInitial.x    = 0;
        pd.swpInitial.hwndInsertBehind = HWND_TOP;
        pd.swpInitial.hwnd             = NULLHANDLE;
        pd.swpInitial.ulReserved1      = 0;
        pd.swpInitial.ulReserved2      = 0;
        WinStartApp( NULLHANDLE , &pd , text , NULL , 0 );
        free( text );
    }
    break;

    case WM_DESTROY:
        ld->labelProc( hwnd, msg, mp1, mp2 );
        if ( ld->url != NULL )  free( ld->url );
        free( ld );
        return (MRESULT)FALSE;
    }
    return ld->labelProc( hwnd, msg, mp1, mp2 );
}
MRESULT EXPENTRY EDImgWinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   // alla creazione estrae dal testo del controllo il nome della libreria
   // e l'ID della risorsa da cui ricavare l'immagine
   switch (msg) {
      case WM_CREATE: {
         LHANDLE himg;        // handle immagine
         PSZ psz;             // per ricavare nome modulo e id risorsa
         ULONG idres;         // id risorsa
         HLIB hlib;
         HAB hab;
         SIZEL szl;
   
         hab = WinQueryAnchorBlock(hwnd);
         // cerca primo tab lo cambia in 0 e carica lib
         if (!(psz = memchr((PVOID)((PCREATESTRUCT)mp2)->pszText, '\t', 9)))
            goto error0;
         *psz = 0;                          
         if (!(hlib = WinLoadLibrary(hab, ((PCREATESTRUCT)mp2)->pszText)))
            goto error0;
         // ottiene handle e dimensione immagine
         if (!(idres = strtoul(++psz, NULL, 10))) goto error1;
         if (((PCREATESTRUCT)mp2)->flStyle & (ESI_PTR | ESI_ICON | ESI_MINI)) {
            if (!(himg = WinLoadPointer(HWND_DESKTOP, hlib, idres)))
               goto error1;
            if (((PCREATESTRUCT)mp2)->flStyle & ESI_PTR) {          // pointer
               szl.cx = WgetSysValue(SV_CXPOINTER);
               szl.cy = WgetSysValue(SV_CYPOINTER);
            } else if (((PCREATESTRUCT)mp2)->flStyle & ESI_ICON) {  // icona
               szl.cx = WgetSysValue(SV_CXICON);
               szl.cy = WgetSysValue(SV_CYICON);
            } else {                               // minicona
               szl.cx = WgetSysValue(SV_CXICON) / 2;
               szl.cy = WgetSysValue(SV_CYICON) / 2;
            } // end if
         } else {                                  // bitmap
            if (!(himg = WloadBitmap(hwnd, hlib, idres)))
               goto error1;                                   
            if (!WqueryBitmapSize(himg, &szl))
               goto error2;
         } // end if
         WinDeleteLibrary(hab, hlib);
         // memorizza handle immagine
         WinSetWindowULong(hwnd, cbWCstc, (ULONG)himg);
         *((PCREATESTRUCT)mp2)->pszText = 0;
         //break;
         WinSetWindowPos(hwnd, 0, 0, 0, szl.cx, szl.cy, SWP_SIZE|SWP_NOADJUST);
         break;
         
         error2: GpiDeleteBitmap(himg);
         error1: WinDeleteLibrary(hab, hlib);
         error0: return (MRESULT)TRUE;
      } // end case WM_CREATE
      case WM_ADJUSTWINDOWPOS:    // default window processing
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
      case WM_PAINT: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         ULONG flStyle = WinQueryWindowULong(hwnd, QWL_STYLE);
         HPS hps;
         hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
         if (flStyle & (ESI_PTR | ESI_ICON | ESI_MINI)) {
            WinDrawPointer(hps, 0, 0, himg,
                           (flStyle & ESI_MINI? DP_MINI: DP_NORMAL));
         } else {
            POINTL ptl = {0,0};
            WinDrawBitmap(hps, himg, NULL, &ptl, 0, 0, DBM_NORMAL);
         } // end if
         WinEndPaint(hps);
         return (MRESULT)FALSE;
      }  // end case WM_PAINT
      // restituisce handle immagine corrente
      case SM_QUERYHANDLE:
         return (MPARAM)WinQueryWindowULong(hwnd, cbWCstc);
      // memorizza nuovo handle immagine, forza repaint e restituisce
      // handle precedente immagine
      case SM_SETHANDLE: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         if (!WinSetWindowULong(hwnd, cbWCstc, (ULONG)mp1))
            return NULLHANDLE;
         WinRefreshWin(hwnd);
         return (MRESULT)himg;
      } // end case SM_SETHANDLE
      case WM_MATCHMNEMONIC:
         return (MRESULT)FALSE;
      case WM_DESTROY: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         if (WinQueryWindowULong(hwnd, QWL_STYLE) &
                                (ESI_PTR | ESI_ICON | ESI_MINI)) {
            WinDestroyPointer(himg);
         } else {
            GpiDeleteBitmap(himg);
         } // end if
      }  break;
   } /* endswitch */
   return pfnwpWCstc(hwnd, msg, mp1, mp2); // default static controls processing
}
// *******************************************************************************
// FUNCTION:     GetBitmapFromTrack
//
// FUNCTION USE: Creates a bitmap from a rectangle structure
//
// DESCRIPTION:  This function takes the rectangle structure that is created 
//               as a result of the tracking operation and creates a bitmap 
//               of that area.  
//
// PARAMETERS:   RECTL    tracking rectangle
//
// RETURNS:      HBITMAP  bitmap handle
//
// INTERNALS:    NONE
//
// HISTORY:
//
// *******************************************************************************
HBITMAP GetBitmapFromTrack (RECTL rclTrack)
{
 HAB                hab;                           
 HBITMAP            hbmTrack;
 HDC                hdcMemory;
 HPS                hpsMemory;
 HPS                hpsScreen;
 LONG               lFormats[2];
 POINTL             aptl[3];
 SIZEL              sizl;
 BITMAPINFOHEADER2  bmp2;

 // --------------------------------------------------------------------------                    
 // Get an anchor block handle                                                                    
 // --------------------------------------------------------------------------                    
 hab = WinQueryAnchorBlock(HWND_DESKTOP);

 // --------------------------------------------------------------------------                    
 // Get a memory device context                                                                  
 // --------------------------------------------------------------------------                    
 hdcMemory = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULLHANDLE) ;

 // --------------------------------------------------------------------------                    
 // Set presentation space size                                                                
 // --------------------------------------------------------------------------                    
 sizl.cx = sizl.cy = 0 ;

 // --------------------------------------------------------------------------                             
 // Create a micro presentation space and associate it                                                                           
 // --------------------------------------------------------------------------                             
 hpsMemory = GpiCreatePS (hab,
                          hdcMemory,
                          &sizl,
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);

 // --------------------------------------------------------------------------           
 // Call GpiQueryDeviceBitmapFormats to get the number of bit planes                                   
 // --------------------------------------------------------------------------           
 GpiQueryDeviceBitmapFormats (hpsMemory,
                              2L,
                              lFormats);

 // --------------------------------------------------------------------------        
 // Initialize the bitmap info header structure                 
 // --------------------------------------------------------------------------        
 memset(&bmp2, 0, sizeof(BITMAPINFOHEADER2));

 // --------------------------------------------------------------------------                     
 // Populate the bitmap info header structure                                                    
 // --------------------------------------------------------------------------                     
 bmp2.cbFix     = sizeof bmp2;
 bmp2.cx        = (rclTrack.xRight - rclTrack.xLeft);
 bmp2.cy        = (rclTrack.yTop   - rclTrack.yBottom);
 bmp2.cPlanes   = lFormats[0];
 bmp2.cBitCount = lFormats[1];

 // --------------------------------------------------------------------------         
 // Create a bitmap representing the tracking rectangle                                
 // --------------------------------------------------------------------------         
 hbmTrack = GpiCreateBitmap (hpsMemory, &bmp2, 0L, NULL, NULL);

 if (hbmTrack == GPI_ERROR)
  {
   return GPI_ERROR;
  }

 else
  {
   // --------------------------------------------------------------------------        
   // Set the bitmap into our memory presentation space.                                                                      
   // --------------------------------------------------------------------------        
   GpiSetBitmap (hpsMemory, hbmTrack);
   hpsScreen = WinGetScreenPS (HWND_DESKTOP);
  
   aptl[0].x = 0;
   aptl[0].y = 0;
   aptl[1].x = bmp2.cx;
   aptl[1].y = bmp2.cy;
   aptl[2].x = rclTrack.xLeft;
   aptl[2].y = rclTrack.yBottom;
  
   WinLockVisRegions (HWND_DESKTOP, TRUE);
  
   // --------------------------------------------------------------------------                 
   // Bit blit the contents of the source presentation space into our target                     
   // presentation space.  This is how we copy the bitmap from the source to                     
   // the target.                                                                                
   // --------------------------------------------------------------------------                 
   GpiBitBlt (hpsMemory,      //  Target presentation space handle           
              hpsScreen,      //  Source presentation space handle           
              3L,             //  Number of Points                           
              aptl,           //  Array of Points                            
              ROP_SRCCOPY,    //  Mixing function (source copy)              
              BBO_IGNORE);    //  Options                                    
  
   WinLockVisRegions (HWND_DESKTOP, FALSE);
   WinReleasePS (hpsScreen);
  }

 // --------------------------------------------------------------------------                  
 // Free Graphics Engine Resources 
 // --------------------------------------------------------------------------                  
 GpiDestroyPS (hpsMemory);
 DevCloseDC (hdcMemory);

 // --------------------------------------------------------------------------                  
 // Return bitmap handle           
 // --------------------------------------------------------------------------                  
 return hbmTrack;
}
// *******************************************************************************                      
// FUNCTION:     DuplicateBitmap                                                                           
//                                                                                                      
// FUNCTION USE: Duplicates a bitmap                                                                        
//                                                                                                      
// DESCRIPTION:  Uses GpiBitBlt to make a copy of a bitmap by bit-bliting the 
//               contents of the source PS containing the bitmap, to the target 
//               presentation space.
//                                                                                                      
// PARAMETERS:   HBITMAP    source bitmap handle to copy                                              
//                                                                                                      
// RETURNS:      HBITMAP    target bitmap handle                                                                                                                      
//                                                                                                      
// HISTORY:                                                                                             
//                                                                                                      
// *******************************************************************************                      
HBITMAP DuplicateBitmap (HBITMAP hbmSource)                                                    
{                                                                                 
 HAB                hab;
 HBITMAP            hbmTarget;                                                        
 HDC                hdcSource;                                                
 HDC                hdcTarget;
 HPS                hpsSource;                                                
 HPS                hpsTarget;
 SIZEL              sizl;         
 POINTL             aptl[3];                                                       
 BOOL               bError = FALSE;
 BITMAPINFOHEADER2  bmp2;                                                           

 // --------------------------------------------------------------------------                      
 // Get an anchor block handle                                                                     
 // --------------------------------------------------------------------------                      
 hab = WinQueryAnchorBlock(HWND_DESKTOP);
                                                                                   
 // --------------------------------------------------------------------------                       
 // Create memory device context handles and presentation space handles                                                                      
 // --------------------------------------------------------------------------                       
 hdcSource = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULLHANDLE);                  
 hdcTarget = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULLHANDLE);                  
                                                                                   
 // --------------------------------------------------------------------------              
 // Set presentation space size                                                            
 // --------------------------------------------------------------------------              
 sizl.cx = 0;                                                         
 sizl.cy = 0;                                                            

 // --------------------------------------------------------------------------            
 // Create our source presentation space                                                           
 // --------------------------------------------------------------------------            
 hpsSource = GpiCreatePS (hab,        
                          hdcSource, 
                          &sizl,                                
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);                    
                                                                                   
 // --------------------------------------------------------------------------                
 // Create our target presentation space                                                      
 // --------------------------------------------------------------------------                
 hpsTarget = GpiCreatePS (hab, 
                          hdcTarget,                  
                          &sizl,
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);   
                                                                                   

 // --------------------------------------------------------------------------                   
 // Initialize the bitmap info header structure                                                        
 // --------------------------------------------------------------------------                                                                                    
// memset(&bmp2, NULL, sizeof(BITMAPINFOHEADER2));           

 // --------------------------------------------------------------------------         
 // Set the size of the structure                                                      
 // --------------------------------------------------------------------------         
 bmp2.cbFix = sizeof (BITMAPINFOHEADER2);                                          

 // --------------------------------------------------------------------------        
 // Get the bitmap information header from the source bitmap                                      
 // --------------------------------------------------------------------------        
 GpiQueryBitmapInfoHeader (hbmSource, &bmp2);                                         

 // --------------------------------------------------------------------------          
 // Create our target bitmap using the bitmap information header from                                                   
 // our source bitmap.
 // --------------------------------------------------------------------------          
 hbmTarget = GpiCreateBitmap (hpsTarget, &bmp2, 0L, NULL, NULL);                         
                                                                                   
 // --------------------------------------------------------------------------                                                 
 // If everything is cool, set the bitmaps into our presentation spaces.                
 // --------------------------------------------------------------------------                   
 if (hbmTarget != GPI_ERROR)                     
  {                                                                            
   GpiSetBitmap (hpsSource, hbmSource);                                              
   GpiSetBitmap (hpsTarget, hbmTarget);                                              
                                                                                   
   aptl[0].x = 0;                                                  
   aptl[0].y = 0;
   aptl[1].x = bmp2.cx;                                                         
   aptl[1].y = bmp2.cy;                                                         
   aptl[2].x = 0;                                                        
   aptl[2].y = 0;
                                                                                   
   // --------------------------------------------------------------------------        
   // Bit blit the contents of the source presentation space into our target           
   // presentation space.  This is how we copy the bitmap from the source to 
   // the target.
   // --------------------------------------------------------------------------        
   bError = GpiBitBlt (hpsTarget,      //  Target presentation space handle                    
                       hpsSource,      //  Source presentation space handle                
                       3L,             //  Number of Points                                
                       aptl,           //  Array of Points                                 
                       ROP_SRCCOPY,    //  Mixing function (source copy)         
                       BBO_IGNORE);    //  Options                                         

   // --------------------------------------------------------------------------                   
   // If we get an error copying from our source PS to our target PS                          
   // set the error flag to TRUE so that we can return GPI_ERROR back                              
   // to the caller.
   // --------------------------------------------------------------------------                   
   if (bError == GPI_ERROR) 
    {
     bError = TRUE;
    }

   // --------------------------------------------------------------------------                
   // If we got a value back from GpiBitBlt reset our error flag since                            
   // bError would be TRUE.
   // --------------------------------------------------------------------------                
   else
    {
     bError = FALSE;
    }
  }                                                                            

 // --------------------------------------------------------------------------            
 // If we get an error creating the bitmap set the bError flag to TRUE      
 // so we can return GPI_ERROR telling the caller that the function failed.
 // --------------------------------------------------------------------------            
 else
  {
   bError = TRUE;
  }

 // --------------------------------------------------------------------------                           
 // Regardless of what happens, we will free all of our graphics engine                            
 // resources by destroying our presentation spaces and device context 
 // handles.
 // --------------------------------------------------------------------------                           
 GpiDestroyPS (hpsSource);                                                           
 GpiDestroyPS (hpsTarget);                                                           
 DevCloseDC (hdcSource);                                                             
 DevCloseDC (hdcTarget);                                                             

 // --------------------------------------------------------------------------              
 // If we get an error trying to duplicate the bitmap, return GPI_ERROR.                   
 // --------------------------------------------------------------------------              
 if (bError) 
  {
   return GPI_ERROR;
  } 

 // --------------------------------------------------------------------------                          
 // If everthing worked like a champ, return the bitmap handle.                                        
 // --------------------------------------------------------------------------                          
 else
  {
   return hbmTarget;                                                                   
  }
}                                                                                 
void M_CWMenuFolder::wpclsInitData()
{
  somId mySomId;
  CLASSINFO ci;
  
  /* call parent */
  if((mySomId=somIdFromString("wpclsInitData"))!=NULLHANDLE) {
    ((somTD_M_WPObject_wpclsInitData)
     somParentNumResolve(__ClassObject->somGetPClsMtabs(),
                         1,
                         __ClassObject->
                         somGetMethodToken(mySomId))
     )(this);
    SOMFree(mySomId);
  }
  else
    M_WPFolder::wpclsInitData();

  if(!fInitDone) {
    /* Get install dir */
    queryInstallDir(chrInstallPath, sizeof(chrInstallPath));
    /* INI file path */
    queryIniFilePath(chrWPSWizIni, sizeof(chrWPSWizIni));

    /* Register new button class */
    if(WinQueryClassInfo(WinQueryAnchorBlock(HWND_DESKTOP),
                         (PSZ) WC_BUTTON,
                         &ci))
      {
        g_ulButtonDataOffset=ci.cbWindowData;
        g_pfnwpOrgButtonProc=ci.pfnWindowProc;
        
        ulQWP_WIZBUTTONDATA=g_ulButtonDataOffset;
        
        if (WinRegisterClass(WinQueryAnchorBlock(HWND_DESKTOP),
                             (PSZ) WC_WIZBUTTON,
                             fnwpWizButtonProc,
                             //  ci.pfnWindowProc, 
                             ci.flClassStyle&~CS_PUBLIC,
                             ci.cbWindowData + WIZBUTTON_DATASIZE))
          {
            /* */

          }
      }

    if(WinQueryClassInfo(WinQueryAnchorBlock(HWND_DESKTOP),
                         WC_STATIC,
                         &ci))
      {
        g_haveFlyOverClient=TRUE; /* Blended flyover window is only available if CWFolder is
                                     installed. */
      }
    
    /* Register percentbar class */
    if(!percentRegisterBarClass())
      SysWriteToTrapLog("Can't register percent bar window class.\n");
    
    /* Register REXX functions */
    RexxRegisterFunctionExe("WPSWizCallWPSFunc", (PFN)rxCallWPSFunc);
    RexxRegisterFunctionExe("WPSWizCallWinFunc", (PFN)rxCallPMFunc);
    RexxRegisterFunctionExe("WPSWizCallFunc", (PFN)rxCallCWWPSFunc);
    RexxRegisterFunctionExe("WPSWizCallWPSClsFunc", (PFN)rxCallWPSClassFunc);
    RexxRegisterFunctionExe("DevGetHash", (PFN)rxGetHash);
    /* Register the gadget REXX function */
    RexxRegisterFunctionExe("WPSWizGadgetFunc", (PFN)rxCallCWWPSFunc);
    RexxRegisterExitExe("WIZREXX", (PFN)cwRexxExitHandler, NULLHANDLE);

    /* Load Rexx error dialog */
    if(!g_hwndRexxError) {
      somTD_M_CWObject_wizclsSetRexxErrorWindowHWND methodPtr;

      g_hwndRexxError=WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP, pfnwpRexxErrorProc, 
                                 queryModuleHandle(), IDDLG_REXXERROR, NULLHANDLE);

      TRY_LOUD(ERROR_HWND) {
        /* Make sure M_CWObject class is installed and replaces the normal M_WPObject
           class. If yes, the M_CWMenuFolder class has a new static method
           "wizclsSetRexxErrorWindowHWND". */
        methodPtr=(somTD_M_CWObject_wizclsSetRexxErrorWindowHWND)
          somResolveByName( this,
                          "wizclsSetRexxErrorWindowHWND");
        //   SysWriteToTrapLog("%s: %x\n", __FUNCTION__, methodPtr);
        if(methodPtr)
          methodPtr(this, g_hwndRexxError);
          }
      CATCH(ERROR_HWND)
        {
          SysWriteToTrapLog("%s: Error while setting REXX error window HWND.\n", __FUNCTION__);
        } END_CATCH;
        
    }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static BOOL   fContinueCalc = FALSE ;
     static HAB    hab ;
     static HWND   hwndMenu ;
     static INT    iStatus = STATUS_READY ;
     static INT    iCurrentRep = IDM_10 ;
     static LONG   lCalcRep, lRepAmts [] = { 10, 100, 1000, 10000, 100000 } ;
     static ULONG  ulElapsedTime ;
     double        A ;
     LONG          lRep ;
     QMSG          qmsg ;

     switch (msg)
          {
          case WM_CREATE:
               hab = WinQueryAnchorBlock (hwnd) ;

               hwndMenu = WinWindowFromID (
                               WinQueryWindow (hwnd, QW_PARENT),
                               FID_MENU) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case IDM_10:
                    case IDM_100:
                    case IDM_1000:
                    case IDM_10000:
                    case IDM_100000:
                         WinCheckMenuItem (hwndMenu, iCurrentRep, FALSE) ;
                         iCurrentRep = COMMANDMSG(&msg)->cmd ;
                         WinCheckMenuItem (hwndMenu, iCurrentRep, TRUE) ;
                         return 0 ;

                    case IDM_START:
                         WinEnableMenuItem (hwndMenu, IDM_START, FALSE) ;
                         WinEnableMenuItem (hwndMenu, IDM_ABORT, TRUE) ;

                         iStatus = STATUS_WORKING ;
                         WinInvalidateRect (hwnd, NULL, FALSE) ;

                         lCalcRep = lRepAmts [iCurrentRep - IDM_10] ;
                         fContinueCalc = TRUE ;
                         ulElapsedTime = WinGetCurrentTime (hab) ;

                         qmsg.msg = WM_NULL ;

                         for (A = 1.0, lRep = 0 ; lRep < lCalcRep ; lRep++)
                              {
                              A = Savage (A) ;

                              while (WinPeekMsg (hab, &qmsg, NULLHANDLE,
                                                 0, 0, PM_NOREMOVE))
                                   {
                                   if (qmsg.msg == WM_QUIT)
                                        break ;

                                   WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0) ;
                                   WinDispatchMsg (hab, &qmsg) ;

                                   if (!fContinueCalc)
                                        break ;
                                   }
                              if (!fContinueCalc || qmsg.msg == WM_QUIT)
                                   break ;
                              }
                         ulElapsedTime = WinGetCurrentTime (hab) - 
                                                  ulElapsedTime ;

                         if (!fContinueCalc || qmsg.msg == WM_QUIT)
                              iStatus = STATUS_READY ;
                         else
                              iStatus = STATUS_DONE ;

                         WinInvalidateRect (hwnd, NULL, FALSE) ;

                         WinEnableMenuItem (hwndMenu, IDM_START, TRUE) ;
                         WinEnableMenuItem (hwndMenu, IDM_ABORT, FALSE) ;
                         return 0 ;

                    case IDM_ABORT:
                         fContinueCalc = FALSE ;
                         return 0 ;
                    }
               break ;

          case WM_PAINT:
               PaintWindow (hwnd, iStatus, lCalcRep, ulElapsedTime) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
static MRESULT EXPENTRY launchPadWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  WPFolder* thisPtr;
  launchPad * lp;
  LPObject *lpo;
  static USHORT id=0;//Initialisation new in V1.00a 

  switch(msg)
    {
#if 0
    case DM_ENDCONVERSATION:
    case DM_DRAGFILECOMPLETE:
    case DM_DROPNOTIFY:
    case DM_FILERENDERED:
    case DM_RENDERCOMPLETE:

break;
      return (MRESULT)FALSE;
    case WM_ENDDRAG:

      break;
      return (MRESULT)TRUE;
#endif
    case WM_PAINT:
      {
      RECTL rcl;
      launchPad * lp;

      HPS hps=WinBeginPaint(hwnd,NULLHANDLE, &rcl);
      WinFillRect(hps, &rcl, SYSCLR_DIALOGBACKGROUND);
      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()==0) {
          WinQueryWindowRect(hwnd,&rcl);
          WinDrawBorder(hps,&rcl,1,1,SYSCLR_WINDOWFRAME,SYSCLR_DIALOGBACKGROUND, DB_STANDARD);
        }
      }
      WinEndPaint(hps);
      return (MRESULT) 0;
      }
    case DM_DRAGOVER:
      return handleDragOver(hwnd, mp1, mp2);
    case DM_DROP:
      {
        ULONG ulCount;
        ULONG ulNumberOfObjects;
        PDRAGITEM pDragItem;
        SOMClass *folderClass;
        WPObject * wpObject;
        PDRAGINFO pDragInfo;
       
        TRY_LOUD(LP_FRAMEDROP) { 
          /* A new object dropped on the launchpad */
          pDragInfo=(PDRAGINFO)mp1;
          if(DrgAccessDraginfo(pDragInfo)) {
            /* Get number of items */
            ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo);           
            if(ulNumberOfObjects>1){
              /* Free the draginfo */
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
            else { 
              ulCount=0;
              
              pDragItem=DrgQueryDragitemPtr( pDragInfo, ulCount);
              wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, ulCount)->ulItemID);
              lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
              if(lp) {
                if(somIsObj(wpObject)) {
  
                  POINTL ptl;
                  int numB;
                  SWP swp;
                  
                  WinQueryWindowPos(hwnd,&swp);
                  ptl.x=pDragInfo->xDrop;
                  ptl.y=pDragInfo->yDrop;
                  /* Pos in window coords */
                  WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
                  numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta);
                  numB=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB);

                  /* Do a link */
                  lp->lpAddButton(wpObject, numB);
                  handleDragLeave(hwnd, mp1, mp2);
                }
              }
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
          }
          handleDragLeave(hwnd, mp1, mp2);
        }
        CATCH(LP_FRAMEDROP)
          {
          } END_CATCH;
          
          break;
      }
    case DM_DRAGLEAVE:
      return handleDragLeave(hwnd, mp1, mp2);
      break;
    case WM_COMMAND:
      if(SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON) {
        /* It's a push button */
        lpo=(LPObject*)WinQueryWindowULong(WinWindowFromID(hwnd,SHORT1FROMMP(mp1)),QWL_USER);
        if(lpo) {
          if(somIsObj(lpo->wpObject))
            lpo->wpObject->wpViewObject(NULLHANDLE, OPEN_DEFAULT,0);
        }
      }
      return (MRESULT)FALSE;
      /***********************************************/
      /* Stuff for fly over help                     */ 
    case WM_MOUSEMOVE:
      launchPad * lp;

      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()!=0) {
          break;
        }
      }
      
#if 0
      tempID=WinQueryWindowUShort(hwnd,QWS_ID);/*  get the id of the window under the pointer  */  			
      if(id!=tempID) {	// New Button?	
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
        id=tempID;  // Save ID 
      }
      else {
        if(!hwndBubbleWindow)
          WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay	
      }
#endif
      if(!hwndBubbleWindow)
        WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 2,(ULONG)iTBFlyOverDelay); // New timer for delay	

      break;
    case WM_DESTROY:
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running
      if(hwndBubbleWindow)
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
      hwndBubbleWindow=0;
      /* Stop delay timer if running */
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd, 2);			
      break;

    case WM_NEWBUBBLE:
      ULONG bubbleEnabled;
      HWND hwndStore;
      POINTL ptl;
      RECTL  rclWork;
      LONG  ulWinTextLen;
      POINTL aptlPoints[TXTBOX_COUNT];
      LONG   deltaX,deltaY;
      HPS  hps;
      RECTL   rcl;
  
      /*  we have to build a new information window  */
      if(hwndBubbleWindow){// if(){...} new in V1.00a 
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
        hwndBubbleWindow=NULL;
      }
      // Query the pointer position
      WinQueryPointerPos(HWND_DESKTOP,&ptl);
      WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
      WinQueryWindowRect(hwnd,&rclWork);				
      if(!hwndBubbleWindow 
         && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)
         && bTBFlyOverEnabled) {
        
        static HWND hwndBubbleClient;
        ULONG style=FCF_BORDER|FCF_NOBYTEALIGN;
        char winText[255];
        
        /* Get window text for size calculating */
            lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
        if(lp) {
          strncpy(winText, lp->lpQueryFlyOverText(), sizeof(winText));
          winText[sizeof(winText)-1]=0;
        }

        ulWinTextLen=(LONG)strlen(winText); // Query text length
        
        /* Delete 'Returns' in object title */
        char *pBuchst;
        char *pRest;
        pRest=winText;
        while((pBuchst=strchr(pRest,13))!=NULL) {
          *pBuchst=' ';
          pBuchst++;
          if(*pBuchst==10)
            *pBuchst=' ';
          pRest=pBuchst;
        }
        
        /* Create help window */
        hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP,
                                            0,
                                            &style,
                                            WC_STATIC,
                                            "",
                                            SS_TEXT|DT_CENTER|DT_VCENTER,
                                            NULLHANDLE,
                                            400,
                                            &hwndBubbleClient);

        hwndShadow=WinCreateWindow(HWND_DESKTOP,
                                   WC_STATIC,
                                   "",
                                   SS_TEXT|DT_CENTER|DT_VCENTER,
                                   0, 0,
                                   0, 0,
                                   hwndBubbleWindow,
                                   hwndBubbleWindow,
                                   401,
                                   NULLHANDLE,
                                   NULLHANDLE);
        oldProc=WinSubclassWindow(hwndShadow, shadowProc);

        // Set the font for the help
        WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE,
                        sizeof(chrTBFlyFontName),
                        chrTBFlyFontName);
        /* Calculate text size in pixel */
        hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL);
        GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints);
        WinEndPaint(hps);
        
        /* Set colors */
        WinSetPresParam(hwndBubbleClient,
                        PP_BACKGROUNDCOLOR,sizeof(rgbTBFlyBackground) ,
                        &rgbTBFlyBackground );
        WinSetPresParam(hwndBubbleClient,
                        PP_FOREGROUNDCOLOR,sizeof(rgbTBFlyForeground) ,
                        &rgbTBFlyForeground );
        
        /* Calculate bubble positon and show bubble */
        WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window
        WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size
        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x 
          > rcl.xRight 
          ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7 
	      : deltaX=0 ;
        
        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y 
          > rcl.yTop 
          ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7
	      : deltaY=0 ;		
        WinSetWindowPos(hwndBubbleWindow,
                        HWND_TOP,
                        ptl.x+xVal+deltaX,ptl.y+yVal+deltaY,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);

        WinSetWindowPos(hwndShadow,
                        hwndBubbleWindow,
                        ptl.x+xVal+deltaX+5
                        ,ptl.y+yVal+deltaY-5,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
        
        /* Set bubble text */
        WinSetWindowText(hwndBubbleClient,winText);
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35); 
      } // end if(!hwndBubbleWindow)
      break;
    case WM_TIMER:
      switch (SHORT1FROMMP(mp1))
        {
        case 1: //Intervall timer
          {
            POINTL ptl;
            RECTL  rclWork;

            /* Test pointer position */
            WinQueryPointerPos(HWND_DESKTOP, &ptl);
            WinMapWindowPoints(HWND_DESKTOP, hwnd,&ptl, 1);
            WinQueryWindowRect(hwnd, &rclWork);
            if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              {	// Window has changed				 
                WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 1);  // stop the running timer
                if(hwndBubbleWindow) 
                  WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
                hwndBubbleWindow=0;
                id=0;
              }			 			
          break;
          }
        case 2:// delay over
          {//our own timer.
            POINTL ptl;
            RECTL  rclWork;

            WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 2);//Stop the delay timer
            /* Check the pointer position */
            WinQueryPointerPos(HWND_DESKTOP,&ptl);
            WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
            WinQueryWindowRect(hwnd,&rclWork);
            if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window
            return (MRESULT)FALSE;
          }
        default:
          break;
        }
      break;
    default:
      break;    
    }
  return pfnwpOldLPProc(hwnd, msg, mp1, mp2);
}
BOOL launchPad::lpSaveObjectList()
{
  SOMClass *folderClass;
  WPFolder *wpFolder;
  char chrPath[CCHMAXPATH];
  ULONG ulBufferSize;
  HINI hIni;
  char * memPtr;
  HOBJECT *hObject;
  HOBJECT hObject2;
  int a;
  LPObject *lpoTemp;

  /* First check the config folder */
  if((hObject2=WinQueryObject(chrConfigID))==NULLHANDLE)
    {
      /* Toolbar folder lost recreate it */
      if(!checkFileExists(chrConfigTarget))
        return FALSE; /* No install dir defined */
      
      sprintf(chrPath,"OBJECTID=%s",chrConfigID);
      if((hObject2=WinCreateObject("WPFolder", chrConfigID, chrPath,chrConfigTarget,CO_FAILIFEXISTS))==NULLHANDLE)
        return FALSE; /* Can't create new toolbar folder */
    }
  
  /* Get toolbar folder */
  if(somIsObj(wpParentFolder)) {
    folderClass=wpParentFolder->somGetClass();
    if(somIsObj(folderClass))
      wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrConfigID, FALSE);
  }

  ulBufferSize=sizeof(chrPath);
  wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
  strcat(chrPath,"\\objects.ini");/* Ini-File containing the hobjects */
  
  //  WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrPath, "~launchPad", 123, MB_OK| MB_MOVEABLE);  
  do{
    /* Open the ini-file */
    if((hIni=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),chrPath))==NULLHANDLE)
      break; 

    if((memPtr=(char*)malloc(ulNumObjects*sizeof(HOBJECT)))==NULL)
      break;
    

    hObject=(HOBJECT*)memPtr;

    lpoTemp=lpoObjectList;
    for(a=ulNumObjects;a>0 && lpoTemp; a--)
      {
        hObject[a-1]=lpoTemp->hObject;
        lpoTemp=lpoTemp->lpoNext;
      }

    if(!PrfWriteProfileData(hIni,"objects","handles", hObject, ulNumObjects*sizeof(HOBJECT))) {
      free(hObject);
      break;
    }

    free(hObject);
    
    PrfCloseProfile(hIni);
    return TRUE;
  }while(TRUE);

  if(hIni)
    PrfCloseProfile(hIni);
  return FALSE;
}
MRESULT EXPENTRY fnSaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  SWP swpDlg, swpParent;
  HWND hwndDlg;
  int rc;

  switch( msg )
  {
    case WM_SUBCLASS_INIT:
		case WM_CREATE: {
			RECTL rclRect;
			// Any initialization of the window and variables should come here.

			// the timer for the moving text
			ulAnimationTimerID = WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ANIMATION_TIMER_ID, 20);

			// setup the initial coordinates for the scrolling text
			WinQueryWindowRect(hwnd, &rclRect);
			textX = rclRect.xRight;
			textY = rclRect.yTop/2;

			// Hide mouse pointer, if we're in real screen-saving mode!
			if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE);
			// Initialize WMCHAR record
			internal_InitWMCHARRecord();
		break; }

		case WM_CHAR:
		if (!bOnlyPreviewMode) internal_SaveWMCHAREventToRecord(mp1, mp2);
		break;

    case WM_ASKPASSWORD:
      {
        // Get parameters
        char *pchPwdBuff = (char *) mp1;
	int iPwdBuffSize = (int) mp2;

	// Show mouse pointer, if we're screensaving.
	if (!bOnlyPreviewMode)
	  WinShowPointer(HWND_DESKTOP, TRUE);

	hwndDlg = WinLoadDlg(hwnd, hwnd,
			     fnAutoHiderDlgProc,
			     hmodOurDLLHandle,
			     DLG_PASSWORDPROTECTION,
			     NULL);
	if (!hwndDlg)
	{
	  // Could not load dialog window resources!
	  if (!bOnlyPreviewMode)
	    WinShowPointer(HWND_DESKTOP, FALSE);

	  return (MRESULT) SSMODULE_ERROR_INTERNALERROR;
	}

        // Ok, dialog window loaded!

        // Now set its texts (NLS)
        internal_SetPageFont(hwndDlg);
        internal_SetPwdProtWindowText(hwndDlg);

        // Resize the window so text will fit!
        internal_ArrangePwdProtWindowControls(hwndDlg);

	// Initialize control(s)!
	WinSendDlgItemMsg(hwndDlg, EF_PASSWORD,
			  EM_SETTEXTLIMIT,
			  (MPARAM) (iPwdBuffSize-1),
			  (MPARAM) 0);
	WinSetDlgItemText(hwndDlg, EF_PASSWORD, "");

	// Center dialog in screen
	if (WinQueryWindowPos(hwndDlg, &swpDlg))
	  if (WinQueryWindowPos(hwnd, &swpParent))
	  {
	    // Center dialog box within the screen
	    int ix, iy;
	    ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2;
	    iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2;
	    WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0,
			    SWP_MOVE);
	  }
	WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0,
			SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);

		// Re-send WM_CHAR messages if needed
		if (bFirstKeyGoesToPwdWindow) internal_ReplayWMCHARRecord();

	// Process the dialog!
	rc = WinProcessDlg(hwndDlg);

	if (rc!=PB_OK)
	{
	  // The user pressed cancel!
          rc = SSMODULE_ERROR_USERPRESSEDCANCEL;
	} else
	{
	  // The user pressed OK!
	  // Get the entered password
	  WinQueryDlgItemText(hwndDlg, EF_PASSWORD,
			      iPwdBuffSize,
			      pchPwdBuff);
          rc = SSMODULE_NOERROR;
	}

	// Destroy window
	WinDestroyWindow(hwndDlg);

	// Hide mouse pointer again, if we're screensaving.
	if (!bOnlyPreviewMode)
	  WinShowPointer(HWND_DESKTOP, FALSE);

	return (MRESULT) rc;
      }

    case WM_SHOWWRONGPASSWORD:

      // Show mouse pointer, if we're screensaving.
      if (!bOnlyPreviewMode)
	WinShowPointer(HWND_DESKTOP, TRUE);

      hwndDlg = WinLoadDlg(hwnd, hwnd,
                           fnAutoHiderDlgProc,
                           hmodOurDLLHandle,
                           DLG_WRONGPASSWORD,
                           NULL);
      if (!hwndDlg)
      {
	// Could not load dialog window resources!

	if (!bOnlyPreviewMode)
          WinShowPointer(HWND_DESKTOP, FALSE);

        return (MRESULT) SSMODULE_ERROR_INTERNALERROR;
      }

      // Ok, dialog window loaded!

      // Now set its texts (NLS)
      internal_SetPageFont(hwndDlg);
      internal_SetWrongPwdWindowText(hwndDlg);

      // Resize the window so text will fit!
      internal_ArrangeWrongPwdWindowControls(hwndDlg);

      // Center dialog in screen
      if (WinQueryWindowPos(hwndDlg, &swpDlg))
        if (WinQueryWindowPos(hwnd, &swpParent))
        {
          // Center dialog box within the screen
          int ix, iy;
          ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2;
          iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2;
          WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0,
                          SWP_MOVE);
        }
      WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0,
                      SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);

      // Process the dialog!
      rc = WinProcessDlg(hwndDlg);

      // Destroy window
      WinDestroyWindow(hwndDlg);

      // Hide mouse pointer again, if we're screensaving.
      if (!bOnlyPreviewMode)
        WinShowPointer(HWND_DESKTOP, FALSE);

      return (MRESULT) SSMODULE_NOERROR;

    case WM_SUBCLASS_UNINIT:
    case WM_DESTROY:
      // All kinds of cleanup (the opposite of everything done in WM_CREATE)
      // should come here.


      WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ulAnimationTimerID);


      // Restore mouse pointer, if we're in real screen-saving mode!
      if (!bOnlyPreviewMode)
        WinShowPointer(HWND_DESKTOP, TRUE);
      break;

    case WM_ADJUSTWINDOWPOS:
      if (!bOnlyPreviewMode)
      {
	SWP *pSWP;

	// The following is required so that this window will be on
        // top of the xCenter window, evenif that is set to be always on top!

	// Real screensaving, here we should stay on top!
        // Set WS_TOPMOST flag again!
	WinSetWindowBits(hwnd, QWL_STYLE, WS_TOPMOST, WS_TOPMOST);

	pSWP = (SWP *) mp1;
	pSWP->hwndInsertBehind = HWND_TOP;
        pSWP->fl |= SWP_ZORDER;
      }
      break;
		case WM_PAINT: {
			HPS hpsBeginPaint;
			RECTL rclRect, blank, rclWindow;
			FONTMETRICS fm;
			int len;

			#ifdef DEBUG_LOGGING
				AddLog("WM_PAINT\n");
			#endif

			hpsBeginPaint = WinBeginPaint(hwnd, NULLHANDLE, &rclRect);
			WinQueryWindowRect(hwnd, &rclRect);
			WinQueryWindowRect(hwnd, &rclWindow);

			WinSetWindowFontMy(hwnd, "10.Courier");	
			GpiQueryFontMetrics(hpsBeginPaint, sizeof(fm), &fm);

			rclRect.xLeft = textX;
			rclRect.yTop  = textY;
			len = strlen(CfgDlgInit.pchText);
			rclRect.xRight = rclRect.xLeft + fm./*lAveCharWidth*/lMaxCharInc * len+5;
			rclRect.yBottom = rclRect.yTop - fm.lMaxBaselineExt;
			WinDrawText(hpsBeginPaint, len ,CfgDlgInit.pchText, &rclRect, CLR_WHITE, CLR_BLACK, DT_ERASERECT | DT_LEFT | DT_VCENTER);
			/* paint the black around the text*/
			blank.xLeft = 0; blank.yBottom = 0; blank.xRight = rclRect.xLeft; blank.yTop = rclWindow.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			blank.xLeft = rclRect.xLeft-2; blank.yBottom = rclRect.yTop; blank.xRight = rclWindow.xRight; blank.yTop = rclWindow.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			blank.xLeft = rclRect.xRight; blank.yBottom = 0; blank.xRight = rclWindow.xRight; blank.yTop = rclRect.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			blank.xLeft = rclRect.xLeft-2; blank.yBottom = 0; blank.xRight = rclRect.xRight+2; blank.yTop = rclRect.yBottom; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK);
			if (rclRect.xRight <= -10) {
				WinQueryWindowRect(hwnd, &rclRect);
				textX = rclRect.xRight;
				textY = rclRect.yTop/2;
			}
			WinEndPaint(hpsBeginPaint);

			#ifdef DEBUG_LOGGING
				AddLog("WM_PAINT done\n");
			#endif
			return (MRESULT) FALSE;
		}

     case WM_TIMER:
      if (((SHORT)mp1)==ANIMATION_TIMER_ID)
      {
	// Timer, so make new image position
	textX -= 2;
	WinInvalidateRect(hwnd, NULL, FALSE);
      }
      break;

    default:
      break;
  }

  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}