source: trunk/dll/seticon.c@ 1187

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

Ticket 187: Draft 2: Move remaining function declarations

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