I'm changing grid's row color to red according to my needs and when it gets colored the text is invisible, under backroung color...
How to change the text color or make it transparent ???
void __fastcall TfRegular::tvFillOutCustomDrawCell(TcxCustomGridTableView *Sender,
TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
bool &ADone)
{
TRect ARec;
ARec=AViewInfo->Bounds;
//AViewInfo->GridRecord->DisplayTexts[7]="+" + AViewInfo->GridRecord->DisplayTexts[7];
// ShowMessage(AViewInfo->GridRecord->Values[13]);
if (AViewInfo->GridRecord->Values[13]>1) {
ACanvas->Canvas->Brush->Color = clRed;
ACanvas->Canvas->Font->Color = clBlack;
ACanvas->Canvas->Pen->Color = clRed;
ACanvas->Canvas->FillRect(ARec);
SetBkMode(ACanvas->Canvas->Handle,TransparentColor);
//InflateRect(AViewInfo->Bounds,2,2);
//ACanvas->DrawTexT("",AViewInfo->Bounds,0);
ADone=true;
}
}
It was really easy than I thought.
I solved this problem using OnGetContentStyle event.
Related
Thanks for your help In solving my problem
I try to add a button that can change the background of the dialog to a different color i using visual studio 2010 but i think its might be wrong way to do that
void PainterDlg::OnBnClickedButton7()
{
CBrush m_brush;
m_brush.CreateSolidBrush(RGB(255, 255, 255));
return m_brush;
}
Or it should look like this
void PainterDlg::OnBnClickedButton7()
{
CBrush m_brush;
m_brush.CreateSolidBrush(RGB(255, 255, 255));
return m_brush;
}
both ways are not work for me
thankS in advance
That is not so easy with CButton. (you have to draw all yourself in OnDrawItem, OnCtlColor)
A simpler way is to use CMFCButton.
Add a Member Variable for your Button (with MFC-ClassWizzard) and change it to CMFCButton.
Here an example to change the color button in green.
void CColorButtonSimpleDlg::OnBnClickedMyColorbtn()
{
// add a Member Variable for your Button
// Change it to CMFC Button
// CMFCButton m_myBtn; declared in Header-File *.h
m_myBtn.EnableWindowsTheming(FALSE); // (important!)
m_myBtn.SetFaceColor(RGB(0, 255, 0)); // Change to your desired Background Color
m_myBtn.SetTextColor(RGB(255, 255, 255)); // Change it to your desired Foreground Color
}
Nvm found it
int r,b,g;
r=rand()%255;
b=rand()%255;
g=rand()%255;
CBrush myb;
myb.CreateSolidBrush(RGB(r,b,g));
dc2.FillRect(&rect,&myb);
How to set style color for a line in javafx?
public void setColor(String color) {
for (int i = 0; i < 9; i++){
//lines[i].setFill(Color.BLUE);
//lines[i].setStyle("-fx-Background-color: yellow;");
//lines[i].setStyle("-fx-color:"+ color);
//setStyle("-fx-Foreground-color:"+ color);
}
}
All 4 comments do nothing the lines not colored.
I would be happy if you could help me.
Use -fx-stroke for coloring lines (using CSS)
line.setStyle("-fx-stroke: red;");
Or call setStroke() for coloring lines (using Java API):
line.setStroke(Color.RED);
I suggest using a for loop to get the children of the "lines"array and then using "-fx-stroke:" as ItachiUchiha suggested but adding the color to the string.
Here is the code:
public void setColor(String color) {
for (Line line:lines){
line.setStyle("-fx-stroke:"+ color);
}
}
I hope this helps. If you have any question just ask.
I'm trying to design a simple button (QPushButton or QToolButton, either can work) that would essentially be a rectangle of the colour it represents. Clicking it opens a QColorDialog, and selecting a colour in it repaints the button.
So, basically, something that will look like one of these:
I made a few attempts, none of which brought me the functionality I wanted.
Slot:
void MainWindow::OnButtonColorClick()
{
QColor initialColor = ui->buttonColor->palette().color(QPalette::Background);
QColor colorSelected = QColorDialog::getColor(initialColor, this);
if(colorSelected.isValid())
{
ui->buttonColor->setPalette(QPalette(colorSelected));
ui->buttonColor->setAutoFillBackground(true);
}
}
Attempt #1:
Set the Palette in the constructor:
ui->buttonCoulor->setPalette(QPalette(Qt::black));
Result: ordinary button before click, thin coloured contour after selection.
Attempt #2:
Add stylesheet:
background-color: rgb(0, 0, 0);
Result: black rectangle before click, black rectangle after selection.
I feel like I'm circling the drain. Essentially, how do I achieve:
?
Here is one way to accomplish the desired effect:
// Slot for the button
void MainWindow::on_button()
{
QColor color = QColorDialog::getColor();
QString s("background: #"
+ QString(color.red() < 16? "0" : "") + QString::number(color.red(),16)
+ QString(color.green() < 16? "0" : "") + QString::number(color.green(),16)
+ QString(color.blue() < 16? "0" : "") + QString::number(color.blue(),16) + ";");
button->setStyleSheet(s);
button->update();
}
Hope that helps.
use setStyleSheet with this style sheet:
border: 1px solid black;
background-color: #XXXXXX;
where XXXXXX is the value returned by QString::number(myColor.rgb(), 16).toUpper();
No need to set any other properties on the button. Leave them all as default and this will work.
This seems to be working just fine for me:
if(colorSelected.isValid())
{
ui->buttonColor->setPalette(QPalette(colorSelected));
}
As a follow-up to phyatt's answer, there's a shortcut to generate the XML-formatted color string:
QString s("background: " + color.name + ";");
button->setStyleSheet(s);
I have following form and I want to change the background color of a column, based on the values of other columns;
In the orange columns, instead of displaying orange background, I want the cell color to be the RGB combo of Red, Green & Blue fields under COLOR ATTRIBUTES section.
Let's say that the control the background of which you need to change is named FirstFieldControl. Set its AutoDeclaration property to Yes and BackgroundColor to Window background.
Now you need to override the displayOption method on your datasource, e.g.:
public void displayOption(Common _record, FormRowDisplayOption _options)
{
YourTable yourTable = _record;
int color;
;
switch (yourTable.Name)
{
case 'Red' :
color = WINAPI::rgbCon2int([255, 0, 0]);
break;
case 'Green' :
color = WINAPI::rgbCon2int([0, 255, 0]);
break;
case 'Blue' :
color = WINAPI::rgbCon2int([0, 0, 255]);
break;
}
if (color)
{
_options.backColor(color);
_options.affectedElementsByControl(FirstFieldControl.id());
}
else
{
super(_record, _options);
}
}
This is just an example to give you an idea - don't copy-paste :)
It's easier to store the color value in the table, then the code will be much nicer.
P.S. If you're changing the colors run-time you might need to use the following piece of code to refresh the record:
yourTable_ds.clearDisplayOption(yourTable);
yourTable_ds.refresh();
I want to show variable color according to warehouse in on-hand form. If I override displayOption on inventdim datasource, it does get called. It does get called if I override InventSum datasource. But I cannot get the actual inventdim record. In this form, InventSum is master table, and InventDim is the joined child table.
This is my code:
QTextCursor cursor = ui->editor->textCursor(); // editor is QTextEdit
cursor.select(QTextCursor::WordUnderCursor);
QString c = cursor.selectedText();
if (c == keywords[i])
{
cursor.removeSelectedText();
cursor.insertHtml("<font color=\"DeepPink\">" + keywords[i] + "</font>");
}
So, if the keyword is "new", this word is colored pink. The problem is that everything that is inserted after "new" is also colored red, and not the standard black.
Anybody? :)
UPDATE:
Stupid me. Just added ui->editor->setTextColor("#000000");
ui->editor->setTextColor("#000000");