Solved

Extracting commandbar FaceIDs for use as image in an image control

Posted on 2014-11-09
6
292 Views
Last Modified: 2014-11-14
I've figured out how to extract both the PICTURE and MASK properties of the FaceId of any of the Office commandbar controls, and save those two properties as images on my computer.

        Set ctrl = CommandBars.FindControl(Id:=rs!FaceId)
        stdole.SavePicture ctrl.Picture, "E:\TempPic.bmp"
        stdole.SavePicture ctrl.Mask, "E:\TempMask.bmp"

But what I want to do is create an image picker that displays a set of these images in a form, either in an image control or as the picture property of a command button.  Unfortunately, neither the image control or the command button has a Mask property, so the background of all of the picture images are black, rather than what they are supposed to be.  
several sample images with Picture and MaskThe image (above) shows the first 15 faceIDs, with the top row displaying the image saved with the PICTURE property and the bottom row showing the image created with the MASK property.

Is there a way to combine these images or to save the image as a gif or other image type, which can then be assigned to the PICTURE property of an image control or a command button?
0
Comment
Question by:Dale Fye (Access MVP)
6 Comments
 
LVL 40

Assisted Solution

by:als315
als315 earned 250 total points
ID: 40431564
I can't give you exact command, but you can combine image and mask with ImageMagick:
http://www.imagemagick.org/
0
 
LVL 47

Author Comment

by:Dale Fye (Access MVP)
ID: 40431609
Thanks, Alexey, I'll take a look, but I was hoping that I wouldn't have to resort to a 3rd party application.  Would prefer to not have to actually distribute the over 3000 face images available in the various Office applications.  

I was hoping there was a way to capture the image intact and that I could go straight from the commandbarcontrol to the clipboard or file and then to the picture property of either an image or command button on a form.

I've seen a couple of things that take advantage of a ribbon gallery, and want to do something similar to that, without using the ribbon.
0
 
LVL 25

Accepted Solution

by:
chaau earned 250 total points
ID: 40431654
I think MaskBlt is what you are after. However, to use it you need the HBITMAP handles. To Load a HBITMAP from file use the following API:
HBITMAP hBMP = (HBITMAP) LoadImage( NULL, "e:\\TempPic.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

Open in new window

HBITMAP hMask = (HBITMAP) LoadImage( NULL, "e:\\TempMask.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

Open in new window

Please let me know if you need the whole C++ function
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Author Closing Comment

by:Dale Fye (Access MVP)
ID: 40443016
Thanks, for your help, but it turns out that that method is a lot of work.  

But I fortunately found an alternative, starting in 2007 the commandbar object has several GetImageXXX methods.  The particular version that I'm using is the GetImageMSO method which looks like:

Dim pic as iPictureDisp
set pic = Application.CommandBars.GetImageMso(msoID, 16, 16)
stdole.SavePicture pic, "E:\Temp.BMP"

This method allows me to save the image intact, but you must know the msoID values associated with the method.  I was finally able to find a list of the msoID text values (which are similar to, but not the same as the Captions of the commandbar controls that you get when you loop through the various commandbar control ID values).  And am now able to quickly (under 1 second) generate a form which displays a set of 255 images, and loop through the data to view and select from among these images.  .

3,286 of these images are available in Access 2007, but 2010 and 2013 apparently have over 8500, have not tested it in those environments yet.  Some of the images are duplicates, but have different msoID values, for example, the green check-marks in row 4 have msoID values of "AcceptInvitation", "AcceptProposal", and "AcceptTask"
0
 
LVL 75
ID: 40443189
COOL !
0
 
LVL 47

Author Comment

by:Dale Fye (Access MVP)
ID: 40443259
Joe, i'll try to get this new interface into the tool this weekend and get you a copy to play with by next week.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

713 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