Solved

Extracting commandbar FaceIDs for use as image in an image control

Posted on 2014-11-09
6
259 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

12 Experts available now in Live!

Get 1:1 Help Now