Simple question 
Author Message
 Simple question

I have Common Dialog loaded on my main form (Form1), which is always
running.
The second form (Form2) is opened ocassionally.
Do I need to load another Common Dialog on Form2 or is it just enough to
make a reference to Common Dialog on Form1?
Is there any advantage (or disadvantage) of one method over another?
Please share your experience,
Claire


Thu, 12 Jul 2012 14:15:41 GMT  
 Simple question

Quote:
>I have Common Dialog loaded on my main form (Form1), which is always
>running.
> The second form (Form2) is opened ocassionally.
> Do I need to load another Common Dialog on Form2 or is it just enough to
> make a reference to Common Dialog on Form1?
> Is there any advantage (or disadvantage) of one method over another?
> Please share your experience,

You can use the control on Form1, however, if Form1 was unloaded, accessing
any property or methods or the controls within it would reload the form. If
you place a second control on Form2, it would take slightly more memory, and
it would slow down loading that form.


Thu, 12 Jul 2012 17:53:56 GMT  
 Simple question


Quote:


>>I have Common Dialog loaded on my main form (Form1), which is always
>>running.
>> The second form (Form2) is opened ocassionally.
>> Do I need to load another Common Dialog on Form2 or is it just enough to
>> make a reference to Common Dialog on Form1?
>> Is there any advantage (or disadvantage) of one method over another?
>> Please share your experience,

> You can use the control on Form1, however, if Form1 was unloaded,
> accessing any property or methods or the controls within it would reload
> the form. If you place a second control on Form2, it would take slightly
> more memory, and it would slow down loading that form.

So what was your recommendation? <g>

I believe the slightly more memory required is very negligible.  Perhaps a
few dozen bytes or so if even that much. And since the common dialog doesn't
really do or load anything until you show one of its dialogs, I can't
believe it would slow down loading of the form at all. If it does, it's
probably only milliseconds (at least on a reasonably fast computer).  Given
these 2 factors, I'd just go ahead and put another common dialog control on
Form2 for simplicity.

Of course, my *real* recommendation would be to forego the common dialog
control completely and use the Win32 API to display these exact same
dialogs. You can then do things not exposed by the control and you eliminate
having to distribute the OCX.

--
Mike



Thu, 12 Jul 2012 22:25:53 GMT  
 Simple question
Thank you both.
So it is just up to me how to do that.
I am interested in the Mike's suggestion to use API instead of ocx.
Mike, can you show a sample how to do that, please?
Thanks,
Claire


Quote:
>I have Common Dialog loaded on my main form (Form1), which is always
>running.
> The second form (Form2) is opened ocassionally.
> Do I need to load another Common Dialog on Form2 or is it just enough to
> make a reference to Common Dialog on Form1?
> Is there any advantage (or disadvantage) of one method over another?
> Please share your experience,
> Claire



Fri, 13 Jul 2012 00:46:47 GMT  
 Simple question

Quote:

> Thank you both.
> So it is just up to me how to do that.
> I am interested in the Mike's suggestion to use API instead of ocx.
> Mike, can you show a sample how to do that, please?
> Thanks,
> Claire

Lots of examples on the web here are two ...

"How To Use a Common Dialog File Open Dialog with Win32 API"
http://support.microsoft.com/kb/161286

"Common Dialog API calls"
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&tx...

-ralph



Fri, 13 Jul 2012 01:30:58 GMT  
 Simple question


Quote:
> Thank you both.
> So it is just up to me how to do that.

Pretty much. Other than your own personal preference, I don't think it makes
enough of a difference one way or the other to really matter.

Quote:
> I am interested in the Mike's suggestion to use API instead of ocx.
> Mike, can you show a sample how to do that, please?

There are tons of previous posts containing example code. The "downside" is
that each dialog has its own function that you must call. These functions
are:

GetOpenFileName
GetSaveFileName
ChooseColor
ChooseFont
PageSetupDlg
PrintDlg
PrintDlgEx

I'm not sure if the common dialog OCX exposes the PrintDlgEx dialog, which
is actually a Print property sheet. If I remember right, the common dialog
OCX essentially "combines" the older Print dialog and the Page Setup dialog.
You display one or the other of these dialog boxes by assigning a constant
to the control's Flag property and calling the ShowPrinter method
(checking...yep, use the constant cdlPDPrintSetup).  Two other common
dialogs not supported by the common dialog OCX are the Find and Find/Replace
dialogs. Those 2 dialog boxes can be shown with the FindText and ReplaceText
API functions. If you search Google Groups on any of these function names,
you should find example VB code.

