Skip to main content
GameDev.net gamedev.net
🔒 Locked

Subclassing the console

Started by OrigamiMan64 Jun 28, 2004 at 1:06 PM 0 replies 800+ views
Original Post
OrigamiMan64
OrigamiMan64
Why does SetWindowLongPtr fail here? I keep getting error 1413: Index out of bounds.

#define _WIN32_WINNT 0x0501
#include <windows.h>

// the real message handler
WNDPROC OldConWndProc;

// intercept erase messages to eliminate an annoying flicker problem
LRESULT CALLBACK ConsoleManagerWndProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
	switch ( message )
	{
	case WM_ERASEBKGND:
		return ( LRESULT ) 1; // Say we handled it.
	}
	return CallWindowProc ( OldConWndProc, hwnd, message, wParam, lParam );
}

int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	AllocConsole (  );
	//DWORD array[1000];
	//DWORD p = GetConsoleProcessList ( array, 1000 );
	SetLastError ( 0 );
	OldConWndProc = ( WNDPROC ) SetWindowLongPtr ( GetConsoleWindow (  ), GWLP_WNDPROC, ( LONG ) ConsoleManagerWndProc );
	DWORD e = GetLastError (  );
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.