source: trunk/src/user32/new/oslibres.cpp@ 350

Last change on this file since 350 was 350, checked in by sandervl, 26 years ago

Fixed icons

File size: 3.3 KB
Line 
1/* $Id: oslibres.cpp,v 1.2 1999-07-20 17:50:39 sandervl Exp $ */
2/*
3 * Window API wrappers for OS/2
4 *
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#define INCL_WIN
13#define INCL_PM
14#include <os2.h>
15#include <os2wrap.h>
16#include <stdlib.h>
17#include <string.h>
18
19#include <misc.h>
20#include <oslibwin.h>
21#include "oslibstyle.h"
22#include "oslibutil.h"
23#include "oslibmsg.h"
24#include "oslibgdi.h"
25#include "pmwindow.h"
26
27
28//******************************************************************************
29//******************************************************************************
30HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
31{
32 return WinCreateMenu(hwndParent, menutemplate);
33}
34//******************************************************************************
35//******************************************************************************
36HANDLE OSLibWinSetAccelTable(HWND hwnd, HANDLE hAccel, PVOID acceltemplate)
37{
38 HAB hab = WinQueryAnchorBlock(hwnd);
39
40 if(hAccel == 0) {
41 hAccel = WinCreateAccelTable(hab, (PACCELTABLE)acceltemplate);
42 if(hAccel == 0) {
43 dprintf(("OSLibWinSetAccelTable: WinCreateAccelTable returned 0"));
44 return FALSE;
45 }
46 }
47 if(WinSetAccelTable(hab, hAccel, hwnd) == TRUE) {
48 return hAccel;
49 }
50 else return 0;
51}
52//******************************************************************************
53//todo: save mask handle somewhere
54//******************************************************************************
55HANDLE OSLibWinSetIcon(HWND hwnd, HANDLE hIcon, PVOID iconbitmap)
56{
57 POINTERINFO pointerInfo = {0};
58 HBITMAP hbmColor, hbmMask;
59 BITMAPARRAYFILEHEADER2 *bafh = (BITMAPARRAYFILEHEADER2 *)iconbitmap;
60 BITMAPFILEHEADER2 *bfh;
61 HPS hps;
62
63 if(hIcon == 0) {
64 //skip xor/and mask
65 bfh = (BITMAPFILEHEADER2 *)((char *)&bafh->bfh2 + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
66 hps = WinGetPS(hwnd);
67 hbmColor = GpiCreateBitmap(hps, &bfh->bmp2, CBM_INIT,
68 (char *)bafh + bfh->offBits,
69 (BITMAPINFO2 *)&bfh->bmp2);
70 if(hbmColor == GPI_ERROR) {
71 dprintf(("OSLibWinSetIcon: GpiCreateBitmap failed!"));
72 WinReleasePS(hps);
73 return 0;
74 }
75 hbmMask = GpiCreateBitmap(hps, &bafh->bfh2.bmp2, CBM_INIT,
76 (char *)bafh + bafh->bfh2.offBits,
77 (BITMAPINFO2 *)&bafh->bfh2.bmp2);
78 if(hbmMask == GPI_ERROR) {
79 dprintf(("OSLibWinSetIcon: GpiCreateBitmap hbmMask failed!"));
80 WinReleasePS(hps);
81 return 0;
82 }
83
84 pointerInfo.fPointer = FALSE; //icon
85 pointerInfo.xHotspot = bfh->xHotspot;
86 pointerInfo.yHotspot = bfh->yHotspot;
87 pointerInfo.hbmColor = hbmColor;
88 pointerInfo.hbmPointer = hbmMask;
89 hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &pointerInfo);
90 if(hIcon == NULL) {
91 dprintf(("WinSetIcon: WinCreatePointerIndirect failed!"));
92 GpiDeleteBitmap(hbmMask);
93 GpiDeleteBitmap(hbmColor);
94 WinReleasePS(hps);
95 }
96 }
97 WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
98 WinReleasePS(hps);
99 return hIcon;
100}
101//******************************************************************************
102//******************************************************************************
103
Note: See TracBrowser for help on using the repository browser.