1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: seticon.c 907 2008-01-06 07:26:17Z 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 |
|
---|
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 "fm3dll.h"
|
---|
27 |
|
---|
28 | #pragma data_seg(DATA2)
|
---|
29 |
|
---|
30 | static PSZ pszSrcFile = __FILE__;
|
---|
31 |
|
---|
32 | MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
33 | {
|
---|
34 | switch (msg) {
|
---|
35 | case WM_INITDLG:
|
---|
36 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
|
---|
37 | WinCheckButton(hwnd, SETICON_SPTR_ARROW, TRUE);
|
---|
38 | break;
|
---|
39 |
|
---|
40 | case WM_CONTROL:
|
---|
41 | return 0;
|
---|
42 |
|
---|
43 | case WM_COMMAND:
|
---|
44 | switch (SHORT1FROMMP(mp1)) {
|
---|
45 | case DID_OK:
|
---|
46 | {
|
---|
47 | CHAR *filename = WinQueryWindowPtr(hwnd, QWL_USER), *buff = NULL;
|
---|
48 | ICONINFO icf;
|
---|
49 | ULONG icid = SPTR_ARROW;
|
---|
50 | INT x;
|
---|
51 | HWND hwndDeskTop;
|
---|
52 | FILE *fp;
|
---|
53 |
|
---|
54 | hwndDeskTop = WinQueryDesktopWindow(WinQueryAnchorBlock(hwnd),
|
---|
55 | NULLHANDLE);
|
---|
56 | memset(&icf, 0, sizeof(ICONINFO));
|
---|
57 | icf.cb = sizeof(ICONINFO);
|
---|
58 | icf.fFormat = ICON_DATA;
|
---|
59 | if (filename && *filename) {
|
---|
60 | fp = xfsopen(filename, "rb", SH_DENYNO, pszSrcFile, __LINE__);
|
---|
61 | if (!fp)
|
---|
62 | break;
|
---|
63 | else {
|
---|
64 | fseek(fp, 0, SEEK_END);
|
---|
65 | icf.cbIconData = ftell(fp);
|
---|
66 | fseek(fp, 0, SEEK_SET);
|
---|
67 | buff = xmalloc(icf.cbIconData, pszSrcFile, __LINE__);
|
---|
68 | if (!buff) {
|
---|
69 | fclose(fp);
|
---|
70 | break;
|
---|
71 | }
|
---|
72 | fread(buff, icf.cbIconData, 1, fp);
|
---|
73 | icf.pIconData = (PVOID) buff;
|
---|
74 | fclose(fp);
|
---|
75 | }
|
---|
76 | }
|
---|
77 | for (x = 1; x < 15; x++) {
|
---|
78 | if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
|
---|
79 | icid = (ULONG) x;
|
---|
80 | break;
|
---|
81 | }
|
---|
82 | }
|
---|
83 | for (x = 18; x < 23; x++) {
|
---|
84 | if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
|
---|
85 | icid = (ULONG) x;
|
---|
86 | break;
|
---|
87 | }
|
---|
88 | }
|
---|
89 | if (!WinSetSysPointerData(hwndDeskTop, icid,
|
---|
90 | (PICONINFO) ((filename && *filename) ?
|
---|
91 | &icf : NULL))) {
|
---|
92 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinSetSysPointerData");
|
---|
93 | }
|
---|
94 | if (buff)
|
---|
95 | free(buff);
|
---|
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)
|
---|