Home  >  Article  >  Computer Tutorials  >  How to add icons to custom component controls in C language

How to add icons to custom component controls in C language

WBOY
WBOYforward
2024-01-16 15:30:06999browse

How to add icons to custom component controls in C language

How to add icons to C custom component controls

Just add the ToolboxBitmapAttribute to the class of your control or component

As shown below (I only tested it on the windows form control, I think it should be possible for web form)

using System;

using System.Windows.Forms;

using System.Drawing;

namespace Zxd

{

[ToolboxBitmap("open.bmp")]//Note: The parameter is your bitmap path. In my experiment, it is in the same directory as the generated Test.Dll file

public class Test:System.Windows.Forms.UserControl//Control

{

Omit

}

}

How to display pictures based on controls on a web page C

checkChaged event

protected void RadioButton1_CheckedChanged(object sender, EventArgs e)

{

this.Image1.ImageUrl = "iamges/1.jpg";

}

public void checkRadioButtonChecked()

//Put it in if(!ispostback) of pageLoad

{

if (RadioButton1.Checked)

{

this.Image1.ImageUrl = "iamges/1.jpg";

}

else

{

this.Image1.ImageUrl = "iamges/2.jpg";

}

}

How to display images on button controls in vc

1. There may be help in the team here

2. Edit the corresponding resource file (bmp format), then:

//Set background image

CDC MemDC;

CBitmap m_Bitmap1;

m_Bitmap1.LoadBitmap(IDB_BKGROUND);

MemDC.CreateCompatibleDC(NULL);

MemDC.SelectObject(&m_Bitmap1);

pDC->StretchBlt(rect.left,rect.top,rect.Width(),rect.Height(),&MemDC,0,0,48,48,SRCCOPY);

m_Bitmap1.DeleteObject();

MemDC.DeleteDC();

The above is the detailed content of How to add icons to custom component controls in C language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:docexcel.net. If there is any infringement, please contact admin@php.cn delete