Reading PictureData FaceID for Command Buttons

  • Thread starter Thread starter Jeff Conrad
  • Start date Start date
J

Jeff Conrad

Hi,

Using Access 97 at the moment.

I'm working on a project and something has me stumped. I've been reviewing Chapter 19 of the ADH 97
and specifically the area of accessing the FaceIDs for command button pictures. The book even has a
sample form to display all the different command button bitmaps which are stored in a big slab and
accessed through FaceID numbers. I understand all this. The sample form allows you to change the
command button pictures of open forms, although once you close the form the changes are not saved.

Here is my issue. Where is this information stored that tells Access that *this* particular command
button is to use *this* particular FaceID? And more importantly, how do I access it? Is this
property not exposed to the developer?

To illustrate my issue, say in design view I tell a command button called cmd1 to use the airplane
bitmap by using the built in button properties. I do this by going to the Picture line on the
Properties area, hitting the (...) button, and browsing to the airplane picture on the built-in
Access form. The only thing the Properties line says is (Picture). It certainly does not say
"Airplane" nor FaceID = <Whatever>. I close and save the form. Every time I open the form, Access in
its infinite wisdom knows to display the airplane. How?

Going to the code window and looking on the available properties for the command button leads me to
an option called PictureData. The ADH form uses the PictureData property, but I still cannot figure
out how to change this value in code, or more importantly, find out what its current *value* is.

