十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
為什么 BitBlt 第二第三參數(shù)是200,這是繪制到位圖上的坐標(biāo)起點,一般是0。如果繪制寬度和坐標(biāo)起點不能使位圖全覆蓋上,留出的空白部分自然為黑色的。

網(wǎng)站設(shè)計制作過程拒絕使用模板建站;使用PHP+MYSQL原生開發(fā)可交付網(wǎng)站源代碼;符合網(wǎng)站優(yōu)化排名的后臺管理系統(tǒng);成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計收費合理;免費進行網(wǎng)站備案等企業(yè)網(wǎng)站建設(shè)一條龍服務(wù).我們是一家持續(xù)穩(wěn)定運營了十多年的創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司。
假如下面那樣,沒見有黑邊:
hBMP = CreateCompatibleBitmap(hDC, 500,600)
hBMPOld = SelectObject(hMDC, hBMP)
BitBlt(hMDC,0,0, 500, 600, hDC, 0, 0, HCC0020)
hBMP = SelectObject(hMDC, hBMPOld)
要么重寫這個控件的 OnPaint 事件,判斷 BorderStyle 屬性為 FixedSingle 的時候自繪其他顏色。
要么不重寫,把 BorderStyle 設(shè)為 None,直接在這個控件的 Paint 事件里自繪邊框,例如:
Private?Sub?Label1_Paint(sender?As?Object,?e?As?PaintEventArgs)?Handles?Label1.Paint
e.Graphics.DrawRectangle(Pens.Red,?New?Rectangle(Label1.DisplayRectangle.X,?Label1.DisplayRectangle.Y,?Label1.DisplayRectangle.Width?-?1,?Label1.DisplayRectangle.Height?-?1))
End?Sub
運行效果:
調(diào)用系統(tǒng)API使窗體下?lián)碛嘘幱靶Ч?/p>
using System.Runtime.InteropServices;
然后再窗口類的隨便哪個地方加上:
const int CS_DROPSHADOW = 0x20000;
const int GCL_STYLE = (-26);
//聲明Win32 API
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetClassLong(IntPtr hwnd,int nIndex,int dwNewLong);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int GetClassLong(IntPtr hwnd, int nIndex);
最后在窗體的構(gòu)造函數(shù)中加上:
SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DROPSHADOW);