Virual Studio 2022 C++ CLR 中 模拟 Android Studo,Eclipse 的 LogCat

1.  其中的 _string 你用 String^ 或者 std::string 即可。

2.  显示格式你自己定义。

3.   看不明白参考前面用C#写的。

 

 

 

 

 关键代码:log_.h

/*****************************************************************************

创建时间       :2022年10月01日

文件名         :log_.h

功能           :模拟 Android Studo,Eclipse 的 LogCat

作者           :李锋

微信号         :lifengwx2005

Email          :ruizhilf@139.com

联系电话       :1382877886(移动),18924615309(电信)

----------------------最后一次修改时间:2022年10月08日
*******************************************************************************/

#ifndef _LOG__H_
#define _LOG__H_
 
#include "X:\Work\Share\CCode\CPlatform\list_.h"



_LF_BEGIN_

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


ref class log_
{
public:
	static RichTextBox^ rtb = null;


	static String^ sMessage = L"";
	static String^ sTag = L"";
	
	delegate void InvokeCallback();

public:

	void setText();
	log_();
	~log_();

	void Invoke();

	static void d(const _string& sMessage, const _string& sTag);

	//static string_ findTag(const char_* pwszFindMessage, const char_* pwszFindTag);
	//static string_ findTag(const String^ csharpFindMessage, const String^ csharpFindTag);
	static String^ findTag(String^ sFindMessage, String^ sFindTag);
};



_LF_END_

 

#endif //------------------------------------------#ifndef _LOGCAT__H_

  

关键代码:log_.cpp


#include "log_.h"
#include "..\..\CPlatform\global_c_.h"

_LF_BEGIN_

void log_::setText()
{

	/*
	/this.Invoke(new MethodInvoker(delegate

	 m_RichEdit.Invoke(new MethodInvoker(
	delegate
	{
		 m_RichEdit.Text = lf.lg.Logcat.FindTag(cb_内容过虑.Text, cb_标题过虑.Text);
	}
	));
	*/

    _string s = findTag(sMessage, sTag);     

	rtb->Text = gcnew String(s.c_str());
}


log_::log_()
{

}



log_::~log_()
{

}


void log_::Invoke()
{

	InvokeCallback^ ic = gcnew InvokeCallback(this, &log_::setText);

	if (rtb != null)
		rtb->Invoke(ic);
}



