|
Problem solved. It's a live source, so there are some things different from a normal pull source.
Don't try it, just do it!
|
|
|
|
|
What is the rigth method to add a Statusbar to a Dialog?
I had done this way.
CStatusBar m_StatusBar //Memeber variable
m_StatusBar->Create(this);
But whenever i call 'Invalidate' method the status bar also flickering
Is the GetClientRect retrieves the StatusBar area also?
Thanks in Advance
Ann
|
|
|
|
|
I think the status bar is flickering because it is a child of the dialog. If you invalidate the entire dialog, then the status bar comes along for the ride.
Some things I would try:
1. Invalidate only the specific client area of the dialog that does not include the status bar.
2. Adjust the client rect of your dialog to exclude the status bar.
3. Set the clip children style of the dialog, so it does not erase or repaint the area with the status bar or any other child controls.
|
|
|
|
|
Anyone knows a method which does hexadecimal to decimal conversion in the visual c++ library ??
Cheers
llp00na
|
|
|
|
|
|
Now I've checked it. Here it is:
int hexToInt(const char * hex)
{
// Expects to get ONE hex digit at the time
int result;
sscanf(hex, "%x", &result);
return result;
}
int main(int argc, char* argv[])
{
int i = hexToInt("FF"); // i becomes 255
i = hexToInt("80"); // i becomes 128
i = hexToInt("40"); // i becomes 64
i = hexToInt("0"); // i becomes 0
return 0;
}
|
|
|
|
|
thanx for the reply, i will test your suggestion and see the results.
I am trying to get colours from the html source code and convert them to RGB format.
using your method will make it easy to convert a string of the format #ffffff
as i will just devide the string into three parts where each part represents red, green, blue respectively.
My problem now is that people sometimes do not use conventional formats but instead use for example : #fff to refer to #0f0f0f, that should not be so hard to deal with. a more complicated case would be : #9999 !!! how do i now which part of the string refers to red, green, and blue !!!
llp00na
|
|
|
|
|
If you can format the string into a string containing 2+2+2 hex characters all the time, then you can use this way to get the values all at once:
int r,g,b;
// Create a test string:
char hex2[10];
strcpy(hex2, "0f05ff");
sscanf(hex2, "%02x%02x%02x", &r, &g, &b);
// Result: r == 15, g == 5, b == 255
It's tested and works.
Later
kakan
|
|
|
|
|
|
I have tested #999 and i found that IE treats it as #090909
Which is bad news for me
llp00na
|
|
|
|
|
not really.
6 hex digits : ok.
3 digits : ok (#fff = #0f0f0f)
anything else : add zeros to the right side to make 6 digits
word : use a map to find the RGB value
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
do you mean hexa into a string ? or hexa into an integer ?
if you want to cast an integer stored in hexa to a decimal, there"s no need to cas, because the hexadecimal is just a representation...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
All i want to do is to convert colour formats to RGB decimal representation
for example: convert #ff0000 to be (255,0,0)
more complicated cases is when i encounter colours expressed as: #999
or #3333
how do you know which part is red, green, and blue !!!
llp00na
|
|
|
|
|
#999 = #000999
#3333 = #003333
Isn't it?
Don't try it, just do it!
|
|
|
|
|
#999 = #090909 not #000999 (which are totally different)
#3333 can be #003333 or #033303 or #330303 or ...
you get my point !!!
llp00na
|
|
|
|
|
llp00na wrote:
#3333 can be #003333 or #033303 or #330303 or ...
So it is impossible to translate to decimal ! You cannot guess what the user wanted to have !! It is purely impossible without some strict rules.
|
|
|
|
|
When I type #999 in any graphics software I get #000999...!
Don't try it, just do it!
|
|
|
|
|
llp00na wrote:
#3333 can be #003333 or #033303 or #330303 or ...
If you stick with the numeric rules, there is no confusion
#3333 = 3333h = 0x3333 = 0x003333.
A good way to test this is if you type in the numeral in you calculator and see how it parses the input. leading zeros are implied and therefore not displayed.
I Dream of Absolute Zero
|
|
|
|
|
split the hex number up in respective RGB values
0x112233 -> 0x11 is red 0x22is green 0x33 is blue
with some bitwise shifting the individual values are easily extracted.
COLORREF nRGBVal = 0x112233;
BYTE nRed = 0xFF&(nRGBVal>>16);
BYTE nGreen = 0xFF&(nRGBVal>>8);
BYTE nBlue = 0xFF&nRGBVal;
That should do it I guess..
|
|
|
|
|
GDavy wrote:
BYTE nRed = 0xFF&(nRGBVal>>16);
BYTE nGreen = 0xFF&(nRGBVal>>8);
BYTE nBlue = 0xFF&nRGBVal;
Use GetRValue() , GetGValue() , and GetBValue() for this.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Please remember that i am getting the colour as a string (eg. #ffffff is a string)
llp00na
|
|
|
|
|
Use strtoul() . It's easier to check for errors than sscanf() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
And probably a damn sight faster too - no parsing involved
|
|
|
|
|
While sscanf's format string can do lots of magical things, the function as a whole does not lend itself to easy error detection and recovery. strtoul() is a tad bit better, but the ultimate solution would of course be a finite state machine (FSM).
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
thanx everyone for helping me sorting my problem, here is more explanation to the RGB possible formats
The format of an RGB value in hexadecimal notation is a '#' immediately followed by either three or six hexadecimal characters. The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands to #ffbb00. This makes sure that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the display
cheers
llp00na
|
|
|
|