您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetDC函数代码示例

51自学网 2021-06-01 21:06:13
  C++
这篇教程C++ GetDC函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ZeroMemory

PRBoolnsGLPbufferWGL::Init(nsCanvasRenderingContextGLPrivate *priv){    // XXX lookup SYSTEM32 path!    char *opengl32 = "C://WINDOWS//SYSTEM32//OPENGL32.DLL";    if (!gWGLWrap.OpenLibrary(opengl32))        return PR_FALSE;    gWGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) wglGetProcAddress);    mPriv = priv;        WNDCLASS wc;    PIXELFORMATDESCRIPTOR pfd;    if (!GetClassInfo(GetModuleHandle(NULL), "GLEW", &wc)) {        ZeroMemory(&wc, sizeof(WNDCLASS));        wc.hInstance = GetModuleHandle(NULL);        wc.lpfnWndProc = DefWindowProc;        wc.lpszClassName = "GLEW";        if (!RegisterClass(&wc)) {            LogMessage(NS_LITERAL_CSTRING("Canvas 3D: RegisterClass failed"));            return PR_FALSE;        }    }    // create window    mGlewWindow = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,                                CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);    if (!mGlewWindow) {        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: CreateWindow failed"));        return PR_FALSE;    }    // get the device context    mGlewDC = GetDC(mGlewWindow);    if (!mGlewDC) {        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GetDC failed"));        return PR_FALSE;    }    // find default pixel format    ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);    pfd.nVersion = 1;    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;    int pixelformat = ChoosePixelFormat(mGlewDC, &pfd);    // set the pixel format for the dc    if (!SetPixelFormat(mGlewDC, pixelformat, &pfd)) {        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: SetPixelFormat failed"));        return PR_FALSE;    }    // create rendering context    mGlewWglContext = wglCreateContext(mGlewDC);    if (!mGlewWglContext) {        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: wglCreateContext failed"));        return PR_FALSE;    }    if (!wglMakeCurrent(mGlewDC, (HGLRC) mGlewWglContext)) {        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: wglMakeCurrent failed"));        return PR_FALSE;    }    // grab all the wgl extension pieces that we couldn't grab before    // we had a context    if (!gWGLWrap.Init())        return PR_FALSE;    // XXX look up system32 dir    if (!mGLWrap.OpenLibrary(opengl32)) {        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Failed to open opengl32.dll (only looked in c://windows//system32, fixme)"));        return PR_FALSE;    }    mGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) wglGetProcAddress);    if (!mGLWrap.Init(GLES20Wrap::TRY_NATIVE_GL)) {        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLWrap init failed"));        return PR_FALSE;    }    return PR_TRUE;}
开发者ID:AllenDou,项目名称:firefox,代码行数:88,


示例2: WBRWPANE

CLIPPER WBRWPANE( PARAMS ) // ( hWnd, hDC, Self, bLine, aSizes, nFirstItem,                   //   nClrFore, nClrBack, hFont, aJustify, nStyle                   //   lCellStyle, lFocused ) -> nRowsSkipped                   //   bTextColor, bBkColor, nClrLine, nColorFondo, bFont ) // New's by CesoTech{   HWND hWnd        = _parni( 1 );   HDC hDC          = _parni( 2 );   WORD wRows;   WORD wLastBottom = 0;   WORD wRow        = 1;   WORD wSkipped    = 1;   PCLIPVAR Self    = _param( 3, -1 );   PCLIPVAR bLine   = _param( 4, -1 );   PCLIPVAR pASizes = _param( 5, -1 );   HFONT hFont      = _parni( 9 );   HFONT hOldFont;   BOOL bDestroyDC  = FALSE;   WORD wHeight ;   RECT rct, box, client;   WORD wIndex      = _parni( 6 );   PCLIPVAR bClrFore = 0, bClrBack = 0;   COLORREF clrFore = 0;   COLORREF clrBack = 0;   HPEN hGrayPen    = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );   HPEN hWhitePen   = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); // GetStockObject( WHITE_PEN );   BOOL bColBlock   = pASizes->wType & BLOCK;   PCLIPVAR pAJustify = ISARRAY( 10 ) ? _param( 10, -1 ): 0;   WORD nHeightCtrl ; // by CeSoTech   WORD nStyle = _parni( 11 );   if( PCOUNT() > 6 )   {      if( ISBLOCK( 7 ) )         bClrFore = _param( 7, -1 );      else         clrFore = _parnl( 7 );   }   if( PCOUNT() > 7 )   {      if( ISBLOCK( 8 ) )      {         bClrBack = _param( 8, -1 );         _cEval0( bClrBack );         clrBack = _parnl( -1 );      }      else         clrBack = _parnl( 8 );   }   if( ! hDC )   {      bDestroyDC = TRUE;      hDC = GetDC( hWnd );   }   if( ! pSkip )       pSkip = _Get_Sym( "SKIP" );   if( hFont )      hOldFont = SelectObject( hDC, hFont );   /////////////////////////   // Borremos el Area de la derecha no coubierta   if ( !bAdjBrowse && !bAdjLastCol )   {       GetClientRect( hWnd, &rct );       SetBkColor( hDC, _parnl( 17 ) ) ;       for( wIndex=wIndex ; wIndex <= _parinfa( 5, NULL); wIndex++ )       {            rct.left += _parni( 5, wIndex ) ;       }       if ( !(nStyle == 0 || nStyle == 7 || nStyle == 8 || nStyle == 3) )          rct.left++;       ExtTextOut( hDC, rct.left, rct.top, ETO_OPAQUE | ETO_CLIPPED,                   &rct, "", 0, 0 );       wIndex = _parni( 6 );       GetClientRect( hWnd, &rct );   }   /////////////////////////   GetClientRect( hWnd, &client );   nHeightCtrl = client.bottom-client.top ; // by CeSoTech   wHeight = wLineHeight + 1 ;   wRows = WBrwRowsC( hWnd, hDC, hFont );   if( ! bClrFore )      SetTextColor( hDC, clrFore );      SetBkColor( hDC, clrBack );   while( wRow <= wRows && wSkipped == 1 )//.........这里部分代码省略.........
开发者ID:azulae,项目名称:Gestool,代码行数:101,


示例3: test_logfont

static void test_logfont(void){    LOGFONTA lfa, lfa2;    GpFont *font;    GpStatus stat;    GpGraphics *graphics;    HDC hdc = GetDC(0);    INT style;    GdipCreateFromHDC(hdc, &graphics);    memset(&lfa, 0, sizeof(LOGFONTA));    memset(&lfa2, 0xff, sizeof(LOGFONTA));    /* empty FaceName */    lfa.lfFaceName[0] = 0;    stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);    expect(NotTrueTypeFont, stat);    lstrcpyA(lfa.lfFaceName, "Arial");    stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);    if (stat == FileNotFound)    {        skip("Arial not installed./n");        return;    }    expect(Ok, stat);    stat = GdipGetLogFontA(font, graphics, &lfa2);    expect(Ok, stat);    ok(lfa2.lfHeight < 0, "Expected negative height/n");    expect(0, lfa2.lfWidth);    expect(0, lfa2.lfEscapement);    expect(0, lfa2.lfOrientation);    ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set/n");    expect(0, lfa2.lfItalic);    expect(0, lfa2.lfUnderline);    expect(0, lfa2.lfStrikeOut);    expect(GetTextCharset(hdc), lfa2.lfCharSet);    expect(0, lfa2.lfOutPrecision);    expect(0, lfa2.lfClipPrecision);    expect(0, lfa2.lfQuality);    expect(0, lfa2.lfPitchAndFamily);    GdipDeleteFont(font);    memset(&lfa, 0, sizeof(LOGFONTA));    lfa.lfHeight = 25;    lfa.lfWidth = 25;    lfa.lfEscapement = lfa.lfOrientation = 50;    lfa.lfItalic = lfa.lfUnderline = lfa.lfStrikeOut = TRUE;    memset(&lfa2, 0xff, sizeof(LOGFONTA));    lstrcpyA(lfa.lfFaceName, "Arial");    stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);    expect(Ok, stat);    stat = GdipGetLogFontA(font, graphics, &lfa2);    expect(Ok, stat);    ok(lfa2.lfHeight < 0, "Expected negative height/n");    expect(0, lfa2.lfWidth);    expect(0, lfa2.lfEscapement);    expect(0, lfa2.lfOrientation);    ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set/n");    expect(TRUE, lfa2.lfItalic);    expect(TRUE, lfa2.lfUnderline);    expect(TRUE, lfa2.lfStrikeOut);    expect(GetTextCharset(hdc), lfa2.lfCharSet);    expect(0, lfa2.lfOutPrecision);    expect(0, lfa2.lfClipPrecision);    expect(0, lfa2.lfQuality);    expect(0, lfa2.lfPitchAndFamily);    stat = GdipGetFontStyle(font, &style);    expect(Ok, stat);    ok (style == (FontStyleItalic | FontStyleUnderline | FontStyleStrikeout),        "Expected , got %d/n", style);    GdipDeleteFont(font);    GdipDeleteGraphics(graphics);    ReleaseDC(0, hdc);}
开发者ID:pstrealer,项目名称:wine,代码行数:84,


示例4: ProgressDlgProc

INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam){	static int fontHeight, listWidth;	static int manualAbort;	static HFONT hBoldFont = NULL;	INT_PTR bReturn;	if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))		return bReturn;	switch (message) {	case WM_INITDIALOG:		EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);		hdlgProgress = hdlg;		hwndStatus = GetDlgItem(hdlg, IDC_STATUS);		errorCount = 0;		bShortModeDone = false;		hwndBar = GetDlgItem(hdlg, IDC_PROGRESS);		SendMessage(hwndBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000));		{			HDC hdc;			HFONT hFont, hoFont;			SIZE s;			hdc = GetDC(NULL);			hFont = (HFONT)SendMessage(hdlg, WM_GETFONT, 0, 0);			hoFont = (HFONT)SelectObject(hdc, hFont);			GetTextExtentPoint32(hdc, _T("x"), 1, &s);			SelectObject(hdc, hoFont);			ReleaseDC(NULL, hdc);			fontHeight = s.cy;			RECT rc;			GetClientRect(GetDlgItem(hdlg, IDC_STATUS), &rc);			listWidth = rc.right;			LOGFONT lf;			GetObject((HFONT)SendDlgItemMessage(hdlg, IDC_STATUS, WM_GETFONT, 0, 0), sizeof(lf), &lf);			lf.lfWeight = FW_BOLD;			hBoldFont = CreateFontIndirect(&lf);		}		manualAbort = 0;		hEventRun = CreateEvent(NULL, TRUE, TRUE, NULL);		hEventAbort = CreateEvent(NULL, TRUE, FALSE, NULL);		TranslateDialogDefault(hdlg);		_beginthread(WorkerThread, 0, NULL);		return TRUE;	case WM_MEASUREITEM:		{			LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;			mis->itemWidth = listWidth;			mis->itemHeight = fontHeight;		}		return TRUE;	case WM_DRAWITEM:		TCHAR str[256];		{			LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;			int bold = 0;			HFONT hoFont = NULL;			if ((int)dis->itemID == -1) break;			SendMessage(dis->hwndItem, LB_GETTEXT, dis->itemID, (LPARAM)str);			switch (dis->itemData & STATUS_CLASSMASK) {			case STATUS_MESSAGE:				SetTextColor(dis->hDC, RGB(0, 0, 0));				break;			case STATUS_WARNING:				SetTextColor(dis->hDC, RGB(192, 128, 0));				break;			case STATUS_ERROR:				SetTextColor(dis->hDC, RGB(192, 0, 0));				break;			case STATUS_FATAL:				bold = 1;				SetTextColor(dis->hDC, RGB(192, 0, 0));				break;			case STATUS_SUCCESS:				bold = 1;				SetTextColor(dis->hDC, RGB(0, 192, 0));				break;			}			if (bold) hoFont = (HFONT)SelectObject(dis->hDC, hBoldFont);			ExtTextOut(dis->hDC, dis->rcItem.left, dis->rcItem.top, ETO_CLIPPED | ETO_OPAQUE, &dis->rcItem, str, (UINT)mir_tstrlen(str), NULL);			if (bold) SelectObject(dis->hDC, hoFont);		}		return TRUE;	case WM_PROCESSINGDONE:		SetProgressBar(1000);		if (bShortMode) {			EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE);			EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);			SetDlgItemText(GetParent(hdlg), IDCANCEL, TranslateT("&Finish"));			bShortModeDone = true;			if (bAutoExit)				PostMessage(GetParent(hdlg), WM_COMMAND, IDCANCEL, 0);		}		else {			AddToStatus(STATUS_SUCCESS, TranslateT("Click Next to continue"));//.........这里部分代码省略.........
开发者ID:Seldom,项目名称:miranda-ng,代码行数:101,


示例5: WBRWLINE

CLIPPER WBRWLINE( PARAMS ) // ( hWnd, hDC, nRow, aText, aSizes, nFirstItem, ;                   // nClrFore, nClrBack, hFont, lTree, aJustify, nPressed,                   // nStyle, nColAct, lFocused )                   // bTextColor, bBkColor, nClrLine, lFooter, lSelect,                   // bFont, lDrawFocusRect ) // New's by CesoTech{   HWND hWnd        = _parni( 1 );   HDC hDC          = _parni( 2 );   WORD wRow        = _parni( 3 );   BOOL bDestroyDC  = FALSE;   WORD wHeight;   RECT rct, box;   PCLIPVAR bClrFore, bClrBack;   COLORREF clrFore = 0;   COLORREF clrBack = 0;   HPEN hGrayPen    ;   HPEN hWhitePen   ;   HFONT hFont      = _parni( 9 );   HFONT hOldFont;   BOOL bTree      = _parl( 10 );   BOOL bFooter = ISLOGICAL( 19 ) ? _parl( 19 ) : FALSE ;  // CeSoTech   WORD nHeightCtrl ; // by CeSoTech   hGrayPen    = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );   hWhitePen   = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); // GetStockObject( WHITE_PEN );   if( PCOUNT() > 6 )   {      if( ISBLOCK( 7 ) )      {         bClrFore = _param( 7, -1 );         _cEval0( bClrFore );         clrFore = _parnl( -1 );      }      else         clrFore = _parnl( 7 );   }   if( PCOUNT() > 7 )   {      if( ISBLOCK( 8 ) )      {         bClrBack = _param( 8, -1 );         _cEval0( bClrBack );         clrBack = _parnl( -1 );      }      else         clrBack = _parnl( 8 );   }   if( ! hDC )   {      bDestroyDC = TRUE;      hDC = GetDC( hWnd );   }   if( hFont )      hOldFont = SelectObject( hDC, hFont );   GetClientRect( hWnd, &rct );   nHeightCtrl = rct.bottom-rct.top ; // by CeSoTech   SetTextColor( hDC, clrFore );   SetBkColor( hDC, clrBack );   wHeight = wLineHeight + 1 ;   if ( ( wRow == 0 ) && bDrawHeaders )  // Es una Cabecera      wHeight = wHeaderHeight + 1 ;   if ( ! bFooter )   {      if ( ( wRow == 0 ) && bDrawHeaders )  // Es una Cabecera      {         rct.top    = 0 ;         rct.bottom = wHeaderHeight + 1 ;      }      else      {        rct.top    = ( bDrawHeaders ? wHeaderHeight+1 : 0 ) + (wHeight * (wRow-1) )  ;        rct.bottom = ( bDrawHeaders ? wHeaderHeight+1 : 0 ) + (wHeight * wRow)  ;      }   } else {      rct.top    = rct.bottom - (wFooterHeight+1) ;   }   rct.left   = 0;   PaintTheLine( hDC, &rct, _parni( 6 ), _param( 4, -1 ), _param( 5, -1 ),                 hWhitePen, hGrayPen, bTree,                 ISARRAY(11) ? _param( 11, -1 ) : 0, _parni( 12 ),                 (wRow == 0), _parni( 13 ),                 _parni( 14 ), _parl( 15 ),                 ISBLOCK( 16 ) ? _param( 16, -1 ) : 0,   // CeSoTech                 ISBLOCK( 17 ) ? _param( 17, -1 ) : 0,   // CeSoTech                 wRow, nHeightCtrl,                      // CeSoTech//.........这里部分代码省略.........
开发者ID:azulae,项目名称:Gestool,代码行数:101,


示例6: PalWinProc

LRESULT CALLBACKPalWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){    switch (message)    {        case WM_PAINT:        {            RECT rc = { 0, 0, 31, 32 };            HDC hDC = GetDC(hwnd);            HPEN oldPen;            HBRUSH oldBrush;            int i, a, b;            DefWindowProc(hwnd, message, wParam, lParam);            for(b = 2; b < 30; b++)                for(a = 2; a < 29; a++)                    if ((a + b) % 2 == 1)                        SetPixel(hDC, a, b, GetSysColor(COLOR_BTNHILIGHT));            DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);            DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_TOPLEFT | BF_BOTTOMRIGHT);            SetRect(&rc, 11, 12, 26, 27);            DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);            oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0));            oldBrush = SelectObject(hDC, CreateSolidBrush(bgColor));            Rectangle(hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1);            DeleteObject(SelectObject(hDC, oldBrush));            SetRect(&rc, 4, 5, 19, 20);            DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);            oldBrush = SelectObject(hDC, CreateSolidBrush(fgColor));            Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);            DeleteObject(SelectObject(hDC, oldBrush));            DeleteObject(SelectObject(hDC, oldPen));            for(i = 0; i < 28; i++)            {                SetRect(&rc, 31 + (i % 14) * 16,                        0 + (i / 14) * 16, 16 + 31 + (i % 14) * 16, 16 + 0 + (i / 14) * 16);                DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);                DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT);                oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0));                oldBrush = SelectObject(hDC, CreateSolidBrush(palColors[i]));                Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);                DeleteObject(SelectObject(hDC, oldBrush));                DeleteObject(SelectObject(hDC, oldPen));            }            ReleaseDC(hwnd, hDC);            break;        }        case WM_LBUTTONDOWN:            if (GET_X_LPARAM(lParam) >= 31)            {                fgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14];                InvalidateRect(hwnd, NULL, FALSE);            }            break;        case WM_RBUTTONDOWN:            if (GET_X_LPARAM(lParam) >= 31)            {                bgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14];                InvalidateRect(hwnd, NULL, FALSE);            }            break;        case WM_LBUTTONDBLCLK:            if (GET_X_LPARAM(lParam) >= 31)                if (ChooseColor(&choosecolor))                {                    palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] =                        choosecolor.rgbResult;                    fgColor = choosecolor.rgbResult;                    InvalidateRect(hwnd, NULL, FALSE);                }            break;        case WM_RBUTTONDBLCLK:            if (GET_X_LPARAM(lParam) >= 31)                if (ChooseColor(&choosecolor))                {                    palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] =                        choosecolor.rgbResult;                    bgColor = choosecolor.rgbResult;                    InvalidateRect(hwnd, NULL, FALSE);                }            break;        default:            return DefWindowProc(hwnd, message, wParam, lParam);    }    return 0;}
开发者ID:rmallof,项目名称:reactos,代码行数:91,