void log_::d(const _string& sMessage, const _string& sTag)
{

	if (gc.slLog.count() > 100000)  //10万
	{
		throw L"错误:日志文件太大了!";
	}

    _string sInfo(L"", 300);

	if (sMessage.length() > 0)
	{   
		sInfo.add(_string::java_valueOf(gc.slLog.count() + 1).intStrFillUp(4));
		sInfo.add(L"  ");
		sInfo.add(DateTime::Now.ToString());
		sInfo.add(L"\t\tsTag = ("); 
		sInfo.add(sTag);   
		sInfo.add(L")\t\tsMessage = (");
		sInfo.add(sMessage);
		sInfo.add(L")");
	}
	else
	{
		sInfo.add(_string::java_valueOf(gc.slLog.count() + 1).intStrFillUp(4));
		sInfo.add(L"  ");
		sInfo.add(DateTime::Now.ToString());
		sInfo.add(L"\t\tsTag = (");
	    sInfo.add(sTag);  
		sInfo.add(L")\t\tsMessage = (");
		sInfo.add(sMessage);
		sInfo.add(L")"); 
	}

	gc.slLog.add(sInfo);     


	(gcnew log_())->Invoke();
}

 
String^ log_::findTag(String^ sFindMessage, String^ sFindTag)
{	 

    /* C#--------------------------------------------------------------代码
            string sResult = "";

            DListNote_<string> pNote = _LogcatList.Last;

            while (pNote != null)
            {
                StringList_ sTemp = pNote.Data._Split("\t\t", true);

                if(sFindMessage.Trim().Length > 0)
                {
                    if(sTemp.Count == 3)
                    {
                        if(sTemp[2].ToLower().IndexOf(sFindMessage.ToLower().Trim()) != -1)
                        {
                            if(sFindTag.Trim().Length > 0)
                            {
                                if (sTemp[1].ToLower().IndexOf(sFindTag.ToLower().Trim()) != -1)
                                {
                                    sResult += pNote.Data;
                                    sResult += "\n";
                                }
                            }
                            else
                            {
                                sResult += pNote.Data;
                                sResult += "\n";
                            }

                        }
                    }
                    else
                    {

                    }
                }
                else
                {
                    if (sFindTag.Trim().Length > 0)
                    {
                        if (sTemp[1].ToLower().IndexOf(sFindTag.ToLower().Trim()) != -1)
                        {
                            sResult += pNote.Data;
                            sResult += "\n";
                        }
                    }
                    else
                    {
                        sResult += pNote.Data;
                        sResult += "\n";
                    }
                }
                pNote = pNote.Prev;
            }
            return sResult;

    */


    _string sResult(L"", 5000);

    dnote_<_string>* pNote = gc.slLog.Last();

    _string sFmTrl = sFindMessage->Trim()->ToLower();//sFindMessage.csharp_Trim().csharp_ToLower();
    _string sFtTrl = sFindTag->Trim()->ToLower();//sFindTag.csharp_Trim().csharp_ToLower();

    while (pNote != null)
    {
        stringList_ sl(pNote->Data.c_str(), L"\t\t", true);           

        if (sFmTrl.csharp_Length() > 0)
        {           
            if (sl.csharp_Count() == 3)
            {       
                if (sl[2].csharp_ToLower().csharp_IndexOf(sFmTrl) != -1)
                {                          
                    if (sFtTrl.csharp_Length() > 0)
                    {
                        if (sl[1].csharp_ToLower().csharp_IndexOf(sFtTrl) != -1)
                        {
                            sResult += pNote->Data;
                            sResult += L"\n";
                        }
                    }else{
                        sResult += pNote->Data;
                        sResult += L"\n";
                    }
                }
            }else{

            }
        }else
        {
            if (sFtTrl.csharp_Length() > 0)
            {
                if (sl[1].csharp_ToLower().csharp_IndexOf(sFtTrl) != -1)
                {
                    sResult += pNote->Data;
                    sResult += L"\n";
                }
            }else{
                sResult += pNote->Data;
                sResult += L"\n";
            }
        }
        pNote = pNote->Prev;
    }

    //Windows::Forms::MessageBox::Show(gcnew String(sResult.c_str()));

    return gcnew String(sResult.c_str());
}


_LF_END_

 

LogcatForm.h

窗体设计

 代码: 

#pragma once

#include "X:\Work\Share\CCode\WindowsPlatform\CLR\gw.h"
 
using namespace lf;

public delegate void MyDel();

