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