比如背景色是紅色的 不要紅色要中間的圖象顯示在picture contor 中 上傳不了圖片
只能用文字描述了
怎么把圖中的綠色去掉顯示在picture contor 中
uj5u.com熱心網友回復:
沒明白你說的問題,不過可以試試這幾個函式SetBkColor:設定背景顏色 (文本的背景色)
SetTextColor:設定文本顏色 (輸出文字的顏色)
SetBkMode:設定背景模式 (是否背景透明)
我當時遇到的問題是黑色背景中顯示幾個字,但是字會有白色小筐,這時候用setbkmode(TRANSPARENT )就好了
uj5u.com熱心網友回復:
舉個簡單的例子:[align=left]CBrush newBrush;
CBrush *pOldBrush;
newBrush.CreateSolidBrush(RGB(0,0,0));
CClientDC clientDC(this);
CRect rect;
m_Picture.GetWindowRect(&rect);
ScreenToClient(&rect);
pOldBrush = clientDC.SelectObject(&newBrush);
clientDC.Rectangle(rect);
clientDC.SetBkMode(TRANSPARENT);
clientDC.SetTextColor(RGB(255,255,255));
clientDC.TextOutW(rect.left+rect.Width()/2,rect.top+rect.Height()/2,_T("呵呵噠"),3);[/align]
uj5u.com熱心網友回復:
這問題看的我稀里糊涂的uj5u.com熱心網友回復:
AlphaBlend[This is preliminary documentation and subject to change.]
The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels.
AlphaBlend(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
BLENDFUNCTION blendFunction
);
Parameter
hdcDest
Handle to the destination device context.
nXOriginDest
Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYOriginDest
Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidthDest
Specifies the width, in logical units, of the destination rectangle.
hHeightDset
Handle to the height, in logical units, of the destination rectangle.
hdcSrc
Handle to the source device context.
nXOriginSrc
Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle.
nYOriginSrc
Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle.
nWidthSrc
Specifies the width, in logical units, of the source rectangle.
nHeightSrc
Specifies the height, in logical units, of the source rectangle.
blendFunction
Specifies the alpha blending function for source and destination bitmaps, a global alpha value to be applied to the entire source bitmap, and format information for the source bitmap. The source and destination blend functions are currently limited to AC_SRC_OVER. See the BLENDFUNCTION and EMRALPHABLEND structures.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
Windows NT: To get extended error information, callGetLastError.
Remarks
If the source rectangle and destination rectangle are not the same size, the source bitmap is stretched to match the destination rectangle. If the SetStretchBltMode function is used, the iStretchMode value is BLACKONWHITE and WHITEONBLACK; the iStretchMode value is automatically converted to COLORONCOLOR for this function.
The destination coordinates are transformed by using the transformation currently specified for the destination device context. The source coordinates are transformed by using the transformation currently specified for the source device context.
An error occurs (and the function returns FALSE) if the source device context identifies an enhanced metafile device context.
If destination and source bitmaps do not have the same color format, AlphaBlend converts the source bitmap to match the destination bitmap.
AlphaBlend does not support mirroring. If either the width or height of the source or destination is negative, this call will fail.
Note: The SourceConstantaAlpha member of BLENDFUNCTION specifies an alpha transparancy value to be used on the entire source bitmap. The SourceConstantAlpha value is combined with any per-pixel alpha values. If you set SourceConstantAlpha to 0, it is assumed that your image is transparent. Set the SourceConstantAlpha value to 255 (indicates that the image is opaque) when you only want to use per-pixel alpha values.
QuickInfo
Windows NT: Requires version 5.0 or later.
Windows: Requires Windows 98 or later.
Windows CE: Unsupported.
Header: Declared in wingdi.h.
Import Library: Included as a resource in msimg32.dll.
See Also
Bitmaps Overview, Bitmap Functions
uj5u.com熱心網友回復:
一種背景色 可以用TransparentBlt
[This is preliminary documentation and subject to change.]
The TransparentBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
BOOL TransparentBlt(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
UINT crTransparent
);
uj5u.com熱心網友回復:
不建議用picture ctrl,建議你通過定義控制元件實作,可參考https://blog.csdn.net/xianglitian/article/details/6075653
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/65493.html
標籤:界面
上一篇:滾輪事件ID
