I am having trouble registering a new window class in C# using RegisterClassEx. My application already heavily uses the WinAPI via pInvoke (i.e. DllImport statements) for other functions, and that part isn't the problem, I don't think (but am open to the possibility.)
Basically, when I call CreateWindowEx, it fails with error 1407, which basically says that my class name is undefined (which I agree with.) I simply can't seem to figure out the WNDCLASSEX structure and how to use it in C#. Could anyone please post and/or send me C# sample code that will successfully register a new window class (named, for example's sake "sample_window") that will allow a call to CreateWindowEx similar to the following to succeed??
IntPtr myNewSampleWindowHWND = CreateWindowEx(WS_EX_TOPMOST, "sample_window", "", WS_VISIBLE, 0, 0, 500, 500, this.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
My goal is to create a blank (in the sense of WinAPI programming) topmost window that I can get a Graphics object from and draw a rectangle on. Other than what I specifically draw, I would like the window to be completely "blank" (A.K.A no menu or title bar, etc.) I only want what I draw to be displayed. Ultimately, the app should be able to destroy the window using something like:
Does that make sense? I know how to do this in VC++, but am trying to stick to C# for code-management purposes. I have tried and tried to no avail to get this to work in C#, and I could really use some help.
Thanks so much!!!
(points awarded to all on-subject responders)