first, create a button via CreateWindow(WC_BUTTON, ...)
second, draw a image via StretchDIBits(hdc, x, ...), the image memory is gotten with a camera
then, I want to draw the button created above on the image
I try to use ShowWindow, it will send a message to windows to draw the button
so ShowWindow and StretchDIBits maybe be draw button first, then draw image, or draw image first, then draw button
it's not what I want to do. I want to draw image first, then draw button immediately. Or the button is covered by the image.
second, draw a image via StretchDIBits(hdc, x, ...), the image memory is gotten with a camera
then, I want to draw the button created above on the image
I try to use ShowWindow, it will send a message to windows to draw the button
so ShowWindow and StretchDIBits maybe be draw button first, then draw image, or draw image first, then draw button
it's not what I want to do. I want to draw image first, then draw button immediately. Or the button is covered by the image.
解决方案 »
- 某个 tcp server 在 8000 口监听,每个 client 连接上后 server 上的 socket 端口都是 8000,那么 client 过来的数据在server上是怎么区分的?
- 用matcom转换小波函数出错,高手请进!
- 【大家都来谈谈你们是怎么写VC文档的,使用那些自动提取注释的工具?】
- 谁能解释一下CRunTime,该类都用在什么地方
- 马上给分,我现在有一个纯资源的DLL,里面有一个字符串资源(IDS_NAME),我的程序想改写这个字符串的内容要怎么做?
- 来者有分?请问MRI图像.img格式的文件怎么打开?
- 各位能不能推荐几本学VC的好书?
- 请问送分是怎么送的???怎么给回答的人呢???
- (新手问题)为何我下载了VC例子在ResurceView中看不到该Dialog。
- endl 输出的间隔问题
- (MFC网络编程) TCP客户端加2个UDP端口_接收数据有问题
- list中erase报错
记录绘制的位置, 鼠标移动和点击的时候,判断是否在这个区域中, 然后模拟按钮发送 WM_COMMAND BN_CLICKED 消息
1 draw image first
2 then draw the button later.
void CMyButton::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rc;
GetClientRect(rc);
MapWindowPoints(GetParent(),rc);
dc.SetBrushOrg(-rc.left,-rc.top);
GetClientRect(rc);
dc.FillRect(&rc,m_brushPat);
//
dc.SetBkMode(TRANSPARENT);
if(m_bHover) dc.SetTextColor(RGB(255,0,0));// red
else dc.SetTextColor(RGB(0,0,0));
dc.TextOut(45,6,"透明按钮");
// Do not call CButton::OnPaint() for painting messages
}BOOL CMyButton::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
return CButton::OnEraseBkgnd(pDC);
}// Operations
public:
CBrush *m_brushPat;//
m_bitmap.LoadBitmap(IDB_CLOUDS);
m_brushPat.CreatePatternBrush(&m_bitmap);
2 下面是 渐变色 按钮
void COwnerBt::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
#define MULTI 256
CRect rect;
GetClientRect(rect);
CClientDC dc(this);
int iHeight = rect.Height();
int iWidth = rect.Width();
COLORREF crFrom=RGB(239,255,255);//0x00ffffef;
COLORREF crTo =RGB(12,169,254 );//0x00fea90c;
int iR = GetRValue( crFrom );
int iG = GetGValue( crFrom );
int iB = GetBValue( crFrom );
//
int idR = (MULTI*(GetRValue(crTo)-iR)) / iWidth;// -379
int idG = (MULTI*(GetGValue(crTo)-iG)) / iWidth;// -143
int idB = (MULTI*(GetBValue(crTo)-iB)) / iWidth;// -1
// =0
iR *= MULTI;
iG *= MULTI;
iB *= MULTI;
// ->
for(int i = rect.left; i <= iWidth; i++)
{
dc.FillSolidRect(i,rect.top,1,iHeight,RGB(iR/MULTI,iG/MULTI,iB/MULTI));
iR += idR;
iG += idG;
iB += idB;
}
if (lpDrawItemStruct->itemState & ODS_FOCUS)// 0x0010
{// focus
rect.DeflateRect(4,4);
dc.SelectObject(GetStockObject(NULL_BRUSH));
dc.Rectangle(&rect);
}
dc.SetBkMode(TRANSPARENT);
dc.TextOut(46,6,"Button",6);
}