本文整理匯總了C++中DeleteObject函數的典型用法代碼示例。如果您正苦於以下問題:C++ DeleteObject函數的具體用法?C++ DeleteObject怎麽用?C++ DeleteObject使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DeleteObject函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetWindowDC
void NativeTextfieldWin::OnNCPaint(HRGN region)
{
if(!textfield_->draw_border())
{
return;
}
HDC hdc = GetWindowDC();
RECT window_rect;
GetWindowRect(&window_rect);
// Convert to be relative to 0x0.
::OffsetRect(&window_rect, -window_rect.left, -window_rect.top);
ExcludeClipRect(hdc,
window_rect.left+content_insets_.left(),
window_rect.top+content_insets_.top(),
window_rect.right-content_insets_.right(),
window_rect.bottom-content_insets_.bottom());
HBRUSH brush = CreateSolidBrush(bg_color_);
FillRect(hdc, &window_rect, brush);
DeleteObject(brush);
int part;
int state;
if(base::win::GetVersion() < base::win::VERSION_VISTA)
{
part = EP_EDITTEXT;
if(!textfield_->IsEnabled())
{
state = ETS_DISABLED;
}
else if(textfield_->read_only())
{
state = ETS_READONLY;
}
else if(!contains_mouse_)
{
state = ETS_NORMAL;
}
else
{
state = ETS_HOT;
}
}
else
{
part = EP_EDITBORDER_HVSCROLL;
if(!textfield_->IsEnabled())
{
state = EPSHV_DISABLED;
}
else if(GetFocus() == m_hWnd)
{
state = EPSHV_FOCUSED;
}
else if(contains_mouse_)
{
state = EPSHV_HOT;
}
else
{
state = EPSHV_NORMAL;
}
// Vista doesn't appear to have a unique state for readonly.
}
int classic_state =
(!textfield_->IsEnabled() || textfield_->read_only()) ? DFCS_INACTIVE : 0;
gfx::NativeThemeWin::instance()->PaintTextField(hdc, part, state, classic_state,
&window_rect, bg_color_, false, true);
// NOTE: I tried checking the transparent property of the theme and invoking
// drawParentBackground, but it didn't seem to make a difference.
ReleaseDC(hdc);
}
示例2: MainWindowProcedure
// Handles OS messages, is driven by the 'main loop' above.
LRESULT CALLBACK MainWindowProcedure(HWND windowHandle, UINT messageCode, WPARAM wParam, LPARAM lParam)
{
switch (messageCode) {
// On window creation.
case WM_CREATE:
DEBUG_OUT(TEXT("WM_CREATE message"));
// Start game loop timer.
DEBUG_VAL(TEXT("SetTimer()"), SetTimer(windowHandle, MAIN_CYCLE_TIMER_ID, MAIN_CYCLE_WAIT, NULL));
break;
// Upon redraw request or something else changing we draw the window.
case WM_PAINT:
{
PAINTSTRUCT paintJobStruct;
HDC deviceContextHandle = BeginPaint(windowHandle, &paintJobStruct);
HDC bufferDeviceContextHandle = CreateCompatibleDC(deviceContextHandle);
HBITMAP bufferBitmapHandle = CreateCompatibleBitmap(deviceContextHandle, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
HGDIOBJ oldBufferBitmapHandle = SelectObject(bufferDeviceContextHandle, bufferBitmapHandle);
Gdiplus::Graphics graphics(bufferDeviceContextHandle);
graphics.SetSmoothingMode(GRAPHICS_SMOOTHING_MODE);
DrawGame(graphics, *mainGameObject);
BitBlt(deviceContextHandle, 0, 0, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT, bufferDeviceContextHandle, 0, 0, SRCCOPY);
SelectObject(bufferDeviceContextHandle, oldBufferBitmapHandle);
DeleteDC(bufferDeviceContextHandle);
DeleteObject(bufferBitmapHandle);
EndPaint(windowHandle, &paintJobStruct);
}
break;
// When a user presses a key (can be triggered by auto-repeat).
case WM_KEYDOWN:
DEBUG_OUT(TEXT("WM_KEYDOWN message"));
DEBUG_VAL(TEXT("wParam"), wParam);
switch(wParam) {
case VK_LEFT:
case VK_UP:
case VK_RIGHT:
case VK_DOWN:
DEBUG_OUT(TEXT("Arrow key pressed"));
mainGameObject->Input(wParam);
}
break;
case WM_TIMER:
if (wParam == MAIN_CYCLE_TIMER_ID) {
// This is where the 'main game loop' kicks in. This line should be reached at a frequency of about 60Hz.
mainGameObject->Step(windowHandle);
RedrawWindow(windowHandle, NULL, NULL, RDW_INVALIDATE);
//InvalidateRect(windowHandle, NULL, TRUE);
//UpdateWindow(windowHandle);
}
break;
case WM_CLOSE:
DEBUG_OUT(TEXT("WM_CLOSE message"));
// Clean up Windows API objects and etc.
KillTimer(windowHandle, MAIN_CYCLE_TIMER_ID);
DestroyWindow(windowHandle);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(windowHandle, messageCode, wParam, lParam);
break;
}
return 0;
}
示例3: drawbmp
static void drawbmp(fz_context *ctx, fz_document *doc, fz_page *page, fz_display_list *list, int pagenum, fz_cookie *cookie)
{
float zoom;
fz_matrix ctm;
fz_irect ibounds;
fz_rect bounds, tbounds;
int w, h;
fz_device *dev;
HDC dc, dc_main;
RECT rc;
HBRUSH bg_brush;
HBITMAP hbmp;
BITMAPINFO bmi = { 0 };
int bmp_data_len;
unsigned char *bmp_data;
int as_tga = !strstr(output, ".bmp");
fz_bound_page(doc, page, &bounds);
zoom = resolution / 72;
fz_pre_scale(fz_rotate(&ctm, rotation), zoom, zoom);
tbounds = bounds;
fz_round_rect(&ibounds, fz_transform_rect(&tbounds, &ctm));
w = width;
h = height;
if (res_specified)
{
fz_round_rect(&ibounds, &tbounds);
if (w && ibounds.x1 - ibounds.x0 <= w)
w = 0;
if (h && ibounds.y1 - ibounds.y0 <= h)
h = 0;
}
if (w || h)
{
float scalex = w / (tbounds.x1 - tbounds.x0);
float scaley = h / (tbounds.y1 - tbounds.y0);
fz_matrix scale_mat;
if (w == 0)
scalex = fit ? 1.0f : scaley;
if (h == 0)
scaley = fit ? 1.0f : scalex;
if (!fit)
scalex = scaley = min(scalex, scaley);
fz_concat(&ctm, &ctm, fz_scale(&scale_mat, scalex, scaley));
tbounds = bounds;
fz_transform_rect(&tbounds, &ctm);
}
fz_round_rect(&ibounds, &tbounds);
fz_rect_from_irect(&tbounds, &ibounds);
w = ibounds.x1 - ibounds.x0;
h = ibounds.y1 - ibounds.y0;
dc_main = GetDC(NULL);
dc = CreateCompatibleDC(dc_main);
hbmp = CreateCompatibleBitmap(dc_main, w, h);
DeleteObject(SelectObject(dc, hbmp));
SetRect(&rc, 0, 0, w, h);
bg_brush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
FillRect(dc, &rc, bg_brush);
DeleteObject(bg_brush);
dev = fz_new_gdiplus_device(ctx, dc, &tbounds);
if (list)
fz_run_display_list(list, dev, &ctm, &tbounds, cookie);
else
fz_run_page(doc, page, dev, &ctm, cookie);
fz_free_device(dev);
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biWidth = w;
bmi.bmiHeader.biHeight = as_tga ? -h : h;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = as_tga ? 32 : 24;
bmi.bmiHeader.biCompression = BI_RGB;
bmp_data_len = as_tga ? w * h * 4 : ((w * 3 + 3) / 4) * 4 * h;
bmp_data = fz_malloc(ctx, bmp_data_len);
if (!GetDIBits(dc, hbmp, 0, h, bmp_data, &bmi, DIB_RGB_COLORS))
fz_throw(ctx, "cannot draw page %d in PDF file '%s'", pagenum, filename);
DeleteDC(dc);
ReleaseDC(NULL, dc_main);
DeleteObject(hbmp);
if (output)
{
char buf[512];
FILE *f;
sprintf(buf, output, pagenum);
f = fopen(buf, "wb");
if (!f)
fz_throw(ctx, "could not create raster file '%s'", buf);
if (as_tga)
{
//.........這裏部分代碼省略.........
示例4: GetTextMetrics
HFONT CATCodeMgr::CheckFont( HDC hdc )
{
HFONT hRetVal = NULL;
TEXTMETRIC tm;
BOOL bRes = GetTextMetrics(hdc, &tm);
// 폰트 다시 로드
if( bRes )//&& tm.tmHeight != lLastFontHeight )
{
HFONT font = NULL;
long lFontSize = tm.tmHeight;
if(m_strFontFace.IsEmpty())
{
m_strFontFace = _T("궁서");
}
// 폰트페이스명이 바뀌었으면 맵 초기화
if(m_strLastFontFace.Compare(m_strFontFace))
{
for(map<long, HFONT>::iterator iter = m_mapFonts.begin();
iter != m_mapFonts.end();
iter++)
{
font = iter->second;
DeleteObject(font);
}
m_mapFonts.clear();
}
// 폰트 크기 고정인 경우
if(m_lFontSize !=0 && m_bFixedFontSize)
{
lFontSize = m_lFontSize;
}
// 이 크기에 해당하는 폰트가 없을 경우 폰트를 생성
if( m_mapFonts.find(lFontSize) == m_mapFonts.end() )
{
font = CreateFont(lFontSize, 0, 0, 0, tm.tmWeight, tm.tmItalic, tm.tmUnderlined, tm.tmStruckOut,
HANGEUL_CHARSET, //ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
DEFAULT_PITCH, // | FF_SWISS,
m_strFontFace);
m_mapFonts[lFontSize] = font;
}
else
{
font = m_mapFonts[lFontSize];
}
hRetVal = (HFONT)SelectObject(hdc, font);
}
/*
TEXTMETRIC tm;
BOOL bRes = GetTextMetrics(hdc, &tm);
// 폰트 다시 로드
if( bRes )
{
// 폰트 크기 고정인 경우
if(m_lFontSize !=0 && m_bFixedFontSize)
{
tm.tmHeight = m_lFontSize;
}
HFONT font = InnerCreateFont(tm.tmHeight, 0, 0, 0, tm.tmWeight, tm.tmItalic, tm.tmUnderlined, tm.tmStruckOut,
HANGEUL_CHARSET, //ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
DEFAULT_PITCH, // | FF_SWISS,
(LPWSTR)(LPCWSTR)m_strFontFace);
if(font)
{
hRetVal = (HFONT)SelectObject(hdc, font);
}
}
*/
return hRetVal;
}
示例5: SplashRedrawWindow
/* The function makes the window visible if it is hidden
or is not yet shown. */
void
SplashRedrawWindow(Splash * splash)
{
if (!SplashIsStillLooping(splash)) {
KillTimer(splash->hWnd, 0);
}
if (splash->currentFrame < 0) {
return;
}
SplashUpdateScreenData(splash);
if (splash->isLayered) {
BLENDFUNCTION bf;
POINT ptSrc;
HDC hdcSrc = CreateCompatibleDC(NULL), hdcDst;
BITMAPINFOHEADER bmi;
void *bitmapBits;
HBITMAP hBitmap, hOldBitmap;
RECT rect;
POINT ptDst;
SIZE size;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.AlphaFormat = AC_SRC_ALPHA;
bf.SourceConstantAlpha = 0xFF;
ptSrc.x = ptSrc.y = 0;
memset(&bmi, 0, sizeof(bmi));
bmi.biSize = sizeof(BITMAPINFOHEADER);
bmi.biWidth = splash->width;
bmi.biHeight = -splash->height;
bmi.biPlanes = 1;
bmi.biBitCount = 32;
bmi.biCompression = BI_RGB;
// FIXME: this is somewhat ineffective
// maybe if we allocate memory for all frames as DIBSections,
// then we could select the frames into the DC directly
hBitmap = CreateDIBSection(NULL, (BITMAPINFO *) & bmi, DIB_RGB_COLORS,
&bitmapBits, NULL, 0);
memcpy(bitmapBits, splash->screenData,
splash->screenStride * splash->height);
hOldBitmap = (HBITMAP) SelectObject(hdcSrc, hBitmap);
hdcDst = GetDC(splash->hWnd);
GetWindowRect(splash->hWnd, &rect);
ptDst.x = rect.left;
ptDst.y = rect.top;
size.cx = splash->width;
size.cy = splash->height;
UpdateLayeredWindow(splash->hWnd, hdcDst, &ptDst, &size,
hdcSrc, &ptSrc, 0, &bf, ULW_ALPHA);
ReleaseDC(splash->hWnd, hdcDst);
SelectObject(hdcSrc, hOldBitmap);
DeleteObject(hBitmap);
DeleteDC(hdcSrc);
}
else {
InvalidateRect(splash->hWnd, NULL, FALSE);
if (splash->maskRequired) {
HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
CombineRgn(hRgn, splash->frames[splash->currentFrame].hRgn,
splash->frames[splash->currentFrame].hRgn, RGN_COPY);
SetWindowRgn(splash->hWnd, hRgn, TRUE);
} else {
SetWindowRgn(splash->hWnd, NULL, TRUE);
}
UpdateWindow(splash->hWnd);
}
if (!IsWindowVisible(splash->hWnd)) {
POINT cursorPos;
ShowWindow(splash->hWnd, SW_SHOW);
// Windows won't update the cursor after the window is shown,
// if the cursor is already above the window. need to do this manually.
GetCursorPos(&cursorPos);
if (WindowFromPoint(cursorPos) == splash->hWnd) {
// unfortunately Windows fail to understand that the window
// thread should own the cursor, even though the mouse pointer
// is over the window, until the mouse has been moved.
// we're using SetCursorPos here to fake the mouse movement
// and enable proper update of the cursor.
SetCursorPos(cursorPos.x, cursorPos.y);
SetCursor(LoadCursor(NULL, IDC_WAIT));
}
}
if (SplashIsStillLooping(splash)) {
int time = splash->time +
splash->frames[splash->currentFrame].delay - SplashTime();
if (time < 0)
//.........這裏部分代碼省略.........
示例6: CopyBitmapTo32
HBITMAP CopyBitmapTo32(HBITMAP hBitmap)
{
BITMAPINFO RGB32BitsBITMAPINFO;
BYTE * ptPixels;
HBITMAP hDirectBitmap;
BITMAP bmp;
DWORD dwLen;
BYTE *p;
GetObject(hBitmap, sizeof(bmp), &bmp);
dwLen = bmp.bmWidth * bmp.bmHeight * 4;
p = (BYTE *)malloc(dwLen);
if (p == NULL)
return NULL;
// Create bitmap
ZeroMemory(&RGB32BitsBITMAPINFO, sizeof(BITMAPINFO));
RGB32BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
RGB32BitsBITMAPINFO.bmiHeader.biWidth = bmp.bmWidth;
RGB32BitsBITMAPINFO.bmiHeader.biHeight = bmp.bmHeight;
RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1;
RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32;
hDirectBitmap = CreateDIBSection(NULL,
(BITMAPINFO *)&RGB32BitsBITMAPINFO,
DIB_RGB_COLORS,
(void **)&ptPixels,
NULL, 0);
// Copy data
if (bmp.bmBitsPixel != 32)
{
HDC hdcOrig, hdcDest;
HBITMAP oldOrig, oldDest;
hdcOrig = CreateCompatibleDC(NULL);
oldOrig = (HBITMAP) SelectObject(hdcOrig, hBitmap);
hdcDest = CreateCompatibleDC(NULL);
oldDest = (HBITMAP) SelectObject(hdcDest, hDirectBitmap);
BitBlt(hdcDest, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcOrig, 0, 0, SRCCOPY);
SelectObject(hdcDest, oldDest);
DeleteObject(hdcDest);
SelectObject(hdcOrig, oldOrig);
DeleteObject(hdcOrig);
// Set alpha
CorrectBitmap32Alpha(hDirectBitmap, FALSE);
}
else
{
GetBitmapBits(hBitmap, dwLen, p);
SetBitmapBits(hDirectBitmap, dwLen, p);
}
free(p);
return hDirectBitmap;
}
示例7: GetMyCheckBitmaps
//.........這裏部分代碼省略.........
HBITMAP hbmpCheck; // handle to check-mark bitmap
RECT rc; // rectangle for check-box bitmap
WORD wBitmapX; // width of check-mark bitmap
WORD wBitmapY; // height of check-mark bitmap
// Get the menu background color and create a solid brush
// with that color.
crBackground = GetSysColor(COLOR_MENU);
hbrBackground = CreateSolidBrush(crBackground);
// Create memory device contexts for the source and
// destination bitmaps.
hdcSource = CreateCompatibleDC((HDC) NULL);
hdcTarget = CreateCompatibleDC(hdcSource);
// Get the size of the system default check-mark bitmap and
// create a compatible bitmap of the same size.
wBitmapX = GetSystemMetrics(SM_CXMENUCHECK);
wBitmapY = GetSystemMetrics(SM_CYMENUCHECK);
hbmpCheck = CreateCompatibleBitmap(hdcSource, wBitmapX,
wBitmapY);
// Select the background brush and bitmap into the target DC.
hbrTargetOld = SelectObject(hdcTarget, hbrBackground);
hbmpTargetOld = SelectObject(hdcTarget, hbmpCheck);
// Use the selected brush to initialize the background color
// of the bitmap in the target device context.
PatBlt(hdcTarget, 0, 0, wBitmapX, wBitmapY, PATCOPY);
// Load the predefined check box bitmaps and select it
// into the source DC.
hbmpCheckboxes = LoadBitmap((HINSTANCE) NULL,
(LPTSTR) OBM_CHECKBOXES);
hbmpSourceOld = SelectObject(hdcSource, hbmpCheckboxes);
// Fill a BITMAP structure with information about the
// check box bitmaps, and then find the upper-left corner of
// the unchecked check box or the checked check box.
GetObject(hbmpCheckboxes, sizeof(BITMAP), &bmCheckbox);
if (fuCheck == 2 /*UNCHECK*/)
{
rc.left = 0;
rc.right = (bmCheckbox.bmWidth / 4);
}
else
{
rc.left = (bmCheckbox.bmWidth / 4);
rc.right = (bmCheckbox.bmWidth / 4) * 2;
}
rc.top = 0;
rc.bottom = (bmCheckbox.bmHeight / 3);
// Copy the appropriate bitmap into the target DC. If the
// check-box bitmap is larger than the default check-mark
// bitmap, use StretchBlt to make it fit; otherwise, just
// copy it.
if (((rc.right - rc.left) > (int) wBitmapX) ||
((rc.bottom - rc.top) > (int) wBitmapY))
{
StretchBlt(hdcTarget, 0, 0, wBitmapX, wBitmapY,
hdcSource, rc.left, rc.top, rc.right - rc.left,
rc.bottom - rc.top, SRCCOPY);
}
else
{
BitBlt(hdcTarget, 0, 0, rc.right - rc.left,
rc.bottom - rc.top,
hdcSource, rc.left, rc.top, SRCCOPY);
}
// Select the old source and destination bitmaps into the
// source and destination DCs, and then delete the DCs and
// the background brush.
SelectObject(hdcSource, hbmpSourceOld);
SelectObject(hdcTarget, hbrTargetOld);
hbmpCheck = SelectObject(hdcTarget, hbmpTargetOld);
DeleteObject(hbrBackground);
DeleteObject(hdcSource);
DeleteObject(hdcTarget);
// Return a handle to the new check-mark bitmap.
return hbmpCheck;
}
示例8: DeleteObject
Brush_c34::~Brush_c34()
{
DeleteObject(_brush);
}
示例9: RegOpenKeyEx
LPTSTR ASSISTANT::Text::GetTtfName()
{
static _TCHAR tszTtfName[512];
HKEY hKeyMachine;
LONG regErr = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"), NULL,KEY_READ,&hKeyMachine);
if ( regErr != ERROR_SUCCESS )
{
LONG regErr = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Fonts"), NULL,KEY_READ,&hKeyMachine);
if ( regErr != ERROR_SUCCESS )
{
return NULL;
}
}
DWORD subValues;
regErr = RegQueryInfoKey(hKeyMachine, NULL, NULL, NULL, NULL, NULL, NULL, &subValues, NULL, NULL, NULL, NULL);
if ( regErr != ERROR_SUCCESS )
{
return NULL;
}
HRESULT hr = ::CoInitialize(NULL);
HDC hdc = ::CreateCompatibleDC(NULL);
DWORD dwType;
_TCHAR tszEntryName[512];
_TCHAR tszEntryValue[512];
HFONT font = CreateFontIndirect(&m_logFont);
UINT cbData;
LPOUTLINETEXTMETRIC lpoltm;
SelectObject(hdc, font);
cbData = GetOutlineTextMetrics (hdc, 0, NULL);
DeleteObject(font);
_TCHAR tszFontFace[512];
if (cbData == 0)
{
_tcscpy(tszFontFace, m_logFont.lfFaceName);
}
else
{
lpoltm = (LPOUTLINETEXTMETRIC)LocalAlloc (LPTR, cbData);
GetOutlineTextMetrics (hdc, cbData, lpoltm);
_tcscpy(tszFontFace, (_TCHAR *)((DWORD) lpoltm + lpoltm->otmpFaceName));
}
bool bFoundFontInfo = false;
for (int i = 0; i < subValues && !bFoundFontInfo; i++)
{
unsigned long entryNameLength = 512 * sizeof _TCHAR;
unsigned long entryValueLength = 512 * sizeof _TCHAR;
if (RegEnumValue(hKeyMachine, i, tszEntryName, &entryNameLength,
NULL, &dwType, (unsigned char *)tszEntryValue, &entryValueLength) != ERROR_SUCCESS)
{
continue;
}
_TCHAR tszFaceName[512];
_tcscpy(tszFaceName, tszEntryName);
_TCHAR *p = _tcsrchr(tszFaceName, '(');
if (p != NULL)
*p = '\0';
if (tszFaceName[_tcslen(tszFaceName) - 1] == _T(' '))
tszFaceName[_tcslen(tszFaceName) - 1] = _T('\0');
if (_tcscmp(tszFontFace, tszFaceName) == 0)
{
bFoundFontInfo = true;
UINT nStringLength = _tcslen(tszEntryValue);
_tcscpy(tszTtfName, tszEntryValue);
tszTtfName[nStringLength] = '\0';
}
}
::DeleteDC(hdc);
::CoUninitialize();
RegCloseKey(hKeyMachine);
if (bFoundFontInfo)
return tszTtfName;
else
return NULL;
}
示例10: WG32CreateDIBSection
//.........這裏部分代碼省略.........
#else
pvIntelBits = pvBits;
#endif
// Create a selector array for the bits backed by pvIntelBits
Parm16.WndProc.wParam = (WORD)-1; // -1 => allocate selectors
Parm16.WndProc.lParam = (LONG) pvIntelBits; // backing pointer
Parm16.WndProc.wMsg = 0x10; // GA_NOCOMPACT
Parm16.WndProc.hwnd = (WORD)((SelectorLimit+65535)/65536);// selector count
CallBack16(RET_SETDIBSEL,
&Parm16,
0,
(PVPVOID)&pvBits32);
// 16:16 pointer is still valid as call above makes no difference
if (pv16 != NULL) {
*(UNALIGNED PVOID*)pv16 = pvBits32;
}
if (pvBits32 == NULL) {
LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection, Callback set_sel_for_dib failed\n"));
goto cds_err;
}
#ifndef i386
// okay, that was successful - map the descriptors properly
if (!VdmAddDescriptorMapping(HIWORD(pvBits32),
(USHORT) ((SelectorLimit+65535)/65536),
(ULONG) pvIntelBits,
(ULONG) pvBits)) {
LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection VdmAddDescriptorMapping failed\n"));
goto cds_err;
}
#endif
LOGDEBUG(LOG_ALWAYS, ("\nWOW:CreateDIBSection: [16:16 %x] [Intel %x] [Flat %x]\n",
pvBits32, pvIntelBits, pvBits));
ul = GETHBITMAP16(hbm32);
// Add it to the list used for cleanup at DeleteObject time.
if ((pdi = malloc_w (sizeof (DIBSECTIONINFO))) != NULL) {
pdi->di_hbm = (HBITMAP)(HAND16)hbm32;
pdi->di_pv16 = pvBits32;
#ifndef i386
pdi->di_newIntelDib = pvIntelBits;
#endif
pdi->di_next = pDibSectionInfoHead;
pDibSectionInfoHead = pdi;
// need to turn batching off since a DIBSECTION means the app can
// also draw on the bitmap and we need synchronization.
GdiSetBatchLimit(1);
goto cds_ok;
}
else {
// Failure, free the selector array
Parm16.WndProc.wParam = (WORD)-1; // -1 => allocate/free
Parm16.WndProc.lParam = (LONG) pvBits32; // pointer
Parm16.WndProc.wMsg = 0x10; // GA_NOCOMPACT
Parm16.WndProc.hwnd = 0; // 0 => free
CallBack16(RET_SETDIBSEL,
&Parm16,
0,
(PVPVOID)&ul);
#ifndef i386
VdmRemoveVirtualMemory((ULONG)pvIntelBits);
#endif
}
}
else {
LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection, CreateDibSection Failed\n"));
}
cds_err:
if (hbm32 != 0) {
DeleteObject(hbm32);
}
LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection returning failure\n"));
ul = 0;
cds_ok:
WOW32APIWARN(ul, "CreateDIBSection");
FREEMISCPTR(pv16);
FREEARGPTR(parg16);
return(ul);
}
示例11: PlPOINTPlot
//.........這裏部分代碼省略.........
int retStat=PL_OK;
HBRUSH hBrush=0, hOldBrush=0;
HPEN hPen=0, hOldPen=0;
int stat, j;
RECT rectPts;
// If the caller has told us the RECT that bounds the points to be
// drawn, check to see if the RECT (or a part of it) lies within
// the area of the window that needs to be drawn. If not, just
// exit from this routine.
if (pRectPts != NULL) {
rectPts = *pRectPts;
// Make the rect follow the Windows convention.
rectPts.right += 1;
rectPts.bottom += 1;
if (pPlot->hRgnPaint != 0) {
if (!RectInRegion(pPlot->hRgnPaint, &rectPts))
goto done;
}
if (!RectVisible(hDC, &rectPts))
goto done;
}
// Now draw the actual data points. There is a separate section
// here for each drawing type. One of the overriding objectives
// in how this is coded is to minimize the number of subroutine
// calls.
if (nPts >= 2 && eDrawType >= PL_LINE &&
eDrawType <= PL_LINE_DASHDOTDOT) {
// Draw all "line" types.
stat = Polyline(hDC, aPts, nPts);
if (stat == 0) {
// In some cases (not well understood), Polyline
// fails. When this happens, draw the line one
// point at a time.
MoveToEx(hDC, aPts[0].x, aPts[0].y, NULL);
for (j=1; j<nPts; j++)
LineTo(hDC, aPts[j].x, aPts[j].y);
}
SetPixel(hDC, aPts[nPts-1].x, aPts[nPts-1].y, rgb);
}
else if (eDrawType >= PL_SQUARE && eDrawType <= PL_CROSS) {
// Draw all "plot mark" types.
int wid, ht;
ht = PL_YPTS_TO_YPIX(fPts);
wid = PL_XPTS_TO_XPIX(fPts);
for (j=0; j<nPts; j++) {
retStat = PlDraw_discrete(pPlot, hDC,
aPts[j].x, aPts[j].y,
wid, ht, eDrawType,
0, 0, 0, 0, 0, 0,
rgb);
if (retStat != PL_OK) goto done;
}
}
else {
// Draw PL_POINT type.
int nX, nY;
nX = PL_XPTS_TO_XPIX(fPts);
nY = PL_YPTS_TO_YPIX(fPts);
if (nX <= 1 && nY <= 1) {
for (j=0; j<nPts; j++)
SetPixel(hDC, aPts[j].x, aPts[j].y, rgb);
}
else {
int xL, xR, yB, yT;
int iHalfWid=(nX - 1)/2;
int iHalfHt=(nY - 1)/2;
if ((hPen = CreatePen(PS_SOLID, 1, rgb)) == 0) goto gdi_error;
/* KG */
//hOldPen = SelectObject(hDC, hPen);
hOldPen = (HPEN)SelectObject(hDC, hPen);
if ((hBrush = CreateSolidBrush(rgb)) == 0) goto gdi_error;
/* KG */
//hOldBrush = SelectObject(hDC, hBrush);
hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
for (j=0; j<nPts; j++) {
xL = aPts[j].x - iHalfWid;
xR = xL + nX;
yT = aPts[j].y - iHalfHt;
yB = yT + nY;
Ellipse(hDC, xL, yT, xR, yB);
}
}
}
done:
if (hOldPen != 0) SelectObject(hDC, hOldPen);
if (hPen != 0) DeleteObject(hPen);
if (hOldBrush != 0) SelectObject(hDC, hOldBrush);
if (hBrush != 0) DeleteObject(hBrush);
return retStat;
gdi_error:
retStat = PL_GDI_FAIL;
goto done;
}
示例12: test_setfont
static void test_setfont(DWORD style)
{
HWND hCombo;
HFONT hFont1, hFont2;
RECT r;
int i;
if (!is_font_installed("Marlett"))
{
skip("Marlett font not available\n");
return;
}
trace("Style %x\n", style);
hCombo = build_combo(style);
hFont1 = CreateFontA(10, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
hFont2 = CreateFontA(8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, font_height(GetStockObject(SYSTEM_FONT)) + 8);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105);
/* The size of the dropped control is initially equal to the size
of the window when it was created. The size of the calculated
dropped area changes only by how much the selection area
changes, not by how much the list area changes. */
if (font_height(hFont1) == 10 && font_height(hFont2) == 8)
{
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, 18);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1)));
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE);
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, 16);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont2)));
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, 18);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1)));
}
else
{
ok(0, "Expected Marlett font heights 10/8, got %d/%d\n",
font_height(hFont1), font_height(hFont2));
}
for (i = 1; i < 30; i++)
{
HFONT hFont = CreateFontA(i, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
int height = font_height(hFont);
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont, FALSE);
GetClientRect(hCombo, &r);
expect_eq(r.bottom - r.top, height + 8, int, "%d");
SendMessageA(hCombo, WM_SETFONT, 0, FALSE);
DeleteObject(hFont);
}
DestroyWindow(hCombo);
DeleteObject(hFont1);
DeleteObject(hFont2);
}
示例13: 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;
static HDC hMemDC;
static INT w, h;
static BITMAP bm;
static HBITMAP hBm;
switch (Msg)
{
case WM_CREATE:
SetTimer(hWnd, 111, 50, NULL);
/* создаем контекст в памяти */
hDC = GetDC(hWnd);
hMemDC = CreateCompatibleDC(hDC);
ReleaseDC(hWnd, hDC);
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(255, 255, 255));
Rectangle(hMemDC, 0, 0, w + 1, h + 1);
SelectObject(hMemDC, GetStockObject(NULL_PEN));
SelectObject(hMemDC, GetStockObject(DC_BRUSH));
SetDCBrushColor(hMemDC, RGB(255, 0, 0));
GlobeBuild();
GlobeDraw(hMemDC, w, h);
InvalidateRect(hWnd, NULL, TRUE);
return 0;
case WM_KEYDOWN:
if (wParam == 'F')
FlipFullScreen(hWnd);
if (wParam == 27)
SendMessage(hWnd, WM_CLOSE, 0, 0);
if (wParam == 'W')
IsWire = !IsWire;
return 0;
case WM_CLOSE:
if (MessageBox(hWnd, "Are you shure to exit from program?",
"Exit", MB_YESNO | MB_ICONQUESTION) == IDNO)
return 0;
break;
case WM_ERASEBKGND:
BitBlt((HDC)wParam, 0, 0, w, h, hMemDC, 0, 0, SRCCOPY);
return 0;
case WM_DESTROY:
DeleteDC(hMemDC);
DeleteObject(hBm);
KillTimer(hWnd, 111);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
示例14: _al_win_create_icon
HICON _al_win_create_icon(HWND wnd,
ALLEGRO_BITMAP *sprite, int xfocus, int yfocus, bool is_cursor)
{
int x, y;
int sys_sm_cx, sys_sm_cy;
HDC h_dc;
HDC h_and_dc;
HDC h_xor_dc;
ICONINFO iconinfo;
HBITMAP and_mask;
HBITMAP xor_mask;
HBITMAP hOldAndMaskBitmap;
HBITMAP hOldXorMaskBitmap;
HICON icon;
if (is_cursor) {
/* Get allowed cursor size - Windows can't make cursors of arbitrary size */
sys_sm_cx = GetSystemMetrics(SM_CXCURSOR);
sys_sm_cy = GetSystemMetrics(SM_CYCURSOR);
}
else {
sys_sm_cx = GetSystemMetrics(SM_CXICON);
sys_sm_cy = GetSystemMetrics(SM_CYICON);
}
if ((sprite->w > sys_sm_cx) || (sprite->h > sys_sm_cy)) {
return NULL;
}
/* Create bitmap */
h_dc = GetDC(wnd);
h_xor_dc = CreateCompatibleDC(h_dc);
h_and_dc = CreateCompatibleDC(h_dc);
/* Prepare AND (monochrome) and XOR (colour) mask */
and_mask = CreateBitmap(sys_sm_cx, sys_sm_cy, 1, 1, NULL);
xor_mask = CreateCompatibleBitmap(h_dc, sys_sm_cx, sys_sm_cy);
hOldAndMaskBitmap = (HBITMAP) SelectObject(h_and_dc, and_mask);
hOldXorMaskBitmap = (HBITMAP) SelectObject(h_xor_dc, xor_mask);
/* Create transparent cursor */
for (y = 0; y < sys_sm_cy; y++) {
for (x = 0; x < sys_sm_cx; x++) {
SetPixel(h_and_dc, x, y, WINDOWS_RGB(255, 255, 255));
SetPixel(h_xor_dc, x, y, WINDOWS_RGB(0, 0, 0));
}
}
local_draw_to_hdc(h_xor_dc, sprite, 0, 0);
/* Make cursor background transparent */
for (y = 0; y < sprite->h; y++) {
for (x = 0; x < sprite->w; x++) {
ALLEGRO_COLOR c;
unsigned char r, g, b, a;
c = al_get_pixel(sprite, x, y);
al_unmap_rgba(c, &r, &g, &b, &a);
if (a != 0) {
/* Don't touch XOR value */
SetPixel(h_and_dc, x, y, 0);
}
else {
/* No need to touch AND value */
SetPixel(h_xor_dc, x, y, WINDOWS_RGB(0, 0, 0));
}
}
}
SelectObject(h_and_dc, hOldAndMaskBitmap);
SelectObject(h_xor_dc, hOldXorMaskBitmap);
DeleteDC(h_and_dc);
DeleteDC(h_xor_dc);
ReleaseDC(wnd, h_dc);
iconinfo.fIcon = is_cursor ? false : true;
iconinfo.xHotspot = xfocus;
iconinfo.yHotspot = yfocus;
iconinfo.hbmMask = and_mask;
iconinfo.hbmColor = xor_mask;
icon = CreateIconIndirect(&iconinfo);
DeleteObject(and_mask);
DeleteObject(xor_mask);
return icon;
}
示例15: MDescButton_OnPaint
static LRESULT MDescButton_OnPaint(HWND hwndDlg, MDescButtonCtrl *dat)
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwndDlg, &ps);
HDC tempDC = CreateCompatibleDC(hdc);
SIZE titleSize = { 0 };
HBITMAP hBmp = CreateCompatibleBitmap(hdc, dat->width, dat->height);
HBITMAP hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp);
RECT temprc;
temprc.left = 0;
temprc.right = dat->width;
temprc.top = 0;
// Draw background
if (dat->bMouseInside || (GetFocus() == hwndDlg)) {
MDescButton_FillRect(tempDC, 0, 0, dat->width, dat->height, dat->clSelBorder);
MDescButton_DrawGradient(tempDC, 1, 1, dat->width - 2, dat->height - 2, &dat->rgbSelTop, &dat->rgbSelBottom);
SetTextColor(tempDC, dat->clSelText);
}
else {
MDescButton_FillRect(tempDC, 0, 0, dat->width, dat->height, dat->clBackground);
SetTextColor(tempDC, dat->clText);
}
if (dat->hIcon)
DrawIcon(tempDC, DBC_BORDER_SIZE, DBC_BORDER_SIZE, dat->hIcon);
HFONT hfntSave = (HFONT)SelectObject(tempDC, dat->hFont);
SetBkMode(tempDC, TRANSPARENT);
if (dat->lpzTitle) {
LOGFONT lf;
GetObject(dat->hFont, sizeof(lf), &lf);
lf.lfWeight = FW_BOLD;
lf.lfHeight *= 1.5;
HFONT hOldFont = (HFONT)SelectObject(tempDC, CreateFontIndirect(&lf));
RECT textRect;
textRect.left = DBC_BORDER_SIZE + (dat->hIcon ? 32 + DBC_VSPACING : 0);
textRect.right = dat->width - DBC_BORDER_SIZE;
textRect.top = DBC_BORDER_SIZE;
textRect.bottom = dat->height - DBC_BORDER_SIZE;
DrawText(tempDC, dat->lpzTitle, -1, &textRect, DT_TOP | DT_LEFT | DT_END_ELLIPSIS);
GetTextExtentPoint32(tempDC, dat->lpzTitle, (int)mir_tstrlen(dat->lpzTitle), &titleSize);
DeleteObject(SelectObject(tempDC, hOldFont));
}
if (dat->lpzDescription) {
RECT textRect;
textRect.left = DBC_BORDER_SIZE + (dat->hIcon ? 32 + DBC_VSPACING : 0);
textRect.right = dat->width - DBC_BORDER_SIZE;
textRect.top = DBC_BORDER_SIZE + titleSize.cy ? titleSize.cy + DBC_HSPACING : 0;
textRect.bottom = dat->height - DBC_BORDER_SIZE;
DrawText(tempDC, dat->lpzDescription, -1, &textRect, DT_TOP | DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS);
GetTextExtentPoint32(tempDC, dat->lpzTitle, (int)mir_tstrlen(dat->lpzTitle), &titleSize);
}
SelectObject(tempDC, hfntSave);
//Copy to output
BitBlt(hdc, dat->rc.left, dat->rc.top, dat->width, dat->height, tempDC, 0, 0, SRCCOPY);
SelectObject(tempDC, hOldBmp);
DeleteObject(hBmp);
DeleteDC(tempDC);
EndPaint(hwndDlg, &ps);
return TRUE;
}