source: trunk/dll/seticon.c@ 1039

Last change on this file since 1039 was 1039, checked in by Gregg Young, 17 years ago

Removed unnecessary xfrees and included fortify.h where needed; moved several misplaced (x)frees;

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1
2/***********************************************************************
3
4 $Id: seticon.c 1039 2008-07-05 22:16:21Z gyoung $
5
6 Edit ICON EA
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2006, 2007 Steven H.Levine
10
11 17 Jul 06 SHL Use Runtime_Error
12 22 Mar 06 GKY Use QWL_USER
13 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
14 29 Feb 08 GKY Use xfree where appropriate
15
16***********************************************************************/
17
18#include <stdlib.h>
19#include <string.h>
20#include <share.h>
21
22#define INCL_WIN
23#define INCL_LONGLONG // dircnrs.h
24
25#include "fm3dlg.h"
26#include "errutil.h" // Dos_Error...
27#include "fm3dll.h"
28#include "fortify.h"
29
30#pragma data_seg(DATA2)
31
32static PSZ pszSrcFile = __FILE__;
33
34MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
35{
36 switch (msg) {
37 case WM_INITDLG:
38 WinSetWindowPtr(hwnd, QWL_USER, (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, QWL_USER), *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, 0, SEEK_END);
67 icf.cbIconData = ftell(fp);
68 fseek(fp, 0, 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 free(buff);
97 }
98 WinDismissDlg(hwnd, 1);
99 break;
100
101 case IDM_HELP:
102 if (hwndHelp)
103 WinSendMsg(hwndHelp,
104 HM_DISPLAY_HELP,
105 MPFROM2SHORT(HELP_SETICON, 0), MPFROMSHORT(HM_RESOURCEID));
106 break;
107
108 case DID_CANCEL:
109 WinDismissDlg(hwnd, 0);
110 break;
111 }
112 return 0;
113 }
114 return WinDefDlgProc(hwnd, msg, mp1, mp2);
115}
116
117#pragma alloc_text(MENU,SetIconDlgProc)
Note: See TracBrowser for help on using the repository browser.