-
Notifications
You must be signed in to change notification settings - Fork 74
/
siframe.c
104 lines (91 loc) · 2.11 KB
/
siframe.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <string.h>
#include <stdio.h>
#include "siframe.h"
#include "tabctl.h"
#include "const.h"
extern HWND hwnd_si_frame;
extern HWND hwnd_tab_ctl;
extern int last_active_item;
static WNDPROC old_si_frame_proc = NULL;
static BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lparam)
{
DWORD processid = *((DWORD*)lparam);
DWORD threadprocessid = 0;
GetWindowThreadProcessId(hwnd,&threadprocessid);
if(threadprocessid == processid && GetParent(hwnd) == NULL)
{
*((HWND*)lparam) = hwnd;
return FALSE;
}
return TRUE;
}
//»ñÈ¡´°¿Ú¾ä±ú
HWND GetSiFrameHwnd(void)
{
DWORD processid = GetCurrentProcessId();
if(!EnumWindows(EnumWindowsProc,(LPARAM)&processid))
{
return (HWND)processid;
}
return NULL;
}
static LRESULT CALLBACK SiFrameSubClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_SETTEXT:
{
char buf[SI_BUF_SIZE];
strcpy(buf,(char*)lParam);
strcat(buf,PLUGIN_TITLE);
lParam = (LPARAM)buf;
}
break;
case WM_NOTIFY:
{
LPNMHDR hdr = (LPNMHDR)lParam;
if(hdr->hwndFrom != hwnd_tab_ctl)
{
break;
}
if(hdr->code == TCN_SELCHANGE)
{
SiTabCtl_OnSelChange();
}
else if(hdr->code == TCN_SELCHANGING)
{
last_active_item = SiTabCtl_GetCurItem();
}
else if(hdr->code == NM_CLICK)
{
SiTabCtl_OnLButtonClk();
}
}
break;
case WM_DRAWITEM:
{
DRAWITEMSTRUCT* item = (DRAWITEMSTRUCT*)lParam;
if (item->hwndItem != hwnd_tab_ctl)
break;
SiTabCtl_OnDrawItem(item);
}
break;
default:
break;
}
LRESULT lr = CallWindowProc(old_si_frame_proc, hWnd, uMsg, wParam, lParam);
return lr;
}
//Ìæ»»´°¿ÚÏûÏ¢
void HookSiFrame(void)
{
char text[256];
memset(text,0,sizeof(text));
GetWindowText(hwnd_si_frame,text,sizeof(text));
strcat(text,PLUGIN_TITLE);
SetWindowText(hwnd_si_frame,text);
old_si_frame_proc = (WNDPROC)GetWindowLong(hwnd_si_frame,GWL_WNDPROC);
SetWindowLong(hwnd_si_frame,GWL_WNDPROC,(DWORD)SiFrameSubClass);
//create tabctl
SiTabCtl_Create(hwnd_si_frame);
}