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

Last change on this file since 396 was 396, checked in by cbratschi, 26 years ago

bug fixes

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