15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Customizing CFileDialog...

Mihir Dalal -- m_dalal@ECE.concordia.CA
Saturday, January 04, 1997



                    Environment: MSVC 1.52, Windows 95

Hi,

I have derived a CMyFileDialog from CFileDialog to customize its 
behaviour. I could manage playing around with almost every control of the 
CFileDialog except for the "Network" push button. 

A view of the resource from commdlg.dll shows that this push button is 
created at run time on the fly and is not a part of the standard resources 
of the "Open File" dialog box. 

How do I suppress it ?? I believe, some data member of the CFileDialog 
has to be set to FALSE to suppress it. I tried with all the network 
related members of the "OPENFILENAME" structure but with no success. 

Any help is appreciated.

Mihir.
(University REsearcher)




Rail J. Rogut -- railro@earthlink.net
Saturday, January 04, 1997

Mihir Dalal wrote:
> 
>                     Environment: MSVC 1.52, Windows 95
> 
> Hi,
> 
> I have derived a CMyFileDialog from CFileDialog to customize its
> behaviour. I could manage playing around with almost every control of the
> CFileDialog except for the "Network" push button.
> 
> A view of the resource from commdlg.dll shows that this push button is
> created at run time on the fly and is not a part of the standard resources
> of the "Open File" dialog box.
> 
> How do I suppress it ?? I believe, some data member of the CFileDialog
> has to be set to FALSE to suppress it. I tried with all the network
> related members of the "OPENFILENAME" structure but with no success.
> 
> Any help is appreciated.
> 
> Mihir.
> (University REsearcher)


Use the OFN_NONETWORKBUTTON flag

	Rail
	Oceanway Recording
	railro@earthlink.net



Mihir Dalal -- m_dalal@ECE.concordia.CA
Sunday, January 05, 1997




> >
> >                    Environment: MSVC 1.52, Windows 95
> >
> >Hi,
> >
> >I have derived a CMyFileDialog from CFileDialog to customize its 
> >behaviour. I could manage playing around with almost every control of the 
> >CFileDialog except for the "Network" push button. 
> >
> >A view of the resource from commdlg.dll shows that this push button is 
> >created at run time on the fly and is not a part of the standard resources 
> >of the "Open File" dialog box. 
> >
> >How do I suppress it ?? I believe, some data member of the CFileDialog 
> >has to be set to FALSE to suppress it. I tried with all the network 
> >related members of the "OPENFILENAME" structure but with no success. 
> >
> >Any help is appreciated.
> 


On Sun, 5 Jan 1997, Tim Robinson wrote:   

> What did the OFN_NONETWORKBUTTON flag do when you included it in your settings?
> 
> | Tim Robinson, Esquire          | Liberty  means responsibility. |
> | timtroyr@ionet.net             | That is why most men dread it. |
> | http://www.ionet.net/~timtroyr |            George Bernard Shaw |

Tim,

In the MSVC 1.52 version I get OFN_NONETWORKBUTTON as an "undeclared 
identifier".

It makes sense, since I don't see that flag even in the help documenation 
for the "OPENFILENAME" structure in my version. 

I believe, the problem now reduces to being environment specific.
For those of you on MSVC 1.52 platform, any answer to this problem ??

Mihir.  
(University Researcher)



D. A. Dunlap -- devincci@ix.netcom.com
Monday, January 06, 1997

[Mini-digest: 2 responses]

Environment: MSVC 1.52, Windows 95

You could possibly try a HACK by doing the GetWindow Function until you run
across the "Network" caption , then use the EnableWindow function

-----From: Tim Robinson 

At 13:47 1/4/97 -0800, "Rail J. Rogut"  wrote:
>Mihir Dalal wrote:
>> 
>>                     Environment: MSVC 1.52, Windows 95
>> 
>> Hi,
>> 
>> I have derived a CMyFileDialog from CFileDialog to customize its
>> behaviour. I could manage playing around with almost every control of the
>> CFileDialog except for the "Network" push button.
>> 
>> A view of the resource from commdlg.dll shows that this push button is
>> created at run time on the fly and is not a part of the standard resources
>> of the "Open File" dialog box.
>> 
>> How do I suppress it ?? I believe, some data member of the CFileDialog
>> has to be set to FALSE to suppress it. I tried with all the network
>> related members of the "OPENFILENAME" structure but with no success.
>> 
>> Any help is appreciated.
>> 
>> Mihir.
>> (University REsearcher)
>
>
>Use the OFN_NONETWORKBUTTON flag

