Home All Groups Group Topic Archive Search About

Common Dialog Confusion

Author
20 Mar 2009 8:40 PM
Bee
Have an old VB6 project that uses ' as CommonDialog'
I copied files over to a new project.
It comiples fine but does not run.
The call to the sub using the 'as CommonDialog' fails and says Type Mismatch
So I changed it to as Object, it works, but now no intellisense.
Also cannot set .DialogTitle (may not be remembering that one correctly).

If I go to the sub with as CommonDialog in place, then the referneces are to
some other sub e.g.

sub x (cdl as CommonDialog)
   with cdl
       .ShowAcquireImage   ' this is what intellsense allows, but not
CommonDialog stuff
    end with
What did I do wrong?
I checked and only have one CommonDialog component and it is a VB6 component.

Author
20 Mar 2009 9:14 PM
Bee
OK, so in this large project I am getting rid of the CommonDialog component
in favor of the API methods.
So ... when I try to remove the component, it says it is in use; meaning
that the object is sitting on some form some place.
But where?
If a predecessor hid it under something, it is not easy to spot.

(1) Is there a tool to scan to find where the multiple components are
located and even possible remove them?
I do not see anything in the IDE to do this, but them I am probably missing
something.
Does MZTools do this?

(2) I do not see a way to pass the API a title.  Rather than just Color, I
would like to title it more appropriately e.g.  "Thingy Color".  Can do?

Show quoteHide quote
"Bee" wrote:

> Have an old VB6 project that uses ' as CommonDialog'
> I copied files over to a new project.
> It comiples fine but does not run.
> The call to the sub using the 'as CommonDialog' fails and says Type Mismatch
> So I changed it to as Object, it works, but now no intellisense.
> Also cannot set .DialogTitle (may not be remembering that one correctly).
>
> If I go to the sub with as CommonDialog in place, then the referneces are to
> some other sub e.g.
>
> sub x (cdl as CommonDialog)
>    with cdl
>        .ShowAcquireImage   ' this is what intellsense allows, but not
> CommonDialog stuff
>     end with
> What did I do wrong?
> I checked and only have one CommonDialog component and it is a VB6 component.
>
Author
20 Mar 2009 11:15 PM
MikeD
Show quote Hide quote
"Bee" <B**@discussions.microsoft.com> wrote in message
news:C57EC6BF-4FCC-4318-9BBE-6A47FEC14D8E@microsoft.com...
> OK, so in this large project I am getting rid of the CommonDialog
> component
> in favor of the API methods.
> So ... when I try to remove the component, it says it is in use; meaning
> that the object is sitting on some form some place.
> But where?
> If a predecessor hid it under something, it is not easy to spot.
>
> (1) Is there a tool to scan to find where the multiple components are
> located and even possible remove them?
> I do not see anything in the IDE to do this, but them I am probably
> missing
> something.
> Does MZTools do this?

None exist that I know of.  Just search .frm files having "CommonDialog" in
them. If worse comes to worse, open each .frm file in Notepad.  I'd make
backups of them before editing them in Notepad, though. Very easy to screw
something up which prevents the form (or even the whole project) from
loading.

>
> (2) I do not see a way to pass the API a title.  Rather than just Color, I
> would like to title it more appropriately e.g.  "Thingy Color".  Can do?

So you mean you're calling the ChooseColor API function now instead of using
the Common Dialog control?  You weren't really too clear on some points.
Might have to use the SetWindowText API function, which means you'd need the
dialog box's window handle, which means you may have to handle the
WM_INITDIALOG message. Or it might even be more involved than that.

--
Mike
Author
20 Mar 2009 11:52 PM
mayayana
Here's what you need to customize the color dialogue from
Randy Birch's site:

http://vbnet.mvps.org/code/hooks/choosecolorcustomize.htm

  He also shows, on that page, how to use the callback function
