|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
color formatHi,
In the forecolor property of a form, for example, there are numbers like: &H00FF1100&. What are these characters stands for? H means hexadecimal but if the numbers refer to RGB system, then it must have 6 digits not 8. Also what is the meaning of & in the beginning and end of the number? Surena > In the forecolor property of a form, for example, there are numbers A colour is defined as three channels, Red, Green and Blue and typically each has a range of 0-255 so they can fit> like: &H00FF1100&. What are these characters stands for? H means > hexadecimal but if the numbers refer to RGB system, then it must have 6 > digits not 8. within a single byte. Since there is no native 3-byte data type they are usually stored in 4-byte Long (or DWord) and the top byte is unused. In some cases however the high byte is used to store flags about the colour or in 32-bit images it can be used to store the opacity of 'alpha' component of the colour. As an example of the high byte used to store flags about the colour, display the hex of a system colour: '*** ?hex(vbButtonFace) Prints: 8000000F '*** In this case the high byte is set to 0x80 indicating this is a system colour and the low byte stores an index of which system colour is being referred to, in this case 15 the button face colour. If you need the literal RGB value for a system colour then you can use my EvalCol() method: http://groups.google.co.uk/group/microsoft.public.vb.winapi.graphics/msg/14e60348e7b08730 Literal VB colours are defined as (A)BGR meaning that the low byte defines the red channel, the second byte defines the green channel and the third byte defined the blue channel so in your case: Red: 0x00 Green: 0x11 Blue 0xFF This would give you a very slight cyan tint off solid blue. If you want to create your own colour values then either define them in hex notation or use the RGB() function which puts all the colour channels together for you. If you want to define colours with an alpha channel then you can use this ARGB() function instead: http://groups.google.co.uk/group/microsoft.public.vb.general.discussion/msg/2a6595e73f5470c8 > Also what is the meaning of & in the beginning and end of the number? The leading "&H" indicates the value is in hexadecimal, and the trailing "&" indicates it should be coerced into a longdata type, otherwise VB will allocate the most efficient datatype instead. Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ "surena" <surena_ab***@yahoo.com> wrote in message Actually &H means hexadecimal.news:1138874358.110586.140340@g14g2000cwa.googlegroups.com... > In the forecolor property of a form, for example, there > are numbers like: &H00FF1100&. What are these > characters stands for? H means hexadecimal . . . > but if the numbers refer to RGB system, then it must Colour values are held in a Long data type (four bytes). In the hexadecimal > have 6 digits not 8 . . . system each byte is displayed as two digits, making eight digits in all. When VB prints or displays a hexadecimal value it normally suppresses leading zeros, so if you type into some code: Dim zed as Long zed = &H00001234 .. . . then as soon as you press the space bar or the enter key or whatever, VB will change it to: zed = &H1234 However, zed is still a Long, and it still contains four bytes of data. It's just that the highest order two bytes contain zero and so VB doesn't bother to display them. In the case of a Long containing a Color value only the lowest order three bytes are significant, but the Long itself always contains four bytes, with the highest order byte containing zero. > Also what is the meaning of & at the end of the number? That is the type-declaration character signifying a Long. A type-declaration character is something that is appended so that VB will know what type of variable you want it to be (Integer, Long, Single, String etc). For example & means it is a Long, % means it is an Integer, ! means it is a Single and $ means it is a String. The use of type-declaration characters is frowned upon these days, and it is preferably to explicitly declare the type of the variable instead. In fact you should never use a variable unless you have declared it first. For example: Dim zed as Long, x, as Integer, s1 as String In the specific case of the Properties window in the Visual Basic IDE the values for BackColor and ForeColor and whatever are displayed in full, showing the leading &H and all eight digits and the trailing & character. A special case in the Properties window is the way in which "system colours" are displayed. You will notice that these all have the first character set to 8 (signifying that the highest order bit of the 32 bit Long value is set), with the remaining seven characters representing a number that tells VB which of the system colours to use. Mike "surena" <surena_ab***@yahoo.com> wrote in message What you're seeing is the Hexadecimal representation of a Long.news:1138874358.110586.140340@g14g2000cwa.googlegroups.com... > Hi, > > In the forecolor property of a form, for example, there are numbers > like: &H00FF1100&. What are these characters stands for? H means > hexadecimal but if the numbers refer to RGB system, then it must have 6 > digits not 8. Also what is the meaning of & in the beginning and end of > the number? Your example, in decimal, would be 16716032 The leading "&H" makes it a Hexadecimal value. The trailing "&" means it's a Long value, rather than an Integer one. Try putting &HFF (which VB assumes in an Integer) into a Long variable and you'll get some very strange values appearing (like &HFFFF00FF&)! As you say, the RGB system using three components, encoded into the value you're seeing like this: &H00BB0000 Blue bits &H0000GG00 Green bits &H000000RR Red bits The most significant byte (the leading "00") is reserved and used to identify the System Colours, e.g. Windows Background, which is &H80000005&. BTW, you should probably try to use the System Colours as much as possible - it's amazing how much users can get upset when you try changing the colour of things on them. ;-) HTH, Phill W.
USB-Memorystick - serial number
Hpw to make a VB6 form appears and gets focus every 15 seconds Writing to .TXT file question Best way to extract a word from a sentence Do we have such a container control? Book for web dev with VS2005? Need help regarding the program... Please help me.. It's very Urgent MSComm application hangs - comEventRxOver Monthview control - run time 380 invalid property value Recordset to FlexGrid |
|||||||||||||||||||||||