source: trunk/dll/seticon.c@ 1348

Last change on this file since 1348 was 1348, checked in by Gregg Young, 17 years ago

More code cleanup

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