namespace MyOffice {

	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>
	/// LogcatForm 摘要
	/// </summary>
	public ref class LogcatForm : public System::Windows::Forms::Form
	{
	public:
		LogcatForm(void)
		{
			InitializeComponent();
			//
			//TODO:  在此处添加构造函数代码
			//

			log_::rtb = m_RichEdit;
		}

	protected:
		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		~LogcatForm()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Panel^ panel1;
	protected:
	private: System::Windows::Forms::Label^ label4;
	private: System::Windows::Forms::ComboBox^ cb_内容过虑;
	private: System::Windows::Forms::ComboBox^ cb_标题过虑;
	private: System::Windows::Forms::Label^ label3;
	private: System::Windows::Forms::ComboBox^ cb_调试类型;
	private: System::Windows::Forms::Label^ label2;
	private: System::Windows::Forms::ComboBox^ cb_日志文件;
	private: System::Windows::Forms::Label^ label1;

	private: System::Windows::Forms::ContextMenuStrip^ m_contextMenuStrip;
	private: System::Windows::Forms::ToolStripMenuItem^ tsmi_清除内容;
	private: System::Windows::Forms::RichTextBox^ m_RichEdit;
	private: System::ComponentModel::IContainer^ components;

	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>


	#pragma region Windows Form Designer generated code
			/// <summary>
			/// 设计器支持所需的方法 - 不要修改
			/// 使用代码编辑器修改此方法的内容。
			/// </summary>
			void InitializeComponent(void)
			{
				this->components = (gcnew System::ComponentModel::Container());
				this->panel1 = (gcnew System::Windows::Forms::Panel());
				this->label4 = (gcnew System::Windows::Forms::Label());
				this->cb_内容过虑 = (gcnew System::Windows::Forms::ComboBox());
				this->cb_标题过虑 = (gcnew System::Windows::Forms::ComboBox());
				this->label3 = (gcnew System::Windows::Forms::Label());
				this->cb_调试类型 = (gcnew System::Windows::Forms::ComboBox());
				this->label2 = (gcnew System::Windows::Forms::Label());
				this->cb_日志文件 = (gcnew System::Windows::Forms::ComboBox());
				this->label1 = (gcnew System::Windows::Forms::Label());
				this->m_contextMenuStrip = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
				this->tsmi_清除内容 = (gcnew System::Windows::Forms::ToolStripMenuItem());
				this->m_RichEdit = (gcnew System::Windows::Forms::RichTextBox());
				this->panel1->SuspendLayout();
				this->m_contextMenuStrip->SuspendLayout();
				this->SuspendLayout();
				// 
				// panel1
				// 
				this->panel1->Controls->Add(this->label4);
				this->panel1->Controls->Add(this->cb_内容过虑);
				this->panel1->Controls->Add(this->cb_标题过虑);
				this->panel1->Controls->Add(this->label3);
				this->panel1->Controls->Add(this->cb_调试类型);
				this->panel1->Controls->Add(this->label2);
				this->panel1->Controls->Add(this->cb_日志文件);
				this->panel1->Controls->Add(this->label1);
				this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
				this->panel1->Location = System::Drawing::Point(0, 0);
				this->panel1->Name = L"panel1";
				this->panel1->Size = System::Drawing::Size(1851, 41);
				this->panel1->TabIndex = 2;
				// 
				// label4
				// 
				this->label4->AutoSize = true;
				this->label4->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->label4->Location = System::Drawing::Point(780, 9);
				this->label4->Name = L"label4";
				this->label4->Size = System::Drawing::Size(130, 24);
				this->label4->TabIndex = 13;
				this->label4->Text = L"标题过虑:";
				// 
				// cb_内容过虑
				// 
				this->cb_内容过虑->BackColor = System::Drawing::Color::White;
				this->cb_内容过虑->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->cb_内容过虑->ForeColor = System::Drawing::Color::Black;
				this->cb_内容过虑->FormattingEnabled = true;
				this->cb_内容过虑->Location = System::Drawing::Point(1418, 5);
				this->cb_内容过虑->Name = L"cb_内容过虑";
				this->cb_内容过虑->Size = System::Drawing::Size(354, 32);
				this->cb_内容过虑->TabIndex = 12;
				this->cb_内容过虑->SelectedIndexChanged += gcnew System::EventHandler(this, &LogcatForm::cb_内容过虑_SelectedIndexChanged);
				this->cb_内容过虑->TextChanged += gcnew System::EventHandler(this, &LogcatForm::cb_内容过虑_TextChanged);
				// 
				// cb_标题过虑
				// 
				this->cb_标题过虑->BackColor = System::Drawing::Color::White;
				this->cb_标题过虑->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->cb_标题过虑->ForeColor = System::Drawing::Color::Black;
				this->cb_标题过虑->FormattingEnabled = true;
				this->cb_标题过虑->Location = System::Drawing::Point(916, 5);
				this->cb_标题过虑->Name = L"cb_标题过虑";
				this->cb_标题过虑->Size = System::Drawing::Size(354, 32);
				this->cb_标题过虑->TabIndex = 11;
				this->cb_标题过虑->SelectedIndexChanged += gcnew System::EventHandler(this, &LogcatForm::cb_标题过虑_SelectedIndexChanged);
				this->cb_标题过虑->TextChanged += gcnew System::EventHandler(this, &LogcatForm::cb_内容过虑_TextChanged);
				// 
				// label3
				// 
				this->label3->AutoSize = true;
				this->label3->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->label3->Location = System::Drawing::Point(1276, 7);
				this->label3->Name = L"label3";
				this->label3->Size = System::Drawing::Size(130, 24);
				this->label3->TabIndex = 10;
				this->label3->Text = L"内容过虑:";
				// 
				// cb_调试类型
				// 
				this->cb_调试类型->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->cb_调试类型->FormattingEnabled = true;
				this->cb_调试类型->Location = System::Drawing::Point(615, 3);
				this->cb_调试类型->Name = L"cb_调试类型";
				this->cb_调试类型->Size = System::Drawing::Size(154, 32);
				this->cb_调试类型->TabIndex = 9;
				// 
				// label2
				// 
				this->label2->AutoSize = true;
				this->label2->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->label2->Location = System::Drawing::Point(497, 8);
				this->label2->Name = L"label2";
				this->label2->Size = System::Drawing::Size(130, 24);
				this->label2->TabIndex = 8;
				this->label2->Text = L"调试类型:";
				// 
				// cb_日志文件
				// 
				this->cb_日志文件->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->cb_日志文件->FormattingEnabled = true;
				this->cb_日志文件->Location = System::Drawing::Point(144, 3);
				this->cb_日志文件->Name = L"cb_日志文件";
				this->cb_日志文件->Size = System::Drawing::Size(347, 32);
				this->cb_日志文件->TabIndex = 7;
				// 
				// label1
				// 
				this->label1->AutoSize = true;
				this->label1->Font = (gcnew System::Drawing::Font(L"Consolas", 7.875F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->label1->Location = System::Drawing::Point(5, 7);
				this->label1->Name = L"label1";
				this->label1->Size = System::Drawing::Size(130, 24);
				this->label1->TabIndex = 6;
				this->label1->Text = L"日志文件:";
				// 
				// m_contextMenuStrip
				// 
				this->m_contextMenuStrip->ImageScalingSize = System::Drawing::Size(32, 32);
				this->m_contextMenuStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) { this->tsmi_清除内容 });
				this->m_contextMenuStrip->Name = L"m_contextMenuStrip";
				this->m_contextMenuStrip->Size = System::Drawing::Size(185, 42);
				// 
				// tsmi_清除内容
				// 
				this->tsmi_清除内容->Name = L"tsmi_清除内容";
				this->tsmi_清除内容->Size = System::Drawing::Size(184, 38);
				this->tsmi_清除内容->Text = L"清除内容";
				// 
				// m_RichEdit
				// 
				this->m_RichEdit->BackColor = System::Drawing::SystemColors::Desktop;
				this->m_RichEdit->ContextMenuStrip = this->m_contextMenuStrip;
				this->m_RichEdit->Dock = System::Windows::Forms::DockStyle::Fill;
				this->m_RichEdit->Font = (gcnew System::Drawing::Font(L"Consolas", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
					static_cast<System::Byte>(0)));
				this->m_RichEdit->ForeColor = System::Drawing::Color::Lime;
				this->m_RichEdit->Location = System::Drawing::Point(0, 41);
				this->m_RichEdit->Name = L"m_RichEdit";
				this->m_RichEdit->Size = System::Drawing::Size(1851, 455);
				this->m_RichEdit->TabIndex = 4;
				this->m_RichEdit->Text = L"Line Text";
				// 
				// LogcatForm
				// 
				this->AutoScaleDimensions = System::Drawing::SizeF(12, 24);
				this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
				this->ClientSize = System::Drawing::Size(1851, 496);
				this->Controls->Add(this->m_RichEdit);
				this->Controls->Add(this->panel1);
				this->Name = L"LogcatForm";
				this->Text = L"LogcatForm";
				this->Load += gcnew System::EventHandler(this, &LogcatForm::LogcatForm_Load);
				this->panel1->ResumeLayout(false);
				this->panel1->PerformLayout();
				this->m_contextMenuStrip->ResumeLayout(false);
				this->ResumeLayout(false);

			}


	#pragma endregion
		



	private: System::Void LogcatForm_Load(System::Object^ sender, System::EventArgs^ e) {
		  //System::Object ^System::Windows::Forms::Control::Invoke(System::Delegate ^method) 
		//System::Delegate::CreateDelegate(System::Type^, System::Object^, System::Reflection::MethodInfo^)
	   

		m_RichEdit->Multiline = true;
		m_RichEdit->ScrollBars = System::Windows::Forms::RichTextBoxScrollBars::Both;

	


	}
 
	

	public: RichTextBox^ getRichTextBox() { return m_RichEdit; }

		    
		 
	private: System::Void cb_内容过虑_TextChanged(System::Object^ sender, System::EventArgs^ e) {
	 

		m_RichEdit->Text = log_::findTag(cb_内容过虑->Text,cb_标题过虑->Text);

	}
	private: System::Void cb_标题过虑_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
	}
	private: System::Void cb_内容过虑_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
	}
};





}

