static HDC myCreateIC(LPCTSTR driver, LPCTSTR device, DEVMODE *devmode) { HDC icPrint; icPrint = CreateIC(driver,device,NULL,devmode); if (!icPrint) icPrint = CreateIC(driver,device,NULL,devmode); // try once again. Adobe printer drivers sometimes need to be told everything twice return icPrint; }
HBITMAP GetBitmapFont (int i) { static TCHAR * szFaceName[3] = { TEXT ("Courier New"), TEXT ("Arial"), TEXT ("Times New Roman") } ; HBITMAP hBitmap ; HDC hdc, hdcMem ; HFONT hFont ; SIZE size ; TEXTMETRIC tm ; hdc = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ; GetTextMetrics (hdc, &tm) ; hdcMem = CreateCompatibleDC (hdc) ; hFont = CreateFont (2 * tm.tmHeight, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, szFaceName[i]) ; hFont = (HFONT) SelectObject (hdcMem, hFont) ; GetTextExtentPoint32 (hdcMem, szFaceName[i], lstrlen (szFaceName[i]), &size); hBitmap = CreateBitmap (size.cx, size.cy, 1, 1, NULL) ; SelectObject (hdcMem, hBitmap) ; TextOut (hdcMem, 0, 0, szFaceName[i], lstrlen (szFaceName[i])) ; DeleteObject (SelectObject (hdcMem, hFont)) ; DeleteDC (hdcMem) ; DeleteDC (hdc) ; return hBitmap ; }
Vector<FaceInfo> GetAllFacesSys() { VectorMap<String, FaceInfo> list; sList = &list; list.Add("STDFONT").name = "STDFONT"; list.Top().info = 0; #ifdef PLATFORM_WINCE HDC hdc = CreateDC(NULL, NULL, NULL, NULL); Win32_ForceFace(hdc, "Tahoma", NULL); Win32_ForceFace(hdc, "Tahoma", "Tahoma"); Win32_ForceFace(hdc, "Courier New", "Tahoma"); Win32_ForceFace(hdc, "Tahoma", "Tahoma"); Win32_ForceFace(hdc, "Tahoma", "Tahoma"); Win32_ForceFace(hdc, "Tahoma", "Tahoma"); #else HDC hdc = CreateIC("DISPLAY", NULL, NULL, NULL); Win32_ForceFace(hdc, "Times New Roman", "Arial"); Win32_ForceFace(hdc, "Arial", "Arial"); Win32_ForceFace(hdc, "Courier New", "Arial"); Win32_ForceFace(hdc, "Symbol", "Arial"); Win32_ForceFace(hdc, "WingDings", "Arial"); Win32_ForceFace(hdc, "Tahoma", "Arial"); #endif Win32_EnumFace(hdc, NULL); DeleteDC(hdc); return list.PickValues(); }
// NB: can't forward this to wxListBoxItem because LB_SETITEMDATA // message is not yet sent when we get here! bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) { // only owner-drawn control should receive this message wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false ); MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item; #ifdef __WXWINCE__ HDC hdc = GetDC(NULL); #else HDC hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0); #endif wxDC dc; dc.SetHDC((WXHDC)hdc); dc.SetFont(GetFont()); pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE; pStruct->itemWidth = dc.GetCharWidth(); dc.SetHDC(0); DeleteDC(hdc); return true; }
static HDC prn_info_dc( Handle self) { LPPRINTER_INFO_2 ppi = &sys s. prn. ppi; HDC ret = CreateIC( ppi-> pDriverName, ppi-> pPrinterName, ppi-> pPortName, ppi-> pDevMode); if ( !ret) apiErr; return ret; }
/* * Private font initialisation function. */ PROTECTED void init_fonts(void) { HDC info; /* get system information */ info = CreateIC("DISPLAY", NULL, NULL, NULL); screen_dpix = GetDeviceCaps(info, LOGPIXELSX); screen_dpiy = GetDeviceCaps(info, LOGPIXELSY); DeleteDC(info); /* set up standard fonts */ SystemFont = new_font_object(GetStockObject(DEFAULT_GUI_FONT)); if (SystemFont) SystemFont->text = new_string("SystemFont"); FixedFont = new_font_object(GetStockObject(OEM_FIXED_FONT)); Times = newfont("Times New Roman", Plain, -10); Helvetica = newfont("Arial", SansSerif, -10); Courier = newfont("Courier New", FixedWidth, -10); protect_object(SystemFont); protect_object(FixedFont); protect_object(Times); protect_object(Helvetica); protect_object(Courier); }
// NB: can't forward this to wxListBoxItem because LB_SETITEMDATA // message is not yet sent when we get here! bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) { // only owner-drawn control should receive this message wxCHECK( HasFlag(wxLB_OWNERDRAW), false ); MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item; #ifdef __WXWINCE__ HDC hdc = GetDC(NULL); #else HDC hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0); #endif { wxDCTemp dc((WXHDC)hdc); dc.SetFont(GetFont()); pStruct->itemHeight = dc.GetCharHeight() + 2 * LISTBOX_EXTRA_SPACE; pStruct->itemWidth = dc.GetCharWidth(); } #ifdef __WXWINCE__ ReleaseDC(NULL, hdc); #else DeleteDC(hdc); #endif return true; }
HDC far pascal zCreateIC( LPSTR pp1, LPSTR pp2, LPSTR pp3, LPSTR pp4 ) { HDC r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:CreateIC LPSTR+LPSTR+LPSTR+LPDEVMODE+", pp1, pp2, pp3, pp4 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = CreateIC(pp1,pp2,pp3,pp4); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:CreateIC HDC+++++", r, (short)0, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
HRGN CDibBitmap::CreateRgnFromBitmap(COLORREF color, CDC* pDC) { if(!ValidCheck()) return NULL; HBITMAP hBmp = CreateBitmap(pDC); // get image properties BITMAP bmp = { 0 }; GetObject( hBmp, sizeof(BITMAP), &bmp ); // allocate memory for extended image information LPBITMAPINFO bi = (LPBITMAPINFO) new BYTE[ sizeof(BITMAPINFO) + 8 ]; memset( bi, 0, sizeof(BITMAPINFO) + 8 ); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); // set window size //m_dwWidth = bmp.bmWidth; // bitmap width //m_dwHeight = bmp.bmHeight; // bitmap height // create temporary dc HDC dc = CreateIC( "DISPLAY",NULL,NULL,NULL ); // get extended information about image (length, compression, length of color table if exist, ...) DWORD res = GetDIBits( dc, hBmp, 0, bmp.bmHeight, 0, bi, DIB_RGB_COLORS ); // allocate memory for image data (colors) LPBYTE pBits = new BYTE[ bi->bmiHeader.biSizeImage + 4 ]; // allocate memory for color table if ( bi->bmiHeader.biBitCount == 8 ) { // actually color table should be appended to this header(BITMAPINFO), // so we have to reallocate and copy it LPBITMAPINFO old_bi = bi; // 255 - because there is one in BITMAPINFOHEADER bi = (LPBITMAPINFO)new char[ sizeof(BITMAPINFO) + 255 * sizeof(RGBQUAD) ]; memcpy( bi, old_bi, sizeof(BITMAPINFO) ); // release old header delete old_bi; } // get bitmap info header BITMAPINFOHEADER& bih = bi->bmiHeader; // get color table (for 256 color mode contains 256 entries of RGBQUAD(=DWORD)) LPDWORD clr_tbl = (LPDWORD)&bi->bmiColors; // fill bits buffer res = GetDIBits( dc, hBmp, 0, bih.biHeight, pBits, bi, DIB_RGB_COLORS ); DeleteDC( dc ); BITMAP bm; GetObject( hBmp, sizeof(BITMAP), &bm ); // shift bits and byte per pixel (for comparing colors) LPBYTE pClr = (LPBYTE)&color; // swap red and blue components BYTE tmp = pClr[0]; pClr[0] = pClr[2]; pClr[2] = tmp; // convert color if curent DC is 16-bit (5:6:5) or 15-bit (5:5:5) if ( bih.biBitCount == 16 ) { // for 16 bit color = ((DWORD)(pClr[0] & 0xf8) >> 3) | ((DWORD)(pClr[1] & 0xfc) << 3) | ((DWORD)(pClr[2] & 0xf8) << 8); // for 15 bit // color = ((DWORD)(pClr[0] & 0xf8) >> 3) | // ((DWORD)(pClr[1] & 0xf8) << 2) | // ((DWORD)(pClr[2] & 0xf8) << 7); }
HDC Win32_IC() { static HDC hdc; ONCELOCK { hdc = CreateIC("DISPLAY", NULL, NULL, NULL); } return hdc; }
VOID SetupInitializeDpi( VOID ) { HDC hdc; if (hdc = CreateIC(L"DISPLAY", NULL, NULL, NULL)) { PhGlobalDpi = GetDeviceCaps(hdc, LOGPIXELSY); ReleaseDC(NULL, hdc); } }
void SizeTheWindow(int *pxStart, int *pyStart, int *pxClient, int *pyClient) { HDC hdc; TEXTMETRIC tm; hdc = CreateIC("DISPLAY", NULL, NULL, NULL); GetTextMetrics(hdc, &tm); DeleteDC(hdc); *pxClient = 2 * GetSystemMetrics(SM_CXDLGFRAME) + 16*tm.tmAveCharWidth; *pxStart = GetSystemMetrics(SM_CXSCREEN) - *pxClient; *pyClient = 2 * GetSystemMetrics(SM_CYDLGFRAME) + 2*tm.tmHeight; *pyStart = 0; }
static void AllCreateIC(XawVendorShellExtPart *ve) { XawIcTableList p; if (ve->im.xim == NULL) return; if (IsSharedIC(ve) && ve->ic.ic_table[0].widget) { p = ve->ic.shared_ic_table; if (p->xic == NULL) CreateIC(ve->ic.ic_table[0].widget, ve); SetICFocus(ve->ic.ic_table[0].widget, ve); return; } for (p = ve->ic.ic_table; p; p = p->next) { if (p->xic == NULL) CreateIC(p->widget, ve); } for (p = ve->ic.ic_table; p; p = p->next) { SetICFocus(p->widget, ve); } }
void game::Init(void) { if(g_isConsoleUpdater) { cmdLine_Init(); return; } //@gHwInfoPoster.Start(); -- DISABLED FOR NOW // set small icon ::SendMessage(win::hWnd, WM_SETICON, FALSE, (LPARAM)::LoadIcon(win::hInstance, MAKEINTRESOURCE(IDI_WARINC))); // make borderless window and subclass wndProc r3dWinStyleModify(win::hWnd, 0, WS_BORDER); r3dWinStyleModify(win::hWnd, 0, WS_CAPTION); SetWindowLong(win::hWnd, GWL_WNDPROC, (DWORD)&updApp_WndFunc); // ok, now r3drendered started using vars inside itself... RegisterAllVars(); const int Width = 785; const int Height = 650; HDC disp_dc = CreateIC("DISPLAY", NULL, NULL, NULL); int curDispWidth = GetDeviceCaps(disp_dc, HORZRES); int curDispHeight = GetDeviceCaps(disp_dc, VERTRES); int StartXPos = (curDispWidth - Width) / 2; int StartYPos = (curDispHeight - Height) / 2; SetWindowPos(win::hWnd, NULL, StartXPos, StartYPos, (int)Width, (int)Height, 0); r3dRenderer = new r3dRenderLayer; r3dRenderer->Init(win::hWnd, NULL); fake_SetMode(Width, Height); char title[512]; sprintf(title, "Infestation Thailand Updater %s (%s)", UPDATER_VERSION, UPDATER_BUILD); if(!UPDATER_UPDATER_ENABLED) strcat(title, "!!!!SELF_UPDATE_DISABLED!!!"); ::SetWindowText(win::hWnd, title); CreateResources(); ShowWindow(win::hWnd, SW_SHOW); ClipCursor(NULL); // release dinput classes becase we won't be using them Keyboard->ReleaseCapture(); Mouse->ReleaseCapture(); }
long UPSF::hBrush_To_UBit( HGLOBAL& hUniv, long& univSize, HBRUSH hBrush, long natvLen) { if(natvLen != (long)sizeof(HBRUSH)) return AUPSF_SIZEERROR; HDC hDC = CreateIC("DISPLAY", NULL, NULL, NULL); HDC hDCMem = CreateCompatibleDC(hDC); HBITMAP hBitmap = CreateBitmap(BRUSH_WIDTH, BRUSH_HEIGHT, 1, 1, NULL); SelectObject(hDCMem, hBitmap); HBRUSH hBrushOld = SelectBrush(hDCMem, hBrush); // draw the brush in the region RECT rect = {0, 0, BRUSH_WIDTH, BRUSH_HEIGHT}; FillRect(hDCMem, &rect, hBrush); SelectBrush(hDCMem, hBrushOld); DeleteDC(hDCMem); DeleteDC(hDC); // we are left with the bitmap with the brush pattern BITMAP bitmap; GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bitmap); long bitmapSize = (long)bitmap.bmHeight * (long)bitmap.bmWidthBytes * (long)bitmap.bmPlanes; HGLOBAL hBits = GlobalAlloc(MEMFLAGS, bitmapSize); if(!hBits) { DeleteObject(hBitmap); return AUPSF_MEMORYERROR; } bitmap.bmBits = GlobalLock(hBits); if(!bitmap.bmBits) { DeleteObject(hBitmap); return AUPSF_MEMORYERROR; } long ret = BITMAP_To_UBit(hUniv, univSize, bitmap, hBitmap); // clean up and exit DeleteObject(hBitmap); GlobalUnlock(hBits); GlobalFree(hBits); return ret; }
PR_PUBLIC_API(int) UNICODE_VERIFYCSIDLIST(int inNumOfItem, int16 *csidlist) { int iIn, iOut; HDC hdc = CreateIC("DISPLAY", NULL,NULL, NULL); if(hdc == NULL) return inNumOfItem; for(iIn=iOut=0; iIn < inNumOfItem; iIn++) { if(unicode_IsCsidAvailable(hdc,csidlist[iIn])) csidlist[iOut++] = csidlist[iIn]; } DeleteDC(hdc); return iOut; }
HBITMAP StretchBitmap (HBITMAP hBitmap1) { BITMAP bm1, bm2 ; HBITMAP hBitmap2 ; HDC hdc, hdcMem1, hdcMem2 ; int cxChar, cyChar ; // Get the width and height of a system font character cxChar = LOWORD (GetDialogBaseUnits ()) ; cyChar = HIWORD (GetDialogBaseUnits ()) ; // Create 2 memory DCs compatible with the display hdc = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ; hdcMem1 = CreateCompatibleDC (hdc) ; hdcMem2 = CreateCompatibleDC (hdc) ; DeleteDC (hdc) ; // Get the dimensions of the bitmap to be stretched GetObject (hBitmap1, sizeof (BITMAP), (PTSTR) &bm1) ; // Scale these dimensions based on the system font size bm2 = bm1 ; bm2.bmWidth = (cxChar * bm2.bmWidth) / 4 ; bm2.bmHeight = (cyChar * bm2.bmHeight) / 8 ; bm2.bmWidthBytes = ((bm2.bmWidth + 15) / 16) * 2 ; // Create a new bitmap of larger size hBitmap2 = CreateBitmapIndirect (&bm2) ; // Select the bitmaps in the memory DCs and do a StretchBlt SelectObject (hdcMem1, hBitmap1) ; SelectObject (hdcMem2, hBitmap2) ; StretchBlt (hdcMem2, 0, 0, bm2.bmWidth, bm2.bmHeight, hdcMem1, 0, 0, bm1.bmWidth, bm1.bmHeight, SRCCOPY) ; // Clean up DeleteDC (hdcMem1) ; DeleteDC (hdcMem2) ; DeleteObject (hBitmap1) ; return hBitmap2 ; }
extern "C" int AL_FUNCTION ALGaugeInit( HINSTANCE hInstance, HINSTANCE hPrevInstance ) { WNDCLASS wc; HDC hdc; if ( ALGauge::iRegistered ) return 1; if ( hPrevInstance == 0 ) { wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hIcon = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = ALGauge::szClassName; wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); wc.hInstance = hInstance; #ifdef AL_BUILDING_DLL wc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = gaugeWndProcDll; #else wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) gaugeWndProc; #endif wc.cbClsExtra = 0; #if defined ( AL_WATCOM ) || defined( AL_FLAT_MODEL ) wc.cbWndExtra = sizeof( ALGauge * ); #else wc.cbWndExtra = sizeof( ALGauge _far * ); #endif if ( !RegisterClass( &wc ) ) return 0; } hdc = CreateIC( "DISPLAY", NULL, NULL, NULL ); if ( !hdc ) { UnregisterClass( ALGauge::szClassName, hInstance ); return 0; } // // Select colors based on whether this is mono or color // if ( GetDeviceCaps( hdc, BITSPIXEL ) == 1 && GetDeviceCaps( hdc, PLANES ) == 1 ) { ALGauge::dwDefaultTextColor = RGB(255, 255, 255); ALGauge::dwDefaultBackgroundColor = RGB(0, 0, 0); } else { ALGauge::dwDefaultTextColor = RGB(0, 0, 255); ALGauge::dwDefaultBackgroundColor = RGB(255, 255, 255); } DeleteDC(hdc); return ( ALGauge::iRegistered = 1); }
long UPSF::hMetaFile_To_UBit( HGLOBAL& hUniv, long& univSize, HMETAFILE hMetaFile, long natvLen) { if(natvLen != (long)sizeof(HMETAFILE)) return AUPSF_SIZEERROR; HDC hDC = CreateIC("DISPLAY", NULL, NULL, NULL); HDC hDCMem = CreateCompatibleDC(hDC); HBITMAP hBitmap = CreateCompatibleBitmap(hDC, GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES)); SelectBitmap(hDCMem, hBitmap); // play the metafile PlayMetaFile(hDCMem, hMetaFile); DeleteDC(hDCMem); DeleteDC(hDC); // we are left with the bitmap with the meta file BITMAP bitmap; GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bitmap); long bitmapSize = (long)bitmap.bmHeight * (long)bitmap.bmWidthBytes * (long)bitmap.bmPlanes; HGLOBAL hBits = GlobalAlloc(MEMFLAGS, bitmapSize); if(!hBits) { DeleteObject(hBitmap); return AUPSF_MEMORYERROR; } bitmap.bmBits = GlobalLock(hBits); if(!bitmap.bmBits) { DeleteObject(hBitmap); return AUPSF_MEMORYERROR; } long ret = BITMAP_To_UBit(hUniv, univSize, bitmap, hBitmap); // clean up and exit DeleteObject(hBitmap); GlobalUnlock(hBits); GlobalFree(hBits); return ret; }
PR_PUBLIC_API(int16) UNICODE_MENUFONTCSID() { HDC hdc = CreateIC("DISPLAY", NULL,NULL, NULL); if(hdc) { TEXTMETRIC metrics; int16 csid; SelectObject(hdc, GetStockObject(SYSTEM_FONT)); GetTextMetrics(hdc, &metrics); DeleteDC(hdc); csid = unicode_CharsetToCsid(metrics.tmCharSet); if(csid != CS_DEFAULT) return csid; } return CS_LATIN1; }
void FindWindowSize (int * pcxWindow, int * pcyWindow) { HDC hdcScreen ; TEXTMETRIC tm ; hdcScreen = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ; GetTextMetrics (hdcScreen, &tm) ; DeleteDC (hdcScreen) ; * pcxWindow = 2 * GetSystemMetrics (SM_CXBORDER) + 12 * tm.tmAveCharWidth ; * pcyWindow = 2 * GetSystemMetrics (SM_CYBORDER) + GetSystemMetrics (SM_CYCAPTION) + 2 * tm.tmHeight ; }
Bool MyCreateICHandler (IMChangeICStruct * call_data) { CreateIC (call_data); if (!CurrentIC) { CurrentIC = (IC *) FindIC (call_data->icid); connect_id = call_data->connect_id; } #ifdef _ENABLE_DBUS if (bUseDBus) updatePropertyByConnectID(connect_id); #endif CreateICID(call_data); return True; }
static void Register(Widget inwidg, XawVendorShellExtPart* ve) { if (ve->im.xim == NULL) { OpenIM(ve); } if (IsRegistered(inwidg, ve)) return; if (RegisterToVendorShell(inwidg, ve) == FALSE) return; if (ve->im.xim == NULL) return; if (XtIsRealized(ve->parent)) { CreateIC(inwidg, ve); SetICFocus(inwidg, ve); } }
static void ResetVideoModes(void) { int iModeNum = 0; HDC hDC; DEVMODE lpDevMode; LPCTSTR lpDriverName, lpDeviceName; lpDriverName = TEXT("DISPLAY"); hDC = CreateIC ( lpDriverName, NULL, NULL, NULL ); lpDevMode.dmSize = sizeof(DEVMODE); lpDeviceName = TEXT("\\\\.\\Display1"); while (EnumDisplaySettings( NULL, iModeNum, &lpDevMode ) != 0) iModeNum++; DeleteDC(hDC); return; }
// move console window to specified corner static void moveWindowToCorner() { HDC disp_dc = CreateIC("DISPLAY", NULL, NULL, NULL); int curDispWidth = GetDeviceCaps(disp_dc, HORZRES); int curDispHeight = GetDeviceCaps(disp_dc, VERTRES); DeleteDC(disp_dc); HWND cwhdn = GetConsoleWindow(); RECT rect; GetWindowRect(cwhdn, &rect); SetWindowPos(cwhdn, 0, curDispWidth - (rect.right - rect.left) - 10, curDispHeight - (rect.bottom - rect.top) - 60, rect.right, rect.bottom, SWP_NOSIZE); }
void SizeTheWindow (short *pxStart, short *pyStart, short *pxClient, short *pyClient ) { HDC hdc; TEXTMETRIC tm; hdc = CreateIC("DISPLAY",NULL,NULL,NULL); // get info on current system font GetTextMetrics(hdc,&tm); DeleteDC(hdc); // width is 16 characters + size of vertical risers in frame. *pxClient = (2 * GetSystemMetrics(SM_CXDLGFRAME) ) + (16 * tm.tmAveCharWidth); // placement is to right *pxStart = GetSystemMetrics(SM_CXSCREEN ) - *pxClient; // height is 2 charactes + size of horizontal runners in frame *pyClient = (2 * GetSystemMetrics(SM_CYDLGFRAME) ) + (2 * tm.tmHeight); // placement is bottom *pyStart = GetSystemMetrics(SM_CYSCREEN ) - *pyClient; }
static void SetFocusValues(Widget inwidg, ArgList args, Cardinal num_args, Bool focus) { XawVendorShellExtPart *ve; VendorShellWidget vw; if ((vw = SearchVendorShell(inwidg)) == NULL) return; if ((ve = GetExtPart(vw)) != NULL) { if (num_args > 0) SetValues(inwidg, ve, args, num_args); if (focus) SetFocus(inwidg, ve); if (XtIsRealized((Widget)vw) && ve->im.xim) { if (IsCreatedIC(inwidg, ve)) { SetICValues(inwidg, ve, FALSE); if (focus) SetICFocus(inwidg, ve); } else { CreateIC(inwidg, ve); SetICFocus(inwidg, ve); } } } }
static ULONG PhpGetCurrentScale( VOID ) { static PH_INITONCE initOnce; static ULONG dpi = 96; if (PhBeginInitOnce(&initOnce)) { HDC hdc; if (hdc = CreateIC(L"DISPLAY", NULL, NULL, NULL)) { dpi = GetDeviceCaps(hdc, LOGPIXELSY); DeleteDC(hdc); } PhEndInitOnce(&initOnce); } return dpi; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { HDC hDC1 = CreateIC(_T("DISPLAY"), NULL, NULL, NULL); HDC hDC2 = CreateDC(_T("DISPLAY"), NULL, NULL, NULL); BOOL r = Rectangle(hDC1, 10, 10, 20, 200); int rs = GetLastError(); r = Rectangle(hDC2, 10, 10, 20, 200); rs = GetLastError(); HWND hWnd = CreateWindow(_T("EDIT"), NULL, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 10, 10, 200, 100, GetDesktopWindow(), NULL, hInstance, NULL); HWND hWnd1 = CreateWindow(_T("EDIT"), NULL, WS_VISIBLE | WS_CHILD | WS_BORDER, 5, 5, 20, 20, hWnd, NULL, hInstance, NULL); ShowWindow(hWnd, SW_SHOW); Test(hWnd, _T("Rectangular Window")); HRGN hRgn = CreateEllipticRgn(0, 0, 300, 300); SetWindowRgn(hWnd, hRgn, TRUE); Test(hWnd, _T("Elliptic Window")); DestroyWindow(hWnd); DeleteDC(hDC1); DeleteDC(hDC2); return 0; }
/* * ChopText * * Purpose: * Parse a string (pathname) and convert it to be within a specified * length by chopping the least significant part * * Parameters: * hWnd window handle in which the string resides * nWidth max width of string in pixels * use width of hWnd if zero * lpch pointer to beginning of the string * nMaxChars maximum allowable number of characters (0 ignore) * * Return Value: * pointer to the modified string */ LPTSTR WINAPI ChopText(HWND hWnd, int nWidth, LPTSTR lpch, int nMaxChars) { HDC hdc; HFONT hfont; HFONT hfontOld = NULL; RECT rc; if (!hWnd || !lpch) return NULL; if (nMaxChars == 0) nMaxChars = 32768; // big number /* Get length of static field. */ if (!nWidth) { GetClientRect(hWnd, (LPRECT)&rc); nWidth = rc.right - rc.left; } /* Set up DC appropriately for the static control */ hdc = CreateIC(TEXT("DISPLAY"), NULL, NULL, NULL); hfont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0L); if (NULL != hfont) // WM_GETFONT returns NULL if window uses system font hfontOld = (HFONT)SelectObject(hdc, hfont); /* check horizontal extent of string */ if (GetTextWSize(hdc, lpch) > nWidth || lstrlen(lpch) >= nMaxChars) Abbreviate(hdc, nWidth, lpch, nMaxChars); if (NULL != hfont) SelectObject(hdc, hfontOld); DeleteDC(hdc); return lpch; }