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.
uj5u.com熱心網友回復:
DrawFrameControl DFC_BUTTON 就可以繪制按鈕記錄繪制的位置, 滑鼠移動和點擊的時候,判斷是否在這個區域中, 然后模擬按鈕發送 WM_COMMAND BN_CLICKED 訊息
uj5u.com熱心網友回復:
可以搜索怎么自繪按鈕,實作你的要求uj5u.com熱心網友回復:
曾經做過整個界面就是一張背景圖,按鈕什么的變化是根據滑鼠狀態的變化,區域貼圖。uj5u.com熱心網友回復:
不必“first, create a button via CreateWindow(WC_BUTTON, ...)”1 draw image first
2 then draw the button later.
uj5u.com熱心網友回復:
how to draw the button later?
uj5u.com熱心網友回復:
下面是一個 透明 按鈕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);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/30286.html
標籤:圖形處理/算法
上一篇:連通區域最小外接矩形的長寬比問題
下一篇:pIUnknown->QueryInterface(const IID& iid, void** ppv)中第一引數如何理解
