试过很多函数不好使啊,比如Setbitmap之类的,哪位指点一下?
4 个解决方案
#1
参考这个
http://www.vckbase.com/document/viewdoc/?id=517
http://www.vckbase.com/document/viewdoc/?id=517
#2
使用CToolBarCtrl,CImageList,TBBUTTON 可实现。代码如下:CDialog::OnInitDialog();
;
m_imagelist.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);
m_toolbar.Create(TBSTYLE_FLAT|CCS_TOP|WS_CHILD|WS_VISIBLE|WS_BORDER|CCS_ADJUSTABLE|TBSTYLE_WRAPABLE,CRect(0,0,0,0),this,IDR_TOOLBAR1);
m_toolbar.SetBitmapSize(CSize(32,32));
UINT Resource[m_buttoncount]={IDI_ICON1,IDI_ICON2,IDI_ICON3,IDI_ICON4,IDI_ICON5,IDI_ICON6,IDI_ICON7,IDI_ICON8,IDI_ICON9,IDI_ICON10,IDI_ICON11,IDI_ICON12,IDI_ICON13};
int i;
for( i=0;i<13;i++)
{
m_imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(Resource[i])));
}
TBBUTTON m_button[m_buttoncount];
m_toolbar.SetImageList(&m_imagelist);
for( i=0;i<m_buttoncount;i++)
{
m_button[i].iBitmap=i;
}
}
}
中间有删节,可做参考.
;
m_imagelist.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);
m_toolbar.Create(TBSTYLE_FLAT|CCS_TOP|WS_CHILD|WS_VISIBLE|WS_BORDER|CCS_ADJUSTABLE|TBSTYLE_WRAPABLE,CRect(0,0,0,0),this,IDR_TOOLBAR1);
m_toolbar.SetBitmapSize(CSize(32,32));
UINT Resource[m_buttoncount]={IDI_ICON1,IDI_ICON2,IDI_ICON3,IDI_ICON4,IDI_ICON5,IDI_ICON6,IDI_ICON7,IDI_ICON8,IDI_ICON9,IDI_ICON10,IDI_ICON11,IDI_ICON12,IDI_ICON13};
int i;
for( i=0;i<13;i++)
{
m_imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(Resource[i])));
}
TBBUTTON m_button[m_buttoncount];
m_toolbar.SetImageList(&m_imagelist);
for( i=0;i<m_buttoncount;i++)
{
m_button[i].iBitmap=i;
}
}
}
中间有删节,可做参考.
#3
用CBitmapButton不就行了??
使用方法如下
CBitmapButton
Use the CBitmapButton class to create pushbutton controls labeled with bitmapped images instead of text. CBitmapButton objects contain up to four bitmaps, which contain images for the different states a button can assume: up (or normal), down (or selected), focused, and disabled. Only the first bitmap is required; the others are optional.
类CBitmapButton用于创建用位图而不是文本做标签的按钮控件。CBitmapButton对象最多可包括4个位图,分别代表按钮所处的不同状态:未按下(或正常)、按下(或选中)、获得焦点和被禁止存取。只有第一个位图是必须的,其它三个可以不提供。
Bitmap-button images include the border around the image as well as the image itself. The border typically plays a part in showing the state of the button. For example, the bitmap for the focused state usually is like the one for the up state but with a dashed rectangle inset from the border or a thick solid line at the border. The bitmap for the disabled state usually resembles the one for the up state but has lower contrast (like a dimmed or grayed menu selection).
位图按钮图像包括图像本身以及图像的边框。边框在表示按钮的不同状态时很有用。例如,按钮获得焦点时的位图与未按下(或正常)状态的位图相同,但是在边框中要么嵌入了由间断线组成的矩形,要么嵌入了由粗实线组成的矩形。禁止存取状态的按钮的位图通常和正常状态的一样,但是颜色的对比度较小,就象变灰的菜单选项一样。
These bitmaps can be of any size, but all are treated as if they were the same size as the bitmap for the up state.
这些位图的尺寸可以不同,但都当成和正常状态下位图一样的大小处理。
Various applications demand different combinations of bitmap images:
不同的应用对位图有不同的组合应用。如下所示:
Up Down Focused Disabled Application
× Bitmap
类Bitmap
× × Button without WS_TABSTOP style
没有设置WS_TABSTOP的按钮
× × × × Dialog button with all states
带有所有状态的对话框按钮
× × × Dialog button with WS_TABSTOP style
设置WS_TABSTOP的按钮
When creating a bitmap-button control, set the BS_OWNERDRAW style to specify that the button is owner-drawn. This causes Windows to send the WM_MEASUREITEM and WM_DRAWITEM messages for the button; the framework handles these messages and manages the appearance of the button for you.
在创建一个位图按钮控件时,设置BS_OWNERDRAW则指明按钮是自定义的(用户自己绘制的)。这样,Windows就会为该按钮发送WM_MEASUREITEM和WM_DRAWITEM消息,由框架处理这些消息并维护按钮的外观。
To create a bitmap-button control in a window’s client area, follow these steps:
在窗口的客户区创建一个位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Construct the CBitmapButton object.
构造CBitmapButton对象。
Call the Create function to create the Windows button control and attach it to the CBitmapButton object.
调用Create函数创建Windows按钮控件,并把它加到CBitmapButton对象上。
Call the LoadBitmaps member function to load the bitmap resources after the bitmap button is constructed.
调用成员函数LoadBitmaps加载位图资源
To include a bitmap-button control in a dialog box, follow these steps:
在对话框控件中包含位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
创建一个对话框模板,其中有一个自定义的按钮放在需要位图按钮的位置。模板中按钮的大小无关紧要。
Set the button’s caption to a value such as “MYIMAGE” and define a symbol for the button such as IDC_MYIMAGE.
把按钮的标题设置为“MYIMAGE”一类的字符串,并为按钮定义一个类似于IDC_MYIMAGE的代号
In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “MYIMAGE,” for example, the IDs would be “MYIMAGEU,” “MYIMAGED,” “MYIMAGEF,” and “MYIMAGEX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
在应用的资源脚本中,分别为每个给该按钮创建的图像一个ID,ID的值为在步骤3中的标题后加上如下的一个字母——U、D、F或X,分别代表正常、按下、获得焦点和禁止存取状态下的按钮。例如,标题设为“MYIMAGE”时,ID就应该是“MYIMAGEU”、“MYIMAGED”、 “MYIMAGEF”和“MYIMAGEX”。位图的ID必须用引号括起来,否则资源编辑器就会为资源赋上一个整数值,MFC在加载图像时就会失败。
In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
在应用的对话框类(从类CDialog继承而来)中加上一个CBitmapButton成员对象。
In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
在CDialog对象的OnInitDialog例程中调用CBitmapButton对象的AutoLoad函数,参数是按钮的ID和CDialog对象的this指针。
If you want to handle Windows notification messages, such as BN_CLICKED, sent by a bitmap-button control to its parent (usually a class derived from CDialog), add to the CDialog-derived object a message-map entry and message-handler member function for each message. The notifications sent by a CBitmapButton object are the same as those sent by a CButton object.
如果想处理Windows的通知消息,如位图按钮控件发给它的父对象(通常是从CDialog继承来的)的BN_CLICKED消息,就要在从CDialog继承来的对象中加入消息映射入口以及处理每个消息的成员函数。CBitmapButton对象发出的通知和CButton对象发出的通知一样。
使用方法如下
CBitmapButton
Use the CBitmapButton class to create pushbutton controls labeled with bitmapped images instead of text. CBitmapButton objects contain up to four bitmaps, which contain images for the different states a button can assume: up (or normal), down (or selected), focused, and disabled. Only the first bitmap is required; the others are optional.
类CBitmapButton用于创建用位图而不是文本做标签的按钮控件。CBitmapButton对象最多可包括4个位图,分别代表按钮所处的不同状态:未按下(或正常)、按下(或选中)、获得焦点和被禁止存取。只有第一个位图是必须的,其它三个可以不提供。
Bitmap-button images include the border around the image as well as the image itself. The border typically plays a part in showing the state of the button. For example, the bitmap for the focused state usually is like the one for the up state but with a dashed rectangle inset from the border or a thick solid line at the border. The bitmap for the disabled state usually resembles the one for the up state but has lower contrast (like a dimmed or grayed menu selection).
位图按钮图像包括图像本身以及图像的边框。边框在表示按钮的不同状态时很有用。例如,按钮获得焦点时的位图与未按下(或正常)状态的位图相同,但是在边框中要么嵌入了由间断线组成的矩形,要么嵌入了由粗实线组成的矩形。禁止存取状态的按钮的位图通常和正常状态的一样,但是颜色的对比度较小,就象变灰的菜单选项一样。
These bitmaps can be of any size, but all are treated as if they were the same size as the bitmap for the up state.
这些位图的尺寸可以不同,但都当成和正常状态下位图一样的大小处理。
Various applications demand different combinations of bitmap images:
不同的应用对位图有不同的组合应用。如下所示:
Up Down Focused Disabled Application
× Bitmap
类Bitmap
× × Button without WS_TABSTOP style
没有设置WS_TABSTOP的按钮
× × × × Dialog button with all states
带有所有状态的对话框按钮
× × × Dialog button with WS_TABSTOP style
设置WS_TABSTOP的按钮
When creating a bitmap-button control, set the BS_OWNERDRAW style to specify that the button is owner-drawn. This causes Windows to send the WM_MEASUREITEM and WM_DRAWITEM messages for the button; the framework handles these messages and manages the appearance of the button for you.
在创建一个位图按钮控件时,设置BS_OWNERDRAW则指明按钮是自定义的(用户自己绘制的)。这样,Windows就会为该按钮发送WM_MEASUREITEM和WM_DRAWITEM消息,由框架处理这些消息并维护按钮的外观。
To create a bitmap-button control in a window’s client area, follow these steps:
在窗口的客户区创建一个位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Construct the CBitmapButton object.
构造CBitmapButton对象。
Call the Create function to create the Windows button control and attach it to the CBitmapButton object.
调用Create函数创建Windows按钮控件,并把它加到CBitmapButton对象上。
Call the LoadBitmaps member function to load the bitmap resources after the bitmap button is constructed.
调用成员函数LoadBitmaps加载位图资源
To include a bitmap-button control in a dialog box, follow these steps:
在对话框控件中包含位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
创建一个对话框模板,其中有一个自定义的按钮放在需要位图按钮的位置。模板中按钮的大小无关紧要。
Set the button’s caption to a value such as “MYIMAGE” and define a symbol for the button such as IDC_MYIMAGE.
把按钮的标题设置为“MYIMAGE”一类的字符串,并为按钮定义一个类似于IDC_MYIMAGE的代号
In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “MYIMAGE,” for example, the IDs would be “MYIMAGEU,” “MYIMAGED,” “MYIMAGEF,” and “MYIMAGEX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
在应用的资源脚本中,分别为每个给该按钮创建的图像一个ID,ID的值为在步骤3中的标题后加上如下的一个字母——U、D、F或X,分别代表正常、按下、获得焦点和禁止存取状态下的按钮。例如,标题设为“MYIMAGE”时,ID就应该是“MYIMAGEU”、“MYIMAGED”、 “MYIMAGEF”和“MYIMAGEX”。位图的ID必须用引号括起来,否则资源编辑器就会为资源赋上一个整数值,MFC在加载图像时就会失败。
In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
在应用的对话框类(从类CDialog继承而来)中加上一个CBitmapButton成员对象。
In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
在CDialog对象的OnInitDialog例程中调用CBitmapButton对象的AutoLoad函数,参数是按钮的ID和CDialog对象的this指针。
If you want to handle Windows notification messages, such as BN_CLICKED, sent by a bitmap-button control to its parent (usually a class derived from CDialog), add to the CDialog-derived object a message-map entry and message-handler member function for each message. The notifications sent by a CBitmapButton object are the same as those sent by a CButton object.
如果想处理Windows的通知消息,如位图按钮控件发给它的父对象(通常是从CDialog继承来的)的BN_CLICKED消息,就要在从CDialog继承来的对象中加入消息映射入口以及处理每个消息的成员函数。CBitmapButton对象发出的通知和CButton对象发出的通知一样。
#4
好像不符合我的要求啊,另外超过256色的是不是不能导入到VC工程中?
导入后不能用啊.
导入后不能用啊.
#1
参考这个
http://www.vckbase.com/document/viewdoc/?id=517
http://www.vckbase.com/document/viewdoc/?id=517
#2
使用CToolBarCtrl,CImageList,TBBUTTON 可实现。代码如下:CDialog::OnInitDialog();
;
m_imagelist.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);
m_toolbar.Create(TBSTYLE_FLAT|CCS_TOP|WS_CHILD|WS_VISIBLE|WS_BORDER|CCS_ADJUSTABLE|TBSTYLE_WRAPABLE,CRect(0,0,0,0),this,IDR_TOOLBAR1);
m_toolbar.SetBitmapSize(CSize(32,32));
UINT Resource[m_buttoncount]={IDI_ICON1,IDI_ICON2,IDI_ICON3,IDI_ICON4,IDI_ICON5,IDI_ICON6,IDI_ICON7,IDI_ICON8,IDI_ICON9,IDI_ICON10,IDI_ICON11,IDI_ICON12,IDI_ICON13};
int i;
for( i=0;i<13;i++)
{
m_imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(Resource[i])));
}
TBBUTTON m_button[m_buttoncount];
m_toolbar.SetImageList(&m_imagelist);
for( i=0;i<m_buttoncount;i++)
{
m_button[i].iBitmap=i;
}
}
}
中间有删节,可做参考.
;
m_imagelist.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);
m_toolbar.Create(TBSTYLE_FLAT|CCS_TOP|WS_CHILD|WS_VISIBLE|WS_BORDER|CCS_ADJUSTABLE|TBSTYLE_WRAPABLE,CRect(0,0,0,0),this,IDR_TOOLBAR1);
m_toolbar.SetBitmapSize(CSize(32,32));
UINT Resource[m_buttoncount]={IDI_ICON1,IDI_ICON2,IDI_ICON3,IDI_ICON4,IDI_ICON5,IDI_ICON6,IDI_ICON7,IDI_ICON8,IDI_ICON9,IDI_ICON10,IDI_ICON11,IDI_ICON12,IDI_ICON13};
int i;
for( i=0;i<13;i++)
{
m_imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(Resource[i])));
}
TBBUTTON m_button[m_buttoncount];
m_toolbar.SetImageList(&m_imagelist);
for( i=0;i<m_buttoncount;i++)
{
m_button[i].iBitmap=i;
}
}
}
中间有删节,可做参考.
#3
用CBitmapButton不就行了??
使用方法如下
CBitmapButton
Use the CBitmapButton class to create pushbutton controls labeled with bitmapped images instead of text. CBitmapButton objects contain up to four bitmaps, which contain images for the different states a button can assume: up (or normal), down (or selected), focused, and disabled. Only the first bitmap is required; the others are optional.
类CBitmapButton用于创建用位图而不是文本做标签的按钮控件。CBitmapButton对象最多可包括4个位图,分别代表按钮所处的不同状态:未按下(或正常)、按下(或选中)、获得焦点和被禁止存取。只有第一个位图是必须的,其它三个可以不提供。
Bitmap-button images include the border around the image as well as the image itself. The border typically plays a part in showing the state of the button. For example, the bitmap for the focused state usually is like the one for the up state but with a dashed rectangle inset from the border or a thick solid line at the border. The bitmap for the disabled state usually resembles the one for the up state but has lower contrast (like a dimmed or grayed menu selection).
位图按钮图像包括图像本身以及图像的边框。边框在表示按钮的不同状态时很有用。例如,按钮获得焦点时的位图与未按下(或正常)状态的位图相同,但是在边框中要么嵌入了由间断线组成的矩形,要么嵌入了由粗实线组成的矩形。禁止存取状态的按钮的位图通常和正常状态的一样,但是颜色的对比度较小,就象变灰的菜单选项一样。
These bitmaps can be of any size, but all are treated as if they were the same size as the bitmap for the up state.
这些位图的尺寸可以不同,但都当成和正常状态下位图一样的大小处理。
Various applications demand different combinations of bitmap images:
不同的应用对位图有不同的组合应用。如下所示:
Up Down Focused Disabled Application
× Bitmap
类Bitmap
× × Button without WS_TABSTOP style
没有设置WS_TABSTOP的按钮
× × × × Dialog button with all states
带有所有状态的对话框按钮
× × × Dialog button with WS_TABSTOP style
设置WS_TABSTOP的按钮
When creating a bitmap-button control, set the BS_OWNERDRAW style to specify that the button is owner-drawn. This causes Windows to send the WM_MEASUREITEM and WM_DRAWITEM messages for the button; the framework handles these messages and manages the appearance of the button for you.
在创建一个位图按钮控件时,设置BS_OWNERDRAW则指明按钮是自定义的(用户自己绘制的)。这样,Windows就会为该按钮发送WM_MEASUREITEM和WM_DRAWITEM消息,由框架处理这些消息并维护按钮的外观。
To create a bitmap-button control in a window’s client area, follow these steps:
在窗口的客户区创建一个位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Construct the CBitmapButton object.
构造CBitmapButton对象。
Call the Create function to create the Windows button control and attach it to the CBitmapButton object.
调用Create函数创建Windows按钮控件,并把它加到CBitmapButton对象上。
Call the LoadBitmaps member function to load the bitmap resources after the bitmap button is constructed.
调用成员函数LoadBitmaps加载位图资源
To include a bitmap-button control in a dialog box, follow these steps:
在对话框控件中包含位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
创建一个对话框模板,其中有一个自定义的按钮放在需要位图按钮的位置。模板中按钮的大小无关紧要。
Set the button’s caption to a value such as “MYIMAGE” and define a symbol for the button such as IDC_MYIMAGE.
把按钮的标题设置为“MYIMAGE”一类的字符串,并为按钮定义一个类似于IDC_MYIMAGE的代号
In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “MYIMAGE,” for example, the IDs would be “MYIMAGEU,” “MYIMAGED,” “MYIMAGEF,” and “MYIMAGEX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
在应用的资源脚本中,分别为每个给该按钮创建的图像一个ID,ID的值为在步骤3中的标题后加上如下的一个字母——U、D、F或X,分别代表正常、按下、获得焦点和禁止存取状态下的按钮。例如,标题设为“MYIMAGE”时,ID就应该是“MYIMAGEU”、“MYIMAGED”、 “MYIMAGEF”和“MYIMAGEX”。位图的ID必须用引号括起来,否则资源编辑器就会为资源赋上一个整数值,MFC在加载图像时就会失败。
In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
在应用的对话框类(从类CDialog继承而来)中加上一个CBitmapButton成员对象。
In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
在CDialog对象的OnInitDialog例程中调用CBitmapButton对象的AutoLoad函数,参数是按钮的ID和CDialog对象的this指针。
If you want to handle Windows notification messages, such as BN_CLICKED, sent by a bitmap-button control to its parent (usually a class derived from CDialog), add to the CDialog-derived object a message-map entry and message-handler member function for each message. The notifications sent by a CBitmapButton object are the same as those sent by a CButton object.
如果想处理Windows的通知消息,如位图按钮控件发给它的父对象(通常是从CDialog继承来的)的BN_CLICKED消息,就要在从CDialog继承来的对象中加入消息映射入口以及处理每个消息的成员函数。CBitmapButton对象发出的通知和CButton对象发出的通知一样。
使用方法如下
CBitmapButton
Use the CBitmapButton class to create pushbutton controls labeled with bitmapped images instead of text. CBitmapButton objects contain up to four bitmaps, which contain images for the different states a button can assume: up (or normal), down (or selected), focused, and disabled. Only the first bitmap is required; the others are optional.
类CBitmapButton用于创建用位图而不是文本做标签的按钮控件。CBitmapButton对象最多可包括4个位图,分别代表按钮所处的不同状态:未按下(或正常)、按下(或选中)、获得焦点和被禁止存取。只有第一个位图是必须的,其它三个可以不提供。
Bitmap-button images include the border around the image as well as the image itself. The border typically plays a part in showing the state of the button. For example, the bitmap for the focused state usually is like the one for the up state but with a dashed rectangle inset from the border or a thick solid line at the border. The bitmap for the disabled state usually resembles the one for the up state but has lower contrast (like a dimmed or grayed menu selection).
位图按钮图像包括图像本身以及图像的边框。边框在表示按钮的不同状态时很有用。例如,按钮获得焦点时的位图与未按下(或正常)状态的位图相同,但是在边框中要么嵌入了由间断线组成的矩形,要么嵌入了由粗实线组成的矩形。禁止存取状态的按钮的位图通常和正常状态的一样,但是颜色的对比度较小,就象变灰的菜单选项一样。
These bitmaps can be of any size, but all are treated as if they were the same size as the bitmap for the up state.
这些位图的尺寸可以不同,但都当成和正常状态下位图一样的大小处理。
Various applications demand different combinations of bitmap images:
不同的应用对位图有不同的组合应用。如下所示:
Up Down Focused Disabled Application
× Bitmap
类Bitmap
× × Button without WS_TABSTOP style
没有设置WS_TABSTOP的按钮
× × × × Dialog button with all states
带有所有状态的对话框按钮
× × × Dialog button with WS_TABSTOP style
设置WS_TABSTOP的按钮
When creating a bitmap-button control, set the BS_OWNERDRAW style to specify that the button is owner-drawn. This causes Windows to send the WM_MEASUREITEM and WM_DRAWITEM messages for the button; the framework handles these messages and manages the appearance of the button for you.
在创建一个位图按钮控件时,设置BS_OWNERDRAW则指明按钮是自定义的(用户自己绘制的)。这样,Windows就会为该按钮发送WM_MEASUREITEM和WM_DRAWITEM消息,由框架处理这些消息并维护按钮的外观。
To create a bitmap-button control in a window’s client area, follow these steps:
在窗口的客户区创建一个位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Construct the CBitmapButton object.
构造CBitmapButton对象。
Call the Create function to create the Windows button control and attach it to the CBitmapButton object.
调用Create函数创建Windows按钮控件,并把它加到CBitmapButton对象上。
Call the LoadBitmaps member function to load the bitmap resources after the bitmap button is constructed.
调用成员函数LoadBitmaps加载位图资源
To include a bitmap-button control in a dialog box, follow these steps:
在对话框控件中包含位图按钮的步骤如下:
Create one to four bitmap images for the button.
为按钮创建1到4个位图。
Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
创建一个对话框模板,其中有一个自定义的按钮放在需要位图按钮的位置。模板中按钮的大小无关紧要。
Set the button’s caption to a value such as “MYIMAGE” and define a symbol for the button such as IDC_MYIMAGE.
把按钮的标题设置为“MYIMAGE”一类的字符串,并为按钮定义一个类似于IDC_MYIMAGE的代号
In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “MYIMAGE,” for example, the IDs would be “MYIMAGEU,” “MYIMAGED,” “MYIMAGEF,” and “MYIMAGEX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
在应用的资源脚本中,分别为每个给该按钮创建的图像一个ID,ID的值为在步骤3中的标题后加上如下的一个字母——U、D、F或X,分别代表正常、按下、获得焦点和禁止存取状态下的按钮。例如,标题设为“MYIMAGE”时,ID就应该是“MYIMAGEU”、“MYIMAGED”、 “MYIMAGEF”和“MYIMAGEX”。位图的ID必须用引号括起来,否则资源编辑器就会为资源赋上一个整数值,MFC在加载图像时就会失败。
In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
在应用的对话框类(从类CDialog继承而来)中加上一个CBitmapButton成员对象。
In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
在CDialog对象的OnInitDialog例程中调用CBitmapButton对象的AutoLoad函数,参数是按钮的ID和CDialog对象的this指针。
If you want to handle Windows notification messages, such as BN_CLICKED, sent by a bitmap-button control to its parent (usually a class derived from CDialog), add to the CDialog-derived object a message-map entry and message-handler member function for each message. The notifications sent by a CBitmapButton object are the same as those sent by a CButton object.
如果想处理Windows的通知消息,如位图按钮控件发给它的父对象(通常是从CDialog继承来的)的BN_CLICKED消息,就要在从CDialog继承来的对象中加入消息映射入口以及处理每个消息的成员函数。CBitmapButton对象发出的通知和CButton对象发出的通知一样。
#4
好像不符合我的要求啊,另外超过256色的是不是不能导入到VC工程中?
导入后不能用啊.
导入后不能用啊.