Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CFileDialog w/ template but default button not working

Posted on 1998-06-04
7
Medium Priority
?
472 Views
Last Modified: 2013-11-19
I have a customized CFileDialog (e.g. CCustFileDialog) with a child dialog template. Everything is working fine except that now I want the default button change to one of the button in my child template (e.g. IDOK1).

Here is the code I tried but failed:

void CCustFileDialog::OnInitDone()
{
     // Set default button

     GetParent()->SetDefID(IDOK1);
     ((CButton*)GetParent()->GetDlgItem(IDOK))->SetButtonStyle(BS_PUSHBUTTON);
     SendDlgItemMessage(IDOK1, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0));
}

Any one can help?
0
Comment
Question by:leow060498
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:dkremer
ID: 1316009
Try sending a DM_SETDEFID message as well.

0
 

Author Comment

by:leow060498
ID: 1316010
Well if you look at DevStudio\VC\mfc\include\AFXWIN2.INL(570):

_AFXWIN_INLINE void CDialog::SetDefID(UINT nID)
      { ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, DM_SETDEFID, nID, 0); }

The call of SetDefID() is sending a DM_SETDEFID....
0
 

Author Comment

by:leow060498
ID: 1316011
Try to open WinZip with an existing file and Add. You can see that it is using the CFileDialog with some buttons underneath. If you press enter on some of them, you got nothing.
0
Independent Software Vendors: 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!

 
LVL 23

Expert Comment

by:chensu
ID: 1316012
Is CCustFileDialog derived from CFileDialog? Why do you use GetParent()?

It should be

void CCustFileDialog::OnInitDone()
{
     // Set default button

     this->SetDefID(IDOK1);
}

If this still does not work, try the following:

1. Define a user-defined message;
2. Post the user-defined message in CCustFileDialog::OnInitDone() by using this->PostMessage;
3. When CCustFileDialog receives this message, call this->SetDefID(IDOK1);.
0
 

Author Comment

by:leow060498
ID: 1316013
No luck with this->SetDefID() and the PostMessage() also.

The way to set the default button to a child dialog is not mentioned clearly in the documentation.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1316014
How about setting the Default Button style in the Dialog Editor?
0
 

Accepted Solution

by:
Amaresh080997 earned 200 total points
ID: 1316015
Set the flag "OFN_EXPLORER" for your CFileDialog derived class..
--Amaresh
0

Featured Post

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.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 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