to make the custom colors boxes workable, which is a nice
touch. If you set that up and save the custom colors in
the program settings somewhere then you can allow people
to save favorite colors between uses of the program.

   I'm not sure whether Randy's sample has all options, but
you can customize *at least* the following:

The window text.
The text over the custom colors selection.
The text on the button that normally says, "Add to custom colors".

   If you have Visual Studio you can see how it works
and get the IDs of the window elements by looking at
the file color.dlg in the folder Microsoft Visual Studio\VC98\Include\.

  As for the component, you can look for it in the Properties
dropdown list for each form, rather than picking over the
form itself.
  If all else fails you could remove the reference from the
..vbp file before starting. Then VB will find the control for you. :)



Show quoteHide quote
> OK, so in this large project I am getting rid of the CommonDialog
component
> in favor of the API methods.
> So ... when I try to remove the component, it says it is in use; meaning
> that the object is sitting on some form some place.
> But where?
> If a predecessor hid it under something, it is not easy to spot.
>
> (1) Is there a tool to scan to find where the multiple components are
> located and even possible remove them?
> I do not see anything in the IDE to do this, but them I am probably
missing
> something.
> Does MZTools do this?
>
> (2) I do not see a way to pass the API a title.  Rather than just Color, I
> would like to title it more appropriately e.g.  "Thingy Color".  Can do?
>
> "Bee" wrote:
>
> > Have an old VB6 project that uses ' as CommonDialog'
> > I copied files over to a new project.
> > It comiples fine but does not run.
> > The call to the sub using the 'as CommonDialog' fails and says Type
Mismatch
> > So I changed it to as Object, it works, but now no intellisense.
> > Also cannot set .DialogTitle (may not be remembering that one
correctly).
> >
> > If I go to the sub with as CommonDialog in place, then the referneces
are to
> > some other sub e.g.
> >
> > sub x (cdl as CommonDialog)
> >    with cdl
> >        .ShowAcquireImage   ' this is what intellsense allows, but not
> > CommonDialog stuff
> >     end with
> > What did I do wrong?
> > I checked and only have one CommonDialog component and it is a VB6
component.
> >
Author
20 Mar 2009 11:18 PM
Bee
That would turn the CDL into pictureboxes no doubt.
The log files generated on error would tell me. the forms to look at closely.
Is that correct?



Show quoteHide quote
"mayayana" wrote:

> Here's what you need to customize the color dialogue from
> Randy Birch's site:
>
> http://vbnet.mvps.org/code/hooks/choosecolorcustomize.htm
>
>   He also shows, on that page, how to use the callback function
> to make the custom colors boxes workable, which is a nice
> touch. If you set that up and save the custom colors in
> the program settings somewhere then you can allow people
> to save favorite colors between uses of the program.
>
>    I'm not sure whether Randy's sample has all options, but
> you can customize *at least* the following:
>
> The window text.
> The text over the custom colors selection.
> The text on the button that normally says, "Add to custom colors".
>
>    If you have Visual Studio you can see how it works
> and get the IDs of the window elements by looking at
> the file color.dlg in the folder Microsoft Visual Studio\VC98\Include\.
>
>   As for the component, you can look for it in the Properties
> dropdown list for each form, rather than picking over the
> form itself.
>   If all else fails you could remove the reference from the
> ..vbp file before starting. Then VB will find the control for you. :)
>
>
>
> > OK, so in this large project I am getting rid of the CommonDialog
> component
> > in favor of the API methods.
> > So ... when I try to remove the component, it says it is in use; meaning
> > that the object is sitting on some form some place.
> > But where?
> > If a predecessor hid it under something, it is not easy to spot.
> >
> > (1) Is there a tool to scan to find where the multiple components are
> > located and even possible remove them?
> > I do not see anything in the IDE to do this, but them I am probably
> missing
> > something.
> > Does MZTools do this?
> >
> > (2) I do not see a way to pass the API a title.  Rather than just Color, I
> > would like to title it more appropriately e.g.  "Thingy Color".  Can do?
> >
> > "Bee" wrote:
> >
> > > Have an old VB6 project that uses ' as CommonDialog'
> > > I copied files over to a new project.
> > > It comiples fine but does not run.
> > > The call to the sub using the 'as CommonDialog' fails and says Type
> Mismatch
> > > So I changed it to as Object, it works, but now no intellisense.
> > > Also cannot set .DialogTitle (may not be remembering that one
> correctly).
> > >
> > > If I go to the sub with as CommonDialog in place, then the referneces
> are to
> > > some other sub e.g.
> > >
> > > sub x (cdl as CommonDialog)
> > >    with cdl
> > >        .ShowAcquireImage   ' this is what intellsense allows, but not
> > > CommonDialog stuff
> > >     end with
> > > What did I do wrong?
> > > I checked and only have one CommonDialog component and it is a VB6
> component.
> > >
>
>
>
Author
21 Mar 2009 2:21 AM
mayayana
> That would turn the CDL into pictureboxes no doubt.
> The log files generated on error would tell me. the forms to look at
closely.
> Is that correct?
>

  That's weird. You're right! I can't imagine how
