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

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

* empty log message *

File size: 3.5 KB
Line 
1/* $Id: oslibres.cpp,v 1.4 1999-07-26 09:01:33 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(iconbitmap == NULL) {
64 dprintf(("OSLibWinSetIcon %x %x: iconbitmap == NULL!!", hwnd, hIcon));
65 return 0;
66 }
67 if(hIcon == 0) {
68 //skip xor/and mask
69 bfh = (BITMAPFILEHEADER2 *)((char *)&bafh->bfh2 + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
70 hps = WinGetPS(hwnd);
71 hbmColor = GpiCreateBitmap(hps, &bfh->bmp2, CBM_INIT,
72 (char *)bafh + bfh->offBits,
73 (BITMAPINFO2 *)&bfh->bmp2);
74 if(hbmColor == GPI_ERROR) {
75 dprintf(("OSLibWinSetIcon: GpiCreateBitmap failed!"));
76 WinReleasePS(hps);
77 return 0;
78 }
79 hbmMask = GpiCreateBitmap(hps, &bafh->bfh2.bmp2, CBM_INIT,
80 (char *)bafh + bafh->bfh2.offBits,
81 (BITMAPINFO2 *)&bafh->bfh2.bmp2);
82 if(hbmMask == GPI_ERROR) {
83 dprintf(("OSLibWinSetIcon: GpiCreateBitmap hbmMask failed!"));
84 WinReleasePS(hps);
85 return 0;
86 }
87
88 pointerInfo.fPointer = FALSE; //icon
89 pointerInfo.xHotspot = bfh->xHotspot;
90 pointerInfo.yHotspot = bfh->yHotspot;
91 pointerInfo.hbmColor = hbmColor;
92 pointerInfo.hbmPointer = hbmMask;
93 hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &pointerInfo);
94 if(hIcon == NULL) {
95 dprintf(("WinSetIcon: WinCreatePointerIndirect failed!"));
96 GpiDeleteBitmap(hbmMask);
97 GpiDeleteBitmap(hbmColor);
98 WinReleasePS(hps);
99 }
100 }
101 WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
102 WinReleasePS(hps);
103 return hIcon;
104}
105//******************************************************************************
106//******************************************************************************
107
Note: See TracBrowser for help on using the repository browser.