the form backcolor is 14221235 , but when i set the customcolor in colordialog to equal the form backcolor, it sets it to 5046311 !!! what is the problem?
this is how i am getting the background color:
get_background = Str(Abs(Form1.BackColor.ToArgb))
the reason i am turning it into a string is because i will feed it into a string which has "32498239, 234234234, 23423234, 32234432432, 423324234"
then i take this string and put it in customcolors like this. btw this piece of code works fine:
Dim numberStrings = My.Settings.mytext1.Split(","c).Select(Function(x) x.Trim())
ColorDialog1.CustomColors = numberStrings.Select(Function(x) CInt(x)).ToArray()
a user below mentioned that toargb takes into account the opacity. this is an excellent point indeed, and i want to clarify that i DO NOT need the opacity. how would i do toargb without taking into opacity?
this is what you want
Microsoft.VisualBasic.RGB(Me.BackColor.R, Me.BackColor.G, Me.BackColor.B).ToString
The 32-bit result from .ToArgb() contains not just the three visible color components (red, green and blue) but also the alpha component, which is essentially opacity. This is a pure guess on my part, but I think the ColorDialog is just used for picking RGB values, so when you set the color to the form's BackColor, the dialog just ignores the alpha component (or sets it to zero), which is why you end up getting a different number from the .ToArgb() method.
Note: this is just speculation on my part. It would help if you posted a code sample that demonstrates the specific problem.
I don't really understand the question. You want to set the custom color dialog CustomColor property to (the form's backcolor) r + g + b components? Not sure why you would do that, you can always just get the form's backcolor, set the Alpha value to 255 and then set the result to the CustomColor property:
Color c = Color.FromArgb( 255, form1.BackColor );
myColorDlg.CustomColor = c;
Or just use form1.BackColor.ToArgb() & 0xFFFFFF (if you want the integer value).
If you are asking for ARGB (A = Alpha) then you are asking for the opacity information. Instead you could use the R, G, B Properties of Color Independently.
You could use Color.FromArgb(255, me.BackColor).ToArgb() in order to get the ARGB value of the same color with 100% opacity.
To highlight how to pass the same colour (Using Fredou's answer) from a colorDialog to set a pie chart segment colour, one which is a .Net embedded chart and the other an Excel chart:
embchartPie.Series(0).Points(Index).Color = ColorDialog1.Color
With ColorDialog1.Color
xl_Pie_Chart.SeriesCollection(1).points(Index + 1).format.fill.forecolor.rgb = RGB(.R, .G, .B).ToString
End With
Related
I am facing problems changing the checkmark on the radiogroup, or color, I appreciate the help
I tried the StyleBuilder, changed the font colors, but failed to change the side mark that shows the selected radiobutton
sample
thank you,
If you have static images, you can change RadioButton icons through constants in your theme.res. The applicable constants are:
radioUnselectedImage
radioUnselectedDisImage
radioSelectedImage
radioSelectedDisImage
If you don't have static images or you want to set the images dynamically in code, you may call below (before your RadioButton declaration):
float sizeMM = 3f;
int size = Display.getInstance().convertToPixels(sizeMM);
int blue = 0x73b5e3;
int white = 0xffffff;
FontImage checkedImage = FontImage.createFixed("" + FontImage.MATERIAL_CHECK, FontImage.getMaterialDesignFont(),
blue, size, size, 0);
FontImage uncheckedImage = FontImage.createFixed("" + FontImage.MATERIAL_CHECK, FontImage.getMaterialDesignFont(),
white, size, size, 0);
((DefaultLookAndFeel) UIManager.getInstance().getLookAndFeel())
.setRadioButtonImages(checkedImage, uncheckedImage, checkedImage, uncheckedImage);
((DefaultLookAndFeel) UIManager.getInstance().getLookAndFeel())
.setRadioButtonFocusImages(checkedImage, uncheckedImage, checkedImage, uncheckedImage);
Note: DefaultLookAndFeel is deprecated and may cause weird behavior, use it with caution.
I'm using similar kind of functions to get some property attributes like Filename, bit depth, dimensions, size etc by using some vba code. The last line of that function would be something like the following:
PicSize = CreateObject("Shell.Application").Namespace(vPth2).Parsename(sPic2).ExtendedProperty("size")
Now, I want to get the height and width of that image file. I've put height and width in the ExtendedProperty attribute value but it's not giving me the height and width of that file.
Note that, in the property dialog box of that image file, in the summary tab, it is showing Bit depth but putting this did not work. Then I put bitdepth and it worked successfully. The names are not case sensitive.
Okay! Now all I want to get the height and width of that selected image file. How can I do that? I mean what to put inside ExtendedProperty() to get height and width.
An early reply with solution would be highly appreciated.
Can't help with why Height and Width don't work, but Dimensions seems to work, returns a string like ?493 x 376?
I suggest the work around method
replace size in your code
PicSize=CreateObject("Shell.Application").Namespace(vPth2).Parsename(sPic2).ExtendedProperty("size")
to Dimensions
you will get something like ?493 x 376?
now declare
a string t = "?493 x 376?"
'search the index of "x"
search_x = InStr(t, "x")
'we would got width and height by
width = Mid(t, 2, search_x - 2)
height = Mid(t, search_x + 2, Len(t) - 8)
It is unknow why but I found that start at "2" in width and "-8" in height like that would give a number
Is there anyway to change parts of the text I add into CEikRichTextEditor control without selecting the text first - which shows the green selection rectangle over the text - and then apply text style?
Here is the code I use which gives an ugly and sloppy style when user see the running green selection rectangle over the text especially when I insert the text inside a loop
CDesCArray* temp = new(ELeave) CDesCArrayFlat(4);
temp->AppendL(_L("First"));
temp->AppendL(_L("Second"));
temp->AppendL(_L("Third"));
temp->AppendL(_L("Fourth"));
TBuf<100>iNumbers;
iNumbers.Copy(_L("Here is the numbers"));
iRichText1->SetTextL(&iNumbers); // iRichText1 is a pointer to CEikRichTextEditor object
for(TInt i = 0; i < temp->Count(); i++)
{
TInt x = iRichText1->Text()->DocumentLength();
iRichText1->RichText()->InsertL(x, (*temp)[i]);
iRichText1->SetSelectionL(x,iRichText1->Text()->DocumentLength());
iRichText1->BoldItalicUnderlineEventL(CEikGlobalTextEditor::EItalic);
TInt line = iRichText1->Text()->DocumentLength();
iRichText1->RichText()->InsertL(line, _L("\f\f"));
}
Many thanks in advance.
You need to operate on the CRichText object owned by the editor and apply a paragraph or character format over it (using ApplyCharFormatL() / ApplyParaFormatL()). This avoids any need to select text.
Example applying a paragraph format
Example applying a character format
I have two problems with my windows form in Visual Basic .NET 2008. If you have worked with sticky notes you will understand me better.
Now my problems:
If you look you'll see the background color of number 1 and 2 are
diffrent but both belongs to the same control. How is this possible?
In right bottom corner, there is something by which a user can resize the form.
How I can do this?
Item 1: I think you are referring to LinearGradient Brush-- look in the System.Drawing.Drawing2D class.
Item 2: They are drawing a resize handler. You can try using the ControlPaint.DrawSizeGrip method or draw your own.
Update:
Per your comments, you can look into Owner-drawing a Windows.Forms TextBox
You can draw a gradient background by overriding OnPaintBackground():
protected override void OnPaintBackground(PaintEventArgs e)
{
// set these to whatever you want
Color color1 = Color.LightBlue;
Color color2 = Color.DarkBlue;
using (Brush backbrush =
new LinearGradientBrush(e.ClipRectangle, color1, color2,
LinearGradientMode.Vertical))
{
e.Graphics.FillRectangle(backbrush, e.ClipRectangle);
}
}
You can show the size gripper by setting the form's SizeGripStyle to Show:
SizeGripStyle = SizeGripStyle.Show;
Or just set it in the designer.
EDIT: Look at this page for creating a transparent textbox (if the textbox is transparent, the gradient form background will show through.)
I have a VB.NET form with a red background and white text. I want to change the opacity of the background (not the text) to 50%; how would I go about accomplishing that?
Use the Form.Opacity property.
Snippet from MSDN link:
Dim instance As Form
Dim value As Double
value = instance.Opacity
instance.Opacity = value