Changeset 345 for trunk/src


Ignore:
Timestamp:
Jul 20, 1999, 5:46:54 PM (26 years ago)
Author:
sandervl
Message:

Accelerator + icon changes

Location:
trunk/src/user32/new
Files:
2 added
8 edited

Legend:

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

    r300 r345  
    1 /* $Id: icon.cpp,v 1.1 1999-07-14 08:35:34 sandervl Exp $ */
     1/* $Id: icon.cpp,v 1.2 1999-07-20 15:46:53 sandervl Exp $ */
    22
    3 /*
    4  *
    5  * Project Odin Software License can be found in LICENSE.TXT
    6  *
    7  */
    83/*
    94 * Win32 icon conversion functions for OS/2
    105 *
    116 * Copyright 1998 Sander van Leeuwen
     7 *
     8 *
     9 * Project Odin Software License can be found in LICENSE.TXT
    1210 *
    1311 */
  • trunk/src/user32/new/loadres.cpp

    r342 r345  
    1 /* $Id: loadres.cpp,v 1.3 1999-07-20 07:42:35 sandervl Exp $ */
     1/* $Id: loadres.cpp,v 1.4 1999-07-20 15:46:53 sandervl Exp $ */
    22
    33/*
     
    3737 HICON rc;
    3838
    39     if((int)lpszIcon >> 16 != 0) {//convert string name identifier to numeric id
    40          dprintf(("LoadIcon %s\n", lpszIcon));
    41          lpszIcon = (LPCSTR)ConvertNameId(hinst, (char *)lpszIcon);
    42     }
    43     else dprintf(("LoadIcon %d\n", (int)lpszIcon));
     39    rc = (HICON)FindResourceA(hinst, lpszIcon, RT_ICONA);
     40    dprintf(("LoadIconA (%X) returned %d\n", hinst, rc));
     41    return(rc);
     42}
     43//******************************************************************************
     44//******************************************************************************
     45HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
     46{
     47 HICON rc;
    4448
    45     rc = O32_LoadIcon(hinst, lpszIcon);
    46 
    47     dprintf(("LoadIcon returned %d\n", rc));
     49    rc = (HICON)FindResourceW(hinst, lpszIcon, RT_ICONW);
     50    dprintf(("LoadIconW (%X) returned %d\n", hinst, rc));
    4851    return(rc);
    4952}
     
    134137}
    135138//******************************************************************************
    136 //******************************************************************************
    137 HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
    138 {
    139  char  *astring = NULL;
    140  HICON rc;
    141 
    142     if((int)lpszIcon >> 16 != 0) {//convert string name identifier to numeric id
    143          astring = UnicodeToAsciiString((LPWSTR)lpszIcon);
    144 
    145          dprintf(("lpszIcon %s\n", astring));
    146          lpszIcon = (LPWSTR)ConvertNameId(hinst, (char *)astring);
    147     }
    148     else dprintf(("lpszIcon %d\n", (int)lpszIcon));
    149 
    150     rc = O32_LoadIcon(hinst, (char *)lpszIcon);
    151     if(astring)
    152         FreeAsciiString(astring);
    153 
    154     dprintf(("LoadIconW returned %d\n", rc));
    155     return(rc);
    156 }
    157 //******************************************************************************
    158 //******************************************************************************
    159 //******************************************************************************
    160139//TODO: Far from complete, but works for loading resources from exe
    161140//fuLoad flag ignored
  • trunk/src/user32/new/makefile

    r342 r345  
    1 # $Id: makefile,v 1.13 1999-07-20 07:42:35 sandervl Exp $
     1# $Id: makefile,v 1.14 1999-07-20 15:46:53 sandervl Exp $
    22
    33#
     
    3131        controls.obj button.obj oslibutil.obj oslibmsg.obj windlg.obj \
    3232        winprop.obj wingdi.obj oslibgdi.obj winaccel.obj winscrollbar.obj \
    33         nativerc.obj
     33        nativerc.obj oslibres.obj
    3434
    3535
     
    9191pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h win32wndchild.h $(PDWIN32_INCLUDE)\wprocess.h  oslibgdi.h
    9292win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
    93 win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h  $(PDWIN32_INCLUDE)\winres.h
     93win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h  $(PDWIN32_INCLUDE)\winres.h oslibres.h
    9494win32dlg.obj:   win32dlg.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
    9595win32wndchild.obj: win32wndchild.cpp win32wndchild.h
     
    9999oslibmsg.obj:   oslibmsg.cpp oslibmsg.h
    100100oslibgdi.obj:   oslibgdi.cpp oslibgdi.h
     101oslibres.obj:   oslibres.cpp oslibwin.h oslibres.h
    101102
    102103clean:
  • trunk/src/user32/new/oslibwin.cpp

    r342 r345  
    1 /* $Id: oslibwin.cpp,v 1.17 1999-07-20 07:42:35 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.18 1999-07-20 15:46:53 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    143143//******************************************************************************
    144144//******************************************************************************
    145 HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
    146 {
    147   return WinCreateMenu(hwndParent, menutemplate);
    148 }
    149 //******************************************************************************
    150 //******************************************************************************
    151 BOOL OSLibWinSetAccelTable(HWND hwnd, PVOID acceltemplate)
    152 {
    153  HACCEL haccel;
    154  HAB    hab = WinQueryAnchorBlock(hwnd);
    155 
    156     haccel = WinCreateAccelTable(hab, (PACCELTABLE)acceltemplate);
    157     if(haccel == 0) {
    158         dprintf(("OSLibWinSetAccelTable: WinCreateAccelTable returned 0"));
    159         return FALSE;
    160     }
    161     return WinSetAccelTable(hab, haccel, hwnd);
    162 }
    163145//******************************************************************************
    164146//******************************************************************************
  • trunk/src/user32/new/oslibwin.h

    r342 r345  
    1 /* $Id: oslibwin.h,v 1.15 1999-07-20 07:42:36 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.16 1999-07-20 15:46:53 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    2626
    2727BOOL  OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam);
    28 
    29 HWND  OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate);
    30 BOOL  OSLibWinSetAccelTable(HWND hwnd, PVOID acceltemplate);
    3128
    3229#define WAOS_WARNING                 0
  • trunk/src/user32/new/win32class.h

    r300 r345  
    1 /* $Id: win32class.h,v 1.2 1999-07-14 08:35:37 sandervl Exp $ */
     1/* $Id: win32class.h,v 1.3 1999-07-20 15:46:53 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    4343         DWORD  getExtraWndWords()      { return nrExtraWindowWords; };
    4444
     45         HICON  getIcon()               { return hIcon; };
     46
    4547          void  setMenuName(LPSTR newMenuName);
    4648
  • trunk/src/user32/new/win32wnd.cpp

    r342 r345  
    1 /* $Id: win32wnd.cpp,v 1.17 1999-07-20 07:42:36 sandervl Exp $ */
     1/* $Id: win32wnd.cpp,v 1.18 1999-07-20 15:46:54 sandervl Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    2929#include <oslibutil.h>
    3030#include <oslibgdi.h>
     31#include <oslibres.h>
    3132#include <winres.h>
    3233
     
    102103  acceltableResource = NULL;
    103104  menuResource       = NULL;
    104 }
    105 //******************************************************************************
     105  iconResource       = NULL;
     106}
     107//******************************************************************************
     108//todo get rid of resources (menu, accel, icon etc)
    106109//******************************************************************************
    107110Win32Window::~Win32Window()
     
    389392  else  windowId = (UINT)cs->hMenu;
    390393
     394  //Set icon from class
     395  if(windowClass->getIcon())
     396        SetIcon(windowClass->getIcon());
     397
    391398  /* Send the WM_CREATE message
    392399   * Perhaps we shouldn't allow width/height changes as well.
     
    416423                HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
    417424#endif
     425        SetLastError(0);
    418426        return TRUE;
    419427        }
     
    10561064//******************************************************************************
    10571065//******************************************************************************
    1058 BOOL Win32Window::SetMenu(ULONG hMenu)
     1066BOOL Win32Window::SetMenu(HMENU hMenu)
    10591067{
    10601068 PVOID          menutemplate;
     
    10821090//******************************************************************************
    10831091//******************************************************************************
    1084 BOOL Win32Window::SetAccelTable(ULONG hAccel)
     1092BOOL Win32Window::SetAccelTable(HACCEL hAccel)
    10851093{
    10861094 Win32Resource *winres = (Win32Resource *)hAccel;
     1095 HANDLE         accelhandle;
    10871096
    10881097    if(HIWORD(hAccel) == 0) {
    10891098        dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
    1090             SetLastError(ERROR_INVALID_PARAMETER);
    1091             return FALSE;
     1099        SetLastError(ERROR_INVALID_PARAMETER);
     1100        return FALSE;
    10921101    }
    10931102    acceltableResource = winres;
    1094         return OSLibWinSetAccelTable(OS2HwndFrame, winres->lockOS2Resource());
     1103    accelhandle = OSLibWinSetAccelTable(OS2HwndFrame, winres->getOS2Handle(), winres->lockOS2Resource());
     1104    winres->setOS2Handle(accelhandle);
     1105    return(accelhandle != 0);
     1106}
     1107//******************************************************************************
     1108//******************************************************************************
     1109BOOL Win32Window::SetIcon(HICON hIcon)
     1110{
     1111 Win32Resource *winres = (Win32Resource *)hIcon;
     1112 HANDLE         iconhandle;
     1113
     1114    if(HIWORD(hIcon) == 0) {
     1115        dprintf(("SetIcon: hIcon %x invalid", hIcon));
     1116        SetLastError(ERROR_INVALID_PARAMETER);
     1117        return FALSE;
     1118    }
     1119    dprintf(("Win32Window::SetIcon %x", hIcon));
     1120    iconResource = winres;
     1121    iconhandle = OSLibWinSetIcon(OS2HwndFrame, winres->getOS2Handle(), winres->lockOS2Resource());
     1122    winres->setOS2Handle(iconhandle);
     1123    return(iconhandle != 0);
    10951124}
    10961125//******************************************************************************
  • trunk/src/user32/new/win32wnd.h

    r342 r345  
    1 /* $Id: win32wnd.h,v 1.16 1999-07-20 07:42:36 sandervl Exp $ */
     1/* $Id: win32wnd.h,v 1.17 1999-07-20 15:46:54 sandervl Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    9393         void   setFlags(DWORD newflags)        { flags = newflags; };
    9494
    95          ULONG  GetAccelTable()                     { return (ULONG) acceltableResource; };
     95         HACCEL GetAccelTable()                     { return (HACCEL) acceltableResource; };
    9696         BOOL   SetAccelTable(ULONG hAccel);
    9797
    98          ULONG  GetMenu()                           { return (ULONG) menuResource; };
     98         HMENU  GetMenu()                           { return (HMENU) menuResource; };
    9999         BOOL   SetMenu(ULONG hMenu);
     100
     101         BOOL   SetIcon(HICON hIcon);
     102         HICON  GetIcon()                           { return (HICON) iconResource; };
    100103
    101104         BOOL   ShowWindow(ULONG nCmdShow);
     
    191194 Win32Resource *acceltableResource;
    192195 Win32Resource *menuResource;
     196 Win32Resource *iconResource;
    193197
    194198        char   *windowName;
Note: See TracChangeset for help on using the changeset viewer.