Ignore:
Timestamp:
Aug 20, 1999, 1:52:19 PM (26 years ago)
Author:
sandervl
Message:

Load* resource api changes

File:
1 edited

Legend:

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

    r345 r596  
    1 /* $Id: loadres.cpp,v 1.4 1999-07-20 15:46:53 sandervl Exp $ */
     1/* $Id: loadres.cpp,v 1.5 1999-08-20 11:52:18 sandervl Exp $ */
    22
    3 /*
    4  *
    5  * Project Odin Software License can be found in LICENSE.TXT
    6  *
    7  */
    83/*
    94 * Win32 resource API functions for OS/2
     
    116 * Copyright 1998 Sander van Leeuwen
    127 *
     8 *
     9 * Project Odin Software License can be found in LICENSE.TXT
     10 *
    1311 */
    1412#include <os2win.h>
    15 #include "user32.h"
    16 #include "resstring.h"
     13#include <string.h>
     14#include <user32.h>
     15#include <winres.h>
     16#include <heapstring.h>
    1717
    18 //NOTE: HINSTANCE 0xFFFFFFFF == hinstance executable
    1918//******************************************************************************
    2019//******************************************************************************
    2120int WIN32API LoadStringA(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer)
    2221{
    23     dprintf(("LoadString from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
    24     return OS2LoadStringAscii(hinst, wID, lpBuffer, cchBuffer);
     22 Win32Resource *winres;
     23 LPWSTR  resstring;
     24 int     resstrlen = 0;
     25
     26    winres = (Win32Resource *)FindResourceA(hinst, (LPSTR)wID, RT_STRINGA);
     27    if(winres == NULL) {
     28        dprintf(("LoadStringA NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
     29        return 0;
     30    }
     31   
     32    resstring = (LPWSTR)winres->lockResource();
     33    if(resstring) {
     34        resstrlen = min(lstrlenW(resstring)+1, cchBuffer);
     35        lstrcpynWtoA(lpBuffer, resstring, resstrlen);
     36        lpBuffer[cchBuffer-1] = 0;
     37        dprintf(("LoadStringA %s", lpBuffer));
     38    }
     39    delete winres;
     40
     41    dprintf(("LoadStringA from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
     42    return(resstrlen);
    2543}
    2644//******************************************************************************
     
    2846int WIN32API LoadStringW(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer)
    2947{
    30     dprintf(("LoadStringW %d\n", wID));
    31     return OS2LoadStringUnicode(hinst, wID, (WCHAR *)lpBuffer, cchBuffer);
     48 Win32Resource *winres;
     49 LPWSTR resstring;
     50 int    resstrlen = 0;
     51
     52    winres = (Win32Resource *)FindResourceW(hinst, (LPWSTR)wID, RT_STRINGW);
     53    if(winres == NULL) {
     54        dprintf(("LoadStringW NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
     55        return 0;
     56    }
     57   
     58    resstring = (LPWSTR)winres->lockResource();
     59    if(resstring) {
     60        resstrlen = min(lstrlenW(resstring)+1, cchBuffer);
     61        lstrcpynW(lpBuffer, resstring, resstrlen);
     62        lpBuffer[cchBuffer-1] = 0;
     63    }
     64    delete winres;
     65
     66    dprintf(("LoadStringW from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
     67    return(resstrlen);
    3268}
    3369//******************************************************************************
     70//TODO: Standard windows icons!
    3471//******************************************************************************
    3572HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon)
     
    3875
    3976    rc = (HICON)FindResourceA(hinst, lpszIcon, RT_ICONA);
     77    if(rc == 0) {
     78        rc = (HICON)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA);
     79    }
    4080    dprintf(("LoadIconA (%X) returned %d\n", hinst, rc));
    4181    return(rc);
    4282}
    4383//******************************************************************************
     84//TODO: Standard windows icons!
    4485//******************************************************************************
    4586HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
     
    4889
    4990    rc = (HICON)FindResourceW(hinst, lpszIcon, RT_ICONW);
     91    if(rc == 0) {
     92        rc = (HICON)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW);
     93    }
    5094    dprintf(("LoadIconW (%X) returned %d\n", hinst, rc));
    5195    return(rc);
    5296}
    5397//******************************************************************************
     98//TODO: Standard windows cursors!
    5499//******************************************************************************
    55100HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor)
     
    57102 HCURSOR rc;
    58103
    59     if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
    60          dprintf(("LoadCursor %s\n", lpszCursor));
    61          lpszCursor = (LPCSTR)ConvertNameId(hinst, (char *)lpszCursor);
    62     }
    63     else dprintf(("LoadCursor %d\n", (int)lpszCursor));
    64 
    65     rc = O32_LoadCursor(hinst, lpszCursor);
     104    rc = (HCURSOR) FindResourceA(hinst, lpszCursor, RT_CURSORA);
    66105
    67106    dprintf(("LoadCursor from %X returned %d\n", hinst, rc));
     
    69108}
    70109//******************************************************************************
     110//TODO: Standard windows cursors!
     111//******************************************************************************
     112HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
     113{
     114 HCURSOR rc;
     115
     116    rc = (HCURSOR) FindResourceW(hinst, lpszCursor, RT_CURSORW);
     117
     118    dprintf(("LoadCursorW from %X returned %d\n", hinst, rc));
     119    return(rc);
     120}
     121//******************************************************************************
     122//TODO: Standard windows bitmaps!
    71123//******************************************************************************
    72124HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap)
     
    74126 HBITMAP rc;
    75127
    76   if((int)lpszBitmap >> 16 != 0)
    77   {  //convert string name identifier to numeric id
    78     dprintf(("lpszBitmap [%s]\n",
    79              lpszBitmap));
    80    
    81     lpszBitmap = (LPCSTR)ConvertNameId(hinst,
    82                                        (char *)lpszBitmap);
    83   }
    84   else
    85     dprintf(("lpszBitmap %08xh\n",
    86              (int)lpszBitmap));
     128    rc = (HBITMAP) FindResourceA(hinst, lpszBitmap, RT_BITMAPA);
    87129
    88   rc = O32_LoadBitmap(hinst, lpszBitmap);
    89 
    90   dprintf(("LoadBitmapA returned %08xh\n",
    91            rc));
    92  
    93   return(rc);
     130    dprintf(("LoadBitmapA from %X returned %d\n", hinst, rc));
     131    return(rc);
    94132}
    95133//******************************************************************************
     134//TODO: Standard windows bitmaps!
    96135//******************************************************************************
    97136HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)
    98137{
    99  char   *astring = NULL;
    100138 HBITMAP rc;
    101139
    102     if((int)lpszBitmap >> 16 != 0) {//convert string name identifier to numeric id
    103          astring = UnicodeToAsciiString((LPWSTR)lpszBitmap);
    104          dprintf(("lpszBitmap %s\n", astring));
     140    rc = (HBITMAP) FindResourceW(hinst, lpszBitmap, RT_BITMAPW);
    105141
    106          lpszBitmap = (LPWSTR)ConvertNameId(hinst, (char *)astring);
    107     }
    108     else dprintf(("lpszBitmap %d\n", (int)lpszBitmap));
    109 
    110     rc = O32_LoadBitmap(hinst, (char *)lpszBitmap);
    111     if(astring)
    112         FreeAsciiString(astring);
    113 
    114     dprintf(("LoadBitmapW returned %d\n", rc));
    115     return(rc);
    116 }
    117 //******************************************************************************
    118 //******************************************************************************
    119 HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
    120 {
    121  char   *astring = NULL;
    122  HCURSOR rc;
    123 
    124     if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
    125          astring = UnicodeToAsciiString((LPWSTR)lpszCursor);
    126          dprintf(("lpszCursor %s\n", astring));
    127          lpszCursor = (LPWSTR)ConvertNameId(hinst, (char *)astring);
    128     }
    129     else dprintf(("lpszCursor %d\n", (int)lpszCursor));
    130 
    131     rc = O32_LoadCursor(hinst, (char *)lpszCursor);
    132     if(astring)
    133         FreeAsciiString(astring);
    134 
    135     dprintf(("LoadCursorW returned %d\n", rc));
     142    dprintf(("LoadBitmapW from %X returned %d\n", hinst, rc));
    136143    return(rc);
    137144}
Note: See TracChangeset for help on using the changeset viewer.