source: trunk/dll/seticon.c@ 1212

Last change on this file since 1212 was 1212, checked in by John Small, 17 years ago

Ticket 187: Move data declarations/definitions out of fm3dll.h

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