Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Overriding MFC's CFileDialog::OnOK...

Posted on 1998-03-08
6
Medium Priority
?
1,577 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

963 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