Ignore:
Timestamp:
Aug 20, 1999, 10:09:51 PM (26 years ago)
Author:
sandervl
Message:

Icon + Cursor resource changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/loadres.cpp

    r599 r601  
    1 /* $Id: loadres.cpp,v 1.6 1999-08-20 15:03:41 sandervl Exp $ */
     1/* $Id: loadres.cpp,v 1.7 1999-08-20 20:09:50 sandervl Exp $ */
    22
    33/*
     
    1414#include <winres.h>
    1515#include <heapstring.h>
     16#include <oslibres.h>
    1617
    1718//******************************************************************************
     
    7273HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon)
    7374{
    74  HICON rc;
    75 
    76     rc = (HICON)FindResourceA(hinst, lpszIcon, RT_ICONA);
    77     dprintf(("LoadIconA (%X) returned %d\n", hinst, rc));
    78     return(rc);
     75 Win32Resource *winres;
     76 HICON          hIcon;
     77
     78    hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon);
     79    if(hIcon == 0) {//not a system icon
     80        winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_ICONA);
     81        if(winres == 0) {
     82                winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA);
     83        }
     84        if(winres) {
     85                hIcon = OSLibWinCreateIcon(winres->lockOS2Resource());
     86                delete winres;
     87        }
     88    }
     89    dprintf(("LoadIconA (%X) returned %x\n", hinst, hIcon));
     90
     91    return(hIcon);
    7992}
    8093//******************************************************************************
     
    8295HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
    8396{
    84  HICON rc;
    85 
    86     rc = (HICON)FindResourceW(hinst, lpszIcon, RT_ICONW);
    87     dprintf(("LoadIconW (%X) returned %d\n", hinst, rc));
    88     return(rc);
     97 Win32Resource *winres;
     98 HICON          hIcon;
     99
     100    hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon);
     101    if(hIcon == 0) {//not a system icon
     102        winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_ICONW);
     103        if(winres == 0) {
     104                winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW);
     105        }
     106        if(winres) {
     107                hIcon = OSLibWinCreateIcon(winres->lockOS2Resource());
     108                delete winres;
     109        }
     110    }
     111    dprintf(("LoadIconW (%X) returned %x\n", hinst, hIcon));
     112
     113    return(hIcon);
    89114}
    90115//******************************************************************************
     
    92117HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor)
    93118{
    94  HCURSOR rc;
    95 
    96     if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
    97          dprintf(("LoadCursor %s\n", lpszCursor));
    98          lpszCursor = (LPCSTR)ConvertNameId(hinst, (char *)lpszCursor);
    99     }
    100     else dprintf(("LoadCursor %d\n", (int)lpszCursor));
    101 
    102     rc = O32_LoadCursor(hinst, lpszCursor);
    103 
    104     dprintf(("LoadCursor from %X returned %d\n", hinst, rc));
    105     return(rc);
     119 Win32Resource *winres;
     120 HCURSOR        hCursor;
     121
     122    hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor);
     123    if(hCursor == 0) {//not a system pointer
     124        winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_CURSORA);
     125        if(winres == 0) {
     126                winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_GROUP_CURSORA);
     127        }
     128        if(winres) {
     129                hCursor = OSLibWinCreatePointer(winres->lockOS2Resource());
     130                delete winres;
     131        }
     132    }
     133    dprintf(("LoadCursorA (%X) returned %x\n", hinst, hCursor));
     134
     135    return(hCursor);
     136}
     137//******************************************************************************
     138//******************************************************************************
     139HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
     140{
     141 Win32Resource *winres;
     142 HCURSOR        hCursor;
     143
     144    hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor);
     145    if(hCursor == 0) {//not a system pointer
     146        winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_CURSORW);
     147        if(winres == 0) {
     148                winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_GROUP_CURSORW);
     149        }
     150        if(winres) {
     151                hCursor = OSLibWinCreatePointer(winres->lockOS2Resource());
     152                delete winres;
     153        }
     154    }
     155    dprintf(("LoadCursorW (%X) returned %x\n", hinst, hCursor));
     156
     157    return(hCursor);
    106158}
    107159//******************************************************************************
     
    111163 HBITMAP rc;
    112164
    113   if((int)lpszBitmap >> 16 != 0)
    114   {  //convert string name identifier to numeric id
    115     dprintf(("lpszBitmap [%s]\n",
    116              lpszBitmap));
     165  if(HIWORD(lpszBitmap) != 0)
     166  {     //convert string name identifier to numeric id
     167        dprintf(("lpszBitmap [%s]\n", lpszBitmap));
    117168   
    118     lpszBitmap = (LPCSTR)ConvertNameId(hinst,
    119                                        (char *)lpszBitmap);
     169        lpszBitmap = (LPCSTR)ConvertNameId(hinst, (char *)lpszBitmap);
    120170  }
    121   else
    122     dprintf(("lpszBitmap %08xh\n",
    123              (int)lpszBitmap));
     171  else  dprintf(("lpszBitmap %08xh\n", (int)lpszBitmap));
    124172
    125173  rc = O32_LoadBitmap(hinst, lpszBitmap);
    126174
    127   dprintf(("LoadBitmapA returned %08xh\n",
    128            rc));
     175  dprintf(("LoadBitmapA returned %08xh\n", rc));
    129176 
    130177  return(rc);
     
    137184 HBITMAP rc;
    138185
    139     if((int)lpszBitmap >> 16 != 0) {//convert string name identifier to numeric id
     186    if(HIWORD(lpszBitmap) != 0) {//convert string name identifier to numeric id
    140187         astring = UnicodeToAsciiString((LPWSTR)lpszBitmap);
    141188         dprintf(("lpszBitmap %s\n", astring));
     
    153200}
    154201//******************************************************************************
    155 //******************************************************************************
    156 HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
    157 {
    158  char   *astring = NULL;
    159  HCURSOR rc;
    160 
    161     if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
    162          astring = UnicodeToAsciiString((LPWSTR)lpszCursor);
    163          dprintf(("lpszCursor %s\n", astring));
    164          lpszCursor = (LPWSTR)ConvertNameId(hinst, (char *)astring);
    165     }
    166     else dprintf(("lpszCursor %d\n", (int)lpszCursor));
    167 
    168     rc = O32_LoadCursor(hinst, (char *)lpszCursor);
    169     if(astring)
    170         FreeAsciiString(astring);
    171 
    172     dprintf(("LoadCursorW returned %d\n", rc));
    173     return(rc);
    174 }
    175 //******************************************************************************
    176202//TODO: Far from complete, but works for loading resources from exe
    177203//fuLoad flag ignored
     
    182208 HANDLE hRet = 0;
    183209
    184   dprintf(("OS2LoadImageA NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
     210  dprintf(("LoadImageA NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
    185211
    186212  switch(uType) {
     
    194220                hRet = (HANDLE)LoadIconA(hinst, lpszName);
    195221                break;
     222        default:
     223                dprintf(("LoadImageA: unsupported type %d!!", uType));
     224                return 0;
    196225  }
    197   dprintf(("OS2LoadImageA returned %d\n", (int)hRet));
     226  dprintf(("LoadImageA returned %d\n", (int)hRet));
    198227
    199228  return(hRet);
     
    206235 HANDLE hRet = 0;
    207236
    208   dprintf(("OS2LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
     237  dprintf(("LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
    209238
    210239  switch(uType) {
     
    218247                hRet = (HANDLE)LoadIconW(hinst, lpszName);
    219248                break;
     249        default:
     250                dprintf(("LoadImageW: unsupported type %d!!", uType));
     251                return 0;
    220252  }
    221   dprintf(("OS2LoadImageW returned %d\n", (int)hRet));
     253  dprintf(("LoadImageW returned %d\n", (int)hRet));
    222254
    223255  return(hRet);
Note: See TracChangeset for help on using the changeset viewer.