That was basically my suggestion to Mihir, but unfortunately older header
files (in his case, notice the "MSVC 1.52") don't have that flag.  However,
it's a DLL that will be interpreting the flag, and if the DLL doesn't
support the flag, I think it's safe to say that it will be ignored.  So the
most straightforward solution I can think of is use the solution we both
suggested, but add the following to the code (like in a local header or the
source module in question):

#ifndef OFN_NONETWORKBUTTON
#define OFN_NONETWORKBUTTON 0x00020000
#endif

Of course, I suppose you could always just go hand-patch COMMDLG.H.

The above is untested, but would probably take less time to try out than it
took me to write this.

| Tim Robinson, Esquire          | Liberty  means responsibility. |
| timtroyr@ionet.net             | That is why most men dread it. |
| http://www.ionet.net/~timtroyr |            George Bernard Shaw |




Mihir Dalal -- m_dalal@ECE.concordia.CA
Tuesday, January 07, 1997


Tim Robinson, 
Rail J. Rogut,
Mao Zhihong,       
Rosco Schock,    
DeVincci,     
&
David Elliot,

Kuddos gentlemen !! I have finally succeeded in customizing my 
CMyFileDialog and I DID GET RID of the Network button finally.

Thanks to you all for your responses. The answer lies in defining 
OFN_NONETWORKBUTTON in the local header and then setting
m_ofn.Flags = OFN_NONETWORKBUTTON | .....
 
While working on this code, I noticed a strange behaviour from MSVC which 
I wish to point out. Please explain me if anybody has explanation to 
this. 

I believe, the m_ofn members are set usually in the class constructor 
(the way I have set them in my implementation below). When I tried to set 
m_ofn.Flags = OFN_NONETWORKBUTTON, I compiled without errors & I ran the 
program without errors too, but guess what ??

I lost all the customizations, I had done in the OnInitialUpdate() of my 
derived class. As you can see in the implementation below, I was creating 
a "Delete" push button "on the fly" in the OnInitialUpdate. I lost that, I 
lost the disabling of some list boxes, and some other list boxes, for 
which I had even disabled the visibility now appeared back on the visual 
interface. 

Although, the customizations done in the class constructor (like setting 
the caption to "File Open\Delete") were retained. 

Upset with this, I commented out the m_ofn.Flags OFN_NONETWORKBUTTON from 
the constructor and put it in the OnInitialUpdate(). That solved all my 
problems. 

Interestingly, I heard a couple of you relating the "network" 
button with the "help" button, but, as it stands, I could get rid of the 
"network" button and still retained the"help" button on my dialog. 
 
Now, am I wrong in initializing m_ofn members in the constructor ??
or is it, that MSVC is behaving awkwardly in this particular case ??
Why doesn't it allow me to set the flaxgs in the constructor ??

Mihir. 
(University Researcher)


// My CMyFileDlg implementation

CMyFileDlg::CMyFileDlg(CWnd* pParent /*=NULL*/)
	: CFileDialog(TRUE, NULL, "*.dbf")
{
    m_ofn.lpstrFilter = "DBase(*.dbf)\0";  // file filter
    m_ofn.lpstrTitle = "File Open/Delete"; // dialog caption 
    m_ofn.lpstrInitialDir = "c:/unitrack"; 
//  m_ofn.Flags = OFN_NONETWORKBUTTON;
}

