Solved

ActiveX Control Creation - "Open File Dialog Box" in properties settings ?

Posted on 1998-09-01
12
355 Views
Last Modified: 2008-03-17
Hello,

I'm a fairly experienced Visual Basic 5.0 programmer that is just getting the hang of ActiveX Control Creation.  I've figured out that to set the color property of your control that you can declare your Let/Get property statements "As OLE_COLOR" and when you've made your OCX / ActiveX and are using it at design time, all you have to do is click on the ChangeColor perperty you made and you have a nice, neat color picker there for you to select a color visually, instead of having to put in the HEX code for the color.

My question is : if you want to pop up a "File Open Dialog Box" so that the user can set a file location of say a picture for the control you're creating, they can click on the property of the .OCX / ActiveX and it will bring up the "File Open Dialog Box" just like when you click on the "Picture" property of a PictureBox and it will let you
locate the picture file you wish to display in the PictureBox, how do you declare that ?  Is there an "As" statement that you just implement similar to the "As OLE_COLOR" that will give you that ?  I've not been able to locate it if there is.

Please Help...

Thanks,

HATCHET
0
Comment
Question by:HATCHET
  • 7
  • 3
  • 2
12 Comments
 
LVL 14

Expert Comment

by:waty
Comment Utility
You declare it as PICTURE :
Public Property Get toto() As Picture
   Set toto = m_toto
End Property

Public Property Set toto(ByVal New_toto As Picture)
   Set m_toto = New_toto
   PropertyChanged "toto"
End Property


0
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
waty,

I took your idea of declaring it as a Picture, but it didn't work.  Here's what I tried:


Public Property Get PictureLocation() As Picture

  PictureLocation = picPicture.Picture

End Property

Public Property Let PictureLocation(ByVal NewPic As Picture)

  picPicture.Picture = NewPic
  PropertyChanged "PictureLocation"

End Property


Here the property name is PictureLocation and the PictureBox object in the ActiveX control that I'm trying to set the property for is picPicture.  When I run the code, it will either give me a compile error "Invalid use of property", and/or will not show up in the Properties Windows so that you can set it at Design Time.  I don't think that declaring it as "Picture" is the answer, or I missed something.

=(

0
 
LVL 14

Expert Comment

by:waty
Comment Utility
I think, it returns you the path of the picture, you have to use loadpicture(path) for your picturebox
0
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
waty,

I don't understand what you're getting at.  Could you maybe provide a sample snipit of code to illustrate?

thx,

HATCHET
0
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
Adjusted points to 125
0
 
LVL 2

Expert Comment

by:marti
Comment Utility
HATCHET, you have to use either PictureLocation or Picture, not both.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Author Comment

by:HATCHET
Comment Utility
marti,

I took your advice and tried to define the property I'm trying to get to work as "PictureLocation" and put in the following code:


Public Property Get PictureFile() As PictureLocation
  PictureFile = picPicture.PictureLocation
End Property

Public Property Let PictureFile(ByVal NewLocation As PictureLocation)
  picPicture.PictureLocation = NewLocation
  PropertyChanged "PictureFile"
End Property


It didn't work.  It gave me the error :  

Compile error:
User-defined type not defined

Can you clerify a bit maybe, or correct my code here If I'm doing something wrong ?

Thank you,

HATCHET
0
 
LVL 2

Accepted Solution

by:
marti earned 120 total points
Comment Utility
This should work:

Private msPictureLocation as String

Public Property Get PictureFile() As String
  PictureFile = msPictureLocation
End Property

Public Property Let PictureFile(ByVal NewLocation As String)
  msPictureLocation = NewLocation
  picPicture.Picture = LoadPicture(msPictureLocation)
  PropertyChanged "PictureFile"
End Property

0
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
marti,

Your code DID work in that it displays the picture now whereas before it did not.  What I really wanted to was the ability to click on the little button in the Properties window with the caption "..." and have the Open File Dialog Box apear so that you could pick the file and not have to manually put the file in as a string.

If you could lemme know how to do that, that would be great and I'd add some points for the extra work.  Because your question did not FULLY answer my question, I'd be willing to give you 100 points if you just left it as is because you did give me an answer that I can work with.  Lemme know what you can do and I'll award the points accordingly.

Thanks again for the help!    =)

HATCHET
0
 
LVL 2

Expert Comment

by:marti
Comment Utility
Well, the easiest way is to use property page for that control. On that page you could add a botton and there you may call a Dialog so that the picture location could be specified.
0
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
Thanks again, marti.  I'll use the Common Dialog Controls on a Properties Page.

HATCHET
0
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
THE ANSWER IS... to declare the Get and Let statements as "StdPicture".  That will give you the picture open dialog when you click on that property.

HATCHET
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now