subclasswindow.cpp

来自「虚拟打印机」· C++ 代码 · 共 82 行

CPP
82
字号
/* * * subclasswindow.cpp * *   Copyright (C) 2006 Michael H. Overlin   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      Contact at poster_printer@yahoo.com */#include "subclasswindow.h"#include "utils.h"static TCHAR atstrProp[] = TEXT("RANdfoiu23132");SubClassWindow::SubClassWindow(HINSTANCE hinst, HWND hwndTarget) :	Window(hinst, hwndTarget){	m_lpfnOldWndProc = (WNDPROC) ::GetWindowLongPtr(hwndTarget, GWL_WNDPROC);	WNDPROC lpfn = (WNDPROC) Window::TheirWndProc<SubClassWindow>;	::SetWindowLong(hwndTarget, GWL_WNDPROC, (LONG_PTR) lpfn);	TheirInstallObjPtr(hwndTarget, this);}SubClassWindow::~SubClassWindow() {	if (::IsWindow(m_hwnd)) {		::SetWindowLongPtr(m_hwnd, GWL_WNDPROC, (LONG_PTR) m_lpfnOldWndProc);	}}LRESULT SubClassWindow::DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam) {	LRESULT lres = ::CallWindowProc(m_lpfnOldWndProc, m_hwnd, msg, wParam, lParam);	return lres;}Window* SubClassWindow::TheirGetObjPtr(HWND hwnd) {	Window *pw = (Window*) ::GetProp(hwnd, atstrProp);	return pw;}void SubClassWindow::PaintMsg(OUT MSGRESULT& mr, UINT msg, WPARAM wParam, LPARAM lParam) {	// DO NOTHING}void SubClassWindow::TheirInstallObjPtr(HWND hwnd, Window *pw) {	::SetProp(hwnd, atstrProp, (HANDLE) pw);}void SubClassWindow::TheirRemoveObjPtr(HWND hwnd, Window *pw) {	::SetProp(hwnd, atstrProp, (HANDLE) NULL);}LPCTSTR SubClassWindow::TheirGetWindowClassName(void) {	// MAYBE THIS SHOULD RETURN INFO ON THE SUBCLASSED WINDOWS CLASS	// IMPLEMENT LATER IF I EVER NEED IT	ASSERTFAIL();	return NULL;}void SubClassWindow::TheirGetClassInfo(OUT ::WNDCLASSEX & wcex, 	IN HINSTANCE hinst, IN LPCTSTR lptstrClass, IN WNDPROC wndproc, IN DWORD dwcExtra) {	// MAYBE THIS SHOULD RETURN INFO ON THE SUBCLASSED WINDOWS CLASS	// IMPLEMENT LATER IF I EVER NEED IT	ASSERTFAIL();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?