Try this link:

http://groups.google.com/groups/search?hl=en&as_q=&as_epq=&as_oq=GetO...

(might have to combine it into a single line)

If you want to use these functions instead of the control, I *strongly*
recommend that you write them into a class module or standard code module (a
.bas file) that you can simply add to any project. After you've written this
module, make it read-only so you don't accidently change anything that might
cause problems in other projects using the module. Or, make a copy of the
.cls or .bas file (whichever way you choose to write it) for each project
and add that copy to each project instead of the "master" file.

--
Mike



Fri, 13 Jul 2012 01:36:21 GMT  
 Simple question

Quote:
> I am interested in the Mike's suggestion to use API instead of ocx.
> Mike, can you show a sample how to do that, please?

  You might also try here at Randy Birch's site,
assuming that you want FileOpn/FileSave
functionality:

http://vbnet.mvps.org/code/comdlg/fileopendlg.htm

  If you just need basic functionality it's fairly simple.
The page linked has a small sample project that can
be copied and pasted.



Fri, 13 Jul 2012 03:01:48 GMT  
 Simple question
Thank you all.
It is nice to learn more.
Claire


Quote:
>I have Common Dialog loaded on my main form (Form1), which is always
>running.
> The second form (Form2) is opened ocassionally.
> Do I need to load another Common Dialog on Form2 or is it just enough to
> make a reference to Common Dialog on Form1?
> Is there any advantage (or disadvantage) of one method over another?
> Please share your experience,
> Claire



Fri, 13 Jul 2012 05:33:56 GMT  
 Simple question
I have a small problem when setting dialog choosing Fonts.
I went through several samples posted online but none of them shows how to
do the following:
1.
Show the font sample in the Sample box.
2.
Disable (or hide) Effects frame.
Removing flag CF_EFFECTS from:
FontDialog.flags = CF_SCREENFONTS Or CF_EFFECTS
does not do that.

Please help,
Claire


Quote:
>I have Common Dialog loaded on my main form (Form1), which is always
>running.
> The second form (Form2) is opened ocassionally.
> Do I need to load another Common Dialog on Form2 or is it just enough to
> make a reference to Common Dialog on Form1?
> Is there any advantage (or disadvantage) of one method over another?
> Please share your experience,
> Claire



Sat, 14 Jul 2012 05:57:19 GMT  
 Simple question
I solved that.
But I have another question regarding .hdc property.
Do I really need to use it?
I tried the code by Randy Birch at:
http://vbnet.mvps.org/code/comdlg/choosefont2.htm
and I do not see any difference in the result with or without that property
used.
Claire


Quote:
>I have a small problem when setting dialog choosing Fonts.
> I went through several samples posted online but none of them shows how to
> do the following:
> 1.
> Show the font sample in the Sample box.
> 2.
> Disable (or hide) Effects frame.
> Removing flag CF_EFFECTS from:
> FontDialog.flags = CF_SCREENFONTS Or CF_EFFECTS
> does not do that.

> Please help,
> Claire



>>I have Common Dialog loaded on my main form (Form1), which is always
>>running.
>> The second form (Form2) is opened ocassionally.
>> Do I need to load another Common Dialog on Form2 or is it just enough to
>> make a reference to Common Dialog on Form1?
>> Is there any advantage (or disadvantage) of one method over another?
>> Please share your experience,
>> Claire



Sat, 14 Jul 2012 11:07:03 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Simple Question: Assigning Icon to an App : Simple Question

2. simple question...what was the source code for this simple custom action (rules wizard)

3. SIMPLE QUESTION : SIMPLE ANSWER?

4. SIMPLE QUESTION : SIMPLE ANSWER?

5. SIMPLE QUESTION, please SIMPLE ANSWER

6. Simple controls and a very simple question

7. Simple Question...simple answer???

8. VB5 Pro Masked Edit control - A simple, simple question

9. HELP! simple question need simple answer

10. HELP! simple question need simple answer

11. HELP! simple question need simple answer

12. Simple Question (dumb Question)

 

 
Powered by phpBB® Forum Software