A simple sub of:
MsgBox Me.cmd1.PictureData
yields this:
(

Huh???
Well that does not help me! How can I find out in code what this *value* may be and how do I then
change it to something else whenever I want? It's easy to change the caption, but how do I read the
value and change the picture if I desire?

Thanks for any help,
 
The PictureData prop is basically the Image in the CF_DIB
format(Clipboard Format = Device Independant Bitmap).
If you GoogleGroups search on my name and CF_DIB you should find a
couple of threads that explain how Access loads and stores different
types of images exposing the data in the control's PictureData prop.

So when you have Access load a Bitmap into a CommandButton's Picture
property it reads in the Bitmap and stores it as a DIB within the
PictureData prop. There is no pointer maintained to the offset within
the original slab of Bitmaps in the DLL/EXE, Access actually stores the
selected Bitmap within the control.

What is it exactly you are trying to do?
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Jeff Conrad said:
Hi,

Using Access 97 at the moment.

I'm working on a project and something has me stumped. I've been
reviewing Chapter 19 of the ADH 97
and specifically the area of accessing the FaceIDs for command button pictures. The book even has a
sample form to display all the different command button bitmaps which are stored in a big slab and
accessed through FaceID numbers. I understand all this. The sample form allows you to change the
command button pictures of open forms, although once you close the
form the changes are not saved.
Here is my issue. Where is this information stored that tells Access that *this* particular command
button is to use *this* particular FaceID? And more importantly, how do I access it? Is this
property not exposed to the developer?

To illustrate my issue, say in design view I tell a command button
called cmd1 to use the airplane
bitmap by using the built in button properties. I do this by going to the Picture line on the
Properties area, hitting the (...) button, and browsing to the
airplane picture on the built-in
Access form. The only thing the Properties line says is (Picture). It certainly does not say
"Airplane" nor FaceID = <Whatever>. I close and save the form. Every
time I open the form, Access in
its infinite wisdom knows to display the airplane. How?

Going to the code window and looking on the available properties for the command button leads me to
an option called PictureData. The ADH form uses the PictureData
property, but I still cannot figure
out how to change this value in code, or more importantly, find out what its current *value* is.

A simple sub of:
MsgBox Me.cmd1.PictureData
yields this:
(

Huh???
Well that does not help me! How can I find out in code what this
*value* may be and how do I then
 
Hi Sensei!

Comments below...
The PictureData prop is basically the Image in the CF_DIB
format(Clipboard Format = Device Independant Bitmap).

Ahhh, I see.
If you GoogleGroups search on my name and CF_DIB you should find a
couple of threads that explain how Access loads and stores different
types of images exposing the data in the control's PictureData prop.

Thanks, that did help.
I actually considered searching on your name, but was not sure what keyword(s) to use.
So when you have Access load a Bitmap into a CommandButton's Picture
property it reads in the Bitmap and stores it as a DIB within the
PictureData prop. There is no pointer maintained to the offset within
the original slab of Bitmaps in the DLL/EXE, Access actually stores the
selected Bitmap within the control.

Now I get it!
This *pointer* was exactly what I was searching for. I assumed that 'something' must be saved with
the control that tells Access to go look for that picture. But in actuality, the picture is actually
saved with the control itself. Correct?
What is it exactly you are trying to do?

Before seeing your response I made a big discovery and this post seems to confirm my findings. I
reviewed the table tblTBPictures in the chapter 19 MDB file and PictureData is defined as an OLE
Object Field. So I created a simple one field test table called tblTest with a field called Test and
defined as OLE Object. Right at the end of the RetrieveDIB sub in the sample ADH form is this line:

ctl.PictureData = rst!PictureData

Carefully looking at this led me to believe that maybe it was just copying the whole bitmap image
from one control to another. So I added these lines just before the end of the procedure just to see
what would happen:

Set dbs = CurrentDb()
Set rs = db.OpenRecordset("tblTest")
rs.AddNew
rs("Test") = ctl.PictureData
rs.Update
rs.Close
Set rs = Nothing
Set dbs = Nothing

Sure enough, the record said Long Binary Data. So then using my test form I did this:
1. Set the command button picture to something else
2. Saved and closed the form
3. Checked to make sure it was a different picture
4. Added this code:

Private Sub Form_Load()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Set dbs = CurrentDb()
Set rs = dbs.OpenRecordset("tblTest")
rs.Edit
Me.cmd1.PictureData = rs!Test
rs.Update
rs.Close
Set rs = Nothing
Set dbs = Nothing
End Sub

5. Saved and closed the form
6. When I opened the form, sure enough the picture displayed was now the one I saved from the ADH
form. Sweeeeet!

This is exactly what I wanted to do: Change button images on a form by loading 'values' from a
table.
This will work perfectly! Much more testing to do, but now I'm moving forward.

Thanks for the help Sensei!
(head bowed)
 
Great detective work Jeff!
Be warned though, the API's are highly addictive.<grin>
:-)

--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Jeff Conrad said:
"Stephen Lebans"
Hi Sensei!

Comments below...


Ahhh, I see.


Thanks, that did help.
I actually considered searching on your name, but was not sure what keyword(s) to use.


Now I get it!
This *pointer* was exactly what I was searching for. I assumed that 'something' must be saved with
the control that tells Access to go look for that picture. But in
actuality, the picture is actually
saved with the control itself. Correct?


Before seeing your response I made a big discovery and this post seems to confirm my findings. I
reviewed the table tblTBPictures in the chapter 19 MDB file and
PictureData is defined as an OLE
Object Field. So I created a simple one field test table called
tblTest with a field called Test and
defined as OLE Object. Right at the end of the RetrieveDIB sub in the sample ADH form is this line:

ctl.PictureData = rst!PictureData

Carefully looking at this led me to believe that maybe it was just copying the whole bitmap image
from one control to another. So I added these lines just before the
end of the procedure just to see
 
Hi Sensei,
Great detective work Jeff!
Thanks!

Be warned though, the API's are highly addictive.<grin>
:-)

Yes, I know, my doctor has increased my medication.
;-)

--
Jeff Conrad
Access Junkie
Bend, Oregon
Jeff Conrad said:
"Stephen Lebans"
Hi Sensei!

Comments below...


Ahhh, I see.


Thanks, that did help.
I actually considered searching on your name, but was not sure what keyword(s) to use.


Now I get it!
This *pointer* was exactly what I was searching for. I assumed that 'something' must be saved with
the control that tells Access to go look for that picture. But in
actuality, the picture is actually
saved with the control itself. Correct?


Before seeing your response I made a big discovery and this post seems to confirm my findings. I
reviewed the table tblTBPictures in the chapter 19 MDB file and
PictureData is defined as an OLE
Object Field. So I created a simple one field test table called
tblTest with a field called Test and
defined as OLE Object. Right at the end of the RetrieveDIB sub in the sample ADH form is this line:

ctl.PictureData = rst!PictureData

Carefully looking at this led me to believe that maybe it was just copying the whole bitmap image
from one control to another. So I added these lines just before the
end of the procedure just to see
 
Back
Top