source: trunk/dll/seticon.c@ 2

Last change on this file since 2 was 2, checked in by root, 23 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1#define INCL_DOS
2#define INCL_WIN
3
4#include <os2.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8#include <ctype.h>
9#include <share.h>
10#include "fm3dll.h"
11#include "fm3dlg.h"
12
13#pragma data_seg(DATA2)
14#pragma alloc_text(MENU,SetIconDlgProc)
15
16
17
18MRESULT EXPENTRY SetIconDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
19
20 switch(msg) {
21 case WM_INITDLG:
22 WinSetWindowPtr(hwnd,0,(PVOID)mp2);
23 WinCheckButton(hwnd,SETICON_SPTR_ARROW,TRUE);
24 break;
25
26 case WM_CONTROL:
27 return 0;
28
29 case WM_COMMAND:
30 switch(SHORT1FROMMP(mp1)) {
31 case DID_OK:
32 {
33 CHAR *filename = WinQueryWindowPtr(hwnd,0),*buff = NULL;
34 ICONINFO icf;
35 ULONG icid = SPTR_ARROW;
36 INT x;
37 HWND hwndDeskTop;
38 FILE *fp;
39
40 hwndDeskTop = WinQueryDesktopWindow(WinQueryAnchorBlock(hwnd),
41 NULLHANDLE);
42 memset(&icf,0,sizeof(ICONINFO));
43 icf.cb = sizeof(ICONINFO);
44 icf.fFormat = ICON_DATA;
45 if(filename && *filename) {
46 fp = _fsopen(filename,"rb",SH_DENYNO);
47 if(fp) {
48 fseek(fp,0L,SEEK_END);
49 icf.cbIconData = ftell(fp);
50 fseek(fp,0L,SEEK_SET);
51 buff = malloc(icf.cbIconData);
52 if(!buff) {
53 fclose(fp);
54 DosBeep(50,100);
55 break;
56 }
57 fread(buff,icf.cbIconData,1,fp);
58 icf.pIconData = (PVOID)buff;
59 fclose(fp);
60 }
61 else {
62 DosBeep(50,100);
63 break;
64 }
65 }
66 for(x = 1;x < 15;x++) {
67 if(WinQueryButtonCheckstate(hwnd,SETICON_FRAME + x)) {
68 icid = (ULONG)x;
69 break;
70 }
71 }
72 for(x = 18;x < 23;x++) {
73 if(WinQueryButtonCheckstate(hwnd,SETICON_FRAME + x)) {
74 icid = (ULONG)x;
75 break;
76 }
77 }
78 if(!WinSetSysPointerData(hwndDeskTop,icid,
79 (PICONINFO)((filename && *filename) ?
80 &icf : NULL)))
81 DosBeep(250,100);
82 if(buff)
83 free(buff);
84 }
85 WinDismissDlg(hwnd,1);
86 break;
87
88 case IDM_HELP:
89 if(hwndHelp)
90 WinSendMsg(hwndHelp,
91 HM_DISPLAY_HELP,
92 MPFROM2SHORT(HELP_SETICON,0),
93 MPFROMSHORT(HM_RESOURCEID));
94 break;
95
96 case DID_CANCEL:
97 WinDismissDlg(hwnd,0);
98 break;
99 }
100 return 0;
101 }
102 return WinDefDlgProc(hwnd,msg,mp1,mp2);
103}
104
Note: See TracBrowser for help on using the repository browser.