-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsicon.c
72 lines (57 loc) · 1.71 KB
/
msicon.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* msicon.c
*/
#include "msicon.h"
#include <tchar.h>
#include <locale.h>
#include <fcntl.h>
/*
* The following function is a dummy one; replace it for
* your C function definitions.
*/
ScmObj test_msicon(void)
{
return SCM_MAKE_STR("msicon is working");
}
// set window icon
void set_window_icon(LPCTSTR classname, LPCTSTR windowname, LPCTSTR iconfilename) {
HWND hwnd;
HANDLE icon;
#if 0
// for printing wide characters
int mode_old;
_tsetlocale(LC_ALL, _T(""));
fflush(stdout);
mode_old = _setmode(_fileno(stdout), _O_TEXT);
if (classname != NULL) { _tprintf(_T("classname=%s\n"), classname); }
if (windowname != NULL) { _tprintf(_T("windowname=%s\n"), windowname); }
if (iconfilename != NULL) { _tprintf(_T("iconfilename=%s\n"), iconfilename); }
fflush(stdout);
if (mode_old != -1) { _setmode(_fileno(stdout), mode_old); }
#endif
// get window handle
hwnd = FindWindow(classname, windowname);
if (hwnd == NULL) { return; }
//printf("hwnd=%d\n", hwnd);
// load icon
icon = LoadImage(NULL, iconfilename, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
if (icon == NULL) { return; }
//printf("icon=%d\n", icon);
// set icon
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon);
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon);
}
/*
* Module initialization function.
*/
extern void Scm_Init_msiconlib(ScmModule*);
void Scm_Init_msicon(void)
{
ScmModule *mod;
/* Register this DSO to Gauche */
SCM_INIT_EXTENSION(msicon);
/* Create the module if it doesn't exist yet. */
mod = SCM_MODULE(SCM_FIND_MODULE("msicon", TRUE));
/* Register stub-generated procedures */
Scm_Init_msiconlib(mod);
}