I am developing a form in C++ using visual studio.
I need to change the color of the text in the text bar across the top, ie. where it says 'form1', until it is changed.
Also, can I change the color of that bar?
9 Replies - 2996 Views - Last Post: 21 April 2012 - 06:43 PM
#1
Change the color of the text associated with the control
Posted 21 April 2012 - 08:54 AM
Replies To: Change the color of the text associated with the control
#2
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 10:12 AM
#3
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 11:01 AM
What section should I be asking this in?
The question applies to C++.
The question applies to C++.
#4
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 11:05 AM
This is the correct forum, you do however need to show some code that illustrates your problem.
Jim
Jim
#5
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 11:10 AM
I am using windows form application, so I have not written any code yet, I have been using the properties window to format my form.
Below is what has been generated:
Below is what has been generated:
#pragma once
namespace MBallentineLab14 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ lblFirstNo;
protected:
private: System::Windows::Forms::Label^ lblSecondNo;
private: System::Windows::Forms::Label^ lblResult;
private: System::Windows::Forms::TextBox^ txtBxFirstNo;
private: System::Windows::Forms::TextBox^ txtBxSecondNo;
private: System::Windows::Forms::TextBox^ txtBoxResult;
private: System::Windows::Forms::Button^ btnAddition;
private: System::Windows::Forms::Button^ btnMinus;
private: System::Windows::Forms::Button^ btnMultiplication;
private: System::Windows::Forms::Button^ button4;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->lblFirstNo = (gcnew System::Windows::Forms::Label());
this->lblSecondNo = (gcnew System::Windows::Forms::Label());
this->lblResult = (gcnew System::Windows::Forms::Label());
this->txtBxFirstNo = (gcnew System::Windows::Forms::TextBox());
this->txtBxSecondNo = (gcnew System::Windows::Forms::TextBox());
this->txtBoxResult = (gcnew System::Windows::Forms::TextBox());
this->btnAddition = (gcnew System::Windows::Forms::Button());
this->btnMinus = (gcnew System::Windows::Forms::Button());
this->btnMultiplication = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// lblFirstNo
//
this->lblFirstNo->AutoSize = true;
this->lblFirstNo->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblFirstNo->Location = System::Drawing::Point(23, 61);
this->lblFirstNo->Name = L"lblFirstNo";
this->lblFirstNo->Size = System::Drawing::Size(70, 16);
this->lblFirstNo->TabIndex = 0;
this->lblFirstNo->Text = L"First No.:";
//
// lblSecondNo
//
this->lblSecondNo->AutoSize = true;
this->lblSecondNo->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblSecondNo->Location = System::Drawing::Point(23, 89);
this->lblSecondNo->Name = L"lblSecondNo";
this->lblSecondNo->Size = System::Drawing::Size(93, 16);
this->lblSecondNo->TabIndex = 1;
this->lblSecondNo->Text = L"Second No.:";
//
// lblResult
//
this->lblResult->AutoSize = true;
this->lblResult->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblResult->Location = System::Drawing::Point(23, 122);
this->lblResult->Name = L"lblResult";
this->lblResult->Size = System::Drawing::Size(52, 16);
this->lblResult->TabIndex = 2;
this->lblResult->Text = L"Result";
//
// txtBxFirstNo
//
this->txtBxFirstNo->Location = System::Drawing::Point(129, 57);
this->txtBxFirstNo->Name = L"txtBxFirstNo";
this->txtBxFirstNo->Size = System::Drawing::Size(100, 20);
this->txtBxFirstNo->TabIndex = 3;
//
// txtBxSecondNo
//
this->txtBxSecondNo->Location = System::Drawing::Point(129, 85);
this->txtBxSecondNo->Name = L"txtBxSecondNo";
this->txtBxSecondNo->Size = System::Drawing::Size(100, 20);
this->txtBxSecondNo->TabIndex = 4;
//
// txtBoxResult
//
this->txtBoxResult->Location = System::Drawing::Point(129, 118);
this->txtBoxResult->Name = L"txtBoxResult";
this->txtBoxResult->Size = System::Drawing::Size(106, 20);
this->txtBoxResult->TabIndex = 5;
//
// btnAddition
//
this->btnAddition->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnAddition->ForeColor = System::Drawing::Color::Black;
this->btnAddition->Location = System::Drawing::Point(93, 165);
this->btnAddition->Name = L"btnAddition";
this->btnAddition->Size = System::Drawing::Size(35, 32);
this->btnAddition->TabIndex = 6;
this->btnAddition->Text = L"+";
this->btnAddition->UseVisualStyleBackColor = true;
//
// btnMinus
//
this->btnMinus->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnMinus->ForeColor = System::Drawing::Color::Black;
this->btnMinus->Location = System::Drawing::Point(154, 165);
this->btnMinus->Name = L"btnMinus";
this->btnMinus->Size = System::Drawing::Size(35, 32);
this->btnMinus->TabIndex = 7;
this->btnMinus->Text = L"-";
this->btnMinus->UseVisualStyleBackColor = true;
//
// btnMultiplication
//
this->btnMultiplication->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnMultiplication->ForeColor = System::Drawing::Color::Black;
this->btnMultiplication->Location = System::Drawing::Point(93, 205);
this->btnMultiplication->Name = L"btnMultiplication";
this->btnMultiplication->Size = System::Drawing::Size(35, 32);
this->btnMultiplication->TabIndex = 8;
this->btnMultiplication->Text = L"x";
this->btnMultiplication->UseVisualStyleBackColor = true;
//
// button4
//
this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button4->ForeColor = System::Drawing::Color::Red;
this->button4->Location = System::Drawing::Point(154, 205);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(35, 32);
this->button4->TabIndex = 9;
this->button4->Text = L"/";
this->button4->UseVisualStyleBackColor = true;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::LightGray;
this->ClientSize = System::Drawing::Size(284, 262);
this->Controls->Add(this->button4);
this->Controls->Add(this->btnMultiplication);
this->Controls->Add(this->btnMinus);
this->Controls->Add(this->btnAddition);
this->Controls->Add(this->txtBoxResult);
this->Controls->Add(this->txtBxSecondNo);
this->Controls->Add(this->txtBxFirstNo);
this->Controls->Add(this->lblResult);
this->Controls->Add(this->lblSecondNo);
this->Controls->Add(this->lblFirstNo);
this->ForeColor = System::Drawing::Color::SteelBlue;
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->Name = L"Form1";
this->Text = L"Michelle Ballentine";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
};
}
#6
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 11:21 AM
I see where the text is, but how can I change the size and color of the font, and the color of the bar itself.
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D; this->Name = L"Form1"; this->Text = L"Michelle Ballentine"; /* this is the text to be changed*/ this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); this->PerformLayout();
#7
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 11:24 AM
Okay Windows forms is not a C/C++ question. I will move this to the C++/CLI forum. However if you are just learning the language, I would suggest C# if you want to use the .Net environment. If you don't need the .Net environment then find a C++ solution. From what I have seen C++/CLI is not a very popular language, and mixing standard C++ with managed C++ (C++/CLI) is a real pain.
Jim
Jim
#8
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 11:44 AM
Thank You
#9
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 12:34 PM
I am not exactly sure if you can control the color of text for the title bar except for going into non client area painting. To give you a taste of what that is like and how you might go about finding more info about it, check out the article below. This talks about custom border painting, but you will get the idea of what you will need to be looking at to get into painting the titlebar. From there you can control the titlebar text color etc.
Not exactly an easy thing to do if you are still new to the language. Hopefully you aren't.
Not exactly an easy thing to do if you are still new to the language. Hopefully you aren't.
#10
Re: Change the color of the text associated with the control
Posted 21 April 2012 - 06:43 PM
Thank You Very Much for the Info
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote





|