someone might have thought it was a good idea
to turn a missing control into a picture box. But
that's what it did when I tried it.

I removed this line from the .vbp file:

Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCX

While it created a picture box, it did write a log file,
as you suspected:

Class MSComDlg.CommonDialog of control CommonDialog1 was not a loaded
control class.

So that method will work if you just have too many forms
to do it the other way. But of course you'll then still
need to hunt down the picture boxes named
CommonDialogue1. :)
Author
22 Mar 2009 4:38 PM
Daryl Muellenberg
>  That's weird. You're right! I can't imagine how
> someone might have thought it was a good idea
> to turn a missing control into a picture box. But
> that's what it did when I tried it.

So what would you suggest VB do with missing controls if you don't think a
picture box is a good idea. Since VB doesn't have any idea what properties
the missing control should have, at least displaying a picture box gives you
a visual representation of where it should be on the form.
Author
22 Mar 2009 7:40 PM
mayayana
> >  That's weird. You're right! I can't imagine how
> > someone might have thought it was a good idea
> > to turn a missing control into a picture box. But
> > that's what it did when I tried it.
>
> So what would you suggest VB do with missing controls if you don't think a
> picture box is a good idea. Since VB doesn't have any idea what properties
> the missing control should have, at least displaying a picture box gives
you
> a visual representation of where it should be on the form.
>

   It's not a missing control. With the reference gone
it's an invalid control.

   If VB finds an invalid control it should tell me,
remove it, and log the error. If I send my shopping
list for home delivery and include an order for 1 lb. of
"sidarky", I expect the store to point out the error.
I don't expect them to just decide for themselves,
willy nilly, that they'll send me 1 lb. of cream cheese. :)
Author
24 Mar 2009 7:26 PM
Daryl Muellenberg
>   It's not a missing control. With the reference gone
> it's an invalid control.

If the reference is not there, then according to VB it is missing from the
project (even though the file may physically be on your system it is still
missing in the project).

>   If VB finds an invalid control it should tell me,
> remove it, and log the error. If I send my shopping
> list for home delivery and include an order for 1 lb. of
> "sidarky", I expect the store to point out the error.
> I don't expect them to just decide for themselves,
> willy nilly, that they'll send me 1 lb. of cream cheese. :)

When you try to access the form VB does inform you that there were errors
during the load and tells you the name of the log file which contains more
details. If you have a non visual control such as the Common Dialog control,
then I guess it would be ok to just remove it, but for visual controls I
would prefer to have the picture box in place of where the missing control
was so I knew where on the form it was originally (and not have to guess
when adding the control back to the form). I'm not sure why you think it is
such a bad idea to put a picture box where the original control was.