|
Llasus wrote: Thank you very much! PostMessage(WM_CLOSE) did the job. Thank you!
You should not call OnClose directly. It's an event handler which is invoked by the MFC messaging framework in response to the WM_CLOSE message. That's why your call didn't work.
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|
|
Actually I placed a TRACE in the OnClose function to see if it works before. Since the timer is the one which calls the OnClose function, it printed out in the Output window the message I set inside the OnClose function using TRACE . What I was wondering about was that I had the CDialog::OnClose() inside the function but it did not work. I needed to click on the close button once again to close the application. I made a breakpoint inside the function to double-check and it actually passes the CDialog::OnClose() but it won't close when called directly by the OnTimer function. I also tried DestroyWindow but it really does not work ( though it passes through that line) when called by OnTimer and needed for the close button to be pressed once again to close it.
|
|
|
|
|
Try using calling AfxPostQuitMessage instead of calling OnClose .
Steve
|
|
|
|
|
Thank you for your time and help. Though when using AfxPostQuitMessage caused the application to immediately close without calling the OnClose() which caused some leaks since I have some objects released at that function. Thanks again for your help!
|
|
|
|
|
In that case try PostMessage(WM_CLOSE); instead.
Steve
|
|
|
|
|
Yes. I tried that and solved my problem. Thank you for your help!
|
|
|
|
|
thanks so much for helping. how about finding and displaying minimum, maximum nodes from the binary search tree, returning the inorder successor of a node,counting and returning the number of nodes on the specified level then the diameter of the tree. please help me i will appreciate. c++ codes please. thanks in advance
-- modified at 19:31 Sunday 21st October, 2007
|
|
|
|
|
I dont think its good idea we show to code and you complete your program with it its better you write and if you have problem ask of us.
|
|
|
|
|
Do your own code and stop asking the same question over and over.
|
|
|
|
|
Hi,
I have a simple GUI in which I currently have a CDialog and a CListCtrlEx. Now, I need to add a event handler for detecting and handling right click on my extended version of CListCtrl (i,e. the CListCtrl class) ... I am adding the following in the message map -
ON_NOTIFY(NM_RCLICK, IDC_LIST_CTRL, &CListCtrlEx::OnNMRclickAllEvents)
If I try it out, the function 'OnNMRclickAllEvents' never gets called. However, if I move this line to CDialog .. it works fine! I don't know what I am missing here...
Any help is appreciated.
Thanks..
|
|
|
|
|
Try using ON_NOTIFY_REFLECT to catch the notification in the
control class.
This is an MFC feature - normally notification messages from a control
go to the control's parent window.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I used the following in my Clistctrlex :
ON_NOTIFY_REFLECT(NM_RCLICK, &CSivoListCtrl::OnNMRclickAllEvents)
That didn't work =( Do I need to add anything in the CDialog as well to make this work?
|
|
|
|
|
Do you still have an ON_NOTIFY in the dialog class?
If so, that will override the reflected message and you should remove it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Nope I don't have it in the main Dialog. Ok, when I described the problem I thought I would keep it simple. But I guess I should describe my exact setup..
So I have main CDialog .. in there there is a CTabCtrl. The CTabCtrl's contents are displayed by another CDialog say CSubCDialog .. not this sub dialog contains my custom CListCtrlEx. The sub dialog is able to receive the nm_rclick message fine, but CListctrlEx doesn't receive it with on_notify_refelct ..
|
|
|
|
|
Regardless of the window hierarchy, this should work.
All notifications are between the control and its parent window,
so the main dialog and tab stuff should be irrelevant.
The control's parent window has no WM_NOTIFY handler or OnNotify()
override, correct?
Again, no ON_NOTIFY() in the parent's message map, right?
And you put the ON_NOTIFY_REFLECT90 in the control's message map, right?
The reflection is done in the control's parent, so if you override any
WM_NOTIFY processing in the control's parent, that may break the
reflection.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Answer is 'yes' for:
The control's parent window has no WM_NOTIFY handler or OnNotify()
override, correct?
Again, no ON_NOTIFY() in the parent's message map, right?
And you put the ON_NOTIFY_REFLECT90 in the control's message map, right?
It's not working. Is there any property called 'notify' = true I need to set for the list control?
|
|
|
|
|
Hmm beats me what's going on.
Are you sure you're using a variable of the derived list control type and
not a CListCtrl?
I did a quick test....this wizard-generated code worked fine for me:
IMPLEMENT_DYNAMIC(CReflectedListCtrl, CListCtrl)
CReflectedListCtrl::CReflectedListCtrl()
{
}
CReflectedListCtrl::~CReflectedListCtrl()
{
}
BEGIN_MESSAGE_MAP(CReflectedListCtrl, CListCtrl)
ON_NOTIFY_REFLECT(NM_RCLICK, &CReflectedListCtrl::OnNMRClick)
END_MESSAGE_MAP()
void CReflectedListCtrl::OnNMRClick(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
*pResult = 0;
}
There's always WM_CONTEXTMENU too...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark for your prompt replies.
Well I think I am doing something wrong. I just created a test mfc application, with a simple CDialog and added a list control to it. Through the resource view, I right clicked on the list control, selected add class and create a class derived from CListCtrl. Then added a variable of type CListCtrlEx. Now again, in the similar fashion, I added on_notify_reflect(as above) in my CListCtrlEx class. I ran the app with this, and it doen't go to the handler ...
|
|
|
|
|
What version of Visual Studio?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Try this in your test app...
1) get rid of the other CListCtrl class you made
2) In project menu (or class view window, right-click the project) choose Add.../Class...
choose the mfc category....go through the wizard to create the CListCtrl-derived class.
Note this is NOT from the dialog editor!
3) You should now have an empty class derived from CListCtrl. In class view, find your
new class, right-click it, and choose properties.
4) In the properties window, click the messages button - scroll down to "=NM_RCLICK" and
add a reflected handler for it using the drop-down to the right of "=NM_RCLICK".
5) Back in the dialog class, make sure you use a control variable of your new class type.
Also make sure you have a DDX_Control() entry in the dialog's DoDataExchange override
so the control object properly attaches to/subclasses the control window.
Maybe you were missing step 5 above??
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It worked just fine! =) Thank you so much. What was going wrong with my initial approach?
-- modified at 23:52 Sunday 21st October, 2007
|
|
|
|
|
Cool. Sorry it took so long to reply. The wind and fires here in
Southern California took out my power yesterday.
neil4781 wrote: What was going wrong with my initial approach?
I'm going to take a look at that - I'm not sure what happens when you create
a class from the dialog editor like that.
I'm testing the release candidate for VS 2008 right now so I want to take
a look at it and see if there's a bug to report to MS.
I'll let you know.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No problem. Thank you so much for your help again to resolve this problem for me.
|
|
|
|
|
Hi all,
I need to convert tiff file to bmp file.
I found libtiff library.
Maybe anybody using this library?
If it possable, give me some ideas how to do that?
(TIFF encoded to CMYK)
|
|
|
|