0
votes

I am using MFC MDI. I create a window the main document window. I create another window(lets call it second window) as child of MDI Window View, then I create child window(third window) of second window. Again I need to create another window, child window of third window. I have a button on the ribbon and I want to call message handler in the third window to handle this command. I have added message map and all required stuff but it is not calling the message handler. If I define the message handler in MDI window view, it catches the event. If I dont delare the message handler in my main CWinApp class or MDI window View class the button appears disabled.

All my child view classes are inherited from CWnd and main MDI window is derived from CView. Please let me know what I am missing here.

Saba

2
Parent child relationships and focus are all working fine, but event is not routed to child windowSaba
I'm guessing you might need to forward the message yourself. I've experienced something similar and IIRC the framework forwarded to its windows, but any other windows that you open (these additional children) probably won't get anything unless you forward the messages yourself.Nerdtron
Thanks Nerdtron, I think you are right, I have also tried a few more things but nothing worked. Basically the ribbon sends it to main frame and the main frame gives it either to View or App. I dont find anyhting related to window in focus searching there in the mfc code.Saba

2 Answers

0
votes

I am at the loss here. You are using MFC; why using events? use command messages and command message handlers instead events. Use MFC implemented and well working command routing.

0
votes

MFC doesnt route messages generated by clicking Ribbon buttons to child windows. If we want to send messages to child windows of MDI windows we need to do it ourselves. Ribbon button's messages are either passed to active MDI window or CWinApp class.