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
RevLine 
[335]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
[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"
[1187]28#include "wrappers.h" // xfsopen
[1039]29#include "fortify.h"
[2]30
31#pragma data_seg(DATA2)
32
[335]33static PSZ pszSrcFile = __FILE__;
[2]34
[551]35MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[335]36{
[551]37 switch (msg) {
38 case WM_INITDLG:
[574]39 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
[551]40 WinCheckButton(hwnd, SETICON_SPTR_ARROW, TRUE);
41 break;
[2]42
[551]43 case WM_CONTROL:
44 return 0;
[2]45
[551]46 case WM_COMMAND:
47 switch (SHORT1FROMMP(mp1)) {
48 case DID_OK:
49 {
[574]50 CHAR *filename = WinQueryWindowPtr(hwnd, QWL_USER), *buff = NULL;
[551]51 ICONINFO icf;
52 ULONG icid = SPTR_ARROW;
53 INT x;
54 HWND hwndDeskTop;
55 FILE *fp;
[2]56
[551]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 {
[766]67 fseek(fp, 0, SEEK_END);
[551]68 icf.cbIconData = ftell(fp);
[766]69 fseek(fp, 0, SEEK_SET);
[551]70 buff = xmalloc(icf.cbIconData, pszSrcFile, __LINE__);
71 if (!buff) {
72 fclose(fp);
73 break;
[335]74 }
[551]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 }
[1039]97 free(buff);
[551]98 }
99 WinDismissDlg(hwnd, 1);
100 break;
[2]101
[551]102 case IDM_HELP:
103 if (hwndHelp)
104 WinSendMsg(hwndHelp,
105 HM_DISPLAY_HELP,
106 MPFROM2SHORT(HELP_SETICON, 0), MPFROMSHORT(HM_RESOURCEID));
107 break;
[2]108
[551]109 case DID_CANCEL:
110 WinDismissDlg(hwnd, 0);
111 break;
112 }
113 return 0;
[2]114 }
[551]115 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]116}
[793]117
118#pragma alloc_text(MENU,SetIconDlgProc)
Note: See TracBrowser for help on using the repository browser.