[comp.windows.ms.programmer] How can I access the backround

dzoey@terminus.umd.edu (Joe Herman) (12/18/90)

Hello, I'm trying to write a program which draws in the backround (root)
window.  The method I'm trying doesn't seem to be working for my
program, but it does work for others.  I wonder if someone could tell
me what I'm doing wrong.

I first tried to just draw on in the window returned by GetDesktopWindow(),
but that draws on the desktop, not the backround (i.e. it draws over
everything).

Next I grabbed the source to Brian Farmer's port of fuse.  His fuses move
in the backround so I figure I'd try his method.  Unfortunatly I keep getting
application errors.  Here's what I do:

		...

	/* set up drawing in the backround window */
	/* get the root window descriptor */
	backwin = GetDesktopWindow();
		
	/* now replace the WinProc function for that window with our own */
	rootfunc = (FARPROC) GetWindowLong (backwin, GWL_WNDPROC);
	SetWindowLong (backwin, GWL_WNDPROC, (LONG) ProcessRootMsgs);

		 ...

/* Handle messages coming to the root window.  Basically pass everything */
/* but redraw messages */
long FAR PASCAL ProcessRootMsgs (HWND hWnd, WORD message, WORD wParam, LONG lParam)
{
    if (message != WM_ERASEBKGND)
	return (CallWindowProc (rootfunc, hWnd, message, wParam, lParam));
    RedrawSelf (hWnd, message, wParam, lParam);
    return (1);
}
				

I get an application error on the first message (which is an unknown
message #0x88) that ProcessRootMsgs receives.  I'm also not sure why
I need to use CallWindowProc() instead of just dereferencing the rootfunc
variable, but Brian's code did it that way and the SDK says to do it that
way.

Any help or pointers to source of other programs that write in the backround
window would be appreciated.

				Adthanksvance,

				Joe Herman
				U. of Md.

dzoey@terminus.umd.edu

P.S.  I get the application error when I pass the 0x88 message to
      CallWindowProc().  Since that's the root window, an application
      error there takes me out of windows.  Don't try this at home.

-- 
"Everything is wonderful until you know something about it."

miked@banyan.UUCP (Mike Deem@Eng@Banyan) (12/20/90)

In article <7734@umd5.umd.edu> dzoey@terminus.umd.edu (Joe Herman) writes:
> Here's what I do:
>	rootfunc = (FARPROC) GetWindowLong (backwin, GWL_WNDPROC);
>	SetWindowLong (backwin, GWL_WNDPROC, (LONG) ProcessRootMsgs);

You need to add your ProcessRootMsgs function to your EXPORTS section of your
.DEF file. You should also use a pointer to your function returned by 
MakeProcInstance as the parameter to SetWindowLong.