chencc77
asked on
commonDialog Show color
i use Visual Interdev to create a CommonDialog box to display color box for me to choose color.
but i found that the color i choosed is not same as the color display. (Not all color, but some)
So i hope anyone can help me. Thanks alot.
Below is the source code.
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META name=VI60_defaultClientScr ipt content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub button1_onclick
CommonDialog1.ShowColor
text1.style.backgroundColo r= CommonDialog1.Color
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<P>
<OBJECT id=CommonDialog1 classid=clsid:F9043C85-F6F 2-101A-A3C 9-08002B2F 49FB><PARA M NAME="_ExtentX" VALUE="847"><PARAM NAME="_ExtentY" VALUE="847"><PARAM NAME="_Version" VALUE="393216"><PARAM NAME="CancelError" VALUE="0"><PARAM NAME="Color" VALUE="0"><PARAM NAME="Copies" VALUE="1"><PARAM NAME="DefaultExt" VALUE=""><PARAM NAME="DialogTitle" VALUE=""><PARAM NAME="FileName" VALUE=""><PARAM NAME="Filter" VALUE=""><PARAM NAME="FilterIndex" VALUE="0"><PARAM NAME="Flags" VALUE="0"><PARAM NAME="FontBold" VALUE="0"><PARAM NAME="FontItalic" VALUE="0"><PARAM NAME="FontName" VALUE=""><PARAM NAME="FontSize" VALUE="8"><PARAM NAME="FontStrikeThru" VALUE="0"><PARAM NAME="FontUnderLine" VALUE="0"><PARAM NAME="FromPage" VALUE="0"><PARAM NAME="HelpCommand" VALUE="0"><PARAM NAME="HelpContext" VALUE="0"><PARAM NAME="HelpFile" VALUE=""><PARAM NAME="HelpKey" VALUE=""><PARAM NAME="InitDir" VALUE=""><PARAM NAME="Max" VALUE="0"><PARAM NAME="Min" VALUE="0"><PARAM NAME="MaxFileSize" VALUE="260"><PARAM NAME="PrinterDefault" VALUE="1"><PARAM NAME="ToPage" VALUE="0"><PARAM NAME="Orientation" VALUE="1"></OBJECT>
<INPUT id=text1 name=text1></P>
<P><INPUT id=button1 type=button value=Button name=button1></P>
</BODY>
</HTML>
but i found that the color i choosed is not same as the color display. (Not all color, but some)
So i hope anyone can help me. Thanks alot.
Below is the source code.
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META name=VI60_defaultClientScr
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub button1_onclick
CommonDialog1.ShowColor
text1.style.backgroundColo
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<P>
<OBJECT id=CommonDialog1 classid=clsid:F9043C85-F6F
<INPUT id=text1 name=text1></P>
<P><INPUT id=button1 type=button value=Button name=button1></P>
</BODY>
</HTML>
In cases I encounered that IE browsers don't show the selected colors but a close match... I thought it might be that I have a pattern of 24bit colors (FFFFFF) and my display settings are set to 16 bit or less.. this might occure..
ASKER
i found that the color box use 'long' numeric to identify the color. So how am i going to solve this problem??
yes.. 24 bit value.. 16777215 = FFFFFF hex
what are your entered values?
what are your entered values?
I found the red and blue color has been change position
try this
Function RGBX(red, green, blue)
On Error Resume Next
RGBX = RGB(blue, green, red)
end Function
function GetRed(color)
On Error Resume Next
GetRed = color And &HFF
end Function
function GetGreen(color)
On Error Resume Next
GetGreen = ((color And &HFF00) / &H100) And &HFF
end Function
function GetBlue(color)
On Error Resume Next
GetBlue = ((color And &HFF0000) / &H10000) And &HFF
end Function
text1.style.backgroundColo r = RGBX(getblue(color), getgreen(color), getred(color))
try this
Function RGBX(red, green, blue)
On Error Resume Next
RGBX = RGB(blue, green, red)
end Function
function GetRed(color)
On Error Resume Next
GetRed = color And &HFF
end Function
function GetGreen(color)
On Error Resume Next
GetGreen = ((color And &HFF00) / &H100) And &HFF
end Function
function GetBlue(color)
On Error Resume Next
GetBlue = ((color And &HFF0000) / &H10000) And &HFF
end Function
text1.style.backgroundColo
OOhs where color is
Dim color
color = CommonDialog1.Color
Dim color
color = CommonDialog1.Color
ASKER
hi EDDYKT,
i have edit the code, but i found it show all black color.
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META name=VI60_defaultClientScr ipt content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Dim color
Sub button1_onclick
CommonDialog1.ShowColor
color = CommonDialog1.Color
msgbox color
msgbox RGBX(getblue(color), getgreen(color), getred(color))
text1.style.backgroundColo r = RGBX(getblue(color), getgreen(color), getred(color))
End Sub
Function RGBX(red, green, blue)
msgbox "rGBX"
On Error Resume Next
RGBX = RGB(blue, green, red)
end Function
function GetRed(color)
On Error Resume Next
GetRed = color And &HFF
end Function
function GetGreen(color)
On Error Resume Next
GetGreen = ((color And &HFF00) / &H100) And &HFF
end Function
function GetBlue(color)
On Error Resume Next
GetBlue = ((color And &HFF0000) / &H10000) And &HFF
end Function
-->
</SCRIPT>
</HEAD>
<BODY>
<P> </P>
<INPUT id=text1 name=text1>
<INPUT id=button1 type=button value=Button name=button1>
<OBJECT id=CommonDialog1 classid=clsid:F9043C85-F6F 2-101A-A3C 9-08002B2F 49FB><PARA M NAME="_ExtentX" VALUE="847"><PARAM NAME="_ExtentY" VALUE="847"><PARAM NAME="_Version" VALUE="393216"><PARAM NAME="CancelError" VALUE="0"><PARAM NAME="Color" VALUE="0"><PARAM NAME="Copies" VALUE="1"><PARAM NAME="DefaultExt" VALUE=""><PARAM NAME="DialogTitle" VALUE=""><PARAM NAME="FileName" VALUE=""><PARAM NAME="Filter" VALUE=""><PARAM NAME="FilterIndex" VALUE="0"><PARAM NAME="Flags" VALUE="0"><PARAM NAME="FontBold" VALUE="0"><PARAM NAME="FontItalic" VALUE="0"><PARAM NAME="FontName" VALUE=""><PARAM NAME="FontSize" VALUE="8"><PARAM NAME="FontStrikeThru" VALUE="0"><PARAM NAME="FontUnderLine" VALUE="0"><PARAM NAME="FromPage" VALUE="0"><PARAM NAME="HelpCommand" VALUE="0"><PARAM NAME="HelpContext" VALUE="0"><PARAM NAME="HelpFile" VALUE=""><PARAM NAME="HelpKey" VALUE=""><PARAM NAME="InitDir" VALUE=""><PARAM NAME="Max" VALUE="0"><PARAM NAME="Min" VALUE="0"><PARAM NAME="MaxFileSize" VALUE="260"><PARAM NAME="PrinterDefault" VALUE="1"><PARAM NAME="ToPage" VALUE="0"><PARAM NAME="Orientation" VALUE="1"></OBJECT>
</BODY>
</HTML>
i have edit the code, but i found it show all black color.
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META name=VI60_defaultClientScr
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Dim color
Sub button1_onclick
CommonDialog1.ShowColor
color = CommonDialog1.Color
msgbox color
msgbox RGBX(getblue(color), getgreen(color), getred(color))
text1.style.backgroundColo
End Sub
Function RGBX(red, green, blue)
msgbox "rGBX"
On Error Resume Next
RGBX = RGB(blue, green, red)
end Function
function GetRed(color)
On Error Resume Next
GetRed = color And &HFF
end Function
function GetGreen(color)
On Error Resume Next
GetGreen = ((color And &HFF00) / &H100) And &HFF
end Function
function GetBlue(color)
On Error Resume Next
GetBlue = ((color And &HFF0000) / &H10000) And &HFF
end Function
-->
</SCRIPT>
</HEAD>
<BODY>
<P> </P>
<INPUT id=text1 name=text1>
<INPUT id=button1 type=button value=Button name=button1>
<OBJECT id=CommonDialog1 classid=clsid:F9043C85-F6F
</BODY>
</HTML>
ASKER
EDDYKT : i found the Getxxx function doesn't work.
Silvers5 : my display setting is 24bit - TRue Color, izit the display setting will effect it?? i found the IE browser use the same color box, but it showed the exact color as i choosed. So wht was the reason there?? Thanks
Silvers5 : my display setting is 24bit - TRue Color, izit the display setting will effect it?? i found the IE browser use the same color box, but it showed the exact color as i choosed. So wht was the reason there?? Thanks
Nahh.. this has nothing with the display then.. 1 min..
why such a turn.. simply remove all the other functions and leave this:
Sub button1_onclick
CommonDialog1.ShowColor
color = hex(CommonDialog1.Color)
text1.style.backgroundColo r = "#" & color
End Sub
;o)
Sub button1_onclick
CommonDialog1.ShowColor
color = hex(CommonDialog1.Color)
text1.style.backgroundColo
End Sub
;o)
hmm same issue.. I'll do it another way.. 1 min..
ASKER
silver5 : can u try my code?? really there are some color that display different color from wht i choose.
ASKER
silver5 : can u try my code?? really there are some color that display different color from wht i choose.
ASKER
silver5 : they are a error if use ur suggestion.
hex(0) = 0
no this color
:>
hex(0) = 0
no this color
:>
the dialogue box is returning the colors info blue green red instead of red green blue ..I'll fix you a code in 1 min..
Shake it baby ;o)
Sub button1_onclick
CommonDialog1.ShowColor
color = hex(CommonDialog1.Color)
color = Right(color,2) & Mid(color,3,2) & left(color,2)
text1.style.backgroundColo r = "#" & color
End Sub
Sub button1_onclick
CommonDialog1.ShowColor
color = hex(CommonDialog1.Color)
color = Right(color,2) & Mid(color,3,2) & left(color,2)
text1.style.backgroundColo
End Sub
ASKER
silver5 : they are a error if use ur suggestion.
hex(0) = 0
no this color
:>
hex(0) = 0
no this color
:>
This issue was tricky! the dialogue box seemed to have a bug.. 100 extra points are nice :o) jokin..
ASKER
silver5 : they are a error if use ur suggestion.
hex(0) = 0
no this color
:>
hex(0) = 0
no this color
:>
ASKER
no problems... :>
need ur help.
need ur help.
I'll need to polish the code for bugs.. like if the color number is less than 6 digits.. or is 0
But the main issue is resolved.. colors are shown exactly as they are.. give me a minute for polishing..
ASKER
silver5 : not all color are fix. still got error.
:(
:(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>silver5 : not all color are fix. still got error.
what color?
what color?
ASKER
silver5 : not all color are fix. still got error.
:(
:(
remove the msb boxes from the sub..
msg boxes
the last code I gave will take all colors.. the error you had is because of the colors that are less than 6 in hex length.. try it and report back
ASKER
silver5 : not all color are fix. still got error.
:(
:(
Chen.. what is the error? or your post is duplicated (you are on a slow connection?)
ASKER
silver5 : thank you very much, really appreciate ur help.
^_^ . really nice to meet u here!!
from,
cc chen
^_^ . really nice to meet u here!!
from,
cc chen
ASKER
silver5 : yes, the msg is duplicated. u have solve all the problems...
ASKER
here's ur points
You're welcome ;o) I was glad to solve.. a bug! :o)
I posted comment to your other question that you can't use getred getgreen and getblue function.. your best way is to convert them to Hex and get the part you need using mid function..
rgrds
I posted comment to your other question that you can't use getred getgreen and getblue function.. your best way is to convert them to Hex and get the part you need using mid function..
rgrds