When I use RegisterClassEx() to register a custom control I have made, I'm forced to make it a local part of my application, but when I have the control code in a DLL and then call the remote function it doesn't work! Please help, Yarin.
When I use RegisterClassEx() to register a custom control I have made, I'm forced to make it a local part of my application, but when I have the control code in a DLL and then call the remote function it doesn't work! Please help, Yarin.
Well, if the DLL registers the class then all you've got to do is to create a control with that classname to see if the control works the way you made it. This is the way all controls work (user32.dll or comctl32.dll register them for you). So you are saying that the control you created with that classname when the DLL had registered the control already doesn't act as it should?
"The Internet treats censorship as damage and routes around it." - John Gilmore
Right, I know how class' work, and yes you got it right. The stupid thing about it is all GetLastError() returns is ERROR_INVALID_WINDOW_HANDLE. And like I said above, it can't be the control it's self, because it works fine when I register the control from within the program.
CreateWindowEx(0,"YourNewClass"... gives that error?
"The Internet treats censorship as damage and routes around it." - John Gilmore
No, CreateWindowEx() returns NULL. GetLastError() called immediately thereafter returns 1400 (invalid window handle). And like I said above, my code works perfectly until I import it into a DLL.
Are you sure the class gets registered? Mabye add a messagebox to the class registration part of the DLL to make sure that part of the DLL code runs.
"The Internet treats censorship as damage and routes around it." - John Gilmore
Okay, I have it figured out. I had the code in the dwReason switch of DllMain. that way all I had to do was call LoadLibrary then FreeLibrary. but as it turns out, even though the code does get called, it doesn't work unless I manually call DllMain from using GetProcAddress. Registering classes must be one of those restrictions MSDN was talking about. Thanks for the help anyway.
I don't think it is one of those restrictions, because I've seen many things register the classes only by loading the DLL (for example Scintilla). Maybe the dwReason does not contain the value you expect it to contain when loading a DLL?
"The Internet treats censorship as damage and routes around it." - John Gilmore
Oh it does. I put Beep(2000,100); right before the registration of the class, and my program beeps upon execution. That was the first problem I considered.