本文整理匯總了C++中CreateSolidBrush函數的典型用法代碼示例。如果您正苦於以下問題:C++ CreateSolidBrush函數的具體用法?C++ CreateSolidBrush怎麽用?C++ CreateSolidBrush使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CreateSolidBrush函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: SelectObject
void CardButton::Draw(HDC hdc, bool fNormal)
{
SIZE textsize;
int x, y; //text x, y
int ix, iy; //icon x, y
int iconwidth = 0;
RECT cliprect;
if(fVisible == 0) return;
if(hFont == 0)
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
else
SelectObject(hdc, hFont);
GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textsize);
if(hIcon)
{
x = rect.left + 32 + 8;
}
else
{
if(uStyle & CB_ALIGN_LEFT)
{
x = rect.left + iconwidth;
}
else if(uStyle & CB_ALIGN_RIGHT)
{
x = rect.left + (rect.right-rect.left-iconwidth-textsize.cx);
}
else //centered
{
x = rect.right - rect.left - iconwidth;
x = (x - textsize.cx) / 2;
x += rect.left + iconwidth;
}
}
y = rect.bottom - rect.top;
y = (y - textsize.cy) / 2;
y += rect.top;
//calc icon position..
ix = rect.left + 4;
iy = rect.top + (rect.bottom-rect.top-32) / 2;
//if button is pressed, then shift text
if(fNormal == false && (uStyle & CB_PUSHBUTTON))
{
x += 1;
y += 1;
ix += 1;
iy += 1;
}
SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);
ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);
//
// Calc icon pos
//
if(hIcon)
{
ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);
}
if(uStyle & CB_PUSHBUTTON)
{
DrawRect(hdc, &rect, fNormal);
SetBkColor(hdc, MAKE_PALETTERGB(crBack));
SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
SelectClipRgn(hdc, 0);
ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText, lstrlen(szText), 0);
}
else
{
SetBkColor(hdc, MAKE_PALETTERGB(crBack));
SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
SelectClipRgn(hdc, 0);
ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0);
}
if(hIcon)
{
HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));
DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);
DeleteObject(hbr);
}
}
示例2: m_brush
Brush::Brush(COLORREF color) : m_brush(CreateSolidBrush(color)) {
assert(m_brush != 0);
}
示例3: MessageBox
VOID GUIFont::DrawOnTexture( LPWSTR _pStr, DWORD _dColor, LPDIRECT3DTEXTURE9 _pTexture, INT _itexX, INT _itexY, INT _itexWidth, INT _itexHeight )
{
if( _pTexture == NULL )
{
MessageBox( NULL, L"DrawFontOnTexture{... _pTexture == NULL }", NULL, MB_OK );
return;
}
HDC hDC;
HBITMAP hBit;
LPVOID pBits;
BITMAPINFO BitInfo;
ZeroMemory( &BitInfo, sizeof( BITMAPINFO ) );
BitInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER ); // 구조체 크기
BitInfo.bmiHeader.biWidth = _itexWidth;
BitInfo.bmiHeader.biHeight = _itexHeight;
BitInfo.bmiHeader.biPlanes = 1; // 목표장차의 플레인 수( 이미지 장수, bitmap은 layer가 존재하지 않음으로 항상 1 )
BitInfo.bmiHeader.biBitCount = 32; // 각 픽셀의 비트수
BitInfo.bmiHeader.biCompression = BI_RGB/*BI_PNG*/; // 압축방법( BI_RGB 또는 0 : 무압축비트맵 )
BitInfo.bmiHeader.biSizeImage = 0; // 비트맵 영상크기
BitInfo.bmiHeader.biXPelsPerMeter = 100; // 미터당 픽셀수
BitInfo.bmiHeader.biYPelsPerMeter = 100; // 미터당 픽셀수
BitInfo.bmiHeader.biClrUsed = 0; // 사용된 컬러수
BitInfo.bmiHeader.biClrImportant = 0; // 비트맵 디스플레이에 사용되는 컬러 수
hDC = CreateCompatibleDC( NULL );
hBit = CreateDIBSection( hDC, &BitInfo, DIB_RGB_COLORS, &pBits, NULL, 0 );
RECT rt;
SetRect( &rt, 0, 0, _itexWidth, _itexHeight );
HBRUSH hBackgroundBrush = CreateSolidBrush( 0x00dddddd );
SelectObject( hDC, hBit );
SelectObject( hDC, m_hFont );
FillRect( hDC, &rt, hBackgroundBrush );
SetBkMode( hDC, TRANSPARENT ); // TRANSPARENT : 투명한 배경 색상
SetTextColor( hDC, _dColor );
// 2,2 대신 좌상단, 중단, 좌하단 3가지로 나누어 할 수 있게 하면 좋을 듯
TextOut( hDC, _itexX, _itexY, _pStr, lstrlen( _pStr ) );
D3DLOCKED_RECT d3drt;
_pTexture->LockRect( 0, &d3drt, NULL, 0 );
UINT* pSrc32 = static_cast< UINT* >( pBits );
UINT* pDst32 = static_cast< UINT* >( d3drt.pBits );
pSrc32 += ( _itexHeight * _itexWidth ) - _itexWidth;
UINT* pTemp = pSrc32;
for( INT y=0 ; y<_itexHeight ; y++ )
{
for( INT x=0 ; x<_itexWidth ; x++ )
{
if( (*pSrc32) != 0x00dddddd )
(*pDst32) = (*pSrc32) | 0xff000000;
pSrc32++;
pDst32++;
}
pTemp -= _itexWidth;
pSrc32 = pTemp;
}
_pTexture->UnlockRect( 0 );
DeleteObject( hBackgroundBrush );
DeleteObject( hBit );
DeleteDC( hDC );
}
示例4: config
static int config(uint32_t width, uint32_t height, uint32_t d_width,uint32_t d_height, uint32_t flags, char *title, uint32_t format){
title = "MPlayer VIDIX WIN32 Overlay";
panscan_init();
image_height = height;
image_width = width;
image_format = format;
vo_screenwidth = GetSystemMetrics(SM_CXSCREEN);
vo_screenheight = GetSystemMetrics(SM_CYSCREEN);
vo_depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL);
aspect_save_orig(width, height);
aspect_save_prescale(d_width, d_height);
aspect_save_screenres(vo_screenwidth, vo_screenheight);
vo_dx = 0;
vo_dy = 0;
vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;
geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight);
vo_fs = flags&VOFLAG_FULLSCREEN;
aspect(&d_width, &d_height, A_NOZOOM);
vo_dwidth=d_width; vo_dheight=d_height;
window_aspect = (float)d_width / (float)d_height;
if(!vo_config_count){
HINSTANCE hInstance = GetModuleHandle(NULL);
WNDCLASS wc;
RECT rd;
rd.left = vo_dx;
rd.top = vo_dy;
rd.right = rd.left + vo_dwidth;
rd.bottom = rd.top + vo_dheight;
AdjustWindowRect(&rd,WS_OVERLAPPEDWINDOW| WS_SIZEBOX,0);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hIcon =ExtractIcon(hInstance,"mplayer.exe",0);
//LoadIcon(NULL,IDI_APPLICATION);
wc.hbrBackground = CreateSolidBrush(RGB(255,0,255));
wc.lpszClassName = "MPlayer - The Movie Player";
wc.lpszMenuName = NULL;
RegisterClass(&wc);
hWnd = CreateWindow("MPlayer - The Movie Player",
title,
WS_OVERLAPPEDWINDOW| WS_SIZEBOX,
rd.left,
rd.top,
rd.right - rd.left,
rd.bottom - rd.top,
NULL,
NULL,
hInstance,
NULL);
wc.hbrBackground = CreateSolidBrush(RGB(0,0,0));
wc.lpszClassName = "MPlayer - Fullscreen";
RegisterClass(&wc);
hWndFS = CreateWindow("MPlayer - Fullscreen","MPlayer VIDIX Fullscreen",WS_POPUP,0,0,vo_screenwidth,vo_screenheight,hWnd,NULL,hInstance,NULL);
}
ShowWindow(hWnd,SW_SHOW);
if(vo_fs)ShowWindow(hWndFS,SW_SHOW);
return(0);
}
示例5: BeginPaint
LRESULT CFrameHolder::OnPaint(HWND hWnd, HDC hdc, UINT uMsg)
{
if (hdc == NULL)
{
LRESULT lRc = 0;
PAINTSTRUCT ps = {0};
hdc = BeginPaint(hWnd, &ps);
if (hdc != NULL)
{
lRc = OnPaint(hWnd, hdc, uMsg);
EndPaint(hWnd, &ps);
}
else
{
_ASSERTE(hdc != NULL);
}
return lRc;
}
#ifdef _DEBUG
RECT rcClientReal = {}; GetClientRect(hWnd, &rcClientReal);
MapWindowPoints(hWnd, NULL, (LPPOINT)&rcClientReal, 2);
#endif
// Если "завис" PostUpdate
if (gpConEmu->mp_TabBar->NeedPostUpdate())
gpConEmu->mp_TabBar->Update();
// Go
RECT wr, cr;
RecalculateFrameSizes();
wr = gpConEmu->GetGuiClientRect();
#ifdef _DEBUG
wchar_t szPaint[140];
_wsprintf(szPaint, SKIPCOUNT(szPaint) L"MainClient %s at {%i,%i}-{%i,%i} screen coords, size (%ix%i) calc (%ix%i)",
(uMsg == WM_PAINT) ? L"WM_PAINT" : (uMsg == WM_PRINTCLIENT) ? L"WM_PRINTCLIENT" : L"UnknownMsg",
LOGRECTCOORDS(rcClientReal), LOGRECTSIZE(rcClientReal), LOGRECTSIZE(wr));
DEBUGSTRPAINT(szPaint);
#endif
#if defined(CONEMU_TABBAR_EX)
#ifdef RED_CLIENT_FILL
HBRUSH h = CreateSolidBrush(RGB(255,0,0));
FillRect(hdc, &wr, h);
DeleteObject(h);
return 0;
#endif
#endif
if (gpSet->isStatusBarShow)
{
int nHeight = gpSet->StatusBarHeight();
if (nHeight < (wr.bottom - wr.top))
{
RECT rcStatus = {wr.left, wr.bottom - nHeight, wr.right, wr.bottom};
gpConEmu->mp_Status->PaintStatus(hdc, &rcStatus);
wr.bottom = rcStatus.top;
}
}
cr = wr;
DEBUGTEST(FrameDrawStyle dt = gpConEmu->DrawType());
#if defined(CONEMU_TABBAR_EX)
RECT tr = {};
if (!gpSet->isTabsInCaption)
{
_ASSERTE(gpConEmu->GetDwmClientRectTopOffset() == 0); // CheckIt, must be zero
if (gpSet->isTabs)
{
RECT captrect = gpConEmu->CalcRect(CER_TAB, wr, CER_MAINCLIENT);
//CalculateCaptionPosition(cr, &captrect);
CalculateTabPosition(cr, captrect, &tr);
PaintDC dc = {false};
RECT pr = {captrect.left, 0, captrect.right, captrect.bottom};
gpConEmu->BeginBufferedPaint(hdc, pr, dc);
gpConEmu->mp_TabBar->PaintTabs(dc, captrect, tr);
gpConEmu->EndBufferedPaint(dc, TRUE);
}
}
else if (dt == fdt_Aero || dt == fdt_Win8)
{
_ASSERTE(gpSet->isTabsInCaption);
int nOffset = gpConEmu->GetDwmClientRectTopOffset();
//.........這裏部分代碼省略.........
示例6: myWindowProc
//.........這裏部分代碼省略.........
goto mousemove;
}
break;
case WM_MOUSEMOVE:
g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
priv = (winPriv *)g->priv;
if ((coord_t)HIWORD(lParam) >= GDISP_SCREEN_HEIGHT)
break;
mousemove:
priv->mousex = (coord_t)LOWORD(lParam);
priv->mousey = (coord_t)HIWORD(lParam);
if ((gmvmt(priv->mouse)->d.flags & GMOUSE_VFLG_NOPOLL)) // For normal setup this is always TRUE
_gmouseWakeup(priv->mouse);
break;
#endif
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
case WM_SYSKEYUP:
case WM_KEYUP:
break;
case WM_CHAR:
case WM_DEADCHAR:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
break;
case WM_ERASEBKGND:
// Pretend we have erased the background.
// We know we don't really need to do this as we
// redraw the entire surface in the WM_PAINT handler.
return TRUE;
case WM_PAINT:
// Get our GDisplay structure
g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
priv = (winPriv *)g->priv;
// Paint the main window area
WaitForSingleObject(drawMutex, INFINITE);
dc = BeginPaint(hWnd, &ps);
BitBlt(dc, ps.rcPaint.left, ps.rcPaint.top,
ps.rcPaint.right - ps.rcPaint.left,
(ps.rcPaint.bottom > GDISP_SCREEN_HEIGHT ? GDISP_SCREEN_HEIGHT : ps.rcPaint.bottom) - ps.rcPaint.top,
priv->dcBuffer, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);
// Paint the toggle area
#if GINPUT_NEED_TOGGLE
if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) {
pen = CreatePen(PS_SOLID, 1, gdispColor2Native(Black));
hbrOn = CreateSolidBrush(gdispColor2Native(Blue));
hbrOff = CreateSolidBrush(gdispColor2Native(Gray));
old = SelectObject(dc, pen);
MoveToEx(dc, 0, GDISP_SCREEN_HEIGHT, &p);
LineTo(dc, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT);
for(pos = 0, bit=1; pos < wWidth; pos=rect.right, bit <<= 1) {
rect.left = pos;
rect.right = pos + GDISP_SCREEN_WIDTH/8;
rect.top = GDISP_SCREEN_HEIGHT;
rect.bottom = GDISP_SCREEN_HEIGHT + WIN32_BUTTON_AREA;
FillRect(dc, &rect, (priv->toggles & bit) ? hbrOn : hbrOff);
if (pos > 0) {
MoveToEx(dc, rect.left, rect.top, &p);
LineTo(dc, rect.left, rect.bottom);
}
}
DeleteObject(hbrOn);
DeleteObject(hbrOff);
SelectObject(dc, old);
}
#endif
EndPaint(hWnd, &ps);
ReleaseMutex(drawMutex);
break;
case WM_DESTROY:
// Get our GDisplay structure
g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
priv = (winPriv *)g->priv;
// Restore the window and free our bitmaps
SelectObject(priv->dcBuffer, priv->dcOldBitmap);
DeleteDC(priv->dcBuffer);
DeleteObject(priv->dcBitmap);
// Cleanup the private area
gfxFree(priv);
// Quit the application
PostQuitMessage(0);
// Actually the above doesn't work (who knows why)
ExitProcess(0);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
示例7: switch
BOOL CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
int nColor;
for (nColor = 0 ; nColor < int(sizeof(colourItems)/sizeof(DWORD)) ; nColor++)
{
::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_ADDSTRING, nColor, (LPARAM) "");
::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETITEMDATA , nColor, (LPARAM) colourItems[nColor]);
//if (g_bgColor == colourItems[nColor])
//::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETCURSEL, nColor, 0);
}
//::SetCapture(_hSelf);
return TRUE;
}
case WM_CTLCOLORLISTBOX:
return (LRESULT) CreateSolidBrush(GetSysColor(COLOR_3DFACE));
case WM_DRAWITEM:
{
HDC hdc;
COLORREF cr;
HBRUSH hbrush;
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
hdc = pdis->hDC;
RECT rc = pdis->rcItem;
// Transparent.
SetBkMode(hdc,TRANSPARENT);
// NULL object
if (pdis->itemID == UINT(-1)) return 0;
switch (pdis->itemAction)
{
case ODA_DRAWENTIRE:
switch (pdis->CtlID)
{
case IDC_COLOUR_LIST:
rc = pdis->rcItem;
cr = (COLORREF) pdis->itemData;
InflateRect(&rc, -3, -3);
hbrush = CreateSolidBrush((COLORREF)cr);
FillRect(hdc, &rc, hbrush);
DeleteObject(hbrush);
FrameRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH));
break;
NO_DEFAULT_CASE;
}
// *** FALL THROUGH ***
//lint -fallthrough
case ODA_SELECT:
rc = pdis->rcItem;
if (pdis->itemState & ODS_SELECTED)
{
rc.bottom --;
rc.right --;
// Draw the lighted side.
HPEN hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
HPEN holdPen = (HPEN)SelectObject(hdc, hpen);
MoveToEx(hdc, rc.left, rc.bottom, NULL);
LineTo(hdc, rc.left, rc.top);
LineTo(hdc, rc.right, rc.top);
SelectObject(hdc, holdPen);
DeleteObject(hpen);
// Draw the darkened side.
hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
holdPen = (HPEN)SelectObject(hdc, hpen);
LineTo(hdc, rc.right, rc.bottom);
LineTo(hdc, rc.left, rc.bottom);
SelectObject(hdc, holdPen);
DeleteObject(hpen);
}
else
{
hbrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
FrameRect(hdc, &rc, hbrush);
DeleteObject(hbrush);
}
break;
case ODA_FOCUS:
rc = pdis->rcItem;
InflateRect(&rc, -2, -2);
DrawFocusRect(hdc, &rc);
break;
default:
break;
}
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
//.........這裏部分代碼省略.........
示例8: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
WORD x, y;
HBRUSH hOldBrush, hNewBrush;
x = LOWORD(lParam);
y = HIWORD(lParam);
switch (message) {
case WM_LBUTTONUP:
color[0] = false;
color[1] = false;
color[2] = false;
color[3] = false;
InvalidateRect(hWnd, NULL, TRUE);
break;
case WM_LBUTTONDOWN:
if(x >= 177 && x <= 257 && y >= 61 && y <= 140)
color[0] = true;
if(x >= 256 && x <= 335 && y >= 61 && y <= 141)
color[1] = true;
if(x >= 177 && x <= 257 && y >= 139 && y <= 219)
color[2] = true;
if(x >= 256 && x <= 335 && y >= 140 && y <= 219)
color[3] = true;
InvalidateRect(hWnd, NULL, TRUE);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
if(color[0]) {
hNewBrush = CreateSolidBrush(RGB(0, 255, 0));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
}
MoveToEx(hdc, 177, 61, NULL);
Rectangle(hdc, 177, 61, 257, 140);
hNewBrush = CreateSolidBrush(RGB(255, 255, 255));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
if(color[1]) {
hNewBrush = CreateSolidBrush(RGB(0, 0, 255));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
}
MoveToEx(hdc, 256, 61, NULL);
Rectangle(hdc, 256, 61, 335, 141);
hNewBrush = CreateSolidBrush(RGB(255, 255, 255));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
if(color[2]) {
hNewBrush = CreateSolidBrush(RGB(255, 0, 0));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
}
MoveToEx(hdc, 177, 139, NULL);
Rectangle(hdc, 177, 139, 257, 219);
hNewBrush = CreateSolidBrush(RGB(255, 255, 255));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
if(color[3]) {
hNewBrush = CreateSolidBrush(RGB(255, 255, 0));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
}
MoveToEx(hdc, 256, 140, NULL);
Rectangle(hdc, 256, 140, 335, 219);
hNewBrush = CreateSolidBrush(RGB(255, 255, 255));
hOldBrush = (HBRUSH) SelectObject(hdc, hNewBrush);
TextOut(hdc, 200, 256, "Your turn...", 12);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
示例9: WindowProcedure
//.........這裏部分代碼省略.........
textFlagGreen = true;
textFlagBlue = false;
textFlagRed = false;
InvalidateRect(textArea2, NULL, TRUE);
break;
}
case IDC_BUTTON5:
{
textFlagBlue = true;
textFlagRed = false;
textFlagGreen = false;
InvalidateRect(textArea2, NULL, TRUE);
break;
}
}
break;
case WM_SYSCOMMAND:
{
switch(wParam)
{
case SC_MINIMIZE:
{
srand(time(NULL));
a = rand() % 255 + 1;
b = rand() % 255 + 1;
c = rand() % 255 + 1;
backgFlag = true;
if(backgFlag == true)
{
SetClassLong(hwnd, GCL_HBRBACKGROUND, (LONG)CreateSolidBrush(RGB(a, b, c)));
}
InvalidateRect(hwnd, NULL, TRUE);
break;
}
case SC_MAXIMIZE:
{
double i = 20;
while (i < 330)
{
SetWindowPos(hwnd, HWND_TOP, 411, i,544, 375, SWP_SHOWWINDOW);
i = i + 0.1;
}
while (i > 20)
{
SetWindowPos(hwnd, HWND_TOP, 411, i,544, 375, SWP_SHOWWINDOW);
i = i - 0.1;
}
break;
}
case SC_CLOSE:
{
if(MessageBox(hwnd, "Do you want to close the program?", "Alert", MB_YESNO) == IDYES)
{
exit(1);
}
break;
}
示例10: ConWndProc
static LRESULT CALLBACK ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
static bool s_timePolarity;
switch (uMsg) {
case WM_ACTIVATE:
if ( LOWORD( wParam ) != WA_INACTIVE ) {
SetFocus( s_wcd.hwndInputLine );
}
break;
case WM_CLOSE:
if ( cvarSystem->IsInitialized() && com_skipRenderer.GetBool() ) {
cmdSystem->BufferCommandText(CMD_EXEC_APPEND, "quit\n");
} else if ( s_wcd.quitOnClose ) {
PostQuitMessage( 0 );
} else {
Sys_ShowConsole( 0, false );
win32.win_viewlog.SetBool( false );
}
return 0;
case WM_CTLCOLORSTATIC:
if ( ( HWND ) lParam == s_wcd.hwndBuffer ) {
SetBkColor( ( HDC ) wParam, RGB( 0x00, 0x00, 0x80 ) );
SetTextColor( ( HDC ) wParam, RGB( 0xff, 0xff, 0x00 ) );
return ( LRESULT ) s_wcd.hbrEditBackground;
} else if ( ( HWND ) lParam == s_wcd.hwndErrorBox ) {
if ( s_timePolarity & 1 ) {
SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
SetTextColor( ( HDC ) wParam, RGB( 0xff, 0x0, 0x00 ) );
} else {
SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
SetTextColor( ( HDC ) wParam, RGB( 0x00, 0x0, 0x00 ) );
}
return ( LRESULT ) s_wcd.hbrErrorBackground;
}
break;
case WM_SYSCOMMAND:
if ( wParam == SC_CLOSE ) {
PostQuitMessage( 0 );
}
break;
case WM_COMMAND:
if ( wParam == COPY_ID ) {
SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
SendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 );
} else if ( wParam == QUIT_ID ) {
if ( s_wcd.quitOnClose ) {
PostQuitMessage( 0 );
} else {
cmdSystem->BufferCommandText(CMD_EXEC_APPEND, "quit\n");
}
} else if ( wParam == CLEAR_ID ) {
SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, FALSE, ( LPARAM ) "" );
UpdateWindow( s_wcd.hwndBuffer );
}
break;
case WM_CREATE:
s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x00, 0x00, 0x80 ) );
s_wcd.hbrErrorBackground = CreateSolidBrush( RGB( 0x80, 0x80, 0x80 ) );
SetTimer( hWnd, 1, 1000, NULL );
break;
/*
case WM_ERASEBKGND:
HGDIOBJ oldObject;
HDC hdcScaled;
hdcScaled = CreateCompatibleDC( ( HDC ) wParam );
assert( hdcScaled != 0 );
if ( hdcScaled ) {
oldObject = SelectObject( ( HDC ) hdcScaled, s_wcd.hbmLogo );
assert( oldObject != 0 );
if ( oldObject )
{
StretchBlt( ( HDC ) wParam, 0, 0, s_wcd.windowWidth, s_wcd.windowHeight,
hdcScaled, 0, 0, 512, 384,
SRCCOPY );
}
DeleteDC( hdcScaled );
hdcScaled = 0;
}
return 1;
*/
case WM_TIMER:
if ( wParam == 1 ) {
s_timePolarity = (bool)!s_timePolarity;
if ( s_wcd.hwndErrorBox ) {
InvalidateRect( s_wcd.hwndErrorBox, NULL, FALSE );
}
}
break;
}
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
示例11: CreateRadioImages
// ImageList_Destroy() the return value
// refresh on WM_THEMECHANGED
static HIMAGELIST CreateRadioImages(COLORREF clrBk, COLORREF clrText)
{
/* draw bitmap */
HDC hdcScreen = GetDC(NULL);
if (hdcScreen == NULL)
return NULL;
HIMAGELIST himl = NULL;
HDC hdc = CreateCompatibleDC(NULL); /* compatible to screen */
if (hdc != NULL) {
SIZE size = { GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON) };
RECT rc;
SetRect(&rc, 0, 0, 2 * size.cx, size.cy);
HBITMAP hbm = CreateCompatibleBitmap(hdcScreen, rc.right, rc.bottom);
if (hbm != NULL) {
HBITMAP hbmPrev = (HBITMAP)SelectObject(hdc, hbm);
if (hbmPrev != NULL) { /* error on select? */
HTHEME hTheme = OpenThemeData(NULL, L"Button");
SetRect(&rc, 0, 0, size.cx, size.cy);
/* unchecked */
if (!DrawThemeBackground(hTheme, hdc, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL, &rc, NULL)) {
/* checked */
OffsetRect(&rc, size.cx, 0);
if (!DrawThemeBackground(hTheme, hdc, BP_RADIOBUTTON, RBS_CHECKEDNORMAL, &rc, NULL))
himl = ImageList_Create(size.cx, size.cy, ILC_COLOR32 | ILC_MASK, 3, 0);
}
CloseThemeData(hTheme);
/* the classic way */
if (himl == NULL) {
RECT rcRadio;
HBRUSH hbrBk = CreateSolidBrush(clrBk);
if (hbrBk != NULL) {
FillRect(hdc, &rc, hbrBk);
DeleteObject(hbrBk);
HDC hdcMono = CreateCompatibleDC(hdc);
if (hdcMono != NULL) {
HBITMAP hbmMono = CreateBitmap(rc.right, rc.bottom, 1, 1, NULL);
if (hbmMono != NULL) {
HBITMAP hbmPrevMono = (HBITMAP)SelectObject(hdcMono, hbmMono);
if (hbmPrevMono != NULL) { /* error on select? */
/* draws a black-and-white mask (see docs)
* we need to colorize it using BitBlt with text and background color */
COLORREF clrPrevText = SetTextColor(hdc, clrText);
COLORREF clrPrevBk = SetBkColor(hdc, clrBk);
/* check mark is slightly smaller than icon size */
SetRect(&rcRadio, 0, 0, GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK));
if (rcRadio.right > size.cx) rcRadio.right = size.cx;
if (rcRadio.bottom > size.cy) rcRadio.bottom = size.cy;
SetRect(&rc, ((size.cx - rcRadio.right) / 2) + 1, ((size.cy - rcRadio.bottom) / 2) + 1, rcRadio.right + 1, rcRadio.bottom + 1);
/* unchecked */
if (BitBlt(hdcMono, 0, 0, rcRadio.right, rcRadio.bottom, NULL, 0, 0, WHITENESS)) { /* white back */
if (DrawFrameControl(hdcMono, &rcRadio, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_FLAT)) {
if (BitBlt(hdc, rc.left, rc.top, rcRadio.right, rcRadio.bottom, hdcMono, 0, 0, SRCCOPY | NOMIRRORBITMAP)) {
/* checked */
OffsetRect(&rc, size.cx, 0);
if (BitBlt(hdcMono, 0, 0, rcRadio.right, rcRadio.bottom, NULL, 0, 0, WHITENESS)) {/* white back */
if (DrawFrameControl(hdcMono, &rcRadio, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_FLAT | DFCS_CHECKED)) {
if (BitBlt(hdc, rc.left, rc.top, rcRadio.right, rcRadio.bottom, hdcMono, 0, 0, SRCCOPY | NOMIRRORBITMAP))
himl = ImageList_Create(size.cx, size.cy, ILC_COLOR | ILC_MASK, 3, 0);
}
else BOX("second DrawFrameControl() failed");
}
else BOX("second BitBlt() failed");
}
else BOX("intermediate BitBlt() failed");
}
else BOX("DrawFrameControl() failed");
}
else BOX("first BitBlt() failed");
/* restore */
SetBkColor(hdc, clrPrevBk);
SetTextColor(hdc, clrPrevText);
SelectObject(hdcMono, hbmPrevMono);
}
else BOX("hbmPrevMono == NULL");
DeleteObject(hbmMono);
}
else BOX("hbmMono == NULL");
DeleteDC(hdcMono);
}
else BOX("hdcMono == NULL");
}
}
SelectObject(hdc, hbmPrev);
/* create imagelist */
if (himl != NULL) {
if (himl == NULL) BOX("img list create failed");
if (himl != NULL) if (ImageList_AddMasked(himl, hbm, clrBk) == -1) BOX("add failed");
}
else BOX("Win9x: drawing code not reached");
}
DeleteObject(hbm);
}
DeleteDC(hdc);
}
ReleaseDC(NULL, hdcScreen);
return himl;
//.........這裏部分代碼省略.........
示例12: BeginPaint
void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
{
if (!debugger->isAlive()) return;
PAINTSTRUCT ps;
HDC actualHdc = BeginPaint(wnd, &ps);
HDC hdc = CreateCompatibleDC(actualHdc);
HBITMAP hBM = CreateCompatibleBitmap(actualHdc, rect.right-rect.left, rect.bottom-rect.top);
SelectObject(hdc, hBM);
SetBkMode(hdc, TRANSPARENT);
HPEN nullPen=CreatePen(0,0,0xffffff);
HBRUSH nullBrush=CreateSolidBrush(0xffffff);
HBRUSH currentBrush=CreateSolidBrush(0xffefe8);
HPEN oldPen=(HPEN)SelectObject(hdc,nullPen);
HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush);
HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font);
HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOP);
HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOPDISABLE);
unsigned int address = windowStart;
std::map<u32,int> addressPositions;
const std::set<std::string> currentArguments = getSelectedLineArguments();
DisassemblyLineInfo line;
for (int i = 0; i < visibleRows; i++)
{
manager.getLine(address,displaySymbols,line);
int rowY1 = rowHeight*i;
int rowY2 = rowHeight*(i+1);
addressPositions[address] = rowY1;
// draw background
COLORREF backgroundColor = whiteBackground ? 0xFFFFFF : debugger->getColor(address);
COLORREF textColor = 0x000000;
if (isInInterval(address,line.totalSize,debugger->getPC()))
{
backgroundColor = scaleColor(backgroundColor,1.05f);
}
if (address >= selectRangeStart && address < selectRangeEnd && searching == false)
{
if (hasFocus)
{
backgroundColor = address == curAddress ? 0xFF8822 : 0xFF9933;
textColor = 0xFFFFFF;
} else {
backgroundColor = 0xC0C0C0;
}
}
HBRUSH backgroundBrush = CreateSolidBrush(backgroundColor);
HPEN backgroundPen = CreatePen(0,0,backgroundColor);
SelectObject(hdc,backgroundBrush);
SelectObject(hdc,backgroundPen);
Rectangle(hdc,0,rowY1,rect.right,rowY1+rowHeight);
SelectObject(hdc,currentBrush);
SelectObject(hdc,nullPen);
DeleteObject(backgroundBrush);
DeleteObject(backgroundPen);
// display address/symbol
bool enabled;
if (CBreakPoints::IsAddressBreakPoint(address,&enabled))
{
if (enabled) textColor = 0x0000FF;
int yOffset = max(-1,(rowHeight-14+1)/2);
if (!enabled) yOffset++;
DrawIconEx(hdc,2,rowY1+1+yOffset,enabled ? breakPoint : breakPointDisable,32,32,0,0,DI_NORMAL);
}
SetTextColor(hdc,textColor);
char addressText[64];
getDisasmAddressText(address,addressText,true,line.type == DISTYPE_OPCODE);
TextOutA(hdc,pixelPositions.addressStart,rowY1+2,addressText,(int)strlen(addressText));
if (isInInterval(address,line.totalSize,debugger->getPC()))
{
TextOut(hdc,pixelPositions.opcodeStart-8,rowY1,L"■",1);
}
// display whether the condition of a branch is met
if (line.info.isConditional && address == debugger->getPC())
{
line.params += line.info.conditionMet ? " ; true" : " ; false";
}
drawArguments(hdc, line, pixelPositions.argumentsStart, rowY1 + 2, textColor, currentArguments);
SelectObject(hdc,boldfont);
TextOutA(hdc,pixelPositions.opcodeStart,rowY1+2,line.name.c_str(),(int)line.name.size());
SelectObject(hdc,font);
//.........這裏部分代碼省略.........
示例13: TRACE
//.........這裏部分代碼省略.........
TCHAR *pszText1 = new TCHAR [m_nMaxText+1];
memset(pszText1, 0, (m_nMaxText+1)*sizeof(TCHAR));
if (pXHDS->pszAnchor)
delete [] pXHDS->pszAnchor;
pXHDS->pszAnchor = NULL;
pXHDS->bHasAnchor = FALSE;
pXHDS->bAnchorIsUnderlined = FALSE;
BOOL bInAnchor = FALSE;
int n = (int) _tcslen(pszText); // n must be int
int i = 0;
int nWidth = 0;
pXHDS->bHasAnchor = FALSE;
pXHDS->nRightX = 0;
COLORREF crText = pXHDS->crText;
if (crText == COLOR_NONE)
crText = GetSysColor(COLOR_WINDOWTEXT);
COLORREF crBackground = pXHDS->crBackground;
if (crBackground == COLOR_NONE)
crBackground = GetSysColor(COLOR_WINDOW);
COLORREF crTextNew = crText;
COLORREF crBkgndNew = crBackground;
// if no transparency, fill entire rect with default bg color
if (!pXHDS->bTransparent)
{
HBRUSH hbrush = CreateSolidBrush(crBkgndNew);
_ASSERTE(hbrush);
FillRect(hMemDC, &rectText, hbrush);
if (hbrush)
DeleteObject(hbrush);
}
BOOL bBold = pXHDS->bBold;
BOOL bItalic = pXHDS->bItalic;
BOOL bUnderline = pXHDS->bUnderline;
BOOL bStrikeThrough = pXHDS->bStrikeThrough;
BOOL bSubscript = FALSE;
BOOL bSuperscript = FALSE;
int nSizeChange = 0;
// replace character entity names in text with codes ------------
TCHAR ent[3] = { _T('\0') };
ent[0] = _T('\001'); // each entity name is replaced with a two-character
// code that begins with \001
BOOL bCharacterEntities = FALSE; // assume no char entities
// we are replacing character entites with a two-character sequence,
// so the resulting string will be shorter
size_t buflen = _tcslen(pszText) + 100;
TCHAR *buf = new TCHAR [buflen];
memset(buf, 0, buflen*sizeof(TCHAR));
for (i = 0; m_aCharEntities[i].pszName != NULL; i++)
{
ent[1] = m_aCharEntities[i].cCode;
int nRep = _tcsistrrep(pszText, m_aCharEntities[i].pszName, ent, buf);
示例14: AboutBoxProc
DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
{
static HBITMAP hbmpBackgroundTop = NULL;
static HFONT hPageHeadingFont = NULL;
static HFONT hTextFont = NULL;
static HFONT hAuthorFont = NULL;
switch (uMsg) {
case WM_INITDIALOG:
{
//Title
SetWindowTextW(hWnd, GS(PLUG_ABOUT));
// Use the size of the image
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO));
BITMAP bmTL;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold");
SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE);
SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE);
SendDlgItemMessage(hWnd, IDC_THANKS, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE);
SendDlgItemMessage(hWnd, IDC_ZILMAR, WM_SETFONT, (WPARAM)hAuthorFont, TRUE);
SendDlgItemMessage(hWnd, IDC_JABO, WM_SETFONT, (WPARAM)hAuthorFont, TRUE);
SendDlgItemMessage(hWnd, IDC_SMIFF, WM_SETFONT, (WPARAM)hAuthorFont, TRUE);
SendDlgItemMessage(hWnd, IDC_GENT, WM_SETFONT, (WPARAM)hAuthorFont, TRUE);
SendDlgItemMessage(hWnd, IDC_ZILMAR_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE);
SendDlgItemMessage(hWnd, IDC_JABO_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE);
SendDlgItemMessage(hWnd, IDC_SMIFF_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE);
SendDlgItemMessage(hWnd, IDC_GENT_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE);
SendDlgItemMessage(hWnd, IDC_THANK_LIST, WM_SETFONT, (WPARAM)hTextFont, TRUE);
stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR);
SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str());
}
break;
case WM_CTLCOLORSTATIC:
{
HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(0, 0, 0));
SetBkMode(hdcStatic, TRANSPARENT);
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
}
break;
case WM_ERASEBKGND:
{
HPEN outline;
HBRUSH fill;
RECT rect;
outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
fill = CreateSolidBrush(0x00FFFFFF);
SelectObject((HDC)wParam, outline);
SelectObject((HDC)wParam, fill);
GetClientRect(hWnd, &rect);
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
if (BeginPaint(hWnd, &ps))
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
BITMAP bmTL_top;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
EndPaint(hWnd, &ps);
}
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
if (hbmpBackgroundTop)
{
DeleteObject(hbmpBackgroundTop);
}
if (hTextFont)
//.........這裏部分代碼省略.........
示例15: CreatePen
Cgdi::Cgdi()
{
m_BlackPen = CreatePen(PS_SOLID, 1, colors[black]);
m_WhitePen = CreatePen(PS_SOLID, 1, colors[white]);
m_RedPen = CreatePen(PS_SOLID, 1, colors[red]);
m_GreenPen = CreatePen(PS_SOLID, 1, colors[green]);
m_BluePen = CreatePen(PS_SOLID, 1, colors[blue]);
m_GreyPen = CreatePen(PS_SOLID, 1, colors[grey]);
m_PinkPen = CreatePen(PS_SOLID, 1, colors[pink]);
m_YellowPen = CreatePen(PS_SOLID, 1, colors[yellow]);
m_OrangePen = CreatePen(PS_SOLID, 1, colors[orange]);
m_PurplePen = CreatePen(PS_SOLID, 1, colors[purple]);
m_BrownPen = CreatePen(PS_SOLID, 1, colors[brown]);
m_DarkGreenPen = CreatePen(PS_SOLID, 1, colors[dark_green]);
m_LightBluePen = CreatePen(PS_SOLID, 1, colors[light_blue]);
m_LightGreyPen = CreatePen(PS_SOLID, 1, colors[light_grey]);
m_LightPinkPen = CreatePen(PS_SOLID, 1, colors[light_pink]);
m_ThickBlackPen = CreatePen(PS_SOLID, 2, colors[black]);
m_ThickWhitePen = CreatePen(PS_SOLID, 2, colors[white]);
m_ThickRedPen = CreatePen(PS_SOLID, 2, colors[red]);
m_ThickGreenPen = CreatePen(PS_SOLID, 2, colors[green]);
m_ThickBluePen = CreatePen(PS_SOLID, 2, colors[blue]);
m_GreenBrush = CreateSolidBrush(colors[green]);
m_RedBrush = CreateSolidBrush(colors[red]);
m_BlueBrush = CreateSolidBrush(colors[blue]);
m_GreyBrush = CreateSolidBrush(colors[grey]);
m_BrownBrush = CreateSolidBrush(colors[brown]);
m_YellowBrush = CreateSolidBrush(colors[yellow]);
m_LightBlueBrush = CreateSolidBrush(colors[light_blue]);
m_DarkGreenBrush = CreateSolidBrush(colors[dark_green]);
m_OrangeBrush = CreateSolidBrush(colors[orange]);
m_PurpleBrush = CreateSolidBrush(colors[purple]);
m_tmpPen = CreatePen(PS_SOLID,1,RGB(0,0,0));
m_tmpBrush = CreateSolidBrush(RGB(0,0,0));
m_hdc = NULL;
}