当前位置: 首页>>代码示例>>C++>>正文


C++ GetDeviceCaps函数代码示例

本文整理汇总了C++中GetDeviceCaps函数的典型用法代码示例。如果您正苦于以下问题:C++ GetDeviceCaps函数的具体用法?C++ GetDeviceCaps怎么用?C++ GetDeviceCaps使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetDeviceCaps函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WndProc

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static CHOOSEFONT cf ;
    static int        iPage ;
    static LOGFONT    lf ;
    HDC               hdc ;
    int               cxChar, cyChar, x, y, i, cxLabels ;
    PAINTSTRUCT       ps ;
    SIZE              size ;
    TCHAR             szBuffer [8] ;
    TEXTMETRIC        tm ;
    WCHAR             ch ;

    switch (message)
    {
    case WM_CREATE:
        hdc = GetDC (hwnd) ;
        lf.lfHeight = - GetDeviceCaps (hdc, LOGPIXELSY) / 6 ;  // 12 points
        lstrcpy (lf.lfFaceName, TEXT ("Lucida Sans Unicode")) ;
        ReleaseDC (hwnd, hdc) ;

        cf.lStructSize = sizeof (CHOOSEFONT) ;
        cf.hwndOwner   = hwnd ;
        cf.lpLogFont   = &lf ;
        cf.Flags       = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS ;

        SetScrollRange (hwnd, SB_VERT, 0, 255, FALSE) ;
        SetScrollPos   (hwnd, SB_VERT, iPage,  TRUE ) ;
        return 0 ;

    case WM_COMMAND:
        switch (LOWORD (wParam))
        {
        case IDM_FONT:
            if (ChooseFont (&cf))
                InvalidateRect (hwnd, NULL, TRUE) ;
            return 0 ;
        }
        return 0 ;

    case WM_VSCROLL:
        switch (LOWORD (wParam))
        {
        case SB_LINEUP:
            iPage -=  1 ;
            break ;
        case SB_LINEDOWN:
            iPage +=  1 ;
            break ;
        case SB_PAGEUP:
            iPage -= 16 ;
            break ;
        case SB_PAGEDOWN:
            iPage += 16 ;
            break ;
        case SB_THUMBPOSITION:
            iPage = HIWORD (wParam) ;
            break ;

        default:
            return 0 ;
        }

        iPage = max (0, min (iPage, 255)) ;

        SetScrollPos (hwnd, SB_VERT, iPage, TRUE) ;
        InvalidateRect (hwnd, NULL, TRUE) ;
        return 0 ;

    case WM_PAINT:
        hdc = BeginPaint (hwnd, &ps) ;

        SelectObject (hdc, CreateFontIndirect (&lf)) ;

        GetTextMetrics (hdc, &tm) ;
        cxChar = tm.tmMaxCharWidth ;
        cyChar = tm.tmHeight + tm.tmExternalLeading ;

        cxLabels = 0 ;

        for (i = 0 ; i < 16 ; i++)
        {
            wsprintf (szBuffer, TEXT (" 000%1X: "), i) ;
            GetTextExtentPoint (hdc, szBuffer, 7, &size) ;

            cxLabels = max (cxLabels, size.cx) ;
        }

        for (y = 0 ; y < 16 ; y++)
        {
            wsprintf (szBuffer, TEXT (" %03X_: "), 16 * iPage + y) ;
            TextOut (hdc, 0, y * cyChar, szBuffer, 7) ;

            for (x = 0 ; x < 16 ; x++)
            {
                ch = (WCHAR) (256 * iPage + 16 * y + x) ;
                TextOutW (hdc, x * cxChar + cxLabels,
                          y * cyChar, &ch, 1);
            }
        }
//.........这里部分代码省略.........
开发者ID:joway,项目名称:WindowsProgrammingNotes,代码行数:101,代码来源:Unichars.c

示例2: glutGameModeString

void GLUTAPIENTRY
glutGameModeString(const char *string)
{
  Criterion *criteria;
  int ncriteria[4], requestedMask, queries = 1;
#if _WIN32
  int bpp, width, height, hertz, n;
#endif

  initGameModeSupport();
#if _WIN32
  XHDC = GetDC(GetDesktopWindow());
  bpp = GetDeviceCaps(XHDC, BITSPIXEL);
  /* Note that Windows 95 and 98 systems always return zero
     for VREFRESH so be prepared to ignore values of hertz
     that are too low. */
  hertz = GetDeviceCaps(XHDC, VREFRESH);
  width = GetSystemMetrics(SM_CXSCREEN);
  height = GetSystemMetrics(SM_CYSCREEN);
#endif
  criteria = parseGameModeString(string, &ncriteria[0], &requestedMask);

#if _WIN32
  /* Build an extra set of default queries.  If no pixel depth is
     explicitly specified, prefer a display mode that doesn't change
     the display mode.  Likewise for the width and height.  Likewise for
     the display frequency. */
  n = ncriteria[0];
  if (!(requestedMask & (1 << DM_PIXEL_DEPTH))) {
    criteria[n].capability = DM_PIXEL_DEPTH;
    criteria[n].comparison = EQ;
    criteria[n].value = bpp;
    n += 1;
    ncriteria[queries] = n;
    queries++;
  }
  if (!(requestedMask & ((1<<DM_WIDTH) | (1<<DM_HEIGHT)) )) {
    criteria[n].capability = DM_WIDTH;
    criteria[n].comparison = EQ;
    criteria[n].value = width;
    criteria[n].capability = DM_HEIGHT;
    criteria[n].comparison = EQ;
    criteria[n].value = height;
    n += 2;
    ncriteria[queries] = n;
    queries++;
  }
  /* Assume a display frequency of less than 50 is to be ignored. */
  if (hertz >= 50) {
    if (!(requestedMask & (1 << DM_HERTZ))) {
      criteria[n].capability = DM_HERTZ;
      criteria[n].comparison = EQ;
      criteria[n].value = hertz;
      n += 1;
      ncriteria[queries] = n;
      queries++;
    }
  }
#endif

  /* Perform multiple queries until one succeeds or no more queries. */
  do {
    queries--;
    currentDm = findMatch(dmodes, ndmodes, criteria, ncriteria[queries]);
  } while((currentDm == NULL) && (queries > 0));

  free(criteria);
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:68,代码来源:glut_gamemode.c

示例3: memset

	void PropSheet::Show(HINSTANCE hInstance, HWND hParent, std::string title, int startpage, bool floating, bool wizard)
	{	
		HPROPSHEETPAGE *pages = new HPROPSHEETPAGE[list.size()];
		PROPSHEETPAGE page;
		//common settings
		memset((void*)&page,0,sizeof(PROPSHEETPAGE));
		page.dwSize = sizeof(PROPSHEETPAGE);
		page.hInstance = hInstance;

		int i=0;
		for (DlgList::iterator iter = list.begin(); iter != list.end(); iter++, i++)
		{
			if (wizard)
			{
				if (i == 0 || i == list.size()-1)
					page.dwFlags = PSP_HIDEHEADER;
				else
					page.dwFlags = PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
			}
			else
			{
				page.dwFlags = PSP_USETITLE;
			}
			page.pszTemplate = iter->resource;
			page.pfnDlgProc = Tab::TabDlgProc;
			page.pszTitle = iter->title;
			page.pszHeaderTitle = wizard?iter->title:0;
			page.pszHeaderSubTitle = wizard?iter->hdrSubTitle:0;
			page.lParam = (LPARAM)iter->tab;
			pages[i] = CreatePropertySheetPage(&page);
		}

		PROPSHEETHEADER sheet;
		memset(&sheet,0,sizeof(sheet));
		sheet.dwSize = sizeof(PROPSHEETHEADER);
		sheet.hInstance = hInstance;
		sheet.hwndParent = hParent;
		sheet.pszbmWatermark = watermark;
		sheet.pszbmHeader = header;
		
		if (icon)
			sheet.hIcon = icon;

		if (wizard)
			sheet.dwFlags = PSH_USECALLBACK | PSH_WIZARD97 | (watermark?PSH_WATERMARK:0) | (header?PSH_HEADER:0);
		else
			sheet.dwFlags = PSH_USECALLBACK | PSH_PROPTITLE;

		if (floating)
			sheet.dwFlags |= PSH_MODELESS;
		//else
		//	sheet.dwFlags |= PSH_NOAPPLYNOW;

		if (icon) 
			sheet.dwFlags |= PSH_USEHICON;

		sheet.pszCaption = ConvertUTF8ToWString(title).c_str();
		sheet.nPages = (UINT)list.size();
		sheet.phpage = pages;
		sheet.nStartPage = startpage;
		sheet.pfnCallback = (PFNPROPSHEETCALLBACK)Callback;
		
		if (wizard)
		{
			NONCLIENTMETRICS ncm = {0};
			ncm.cbSize = sizeof(ncm);
			SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);

			//Create the intro/end title font
			LOGFONT TitleLogFont = ncm.lfMessageFont;
			TitleLogFont.lfWeight = FW_BOLD;
			lstrcpy(TitleLogFont.lfFaceName, TEXT("Verdana Bold"));
			//StringCchCopy(TitleLogFont.lfFaceName, 32, TEXT("Verdana Bold"));

			HDC hdc = GetDC(NULL); //gets the screen DC
			INT FontSize = 12;
			TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72;
			hTitleFont = CreateFontIndirect(&TitleLogFont);
			ReleaseDC(NULL, hdc);
		}
		else
			hTitleFont = 0;

		centered=false;
		PropertySheet(&sheet);
		if (!floating)
		{
			for (DlgList::iterator iter = list.begin(); iter != list.end(); iter++)
			{
				delete iter->tab;
			}
			DeleteObject(hTitleFont);
		}
		delete [] pages;
	}
开发者ID:18859966862,项目名称:ppsspp,代码行数:95,代码来源:PropertySheet.cpp

示例4: winQueryRGBBitsAndMasks

static
Bool
winQueryRGBBitsAndMasks (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  BITMAPINFOHEADER	*pbmih = NULL;
  Bool			fReturn = TRUE;
  LPDWORD		pdw = NULL;
  DWORD			dwRedBits, dwGreenBits, dwBlueBits;

  /* Color masks for 8 bpp are standardized */
  if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
    {
      /* 
       * RGB BPP for 8 bit palletes is always 8
       * and the color masks are always 0.
       */
      pScreenPriv->dwBitsPerRGB = 8;
      pScreenPriv->dwRedMask = 0x0L;
      pScreenPriv->dwGreenMask = 0x0L;
      pScreenPriv->dwBlueMask = 0x0L;
      return TRUE;
    }

  /* Color masks for 24 bpp are standardized */
  if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
      * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
    {
      ErrorF ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
	      "returned 24 for the screen.  Using default 24bpp masks.\n");

      /* 8 bits per primary color */
      pScreenPriv->dwBitsPerRGB = 8;

      /* Set screen privates masks */
      pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
      pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
      pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
      
      return TRUE;
    }

  /* Allocate a bitmap header and color table */
  pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
				      + 256  * sizeof (RGBQUAD));
  if (pbmih == NULL)
    {
      ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
      return FALSE;
    }

  /* Get screen description */
  if (winQueryScreenDIBFormat (pScreen, pbmih))
    {
      /* Get a pointer to bitfields */
      pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
      
#if CYGDEBUG
      winDebug ("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
	      pdw[0], pdw[1], pdw[2]);
      winDebug ("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
              pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes);
      winDebug ("%s - Compression: %d %s\n", __FUNCTION__,
              pbmih->biCompression,
              (pbmih->biCompression == BI_RGB?"(BI_RGB)":
               (pbmih->biCompression == BI_RLE8?"(BI_RLE8)":
                (pbmih->biCompression == BI_RLE4?"(BI_RLE4)":
                 (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":""
                 )))));
#endif

      /* Handle BI_RGB case, which is returned by Wine */
      if (pbmih->biCompression == BI_RGB)
        {
	  dwRedBits = 5;
	  dwGreenBits = 5;
	  dwBlueBits = 5;
	  
	  pScreenPriv->dwBitsPerRGB = 5;
	  
	  /* Set screen privates masks */
	  pScreenPriv->dwRedMask = 0x7c00;
	  pScreenPriv->dwGreenMask = 0x03e0;
	  pScreenPriv->dwBlueMask = 0x001f;
        }
      else 
        {
          /* Count the number of bits in each mask */
          dwRedBits = winCountBits (pdw[0]);
          dwGreenBits = winCountBits (pdw[1]);
          dwBlueBits = winCountBits (pdw[2]);

	  /* Find maximum bits per red, green, blue */
	  if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
	    pScreenPriv->dwBitsPerRGB = dwRedBits;
	  else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
	    pScreenPriv->dwBitsPerRGB = dwGreenBits;
	  else
	    pScreenPriv->dwBitsPerRGB = dwBlueBits;

//.........这里部分代码省略.........
开发者ID:OpenInkpot-archive,项目名称:iplinux-xorg-server,代码行数:101,代码来源:winshadgdi.c

示例5: LConProc

LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND view;
	HDC hdc;
	HBRUSH hbr;
	HGDIOBJ oldfont;
	RECT rect;
	int titlelen;
	SIZE size;
	LOGFONT lf;
	TEXTMETRIC tm;
	HINSTANCE inst = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
	DRAWITEMSTRUCT *drawitem;
	CHARFORMAT2W format;

	switch (msg)
	{
	case WM_CREATE:
		// Create game title static control
		memset (&lf, 0, sizeof(lf));
		hdc = GetDC (hWnd);
		lf.lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
		lf.lfCharSet = ANSI_CHARSET;
		lf.lfWeight = FW_BOLD;
		lf.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
		strcpy (lf.lfFaceName, "Trebuchet MS");
		GameTitleFont = CreateFontIndirect (&lf);

		oldfont = SelectObject (hdc, GetStockObject (DEFAULT_GUI_FONT));
		GetTextMetrics (hdc, &tm);
		DefaultGUIFontHeight = tm.tmHeight;
		if (GameTitleFont == NULL)
		{
			GameTitleFontHeight = DefaultGUIFontHeight;
		}
		else
		{
			SelectObject (hdc, GameTitleFont);
			GetTextMetrics (hdc, &tm);
			GameTitleFontHeight = tm.tmHeight;
		}
		SelectObject (hdc, oldfont);

		// Create log read-only edit control
		view = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "RichEdit20W", NULL,
			WS_CHILD | WS_VISIBLE | WS_VSCROLL |
			ES_LEFT | ES_MULTILINE | WS_CLIPSIBLINGS,
			0, 0, 0, 0,
			hWnd, NULL, inst, NULL);
		HRESULT hr;
		hr = GetLastError();
		if (view == NULL)
		{
			ReleaseDC (hWnd, hdc);
			return -1;
		}
		SendMessage (view, EM_SETREADONLY, TRUE, 0);
		SendMessage (view, EM_EXLIMITTEXT, 0, 0x7FFFFFFE);
		SendMessage (view, EM_SETBKGNDCOLOR, 0, RGB(70,70,70));
		// Setup default font for the log.
		//SendMessage (view, WM_SETFONT, (WPARAM)GetStockObject (DEFAULT_GUI_FONT), FALSE);
		format.cbSize = sizeof(format);
		format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_CHARSET;
		format.dwEffects = 0;
		format.yHeight = 200;
		format.crTextColor = RGB(223,223,223);
		format.bCharSet = ANSI_CHARSET;
		format.bPitchAndFamily = FF_SWISS | VARIABLE_PITCH;
		wcscpy(format.szFaceName, L"DejaVu Sans");	// At least I have it. :p
		SendMessageW(view, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&format);

		ConWindow = view;
		ReleaseDC (hWnd, hdc);

		view = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW, 0, 0, 0, 0, hWnd, NULL, inst, NULL);
		if (view == NULL)
		{
			return -1;
		}
		SetWindowLong (view, GWL_ID, IDC_STATIC_TITLE);
		GameTitleWindow = view;

		return 0;

	case WM_SIZE:
		if (wParam != SIZE_MAXHIDE && wParam != SIZE_MAXSHOW)
		{
			LayoutMainWindow (hWnd, ErrorPane);
		}
		return 0;

	case WM_DRAWITEM:
		// Draw title banner.
		if (wParam == IDC_STATIC_TITLE && DoomStartupInfo.Name.IsNotEmpty())
		{
			const PalEntry *c;

			// Draw the game title strip at the top of the window.
			drawitem = (LPDRAWITEMSTRUCT)lParam;

//.........这里部分代码省略.........
开发者ID:emileb,项目名称:gzdoom,代码行数:101,代码来源:i_main.cpp

示例6: readscreen

static void readscreen(void)
{
  HDC		hScrDC;		/* screen DC */
  HDC		hMemDC;		/* memory DC */
  HBITMAP	hBitmap;	/* handle for our bitmap */
  HBITMAP	hOldBitmap;	/* handle for previous bitmap */
  BITMAP	bm;		/* bitmap properties */
  unsigned int	size;		/* size of bitmap */
  char		*bmbits;	/* contents of bitmap */
  int		w;		/* screen width */
  int		h;		/* screen height */
  int		y;		/* y-coordinate of screen lines to grab */
  int		n = 16;		/* number of screen lines to grab at a time */

  /* Create a screen DC and a memory DC compatible to screen DC */
  hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
  hMemDC = CreateCompatibleDC(hScrDC);

  /* Get screen resolution */
  w = GetDeviceCaps(hScrDC, HORZRES);
  h = GetDeviceCaps(hScrDC, VERTRES);

  /* Create a bitmap compatible with the screen DC */
  hBitmap = CreateCompatibleBitmap(hScrDC, w, n);

  /* Select new bitmap into memory DC */
  hOldBitmap = SelectObject(hMemDC, hBitmap);

  /* Get bitmap properties */
  GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
  size = (unsigned int)bm.bmWidthBytes * bm.bmHeight * bm.bmPlanes;

  bmbits = OPENSSL_malloc(size);
  if (bmbits) {
    /* Now go through the whole screen, repeatedly grabbing n lines */
    for (y = 0; y < h-n; y += n)
    	{
	unsigned char md[MD_DIGEST_LENGTH];

	/* Bitblt screen DC to memory DC */
	BitBlt(hMemDC, 0, 0, w, n, hScrDC, 0, y, SRCCOPY);

	/* Copy bitmap bits from memory DC to bmbits */
	GetBitmapBits(hBitmap, size, bmbits);

	/* Get the hash of the bitmap */
	MD(bmbits,size,md);

	/* Seed the random generator with the hash value */
	RAND_add(md, MD_DIGEST_LENGTH, 0);
	}

    OPENSSL_free(bmbits);
  }

  /* Select old bitmap back into memory DC */
  hBitmap = SelectObject(hMemDC, hOldBitmap);

  /* Clean up */
  DeleteObject(hBitmap);
  DeleteDC(hMemDC);
  DeleteDC(hScrDC);
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:63,代码来源:rand_win.c

示例7: GLimp_SetMode

bool GLimp_SetMode(unsigned *pwidth, unsigned *pheight, int mode, bool fullscreen)
{
	int		width, height, colorBits;

	if (!Vid_GetModeInfo(&width, &height, mode))
	{
		appWPrintf("Invalid mode: %d\n", mode);
		return false;
	}

	appPrintf("Mode %d: %dx%d (%s)\n", mode, width, height, fullscreen ? "fullscreen" : "windowed");

	// destroy the existing window
	if (gl_hWnd)
		GLimp_Shutdown(false);

	colorBits = gl_bitdepth->integer;
	gl_bitdepth->modified = false;

	// do a CDS if needed
	if (fullscreen)
	{
		DEVMODE dm;
		memset(&dm, 0, sizeof(dm));
		dm.dmSize       = sizeof(dm);
		dm.dmPelsWidth  = width;
		dm.dmPelsHeight = height;
		dm.dmFields     = DM_PELSWIDTH|DM_PELSHEIGHT;

		if (colorBits)
		{
			dm.dmBitsPerPel = colorBits;
			dm.dmFields |= DM_BITSPERPEL;
			appPrintf("...using color depth of %d\n", colorBits);
		}
		else
		{
			HDC hdc = GetDC(NULL);
			int bitspixel = GetDeviceCaps(hdc, BITSPIXEL);
			ReleaseDC(0, hdc);
			appPrintf("...using desktop color depth of %d\n", bitspixel);
		}

		MSGLOG(("CDS(%dx%d, FS)\n", dm.dmPelsWidth, dm.dmPelsHeight));
		if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
		{
			appWPrintf("...fullscreen unavailable in this mode\n");
			appPrintf("...setting windowed mode\n");
			fullscreen = false;

			MSGLOG(("CDS(NULL)\n"));
			ChangeDisplaySettings(NULL, 0);
		}
	}
	else	// not fullscreen
	{
		appPrintf("...setting windowed mode\n");
		MSGLOG(("CDS(NULL)\n"));
		ChangeDisplaySettings(NULL, 0);
	}

	*pwidth  = width;
	*pheight = height;
	gl_config.fullscreen = fullscreen;

	gl_hWnd = (HWND) Vid_CreateWindow(width, height, fullscreen);
	if (!gl_hWnd) return false;
	if (!GLimp_InitGL()) return false;	//?? may try to DestroyWindow(force) + CreateWindow() again

	// init gamma
	ReadGamma();
	appPrintf("Gamma: %s\n", gammaStored ? "hardware" : "software");

	return true;
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:75,代码来源:gl_win.cpp

示例8: Sys_CreateConsole

/*
** Sys_CreateConsole
*/
void Sys_CreateConsole( void )
{
	HDC hDC;
	WNDCLASS wc;
	RECT rect;
	const char *DEDCLASS = "JK2MP WinConsole";
	int nHeight;
	int swidth, sheight;
	int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;

	memset( &wc, 0, sizeof( wc ) );

	wc.style         = 0;
	wc.lpfnWndProc   = (WNDPROC) ConWndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = g_wv.hInstance;
	wc.hIcon         = LoadIcon( g_wv.hInstance, MAKEINTRESOURCE(IDI_ICON1));
	wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
	wc.hbrBackground = (HBRUSH__ *)COLOR_INACTIVEBORDER;//(HBRUSH__ *)COLOR_WINDOW;
	wc.lpszMenuName  = 0;
	wc.lpszClassName = DEDCLASS;

	if ( !RegisterClass (&wc) ) {
		return;
	}

	rect.left = 0;
	rect.right = 600;
	rect.top = 0;
	rect.bottom = 450;
	AdjustWindowRect( &rect, DEDSTYLE, FALSE );

	hDC = GetDC( GetDesktopWindow() );
	swidth = GetDeviceCaps( hDC, HORZRES );
	sheight = GetDeviceCaps( hDC, VERTRES );
	ReleaseDC( GetDesktopWindow(), hDC );

	s_wcd.windowWidth = rect.right - rect.left + 1;
	s_wcd.windowHeight = rect.bottom - rect.top + 1;

	s_wcd.hWnd = CreateWindowEx( 0,
							   DEDCLASS,
							   "OpenJK Singleplayer Console",
							   DEDSTYLE,
							   ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,
							   NULL,
							   NULL,
							   g_wv.hInstance,
							   NULL );

	if ( s_wcd.hWnd == NULL )
	{
		return;
	}

	//
	// create fonts
	//
	hDC = GetDC( s_wcd.hWnd );
	nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY), 72);

	s_wcd.hfBufferFont = CreateFont( nHeight,
									  0,
									  0,
									  0,
									  FW_LIGHT,
									  0,
									  0,
									  0,
									  DEFAULT_CHARSET,
									  OUT_DEFAULT_PRECIS,
									  CLIP_DEFAULT_PRECIS,
									  DEFAULT_QUALITY,
									  FF_MODERN | FIXED_PITCH,
									  "Consolas" );

	ReleaseDC( s_wcd.hWnd, hDC );

	//
	// create the input line
	//
	s_wcd.hwndInputLine = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | 
												ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP,
												6, 400, s_wcd.windowWidth-20, 20,
												s_wcd.hWnd, 
												( HMENU ) INPUT_ID,	// child window ID
												g_wv.hInstance, NULL );

	//
	// create the buttons
	//
	s_wcd.hwndButtonCopy = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
												5, 425, 72, 24,
												s_wcd.hWnd, 
												( HMENU ) COPY_ID,	// child window ID
												g_wv.hInstance, NULL );
//.........这里部分代码省略.........
开发者ID:Razish,项目名称:OpenJK-Speed,代码行数:101,代码来源:win_syscon.cpp

示例9: VersionProc

LRESULT CALLBACK VersionProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
  switch (message)
  {
  case WM_INITDIALOG:
    {
      HWND h = GetDlgItem(hDlg,IDC_DEVICEINFO);
      std::string buf;
      buf += "* * * * * * * *\r\n";
      buf += "* ディスプレイ情報\r\n";
      buf += "* * * * * * * *\r\n";
      buf += GetMaxMinDisplayColors(NULL,NULL);
      buf += "---\r\n";
      if(gdiplus_useable){
        HMODULE hmd = GetModuleHandle("gdiplus.dll");
        char b[MAX_PATH] = "";
        GetModuleFileName(hmd,b,sizeof(b)-1);
        buf += "GDI+: 使用可->\"";
        buf += b;
        buf += "\"\r\n";
      }else{
        buf += "GDI+: 使用不可->gdiplus.dllが見つからない\r\n";
      }
      buf += "---\r\n";
      DWORD r;
      const int dcnum1[]     = { RASTERCAPS , CURVECAPS , LINECAPS , POLYGONALCAPS , TEXTCAPS };
      const char * dcname1[] = {"RASTERCAPS","CURVECAPS","LINECAPS","POLYGONALCAPS","TEXTCAPS"};
      const int dcnum2[]     = { 
       NUMBRUSHES , NUMPENS , NUMFONTS , NUMCOLORS ,
       HORZSIZE , VERTSIZE , HORZRES , VERTRES , LOGPIXELSX , LOGPIXELSY ,
       BITSPIXEL , PLANES , ASPECTX , ASPECTY , ASPECTXY , CLIPCAPS , 
       PHYSICALWIDTH , PHYSICALHEIGHT , PHYSICALOFFSETX , PHYSICALOFFSETY , SCALINGFACTORX , SCALINGFACTORY };
      const char * dcname2[] = {
       "NUMBRUSHES","NUMPENS","NUMFONTS","NUMCOLORS",
       "HORZSIZE","VERTSIZE","HORZRES","VERTRES","LOGPIXELSX","LOGPIXELSY",
       "BITSPIXEL","PLANES","ASPECTX","ASPECTY","ASPECTXY","CLIPCAPS",
       "PHYSICALWIDTH","PHYSICALHEIGHT","PHYSICALOFFSETX","PHYSICALOFFSETY","SCALINGFACTORX","SCALINGFACTORY"};
      
      HDC hdc = CreateDC("DISPLAY",NULL,NULL,NULL);
      for(int i = 0; i < sizeof(dcnum1)/sizeof(*dcnum1); i++){
        char b[16];
        r = GetDeviceCaps(hdc,dcnum1[i]);
        wsprintf(b,"%08X",r);
        buf += dcname1[i];
        buf += ": ";
        buf += b;
        buf += "\r\n";
      }
      DeleteDC(hdc);
      buf += "* * * * * * * *\r\n";
      buf += "* プリンタ情報 \r\n";
      buf += "* * * * * * * *\r\n";
      if(hPrintDC == NULL){
        buf += "プリンタDCを取得できません\r\n";
      }else{
        if(hDevNames == NULL){
          buf += "DEVNAMES が NULL です\r\n";
        }else{
          DEVNAMES * pdn = (DEVNAMES *)GlobalLock(hDevNames);
          buf += "デバイスドライバ: ";
          buf += (char *)pdn + pdn->wDriverOffset;
          buf += "\r\n";
          buf += "デバイス名: ";
          buf += (char *)pdn + pdn->wDeviceOffset;
          buf += "\r\n";
          buf += "出力メディア: ";
          buf += (char *)pdn + pdn->wOutputOffset;
          buf += "\r\n";
          GlobalUnlock(hDevNames);
        }
        buf += "---\r\n";
        if(hDevMode == NULL){
          buf += "DEVMODE が NULL です\r\n";
        }else{
          DEVMODE * pdv = (DEVMODE *)GlobalLock(hDevMode);
          char bb[16];
          if(pdv->dmFields & DM_ORIENTATION){wsprintf(bb,"%d",pdv->dmOrientation );buf +=           "ORIENTATION: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_PAPERSIZE){wsprintf(bb,"%d",pdv->dmPaperSize );buf +=               "PAPERSIZE: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_PAPERLENGTH){wsprintf(bb,"%d",pdv->dmPaperLength );buf +=           "PAPERLENGTH: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_PAPERWIDTH){wsprintf(bb,"%d",pdv->dmPaperWidth );buf +=             "PAPERWIDTH: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_POSITION){wsprintf(bb,"%d",pdv->dmPosition );buf +=                 "POSITION: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_SCALE){wsprintf(bb,"%d",pdv->dmScale );buf +=                       "SCALE: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_COPIES){wsprintf(bb,"%d",pdv->dmCopies );buf +=                     "COPIES: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_DEFAULTSOURCE){wsprintf(bb,"%d",pdv->dmDefaultSource );buf +=       "DEFAULTSOURCE: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_PRINTQUALITY){wsprintf(bb,"%d",pdv->dmPrintQuality );buf +=         "PRINTQUALITY: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_COLOR){
            buf += "COLOR: ";
            if(pdv->dmColor == DMCOLOR_COLOR){
              buf += "COLOR";
            }else if(pdv->dmColor == DMCOLOR_MONOCHROME){
              buf += "MONOCHROME";
            }else{
              wsprintf(bb,"%d",pdv->dmColor);
              buf += bb;
            }
            buf+="\r\n";
          }
          if(pdv->dmFields & DM_DUPLEX){wsprintf(bb,"%d",pdv->dmDuplex );buf +=                     "DUPLEX: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_YRESOLUTION){wsprintf(bb,"%d",pdv->dmYResolution );buf +=           "YRESOLUTION: "; buf += bb; buf+="\r\n";}
          if(pdv->dmFields & DM_TTOPTION){
//.........这里部分代码省略.........
开发者ID:pjmtdw,项目名称:kazesomiso,代码行数:101,代码来源:kazesomiso.cpp

示例10: CSourceStream

// the default child constructor...
CPushPinDesktop::CPushPinDesktop(HRESULT *phr, CPushSourceDesktop *pFilter)
        : CSourceStream(NAME("Push Source CPushPinDesktop child/pin"), phr, pFilter, L"Capture"),
		m_bReReadRegistry(0),
		m_bDeDupe(0),
        m_iFrameNumber(0),
		pOldData(NULL),
		m_bConvertToI420(false),
		m_pParent(pFilter),
		m_bFormatAlreadySet(false),
		hRawBitmap(NULL),
		m_bUseCaptureBlt(false),
		previousFrameEndTime(0)
{
	// Get the device context of the main display, just to get some metrics for it...
	globalStart = GetTickCount();

	m_iHwndToTrack = (HWND) read_config_setting(TEXT("hwnd_to_track"), NULL);
    hScrDc = GetDC(m_iHwndToTrack);
	//m_iScreenBitDepth = GetTrueScreenDepth(hScrDc);
	ASSERT(hScrDc != 0); // failure...
	
    // Get the dimensions of the main desktop window as the default
    m_rScreen.left   = m_rScreen.top = 0;
    m_rScreen.right  = GetDeviceCaps(hScrDc, HORZRES); // NB this *fails* for dual monitor support currently... but we just get the wrong width by default, at least with aero windows 7 both can capture both monitors
    m_rScreen.bottom = GetDeviceCaps(hScrDc, VERTRES);

	// now read some custom settings...
	WarmupCounter();
    reReadCurrentPosition(0);

	int config_width = read_config_setting(TEXT("capture_width"), 0);
	ASSERT(config_width >= 0); // negatives not allowed...
	int config_height = read_config_setting(TEXT("capture_height"), 0);
	ASSERT(config_height >= 0); // negatives not allowed, if it's set :)

	if(config_width > 0) {
		int desired = m_rScreen.left + config_width;
		//int max_possible = m_rScreen.right; // disabled check until I get dual monitor working. or should I allow off screen captures anyway?
		//if(desired < max_possible)
			m_rScreen.right = desired;
		//else
		//	m_rScreen.right = max_possible;
	} else {
		// leave full screen
	}

	m_iCaptureConfigWidth = m_rScreen.right - m_rScreen.left;
	ASSERT(m_iCaptureConfigWidth  > 0);

	if(config_height > 0) {
		int desired = m_rScreen.top + config_height;
		//int max_possible = m_rScreen.bottom; // disabled, see above.
		//if(desired < max_possible)
			m_rScreen.bottom = desired;
		//else
		//	m_rScreen.bottom = max_possible;
	} else {
		// leave full screen
	}
	m_iCaptureConfigHeight = m_rScreen.bottom - m_rScreen.top;
	ASSERT(m_iCaptureConfigHeight > 0);

	m_iStretchToThisConfigWidth = read_config_setting(TEXT("stretch_to_width"), 0);
	m_iStretchToThisConfigHeight = read_config_setting(TEXT("stretch_to_height"), 0);
	m_iStretchMode = read_config_setting(TEXT("stretch_mode_high_quality_if_1"), 0);
	ASSERT(m_iStretchToThisConfigWidth >= 0 && m_iStretchToThisConfigHeight >= 0 && m_iStretchMode >= 0); // sanity checks

	m_bUseCaptureBlt = read_config_setting(TEXT("capture_transparent_windows_with_mouse_blink_only_non_aero_if_1"), 0) == 1;

	// default 30 fps...hmm...
	int config_max_fps = read_config_setting(TEXT("default_max_fps"), 30); // TODO allow floats [?] when ever requested
	ASSERT(config_max_fps >= 0);	

	// m_rtFrameLength is also re-negotiated later...
  	m_rtFrameLength = UNITS / config_max_fps; 

	if(is_config_set_to_1(TEXT("track_new_x_y_coords_each_frame_if_1"))) {
		m_bReReadRegistry = 1; // takes 0.416880ms, but I thought it took more when I made it off by default :P
	}
	if(is_config_set_to_1(TEXT("dedup_if_1"))) {
		m_bDeDupe = 1; // takes 10 or 20ms...but useful to me! :)
	}
	m_millisToSleepBeforePollForChanges = read_config_setting(TEXT("millis_to_sleep_between_poll_for_dedupe_changes"), 10);

    wchar_t out[1000];
	swprintf(out, 1000, L"default/from reg read config as: %dx%d -> %dx%d (%dtop %db %dl %dr) %dfps, dedupe? %d, millis between dedupe polling %d, m_bReReadRegistry? %d \n", 
	  m_iCaptureConfigHeight, m_iCaptureConfigWidth, getCaptureDesiredFinalHeight(), getCaptureDesiredFinalWidth(), m_rScreen.top, m_rScreen.bottom, m_rScreen.left, m_rScreen.right, config_max_fps, m_bDeDupe, m_millisToSleepBeforePollForChanges, m_bReReadRegistry);

	LocalOutput(L"warmup the debugging message system");
	__int64 measureDebugOutputSpeed = StartCounter();
	LocalOutput(out);
	LocalOutput("writing a large-ish debug itself took: %.02Lf ms", GetCounterSinceStartMillis(measureDebugOutputSpeed));
	set_config_string_setting(L"last_init_config_was", out);
}
开发者ID:MAMICHAEL,项目名称:screen-capture-recorder-to-video-windows-free,代码行数:95,代码来源:PushSourceDesktop.cpp

示例11: GetDeviceCaps

void    plDynSurfaceWriter::plWinSurface::SetFont( const plString &face, uint16_t size, uint8_t flags, bool aaRGB )
{
    fFontFace = face;
    fFontSize = size;
    fFontFlags = flags;
    fFontAntiAliasRGB = aaRGB;

    bool hadAFont = false;
    if( fFont != nil )
    {
        hadAFont = true;
        plWinFontCache::GetInstance().FreeFont( fFont );    
        fFont = nil;
    }

    if (face.IsEmpty())
        return;

    bool    bold = ( fFontFlags & plDynSurfaceWriter::kFontBold ) ? true : false;
    bool    italic = ( fFontFlags & plDynSurfaceWriter::kFontItalic ) ? true : false;

    int nHeight = -MulDiv( size, GetDeviceCaps( fDC, LOGPIXELSY ), 72 );
    fFont = plWinFontCache::GetInstance().GetMeAFont( face, nHeight, bold ? FW_BOLD : FW_NORMAL, italic, 
                                                        fFontAntiAliasRGB ? ANTIALIASED_QUALITY : DEFAULT_QUALITY );
    if( fFont == nil && fFontAntiAliasRGB )
    {
        static bool warnedCantAntiAlias = false;

        // Creation of font failed; could be that we can't do anti-aliasing? Try not doing it...
        if( !warnedCantAntiAlias )
        {
            plStatusLog::AddLineS( "pipeline.log", "WARNING: Cannot allocate anti-aliased font. Falling back to non-anti-aliased. This will be the only warning" );
            warnedCantAntiAlias = true;
        }

        fFont = plWinFontCache::GetInstance().GetMeAFont( face, nHeight, bold ? FW_BOLD : FW_NORMAL, italic, 
                                                            fFontAntiAliasRGB ? ANTIALIASED_QUALITY : DEFAULT_QUALITY );
    }

    if( fFont == nil )
    {
        hsAssert( false, "Cannot create Windows font for plDynSurfaceWriter" );
        plStatusLog::AddLineS( "pipeline.log", "ERROR: Cannot allocate font for RGB surface! (face: %s, size: %d %s %s)",
                               face.c_str(), nHeight, bold ? "bold" : "", italic ? "italic" : "" );

        fFontFace = plString::Null;
        fFontSize = 0;
        return;
    }

    if( SelectObject( fDC, fFont ) == nil && hadAFont )
    {
        char msg[ 256 ];
        FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nil, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), msg, sizeof( msg ), nil );
        char *ret = strrchr( msg, '\n' );
        if( ret != nil )
            *ret = 0;

        plStatusLog::AddLineS( "pipeline.log", 0xffff0000, "SelectObject() FAILED (%s)", msg );
    }

}
开发者ID:Drakesinger,项目名称:Plasma,代码行数:62,代码来源:plDynSurfaceWriter.cpp

示例12: SaveBmp

//VC下把HBITMAP保存为bmp图片   
BOOL  SaveBmp(HBITMAP     hBitmap, CString     FileName)
{
	HDC     hDC;
	//当前分辨率下每象素所占字节数         
	int     iBits;
	//位图中每象素所占字节数         
	WORD     wBitCount;
	//定义调色板大小,     位图中像素字节大小     ,位图文件大小     ,     写入文件字节数             
	DWORD     dwPaletteSize = 0, dwBmBitsSize = 0, dwDIBSize = 0, dwWritten = 0;
	//位图属性结构             
	BITMAP     Bitmap;
	//位图文件头结构         
	BITMAPFILEHEADER     bmfHdr;
	//位图信息头结构             
	BITMAPINFOHEADER     bi;
	//指向位图信息头结构                 
	LPBITMAPINFOHEADER     lpbi;
	//定义文件,分配内存句柄,调色板句柄             
	HANDLE     fh, hDib, hPal, hOldPal = NULL;

	//计算位图文件每个像素所占字节数             
	hDC = CreateDC(L"DISPLAY", NULL, NULL, NULL);
	iBits = GetDeviceCaps(hDC, BITSPIXEL)     *     GetDeviceCaps(hDC, PLANES);
	DeleteDC(hDC);
	if (iBits <= 1)
		wBitCount = 1;
	else  if (iBits <= 4)
		wBitCount = 4;
	else if (iBits <= 8)
		wBitCount = 8;
	else
		wBitCount = 24;

	GetObject(hBitmap, sizeof(Bitmap), (LPSTR)&Bitmap);
	bi.biSize = sizeof(BITMAPINFOHEADER);
	bi.biWidth = Bitmap.bmWidth;
	bi.biHeight = Bitmap.bmHeight;
	bi.biPlanes = 1;
	bi.biBitCount = wBitCount;
	bi.biCompression = BI_RGB;
	bi.biSizeImage = 0;
	bi.biXPelsPerMeter = 0;
	bi.biYPelsPerMeter = 0;
	bi.biClrImportant = 0;
	bi.biClrUsed = 0;

	dwBmBitsSize = ((Bitmap.bmWidth *wBitCount + 31) / 32) * 4 * Bitmap.bmHeight;

	//为位图内容分配内存             
	hDib = GlobalAlloc(GHND, dwBmBitsSize + dwPaletteSize + sizeof(BITMAPINFOHEADER));
	lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib);
	*lpbi = bi;

	//     处理调色板                 
	hPal = GetStockObject(DEFAULT_PALETTE);
	if (hPal)
	{
		hDC = ::GetDC(NULL);
		hOldPal = ::SelectPalette(hDC, (HPALETTE)hPal, FALSE);
		RealizePalette(hDC);
	}

	//     获取该调色板下新的像素值             
	GetDIBits(hDC, hBitmap, 0, (UINT)Bitmap.bmHeight,
		(LPSTR)lpbi + sizeof(BITMAPINFOHEADER) + dwPaletteSize,
		(BITMAPINFO *)lpbi, DIB_RGB_COLORS);

	//恢复调色板                 
	if (hOldPal)
	{
		::SelectPalette(hDC, (HPALETTE)hOldPal, TRUE);
		RealizePalette(hDC);
		::ReleaseDC(NULL, hDC);
	}


	//创建位图文件                 
	fh = CreateFile(FileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
		FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);

	if (fh == INVALID_HANDLE_VALUE)         return     FALSE;

	//     设置位图文件头             
	bmfHdr.bfType = 0x4D42;     //     "BM"             
	dwDIBSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dwPaletteSize + dwBmBitsSize;
	bmfHdr.bfSize = dwDIBSize;
	bmfHdr.bfReserved1 = 0;
	bmfHdr.bfReserved2 = 0;
	bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER) + dwPaletteSize;
	//     写入位图文件头             
	WriteFile(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
	//     写入位图文件其余内容             
	WriteFile(fh, (LPSTR)lpbi, dwDIBSize, &dwWritten, NULL);
	//清除                 
	GlobalUnlock(hDib);
	GlobalFree(hDib);
	CloseHandle(fh);

	return     TRUE;
//.........这里部分代码省略.........
开发者ID:gao19920804,项目名称:ScreenShot,代码行数:101,代码来源:ScreenShot.cpp

示例13: GetFontSettingFromDB

int GetFontSettingFromDB(char *settings_group, char *prefix, LOGFONT* lf, COLORREF * colour, DWORD flags)
{
	DBVARIANT dbv;
	char idstr[256];
	BYTE style;
	int retval = 0;

	GetDefaultFontSetting(lf, colour);

	if (flags & FIDF_APPENDNAME) mir_snprintf(idstr, SIZEOF(idstr), "%sName", prefix);
	else mir_snprintf(idstr, SIZEOF(idstr), "%s", prefix);

	if (!db_get_ts(NULL, settings_group, idstr, &dbv)) {
		_tcscpy(lf->lfFaceName, dbv.ptszVal);
		db_free(&dbv);
	}
	else retval = 1;

	if (colour) {
		mir_snprintf(idstr, SIZEOF(idstr), "%sCol", prefix);
		*colour = db_get_dw(NULL, settings_group, idstr, *colour);
	}

	mir_snprintf(idstr, SIZEOF(idstr), "%sSize", prefix);
	lf->lfHeight = (char)db_get_b(NULL, settings_group, idstr, lf->lfHeight);

	//wsprintf(idstr, "%sFlags", prefix);
	//if (db_get_dw(NULL, settings_group, idstr, 0) & FIDF_SAVEACTUALHEIGHT) {
	//	HDC hdc = GetDC(0);
	//	lf->lfHeight = -lf->lfHeight;
	//	ReleaseDC(0, hdc);
	//}

	mir_snprintf(idstr, SIZEOF(idstr), "%sSty", prefix);
	style = (BYTE) db_get_b(NULL, settings_group, idstr,
		(lf->lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf->lfItalic ? DBFONTF_ITALIC : 0) | (lf->lfUnderline ? DBFONTF_UNDERLINE : 0) | lf->lfStrikeOut ? DBFONTF_STRIKEOUT : 0);

	lf->lfWidth = lf->lfEscapement = lf->lfOrientation = 0;
	lf->lfWeight = style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL;
	lf->lfItalic = (style & DBFONTF_ITALIC) != 0;
	lf->lfUnderline = (style & DBFONTF_UNDERLINE) != 0;
	lf->lfStrikeOut = (style & DBFONTF_STRIKEOUT) != 0;

	mir_snprintf(idstr, SIZEOF(idstr), "%sSet", prefix);
	lf->lfCharSet = db_get_b(NULL, settings_group, idstr, lf->lfCharSet);

	lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
	lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
	lf->lfQuality = DEFAULT_QUALITY;
	lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;

	if (lf->lfHeight > 0) {
		HDC hdc = GetDC(0);
		if (flags & FIDF_SAVEPOINTSIZE) {
			lf->lfHeight = -MulDiv(lf->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
		} else { // assume SAVEACTUALHEIGHT
			TEXTMETRIC tm;
			HFONT hFont = CreateFontIndirect(lf);
			HFONT hOldFont = (HFONT)SelectObject(hdc, hFont);

			GetTextMetrics(hdc, &tm);

			lf->lfHeight = -(lf->lfHeight - tm.tmInternalLeading);

			SelectObject(hdc, hOldFont);
			DeleteObject(hFont);
		}
		//lf->lfHeight = -MulDiv(lf->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
		ReleaseDC(0, hdc);
	}

	return retval;
}
开发者ID:Ganster41,项目名称:miranda-ng,代码行数:73,代码来源:services.cpp

示例14: Sys_CreateConsole

/*
** Sys_CreateConsole
*/
void Sys_CreateConsole( void ) {
	HDC hDC;
	WNDCLASS wc;
	RECT rect;
	const char *DEDCLASS = WIN32_CONSOLE_CLASS;
	int nHeight;
	int swidth, sheight;
	int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;
	int i;

	memset( &wc, 0, sizeof( wc ) );

	wc.style         = 0;
	wc.lpfnWndProc   = (WNDPROC) ConWndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = win32.hInstance;
	wc.hIcon         = LoadIcon( win32.hInstance, MAKEINTRESOURCE(IDI_ICON1));
	wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
	wc.hbrBackground = (struct HBRUSH__ *)COLOR_WINDOW;
	wc.lpszMenuName  = 0;
	wc.lpszClassName = DEDCLASS;

	if ( !RegisterClass (&wc) ) {
		return;
	}

	rect.left = 0;
	rect.right = 540;
	rect.top = 0;
	rect.bottom = 450;
	AdjustWindowRect( &rect, DEDSTYLE, FALSE );

	hDC = GetDC( GetDesktopWindow() );
	swidth = GetDeviceCaps( hDC, HORZRES );
	sheight = GetDeviceCaps( hDC, VERTRES );
	ReleaseDC( GetDesktopWindow(), hDC );

	s_wcd.windowWidth = rect.right - rect.left + 1;
	s_wcd.windowHeight = rect.bottom - rect.top + 1;

	//s_wcd.hbmLogo = LoadBitmap( win32.hInstance, MAKEINTRESOURCE( IDB_BITMAP_LOGO) );

	s_wcd.hWnd = CreateWindowEx( 0,
							   DEDCLASS,
							   GAME_NAME,
							   DEDSTYLE,
							   ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,
							   NULL,
							   NULL,
							   win32.hInstance,
							   NULL );

	if ( s_wcd.hWnd == NULL ) {
		return;
	}

	//
	// create fonts
	//
	hDC = GetDC( s_wcd.hWnd );
	nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY ), 72 );

	s_wcd.hfBufferFont = CreateFont( nHeight, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH, "Courier New" );

	ReleaseDC( s_wcd.hWnd, hDC );

	//
	// create the input line
	//
	s_wcd.hwndInputLine = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER |
												ES_LEFT | ES_AUTOHSCROLL,
												6, 400, 528, 20,
												s_wcd.hWnd,
												( HMENU ) INPUT_ID,	// child window ID
												win32.hInstance, NULL );

	//
	// create the buttons
	//
	s_wcd.hwndButtonCopy = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
												5, 425, 72, 24,
												s_wcd.hWnd,
												( HMENU ) COPY_ID,	// child window ID
												win32.hInstance, NULL );
	SendMessage( s_wcd.hwndButtonCopy, WM_SETTEXT, 0, ( LPARAM ) "copy" );

	s_wcd.hwndButtonClear = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
												82, 425, 72, 24,
												s_wcd.hWnd,
												( HMENU ) CLEAR_ID,	// child window ID
												win32.hInstance, NULL );
	SendMessage( s_wcd.hwndButtonClear, WM_SETTEXT, 0, ( LPARAM ) "clear" );

	s_wcd.hwndButtonQuit = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
												462, 425, 72, 24,
												s_wcd.hWnd,
//.........这里部分代码省略.........
开发者ID:AndreiBarsan,项目名称:doom3.gpl,代码行数:101,代码来源:win_syscon.cpp

示例15: fghInitialize


//.........这里部分代码省略.........
        if (fgHintPresent(fgDisplay.RootWindow, supported, full_screen))
        {
          fgDisplay.StateFullScreen = full_screen;
        }
      }
    }

