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