Index: trunk/src/user32/new/loadres.cpp
===================================================================
--- trunk/src/user32/new/loadres.cpp	(revision 593)
+++ trunk/src/user32/new/loadres.cpp	(revision 596)
@@ -1,9 +1,4 @@
-/* $Id: loadres.cpp,v 1.4 1999-07-20 15:46:53 sandervl Exp $ */
+/* $Id: loadres.cpp,v 1.5 1999-08-20 11:52:18 sandervl Exp $ */
 
-/*
- *
- * Project Odin Software License can be found in LICENSE.TXT
- *
- */
 /*
  * Win32 resource API functions for OS/2
@@ -11,16 +6,39 @@
  * Copyright 1998 Sander van Leeuwen
  *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
  */
 #include <os2win.h>
-#include "user32.h"
-#include "resstring.h"
+#include <string.h>
+#include <user32.h>
+#include <winres.h>
+#include <heapstring.h>
 
-//NOTE: HINSTANCE 0xFFFFFFFF == hinstance executable
 //******************************************************************************
 //******************************************************************************
 int WIN32API LoadStringA(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer)
 {
-    dprintf(("LoadString from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
-    return OS2LoadStringAscii(hinst, wID, lpBuffer, cchBuffer);
+ Win32Resource *winres;
+ LPWSTR  resstring;
+ int     resstrlen = 0;
+
+    winres = (Win32Resource *)FindResourceA(hinst, (LPSTR)wID, RT_STRINGA);
+    if(winres == NULL) {
+	dprintf(("LoadStringA NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
+	return 0;
+    }
+    
+    resstring = (LPWSTR)winres->lockResource();
+    if(resstring) {
+	resstrlen = min(lstrlenW(resstring)+1, cchBuffer);
+	lstrcpynWtoA(lpBuffer, resstring, resstrlen);
+	lpBuffer[cchBuffer-1] = 0;
+	dprintf(("LoadStringA %s", lpBuffer));
+    }
+    delete winres;
+
+    dprintf(("LoadStringA from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
+    return(resstrlen);
 }
 //******************************************************************************
@@ -28,8 +46,27 @@
 int WIN32API LoadStringW(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer)
 {
-    dprintf(("LoadStringW %d\n", wID));
-    return OS2LoadStringUnicode(hinst, wID, (WCHAR *)lpBuffer, cchBuffer);
+ Win32Resource *winres;
+ LPWSTR resstring;
+ int    resstrlen = 0;
+
+    winres = (Win32Resource *)FindResourceW(hinst, (LPWSTR)wID, RT_STRINGW);
+    if(winres == NULL) {
+	dprintf(("LoadStringW NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
+	return 0;
+    }
+    
+    resstring = (LPWSTR)winres->lockResource();
+    if(resstring) {
+	resstrlen = min(lstrlenW(resstring)+1, cchBuffer);
+	lstrcpynW(lpBuffer, resstring, resstrlen);
+	lpBuffer[cchBuffer-1] = 0;
+    }
+    delete winres;
+
+    dprintf(("LoadStringW from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
+    return(resstrlen);
 }
 //******************************************************************************
+//TODO: Standard windows icons!
 //******************************************************************************
 HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon)
@@ -38,8 +75,12 @@
 
     rc = (HICON)FindResourceA(hinst, lpszIcon, RT_ICONA);
+    if(rc == 0) {
+    	rc = (HICON)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA);
+    }
     dprintf(("LoadIconA (%X) returned %d\n", hinst, rc));
     return(rc);
 }
 //******************************************************************************
+//TODO: Standard windows icons!
 //******************************************************************************
 HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
@@ -48,8 +89,12 @@
 
     rc = (HICON)FindResourceW(hinst, lpszIcon, RT_ICONW);
+    if(rc == 0) {
+    	rc = (HICON)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW);
+    }
     dprintf(("LoadIconW (%X) returned %d\n", hinst, rc));
     return(rc);
 }
 //******************************************************************************
+//TODO: Standard windows cursors!
 //******************************************************************************
 HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor)
@@ -57,11 +102,5 @@
  HCURSOR rc;
 
-    if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
-         dprintf(("LoadCursor %s\n", lpszCursor));
-	 lpszCursor = (LPCSTR)ConvertNameId(hinst, (char *)lpszCursor);
-    }
-    else dprintf(("LoadCursor %d\n", (int)lpszCursor));
-
-    rc = O32_LoadCursor(hinst, lpszCursor);
+    rc = (HCURSOR) FindResourceA(hinst, lpszCursor, RT_CURSORA);
 
     dprintf(("LoadCursor from %X returned %d\n", hinst, rc));
@@ -69,4 +108,17 @@
 }
 //******************************************************************************
+//TODO: Standard windows cursors!
+//******************************************************************************
+HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
+{
+ HCURSOR rc;
+
+    rc = (HCURSOR) FindResourceW(hinst, lpszCursor, RT_CURSORW);
+
+    dprintf(("LoadCursorW from %X returned %d\n", hinst, rc));
+    return(rc);
+}
+//******************************************************************************
+//TODO: Standard windows bitmaps!
 //******************************************************************************
 HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap)
@@ -74,64 +126,19 @@
  HBITMAP rc;
 
-  if((int)lpszBitmap >> 16 != 0) 
-  {  //convert string name identifier to numeric id
-    dprintf(("lpszBitmap [%s]\n",
-             lpszBitmap));
-    
-    lpszBitmap = (LPCSTR)ConvertNameId(hinst, 
-                                       (char *)lpszBitmap);
-  }
-  else 
-    dprintf(("lpszBitmap %08xh\n",
-             (int)lpszBitmap));
+    rc = (HBITMAP) FindResourceA(hinst, lpszBitmap, RT_BITMAPA);
 
-  rc = O32_LoadBitmap(hinst, lpszBitmap);
-
-  dprintf(("LoadBitmapA returned %08xh\n",
-           rc));
-  
-  return(rc);
+    dprintf(("LoadBitmapA from %X returned %d\n", hinst, rc));
+    return(rc);
 }
 //******************************************************************************
