Click here to Skip to main content
16,008,075 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Should Contextual menu show mnemonics ? Pin
Maximilien14-Mar-02 10:49
Maximilien14-Mar-02 10:49 
GeneralRe: Should Contextual menu show mnemonics ? Pin
Shog914-Mar-02 11:09
sitebuilderShog914-Mar-02 11:09 
GeneralRe: Should Contextual menu show mnemonics ? Pin
Maximilien14-Mar-02 13:15
Maximilien14-Mar-02 13:15 
Questionl,Winsock Spy? Pin
Aaron Schaefer14-Mar-02 8:56
Aaron Schaefer14-Mar-02 8:56 
AnswerRe: l,Winsock Spy? Pin
Tomasz Sowinski14-Mar-02 9:17
Tomasz Sowinski14-Mar-02 9:17 
AnswerRe: l,Winsock Spy? Pin
Jon Hulatt15-Mar-02 0:48
Jon Hulatt15-Mar-02 0:48 
Questionl,Winsock Spy? Pin
Aaron Schaefer14-Mar-02 8:55
Aaron Schaefer14-Mar-02 8:55 
GeneralMFC Regular DLLs and Handle Maps Pin
Dave Glick14-Mar-02 8:20
Dave Glick14-Mar-02 8:20 
Hi all,

I've got a very difficult problem that I've spent several weeks trying to figure out. I think I finnaly know the issues, but not how to solve them. I humbley submit my predicament to you fine folks here on code project to see if anyone has any insight...

Let me describe the setup:
-I have a MFC regular DLL statically linked to MFC (I don't know what language or environment my DLL will be used from and I want to support the broadest range).
-This DLL globaly subclasses certain types of GUI objects. For the purpose of providing an example, I'll use the windows BUTTON api class for illustration here.
-The DLL calls ::SetClassLong and does some mumbo-jumbo to override all BUTTON WndProcs and set them to be ownerdrawn. At the same time, I subclass all of them to a special CoolButton class derived from the MFC CButton.
-I also subclass all Dialogs so that I can intercept WM_DRAWITEM messages and send them to the child based on my handle map rather than the app's (because the app doesn't know about my subclassed CoolButtons, it would send the DrawItem message to CButtons which would assert because the DrawItem function hasn't been overridden).

Everyone still with me Smile | :)

Everything works perfectly from other languages and from within MFC except in one case, and this is the root of the problem: When a button on a dialog has had a member variable of type CButton declared from within the calling application, I ASSERT on a call to CButton::DrawItem (because no override is present) at random times (for example right after a WM_KILLFOCUS message).

I think this happens because the message pump looks like this:
-Send WM_KILLFOCUS to the AfxWndProc
-AfxWndProc sends it down the pipe
-I intercept (remember I'm looking for WM_DRAWITEM messages for the parent so I've inserted myself here)
-I want to do the default action, so I pass the WM_FILLFOCUS to the old WndProc (which I got from my call to ::SetClassLong)
-The old WndProc does the default OnKillFocus action - everything works great up to here.
-If no member CButton variable has been declared, the old WndProc sends a WM_DRAWITEM to the parent, I intercept it, take action, and viola, everything works great! If a member CButton has been declared, the default WndProc bypasses the top level windows message routing routine, I never see the WM_DRAWITEM message, and by looking up the CButton member from the application's permanent handle map it calls the CButton::DrawItem and I crash Frown | :(

The solution, as I see it, is to replace the CButton member variable with my CoolButton inside the application's permanent message map. In fact, this approach works perfectly if I compile the dll code straight into the application rather than as a DLL. My problem is that I can't get to it from the DLL. So, and thank you for sticking with me through all this, here is the question:

Is it possible to get a functioning pointer to the application's CHandleMap structure (or otherwise manipulate the handle map) from within my regular DLL?

Thanks a bunch!

Dave
GeneralRe: MFC Regular DLLs and Handle Maps Pin
Tomasz Sowinski14-Mar-02 8:42
Tomasz Sowinski14-Mar-02 8:42 
GeneralRe: MFC Regular DLLs and Handle Maps Pin
Dave Glick14-Mar-02 8:55
Dave Glick14-Mar-02 8:55 
GeneralRe: MFC Regular DLLs and Handle Maps Pin
Tomasz Sowinski14-Mar-02 9:27
Tomasz Sowinski14-Mar-02 9:27 
GeneralWrong app icon used in explorer Pin
Jason Hihn14-Mar-02 8:19
Jason Hihn14-Mar-02 8:19 
Generalpdf about win32 Pin
DiegoValdevino14-Mar-02 7:57
DiegoValdevino14-Mar-02 7:57 
GeneralRe: pdf about win32 Pin
14-Mar-02 21:03
suss14-Mar-02 21:03 
QuestionHow to use WM_COPY? Pin
Pony14-Mar-02 7:21
Pony14-Mar-02 7:21 
AnswerRe: How to use WM_COPY? Pin
Dave Glick14-Mar-02 8:25
Dave Glick14-Mar-02 8:25 
AnswerRe: How to use WM_COPY? Pin
Tomasz Sowinski14-Mar-02 8:57
Tomasz Sowinski14-Mar-02 8:57 
GeneralToolbars status Pin
Paolo Vernazza14-Mar-02 6:00
Paolo Vernazza14-Mar-02 6:00 
GeneralRe: Toolbars status Pin
Alexander Wiseman14-Mar-02 6:11
Alexander Wiseman14-Mar-02 6:11 
GeneralRe: Toolbars status Pin
Paolo Vernazza14-Mar-02 12:08
Paolo Vernazza14-Mar-02 12:08 
GeneralRe: Toolbars status Pin
Alexander Wiseman14-Mar-02 12:24
Alexander Wiseman14-Mar-02 12:24 
GeneralRe: Toolbars status Pin
Paolo Vernazza15-Mar-02 1:22
Paolo Vernazza15-Mar-02 1:22 
GeneralRe: Toolbars status Pin
Alexander Wiseman15-Mar-02 15:38
Alexander Wiseman15-Mar-02 15:38 
GeneralMulti-threaded app connecting to db, Design Question Pin
14-Mar-02 5:55
suss14-Mar-02 5:55 
GeneralRe: Multi-threaded app connecting to db, Design Question Pin
Joaquín M López Muñoz14-Mar-02 6:21
Joaquín M López Muñoz14-Mar-02 6:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.