source: trunk/dll/seticon.c@ 766

Last change on this file since 766 was 766, checked in by Gregg Young, 18 years ago

format cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1
2/***********************************************************************
3
4 $Id: seticon.c 766 2007-08-05 20:21:20Z gyoung $
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
14***********************************************************************/
15
16#define INCL_DOS
17#define INCL_WIN
18#include <os2.h>
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <ctype.h>
24#include <share.h>
25
26#include "fm3dll.h"
27#include "fm3dlg.h"
28
29#pragma data_seg(DATA2)
30
31static PSZ pszSrcFile = __FILE__;
32
33#pragma alloc_text(MENU,SetIconDlgProc)
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 if (buff)
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}
Note: See TracBrowser for help on using the repository browser.