source: trunk/dll/seticon.c@ 1212

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

Ticket 187: Move data declarations/definitions out of fm3dll.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
RevLine 
[335]1
2/***********************************************************************
3
4 $Id: seticon.c 1212 2008-09-13 06:52:38Z jbs $
5
6 Edit ICON EA
7
8 Copyright (c) 1993-98 M. Kimes
[574]9 Copyright (c) 2006, 2007 Steven H.Levine
[335]10
11 17 Jul 06 SHL Use Runtime_Error
[574]12 22 Mar 06 GKY Use QWL_USER
[793]13 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[335]14
15***********************************************************************/
16
[2]17#include <stdlib.h>
18#include <string.h>
19#include <share.h>
[335]20
[907]21#define INCL_WIN
22#define INCL_LONGLONG // dircnrs.h
23
24#include "fm3dlg.h"
25#include "errutil.h" // Dos_Error...
[1163]26#include "seticon.h"
[2]27#include "fm3dll.h"
[1212]28#include "notebook.h" // Data declaration(s)
[1187]29#include "wrappers.h" // xfsopen
[1039]30#include "fortify.h"
[2]31
32#pragma data_seg(DATA2)
33
[335]34static PSZ pszSrcFile = __FILE__;
[2]35
[551]36MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[335]37{
[551]38 switch (msg) {
39 case WM_INITDLG:
[574]40 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
[551]41 WinCheckButton(hwnd, SETICON_SPTR_ARROW, TRUE);
42 break;
[2]43
[551]44 case WM_CONTROL:
45 return 0;
[2]46
[551]47 case WM_COMMAND:
48 switch (SHORT1FROMMP(mp1)) {
49 case DID_OK:
50 {
[574]51 CHAR *filename = WinQueryWindowPtr(hwnd, QWL_USER), *buff = NULL;
[551]52 ICONINFO icf;
53 ULONG icid = SPTR_ARROW;
54 INT x;
55 HWND hwndDeskTop;
56 FILE *fp;
[2]57
[551]58 hwndDeskTop = WinQueryDesktopWindow(WinQueryAnchorBlock(hwnd),
59 NULLHANDLE);
60 memset(&icf, 0, sizeof(ICONINFO));
61 icf.cb = sizeof(ICONINFO);
62 icf.fFormat = ICON_DATA;
63 if (filename && *filename) {
64 fp = xfsopen(filename, "rb", SH_DENYNO, pszSrcFile, __LINE__);
65 if (!fp)
66 break;
67 else {
[766]68 fseek(fp, 0, SEEK_END);
[551]69 icf.cbIconData = ftell(fp);
[766]70 fseek(fp, 0, SEEK_SET);
[551]71 buff = xmalloc(icf.cbIconData, pszSrcFile, __LINE__);
72 if (!buff) {
73 fclose(fp);
74 break;
[335]75 }
[551]76 fread(buff, icf.cbIconData, 1, fp);
77 icf.pIconData = (PVOID) buff;
78 fclose(fp);
79 }
80 }
81 for (x = 1; x < 15; x++) {
82 if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
83 icid = (ULONG) x;
84 break;
85 }
86 }
87 for (x = 18; x < 23; x++) {
88 if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
89 icid = (ULONG) x;
90 break;
91 }
92 }
93 if (!WinSetSysPointerData(hwndDeskTop, icid,
94 (PICONINFO) ((filename && *filename) ?
95 &icf : NULL))) {
96 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinSetSysPointerData");
97 }
[1039]98 free(buff);
[551]99 }
100 WinDismissDlg(hwnd, 1);
101 break;
[2]102
[551]103 case IDM_HELP:
104 if (hwndHelp)
105 WinSendMsg(hwndHelp,
106 HM_DISPLAY_HELP,
107 MPFROM2SHORT(HELP_SETICON, 0), MPFROMSHORT(HM_RESOURCEID));
108 break;
[2]109
[551]110 case DID_CANCEL:
111 WinDismissDlg(hwnd, 0);
112 break;
113 }
114 return 0;
[2]115 }
[551]116 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]117}
[793]118
119#pragma alloc_text(MENU,SetIconDlgProc)
Note: See TracBrowser for help on using the repository browser.