MainForm.h

窗体设计

 MainForm_Load代码:

 gw.h

/*****************************************************************************

创建时间       :2022年10月07日

文件名         :gw.h

功能           :C++ CLR 全局类

作者           :李锋

微信号         :lifengwx2005

Email          :ruizhilf@139.com

联系电话       :1382877886(移动)

----------------------最后一次修改时间:2022年10月07日
*******************************************************************************/
#ifndef  _GW_H_
#define  _GW_H_

#include "X:\Work\Share\CCode\CPlatform\global_c_.h"
#include "keyBinaryFile_.h"
#include "IniFile_.h"
#include "log_.h"

_LF_BEGIN_


using namespace System;
using namespace System::Drawing;
using namespace System::Windows;
using namespace System::Windows::Forms;
using namespace System::IO;
 

ref class Theme_
{
public:
    Font^ TextFont;

    Color ForeColor;

    Color BackColor;

    /// <summary>
    /// /苹果绿
    /// </summary>
    static Color AppleGreen = Color::FromArgb(204, 255, 204);

    /// <summary>
    /// 杏仁黄
    /// </summary>
    static Color AlmondYellow = Color::FromArgb(250, 249, 222);

    /// <summary>
    /// 秋叶褐
    /// </summary>
    static Color AutumnLeafBrown = Color::FromArgb(255, 242, 226);

    /// <summary>
    /// 胭脂红
    /// </summary>
    static Color Carminum = Color::FromArgb(253, 230, 224);

    /// <summary>
    /// 青草绿  
    /// </summary>
    static Color GreenGrass = Color::FromArgb(227, 237, 205);


    /// <summary>
    /// 青草绿 2 
    /// </summary>
    static Color GreenGrass2 = Color::FromArgb(220, 255, 205);


    /// <summary>
    /// 海天蓝
    /// </summary>
    static Color SeaAndSkyBlue = Color::FromArgb(220, 226, 241);


    /// <summary>
    /// 葛巾紫
    /// </summary>
    static Color PuerariaPurple = Color::FromArgb(233, 235, 254);


    /// <summary>
    /// 极光灰
    /// </summary>
    static Color AuroralAsh = Color::FromArgb(234, 234, 239);

    Theme_(Color textColor, Color backColor, Font^ f)
    {
        TextFont = f;
        ForeColor = textColor;
        BackColor = backColor;
    }

    Theme_()
    {
        TextFont = gcnew Font("微软雅黑", 11);
        ForeColor = Color::FromKnownColor(KnownColor::Black);
        BackColor = Color::FromKnownColor(KnownColor::White);
    }

};


