本文整理汇总了C++中SetBkColor函数的典型用法代码示例。如果您正苦于以下问题:C++ SetBkColor函数的具体用法?C++ SetBkColor怎么用?C++ SetBkColor使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetBkColor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WndProc
//.........这里部分代码省略.........
}
}
break;
}
break;
case WM_MEASUREITEM:
((LPMEASUREITEMSTRUCT)lParam)->itemHeight = 32;
return 0;
case WM_SIZE:
MoveWindow(hList, 0, 0, LOWORD(lParam), HIWORD(lParam), 0);
break;
case WM_EXITTHREAD:
{
DATA* pData = (DATA*)lParam;
WaitForSingleObject(pData->hThread, INFINITE);
CloseHandle(pData->hThread);
pData->hThread = 0;
InvalidateRect(hList, 0, 0);
}
break;
case WM_DRAWITEM:
if ((UINT)wParam == IDC_LIST)
{
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
if (lpdis->itemID == -1)
{
if (!SendMessage(hList, LB_GETCOUNT, 0, 0))
{
RECT rect;
GetClientRect(hList, &rect);
HBRUSH hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
FillRect(lpdis->hDC, &rect, hBrush);
DeleteObject(hBrush);
SetTextColor(lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
DrawText(lpdis->hDC, TEXT("ここにファイルをドラッグ"), -1, &rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_CENTER);
}
break;
}
DATA* pData = (DATA*)SendMessage(hList, LB_GETITEMDATA, lpdis->itemID, 0);
if ((lpdis->itemState)&(ODS_SELECTED))
{
SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
}
else
{
SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));
SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
}
RECT rect1 = lpdis->rcItem;
rect1.right = dwSplitLine + 16;
const LPCTSTR lpszFileName = PathFindFileName(pData->szFilePath);
SetTextAlign(lpdis->hDC, TA_RIGHT);
ExtTextOut(lpdis->hDC, rect1.right, rect1.top + 4, ETO_OPAQUE, &rect1, lpszFileName, lstrlen(lpszFileName), 0);
RECT rect2 = lpdis->rcItem;
rect2.left = dwSplitLine + 16;
SetTextAlign(lpdis->hDC, TA_LEFT);
ExtTextOut(lpdis->hDC, rect2.left + 32, rect2.top + 4, ETO_OPAQUE, &rect2, pData->szHashValue, lstrlen(pData->szHashValue), 0);
}
break;
case WM_DROPFILES:
{
HDROP hDrop = (HDROP)wParam;
TCHAR szFileName[MAX_PATH];
UINT i;
const DWORD dwFastItem = SendMessage(hList, LB_GETCOUNT, 0, 0);
SendMessage(hList, LB_SETSEL, 0, -1);
const UINT nFiles = DragQueryFile((HDROP)hDrop, 0xFFFFFFFF, NULL, 0);
for (i = 0; i<nFiles; i++)
{
DragQueryFile(hDrop, i, szFileName, sizeof(szFileName));
CalcSha1(hList, szFileName);
const DWORD dwTempWidth = GetStringWidth(hList, PathFindFileName(szFileName));
if (dwTempWidth>dwSplitLine)dwSplitLine = dwTempWidth;
}
DragFinish(hDrop);
const DWORD dwLastItem = SendMessage(hList, LB_GETCOUNT, 0, 0);
SendMessage(hList, LB_SELITEMRANGE, TRUE, MAKELPARAM(dwFastItem, dwLastItem - 1));
SetForegroundWindow(hWnd);
}
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
{
const int nCount = SendMessage(hList, LB_GETCOUNT, 0, 0);
for (int i = nCount - 1; i >= 0; i--)
{
DeleteItem(hList, i);
}
}
DeleteObject(hFont);
PostQuitMessage(0);
break;
default:
return DefDlgProc(hWnd, msg, wParam, lParam);
}
return 0;
}
示例2: Picker_HandleDrawItem
//.........这里部分代码省略.........
DeleteDC(htempDC);
if (GetBackgroundPalette() == NULL)
{
DeletePalette(hPAL);
hPAL = NULL;
}
}
indent_space = 0;
if (bDrawAsChild)
{
RECT rect;
res = ListView_GetItemRect_Modified(hWnd, nItem, &rect, LVIR_ICON);
/* indent width of icon + the space between the icon and text
* so left of clone icon starts at text of parent
*/
indent_space = rect.right - rect.left + offset;
}
rcAllLabels.left += indent_space;
if (bSelected)
{
HBRUSH hBrush;
HBRUSH hOldBrush;
if (bFocus)
{
clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT));
hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
}
else
{
clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT));
clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_BTNFACE));
hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
}
hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
FillRect(hDC, &rcAllLabels, hBrush);
SelectObject(hDC, hOldBrush);
DeleteBrush(hBrush);
}
else
{
if (hBackground == NULL)
{
HBRUSH hBrush;
hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
FillRect(hDC, &rcAllLabels, hBrush);
DeleteBrush(hBrush);
}
if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren())
{
if (bDrawAsChild || bColorChild)
clrTextSave = SetTextColor(hDC, GetListCloneColor());
else
clrTextSave = SetTextColor(hDC, GetListFontColor());
}
示例3: MyWindowFunc
/* Ôóíêöèÿ îáðàáîòêè ñîîáùåíèÿ îêíà.
* ÀÐÃÓÌÅÍÒÛ:
* - äåñêðèïòîð îêíà:
* HWND hWnd;
* - íîìåð ñîîáùåíèÿ (ñì. WM_***):
* UINT Msg;
* - ïàðàìåòð ñîîáøåíèÿ ('word parameter'):
* WPARAM wParam;
* - ïàðàìåòð ñîîáøåíèÿ ('long parameter'):
* LPARAM lParam;
* ÂÎÇÂÐÀÙÀÅÌÎÅ ÇÍÀ×ÅÍÈÅ:
* (LRESULT) - â çàâèñèìîñòè îò ñîîáùåíèÿ.
*/
LRESULT CALLBACK MyWindowFunc( HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam )
{
HDC hDC;
CREATESTRUCT *cs;
SYSTEMTIME st;
CHAR Buf[100];
HFONT hFnt, hOldFnt;
/* HPEN hPen; */
/* HBRUSH hBrush, hOldBr;*/
static INT xx[100], yy[100];
static BITMAP bm;
static HBITMAP hBm, hBmLogo;
static HDC hMemDC, hMemDCLogo;
static INT w, h;
switch (Msg)
{
case WM_CREATE:
cs = (CREATESTRUCT *)lParam;
SetTimer(hWnd, 111, 50, NULL);
hBmLogo = LoadImage(NULL, "clock.bmp", IMAGE_BITMAP, w, h, LR_LOADFROMFILE);
GetObject(hBmLogo, sizeof(bm), &bm);
/* ñîçäàåì êîíòåêñò â ïàìÿòè */
hDC = GetDC(hWnd);
hMemDC = CreateCompatibleDC(hDC);
hMemDCLogo = CreateCompatibleDC(hDC);
ReleaseDC(hWnd, hDC);
SelectObject(hMemDCLogo, hBmLogo);
return 0;
case WM_SIZE:
w = LOWORD(lParam);
h = HIWORD(lParam);
/* ñîçäàåì êàðòèíêó ðàçìåðîì ñ îêíî */
if (hBm != NULL)
DeleteObject(hBm);
hDC = GetDC(hWnd);
hBm = CreateCompatibleBitmap(hDC, w, h);
ReleaseDC(hWnd, hDC);
SelectObject(hMemDC, hBm);
SendMessage(hWnd, WM_TIMER, 111, 0);
return 0;
case WM_TIMER:
/* Clear Background */
SelectObject(hMemDC, GetStockObject(NULL_PEN));
SelectObject(hMemDC, GetStockObject(DC_BRUSH));
SetDCBrushColor(hMemDC, RGB(0, 0, 0));
Rectangle(hMemDC, 0, 0, w, h);
StretchBlt(hMemDC, w / 2 - bm.bmWidth / 2, h / 2 - bm.bmHeight / 2, bm.bmWidth, bm.bmHeight,
hMemDCLogo, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
GetLocalTime(&st);
DrawHand(hMemDC, w / 2, h / 2, 160, 5, (st.wSecond * 6 + 180) * PI / 180);
DrawHand(hMemDC, w / 2, h / 2, 130, 10, (st.wMinute * 6 + 180) * PI / 180);
DrawHand(hMemDC, w / 2, h / 2, 130, 10, (st.wHour % 12 * 30 + 180) * PI / 180);
SelectObject(hMemDC, GetStockObject(NULL_PEN));
SelectObject(hMemDC, GetStockObject(NULL_BRUSH));
hFnt = CreateFont(h / 8 , 0, 0, 0, FW_BOLD, FALSE, FALSE,
FALSE, RUSSIAN_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
VARIABLE_PITCH | FF_ROMAN, "");
hOldFnt = SelectObject(hMemDC, hFnt);
GetLocalTime(&st);
SetTextColor(hMemDC, RGB(255, 255, 255));
SetBkColor(hMemDC, RGB(12, 24, 200));
SetBkMode(hMemDC, TRANSPARENT);
TextOut(hMemDC, w / 4, h / 6, Buf,
sprintf(Buf, "%02d:%02d:%02d (%02d.%02d.%d)",
st.wHour, st.wMinute, st.wSecond,
st.wDay, st.wMonth, st.wYear));
DeleteObject(hFnt);
InvalidateRect(hWnd, NULL, TRUE);
//.........这里部分代码省略.........
示例4: DlgProc
//.........这里部分代码省略.........
//~ strncpy(Content2,Content,strlen(Content)-2);
SetDlgItemText(hwndDlg,IDC_EDIT2,Content);
//~ SendMessage(hEdit, EM_LINESCROLL, 0, 80);//WS_VSCROLL
SQLFreeStmt(hstmt,SQL_CLOSE);
}
default:
break;
}
return TRUE;
}
break;
case WM_CTLCOLORBTN:
//~ hDC = BeginPaint((HWND)wParam, &ps);
//~ FillRect(hDC, &rect, hbrush);
//~ EndPaint((HWND)wParam, &ps);
//~ if(RedrawFlag){
//~ hbrush = CreateSolidBrush(RGB(0,255,0));
//~ SetTextColor((HDC)wParam,RGB(0,0,0));
//~ SetBkColor((HDC)wParam,RGB(0,255,0));
//~ return (long)hbrush ;
//~ }
//~ else
//~ {
//~ SetTextColor((HDC)wParam,RGB(255,0,0));
//~ SetBkColor((HDC)wParam,RGB(0,0,0));
//~ SetBkMode((HDC)wParam, TRANSPARENT);
//~ return (long)hbrush ;
//~ }
break;
case WM_CLOSE://Massage for terminate/exit (may close button clicked on title bar)
{
//Close dialog
SQLFreeStmt(hstmt,SQL_CLOSE);
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, henv);
//~ EndDialog(hwndDlg,0);
DestroyWindow(hwndDlg);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return TRUE;
}
case WM_CTLCOLORDLG: //set its text and background colors using the specified display device context handle.
{
break;
}
case WM_PAINT:
{
if (RedrawFlag == 1){
hbrush = CreateSolidBrush(RGB(0,255,0));
hDC = BeginPaint(hBTN1, &ps);
FillRect(hDC, &rect, hbrush);
EndPaint(hBTN1, &ps);
return (LONG)hbrush;
}
break;
}
case WM_DRAWITEM:
{
dItem = (DRAWITEMSTRUCT*)lParam;
if (ifconnect){
SetBkColor(dItem->hDC, RGB(0,255,0));
}
else
{
SetBkColor(dItem->hDC, RGB(255,0,0));
}
//~ SetTextColor(dItem->hDC, RGB(0,0,0xFF));
memset(text, '\0', 20);
GetWindowText(dItem->hwndItem, text, 20);
len=lstrlen(text);
GetTextExtentPoint32(dItem->hDC, text, len, &sz);
ExtTextOut( dItem->hDC
, ((dItem->rcItem.right - dItem->rcItem.left) / 2) + dItem->rcItem.left - (sz.cx / 2)
, ((dItem->rcItem.bottom - dItem->rcItem.top) / 2) + dItem->rcItem.top - (sz.cy / 2)
, ETO_OPAQUE | ETO_CLIPPED, &dItem->rcItem, text, len, NULL);
DrawEdge( dItem->hDC, &dItem->rcItem
, (dItem->itemState & ODS_SELECTED ? BDR_SUNKENOUTER : BDR_RAISEDOUTER), BF_RECT);
return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
break;
}
case WM_CTLCOLORSTATIC: //可以控制静态控件的颜色
{
break;
}
default:
break;
}
return FALSE;
}
示例5: AutoMap_DlgProc
BOOL CALLBACK AutoMap_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_INITDIALOG:
AutoMap_OnInitDialog (hDlg);
break;
case WM_CTLCOLORSTATIC:
if ((HWND)lp == GetDlgItem (hDlg, IDC_CHUNK_SIZE))
{
if (IsWindowEnabled ((HWND)lp))
{
static HBRUSH hbrStatic = CreateSolidBrush (GetSysColor (COLOR_WINDOW));
SetTextColor ((HDC)wp, GetSysColor (COLOR_WINDOWTEXT));
SetBkColor ((HDC)wp, GetSysColor (COLOR_WINDOW));
return (BOOL)hbrStatic;
}
}
break;
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDHELP:
AutoMap_DlgProc (hDlg, WM_HELP, 0, 0);
break;
case IDOK:
EndDialog(hDlg, IDOK);
break;
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
break;
case IDC_ADD:
AutoMap_OnAdd(hDlg);
break;
case IDC_CHANGE:
AutoMap_OnEdit(hDlg);
break;
case IDC_REMOVE:
AutoMap_OnRemove(hDlg);
break;
}
break;
case WM_NOTIFY:
switch (((LPNMHDR)lp)->code)
{
case FLN_ITEMSELECT:
AutoMap_OnSelect (hDlg);
break;
case FLN_LDBLCLICK:
if (IsWindowEnabled (GetDlgItem (hDlg, IDC_EDIT)))
AutoMap_OnEdit (hDlg);
break;
}
break;
case WM_HELP:
WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_ADVANCED_AUTOMAP);
break;
}
return FALSE;
}
示例6: TitleWndProc
static LRESULT CALLBACK TitleWndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
TitleData* data = (TitleData*)GetWindowLong(hWnd, GWL_USERDATA);
switch (msg)
{
#ifdef SDK_REGISTRATION
case WM_TIMER:
{
ScrollTextData* scroll = data->scrollText;
switch (wp)
{
case SCROLL_TIMER:
data->bRepaint = TRUE;
scroll->offset++;
if (scroll->offset >= ((scroll->font.lfHeight *
scroll->lineCount) + SCROLL_LINE_SPACE * (
scroll->lineCount + 1)))
{
scroll->offset = 0;
scroll->bFirstLoop = FALSE;
}
if (scroll->offset == SCROLL_INIT_OFFSET && scroll->bOneTime)
{
TitleStopScroller(GetParent(hWnd));
}
else
{
InvalidateRect(hWnd, NULL, FALSE);
}
break;
case SCROLL_DELAY_TIMER:
KillTimer(hWnd, SCROLL_DELAY_TIMER);
SetTimer(hWnd, SCROLL_TIMER, SCROLL_TIMER_PERIOD, NULL);
ShowWindow(GetDlgItem(GetParent(hWnd),IDC_PRODUCT_KEY),SW_HIDE);
scroll->bScrolling = TRUE;
scroll->bFirstLoop = TRUE;
scroll->offset = SCROLL_INIT_OFFSET;
data->bRepaint = TRUE;
InvalidateRect(hWnd, NULL, FALSE);
break;
default:
// Forward the message to the default window proc
return CallWindowProc(data->superProc, hWnd, msg, wp, lp);
}
}
return 0;
#endif // SDK_REGISTRATION
case WM_PAINT:
if (data->hBitmap)
{
RECT rc;
if (GetUpdateRect(hWnd, &rc, FALSE))
{
PAINTSTRUCT paint;
HDC dc = BeginPaint(hWnd, &paint);
if (dc)
{
int w = RECT_Width(&rc);
int h = RECT_Height(&rc);
if (!data->hOffScreen)
{
data->hOffScreen = CreateCompatibleBitmap(dc,w,h);
}
if (!data->hOffScreenBg)
{
data->hOffScreenBg = CreateCompatibleBitmap(dc,w,h);
}
if (!data->hOffScreenDC && data->hOffScreen)
{
data->hOffScreenDC = CreateCompatibleDC(dc);
if (data->hOffScreenDC)
{
SetTextColor(data->hOffScreenDC, RGB(0,0,0));
SetBkColor(data->hOffScreenDC, RGB(255,255,255));
SetBkMode(data->hOffScreenDC, OPAQUE);
}
}
if (!data->hBitmapDC)
{
data->hBitmapDC = CreateCompatibleDC(dc);
}
if (data->hBitmapDC &&
data->hOffScreenDC &&
data->hOffScreen &&
data->hOffScreenBg)
{
TitlePaint(data, hWnd, dc);
}
EndPaint(hWnd, &paint);
return 1;
}
}
//.........这里部分代码省略.........
示例7: CreateDIBFromDC
FIBITMAP* CreateDIBFromDC(HDC hDC, const RECT* rect, HWND hCapture/*=NULL*/)
{
///HDC GetDC (NULL) entire desktp
///HDC GetDC (HWND hWnd) client area of the specified window. (may include artifacts)
///HDC GetWindowDC (HWND hWnd) entire window.
FIBITMAP* dib;// return value
HBITMAP hBitmap; // handles to device-dependent bitmaps
HDC hScrDC, hMemDC; // screen DC and memory DC
long width = rect->right - rect->left;
long height = rect->bottom - rect->top;
// create a DC for the screen and create
// a memory DC compatible to screen DC
if (!(hScrDC = hDC)) hScrDC = GetDC(hCapture);
hMemDC = CreateCompatibleDC(hScrDC);
// create a bitmap compatible with the screen DC
hBitmap = CreateCompatibleBitmap(hScrDC, width, height);//width,height
// select new bitmap into memory DC
SelectObject(hMemDC, hBitmap);
if (hCapture && hDC) {
PrintWindow(hCapture, hMemDC, 0);
}
else {// bitblt screen DC to memory DC
BitBlt(hMemDC, 0, 0, width, height, hScrDC, rect->left, rect->top, CAPTUREBLT | SRCCOPY);
}
dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap);
//alpha channel from window is always wrong and sometimes even for desktop (Win7, no aero)
//coz GDI do not draw all in alpha mode.
//we have to create our own new alpha channel.
bool bFixAlpha = true;
bool bInvert = false;
HBRUSH hBr = CreateSolidBrush(RGB(255, 255, 255));//Create a SolidBrush object for non transparent area
HBITMAP hMask = CreateBitmap(width, height, 1, 1, NULL);// Create monochrome (1 bit) B+W mask bitmap.
HDC hMaskDC = CreateCompatibleDC(0);
SelectBitmap(hMaskDC, hMask);
HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
if (hCapture && GetWindowRgn(hCapture, hRgn) == ERROR) {
if ((GetWindowLongPtr(hCapture, GWL_EXSTYLE)&WS_EX_LAYERED)) {
BYTE bAlpha = 0;
COLORREF crKey = 0x00000000;
DWORD dwFlags = 0;
if (GetLayeredWindowAttributes(hCapture, &crKey, &bAlpha, &dwFlags)) {
/// per window transparency (like fading in a whole window)
if ((dwFlags&LWA_COLORKEY)) {
SetBkColor(hMemDC, crKey);
BitBlt(hMaskDC, 0, 0, width, height, hMemDC, rect->left, rect->top, SRCCOPY);
bInvert = true;
}
else if ((dwFlags&LWA_ALPHA)) {
bFixAlpha = false;
}
}
else {//per-pixel transparency (won't use the WM_PAINT)
bFixAlpha = false;
}
}
else {//not layered - fill the window region
SetRectRgn(hRgn, 0, 0, width, height);
FillRgn(hMaskDC, hRgn, hBr);
}
}
else {
if (!hCapture) SetRectRgn(hRgn, 0, 0, width, height);//client area only, no transparency
FillRgn(hMaskDC, hRgn, hBr);
}
DeleteObject(hRgn);
if (bFixAlpha) {
FIBITMAP* dibMask = FIP->FI_CreateDIBFromHBITMAP(hMask);
if (bInvert) FIP->FI_Invert(dibMask);
FIBITMAP* dib8 = FIP->FI_ConvertTo8Bits(dibMask);
//copy the dib8 alpha mask to dib32 main bitmap
FIP->FI_SetChannel(dib, dib8, FICC_ALPHA);
FIP->FI_Unload(dibMask);
FIP->FI_Unload(dib8);
}
DeleteDC(hMaskDC);
DeleteObject(hMask);
DeleteObject(hBr);
//clean up
DeleteDC(hMemDC);
DeleteObject(hBitmap);
if (!hDC) ReleaseDC(NULL, hScrDC);
#ifdef _DEBUG
switch (FIP->FI_GetImageType(dib)) {
case FIT_UNKNOWN:
OutputDebugStringA("FIBITMAP Type: FIT_UNKNOWN\r\n");
break;
case FIT_BITMAP:
OutputDebugStringA("FIBITMAP Type: FIT_BITMAP\r\n");
break;
case FIT_UINT16:
OutputDebugStringA("FIBITMAP Type: FIT_UINT16\r\n");
break;
case FIT_INT16:
OutputDebugStringA("FIBITMAP Type: FIT_INT16\r\n");
break;
case FIT_UINT32:
//.........这里部分代码省略.........
示例8: DlgProcColorToolWindow
INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static COLORCHOOSER* pCC = NULL;
static int iCurrentHotTrack;
static BOOL bChoosing;
static int iRows;
static int iColumns;
static HWND hPreviousActiveWindow;
switch (msg) {
case WM_INITDIALOG: {
RECT rc;
int iSquareRoot;
int width ;
int height;
TranslateDialogDefault(hwndDlg);
pCC = (COLORCHOOSER*) lParam;
iCurrentHotTrack = -2;
bChoosing = FALSE;
iSquareRoot = (int)sqrt(static_cast<float>(pCC->pModule->nColorCount));
iColumns = iSquareRoot * iSquareRoot == pCC->pModule->nColorCount ? iSquareRoot : iSquareRoot + 1;
iRows = iSquareRoot;
rc.top = rc.left = 100;
rc.right = 100 + iColumns * 25 + 1;
rc.bottom = iRows * 20 + 100 + 20;
AdjustWindowRectEx(&rc, GetWindowLongPtr(hwndDlg, GWL_STYLE), FALSE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE));
width = rc.right - rc.left;
height = rc.bottom - rc.top;
pCC->yPosition -= height;
SetDlgItemText(hwndDlg, IDC_COLORTEXT, pCC->bForeground ? CTranslator::get(CTranslator::GEN_MUC_TEXTCOLOR) :
CTranslator::get(CTranslator::GEN_MUC_BGCOLOR));
SetWindowPos(GetDlgItem(hwndDlg, IDC_COLORTEXT), NULL, 0, 0, width, 20, 0);
SetWindowPos(hwndDlg, NULL, pCC->xPosition, pCC->yPosition, width, height, SWP_SHOWWINDOW);
}
break;
case WM_CTLCOLOREDIT:
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_COLORTEXT)) {
SetTextColor((HDC)wParam, RGB(60, 60, 150));
SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
}
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
if (iCurrentHotTrack >= 0)
PostMessage(hwndDlg, WM_LBUTTONUP, 0, 0);
break;
case IDCANCEL:
DestroyWindow(hwndDlg);
break;
}
break;
case WM_LBUTTONUP:
if (iCurrentHotTrack >= 0 && iCurrentHotTrack < pCC->pModule->nColorCount && pCC->hWndTarget != NULL) {
HWND hWindow;
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwMask = 0;
cf.dwEffects = 0;
hWindow = GetParent(pCC->hWndTarget);
if (pCC->bForeground) {
pCC->si->bFGSet = TRUE;
pCC->si->iFG = iCurrentHotTrack;
if (IsDlgButtonChecked(hWindow, IDC_COLOR)) {
cf.dwMask = CFM_COLOR;
cf.crTextColor = pCC->pModule->crColors[iCurrentHotTrack];
SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
} else {
pCC->si->bBGSet = TRUE;
pCC->si->iBG = iCurrentHotTrack;
if (IsDlgButtonChecked(hWindow, IDC_BKGCOLOR)) {
cf.dwMask = CFM_BACKCOLOR;
cf.crBackColor = pCC->pModule->crColors[iCurrentHotTrack];
SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
}
PostMessage(hwndDlg, WM_CLOSE, 0, 0);
break;
case WM_ACTIVATE:
if (wParam == WA_INACTIVE)
PostMessage(hwndDlg, WM_CLOSE, 0, 0);
//.........这里部分代码省略.........
示例9: NHTextWndProc
INT_PTR CALLBACK
NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND control;
HDC hdc;
PNHTextWindow data;
TCHAR title[MAX_LOADSTRING];
data = (PNHTextWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
switch (message) {
case WM_INITDIALOG:
/* set text control font */
control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
if (!control) {
panic("cannot get text view window");
}
hdc = GetDC(control);
SendMessage(control, WM_SETFONT,
(WPARAM) mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE),
0);
ReleaseDC(control, hdc);
/* subclass edit control */
editControlWndProc =
(WNDPROC) GetWindowLongPtr(control, GWLP_WNDPROC);
SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR) NHEditHookWndProc);
SetFocus(control);
/* Even though the dialog has no caption, you can still set the title
which shows on Alt-Tab */
LoadString(GetNHApp()->hApp, IDS_APP_TITLE, title, MAX_LOADSTRING);
SetWindowText(hWnd, title);
return FALSE;
case WM_MSNH_COMMAND:
onMSNHCommand(hWnd, wParam, lParam);
break;
case WM_SIZE: {
RECT rt;
GetWindowRect(hWnd, &rt);
ScreenToClient(GetNHApp()->hMainWnd, (LPPOINT) &rt);
ScreenToClient(GetNHApp()->hMainWnd, ((LPPOINT) &rt) + 1);
mswin_update_window_placement(NHW_TEXT, &rt);
LayoutText(hWnd);
}
return FALSE;
case WM_MOVE: {
RECT rt;
GetWindowRect(hWnd, &rt);
ScreenToClient(GetNHApp()->hMainWnd, (LPPOINT) &rt);
ScreenToClient(GetNHApp()->hMainWnd, ((LPPOINT) &rt) + 1);
mswin_update_window_placement(NHW_TEXT, &rt);
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
if (GetNHApp()->hMainWnd == hWnd)
GetNHApp()->hMainWnd = NULL;
DestroyWindow(hWnd);
SetFocus(GetNHApp()->hMainWnd);
return TRUE;
}
break;
case WM_CTLCOLORSTATIC: { /* sent by edit control before it is drawn */
HDC hdcEdit = (HDC) wParam;
HWND hwndEdit = (HWND) lParam;
if (hwndEdit == GetDlgItem(hWnd, IDC_TEXT_CONTROL)) {
SetBkColor(hdcEdit, text_bg_brush ? text_bg_color
: (COLORREF) GetSysColor(
DEFAULT_COLOR_BG_TEXT));
SetTextColor(hdcEdit, text_fg_brush ? text_fg_color
: (COLORREF) GetSysColor(
DEFAULT_COLOR_FG_TEXT));
return (INT_PTR)(text_bg_brush
? text_bg_brush
: SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
}
}
return FALSE;
case WM_DESTROY:
if (data) {
if (data->window_text)
free(data->window_text);
free(data);
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) 0);
}
break;
}
//.........这里部分代码省略.........
示例10: gwdraw
//.........这里部分代码省略.........
if (*text == '*')
{
HBRUSH oldbrush, newbrush;
newbrush = CreateSolidBrush(fgc);
oldbrush = SelectObject(hDC, newbrush);
Pie(hDC, xcenter - radius, ycenter - radius,
xcenter + radius, ycenter + radius,
xcenter - radius, ycenter, xcenter - radius, ycenter);
SelectObject(hDC, oldbrush);
DeleteObject(newbrush);
}
/* Advance the points to the next cell */
xleft = xright;
xcenter += gwp->xcsize;
xright += gwp->xcsize;
}
/* Restore foreground color to its previous value, so we can delete
* the local hPen object.
*/
SelectObject(hDC, hPrevPen);
DeleteObject(hPen);
}
else
{
/* Find a font with the right bold/italic/underlined attributes */
i = 0;
if (bits & COLOR_BOLD) i += 1;
if (bits & COLOR_ITALIC) i += 2;
if (bits & COLOR_UNDERLINED) i += 4;
hFont = gwp->fonts[i];
/* prepare DC & output text */
SetTextColor(hDC, fgc);
SetBkColor(hDC, bgc);
SetBkMode(hDC, OPAQUE);
SelectObject(hDC, hFont);
options = ETO_OPAQUE | ETO_CLIPPED;
#ifdef FEATURE_IMAGE
if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg)
{
gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled);
options = ETO_CLIPPED;
SetBkMode(hDC, TRANSPARENT);
}
else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg)
{
gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled);
options = ETO_CLIPPED;
SetBkMode(hDC, TRANSPARENT);
}
#endif
ExtTextOut(hDC, rect.left - ileft, rect.top, options, &rect,
(char *)text, len, gwp->font_size_array);
#ifdef FEATURE_IMAGE
SetBkColor(hDC, bgc);
SetBkMode(hDC, OPAQUE);
#endif
}
/* If COLOR_BOXED then draw a rectangle around the text */
if (bits & (COLOR_BOXED | COLOR_LEFTBOX | COLOR_RIGHTBOX))
{
/* Select the foreground color */
hPen = CreatePen(PS_SOLID, 0, fgc);
hPrevPen = SelectObject(hDC, hPen);
/* Draw the rectangle */
if (bits & COLOR_BOXED)
{
MoveToEx(hDC, rect.left, rect.top, NULL);
LineTo(hDC, rect.right, rect.top);
MoveToEx(hDC, rect.left, rect.bottom - 1, NULL);
LineTo(hDC, rect.right, rect.bottom - 1);
}
if (bits & COLOR_RIGHTBOX)
{
MoveToEx(hDC, rect.right - 1, rect.top, NULL);
LineTo(hDC, rect.right - 1, rect.bottom);
}
if (bits & COLOR_LEFTBOX)
{
MoveToEx(hDC, rect.left, rect.top, NULL);
LineTo(hDC, rect.left, rect.bottom);
}
/* Restore foreground color to its previous value, so we can delete
* the local hPen object.
*/
SelectObject(hDC, hPrevPen);
DeleteObject(hPen);
}
/* release the window's device context */
ReleaseDC(gwp->clientHWnd, hDC);
/* update cursor position */
gwp->curcol += len;
}
示例11: Init_ConsoleWin
int Init_ConsoleWin(void)
{
HDC conDC;
WNDCLASS wndclass;
TEXTMETRIC metrics;
RECT cRect;
int width,height;
int scr_width,scr_height;
HINSTANCE hInstance;
char titlebuffer[2048];
if (con_hWnd)
return TRUE;
hInstance = GetModuleHandle(NULL);
Init_Console();
/* Register the frame class */
wndclass.style = CS_OWNDC;
wndclass.lpfnWndProc = (WNDPROC)ConWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (hInstance, IDI_WINLOGO);
wndclass.hCursor = LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH);
wndclass.lpszMenuName = szConName;
wndclass.lpszClassName = szConName;
if (!RegisterClass(&wndclass))
return FALSE;
width=100;
height=100;
strcpy(titlebuffer,PACKAGE);
strcat(titlebuffer," ");
strcat(titlebuffer,VERSION);
strcat(titlebuffer," console");
con_hWnd = CreateWindow(szConName, titlebuffer,
WS_CAPTION | WS_POPUP,
0, 0, width, height,
NULL, NULL, hInstance, NULL);
conDC=GetDC(con_hWnd);
OemFont = GetStockObject(OEM_FIXED_FONT);
SelectObject(conDC, OemFont);
GetTextMetrics(conDC, &metrics);
OemWidth = metrics.tmAveCharWidth;
OemHeight = metrics.tmHeight;
GetClientRect(con_hWnd, &cRect);
width += (OemWidth * 80) - cRect.right;
height += (OemHeight * 25) - cRect.bottom;
// proff 11/09/98: Added code for centering console
scr_width = GetSystemMetrics(SM_CXFULLSCREEN);
scr_height = GetSystemMetrics(SM_CYFULLSCREEN);
MoveWindow(con_hWnd, (scr_width-width)/2, (scr_height-height)/2, width, height, TRUE);
GetClientRect(con_hWnd, &cRect);
ConWidth = cRect.right;
ConHeight = cRect.bottom;
SetTextColor(conDC, RGB(192,192,192));
SetBkColor(conDC, RGB(0,0,0));
SetBkMode(conDC, OPAQUE);
ReleaseDC(con_hWnd,conDC);
ShowWindow(con_hWnd, SW_SHOW);
UpdateWindow(con_hWnd);
return TRUE;
}
示例12: WndProc
//.........这里部分代码省略.........
"Arial");
hAdjButton[0] = CreateWindow ("button", "", WS_CHILD | BS_BITMAP | BS_CENTER | BS_VCENTER, xPos[0], yPos, butWidth[0], butHeight[0],
hwnd, (HMENU)IDB_BITMAP_CL_UP, hInst, NULL);
SendMessage (hAdjButton[0], BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap[0]);
hAdjButton[1] = CreateWindow ("button", "", WS_CHILD | BS_BITMAP | BS_CENTER | BS_VCENTER, xPos[1], yPos, butWidth[1], butHeight[1],
hwnd, (HMENU)IDB_BITMAP_CL_UP_SM, hInst, NULL);
SendMessage (hAdjButton[1], BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap[1]);
hAdjButton[2] = CreateWindow ("button", "", WS_CHILD | BS_BITMAP | BS_CENTER | BS_VCENTER, xPos[2], yPos, butWidth[2], butHeight[2],
hwnd, (HMENU)IDB_BITMAP_CL_DOWN_SM, hInst, NULL);
SendMessage (hAdjButton[2], BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap[2]);
hAdjButton[3] = CreateWindow ("button", "", WS_CHILD | BS_BITMAP | BS_CENTER | BS_VCENTER, xPos[3], yPos, butWidth[3], butHeight[3],
hwnd, (HMENU)IDB_BITMAP_CL_DOWN, hInst, NULL);
SendMessage (hAdjButton[3], BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap[3]);
hBackgrnd = CreateSolidBrush(GetSysColor (COLOR_WINDOW));
ready4Respond = 0;
//GetCurrentProcInfo(AppPath, procname, verstr);
//getVersionStringAndUpdateTitle(hwnd, procname, verstr);
break;
case WM_SIZE:
MoveWindow(hwnd, 0, 0, sizex, sizey, 1);
break;
case WM_CTLCOLORSTATIC:
hdc = (HDC)wParam;
col = GetSysColor (COLOR_WINDOW);
id = (int)GetWindowLong ((HWND)lParam, GWL_ID);
switch (id)
{
case ID_FEEDBACK:
SelectObject (hdc, hFont2);
SetTextColor (hdc, RGB(113, 30, 225));
SetBkColor (hdc, col);
return (LRESULT) hBackgrnd;
case ID_HMSG:
SelectObject (hdc, hFont);
SetTextColor (hdc, RGB(100, 80, 64));
SetBkColor (hdc, col);
return (LRESULT) hBackgrnd;
case ID_HMSG2:
SelectObject (hdc, hFont);
SetTextColor (hdc, RGB(190, 30, 64));
SetBkColor (hdc, col);
return (LRESULT) hBackgrnd;
case ID_CAP:
SelectObject (hdc, hFont4 );
SetBkColor (hdc, col);
return (LRESULT) hBackgrnd;
}
break;
case WM_FL_CONNECTED:
//SetWindowText (hCap, "Connection: On");
break;
case WM__MOVE_BUTTONS:
count = (WPARAM)wParam;
if (count == 0)
break;
// Calculating the width, spacing, etc... of the buttons
{
int each = (int)(sizex/(count+0.2));
width = each * 8/10;
spacing = each * 2/10;
marginx = each * 2/10;
示例13: wlog_text_log_callback
/* Text log window callback. */
static LRESULT CALLBACK wlog_text_log_callback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CREATESTRUCT* create_struct;
ALLEGRO_NATIVE_DIALOG* textlog = (ALLEGRO_NATIVE_DIALOG*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
switch (uMsg) {
case WM_CTLCOLORSTATIC:
/* Set colors for text and background */
SetBkColor((HDC)wParam, RGB(16, 16, 16));
SetTextColor((HDC)wParam, RGB(128, 255, 128));
return (LRESULT)CreateSolidBrush(RGB(16, 16, 16));
case WM_CREATE:
/* Set user data for window, so we will be able to retieve text log structure any time */
create_struct = (CREATESTRUCT*)lParam;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)create_struct->lpCreateParams);
break;
case WM_CLOSE:
if (textlog->is_active) {
if (!(textlog->flags & ALLEGRO_TEXTLOG_NO_CLOSE)) {
wlog_emit_close_event(textlog, false);
}
return 0;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE) {
wlog_emit_close_event(textlog, true);
}
break;
case WM_MOVE:
InvalidateRect(hWnd, NULL, FALSE);
break;
case WM_SIZE:
/* Match text log size to parent client area */
if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) {
RECT client_rect;
GetClientRect(hWnd, &client_rect);
MoveWindow(textlog->tl_textview, client_rect.left, client_rect.top,
client_rect.right - client_rect.left, client_rect.bottom - client_rect.top, TRUE);
}
break;
case WM_USER:
al_lock_mutex(textlog->tl_text_mutex);
wlog_do_append_native_text_log(textlog);
al_unlock_mutex(textlog->tl_text_mutex);
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
示例14: WindowProc
// FUNCTIONS //////////////////////////////////////////////
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
// this is the main message handler of the system
PAINTSTRUCT ps; // used in WM_PAINT
HDC hdc; // handle to a device context
char buffer[80]; // used to print strings
// what is the message
switch(msg)
{
case WM_CREATE:
{
// do initialization stuff here
// return success
return(0);
} break;
case WM_COMMAND: // all buttons come thru here
{
// get the dc
hdc = GetDC(hwnd);
// set background mode
SetBkMode(hdc,OPAQUE);
// select a random text and background color
SetTextColor(hdc,RGB(0,255,0));
SetBkColor(hdc,RGB(128,128,128));
// print out the wparam an lparam
sprintf(buffer, "LOWORD(wparam) = %d, HIWORD(wparam) = %d ",
LOWORD(wparam), HIWORD(wparam));
// print text at a random location
TextOut(hdc,220,100,buffer,strlen(buffer));
sprintf(buffer, "LOWORD(lparam) = 0X%X, HIWORD(lparam) = 0X%X ",
LOWORD(lparam), HIWORD(lparam));
// print text at a random location
TextOut(hdc,220,140,buffer,strlen(buffer));
// release the dc
ReleaseDC(hwnd, hdc);
} break;
case WM_PAINT:
{
// simply validate the window
hdc = BeginPaint(hwnd,&ps);
// end painting
EndPaint(hwnd,&ps);
// return success
return(0);
} break;
case WM_DESTROY:
{
// kill the application, this sends a WM_QUIT message
PostQuitMessage(0);
// return success
return(0);
} break;
default:break;
} // end switch
// process any messages that we didn't take care of
return (DefWindowProc(hwnd, msg, wparam, lparam));
} // end WinProc
示例15: CommonPhraseMsgProc
CommonPhraseMsgProc (
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_CONTEXTMENU:
{
char szHelpFile[MAX_PATH+1];
GetHelpDir(szHelpFile);
WinHelp ((HWND) wParam, szHelpFile, HELP_CONTEXTMENU,
(DWORD) (LPVOID) aIds);
return TRUE;
}
case WM_KEYUP:
{
SetCapsLockMessageState(GetParent(hwnd));
break;
}
// case WM_RBUTTONDOWN :
// case WM_CONTEXTMENU :
case WM_LBUTTONDBLCLK :
case WM_MOUSEMOVE :
case WM_COPY :
case WM_CUT :
case WM_PASTE :
case WM_CLEAR :
return TRUE;
case WM_LBUTTONDOWN :
if (GetKeyState (VK_SHIFT) & 0x8000) return TRUE;
break;
case WM_PAINT :
{
GPP *gpp;
gpp=(GPP *)GetWindowLong (GetParent(hwnd), GWL_USERDATA);
if (wParam)
{
SetBkColor ((HDC)wParam, GetSysColor (COLOR_WINDOW));
if (gpp->bHideText)
SetTextColor ((HDC)wParam, GetSysColor (COLOR_WINDOW));
else
SetTextColor ((HDC)wParam, GetSysColor (COLOR_WINDOWTEXT));
}
break;
}
case WM_KEYDOWN :
if (GetKeyState (VK_SHIFT) & 0x8000)
{
switch (wParam)
{
case VK_HOME :
case VK_END :
case VK_UP :
case VK_DOWN :
case VK_LEFT :
case VK_RIGHT :
case VK_NEXT :
case VK_PRIOR :
return TRUE;
}
}
break;
case WM_SETFOCUS :
SendMessage (hwnd, EM_SETSEL, 0xFFFF, 0xFFFF);
break;
}
return FALSE;
}