示例#1
0
static void GetWordTextOutHook (TEverythingParams *TP)
{
	CurParams = TP;
	ScreenToClient(TP->WND, &(TP->Pt));
	if (TP->Pt.y<0) { // point is outside the client area
		TCHAR buffer[256];
		HMENU menu;
		TCHAR buffer2[256];

		/* Reset window title to make some of the hooked function to be invoked */
		GetWindowText(TP->WND, buffer, sizeof(buffer)/sizeof(buffer[0]));
		SetWindowText(TP->WND, TEXT(""));
		GetWindowText(TP->WND, buffer2, sizeof(buffer2)/sizeof(buffer2[0]));
		if (buffer2[0]) { // MDI window.
			TCHAR *p = StrStr(buffer, buffer2);
			if (p) {
				if (p == buffer) { // FWS_PREFIXTITLE
					StrCpy(buffer, buffer+lstrlen(buffer2));
				} else {
					*p = TEXT('\0');
				}
			}
		}
		CurParams->Active = TRUE;
		SetWindowText(TP->WND, buffer);
		CurParams->Active = FALSE;
		menu = GetMenu(TP->WND);
		if (menu) {
			ClientToScreen(TP->WND, &(TP->Pt));
			IterateThroughItems(TP->WND, menu, &(TP->Pt));
		}
	}
	else {
		/* redraw a part of the window to make some of the hooked functions to be invoked */
		RECT UpdateRect;
		GetClientRect(TP->WND, &UpdateRect);
		UpdateRect.top = TP->Pt.y;
		UpdateRect.bottom = TP->Pt.y + 1;
		CurParams->Active = TRUE;
		InvalidateRect(TP->WND, &UpdateRect, FALSE);
		UpdateWindow(TP->WND);
		CurParams->Active = FALSE;
	}
	CurParams = NULL;
}
static void GetWordTextOutHook (TEverythingParams *TP)
{
	CurParams = TP;
	ScreenToClient(TP->WND, &(TP->Pt));
	if (TP->Pt.y<0) {
		char buffer[256];
		HMENU menu;
		char buffer2[256];

		GetWindowText(TP->WND, buffer, sizeof(buffer)-1);
		SetWindowText(TP->WND, "");
		
		GetWindowText(TP->WND, buffer2, sizeof(buffer2)-1);
		if (buffer2[0]) { // MDI window.
			char *p = strstr(buffer, buffer2);
			if (p) {
				if (p == buffer) { // FWS_PREFIXTITLE
					strcpy(buffer, buffer+strlen(buffer2));
				} else {
					*p = '\0';
				}
			}
		}
		CurParams->Active = TRUE;
		SetWindowText(TP->WND, buffer);
		CurParams->Active = FALSE;
		menu = GetMenu(TP->WND);
		if (menu) {
			ClientToScreen(TP->WND, &(TP->Pt));
			IterateThroughItems(TP->WND, menu, &(TP->Pt));
		}
	}
	else {
		RECT UpdateRect;
		GetClientRect(TP->WND, &UpdateRect);
		UpdateRect.top = TP->Pt.y;
		UpdateRect.bottom = TP->Pt.y + 1;
		CurParams->Active = TRUE;
		InvalidateRect(TP->WND, &UpdateRect, FALSE);
		UpdateWindow(TP->WND);
		CurParams->Active = FALSE;
	}
	CurParams = NULL;
}