static ref class gw
{
private:
    static Theme_^  _theme;
public:

    /// <summary>
    /// 获取应用程序的全路径
    /// </summary>
    /// <returns></returns>
    static property String^ exeFullPathName{
        String^  get()
        {
            return Application::StartupPath + L"\\" + Application::ProductName + L".exe";
        }
    }

    static property String^ dataPath {

        String^ get() {

            if (gc.dataPath.length() == 0) {
                
                String^ tmpPath;
                
                tmpPath = Path::GetDirectoryName(gw::exeFullPathName) + "\\Data\\";

                if (!Directory::Exists(tmpPath))
                {
                    if (Directory::CreateDirectory(tmpPath)->Exists)
                    {
                    }
                    else
                    {
                        gc.p(L"创建数据文件夹Data失败!", L"gw::property String^ dataPath");
                    }
                }
                gc.dataPath = tmpPath;

                return tmpPath;
            }
            else {
                return gc.dataPath;
            }     
        }
    }

    /// <summary>
    /// 应用程序名
    /// </summary>
    static property String^ exeOnlyName
    {
        String^ get()
        {
            return  Path::GetFileNameWithoutExtension(exeFullPathName);
        }
    }

    static property IniFile_^ iniFile{
        IniFile_^ get(){
            if (_iniFile == null)
            {
                _iniFile = gcnew IniFile_(gw::dataPath + gw::exeOnlyName + L".ini");
            }
            return _iniFile;
        }
    }


    static property Theme_^ theme{
        Theme_^ get() {
            if (_theme == null)
            {
                _theme = gcnew Theme_();
            }
            return _theme;
        }
    }
       


public:
    gw();   
    ~gw();
    static void SetThemeALL(Theme_^ theme);
    static void SetThemeForm(Form^ f);
    static void SetControlBackColor(Control^ control, Color c);
    static void SetMenuStripBackcolor(MenuStrip^ ms, Color c);
    static void SetToolStripItemBackcolor(ToolStripItem^ tsi, Color c);

private:

    static IniFile_^ _iniFile;


}; 
 
 