+//TODO: Standard windows bitmaps!
 //******************************************************************************
 HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)
 {
- char   *astring = NULL;
  HBITMAP rc;
 
-    if((int)lpszBitmap >> 16 != 0) {//convert string name identifier to numeric id
-	 astring = UnicodeToAsciiString((LPWSTR)lpszBitmap);
-         dprintf(("lpszBitmap %s\n", astring));
+    rc = (HBITMAP) FindResourceW(hinst, lpszBitmap, RT_BITMAPW);
 
-	 lpszBitmap = (LPWSTR)ConvertNameId(hinst, (char *)astring);
-    }
-    else dprintf(("lpszBitmap %d\n", (int)lpszBitmap));
-
-    rc = O32_LoadBitmap(hinst, (char *)lpszBitmap);
-    if(astring)
-	FreeAsciiString(astring);
-
-    dprintf(("LoadBitmapW returned %d\n", rc));
-    return(rc);
-}
-//******************************************************************************
-//******************************************************************************
-HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
-{
- char   *astring = NULL;
- HCURSOR rc;
-
-    if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
-	 astring = UnicodeToAsciiString((LPWSTR)lpszCursor);
-         dprintf(("lpszCursor %s\n", astring));
-	 lpszCursor = (LPWSTR)ConvertNameId(hinst, (char *)astring);
-    }
-    else dprintf(("lpszCursor %d\n", (int)lpszCursor));
-
-    rc = O32_LoadCursor(hinst, (char *)lpszCursor);
-    if(astring)
-	FreeAsciiString(astring);
-
-    dprintf(("LoadCursorW returned %d\n", rc));
+    dprintf(("LoadBitmapW from %X returned %d\n", hinst, rc));
     return(rc);
 }
Index: trunk/src/user32/new/makefile
===================================================================
--- trunk/src/user32/new/makefile	(revision 593)
+++ trunk/src/user32/new/makefile	(revision 596)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.25 1999-08-19 12:53:56 sandervl Exp $
+# $Id: makefile,v 1.26 1999-08-20 11:52:18 sandervl Exp $
 
 #
@@ -21,5 +21,5 @@
 TARGET = user32
 
-OBJS =  user32.obj resstring.obj dialog.obj loadres.obj \
+OBJS =  user32.obj dialog.obj loadres.obj \
         dde.obj \
         icon.obj hook.obj hooks.obj winmenu.obj \
@@ -56,5 +56,4 @@
 user32.obj: user32.cpp $(PDWIN32_INCLUDE)\wndproc.h \
             $(PDWIN32_INCLUDE)\winicon.h syscolor.h
-resstring.obj: resstring.cpp resstring.h
 char.obj: char.cpp user32.h
 loadres.obj: loadres.cpp user32.h
