source: trunk/dll/seticon.c@ 907

Last change on this file since 907 was 907, checked in by Steven Levine, 18 years ago

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

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