How to watch for a window being opened?

BlitzMax Forums/BlitzMax Programming/How to watch for a window being opened?

ImaginaryHuman(Posted 2010) [#1]
Hey,

In Window's I'm trying to get a BlitzMax program to create a Hook into the Window's event stream, to watch for the creation of a specifically-named window. Once the Hook function sees the window is being created it is supposed to reposition the window, prior to it becoming visible. I've got some of the code working... creation of the hook function in a dll, loading of the dll, finding the function, adding the hook. However the hook function itself is not functioning properly.

I don't know if it's supposed to have Short-sized parameters for wParam and lParam? And just the general structure/behavior of the function might not be right. Currently when it runs it prevents any new windows from opening (which is not what I want) and sometimes creates a nice crash resulting in the disappearance of the task bar. I'm obviously doing some things not quite right. I included some structs and a piece of C code in the comments at the bottom. I'd like the DLL to be in Blitz code, not C. This is partly based on a working keyboard hook that someone else posted, which seemed to work, but this is not working.

If anyone can point me in the right direction I'd be very grateful. I also don't quite understand what would be the correct/safe way to go into the two structures to change the window x,y,width,height, and how to read the name of the window to see if it's the one I want?

The hook function as DLLTest2.bmx:


The DLLTest2.def file which is needed to build the DLL:
EXPORTS
WindowCreationHook=bb_WindowCreationHook


The command to build the DLL is, from the command prompt (cmd.exe), provided the blitzmax bin folder is in your PATH environmental variable, type:
bmk.exe makelib -r DLLTest2.bmx


And the test program DLLCaller2.bmx:



ImaginaryHuman(Posted 2010) [#2]
Anyone?


ImaginaryHuman(Posted 2010) [#3]
Please, pretty please?


Czar Flavius(Posted 2010) [#4]
If I knew how I would tell you :(


ImaginaryHuman(Posted 2010) [#5]
Hmm, anyone else who has actually dabbled with hooks?