Changeset 9851 for trunk/src/user32


Ignore:
Timestamp:
Feb 24, 2003, 6:03:00 PM (23 years ago)
Author:
sandervl
Message:

Convert win32 icon file to os2 format when creating a shell link

Location:
trunk/src/user32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/USER32.DEF

    r9810 r9851  
    1 ; $Id: USER32.DEF,v 1.76 2003-02-16 15:31:08 sandervl Exp $
     1; $Id: USER32.DEF,v 1.77 2003-02-24 17:02:42 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    718718    _OSLibWinCreateObject@32                                     @2031 NONAME
    719719    _ConvertIconGroup@12                                         @2032 NONAME
     720    _ConvertIconGroupIndirect@12                                 @2037 NONAME
    720721
    721722    _WinSetVisibleRgnNotifyProc@12                               @2033 NONAME
  • trunk/src/user32/icon.cpp

    r7733 r9851  
    1 /* $Id: icon.cpp,v 1.14 2002-01-07 11:17:52 sandervl Exp $ */
     1/* $Id: icon.cpp,v 1.15 2003-02-24 17:02:43 sandervl Exp $ */
    22
    33/*
     
    371371//******************************************************************************
    372372//******************************************************************************
     373void *WIN32API ConvertIconGroupIndirect(void *lpIconData, DWORD iconsize,
     374                                        DWORD *ressize)
     375{
     376 ICONDIR *ihdr = (ICONDIR *)lpIconData;
     377 ICONDIRENTRY *rdir = (ICONDIRENTRY *)(ihdr + 1);
     378 int i, groupsize = 0, os2iconsize;
     379 BITMAPARRAYFILEHEADER2 *bafh, *orgbafh;
     380 WINBITMAPINFOHEADER    *iconhdr;
     381 void                   *os2icon;
     382 int                     nricons = 0;
     383 void                   *winicon;
     384
     385  dprintf(("Icon Group type :%d", ihdr->idType));
     386  dprintf(("Icon Group count:%d", ihdr->idCount));
     387  for(i=0;i<ihdr->idCount;i++) {
     388        dprintf2(("Icon    : %x", rdir->dwImageOffset));
     389        dprintf2(("Width   : %d", (int)rdir->bWidth));
     390        dprintf2(("Height  : %d", (int)rdir->bHeight));
     391        dprintf2(("Colors  : %d", (int)rdir->bColorCount));
     392        dprintf2(("Bits    : %d", rdir->wBitCount));
     393        dprintf2(("ResBytes: %d", rdir->dwBytesInRes));
     394
     395        winicon = (char *)lpIconData + rdir->dwImageOffset;
     396        groupsize += QueryConvertedIconSize((WINBITMAPINFOHEADER *)winicon,
     397                                            rdir->dwBytesInRes);
     398        //add centered icon if size is 32x32
     399        if(rdir->bWidth == 32 && rdir->bHeight == 32 && rdir->wBitCount >= 4)
     400        {
     401            groupsize += QueryConvertedIconSize((WINBITMAPINFOHEADER *)winicon,
     402                                                rdir->dwBytesInRes, TRUE);
     403            //extra pixels
     404            groupsize += (40*8 + 8*32)*rdir->wBitCount/8;
     405            nricons++;
     406        }
     407        nricons++;
     408        rdir++;
     409  }
     410  groupsize = groupsize+nricons*(sizeof(BITMAPARRAYFILEHEADER2) - sizeof(BITMAPFILEHEADER2));
     411  bafh    = (BITMAPARRAYFILEHEADER2 *)malloc(groupsize);
     412  memset(bafh, 0, groupsize);
     413  orgbafh = bafh;
     414
     415  rdir = (ICONDIRENTRY *)(ihdr + 1);
     416  for(i=0;i<ihdr->idCount;i++) {
     417        bafh->usType    = BFT_BITMAPARRAY;
     418        bafh->cbSize    = sizeof(BITMAPARRAYFILEHEADER2);
     419        bafh->cxDisplay = 0;
     420        bafh->cyDisplay = 0;
     421
     422        winicon = (char *)lpIconData + rdir->dwImageOffset;
     423        iconhdr = (WINBITMAPINFOHEADER *)winicon;
     424
     425        os2icon = ConvertIcon(iconhdr, rdir->dwBytesInRes, &os2iconsize, (ULONG)bafh - (ULONG)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
     426        if(os2icon == NULL) {
     427                dprintf(("Can't convert icon!"));
     428                rdir++;
     429                continue;
     430        }
     431
     432        if(rdir->bWidth == 32 && rdir->bHeight == 32 && rdir->wBitCount >= 4)
     433        {
     434                //add 40x40 icon by centering 32x32 icon in 40x40 grid
     435                //(resize is really ugly)
     436                bafh->offNext = (ULONG)&bafh->bfh2 - (ULONG)orgbafh + os2iconsize;
     437                memcpy((char *)&bafh->bfh2, os2icon, os2iconsize);
     438                free(os2icon);
     439
     440                bafh = (BITMAPARRAYFILEHEADER2 *)((ULONG)&bafh->bfh2 + os2iconsize);
     441
     442                os2icon = ConvertIcon(iconhdr, rdir->dwBytesInRes, &os2iconsize, (ULONG)bafh - (ULONG)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2), TRUE);
     443                if(os2icon == NULL) {
     444                        dprintf(("Can't convert icon!"));
     445                        rdir++;
     446                        continue;
     447                }
     448        }
     449
     450        if(i != ihdr->idCount -1) {
     451                bafh->offNext = (ULONG)&bafh->bfh2 - (ULONG)orgbafh + os2iconsize;
     452        }
     453        else    bafh->offNext = 0;
     454
     455        memcpy((char *)&bafh->bfh2, os2icon, os2iconsize);
     456        free(os2icon);
     457
     458        bafh = (BITMAPARRAYFILEHEADER2 *)((ULONG)&bafh->bfh2 + os2iconsize);
     459
     460        rdir++;
     461  }
     462  *ressize = groupsize;
     463  return (void *)orgbafh;
     464}
     465//******************************************************************************
     466//******************************************************************************
  • trunk/src/user32/oslibres.cpp

    r9624 r9851  
    1 /* $Id: oslibres.cpp,v 1.34 2003-01-05 16:34:58 sandervl Exp $ */
     1/* $Id: oslibres.cpp,v 1.35 2003-02-24 17:02:43 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    749749   char    szWorkDir[256];
    750750   char    szPEGUILoaderPath[256];
     751   BOOL    fWin32App;
    751752
    752753   if(pszName) {
     
    784785                                  ((pszWorkDir) ? strlen(pszWorkDir) : 0));
    785786
    786    sprintf(pszSetupString, "PROGTYPE=PM;OBJECTID=<%s>;EXENAME=%s;SET BEGINLIBPATH=%s;STARTUPDIR=%s;ICONFILE=%s;PARAMETERS=\"%s\"", pszName, szPEGUILoaderPath, szSystemDir, szWorkDir, pszIcoPath, pszPath);
     787   fWin32App = ODIN_IsWin32App(pszPath);
     788   if(!fWin32App)
     789   {//don't use the PE loader; use the program path directly
     790        sprintf(pszSetupString, "PROGTYPE=PM;OBJECTID=<%s%s>;EXENAME=%s;SET BEGINLIBPATH=%s;STARTUPDIR=%s;ICONFILE=%s;PARAMETERS=", (fDesktop) ? "DESKTOP_" : "", pszName, pszPath, szSystemDir, szWorkDir, pszIcoPath);
     791   }
     792   else sprintf(pszSetupString, "PROGTYPE=PM;OBJECTID=<%s%s>;EXENAME=%s;SET BEGINLIBPATH=%s;STARTUPDIR=%s;ICONFILE=%s;PARAMETERS=\"%s\"", (fDesktop) ? "DESKTOP_" : "", pszName, szPEGUILoaderPath, szSystemDir, szWorkDir, pszIcoPath, pszPath);
     793
    787794   if(pszArgs && *pszArgs) {
    788795       strcat(pszSetupString, " ");
     
    794801       dprintf(("Name = %s", pszName));
    795802       dprintf(("Setup string = %s", pszSetupString));
     803
     804       //Use a different name for desktop objects
    796805       hObject = WinCreateObject("WPProgram", pszName, pszSetupString,
    797806                                 "<WP_DESKTOP>", CO_REPLACEIFEXISTS);
     
    805814       hObject = WinCreateObject("WPFolder", pszFolder, szWorkDir,
    806815                                 "<ODINFOLDER>", CO_UPDATEIFEXISTS);
    807        hObject = WinCreateObject("WPProgram", pszName, pszSetupString,
    808                                  temp, CO_REPLACEIFEXISTS);
     816       if(hObject) {
     817           hObject = WinCreateObject("WPProgram", pszName, pszSetupString,
     818                                     temp, CO_REPLACEIFEXISTS);
     819       }
     820       else {
     821           hObject = 1; //force silent failure
     822       }
    809823   }
    810824
  • trunk/src/user32/user32dbg.def

    r9810 r9851  
    1 ; $Id: user32dbg.def,v 1.9 2003-02-16 15:31:11 sandervl Exp $
     1; $Id: user32dbg.def,v 1.10 2003-02-24 17:02:43 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    717717    _OSLibWinCreateObject@32                                     @2031 NONAME
    718718    _ConvertIconGroup@12                                         @2032 NONAME
     719    _ConvertIconGroupIndirect@12                                 @2037 NONAME
    719720
    720721    _WinSetVisibleRgnNotifyProc@12                               @2033 NONAME
Note: See TracChangeset for help on using the changeset viewer.