_LF_END_


#endif // ! _GW_H_
 

gw.cpp

#include "gw.h"
#include "X:\Work\Share\CCode\CPlatform\global_c_.h"

_LF_BEGIN_
 
gw::gw()
{


}

gw::~gw()
{


}
 


/// <summary>
/// 设置皮肤背景
/// </summary>
/// <param name="theme"></param>
/// 创建时间: 2022-10-08      最后一次修改时间:2022-10-08
void gw::SetThemeALL(Theme_^ theme)
{   
    if (theme != null)
    {
        _theme = theme;    
    }  

    FormCollection^ fc = Application::OpenForms;

    for (int i = 0; i < fc->Count; ++i)
    {
        Form^ f = fc[i];
        SetThemeForm(f);
    }
}


/// <summary>
/// 设置单个窗体的皮肤
/// </summary>
/// <param name="f"></param>
/// 创建时间: 2022-10-08      最后一次修改时间:2022-10-08
void  gw:: SetThemeForm(Form^ f) {

    SetControlBackColor(f, theme->BackColor);

    SetMenuStripBackcolor(f->MainMenuStrip, theme->BackColor);
}


/// <summary>
/// 
/// </summary>
/// <param name="control"></param>
/// <param name="c"></param>
/// 创建时间: 2022-10-08      最后一次修改时间:2022-10-08
void gw::SetControlBackColor(Control^ control, Color c)

    control->BackColor = c;

    for (int i = 0; i < control->Controls->Count; ++i)
    {
        Control^ con = control->Controls[i];
        
        log_::d(con->Name, L"void gw::SetControlBackColor");

        SetControlBackColor(con, c);

    }
}


/// <summary>
/// 
/// </summary>
/// 创建时间: 2022-09-08      最后一次修改时间:2022-10-08
void gw::SetMenuStripBackcolor(MenuStrip^ ms, Color c){
     
    if (ms == null) return; 

    ms->BackColor = c;

    for (int i = 0; i < ms->Items->Count; ++i) {

        ToolStripItem^ tsi = (ms->Items[i]);
        SetToolStripItemBackcolor(tsi,c);
    }  
}

/// <summary>
/// 设置ToolStripItem的背景颜色
/// </summary>
/// 创建时间: 2022-10-08      最后一次修改时间:2022-10-08
void gw::SetToolStripItemBackcolor(ToolStripItem^ tsi, Color c)
{
    if (tsi == null) return;

    ToolStripMenuItem^ tsmi = (ToolStripMenuItem^)(tsi);

    tsmi->BackColor = c;
    for (int j = 0; j < tsmi->DropDownItems->Count; ++j) {

        ToolStripMenuItem^ tmp = (ToolStripMenuItem^)tsmi->DropDownItems[j];
        SetToolStripItemBackcolor(tmp, c);
    }
}


 

_LF_END_

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值