示例7: GLW_InitDriver

/*====================GLW_InitDriverSet the pixelformat for the window before it isshown, and create the rendering context====================*/static bool GLW_InitDriver( glimpParms_t parms ) {    PIXELFORMATDESCRIPTOR src = 	{		sizeof(PIXELFORMATDESCRIPTOR),	// size of this pfd		1,								// version number		PFD_DRAW_TO_WINDOW |			// support window		PFD_SUPPORT_OPENGL |			// support OpenGL		PFD_DOUBLEBUFFER,				// double buffered		PFD_TYPE_RGBA,					// RGBA type		32,								// 32-bit color depth		0, 0, 0, 0, 0, 0,				// color bits ignored		8,								// 8 bit destination alpha		0,								// shift bit ignored		0,								// no accumulation buffer		0, 0, 0, 0, 					// accum bits ignored		24,								// 24-bit z-buffer			8,								// 8-bit stencil buffer		0,								// no auxiliary buffer		PFD_MAIN_PLANE,					// main layer		0,								// reserved		0, 0, 0							// layer masks ignored    };	common->Printf( "Initializing OpenGL driver/n" );	//	// get a DC for our window if we don't already have one allocated	//	if ( win32.hDC == NULL ) {		common->Printf( "...getting DC: " );		if ( ( win32.hDC = GetDC( win32.hWnd ) ) == NULL ) {			common->Printf( "^3failed^0/n" );			return false;		}		common->Printf( "succeeded/n" );	}	// the multisample path uses the wgl 	if ( wglChoosePixelFormatARB ) {		win32.pixelformat = GLW_ChoosePixelFormat( win32.hDC, parms.multiSamples, parms.stereo );	} else {		// this is the "classic" choose pixel format path		common->Printf( "Using classic ChoosePixelFormat/n" );		// eventually we may need to have more fallbacks, but for		// now, ask for everything		if ( parms.stereo ) {			common->Printf( "...attempting to use stereo/n" );			src.dwFlags |= PFD_STEREO;		}		//		// choose, set, and describe our desired pixel format.  If we're		// using a minidriver then we need to bypass the GDI functions,		// otherwise use the GDI functions.		//		if ( ( win32.pixelformat = ChoosePixelFormat( win32.hDC, &src ) ) == 0 ) {			common->Printf( "...^3GLW_ChoosePFD failed^0/n");			return false;		}		common->Printf( "...PIXELFORMAT %d selected/n", win32.pixelformat );	}	// get the full info	DescribePixelFormat( win32.hDC, win32.pixelformat, sizeof( win32.pfd ), &win32.pfd );	glConfig.colorBits = win32.pfd.cColorBits;	glConfig.depthBits = win32.pfd.cDepthBits;	glConfig.stencilBits = win32.pfd.cStencilBits;	// XP seems to set this incorrectly	if ( !glConfig.stencilBits ) {		glConfig.stencilBits = 8;	}	// the same SetPixelFormat is used either way	if ( SetPixelFormat( win32.hDC, win32.pixelformat, &win32.pfd ) == FALSE ) {		common->Printf( "...^3SetPixelFormat failed^0/n", win32.hDC );		return false;	}	//	// startup the OpenGL subsystem by creating a context and making it current	//	common->Printf( "...creating GL context: " );	win32.hGLRC = CreateOpenGLContextOnDC( win32.hDC, r_debugContext.GetBool() );	if ( win32.hGLRC == 0 ) {		common->Printf( "^3failed^0/n" );		return false;	}	common->Printf( "succeeded/n" );//.........这里部分代码省略.........
开发者ID:469486139,项目名称:DOOM-3-BFG,代码行数:101,


示例8: getHCursor

bool WindowsCursorShapeGrabber::grabPixels(const PixelFormat *pixelFormat){  HCURSOR hCursor = getHCursor();  if (hCursor == 0) {    return false;  }  m_lastHCursor = hCursor;  // Get bitmap mask  ICONINFO iconInfo;  if (!GetIconInfo(hCursor, &iconInfo)) {    return false;  }  if (iconInfo.hbmMask == NULL) {    return false;  }  bool isColorShape = (iconInfo.hbmColor != NULL);  BITMAP bmMask;  if (!GetObject(iconInfo.hbmMask, sizeof(BITMAP), (LPVOID)&bmMask)) {    DeleteObject(iconInfo.hbmMask);    return false;  }  if (bmMask.bmPlanes != 1 || bmMask.bmBitsPixel != 1) {    DeleteObject(iconInfo.hbmMask);    return false;  }  m_cursorShape.setHotSpot(iconInfo.xHotspot, iconInfo.yHotspot);  int width = bmMask.bmWidth;  int height = isColorShape ? bmMask.bmHeight : bmMask.bmHeight/2;  int widthBytes = bmMask.bmWidthBytes;  const FrameBuffer *pixels= m_cursorShape.getPixels();  m_cursorShape.setProperties(&Dimension(width, height), pixelFormat);  std::vector<char> maskBuff(widthBytes * bmMask.bmHeight);  if (maskBuff.empty()) {    DeleteObject(iconInfo.hbmMask);    return true;  }  char *mask = &maskBuff.front();  // FIXME: Use try-catch block to escape code duplication  // and free resources on an error.  bool result = GetBitmapBits(iconInfo.hbmMask,                              widthBytes * bmMask.bmHeight,                              mask) != 0;  DeleteObject(iconInfo.hbmMask);  if (!result) {    return false;  }  // Get cursor pixels  HDC screenDC = GetDC(0);  if (screenDC == NULL) {    return false;  }  Screen::BMI bmi;  try {    m_screen.getBMI(&bmi, screenDC);  } catch (...) {    return false;  }  bmi.bmiHeader.biBitCount = pixelFormat->bitsPerPixel;  bmi.bmiHeader.biWidth = width;  bmi.bmiHeader.biHeight = -height;  bmi.bmiHeader.biCompression = BI_BITFIELDS;  bmi.red   = pixelFormat->redMax   << pixelFormat->redShift;  bmi.green = pixelFormat->greenMax << pixelFormat->greenShift;  bmi.blue  = pixelFormat->blueMax  << pixelFormat->blueShift;  HDC destDC = CreateCompatibleDC(NULL);  if (destDC == NULL) {    DeleteDC(screenDC);    return false;  }  void *buffer;  HBITMAP hbmDIB = CreateDIBSection(destDC, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, &buffer, NULL, NULL);  if (hbmDIB == 0) {    DeleteDC(destDC);    DeleteDC(screenDC);    return false;  }  HBITMAP hbmOld = (HBITMAP)SelectObject(destDC, hbmDIB);  result = DrawIconEx(destDC, 0, 0, hCursor, 0, 0, 0, NULL, DI_IMAGE) != 0;  memcpy(pixels->getBuffer(), buffer, pixels->getBufferSize());//.........这里部分代码省略.........
开发者ID:Aliceljm1,项目名称:TightVNC-1,代码行数:101,


示例9: WindowFunc

static LONG WINAPI WindowFunc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp){	switch(msg)	{	case WM_QUERYNEWPALETTE:	case WM_PALETTECHANGED:		if(NULL!=fsWin32Internal.hPlt)		{			SelectPalette(fsWin32Internal.hDC,fsWin32Internal.hPlt,FALSE);			RealizePalette(fsWin32Internal.hDC);		}		return DefWindowProc(hWnd,msg,wp,lp);	case WM_CREATE:		fsWin32Internal.hDC=GetDC(hWnd);		YsSetPixelFormat(fsWin32Internal.hDC);		fsWin32Internal.hRC=wglCreateContext(fsWin32Internal.hDC);		wglMakeCurrent(fsWin32Internal.hDC,fsWin32Internal.hRC);		if(0==doubleBuffer)		{			glDrawBuffer(GL_FRONT);		}		InitializeOpenGL(hWnd);		break;	case WM_SIZE:		wglMakeCurrent(fsWin32Internal.hDC,fsWin32Internal.hRC);		break;	case WM_PAINT:		wglMakeCurrent(fsWin32Internal.hDC,fsWin32Internal.hRC);		exposure=1;		return DefWindowProc(hWnd,msg,wp,lp);	case WM_COMMAND:		break;	case WM_DESTROY:		exit(1);		break;	case WM_MOUSEWHEEL:		{			int step;			step=HIWORD(wp);			if(step>=0x8000)			{				step-=0x10000;			}			step/=WHEEL_DELTA;			if(step>0)			{				while(step>0)				{					if(nKeyBufUsed<NKEYBUF)					{						keyBuffer[nKeyBufUsed++]=FSKEY_WHEELUP;					}					step--;				}			}			else if(step<0)			{				while(step<0)				{					if(nKeyBufUsed<NKEYBUF)					{						keyBuffer[nKeyBufUsed++]=FSKEY_WHEELDOWN;					}					step++;				}			}		}		break;	case WM_SYSKEYDOWN:		if((lp & (1<<29))!=0 && // Alt		  (wp==VK_MENU ||		   wp==VK_OEM_1 ||		   wp==VK_OEM_PLUS ||		   wp==VK_OEM_COMMA ||		   wp==VK_OEM_MINUS ||		   wp==VK_OEM_PERIOD ||		   wp==VK_OEM_2 ||		   wp==VK_OEM_3 ||		   wp==VK_OEM_4 ||		   wp==VK_OEM_5 ||		   wp==VK_OEM_6 ||		   wp==VK_OEM_7 ||		   wp==VK_OEM_8 ||#ifdef VK_OEM_AX		   wp==VK_OEM_AX ||#endif		   wp==VK_OEM_102 ||		   wp=='0' ||		   wp=='1' ||		   wp=='2' ||		   wp=='3' ||		   wp=='4' ||		   wp=='5' ||		   wp=='6' ||		   wp=='7' ||		   wp=='8' ||		   wp=='9' ||		   wp=='A' ||		   wp=='B' ||		   wp=='C' ||//.........这里部分代码省略.........
开发者ID:hewolf,项目名称:Engineering-Computation,代码行数:101,


示例10: GLW_InitDriver

/*** GLW_InitDriver**** - get a DC if one doesn't exist** - create an HGLRC if one doesn't exist*/static qboolean GLW_InitDriver( int colorbits ){	int		tpfd;	int		depthbits, stencilbits;    static PIXELFORMATDESCRIPTOR pfd;		// save between frames since 'tr' gets cleared	ri.Printf( PRINT_ALL, "Initializing OpenGL driver/n" );	//	// get a DC for our window if we don't already have one allocated	//	if ( glw_state.hDC == NULL )	{		ri.Printf( PRINT_ALL, "...getting DC: " );		if ( ( glw_state.hDC = GetDC( g_wv.hWnd ) ) == NULL )		{			ri.Printf( PRINT_ALL, "failed/n" );			return qfalse;		}		ri.Printf( PRINT_ALL, "succeeded/n" );	}	if ( colorbits == 0 )	{		colorbits = glw_state.desktopBitsPixel;	}	//	// implicitly assume Z-buffer depth == desktop color depth	//	if ( r_depthbits->integer == 0 ) {		if ( colorbits > 16 ) {			depthbits = 24;		} else {			depthbits = 16;		}	} else {		depthbits = r_depthbits->integer;	}	//	// do not allow stencil if Z-buffer depth likely won't contain it	//	stencilbits = r_stencilbits->integer;	if ( depthbits < 24 )	{		stencilbits = 0;	}	//	// make two attempts to set the PIXELFORMAT	//	//	// first attempt: r_colorbits, depthbits, and r_stencilbits	//	if ( !glw_state.pixelFormatSet )	{		GLW_CreatePFD( &pfd, colorbits, depthbits, stencilbits, (qboolean)r_stereo->integer );		if ( ( tpfd = GLW_MakeContext( &pfd ) ) != TRY_PFD_SUCCESS )		{			if ( tpfd == TRY_PFD_FAIL_HARD )			{				ri.Printf( PRINT_WARNING, "...failed hard/n" );				return qfalse;			}			//			// punt if we've already tried the desktop bit depth and no stencil bits			//			if ( ( r_colorbits->integer == glw_state.desktopBitsPixel ) &&				 ( stencilbits == 0 ) )			{				ReleaseDC( g_wv.hWnd, glw_state.hDC );				glw_state.hDC = NULL;				ri.Printf( PRINT_ALL, "...failed to find an appropriate PIXELFORMAT/n" );				return qfalse;			}			//			// second attempt: desktop's color bits and no stencil			//			if ( colorbits > glw_state.desktopBitsPixel )			{				colorbits = glw_state.desktopBitsPixel;			}			GLW_CreatePFD( &pfd, colorbits, depthbits, 0, (qboolean)r_stereo->integer );			if ( GLW_MakeContext( &pfd ) != TRY_PFD_SUCCESS )			{				if ( glw_state.hDC )				{//.........这里部分代码省略.........
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:101,


示例11: GLW_SetMode

/*** GLW_SetMode*/static rserr_t GLW_SetMode( int mode, 							int colorbits, 							qboolean cdsFullscreen ){	HDC hDC;	const char *win_fs[] = { "W", "FS" };	int		cdsRet;	DEVMODE dm;			//	// print out informational messages	//	ri.Printf( PRINT_ALL, "...setting mode %d:", mode );	if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )	{		ri.Printf( PRINT_ALL, " invalid mode/n" );		return RSERR_INVALID_MODE;	}	ri.Printf( PRINT_ALL, " %d %d %s/n", glConfig.vidWidth, glConfig.vidHeight, win_fs[cdsFullscreen] );	//	// check our desktop attributes	//	hDC = GetDC( GetDesktopWindow() );	glw_state.desktopBitsPixel = GetDeviceCaps( hDC, BITSPIXEL );	glw_state.desktopWidth = GetDeviceCaps( hDC, HORZRES );	glw_state.desktopHeight = GetDeviceCaps( hDC, VERTRES );	ReleaseDC( GetDesktopWindow(), hDC );	//	// verify desktop bit depth	//	if ( glw_state.desktopBitsPixel < 15 || glw_state.desktopBitsPixel == 24 )	{		if ( colorbits == 0 || ( !cdsFullscreen && colorbits >= 15 ) )		{			// since I can't be bothered trying to mess around with asian codepages and MBCS stuff for a windows			//	error box that'll only appear if something's seriously fucked then I'm going to fallback to			//	english text when these would otherwise be used...			//			char sErrorHead[1024];	// ott			extern qboolean Language_IsAsian(void);			Q_strncpyz(sErrorHead, Language_IsAsian() ? "Low Desktop Color Depth" : SP_GetStringTextString("CON_TEXT_LOW_DESKTOP_COLOUR_DEPTH"), sizeof(sErrorHead) );			const char *psErrorBody = Language_IsAsian() ?												"It is highly unlikely that a correct windowed/n"												"display can be initialized with the current/n"												"desktop display depth.  Select 'OK' to try/n"												"anyway.  Select 'Cancel' to try a fullscreen/n"												"mode instead."												:												SP_GetStringTextString("CON_TEXT_TRY_ANYWAY");			if ( MessageBox( NULL, 													psErrorBody,						sErrorHead,						MB_OKCANCEL | MB_ICONEXCLAMATION ) != IDOK )			{				return RSERR_INVALID_MODE;			}		}	}	// do a CDS if needed	if ( cdsFullscreen )	{		memset( &dm, 0, sizeof( dm ) );				dm.dmSize = sizeof( dm );				dm.dmPelsWidth  = glConfig.vidWidth;		dm.dmPelsHeight = glConfig.vidHeight;		dm.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT;		if ( r_displayRefresh->integer != 0 )		{			dm.dmDisplayFrequency = r_displayRefresh->integer;			dm.dmFields |= DM_DISPLAYFREQUENCY;		}				// try to change color depth if possible		if ( colorbits != 0 )		{			if ( glw_state.allowdisplaydepthchange )			{				dm.dmBitsPerPel = colorbits;				dm.dmFields |= DM_BITSPERPEL;				ri.Printf( PRINT_ALL, "...using colorsbits of %d/n", colorbits );			}			else			{				ri.Printf( PRINT_ALL, "WARNING:...changing depth not supported on Win95 < pre-OSR 2.x/n" );			}		}		else		{//.........这里部分代码省略.........
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:101,


示例12: window_init

static int window_init(WININFO *info, bool use_custom_pixel_format = false, int custom_pixel_format = 0){    unsigned int	PixelFormat;    DWORD			dwExStyle, dwStyle;    DEVMODE			dmScreenSettings;    RECT			rec;    WNDCLASS		wc;    ZeroMemory(&wc, sizeof(WNDCLASS));    wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;    wc.lpfnWndProc = WndProc;    wc.hInstance = info->hInstance;    wc.lpszClassName = info->wndclass;    if (!RegisterClass(&wc))        return(0);    if (info->full)    {        dmScreenSettings.dmSize = sizeof(DEVMODE);        dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;        dmScreenSettings.dmBitsPerPel = 24;        dmScreenSettings.dmPelsWidth = XRES;        dmScreenSettings.dmPelsHeight = YRES;        if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)            return(0);        dwExStyle = WS_EX_APPWINDOW;        dwStyle = WS_VISIBLE | WS_POPUP;// | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;        ShowCursor(0);    }    else    {        dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;        dwStyle = WS_VISIBLE | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU;    }    rec.left = 0;    rec.top = 0;    rec.right = XRES;    rec.bottom = YRES;    AdjustWindowRect(&rec, dwStyle, 0);    windowRect.left = 0;    windowRect.top = 0;    windowRect.right = XRES;    windowRect.bottom = YRES;    info->hWnd = CreateWindowEx(dwExStyle, wc.lpszClassName, "live coding", dwStyle,        (GetSystemMetrics(SM_CXSCREEN) - rec.right + rec.left) >> 1,        (GetSystemMetrics(SM_CYSCREEN) - rec.bottom + rec.top) >> 1,        rec.right - rec.left, rec.bottom - rec.top, 0, 0, info->hInstance, 0);    if (!info->hWnd)        return(0);    if (!(info->hDC = GetDC(info->hWnd)))        return(0);    if (!use_custom_pixel_format) {        if (!(PixelFormat = ChoosePixelFormat(info->hDC, &pfd)))            return(0);        if (!SetPixelFormat(info->hDC, PixelFormat, &pfd))            return(0);    } else {        if (!SetPixelFormat(info->hDC, custom_pixel_format, &pfd))            return(0);    }    if (!(info->hRC = wglCreateContext(info->hDC)))        return(0);    if (!wglMakeCurrent(info->hDC, info->hRC))        return(0);    return(1);}
开发者ID:chock-mostlyharmless,项目名称:mostlyharmless,代码行数:76,


示例13: MessageBox

//Basic Init, create the font, backbuffer, etcWINDOW *initscr(void){   // _windows = new WINDOW[20];         //initialize all of our variables    BITMAPINFO bmi;    lastchar=-1;    inputdelay=-1;    std::string typeface;char * typeface_c;std::ifstream fin;fin.open("data//FONTDATA"); if (!fin.is_open()){     MessageBox(WindowHandle, "Failed to open FONTDATA, loading defaults.",                NULL, NULL);     fontheight=16;     fontwidth=8; } else {     getline(fin, typeface);     typeface_c= new char [typeface.size()+1];     strcpy (typeface_c, typeface.c_str());     fin >> fontwidth;     fin >> fontheight;     if ((fontwidth <= 4) || (fontheight <=4)){         MessageBox(WindowHandle, "Invalid font size specified!",                    NULL, NULL);        fontheight=16;        fontwidth=8;     } }    halfwidth=fontwidth / 2;    halfheight=fontheight / 2;    WindowWidth=80*fontwidth;    WindowHeight=25*fontheight;    WindowX=(GetSystemMetrics(SM_CXSCREEN) / 2)-WindowWidth/2;    //center this    WindowY=(GetSystemMetrics(SM_CYSCREEN) / 2)-WindowHeight/2;   //sucker    WinCreate();    //Create the actual window, register it, etc    CheckMessages();    //Let the message queue handle setting up the window    WindowDC = GetDC(WindowHandle);    backbuffer = CreateCompatibleDC(WindowDC);    ZeroMemory(&bmi, sizeof(BITMAPINFO));    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);    bmi.bmiHeader.biWidth = WindowWidth;    bmi.bmiHeader.biHeight = -WindowHeight;    bmi.bmiHeader.biPlanes = 1;    bmi.bmiHeader.biBitCount=8;    bmi.bmiHeader.biCompression = BI_RGB;   //store it in uncompressed bytes    bmi.bmiHeader.biSizeImage = WindowWidth * WindowHeight * 1;    bmi.bmiHeader.biClrUsed=16;         //the number of colors in our palette    bmi.bmiHeader.biClrImportant=16;    //the number of colors in our palette    backbit = CreateDIBSection(0, &bmi, DIB_RGB_COLORS, (void**)&dcbits, NULL, 0);    DeleteObject(SelectObject(backbuffer, backbit));//load the buffer into DC int nResults = AddFontResourceExA("data//termfont",FR_PRIVATE,NULL);   if (nResults>0){    font = CreateFont(fontheight, fontwidth, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,                      ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,                      PROOF_QUALITY, FF_MODERN, typeface_c);   //Create our font  } else {      MessageBox(WindowHandle, "Failed to load default font, using FixedSys.",                NULL, NULL);       font = CreateFont(fontheight, fontwidth, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,                      ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,                      PROOF_QUALITY, FF_MODERN, "FixedSys");   //Create our font   }    //FixedSys will be user-changable at some point in time??    SetBkMode(backbuffer, TRANSPARENT);//Transparent font backgrounds    SelectObject(backbuffer, font);//Load our font into the DC//    WindowCount=0;    delete typeface_c;    mainwin = newwin(25,80,0,0);    return mainwin;   //create the 'stdscr' window and return its ref};
开发者ID:Gremour,项目名称:Cataclysm,代码行数:74,


示例14: render_proc

/* render_proc: *  Timer proc that updates the window. */static void render_proc(void){   int top_line, bottom_line;   HDC hdc = NULL;   HWND allegro_wnd = win_get_window();   /* to prevent reentrant calls */   if (render_semaphore)      return;   render_semaphore = TRUE;   /* to prevent the drawing threads and the rendering proc    * from concurrently accessing the dirty lines array.    */   _enter_gfx_critical();   if (!gdi_screen) {      _exit_gfx_critical();      render_semaphore = FALSE;      return;   }   /* pseudo dirty rectangles mechanism:    *  at most only one GDI call is performed for each frame,    *  a true dirty rectangles mechanism makes the demo game    *  unplayable in 640x480 on my system.    */   /* find the first dirty line */   top_line = 0;   while (!gdi_dirty_lines[top_line])      top_line++;   if (top_line < gfx_gdi.h) {      /* find the last dirty line */      bottom_line = gfx_gdi.h-1;      while (!gdi_dirty_lines[bottom_line])         bottom_line--;      hdc = GetDC(allegro_wnd);      if (_color_depth == 8)         set_palette_to_hdc(hdc, palette);      blit_to_hdc(gdi_screen, hdc, 0, top_line, 0, top_line,                  gfx_gdi.w, bottom_line - top_line + 1);      /* update mouse pointer if needed */      if (mouse_on) {         if ((mouse_ypos+wgdi_mouse_sprite->h > top_line) && (mouse_ypos <= bottom_line)) {            blit(gdi_screen, mouse_backbuffer, mouse_xpos, mouse_ypos, 0, 0,                 mouse_backbuffer->w, mouse_backbuffer->h);            update_mouse_pointer(mouse_xpos, mouse_ypos, TRUE);         }      }            /* clean up the dirty lines */      while (top_line <= bottom_line)         gdi_dirty_lines[top_line++] = 0;      ReleaseDC(allegro_wnd, hdc);   }   _exit_gfx_critical();   /* simulate vertical retrace */   PulseEvent(vsync_event);   render_semaphore = FALSE;}
开发者ID:dodamn,项目名称:pkg-allegro4.2,代码行数:77,


示例15: DlgProc

//---------------------------------------------------------------------------LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg,	WPARAM wParam, LPARAM lParam){	HDC hdc;	HWND hWndDateTimePicker, hWndOK;	LONG ptrStyles = GetWindowLong(hWndDlg, GWL_STYLE);	// This will represent the dimensions of the whole screen	RECT rctClient;	// Create a black brush	HBRUSH BlackBrush;	// Select the black brush	HBRUSH oldBrush =(HBRUSH) GetSysColor(COLOR_BACKGROUND);	hWndDateTimePicker = GetDlgItem(hWndDlg, IDC_TIMETOWAKEUP);	hWndOK = GetDlgItem(hWndDlg, IDOK);	SYSTEMTIME tmeCurrent;	switch (Msg)	{	case WM_INITDIALOG:		return TRUE;	case WM_COMMAND:		switch (wParam)		{		case IDCANCEL:			EndDialog(hWndDlg, 0);			return TRUE;		case IDC_SET_BTN:			// Get the time that the user had set and store it			// in the tmeSet variable			DateTime_GetSystemtime(hWndDateTimePicker, &tmeSet);						TCHAR str[20];			GetTimeFormat(				MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT),				0,				&tmeSet,				NULL,				str,				20);			MessageBox(hWndDlg, str, _T("System Time"), MB_OK);			hdc = GetDC(hWndDlg);			BlackBrush = CreateSolidBrush(RGB(0, 0, 0));			SelectObject(hdc, BlackBrush);			// TODO: Add your control notification handler code here			// Get the screen dimensions			DialogWidth = GetSystemMetrics(SM_CXSCREEN);			DialogHeight = GetSystemMetrics(SM_CYSCREEN);			// When sets the clock wave sound, remove the title bar and the borders			ptrStyles &= ~WS_TILEDWINDOW;			SetWindowLong(hWndDlg, GWL_STYLE, ptrStyles);			// Occupy the whole screen			SetWindowPos(hWndDlg, HWND_TOPMOST, 0, 0, DialogWidth, DialogHeight, SWP_SHOWWINDOW);			// Get the dimension of the current dialog box			GetWindowRect(hWndDlg, &rctClient);			// Paint the dialog box in black			Rectangle(hdc, rctClient.left, rctClient.top, rctClient.right, rctClient.bottom);			// Restore the original brush			//SelectObject(hdc, oldBrush);			// Start the timer control			SetTimer(hWndDlg, IDC_CHECKTIME, 2000, 0);			// We don't need to see the cursor			ShowCursor(FALSE);			ReleaseDC(hWndDlg, hdc);			return TRUE;		}		break;	case WM_TIMER:		// Get the current time on the computer		GetLocalTime(&tmeCurrent);		// Compare the current time with the time the user had set		// If they are the same, then start playing the CD		if ((tmeCurrent.wYear == tmeSet.wYear) &&			(tmeCurrent.wMonth == tmeSet.wMonth) &&			//(tmeCurrent.wDayOfWeek == tmeSet.wDayOfWeek) &&			(tmeCurrent.wDay == tmeSet.wDay) &&			(tmeCurrent.wHour == tmeSet.wHour) &&			(tmeCurrent.wMinute == tmeSet.wMinute) /* &&												   (tmeCurrent.wSecond == tmeSet.wSecond) &&												   (tmeCurrent.wMilliseconds == tmeSet.wMilliseconds) */)//.........这里部分代码省略.........
开发者ID:andrebonner,项目名称:Deckers,代码行数:101,


示例16: VolumeMeterProc

LRESULT CALLBACK VolumeMeterProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){    VolumeMeterData *meter;    switch(message)    {        case WM_NCCREATE:            {                CREATESTRUCT *pCreateData = (CREATESTRUCT*)lParam;                meter = (VolumeMeterData*)malloc(sizeof(VolumeMeterData));                zero(meter, sizeof(VolumeMeterData));                SetWindowLongPtr(hwnd, 0, (LONG_PTR)meter);                meter->curVolume = VOL_MIN;                meter->curMax = VOL_MIN;                meter->curPeak = VOL_MIN;                                meter->cx = pCreateData->cx;                meter->cy = pCreateData->cy;                for(int i = 0; i < 16; i++)                {                    meter->graduations[i] = (DBtoLog(-96.0f + 6.0f * (i+1)) - minLinear) / (maxLinear - minLinear);                }                /*create color brushes*/                meter->hRed  = CreateSolidBrush(0x2929f4);                meter->hGreen  = CreateSolidBrush(0x2bf13e);                meter->hGreenDark  = CreateSolidBrush(0x177d20);                meter->hBlack = CreateSolidBrush(0x000000);                meter->hGray = CreateSolidBrush(0x777777);                meter->hLightGray = CreateSolidBrush(0xCCCCCC);                                return TRUE;            }        case WM_DESTROY:            {                meter = GetVolumeMeterData(hwnd);                                DeleteObject(meter->hRed);                DeleteObject(meter->hGreen);                DeleteObject(meter->hGreenDark);                DeleteObject(meter->hBlack);                DeleteObject(meter->hGray);                DeleteObject(meter->hLightGray);                                if(meter)                    free(meter);                break;            }        case WM_PAINT:            {                meter = GetVolumeMeterData(hwnd);                PAINTSTRUCT ps;                HDC hDC = BeginPaint(hwnd, &ps);                meter->DrawVolumeMeter(hDC);                EndPaint(hwnd, &ps);                break;            }        case WM_SIZE:            {                meter = GetVolumeMeterData(hwnd);                meter->cx = LOWORD(lParam);                meter->cy = HIWORD(lParam);                HDC hDC = GetDC(hwnd);                meter->DrawVolumeMeter(hDC);                ReleaseDC(hwnd, hDC);                break;            }        default:            return DefWindowProc(hwnd, message, wParam, lParam);    }    return 0;}
开发者ID:AndrewHolder,项目名称:OBS,代码行数:85,


示例17: GetDC

void CMuleToolbarCtrl::SetAllButtonsWidth(){	if (GetButtonCount() == 0)		return;	if (m_eLabelType == LabelsBelow)	{		CDC *pDC = GetDC();		CFont *pFnt = GetFont();		CFont *pOldFnt = pDC->SelectObject(pFnt);		CRect r(0,0,0,0);		// calculate the max. possible button-size		int iCalcSize = 0;		for (int i = 0; i < m_buttoncount ; i++)		{			if (!IsButtonHidden(IDC_TOOLBARBUTTON + i))			{				pDC->DrawText(TBStrings[i], -1, r, DT_SINGLELINE | DT_CALCRECT); 				if (r.Width() > iCalcSize)					iCalcSize = r.Width();			}		}		iCalcSize += 10;		pDC->SelectObject(pOldFnt);		ReleaseDC(pDC);		if (!thePrefs.GetUseReBarToolbar())		{			GetClientRect(&r);			int bc = GetButtonCount();			if (bc == 0)				bc = 1;			int iMaxPossible = r.Width() / bc;			// if the buttons are to big, reduze their size			if (iCalcSize > iMaxPossible)				iCalcSize = iMaxPossible;		}		else		{			if (iCalcSize < 56)				iCalcSize = 56;			else if (iCalcSize > 72)				iCalcSize = 72;		}		SetButtonWidth(iCalcSize, iCalcSize);	}	else	{		int iSmallIconsButtonHeight;		if (theApp.m_ullComCtrlVer < MAKEDLLVERULL(6, 0, 0, 0)) {			// Win98,WinME,Win2000: Comtrl32 prior to 6.0 cannot make a toolbar smaller than 22 pixels			// in height and if it gets larger than 22 pixels the icons do not get centered vertically.			iSmallIconsButtonHeight = 22;		}		else			iSmallIconsButtonHeight = GetSystemMetrics(SM_CYSCREEN) <= 600 ? 16 : 28;		if (m_eLabelType == NoLabels)		{			DWORD dwSize = GetButtonSize();			int iFixedButtonWidth;			int iFixedButtonHeight = HIWORD(dwSize);			if (m_sizBtnBmp.cx == 16)			{				iFixedButtonWidth = 28;				iFixedButtonHeight = iSmallIconsButtonHeight;			}			else			{				iFixedButtonWidth = 56;			}			// it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize'			SetButtonWidth(iFixedButtonWidth, iFixedButtonWidth);			SetButtonSize(CSize(iFixedButtonWidth, iFixedButtonHeight));		}		else		{			int iFixedButtonHeight = 0;			if (m_sizBtnBmp.cx == 16)				iFixedButtonHeight = iSmallIconsButtonHeight;			// it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize'			SetButtonWidth(0, 0);			SetButtonSize(CSize(0, iFixedButtonHeight));		}	}}
开发者ID:rusingineer,项目名称:emulemorph,代码行数:91,


示例18: void

bool COpenGLControl::initOpenGL(HINSTANCE hInstance, HWND* a_hWnd, int iMajorVersion, int iMinorVersion, void (*a_initScene)(LPVOID), void (*a_renderScene)(LPVOID), void(*a_releaseScene)(LPVOID), LPVOID lpParam){	if(!initGLEW(hInstance))return false;	hWnd = a_hWnd;	hDC = GetDC(*hWnd);	bool bError = false;	PIXELFORMATDESCRIPTOR pfd;	if(iMajorVersion <= 2)	{		memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));		pfd.nSize		= sizeof(PIXELFORMATDESCRIPTOR);		pfd.nVersion   = 1;		pfd.dwFlags    = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;		pfd.iPixelType = PFD_TYPE_RGBA;		pfd.cColorBits = 32;		pfd.cDepthBits = 32;		pfd.iLayerType = PFD_MAIN_PLANE; 		int iPixelFormat = ChoosePixelFormat(hDC, &pfd);		if (iPixelFormat == 0)return false;		if(!SetPixelFormat(hDC, iPixelFormat, &pfd))return false;		// Create the old style context (OpenGL 2.1 and before)		hRC = wglCreateContext(hDC);		if(hRC)wglMakeCurrent(hDC, hRC);		else bError = true;	}	else if(WGLEW_ARB_create_context && WGLEW_ARB_pixel_format)	{		const int iPixelFormatAttribList[] =		{			WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,			WGL_SUPPORT_OPENGL_ARB, GL_TRUE,			WGL_DOUBLE_BUFFER_ARB, GL_TRUE,			WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,			WGL_COLOR_BITS_ARB, 32,			WGL_DEPTH_BITS_ARB, 24,			WGL_STENCIL_BITS_ARB, 8,			0 // End of attributes list		};		int iContextAttribs[] =		{			WGL_CONTEXT_MAJOR_VERSION_ARB, iMajorVersion,			WGL_CONTEXT_MINOR_VERSION_ARB, iMinorVersion,			WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,			0 // End of attributes list		};		int iPixelFormat, iNumFormats;		wglChoosePixelFormatARB(hDC, iPixelFormatAttribList, NULL, 1, &iPixelFormat, (UINT*)&iNumFormats);		// PFD seems to be only redundant parameter now		if(!SetPixelFormat(hDC, iPixelFormat, &pfd))return false;		hRC = wglCreateContextAttribsARB(hDC, 0, iContextAttribs);		// If everything went OK		if(hRC) wglMakeCurrent(hDC, hRC);		else bError = true;	}	else bError = true;		if(bError)	{		// Generate error messages		char sErrorMessage[255], sErrorTitle[255];		sprintf(sErrorMessage, "OpenGL %d.%d is not supported! Please download latest GPU drivers!", iMajorVersion, iMinorVersion);		sprintf(sErrorTitle, "OpenGL %d.%d Not Supported", iMajorVersion, iMinorVersion);		MessageBox(*hWnd, sErrorMessage, sErrorTitle, MB_ICONINFORMATION);		return false;	}	renderScene = a_renderScene;	initScene = a_initScene;	releaseScene = a_releaseScene;	if(initScene != NULL)initScene(lpParam);	return true;}
开发者ID:Derongan,项目名称:ecs175HW5,代码行数:84,


示例19: GLimp_Init

/*===================GLimp_InitThis is the platform specific OpenGL initialization function.  Itis responsible for loading OpenGL, initializing it,creating a window of the appropriate size, doingfullscreen manipulations, etc.  Its overall responsibility isto make sure that a functional OpenGL subsystem is operatingwhen it returns to the ref.If there is any failure, the renderer will revert back to safeparameters and try again.===================*/bool GLimp_Init( glimpParms_t parms ) {	const char	*driverName;	HDC		hDC;	cmdSystem->AddCommand( "testSwapBuffers", GLimp_TestSwapBuffers, CMD_FL_SYSTEM, "Times swapbuffer options" );	common->Printf( "Initializing OpenGL subsystem with multisamples:%i stereo:%i fullscreen:%i/n", 		parms.multiSamples, parms.stereo, parms.fullScreen );	// check our desktop attributes	hDC = GetDC( GetDesktopWindow() );	win32.desktopBitsPixel = GetDeviceCaps( hDC, BITSPIXEL );	win32.desktopWidth = GetDeviceCaps( hDC, HORZRES );	win32.desktopHeight = GetDeviceCaps( hDC, VERTRES );	ReleaseDC( GetDesktopWindow(), hDC );	// we can't run in a window unless it is 32 bpp	if ( win32.desktopBitsPixel < 32 && parms.fullScreen <= 0 ) {		common->Printf("^3Windowed mode requires 32 bit desktop depth^0/n");		return false;	}	// save the hardware gamma so it can be	// restored on exit	GLimp_SaveGamma();	// create our window classes if we haven't already	GLW_CreateWindowClasses();	// this will load the dll and set all our qgl* function pointers,	// but doesn't create a window	// r_glDriver is only intended for using instrumented OpenGL	// dlls.  Normal users should never have to use it, and it is	// not archived.	driverName = r_glDriver.GetString()[0] ? r_glDriver.GetString() : "opengl32";	if ( !QGL_Init( driverName ) ) {		common->Printf( "^3GLimp_Init() could not load r_glDriver /"%s/"^0/n", driverName );		return false;	}	// getting the wgl extensions involves creating a fake window to get a context,	// which is pretty disgusting, and seems to mess with the AGP VAR allocation	GLW_GetWGLExtensionsWithFakeWindow();	// Optionally ChangeDisplaySettings to get a different fullscreen resolution.	if ( !GLW_ChangeDislaySettingsIfNeeded( parms ) ) {		GLimp_Shutdown();		return false;	}	// try to create a window with the correct pixel format	// and init the renderer context	if ( !GLW_CreateWindow( parms ) ) {		GLimp_Shutdown();		return false;	}	glConfig.isFullscreen = parms.fullScreen;	glConfig.isStereoPixelFormat = parms.stereo;	glConfig.nativeScreenWidth = parms.width;	glConfig.nativeScreenHeight = parms.height;	glConfig.multisamples = parms.multiSamples;	glConfig.pixelAspect = 1.0f;	// FIXME: some monitor modes may be distorted									// should side-by-side stereo modes be consider aspect 0.5?	// get the screen size, which may not be reliable...	// If we use the windowDC, I get my 30" monitor, even though the window is	// on a 27" monitor, so get a dedicated DC for the full screen device name.	const idStr deviceName = GetDeviceName( Max( 0, parms.fullScreen - 1 ) );	HDC deviceDC = CreateDC( deviceName.c_str(), deviceName.c_str(), NULL, NULL );	const int mmWide = GetDeviceCaps( win32.hDC, HORZSIZE );	DeleteDC( deviceDC );	if ( mmWide == 0 ) {		glConfig.physicalScreenWidthInCentimeters = 100.0f;	} else {		glConfig.physicalScreenWidthInCentimeters = 0.1f * mmWide;	}//.........这里部分代码省略.........
开发者ID:469486139,项目名称:DOOM-3-BFG,代码行数:101,


示例20: dt_ctl_set_display_profile

// Get the display ICC profile of the monitor associated with the widget.// For X display, uses the ICC profile specifications version 0.2 from// http://burtonini.com/blog/computers/xicc// Based on code from Gimp's modules/cdisplay_lcms.cvoid dt_ctl_set_display_profile(){  if(!dt_control_running()) return;  // make sure that no one gets a broken profile  // FIXME: benchmark if the try is really needed when moving/resizing the window. Maybe we can just lock it  // and block  if(pthread_rwlock_trywrlock(&darktable.control->xprofile_lock))    return; // we are already updating the profile. Or someone is reading right now. Too bad we can't            // distinguish that. Whatever ...  GtkWidget *widget = dt_ui_center(darktable.gui->ui);  guint8 *buffer = NULL;  gint buffer_size = 0;  gchar *profile_source = NULL;#if defined GDK_WINDOWING_X11  // we will use the xatom no matter what configured when compiled without colord  gboolean use_xatom = TRUE;#if defined USE_COLORDGTK  gboolean use_colord = TRUE;  gchar *display_profile_source = dt_conf_get_string("ui_last/display_profile_source");  if(display_profile_source)  {    if(!strcmp(display_profile_source, "xatom"))      use_colord = FALSE;    else if(!strcmp(display_profile_source, "colord"))      use_xatom = FALSE;    g_free(display_profile_source);  }#endif  /* let's have a look at the xatom, just in case ... */  if(use_xatom)  {    GdkScreen *screen = gtk_widget_get_screen(widget);    if(screen == NULL) screen = gdk_screen_get_default();    int monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget));    char *atom_name;    if(monitor > 0)      atom_name = g_strdup_printf("_ICC_PROFILE_%d", monitor);    else      atom_name = g_strdup("_ICC_PROFILE");    profile_source = g_strdup_printf("xatom %s", atom_name);    GdkAtom type = GDK_NONE;    gint format = 0;    gdk_property_get(gdk_screen_get_root_window(screen), gdk_atom_intern(atom_name, FALSE), GDK_NONE, 0,                     64 * 1024 * 1024, FALSE, &type, &format, &buffer_size, &buffer);    g_free(atom_name);  }#ifdef USE_COLORDGTK  /* also try to get the profile from colord. this will set the value asynchronously! */  if(use_colord)  {    CdWindow *window = cd_window_new();    GtkWidget *center_widget = dt_ui_center(darktable.gui->ui);    cd_window_get_profile(window, center_widget, NULL, dt_ctl_get_display_profile_colord_callback, NULL);  }#endif#elif defined GDK_WINDOWING_QUARTZ  GdkScreen *screen = gtk_widget_get_screen(widget);  if(screen == NULL) screen = gdk_screen_get_default();  int monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget));  CGDirectDisplayID ids[monitor + 1];  uint32_t total_ids;  CMProfileRef prof = NULL;  if(CGGetOnlineDisplayList(monitor + 1, &ids[0], &total_ids) == kCGErrorSuccess && total_ids == monitor + 1)    CMGetProfileByAVID(ids[monitor], &prof);  if(prof != NULL)  {    CFDataRef data;    data = CMProfileCopyICCData(NULL, prof);    CMCloseProfile(prof);    UInt8 *tmp_buffer = (UInt8 *)g_malloc(CFDataGetLength(data));    CFDataGetBytes(data, CFRangeMake(0, CFDataGetLength(data)), tmp_buffer);    buffer = (guint8 *)tmp_buffer;    buffer_size = CFDataGetLength(data);    CFRelease(data);  }  profile_source = g_strdup("osx color profile api");#elif defined G_OS_WIN32  (void)widget;  HDC hdc = GetDC(NULL);  if(hdc != NULL)  {    DWORD len = 0;    GetICMProfile(hdc, &len, NULL);    gchar *path = g_new(gchar, len);//.........这里部分代码省略.........
开发者ID:powentan,项目名称:darktable,代码行数:101,


示例21: GLW_CreateWindow

/*=======================GLW_CreateWindowResponsible for creating the Win32 window.If fullscreen, it won't have a border=======================*/static bool GLW_CreateWindow( glimpParms_t parms ) {	int				x, y, w, h;	if ( !GLW_GetWindowDimensions( parms, x, y, w, h ) ) {		return false;	}	int				stylebits;	int				exstyle;	if ( parms.fullScreen != 0 ) {		exstyle = WS_EX_TOPMOST;		stylebits = WS_POPUP|WS_VISIBLE|WS_SYSMENU;	} else {		exstyle = 0;		stylebits = WINDOW_STYLE|WS_SYSMENU;	}	win32.hWnd = CreateWindowEx (		 exstyle, 		 WIN32_WINDOW_CLASS_NAME,		 GAME_NAME,		 stylebits,		 x, y, w, h,		 NULL,		 NULL,		 win32.hInstance,		 NULL);	if ( !win32.hWnd ) {		common->Printf( "^3GLW_CreateWindow() - Couldn't create window^0/n" );		return false;	}	::SetTimer( win32.hWnd, 0, 100, NULL );	ShowWindow( win32.hWnd, SW_SHOW );	UpdateWindow( win32.hWnd );	common->Printf( "...created window @ %d,%d (%dx%d)/n", x, y, w, h );	// makeCurrent NULL frees the DC, so get another	win32.hDC = GetDC( win32.hWnd );	if ( !win32.hDC ) {		common->Printf( "^3GLW_CreateWindow() - GetDC()failed^0/n" );		return false;	}	// Check to see if we can get a stereo pixel format, even if we aren't going to use it,	// so the menu option can be 	if ( GLW_ChoosePixelFormat( win32.hDC, parms.multiSamples, true ) != -1 ) {		glConfig.stereoPixelFormatAvailable = true;	} else {		glConfig.stereoPixelFormatAvailable = false;	}	if ( !GLW_InitDriver( parms ) ) {		ShowWindow( win32.hWnd, SW_HIDE );		DestroyWindow( win32.hWnd );		win32.hWnd = NULL;		return false;	}	SetForegroundWindow( win32.hWnd );	SetFocus( win32.hWnd );	glConfig.isFullscreen = parms.fullScreen;	return true;}
开发者ID:469486139,项目名称:DOOM-3-BFG,代码行数:75,


示例22: switch

voidnsThebesDeviceContext::CalcPrintingSize(){    if (!mPrintingSurface)        return;    PRBool inPoints = PR_TRUE;    gfxSize size;    switch (mPrintingSurface->GetType()) {    case gfxASurface::SurfaceTypeImage:        inPoints = PR_FALSE;        size = reinterpret_cast<gfxImageSurface*>(mPrintingSurface.get())->GetSize();        break;#if defined(MOZ_ENABLE_GTK2) || defined(XP_WIN) || defined(XP_OS2)    case gfxASurface::SurfaceTypePDF:        inPoints = PR_TRUE;        size = reinterpret_cast<gfxPDFSurface*>(mPrintingSurface.get())->GetSize();        break;#endif#ifdef MOZ_ENABLE_GTK2    case gfxASurface::SurfaceTypePS:        inPoints = PR_TRUE;        size = reinterpret_cast<gfxPSSurface*>(mPrintingSurface.get())->GetSize();        break;#endif#ifdef XP_MACOSX    case gfxASurface::SurfaceTypeQuartz:        inPoints = PR_TRUE; // this is really only true when we're printing        size = reinterpret_cast<gfxQuartzSurface*>(mPrintingSurface.get())->GetSize();        break;#endif#ifdef XP_WIN    case gfxASurface::SurfaceTypeWin32:    case gfxASurface::SurfaceTypeWin32Printing:    {        inPoints = PR_FALSE;        HDC dc =  GetPrintHDC();        if (!dc)            dc = GetDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET));        size.width = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, HORZRES)/mPrintingScale, AppUnitsPerDevPixel());        size.height = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, VERTRES)/mPrintingScale, AppUnitsPerDevPixel());        mDepth = (PRUint32)::GetDeviceCaps(dc, BITSPIXEL);        if (dc != (HDC)GetPrintHDC())            ReleaseDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET), dc);        break;    }#endif#ifdef XP_OS2    case gfxASurface::SurfaceTypeOS2:    {        inPoints = PR_FALSE;        // we already set the size in the surface constructor we set for        // printing, so just get those values here        size = reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetSize();        // as they are in pixels we need to scale them to app units        size.width = NSFloatPixelsToAppUnits(size.width, AppUnitsPerDevPixel());        size.height = NSFloatPixelsToAppUnits(size.height, AppUnitsPerDevPixel());        // still need to get the depth from the device context        HDC dc = GetPrintHDC();        LONG value;        if (DevQueryCaps(dc, CAPS_COLOR_BITCOUNT, 1, &value))            mDepth = value;        else            mDepth = 8; // default to 8bpp, should be enough for printers        break;    }#endif    default:        NS_ERROR("trying to print to unknown surface type");    }    if (inPoints) {        // For printing, CSS inches and physical inches are identical        // so it doesn't matter which we use here        mWidth = NSToCoordRound(float(size.width) * AppUnitsPerPhysicalInch() / 72);        mHeight = NSToCoordRound(float(size.height) * AppUnitsPerPhysicalInch() / 72);    } else {        mWidth = NSToIntRound(size.width);        mHeight = NSToIntRound(size.height);    }}
开发者ID:lofter2011,项目名称:Icefox,代码行数:87,


示例23: InitInstance

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){    WNDCLASSEX wcFrame = {        sizeof(WNDCLASSEX),        CS_HREDRAW | CS_VREDRAW/*style*/,        FrameWndProc,        0/*cbClsExtra*/,        0/*cbWndExtra*/,        hInstance,        LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)),        LoadCursor(0, IDC_ARROW),        0/*hbrBackground*/,        0/*lpszMenuName*/,        szFrameClass,        (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_MDI_APP), IMAGE_ICON,            GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)    };    ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class#if 0    WNDCLASS wcChild = {        CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW,        ChildWndProc,        0/*cbClsExtra*/,        0/*cbWndExtra*/,        hInstance,        0/*hIcon*/,        LoadCursor(0, IDC_ARROW),        0/*hbrBackground*/,        0/*lpszMenuName*/,        szChildClass    };    ATOM hChildWndClass = RegisterClass(&wcChild); // register child windows class#else    // WNDCLASSEX wcChild = {    //     sizeof(WNDCLASSEX),    //     CS_HREDRAW | CS_VREDRAW/*style*/,    //     ChildWndProc,    //     0/*cbClsExtra*/,    //     sizeof(HANDLE)/*cbWndExtra*/,    //     hInstance,    //     LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)),    //     LoadCursor(0, IDC_ARROW),    //     0/*hbrBackground*/,    //     0/*lpszMenuName*/,    //     szChildClass,    //     (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDC_MDI_APP), IMAGE_ICON,    //         GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)    // };    // ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class#endif    HMENU hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP));    HMENU hMenuOptions = GetSubMenu(hMenu, ID_OPTIONS_MENU);    // HMENU hChildMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP_CHILD));    INITCOMMONCONTROLSEX icc = {        sizeof(INITCOMMONCONTROLSEX),        ICC_BAR_CLASSES    };    HDC hdc = GetDC(0);    hMenuFrame = hMenu;//  hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);    hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MDI_APP));    hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif"));    ReleaseDC(0, hdc);    hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,//  hFrameWnd = CreateWindow(szFrameClass, szTitle,                    WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,                    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,                    NULL/*hWndParent*/, hMenuFrame, hInstance, NULL/*lpParam*/);    if (!hFrameWnd) {        return FALSE;    }    if (InitCommonControlsEx(&icc))    {        int nParts[3];        TBBUTTON toolbarBtns[] = {            {0, 0, 0, TBSTYLE_SEP},            {0, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON},            {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},            {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON},            {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON},            {4, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},            {5, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},        };        hToolBar = CreateToolbarEx(hFrameWnd, WS_CHILD|WS_VISIBLE,            IDC_TOOLBAR, 2, hInstance, IDB_TOOLBAR, toolbarBtns,            sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON));        CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_CHECKED);        // Create the status bar        hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,                                        "", hFrameWnd, IDC_STATUSBAR);        if (!hStatusBar)            return FALSE;//.........这里部分代码省略.........
开发者ID:GYGit,项目名称:reactos,代码行数:101,


示例24: CreateDummyWindow

//.........这里部分代码省略.........   // Data about OpenGL are gathered, proper Pixel Format is choosed.    // Destroy Dummy Window and proceed to creation of proper window.    // Disabling and deleting all rendering contexts    wglMakeCurrent( NULL, NULL );     wglDeleteContext( mhRC );    mhRC = NULL;    // Disabling device context    ReleaseDC( hWnd, mhDC );     mhDC = 0;   	// Deleting window    DestroyWindow( hWnd );      // Unregistering window class    if(TRUE != UnregisterClass( L"DummyWindowClass", GetModuleHandle(NULL) ))	{		return CPUT_ERROR;	}    // Clear message queue    MSG msg = { 0 };    while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )    {        TranslateMessage( &msg );        DispatchMessage( &msg );    }	hWnd = mpWindow->GetHWnd();       // Acquiring Device Context    mhDC = GetDC( hWnd );    if ( mhDC == NULL )    {        cerr << "Error! Cannot create device context." << endl;		        DestroyOGLContext();	        return CPUT_ERROR;    }      // Activating Pixel Format    if ( !SetPixelFormat( mhDC, PixelFormat, &pfdLegacy ) )    {	        cerr << "Error! Cannot init pixel format." << endl;        DestroyOGLContext();	        return CPUT_ERROR;	}     // OpenGL 4.0 Core profile settings    uint32 glAttributes[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 4,                              WGL_CONTEXT_MINOR_VERSION_ARB, 0,                              WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,                              GL_CONTEXT_PROFILE_MASK, GL_CONTEXT_CORE_PROFILE_BIT,                              0, 0 };   //         GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,     //   GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,    // Debug version supports better debugging#ifdef _DEBUG    glAttributes[5] |= WGL_CONTEXT_DEBUG_BIT_ARB;#endif     // Try to create OpenGL context in new way    mhRC = wglCreateContextAttribsARB( mhDC, 0, (const int *) &glAttributes );    if ( mhRC == NULL )    {
开发者ID:GameTechDev,项目名称:OpenGLESTessellation,代码行数:67,


示例25: WBrwRect

CLIPPER WBrwRect( PARAMS ) // ( hWnd, nRow, aSizes, nFirstItem, nCol,                           //   nLineStyle, nWidthVScroll ){   HWND hWnd        = ( HWND ) _parnl( 1 );   HDC hDC          = GetDC( hWnd );   WORD wRow        = _parni( 2 );   WORD wHeight ;   RECT rct;   WORD nStyle = ISNUM( 6 ) ? _parni( 6 ) : -1 ; // CeSoTech   #ifdef __CLIPPER__      PCLIPVAR paSizes = _param( 3, 0x8000 );      WORD wLen        = _VARRAYLEN( paSizes );   #else      #ifdef __HARBOUR__         void * paSizes = ( void * ) _param( 3, IT_ARRAY );         WORD wLen      = _parinfa( 3, 0 );      #else         void * paSizes = ( void * ) _param( 3, 0x8000 );         WORD wLen      = _VARRAYLEN( paSizes );      #endif   #endif   WORD wIndex      = _parni( 4 );   WORD wCol        = _parni( 5 );   WORD wMaxRight;   LONG l;   if( !wCol || wCol > wLen )        return;   GetWindowRect( hWnd, &rct );   wMaxRight = rct.right - 2;   wHeight = wLineHeight + 1 ;   rct.top    = rct.top + ( bDrawHeaders ? wHeaderHeight+1 : 0 ) +                (wHeight * (wRow-1) ) ;   rct.bottom = rct.top + wHeight;   rct.right  = rct.left;   while( wIndex <= wCol )   {        rct.left   = rct.right;        #ifndef __FLAT__           rct.right  = ( wIndex == wLen && bAdjLastCol ? wMaxRight                                         : rct.left + GetInt( paSizes, wIndex ) );        #else           #ifndef __HARBOUR__              #define _parnl(x,y) PARNL(x,params,y);           #endif           l = _parnl( 3, wIndex );           rct.right  = ( wIndex == wLen && bAdjLastCol ? wMaxRight                                         : rct.left + l );           #undef _parnl        #endif        if( rct.right >= wMaxRight )        {            wIndex = wCol + 1;   // ya no pintamos m
C++ GetDIBits函数代码示例
C++ GetDB函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。