本文整理汇总了C++中GetWindowDC函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWindowDC函数的具体用法?C++ GetWindowDC怎么用?C++ GetWindowDC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetWindowDC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetWindowDC
// Windows-specific code to set the horizontal extent of the listbox, if
// necessary. If s is non-NULL, it's used to calculate the horizontal extent.
// Otherwise, all strings are used.
void wxListBox::SetHorizontalExtent(const wxString& s)
{
// Only necessary if we want a horizontal scrollbar
if (!(m_windowStyle & wxHSCROLL))
return;
TEXTMETRIC lpTextMetric;
if ( !s.empty() )
{
int existingExtent = (int)SendMessage(GetHwnd(), LB_GETHORIZONTALEXTENT, 0, 0L);
HDC dc = GetWindowDC(GetHwnd());
HFONT oldFont = 0;
if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
SIZE extentXY;
::GetTextExtentPoint32(dc, (LPTSTR) (const wxChar *)s, s.Length(), &extentXY);
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
if (oldFont)
::SelectObject(dc, oldFont);
ReleaseDC(GetHwnd(), dc);
if (extentX > existingExtent)
SendMessage(GetHwnd(), LB_SETHORIZONTALEXTENT, LOWORD(extentX), 0L);
}
else
{
int largestExtent = 0;
HDC dc = GetWindowDC(GetHwnd());
HFONT oldFont = 0;
if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
for (int i = 0; i < m_noItems; i++)
{
wxString str = GetString(i);
SIZE extentXY;
::GetTextExtentPoint32(dc, str.c_str(), str.length(), &extentXY);
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
if (extentX > largestExtent)
largestExtent = extentX;
}
if (oldFont)
::SelectObject(dc, oldFont);
ReleaseDC(GetHwnd(), dc);
SendMessage(GetHwnd(), LB_SETHORIZONTALEXTENT, LOWORD(largestExtent), 0L);
}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:56,代码来源:listbox.cpp
示例2: DrawGaugeBorder
// Draws a recessed border around the gauge
static void
DrawGaugeBorder(HWND hWnd)
{
HDC hDC = GetWindowDC(hWnd);
RECT rect;
int cx, cy;
HPEN hShadowPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
HGDIOBJ hOldPen;
GetWindowRect(hWnd, &rect);
cx = rect.right - rect.left;
cy = rect.bottom - rect.top;
// Draw a dark gray line segment
hOldPen = SelectObject(hDC, (HGDIOBJ)hShadowPen);
MoveToEx(hDC, 0, cy - 1, NULL);
LineTo(hDC, 0, 0);
LineTo(hDC, cx - 1, 0);
// Draw a white line segment
SelectObject(hDC, GetStockObject(WHITE_PEN));
MoveToEx(hDC, 0, cy - 1, NULL);
LineTo(hDC, cx - 1, cy - 1);
LineTo(hDC, cx - 1, 0);
SelectObject(hDC, hOldPen);
DeleteObject(hShadowPen);
ReleaseDC(hWnd, hDC);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:30,代码来源:xpnetHook.cpp
示例3: DrawMap
void DrawMap(HWND hWnd)
{
HDC hDc = GetWindowDC(hWnd);
HDC memDc = CreateCompatibleDC(NULL); //缓存DC
HBITMAP hBitMap = CreateCompatibleBitmap(hDc, 850, 650);
SelectObject(memDc, hBitMap);
//背景刷成绿色
HBRUSH hBrushBack = CreateSolidBrush(RGB(0, 255, 0));
RECT rectBack;
rectBack.top = 0;
rectBack.bottom = 650;
rectBack.left = 0;
rectBack.right = 850;
FillRect(memDc, &rectBack, hBrushBack);
DrawStoneAndBrike(memDc);
DrawMan(memDc);
BitBlt(hDc, 3, 25, 850, 650, memDc, 0, 0, SRCCOPY);//拷贝
DeleteObject(memDc);
DeleteObject(hBitMap);
DeleteObject(hBrushBack);
ReleaseDC(hWnd, hDc);
}
开发者ID:YangMingYu,项目名称:BomberMan,代码行数:28,代码来源:Bomberman.cpp
示例4: GetWindowDC
void CConfigMsgLogDlg::OnTimer(UINT nIDEvent)
{
if (nIDEvent == m_unDispUpdateTimerId)
{
static bool bSwitchDisplay = true;
CDC* pdc= GetWindowDC();
pdc->SetTextColor(RGB(253,153,4));
pdc->SetBkMode(TRANSPARENT);
if(bSwitchDisplay)
{
SetWindowText("");
pdc->DrawText(m_strCurrWndText,CRect(4,4,400,50),DT_END_ELLIPSIS);
bSwitchDisplay = false;
}
else
{
pdc->DrawText(m_strCurrWndText,CRect(4,4,400,50),DT_END_ELLIPSIS);
SetWindowText(m_strCurrWndText);
bSwitchDisplay = true;
}
ReleaseDC(pdc);
}
CDialog::OnTimer(nIDEvent);
}
开发者ID:BlackVodka,项目名称:busmaster,代码行数:25,代码来源:ConfigMsgLogDlg.cpp
示例5: CaptureWindow
HBITMAP CaptureWindow(HWND hWnd)
{
RECT wnd;
if ( ! GetWindowRect(hWnd, & wnd) )
return NULL;
HDC hDC = GetWindowDC(hWnd);
HBITMAP hBmp = CreateCompatibleBitmap(hDC, wnd.right - wnd.left, wnd.bottom - wnd.top);
if ( hBmp )
{
HDC hMemDC = CreateCompatibleDC(hDC);
HGDIOBJ hOld = SelectObject(hMemDC, hBmp);
BitBlt(hMemDC, 0, 0, wnd.right - wnd.left, wnd.bottom - wnd.top,
hDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hOld);
DeleteObject(hMemDC);
}
ReleaseDC(hWnd, hDC);
return hBmp;
}
开发者ID:b2kguga,项目名称:CodesAndNotes,代码行数:27,代码来源:Dib.cpp
示例6: aigisHwnd
bool CFrame::findColor(CPnt5* pnt5)
{
HWND hwnd = aigisHwnd();
if (!hwnd)
{
return false;
}
HDC hdc = GetWindowDC(hwnd);
if (!hdc)
{
return false;
}
bool bSame = true;
for (size_t i = 0; i < EPD_MAX; i++)
{
POINT pntTmp = pnt5->getPoint((E_POINT_DIRECTION)i);
COLORREF colorDefi = pnt5->getColor((E_POINT_DIRECTION)i);
COLORREF colorFind = GetPixel(hdc, pntTmp.x, pntTmp.y);
if (!CPnt5::isSameColor(colorDefi, colorFind ))
{
bSame = false;
break;
}
}
ReleaseDC(hwnd, hdc);
return bSame;
}
开发者ID:kpli,项目名称:AigisDmm,代码行数:29,代码来源:Frame.cpp
示例7: GetWindowDC
void IWindow::selectWindow()
{
hWndDC = GetWindowDC(hWnd);
hBufferDC = CreateCompatibleDC(hWndDC);
hWndBitmap = CreateCompatibleBitmap(hWndDC, wndWidth, wndHeight);
hWndBitmap = (HBITMAP)SelectObject(hBufferDC, hWndBitmap);
if(!BitBlt(hBufferDC, 0, 0, wndWidth, wndHeight, hWndDC, 0, 0, SRCCOPY)){
DWORD dwError = GetLastError();
_tprintf(_T("BitBlt: dwError = %i \n"), dwError);
}
if(hWndDC != NULL)
{
HPEN hPen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
hPen = (HPEN)SelectObject(hWndDC, hPen);
MoveToEx(hWndDC, 1, 1, NULL);
LineTo(hWndDC, wndWidth - 1, 1);
LineTo(hWndDC, wndWidth - 1, wndHeight - 1);
LineTo(hWndDC, 1, wndHeight - 1);
LineTo(hWndDC, 1, 1);
DeleteObject(SelectObject(hWndDC, hPen));
}
}
开发者ID:KostjaStern,项目名称:WinInfo,代码行数:26,代码来源:IWindow.cpp
示例8: ToolbarWndProc
LRESULT CALLBACK ToolbarWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_NOTIFY:
{
switch (((LPNMHDR) lParam)->code)
{
case TTN_GETDISPINFOA:
case TTN_GETDISPINFOW:
{
LPNMTTDISPINFO Info = (LPNMTTDISPINFO) lParam;
Info->hinst = GetModuleHandle(NULL);
Info->lpszText = MAKEINTRESOURCE(Info->hdr.idFrom);
break;
}
}
return 0;
}
case WM_NCPAINT:
{
RECT R;
GetWindowRect(hWnd, &R);
R.right -= R.left;
R.bottom -= R.top;
R.left = 0;
R.top = 0;
HDC DC = GetWindowDC(hWnd);
DrawEdge(DC, &R, EDGE_ETCHED, BF_RECT);
ReleaseDC(hWnd, DC);
return 0;
}
}
return CallWindowProc((WNDPROC)DefaultToolbarWndProc, hWnd, Msg, wParam, lParam);
}
开发者ID:Malbeth81,项目名称:lambda-html-editor,代码行数:35,代码来源:toolbar.cpp
示例9: GetWindowDC
void CttView::BsmLine(CPoint st, CPoint ed)
{
CDC* pDC = GetWindowDC();
COLORREF color = RGB(0,0,0);
int x,y;
int dx=(((ed.x-st.x)>0)<<1)-1;
int dy=(((ed.y-st.y)>0)<<1)-1; //算y的增量是1还是-1
//x若相等,则为横着的直线
if(ed.x==st.x){
int x=st.x, y=st.y;
while(y!=ed.y){
pDC->SetPixel(x,y,color);
y+=dy;
}
pDC->SetPixel(x,y,color);
return;
}
//斜率小于等于1 / 大于1
if(fabs((1.0*ed.y-st.y)/(1.0*ed.x-st.x)) <= 1.0){
if(st.x > ed.x)swap(st,ed); //将小的x放st、大的放ed
dy=(((ed.y-st.y)>0)<<1)-1;
x=st.x;
y=st.y;
int dtx=ed.x-st.x;
int dty=(ed.y-st.y)*dy;
int e=2*dty-dtx;
while(x!=ed.x || y!=ed.y){
pDC->SetPixel(x,y,color);
if(e>=0){
x++;
y+=dy;
e+=dty+dty-dtx-dtx;
}else{
x++;
e+=dty+dty;
}
}
}else{ //斜率大于1,则xy交换
if(st.y > ed.y)swap(st,ed); //将小的y放st、大的放ed
dx=(((ed.x-st.x)>0)<<1)-1;
x=st.x;
y=st.y;
int dtx=(ed.x-st.x)*dx;
int dty=ed.y-st.y;
int e=2*dtx-dty;
while(x!=ed.x || y!=ed.y){
pDC->SetPixel(x,y,color);
if(e>=0){
y++;
x+=dx;
e+=dtx+dtx-dty-dty;
}else{
y++;
e+=dtx+dtx;
}
}
}
pDC->SetPixel(x,y,color);
}
开发者ID:Yuiffy,项目名称:computer-graphics-,代码行数:60,代码来源:ttView.cpp
示例10: GetWindowDC
//-----------------------------------------------------------------------------
// Name: HighlightWindow (from MSDN Spy Sample)
// Object: highlight or unhightlight a window
// Parameters :
// in : HWND hwnd : target window handle
// BOOL fDraw : TRUE to draw, FALSE to clear
// Return : TRUE on success
//-----------------------------------------------------------------------------
void CSelectWindow::HighlightWindow( HWND hwnd, BOOL fDraw )
{
#define DINV 3
HDC hdc;
RECT rc;
BOOL bBorderOn;
bBorderOn = fDraw;
if (hwnd == NULL || !IsWindow(hwnd))
return;
hdc = GetWindowDC(hwnd);
GetWindowRect(hwnd, &rc);
OffsetRect(&rc, -rc.left, -rc.top);
if (!IsRectEmpty(&rc))
{
PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, DINV, DSTINVERT);
PatBlt(hdc, rc.left, rc.bottom - DINV, DINV,
-(rc.bottom - rc.top - 2 * DINV), DSTINVERT);
PatBlt(hdc, rc.right - DINV, rc.top + DINV, DINV,
rc.bottom - rc.top - 2 * DINV, DSTINVERT);
PatBlt(hdc, rc.right, rc.bottom - DINV, -(rc.right - rc.left),
DINV, DSTINVERT);
}
ReleaseDC(hwnd, hdc);
}
开发者ID:340211173,项目名称:hf-2011,代码行数:36,代码来源:SelectWindow.cpp
示例11: GetWindowDC
void CAboutDlg::OnNcPaint()
{
CDC* pDC = GetWindowDC();
CRect rc, rcCut,rcDraw;
GetWindowRect(&rc);
rcDraw.top = 0;
rcDraw.left = 0;
rcDraw.right = rc.Width() ;
rcDraw.bottom = rc.Height();
CRect rcClient;
GetClientRect(&rcClient);
ClientToScreen(&rcClient);
rcCut.left = rcClient.left - rc.left;
rcCut.right = rcClient.right - rc.left;
rcCut.top = rcClient.top - rc.top;
rcCut.bottom = rcClient.bottom - rc.top;
CRgn rgnCut,rgnResult;
rgnCut.CreateRectRgnIndirect(&rcCut);
rgnResult.CreateRectRgnIndirect(&rcDraw);
rgnResult.CombineRgn(&rgnResult,&rgnCut, RGN_XOR);
pDC->SelectClipRgn(&rgnResult);
pDC->FillSolidRect(rcDraw, RGB(0, 119, 158));
ReleaseDC(pDC);
}
开发者ID:ZuDame,项目名称:Smart3DCoating,代码行数:27,代码来源:DlgAbout.cpp
示例12: frame_draw_end
/*
* frame_draw_end - フレームの描画終了、フレームの最終位置を返す
*/
int frame_draw_end(const HWND hWnd)
{
HDC hdc;
int draw_cnt;
int ret;
if (frame_rect[0].left == 0 && frame_rect[0].right == 0 &&
frame_rect[0].top == 0 && frame_rect[0].bottom == 0) {
frame_free();
return -1;
}
// 前回描画分を消去
hdc = GetWindowDC(hWnd);
for (draw_cnt = 0;draw_cnt < FRAME_CNT;draw_cnt++) {
DrawFocusRect(hdc, (LPRECT)&frame_rect[draw_cnt]);
}
ReleaseDC(hWnd, hdc);
// 境界位置の取得
ret = frame_rect[0].left - GetSystemMetrics(SM_CXFRAME);
frame_free();
return ret;
}
开发者ID:tobynet,项目名称:clcl,代码行数:28,代码来源:Frame.c
示例13: GetWindowDC
FilteredListBox::FilteredListBox( DWORD dwStyle,int x,int y,int nWidth,int nHeigth,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance )
:ListBox(dwStyle | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS,WS_EX_CLIENTEDGE,x,y,nWidth,nHeigth,hWndParent,hMenu,hInstance)
{
HDC dc = GetWindowDC();
GetTextMetrics(dc,&m_TextMetrics);
ReleaseDC(dc);
}
开发者ID:AndrewBourgeois,项目名称:GWLP-R-Utils,代码行数:7,代码来源:FilteredListBox.cpp
示例14: GetWindowDC
// WM_MEASUREITEM handler
// Since we have owner drawn menus, we need to provide information about
// the menus back to Windows so it can layout the menubar appropriately.
BOOL cef_dark_window::HandleMeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
static wchar_t szMenuString[256] = L"";
if (lpMIS->CtlType == ODT_MENU) {
HDC dc = GetWindowDC();
HMENU menu = GetMenu();
int items = ::GetMenuItemCount(menu);
InitMenuFont();
HGDIOBJ fontOld = ::SelectObject(dc, mMenuFont);
::GetMenuString(menu, lpMIS->itemID, szMenuString, _countof(szMenuString), MF_BYCOMMAND);
RECT rectTemp;
SetRectEmpty(&rectTemp);
// Calc the size of this menu item
::DrawText(dc, szMenuString, ::wcslen(szMenuString), &rectTemp, DT_SINGLELINE|DT_CALCRECT);
lpMIS->itemHeight = ::RectHeight(rectTemp);
lpMIS->itemWidth = ::RectWidth(rectTemp);
::SelectObject(dc, fontOld);
ReleaseDC(dc);
return TRUE;
}
return FALSE;
}
开发者ID:MattSturgeon,项目名称:brackets-shell,代码行数:34,代码来源:cef_dark_window.cpp
示例15: WinMain
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int nCmdShow)
{
MSG msg;
HDC hdcWindow;
RegisterMyWindow(hInstance);
if (!InitialiseMyWindow(hInstance, nCmdShow))
return FALSE;
hdcWindow = GetWindowDC (Application.ghwnd);
Application.setBuffers();
while (Application.Running())
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
break;
TranslateMessage (&msg);
DispatchMessage (&msg);
}
else
{
Application.MainLoop();
}
}
Application.releaseResources();
return msg.wParam ;
}
开发者ID:Steelbadger,项目名称:theElements,代码行数:33,代码来源:Main.cpp
示例16: clearScreen
void clearScreen(){
HDC hdc = GetWindowDC(hwnd);
RECT rect = {155, 65, 300, 92};
HBRUSH brush = CreateSolidBrush(RGB(255, 255, 255));
FillRect(hdc, &rect, brush);
DeleteObject(brush);
}
开发者ID:kurlp00,项目名称:beslanguage,代码行数:7,代码来源:PL_ENVIRONMENT.c
示例17: DynamicStat
void CColorSlide::DynamicStat(ENUM_SLIDERSTATE aState)
{
if (m_nWidth <= 0)
{
return;
}
CDC* pDC =GetWindowDC();
if (pDC == NULL)
{
return;
}
pDC->SetBkColor(TRANSPARENT);
CRect lrcClientRect;
GetClientRect(lrcClientRect);
m_nWidth = lrcClientRect.Width();
lrcClientRect.bottom;
m_nHeight = lrcClientRect.Height();
CMemDC TempDC(pDC, CRect(lrcClientRect.left, lrcClientRect.top,lrcClientRect.right, lrcClientRect.bottom));
PaintBK(lrcClientRect,TempDC.GetSafeHdc());
if( m_SlideType != PERCENT_SLIDE )
DrawSlider(aState,lrcClientRect,TempDC.GetSafeHdc());
BitBlt(pDC->GetSafeHdc(),0,0,m_nWidth,m_nHeight,TempDC.GetSafeHdc(),0,0,SRCCOPY);
ReleaseDC(pDC);
}
开发者ID:2Dou,项目名称:PlayBox,代码行数:25,代码来源:ColorSlide.cpp
示例18: getRect
void App::render()
{
ProcessRunnable::Vec2 res;
ProcessRunnable* runnable = (ProcessRunnable*)mProcessRunnable;
if (runnable->isResumed())
res = runnable->get();
else
{
return;
}
const int bottomBoundary = m_height - 80;
RECT rect = getRect(0, 0, m_width, bottomBoundary);
int cx = (int)(res.x / 2);
int cy = (int)(res.y / 2);
int middleH = m_height / 2;
RECT rectPos = getRect(0 + cx, middleH - cy, 10 + cx, middleH + 10 - cy);
if (middleH - cy > (bottomBoundary - (rectPos.bottom - rectPos.top)))
{
runnable->stop();
return;
}
HDC hDC = GetWindowDC(mHwnd);
FillRect(hDC, &rect, (HBRUSH)(COLOR_WINDOW + 2));
Rectangle(hDC, rectPos.left, rectPos.top, rectPos.right, rectPos.bottom);
DeleteDC(hDC);
}
开发者ID:gtreumer,项目名称:PhysicCalculation,代码行数:31,代码来源:App.cpp
示例19: DefWndScreenshot
VOID FASTCALL
DefWndScreenshot(HWND hWnd)
{
RECT rect;
HDC hdc;
INT w;
INT h;
HBITMAP hbitmap;
HDC hdc2;
OpenClipboard(hWnd);
EmptyClipboard();
hdc = GetWindowDC(hWnd);
GetWindowRect(hWnd, &rect);
w = rect.right - rect.left;
h = rect.bottom - rect.top;
hbitmap = CreateCompatibleBitmap(hdc, w, h);
hdc2 = CreateCompatibleDC(hdc);
SelectObject(hdc2, hbitmap);
BitBlt(hdc2, 0, 0, w, h,
hdc, 0, 0,
SRCCOPY);
SetClipboardData(CF_BITMAP, hbitmap);
ReleaseDC(hWnd, hdc);
ReleaseDC(hWnd, hdc2);
CloseClipboard();
}
开发者ID:staring,项目名称:RosFE,代码行数:33,代码来源:defwnd.c
示例20: assert
//////////////////
// Create window DC, including non-client area.
//
WPNCWinDC::WPNCWinDC(WPWin *w)
{
assert(w);
win = w;
hdc = GetWindowDC((*win)());
assert(hdc);
}
开发者ID:1000copy,项目名称:Piero,代码行数:10,代码来源:WPGDI.CPP
注:本文中的GetWindowDC函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论