BOOL CMyFileDlg::OnInitDialog()
{
    m_ofn.Flags = OFN_NONETWORKBUTTON;

    m_bDeleteFlag = FALSE;
    CRect rect(372, 105, 459, 129); // button location in dialog window
    m_deleteButton.Create("Delete",
                          WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
    ......
    ......
}



Dmitry Davidovich -- dmitry@enigma.co.il
Wednesday, January 08, 1997

[Mini-digest: 4 responses]

At 20:10 7/01/97 -0500, you wrote:
>
>Tim Robinson, 
>Rail J. Rogut,
>Mao Zhihong,       
>Rosco Schock,    
>DeVincci,     
>&
>David Elliot,
>
>Kuddos gentlemen !! I have finally succeeded in customizing my 
>CMyFileDialog and I DID GET RID of the Network button finally.
>
>Thanks to you all for your responses. The answer lies in defining 
>OFN_NONETWORKBUTTON in the local header and then setting
>m_ofn.Flags = OFN_NONETWORKBUTTON | .....
> 
>While working on this code, I noticed a strange behaviour from MSVC which 
>I wish to point out. Please explain me if anybody has explanation to 
>this. 
>
>I believe, the m_ofn members are set usually in the class constructor 
>(the way I have set them in my implementation below). When I tried to set 
>m_ofn.Flags = OFN_NONETWORKBUTTON, I compiled without errors & I ran the 
>program without errors too, but guess what ??
>
>I lost all the customizations, I had done in the OnInitialUpdate() of my 
>derived class. As you can see in the implementation below, I was creating 
>a "Delete" push button "on the fly" in the OnInitialUpdate. I lost that, I 
>lost the disabling of some list boxes, and some other list boxes, for 
>which I had even disabled the visibility now appeared back on the visual 
>interface. 
>
>Although, the customizations done in the class constructor (like setting 
>the caption to "File Open\Delete") were retained. 
>
>Upset with this, I commented out the m_ofn.Flags OFN_NONETWORKBUTTON from 
>the constructor and put it in the OnInitialUpdate(). That solved all my 
>problems. 
>
>Interestingly, I heard a couple of you relating the "network" 
>button with the "help" button, but, as it stands, I could get rid of the 
>"network" button and still retained the"help" button on my dialog. 
> 
>Now, am I wrong in initializing m_ofn members in the constructor ??
>or is it, that MSVC is behaving awkwardly in this particular case ??
>Why doesn't it allow me to set the flaxgs in the constructor ??
>
>Mihir. 
>(University Researcher)
>
>
>// My CMyFileDlg implementation
>
>CMyFileDlg::CMyFileDlg(CWnd* pParent /*=NULL*/)
>	: CFileDialog(TRUE, NULL, "*.dbf")
>{
>    m_ofn.lpstrFilter = "DBase(*.dbf)\0";  // file filter
>    m_ofn.lpstrTitle = "File Open/Delete"; // dialog caption 
>    m_ofn.lpstrInitialDir = "c:/unitrack"; 
>//  m_ofn.Flags = OFN_NONETWORKBUTTON;

Try to use m_ofn.Flags |= OFN_NONETWORKBUTTON instead.



-----------------------------------------
Dmitry Davidovich
CS Tel Aviv University
dmitry@enigma.co.il
ddmitry@math.tau.ac.il
-----------------------------------------

-----From: Mike Blaszczak 

At 20:10 1/7/97 -0500, Mihir Dalal wrote:

>Thanks to you all for your responses. The answer lies in defining 
>OFN_NONETWORKBUTTON in the local header and then setting
>m_ofn.Flags = OFN_NONETWORKBUTTON | .....
 
>While working on this code, I noticed a strange behaviour from MSVC which 
>I wish to point out. Please explain me if anybody has explanation to 
>this. 

This behaviour wouldn't be unique to Microsoft Visual C++.  It would
be evident in any C++ compiler.

>I believe, the m_ofn members are set usually in the class constructor 
>(the way I have set them in my implementation below). When I tried to set 
>m_ofn.Flags = OFN_NONETWORKBUTTON, I compiled without errors & I ran the 
>program without errors too, but guess what ??

Since you set the value, what used to be in the variable is now gone.
If you code:

	int n;
	n = 6;
	n = 37;

you expect n to contain 37, not six.  Similarly, if you code:

	m_ofn.Flags = OFN_NONETWORKBUTTON;

you expect m_ofn.Flags to contain OFN_NONETWORKBUTTON, not some other
stuff.

The Flags member is a group of binary flags. If you want to adjust them
without changing the other flags that are already set, you should use
the bitwise or assignment operator:

	m_ofn.Flags |= OFN_NONETWORKBUTTON;

instead of doing a direct assignment.

>Now, am I wrong in initializing m_ofn members in the constructor ??

No.

>or is it, that MSVC is behaving awkwardly in this particular case ??

No.

>Why doesn't it allow me to set the flaxgs in the constructor ??

It does.  You just have to know how to use it.


.B ekiM
http://www.nwlink.com/~mikeblas/
Why does the "new" Corvette look like a 1993 RX-7?
These words are my own. I do not speak on behalf of Microsoft.

-----From: dima@ssm6000.samsung.ru (Dulepov Dmitry)

        [Mailer: "Groupware E-Mail". Version 1.02.051]

>        [From: Mihir Dalal
>        [Address: m_dalal@ECE.concordia.CA
>        [To: Dmitry A. Dulepov
>        [Date: Thu Jan 09 08:18:54 1997

>I noticed a strange behaviour from MSVC which 
>I wish to point out. Please explain me if anybody has explanation to 
>this. 
>
>I believe, the m_ofn members are set usually in the class constructor 

You are right!

>When I tried to set 
>m_ofn.Flags = OFN_NONETWORKBUTTON, I compiled without errors & I ran the 
>program without errors too, but guess what ??

You've lost MFC support for this dialog.

>I lost all the customizations, I had done in the OnInitialUpdate() of my 
>derived class.

I was right!

> As you can see in the implementation below, I was creating 
>a "Delete" push button "on the fly" in the OnInitialUpdate. I lost that, I 
>lost the disabling of some list boxes, and some other list boxes, for 
>which I had even disabled the visibility now appeared back on the visual 
>interface. 
>
>Although, the customizations done in the class constructor (like setting 
>the caption to "File Open\Delete") were retained. 
>
>Upset with this, I commented out the m_ofn.Flags OFN_NONETWORKBUTTON from 
>the constructor and put it in the OnInitialUpdate(). That solved all my 
>problems. 
>
>Interestingly, I heard a couple of you relating the "network" 
>button with the "help" button, but, as it stands, I could get rid of the 
>"network" button and still retained the"help" button on my dialog. 
> 
>Now, am I wrong in initializing m_ofn members in the constructor ??
>or is it, that MSVC is behaving awkwardly in this particular case ??
>Why doesn't it allow me to set the flaxgs in the constructor ??
>
>Mihir. 
>(University Researcher)


The explanation is very simple. MFC's code to CFileDialogs sets some values to "m_ofn.Flags". When you assing values to this variable in your constructor, you override MFC flags anddoes not give to MFC the opprtunity to set a hook to dialog.
Of course, it is more convinient to do such assigments in constructor. Use operator '|=' instead of '=' and your problem will be solved.


Dmitry A. Dulepov
Samsung Electronics Co., Ltd.
Russian Research Center
Phone: +7 (095) 213-9207
Fax: +7 (095) 213-9196
E-mail: dima@src.samsung.ru
====================================

-----From: Syed 

Just a thought:-
Try putting all your m_ofn initialization in DoModal() - derive DoModal from
CFIleDialog and place all the initialization in your 'customized CFileDialog':-
int CMyFileDialog::DoModal()
{
 m_ofn.XXXXX  =
 ...
 ...
 return CFileDialog::DoModal()
}




hemantab@hclt.com
Tuesday, December 10, 1996

Hi, 
>Now, am I wrong in initializing m_ofn members in the constructor ??
>or is it, that MSVC is behaving awkwardly in this particular case ??
>Why doesn't it allow me to set the flaxgs in the constructor ??
>
I beleive MFC's help tells that m_ofn members should be set after
construction , I don't know why ??? 

It can be done like this

myFileDlg = new CMyFileDialog 
myFileDlg.m_ofn ....//set all elements
myFileDlg->DoModal()

Bye, 
Hemanta
___________________________________________________
Thought for the day:
    Dictatorship (n): a form of government under which everything 
    which is not prohibited is compulsory.





| Вернуться в корень Архива |