[335] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: seticon.c 1009 2008-05-10 07:51:58Z 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
|
---|
[985] | 14 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[335] | 15 |
|
---|
| 16 | ***********************************************************************/
|
---|
| 17 |
|
---|
[2] | 18 | #include <stdlib.h>
|
---|
| 19 | #include <string.h>
|
---|
| 20 | #include <share.h>
|
---|
[335] | 21 |
|
---|
[907] | 22 | #define INCL_WIN
|
---|
| 23 | #define INCL_LONGLONG // dircnrs.h
|
---|
| 24 |
|
---|
| 25 | #include "fm3dlg.h"
|
---|
| 26 | #include "errutil.h" // Dos_Error...
|
---|
[2] | 27 | #include "fm3dll.h"
|
---|
| 28 |
|
---|
| 29 | #pragma data_seg(DATA2)
|
---|
| 30 |
|
---|
[335] | 31 | static PSZ pszSrcFile = __FILE__;
|
---|
[2] | 32 |
|
---|
[551] | 33 | MRESULT EXPENTRY SetIconDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[335] | 34 | {
|
---|
[551] | 35 | switch (msg) {
|
---|
| 36 | case WM_INITDLG:
|
---|
[574] | 37 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
|
---|
[551] | 38 | WinCheckButton(hwnd, SETICON_SPTR_ARROW, TRUE);
|
---|
| 39 | break;
|
---|
[2] | 40 |
|
---|
[551] | 41 | case WM_CONTROL:
|
---|
| 42 | return 0;
|
---|
[2] | 43 |
|
---|
[551] | 44 | case WM_COMMAND:
|
---|
| 45 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 46 | case DID_OK:
|
---|
| 47 | {
|
---|
[574] | 48 | CHAR *filename = WinQueryWindowPtr(hwnd, QWL_USER), *buff = NULL;
|
---|
[551] | 49 | ICONINFO icf;
|
---|
| 50 | ULONG icid = SPTR_ARROW;
|
---|
| 51 | INT x;
|
---|
| 52 | HWND hwndDeskTop;
|
---|
| 53 | FILE *fp;
|
---|
[2] | 54 |
|
---|
[551] | 55 | hwndDeskTop = WinQueryDesktopWindow(WinQueryAnchorBlock(hwnd),
|
---|
| 56 | NULLHANDLE);
|
---|
| 57 | memset(&icf, 0, sizeof(ICONINFO));
|
---|
| 58 | icf.cb = sizeof(ICONINFO);
|
---|
| 59 | icf.fFormat = ICON_DATA;
|
---|
| 60 | if (filename && *filename) {
|
---|
| 61 | fp = xfsopen(filename, "rb", SH_DENYNO, pszSrcFile, __LINE__);
|
---|
| 62 | if (!fp)
|
---|
| 63 | break;
|
---|
| 64 | else {
|
---|
[766] | 65 | fseek(fp, 0, SEEK_END);
|
---|
[551] | 66 | icf.cbIconData = ftell(fp);
|
---|
[766] | 67 | fseek(fp, 0, SEEK_SET);
|
---|
[551] | 68 | buff = xmalloc(icf.cbIconData, pszSrcFile, __LINE__);
|
---|
| 69 | if (!buff) {
|
---|
| 70 | fclose(fp);
|
---|
| 71 | break;
|
---|
[335] | 72 | }
|
---|
[551] | 73 | fread(buff, icf.cbIconData, 1, fp);
|
---|
| 74 | icf.pIconData = (PVOID) buff;
|
---|
| 75 | fclose(fp);
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | for (x = 1; x < 15; x++) {
|
---|
| 79 | if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
|
---|
| 80 | icid = (ULONG) x;
|
---|
| 81 | break;
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | for (x = 18; x < 23; x++) {
|
---|
| 85 | if (WinQueryButtonCheckstate(hwnd, SETICON_FRAME + x)) {
|
---|
| 86 | icid = (ULONG) x;
|
---|
| 87 | break;
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | if (!WinSetSysPointerData(hwndDeskTop, icid,
|
---|
| 91 | (PICONINFO) ((filename && *filename) ?
|
---|
| 92 | &icf : NULL))) {
|
---|
| 93 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinSetSysPointerData");
|
---|
| 94 | }
|
---|
[1009] | 95 | xfree(buff, pszSrcFile, __LINE__);
|
---|
[551] | 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)
|
---|