-
setbkcolor
鎖定
setbkcolor,函數名。該函數用指定的顏色值來設置當前的背景色,如果指定的顏色值超出了當前設備的表示範圍,則設置為最近似的、設備可以表示的顏色。
- 外文名
- setbkcolor
- 類 別
- 函數
- 函數功能
- 設置當前的背景色
- 函數原型
- COLORREF SetBkColor
setbkcolor函數原型
COLORREF SetBkColor(HDC hdc,COLORREF color);
setbkcolor參數説明
hdc: 設置上下文句柄
crColor: 標識新的背景顏色值。如果想要獲得COLORREF的值,請使用RGB宏。
setbkcolor返回值
如果函數成功,返回值是原背景色的COLORREF值。如果函數失敗,則返回CLR_INVALID。想要獲得更多信息,請調用GetLastError函數。
速查:
Windows NT/2000: 需要 Windows NT 3.1 或更高版本.
Windows 95/98: 需要 Windows 95 或更高版本.
Header: 在頭文件Wingdi.h中聲明;請包含 Windows.h.
Library: Use Gdi32.lib.程序例
setbkcolor示例
#include <WinAPI> #include <WindowsConstants> #include <FontConstants> Global $tRECT, $hFont, $hOldFont, $hDC HotKeySet("{ESC}", "_Exit") $tRECT = DllStructCreate($tagRect) DllStructSetData($tRECT, "Left", 5) DllStructSetData($tRECT, "Top", 5) DllStructSetData($tRECT, "Right", 250) DllStructSetData($tRECT, "Bottom", 50) $hDC = _WinAPI_GetDC(0) $hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') $hOldFont = _WinAPI_SelectObject($hDC, $hFont) _WinAPI_SetTextColor($hDC, 0x0000FF) _WinAPI_SetBkColor($hDC, 0x000000) ; comment next line to get black background instead of transparent one _WinAPI_SetBkMode($hDC, $TRANSPARENT) While 1 _WinAPI_DrawText($hDC, "Hello world!", $tRECT, $DT_CENTER) Sleep(100) WEnd Func _Exit() _WinAPI_SelectObject($hDC, $hOldFont) _WinAPI_DeleteObject($hFont) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_InvalidateRect(0, 0) $tRECT = 0 Exit EndFunc ;==>_Exit
- 詞條統計
-
- 瀏覽次數:次
- 編輯次數:18次歷史版本
- 最近更新: canguanxihu