source: trunk/dll/seticon.c@ 551

Last change on this file since 551 was 551, checked in by Gregg Young, 19 years ago

Indentation cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1
2/***********************************************************************
3
4 $Id: seticon.c 551 2007-02-28 01:33:51Z gyoung $
5
6 Edit ICON EA
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2006 Steven H.Levine
10
11 17 Jul 06 SHL Use Runtime_Error
12
13***********************************************************************/
14
15#define INCL_DOS
16#define INCL_WIN
17#include <os2.h>
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <ctype.h>
23#include <share.h>
24
25#include "fm3dll.h"
26#include "fm3dlg.h"
27
28#pragma data_seg(DATA2)
29
30static PSZ pszSrcFile = __FILE__;
31
32#pragma alloc_text(MENU,SetIconDlgProc)
33
34MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
35{
36 switch (msg) {
37 case WM_INITDLG:
38 WinSetWindowPtr(hwnd, 0, (PVOID) mp2);
39 WinCheckButton(hwnd, SETICON_SPTR_ARROW, TRUE);
40 break;
41
42 case WM_CONTROL:
43 return 0;
44
45 case WM_COMMAND:
46 switch (SHORT1FROMMP(mp1)) {
47 case DID_OK:
48 {
49 CHAR *filename = WinQueryWindowPtr(hwnd, 0), *buff = NULL;
50 ICONINFO icf;
51 ULONG icid = SPTR_ARROW;
52 INT x;
53 HWND hwndDeskTop;
54 FILE *fp;
55
56 hwndDeskTop = WinQueryDesktopWindow(WinQueryAnchorBlock(hwnd),
57 NULLHANDLE);
58 memset(&icf, 0, sizeof(ICONINFO));
59 icf.cb = sizeof(ICONINFO);
60 icf.fFormat = ICON_DATA;
61 if (filename && *filename) {
62 fp = xfsopen(filename, "rb", SH_DENYNO, pszSrcFile, __LINE__);
63 if (!fp)
64 break;
65 else {
66 fseek(fp, 0L, SEEK_END);
67 icf.cbIconData = ftell(fp);
68 fseek(fp, 0L, SEEK_SET);
69 buff = xmalloc(icf.cbIconData, pszSrcFile, __LINE__);
70 if (!buff) {
71 fclose(fp);
72 break;
73 }
74 fread(buff, icf.cbIconData, 1, fp);
75 icf.pIconData = (PVOID) buff;
76 fclose(fp);
77 }
78 }
79 for (x = 1; x < 15; x++) {
80 if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
81 icid = (ULONG) x;
82 break;
83 }
84 }
85 for (x = 18; x < 23; x++) {
86 if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
87 icid = (ULONG) x;
88 break;
89 }
90 }
91 if (!WinSetSysPointerData(hwndDeskTop, icid,
92 (PICONINFO) ((filename && *filename) ?
93 &icf : NULL))) {
94 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinSetSysPointerData");
95 }
96 if (buff)
97 free(buff);
98 }
99 WinDismissDlg(hwnd, 1);
100 break;
101
102 case IDM_HELP:
103 if (hwndHelp)
104 WinSendMsg(hwndHelp,
105 HM_DISPLAY_HELP,
106 MPFROM2SHORT(HELP_SETICON, 0), MPFROMSHORT(HM_RESOURCEID));
107 break;
108
109 case DID_CANCEL:
110 WinDismissDlg(hwnd, 0);
111 break;
112 }
113 return 0;
114 }
115 return WinDefDlgProc(hwnd, msg, mp1, mp2);
116}
Note: See TracBrowser for help on using the repository browser.