1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: seticon.c 335 2006-07-25 19:03:44Z root $
|
---|
5 |
|
---|
6 | Edit ICON EA
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2006 Steven H.Levine
|
---|
10 |
|
---|
11 | 17 Jul 06 SHL Use Runtime_Error
|
---|
12 |
|
---|
13 | ***********************************************************************/
|
---|
14 |
|
---|
15 | #define INCL_DOS
|
---|
16 | #define INCL_WIN
|
---|
17 | #include <os2.h>
|
---|
18 |
|
---|
19 | #include <stdio.h>
|
---|
20 | #include <stdlib.h>
|
---|
21 | #include <string.h>
|
---|
22 | #include <ctype.h>
|
---|
23 | #include <share.h>
|
---|
24 |
|
---|
25 | #include "fm3dll.h"
|
---|
26 | #include "fm3dlg.h"
|
---|
27 |
|
---|
28 | #pragma data_seg(DATA2)
|
---|
29 |
|
---|
30 | static PSZ pszSrcFile = __FILE__;
|
---|
31 |
|
---|
32 | #pragma alloc_text(MENU,SetIconDlgProc)
|
---|
33 |
|
---|
34 |
|
---|
35 | MRESULT EXPENTRY SetIconDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
---|
36 | {
|
---|
37 | switch(msg) {
|
---|
38 | case WM_INITDLG:
|
---|
39 | WinSetWindowPtr(hwnd,0,(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,0),*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,0L,SEEK_END);
|
---|
68 | icf.cbIconData = ftell(fp);
|
---|
69 | fseek(fp,0L,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 | {
|
---|
96 | Win_Error(hwnd,hwnd,pszSrcFile,__LINE__,"WinSetSysPointerData");
|
---|
97 | }
|
---|
98 | if(buff)
|
---|
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),
|
---|
109 | MPFROMSHORT(HM_RESOURCEID));
|
---|
110 | break;
|
---|
111 |
|
---|
112 | case DID_CANCEL:
|
---|
113 | WinDismissDlg(hwnd,0);
|
---|
114 | break;
|
---|
115 | }
|
---|
116 | return 0;
|
---|
117 | }
|
---|
118 | return WinDefDlgProc(hwnd,msg,mp1,mp2);
|
---|
119 | }
|
---|
120 |
|
---|