Skaityti anglų kalba

Bendrinti naudojant


How-To Use 32-Bit Graphics In Your Snap-in

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

Here are some guidelines for using 32-bit graphics in your snap-ins.

Native Snap-ins

For native snap-ins, provide device independent bitmaps to MMC. Use LoadImage with LR_CREATEDIBSECTION when you load your bitmap resources. This will load them as device independent bitmaps. This is not required for icons. Please set the higher order byte of your color mask. This informs MMC that it is a 32-bit image. An example of such a color mask is 0xFF000000 | RGB(255, 0, 255).

Managed Snap-ins

Do not set the TransparentColor property for MMC small image lists and MMC large image lists. If you have some old 8-bit bitmaps which you want to use with your 32-bit bitmaps, use the image list Add function with the appropriate Mask.

If you add icons to the small image list, load them as 16x16 icons (for example, System.Drawing.Icon ( Resource.Icon1, 16, 16) ). By default, the resource class provides 32x32 icons. MMC does not support 32-bit bitmaps with alpha channel, since GDI+ does not support them. You may use 32-bit icons and PNGs.

Guidelines for Graphics With Bidirectional Requirements

MMC automatically flips all images which are added to the MMC image list on RTL (Right To Left) operating systems. If you have an image which you don’t want to flip, you must keep two versions of the resource, one for LTR (Left To Right) and one for RTL. In the RTL version of the resource pre-flip any images that you do not want flipped. They will get flipped by MMC again, thus causing them to render correctly. Another option is to add the icon to your .rcconfig file so that it gets flipped during localization.

Pastaba

The snap-in icon in the caption bar and the snap-in icon in the About dialog do not come from the MMC image list, and hence they will not be flipped automatically.

How-To Find Out If a Particular Window is RTL

For native code, use the following check:

if( <window>::GetExStyle() & WS_EX_LAYOUTRTL)
{
    //Window is RTL
}
else
{
    //Window is not RTL
}

For more information see GetExStyle() and WS_EX_LAYOUTRTL Constant on MSDN. For managed code, examine the culture used by the resource manager:

if(Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft)
{
   //Window is RTL
}
else
{
   //Window is not RTL
}

For more information visit Thread.CurrentUICulture Property.

How To Set a snap-in Custom Bitmap in an Add/Remove Dialog

Set the SmallFolderBitmapId attribute to a bitmap resource id. Note that icons are not supported. For more information please see SnapInAboutAttribute .

How-To Use Your Own Managed Image List

  1. Set the size of your image list.

    <yourimgList>.ImageSize = new Size(16, 16);
    
  2. Set the color depth of your image list to 32-bit. By default, it is 8-bit.

    <yourimgList>.ColorDepth = ColorDepth.Depth32Bit;
    
  3. Do not set the TransparentColor property for your image list.

How-To Update a console file With 48x48 Icons

Windows Vista provides support for 48x48 icons in MMC 3.0. Follow these steps to update your console files (.msc files) with 48x48 icons.

Update Existing .msc Files

  1. Check out the .msc file and load it into MMC in an administrative mode. 

  2. Go to File > Options > Change Icon and select a different icon. Click OK. This step is necessary to ensure that the new icon gets picked even if the path to the icon is still the same.

  3. Again, go to File > Options > Change Icon and choose the snap-in icon. Click OK. This will ensure that the 48x48 image is picked.

  4. Save and overwrite the existing .msc file.

  5. Verify that the console file icon shows up correctly in the file explorer.

Create New .msc Files

  1. Update your console file icons resource and add the new icon.

  2. Build your snap-in with the new icon.

  3. Load the snap-in in MMC using the MMC Add/Remove dialog.

  4. Save the new MMC console file.

See Also

MMC Advanced Topics