Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Overriding MFC's CFileDialog::OnOK...

Posted on 1998-03-08
6
Medium Priority
?
1,585 Views
Last Modified: 2008-02-01
Hi,

I have created an exteded version of the CFileDialog by adding a template to the bottom of it. I now want to override the OnOK function for this dialog so that I can do some validation code in my program. I find that I cannot step into or hit the overridden OnOK function for some unknown reason. My definition of this funciton in the derived CFileDialog class is:

virtual void OnOK();

The implementaion is:

void CMyFileDialog::OnOK()
{
    // do something
    CFileDialog::OnOK();
}

Can anyone tell me how to properly overide the OnOK button for this dervied class ?
0
Comment
Question by:zafar030898
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 400 total points
ID: 1183245
The function will get called if the dialog has a button control in it with the id of IDOK. Are you sure you did not change the id of the button in the template? What does calling GetDlgItem(IDOK) return in a member function of the dialog? Does it return a valid (non-null) value? If it does, then there could be something wrong with your message map for the class.

Another possibility is to look at your dialog with Spy++ which tells you the IDs of window as well as where and what messages are generated. Use that as a debugging tool.

0
 

Author Comment

by:zafar030898
ID: 1183246
Hi,

What I am trying to override is the Open button's OnOK function which is present on the File Open dialog box. I am not using anyother buttons on my customized template with the same ID. I also used to find the ID of the open button, which is given as 1 (=IDOK) by the Spy++.

I am still wondering why when the Open button is pressed, by derived class's OnOK member function doens't get hit...
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1183247
Have you verified that when you press the OK button that your dialog is getting the WM_COMMAND message?


0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:zafar030898
ID: 1183248
Hi,

I used the classwizard to create a OnCommand function to see the messages passed from the dialog. When I hit a button on my child (i.e., the template added to the CFileDialog), the OnCommand function is hit. But when I Press the OK button present on the File Dialog itself, the OnCommand function is not hit. Any idea why ??
0
 

Author Comment

by:zafar030898
ID: 1183249
Hi,

I used the classwizard to create a OnCommand function to see the messages passed from the dialog. When I hit a button on my child (i.e., the template added to the CFileDialog), the OnCommand function is hit. But when I Press the OK button present on the File Dialog itself, the OnCommand function is not hit. Any idea why ??
0
 

Expert Comment

by:FranzReitner
ID: 5543302
Create a new class derived from CDialog and try to sublasswindow with the parent of your template dialog. Then your OnOK is called.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question