source: trunk/dll/seticon.c@ 1036

Last change on this file since 1036 was 1009, checked in by Steven Levine, 17 years ago

Add xfree xstrdup Fortify support
Add MT capable Fortify scope logic

  • 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 1009 2008-05-10 07:51:58Z stevenhl $
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
29#pragma data_seg(DATA2)
30
31static PSZ pszSrcFile = __FILE__;
32
33MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
34{
35 switch (msg) {
36 case WM_INITDLG:
37 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
38 WinCheckButton(hwnd, SETICON_SPTR_ARROW, TRUE);
39 break;
40
41 case WM_CONTROL:
42 return 0;
43
44 case WM_COMMAND:
45 switch (SHORT1FROMMP(mp1)) {
46 case DID_OK:
47 {
48 CHAR *filename = WinQueryWindowPtr(hwnd, QWL_USER), *buff = NULL;
49 ICONINFO icf;
50 ULONG icid = SPTR_ARROW;
51 INT x;
52 HWND hwndDeskTop;
53 FILE *fp;
54
55 hwndDeskTop = WinQueryDesktopWindow(WinQueryAnchorBlock(hwnd),
56 NULLHANDLE);
57 memset(&icf, 0, sizeof(ICONINFO));
58 icf.cb = sizeof(ICONINFO);
59 icf.fFormat = ICON_DATA;
60 if (filename && *filename) {
61 fp = xfsopen(filename, "rb", SH_DENYNO, pszSrcFile, __LINE__);
62 if (!fp)
63 break;
64 else {
65 fseek(fp, 0, SEEK_END);
66 icf.cbIconData = ftell(fp);
67 fseek(fp, 0, SEEK_SET);
68 buff = xmalloc(icf.cbIconData, pszSrcFile, __LINE__);
69 if (!buff) {
70 fclose(fp);
71 break;
72 }
73 fread(buff, icf.cbIconData, 1, fp);
74 icf.pIconData = (PVOID) buff;
75 fclose(fp);
76 }
77 }
78 for (x = 1; x < 15; x++) {
79 if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
80 icid = (ULONG) x;
81 break;
82 }
83 }
84 for (x = 18; x < 23; x++) {
85 if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
86 icid = (ULONG) x;
87 break;
88 }
89 }
90 if (!WinSetSysPointerData(hwndDeskTop, icid,
91 (PICONINFO) ((filename && *filename) ?
92 &icf : NULL))) {
93 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinSetSysPointerData");
94 }
95 xfree(buff, pszSrcFile, __LINE__);
96 }
97 WinDismissDlg(hwnd, 1);
98 break;
99
100 case IDM_HELP:
101 if (hwndHelp)
102 WinSendMsg(hwndHelp,
103 HM_DISPLAY_HELP,
104 MPFROM2SHORT(HELP_SETICON, 0), MPFROMSHORT(HM_RESOURCEID));
105 break;
106
107 case DID_CANCEL:
108 WinDismissDlg(hwnd, 0);
109 break;
110 }
111 return 0;
112 }
113 return WinDefDlgProc(hwnd, msg, mp1, mp2);
114}
115
116#pragma alloc_text(MENU,SetIconDlgProc)
Note: See TracBrowser for help on using the repository browser.