&HBBGGRR&
BB 指定蓝颜色的值,GG 指定绿颜色的值,RR 指定红颜色的值。每个数段都是两位十六进制数,即从 00 到 FF。&H808080&将最高位设置
Constant |
Value | Description |
---|---|---|
vbScrollBars |
0x80000000 |
Scroll bar color |
vbDesktop |
0x80000001 |
Desktop color |
vbActiveTitleBar |
0x80000002 |
Color of the title bar for the active window |
vbInactiveTitleBar |
0x80000003 |
Color of the title bar for the inactive window |
vbMenuBar |
0x80000004 |
Menu background color |
vbWindowBackground |
0x80000005 |
Window background color |
vbWindowFrame |
0x80000006 |
Window frame color |
vbMenuText |
0x80000007 |
Color of text on menus |
vbWindowText |
0x80000008 |
Color of text in windows |
vbTitleBarText |
0x80000009 |
Color of text in caption,size Box,and scroll arrow |
vbActiveBorder |
0x8000000A |
Border color of active window |
vbInactiveBorder |
0x8000000B |
Border color of inactive window |
vbApplicationWorkspace |
0x8000000C |
Background color of multiple-document interface (MDI) applications |
vbHighlight |
0x8000000D |
Background color of items selected in a control |
vbHighlightText |
0x8000000E |
Text color of items selected in a control |
vbButtonFace |
0x8000000F |
Color of shading on the face of command buttons |
vbButtonShadow |
0x80000010 |
Color of shading on the edge of command buttons |
vbGrayText |
0x80000011 |
Grayed (disabled) text |
vbButtonText |
0x80000012 |
Text color on push buttons |
vbInactiveCaptionText |
0x80000013 |
Color of text in an inactive caption |
vb3DHighlight |
0x80000014 |
Highlight color for 3-D display elements |
vb3DDKShadow |
0x80000015 |
Darkest shadow color for 3-D display elements |
vb3DLight |
0x80000016 |
Second lightest 3-D color aftervb3DHighlight |
vbInfoText |
0x80000017 |
Color of text in ToolTips |
vbInfoBackground |
0x80000018 |
Background color of ToolTips |
public final static SystemColor desktop = new SystemColor((byte)DESKTOP); public final static SystemColor activeCaption = new SystemColor((byte)ACTIVE_CAPTION); public final static SystemColor activeCaptionText = new SystemColor((byte)ACTIVE_CAPTION_TEXT); ... private static int[] systemColors; static { updateSystemColors(); } /** * Called from <init> & toolkit to update the above systemColors cache. */ private static void updateSystemColors() { if (!GraphicsEnvironment.isHeadless()) { Toolkit.getDefaultToolkit().loadSystemColors(systemColors); } } private SystemColor(byte index) { super(0,0); value = index; } public int getRGB() { return systemColors[value]; }
package com.cdai.jd; import java.awt.SystemColor; import java.util.HashMap; public class SystemColorTest { public static void main(String[] args) { SystemColorTest tester = new SystemColorTest(); // 1.Test for Palette color System.out.println(tester.convertVB2JavaColor(0x80000007) == SystemColor.menuText.getRGB()); // 2.Test for System color System.out.println(tester.convertVB2JavaColor(0x004207) == (0xFF | 0x4207)); // 3.Test for invalid input argument try { System.out.println(tester.convertVB2JavaColor(0x8100000A)); } catch (Exception e) { System.out.println("Expect exception here."); } } private static HashMap<Integer,Integer> VB2JavaSystemColorMapping = new HashMap<Integer,Integer>(); /** * Color constants refer to: * http://msdn.microsoft.com/en-us/library/office/gg264801.aspx */ static { VB2JavaSystemColorMapping.put(0x80000000,SystemColor.scrollbar.getRGB()); VB2JavaSystemColorMapping.put(0x80000001,SystemColor.desktop.getRGB()); VB2JavaSystemColorMapping.put(0x80000002,SystemColor.activeCaption.getRGB()); VB2JavaSystemColorMapping.put(0x80000003,SystemColor.inactiveCaption.getRGB()); VB2JavaSystemColorMapping.put(0x80000004,SystemColor.menu.getRGB()); VB2JavaSystemColorMapping.put(0x80000005,SystemColor.window.getRGB()); VB2JavaSystemColorMapping.put(0x80000006,SystemColor.scrollbar.getRGB()); //Window frame color? VB2JavaSystemColorMapping.put(0x80000007,SystemColor.menuText.getRGB()); VB2JavaSystemColorMapping.put(0x80000008,SystemColor.windowText.getRGB()); VB2JavaSystemColorMapping.put(0x80000009,SystemColor.activeCaptionText.getRGB()); VB2JavaSystemColorMapping.put(0x8000000A,SystemColor.activeCaptionBorder.getRGB()); VB2JavaSystemColorMapping.put(0x8000000B,SystemColor.inactiveCaptionBorder.getRGB()); VB2JavaSystemColorMapping.put(0x8000000C,SystemColor.scrollbar.getRGB()); //Background color of multiple-document interface (MDI) applications? VB2JavaSystemColorMapping.put(0x8000000D,SystemColor.textHighlight.getRGB()); VB2JavaSystemColorMapping.put(0x8000000E,SystemColor.textHighlightText.getRGB()); VB2JavaSystemColorMapping.put(0x8000000F,SystemColor.scrollbar.getRGB()); //Color of shading on the face of command buttons? VB2JavaSystemColorMapping.put(0x80000010,SystemColor.scrollbar.getRGB()); //Color of shading on the edge of command buttons? VB2JavaSystemColorMapping.put(0x80000011,SystemColor.textInactiveText.getRGB()); VB2JavaSystemColorMapping.put(0x80000012,SystemColor.controlText.getRGB()); VB2JavaSystemColorMapping.put(0x80000013,SystemColor.inactiveCaptionText.getRGB()); VB2JavaSystemColorMapping.put(0x80000014,SystemColor.controlHighlight.getRGB()); VB2JavaSystemColorMapping.put(0x80000015,SystemColor.controlDkShadow.getRGB()); VB2JavaSystemColorMapping.put(0x80000016,SystemColor.controlLtHighlight.getRGB()); VB2JavaSystemColorMapping.put(0x80000017,SystemColor.infoText.getRGB()); VB2JavaSystemColorMapping.put(0x80000018,SystemColor.info.getRGB()); } /** * Convert color hex value in VB to Java color hex. * * @param vbColorHex 0x80000000 - 0x80000018 for VB system color,* 0x00AB1234 for palette color * * @return Bits 24-31 are alpha (FF as default),* 16-23 are red,* 8-15 are green,* 0-7 are blue */ public int convertVB2JavaColor(int vbColorHex) { int javaColorHex; int highByte = (vbColorHex >>> 24); if (highByte == 0) { // Palette color if high byte is 0. javaColorHex = 0xFF | vbColorHex; } else if (highByte == 128) { // System color if highest bit is 1 javaColorHex = VB2JavaSystemColorMapping.get(vbColorHex); } else { throw new IllegalArgumentException("Illegal hex color argument: " + vbColorHex); } return javaColorHex; } }简单跑了下,不知道是否正确,有没有人有写这方面代码的经验? 原文链接:https://www.f2er.com/vb/259464.html