#elif TARGET_HOST_MS_WINDOWS

    WNDCLASS wc;
    ATOM atom;

    /* What we need to do is to initialize the fgDisplay global structure here. */
    fgDisplay.Instance = GetModuleHandle( NULL );
    fgDisplay.DisplayName= displayName ? strdup(displayName) : 0 ;
    atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );

    if( atom == 0 )
    {
        ZeroMemory( &wc, sizeof(WNDCLASS) );

        /*
         * Each of the windows should have its own device context, and we
         * want redraw events during Vertical and Horizontal Resizes by
         * the user.
         *
         * XXX Old code had "| CS_DBCLCKS" commented out.  Plans for the
         * XXX future?  Dead-end idea?
         */
        wc.lpfnWndProc    = fgWindowProc;
        wc.cbClsExtra     = 0;
        wc.cbWndExtra     = 0;
        wc.hInstance      = fgDisplay.Instance;
        wc.hIcon          = LoadIcon( fgDisplay.Instance, _T("GLUT_ICON") );

#if defined(_WIN32_WCE)
        wc.style          = CS_HREDRAW | CS_VREDRAW;
#else
        wc.style          = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
        if (!wc.hIcon)
          wc.hIcon        = LoadIcon( NULL, IDI_WINLOGO );
#endif

        wc.hCursor        = LoadCursor( NULL, IDC_ARROW );
        wc.hbrBackground  = NULL;
        wc.lpszMenuName   = NULL;
        wc.lpszClassName  = _T("FREEGLUT");

        /* Register the window class */
        atom = RegisterClass( &wc );
        FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fghInitialize" );
    }

    /* The screen dimensions can be obtained via GetSystemMetrics() calls */
    fgDisplay.ScreenWidth  = GetSystemMetrics( SM_CXSCREEN );
    fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );

    {
        HWND desktop = GetDesktopWindow( );
        HDC  context = GetDC( desktop );

        fgDisplay.ScreenWidthMM  = GetDeviceCaps( context, HORZSIZE );
        fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );

        ReleaseDC( desktop, context );
    }
    /* If we have a DisplayName try to use it for metrics */
    if( fgDisplay.DisplayName )
    {
        HDC context = CreateDC(fgDisplay.DisplayName,0,0,0);
        if( context )
        {
	    fgDisplay.ScreenWidth  = GetDeviceCaps( context, HORZRES );
	    fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
	    fgDisplay.ScreenWidthMM  = GetDeviceCaps( context, HORZSIZE );
	    fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
	    DeleteDC(context);
        }
        else
	    fgWarning("fghInitialize: "
		      "CreateDC failed, Screen size info may be incorrect\n"
          "This is quite likely caused by a bad '-display' parameter");
      
    }
    /* Set the timer granularity to 1 ms */
    timeBeginPeriod ( 1 );

#endif

    fgState.Initialised = GL_TRUE;

    /* Avoid registering atexit callback on Win32 as it results in an access
     * violation due to calling into a module which has been unloaded. */
#if ( TARGET_HOST_MS_WINDOWS == 0 )
    atexit(fgDeinitialize);
#endif

    /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
    fgInitialiseInputDevices();
}
开发者ID:wiplug,项目名称:glvnc,代码行数:101,代码来源:freeglut_init.c


注:本文中的GetDeviceCaps函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。