Solved

Extracting commandbar FaceIDs for use as image in an image control

Posted on 2014-11-09
6
273 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 39

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 24

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

772 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