Results 1 to 9 of 9

Thread: Subclassing in C++

  1. #1
    Guest

    Angry

    When I hear people talking about using VB to subclass windows that arent yours, they say you need a C++ DLL,
    but I heard somebody say on this forum that you still need a DLL to do it in C++....


    is there ANY WAY to subclass any window in C++ without using a DLL???


    Thanks,

    Dennis

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Nope. The reason you need a dll is that the foreign procedure can't access the memory of a standard exe. but it can get at the memory in a standard dll. It's not too hard, just make the dll to subclass it (put in all the stuff you'd put in a standard module in VB) then call the functions in the dll. windows will automaticly inject the dll into the foreign procedure.

  3. #3
    Guest
    Ok, I see now....
    How would I go about doing that?
    would I have to have a specific DLL for each thing I want to subclass?
    or could I just have a universal one???

    and on the subject of DLL's. how do you make one?
    I tried making a simple message box DLL, but when I tried to use it from VB it said that it couldnt find the DLL entry point.



  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Some function names are a bit dodgy - what name did you use for your function?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Guest
    You can call the built-in SubClass routine.
    Code:
    CTestDlg dlg;
    dlg.SubclassWindow(m_hWnd);

  6. #6
    Guest
    Parksie, I named the function MsgBBox.


    Megatron, is that part of MFC??
    because I dont want to use MFC.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I think that's only for MFC.

    Dennis - you can't create standard DLLs in VB - you have to use C++ or another language that makes them. Also, make a .def file, with this in it:
    Code:
    LIBRARY yourdll.dll
    
    DESCRIPTION 'My DLL'
    
    EXPORTS
    	Function_A
    	Different_function
    Add it to your project, and it should work...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Guest
    I know I cant create standard DLL's in VB, I was talking about in C++,
    I made one with a fucntion of MsgBBox, and when i tried accessing it from vb, It said it couldnt find the DLL entry point.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You need to specifically export the function. This is for VC++:
    Code:
    __declspec(dllexport) long MsgBBox(HWND hWnd, ...) {
        return 0;
    }
    then put this into the .def file, which tells the DLL creation process what to export:
    Code:
    LIBRARY yourdll.dll
    
    DESCRIPTION 'My DLL'
    
    EXPORTS
    	MsgBBox
    If you add it to your project, it will export the named functions.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width