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
RevLine 
[335]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
[574]9 Copyright (c) 2006, 2007 Steven H.Levine
[335]10
11 17 Jul 06 SHL Use Runtime_Error
[574]12 22 Mar 06 GKY Use QWL_USER
[793]13 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[985]14 29 Feb 08 GKY Use xfree where appropriate
[335]15
16***********************************************************************/
17
[2]18#include <stdlib.h>
19#include <string.h>
20#include <share.h>
[335]21
[907]22#define INCL_WIN
23#define INCL_LONGLONG // dircnrs.h
24
25#include "fm3dlg.h"
26#include "errutil.h" // Dos_Error...
[2]27#include "fm3dll.h"
[1039]28#include "fortify.h"
[2]29
30#pragma data_seg(DATA2)
31
[335]32static PSZ pszSrcFile = __FILE__;
[2]33
[551]34MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[335]35{
[551]36 switch (msg) {
37 case WM_INITDLG:
[574]38 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
[551]39 WinCheckButton(hwnd, SETICON_SPTR_ARROW, TRUE);
40 break;
[2]41
[551]42 case WM_CONTROL:
43 return 0;
[2]44
[551]45 case WM_COMMAND:
46 switch (SHORT1FROMMP(mp1)) {
47 case DID_OK:
48 {
[574]49 CHAR *filename = WinQueryWindowPtr(hwnd, QWL_USER), *buff = NULL;
[551]50 ICONINFO icf;
51 ULONG icid = SPTR_ARROW;
52 INT x;
53 HWND hwndDeskTop;
54 FILE *fp;
[2]55
[551]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 {
[766]66 fseek(fp, 0, SEEK_END);
[551]67 icf.cbIconData = ftell(fp);
[766]68 fseek(fp, 0, SEEK_SET);
[551]69 buff = xmalloc(icf.cbIconData, pszSrcFile, __LINE__);
70 if (!buff) {
71 fclose(fp);
72 break;
[335]73 }
[551]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 }
[1039]96 free(buff);
[551]97 }
98 WinDismissDlg(hwnd, 1);
99 break;
[2]100
[551]101 case IDM_HELP:
102 if (hwndHelp)
103 WinSendMsg(hwndHelp,
104 HM_DISPLAY_HELP,
105 MPFROM2SHORT(HELP_SETICON, 0), MPFROMSHORT(HM_RESOURCEID));
106 break;
[2]107
[551]108 case DID_CANCEL:
109 WinDismissDlg(hwnd, 0);
110 break;
111 }
112 return 0;
[2]113 }
[551]114 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]115}
[793]116
117#pragma alloc_text(MENU,SetIconDlgProc)
Note: See TracBrowser for help on using the repository browser.