Index: trunk/src/user32/new/resstring.cpp
===================================================================
--- trunk/src/user32/new/resstring.cpp	(revision 593)
+++ 	(revision )
@@ -1,164 +1,0 @@
-/* $Id: resstring.cpp,v 1.1 1999-07-14 08:35:35 sandervl Exp $ */
-
-/*
- *
- * Project Odin Software License can be found in LICENSE.TXT
- *
- */
-/*
- * Win32 resource string functions for OS/2
- *
- * Copyright 1998 Sander van Leeuwen
- *
- */
-#define INCL_BASE
-#define INCL_WIN
-#define INCL_WINERRORS
-#define INCL_DOSFILEMGR
-#include <os2wrap.h>	//Odin32 OS/2 api wrappers
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "misc.h"
-#include "resstring.h"
-#include "win32util.h"
-#include "unicode.h"
-
-/******************************************************************************/
-//Strings stored as original: WORD    len
-//                            UNICODE string (not null terminated)
-/******************************************************************************/
-int OS2LoadStringAscii(HINSTANCE hinst,
-                       UINT      wID,
-                       LPSTR     lpBuffer,
-                       int       cchBuffer)
-{
-  APIRET  rc;
-  WCHAR  *szbuf;
-  char    modname[128];
-  HMODULE hmodule;
-
-  if(hinst != 0 && hinst != -1)
-  {
-    if(Win32QueryModuleName(hinst,
-                            modname,
-                            sizeof(modname)) == 0)
-    {
-      dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %08xh\n",
-               hinst));
-      return(0);
-   }
-
-   rc = DosQueryModuleHandle(modname,
-                             &hmodule);
-   if(rc)
-   {
-     dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %s\n",
-              modname));
-
-     return(0);
-   }
-  }
-  else
-    hmodule = 0;
-
-  rc = DosGetResource(hmodule,
-                      RT_RCDATA,
-                      wID,
-                      (PPVOID)&szbuf);
-  if(rc)
-  {
-    dprintf(("USER32: OS2LoadStringAscii failed with rc %08xh\n",
-             rc));
-
-    if(lpBuffer)
-      *lpBuffer = 0;
-
-    return(0);  //TODO: SetLastError!
-  }
-
-  UnicodeToAsciiN(szbuf+1,
-                  lpBuffer,
-                  min((*szbuf+1), cchBuffer));
-
-  dprintf(("USER32: OS2LoadStringA retrieved string '%s' (size %d)\n",
-           lpBuffer,
-           (int)*szbuf));
-
-  DosFreeResource(szbuf);
-  return(strlen(lpBuffer));              //not including null terminator!
-}
-//******************************************************************************
-//******************************************************************************
-int OS2LoadStringUnicode(HINSTANCE hinst,
-                         UINT      wID,
-                         WCHAR     *lpBuffer,
-                         int       cchBuffer)
-{
-  APIRET  rc;
-  WCHAR  *szbuf;
-  char    modname[128];
-  HMODULE hmodule;
-
-#ifdef DEBUG
- char   *astring;
-#endif
-
-  if(hinst != 0 && hinst != -1)
-  {
-    if(Win32QueryModuleName(hinst,
-                            modname,
-                            sizeof(modname)) == 0)
-    {
-      dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %08xh\n",
-               hinst));
-      return(0);
-   }
-
-   rc = DosQueryModuleHandle(modname,
-                             &hmodule);
-   if(rc)
-   {
-     dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %s\n",
-              modname));
-
-     return(0);
-   }
-  }
-  else
-    hmodule = 0;
-
-  rc = DosGetResource(hmodule,
-                      RT_RCDATA,
-                      wID,
-                      (PPVOID)&szbuf);
-  if(rc)
-  {
-    dprintf(("USER32: OS2LoadStringUnicode failed with rc %08xh\n",
-             rc));
-
-    if(lpBuffer)
-      *lpBuffer = 0;
-
-    return(0);  //TODO: SetLastError!
-  }
-
-
-  memcpy(lpBuffer,
-         szbuf+1,
-         min((*szbuf), cchBuffer-1) * sizeof(WCHAR));
-
-  lpBuffer[min((*szbuf), cchBuffer-1)] = 0;
-
-#ifdef DEBUG
-  astring = UnicodeToAsciiString(lpBuffer);
-  WriteLog("USER32: OS2LoadStringUnicode retrieved string '%s' of size %d\n",
-           astring,
-           (int)*szbuf);
-  FreeAsciiString(astring);
-#endif
-
-  DosFreeResource(szbuf);
-  return(UniStrlen(lpBuffer));           //not including null terminator!
-}
-
Index: trunk/src/user32/new/resstring.h
===================================================================
--- trunk/src/user32/new/resstring.h	(revision 593)
+++ 	(revision )
@@ -1,28 +1,0 @@
-/* $Id: resstring.h,v 1.1 1999-07-14 08:35:33 sandervl Exp $ */
-
-/*
- *
- * Project Odin Software License can be found in LICENSE.TXT
- *
- */
-/*
- * Win32 resource string functions for OS/2
- *
- * Copyright 1998 Sander van Leeuwen
- *
- */
-#ifndef __STRING_H__
-#define __STRING_H__
-
-#ifdef __cplusplus
-      extern "C" {
-#endif
-
-int OS2LoadStringAscii(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer);
-int OS2LoadStringUnicode(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer);
-
-#ifdef __cplusplus
-      }
-#endif
-
-#endif
