Thread: Unable to remotly register my custom controls.

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    Unable to remotly register my custom controls.

    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.

  2. #2
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    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

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    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.

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    CreateWindowEx(0,"YourNewClass"... gives that error?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    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.

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    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

  7. #7
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    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.

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    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

  9. #9
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  2. custom controls
    By eXistenZ in forum Windows Programming
    Replies: 5
    Last Post: 04-18-2005, 06:09 AM
  3. Creating Custom Controls
    By Grayson_Peddie in forum C# Programming
    Replies: 1
    Last Post: 12-29-2003, 01:41 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Register
    By sean345 in forum C Programming
    Replies: 7
    Last Post: 05-08-2002, 03:06 PM