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


C++ CreatePen函数代码示例

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


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

示例1: drawProgressBarPart

static HRESULT drawProgressBarPart(HRESULT hr, struct drawState *s)
{
	int progress;
	LONG indeterminatePos;
	HTHEME theme;
	RECT r;
	RECT rBorder, rFill[2];
	int i, nFill;
	TEXTMETRICW tm;
	int sysColor;

	if (hr != S_OK)
		return hr;
	if (s->p->progressBarModelColumn == -1)
		return S_OK;

	progress = uiprivTableProgress(s->t, s->iItem, s->iSubItem, s->p->progressBarModelColumn, &indeterminatePos);

	theme = OpenThemeData(s->t->hwnd, L"PROGRESS");

	if (GetTextMetricsW(s->dc, &tm) == 0) {
		logLastError(L"GetTextMetricsW()");
		hr = E_FAIL;
		goto fail;
	}
	r = s->m->subitemBounds;
	// this sets the height of the progressbar and vertically centers it in one fell swoop
	r.top += (r.bottom - tm.tmHeight - r.top) / 2;
	r.bottom = r.top + tm.tmHeight;

	// TODO check errors
	rBorder = r;
	InflateRect(&rBorder, -1, -1);
	if (theme != NULL) {
		RECT crect;

		hr = GetThemeBackgroundContentRect(theme, s->dc,
			PP_TRANSPARENTBAR, PBBS_NORMAL,
			&rBorder, &crect);
		if (hr != S_OK) {
			logHRESULT(L"GetThemeBackgroundContentRect()", hr);
			goto fail;
		}
		hr = DrawThemeBackground(theme, s->dc,
			PP_TRANSPARENTBAR, PBBS_NORMAL,
			&crect, NULL);
		if (hr != S_OK) {
			logHRESULT(L"DrawThemeBackground() border", hr);
			goto fail;
		}
	} else {
		HPEN pen, prevPen;
		HBRUSH brush, prevBrush;

		sysColor = COLOR_HIGHLIGHT;
		if (s->m->selected)
			sysColor = COLOR_HIGHLIGHTTEXT;

		// TODO check errors everywhere
		pen = CreatePen(PS_SOLID, 1, GetSysColor(sysColor));
		prevPen = (HPEN) SelectObject(s->dc, pen);
		brush = (HBRUSH) GetStockObject(NULL_BRUSH);
		prevBrush = (HBRUSH) SelectObject(s->dc, brush);
		Rectangle(s->dc, rBorder.left, rBorder.top, rBorder.right, rBorder.bottom);
		SelectObject(s->dc, prevBrush);
		SelectObject(s->dc, prevPen);
		DeleteObject(pen);
	}

	nFill = 1;
	rFill[0] = r;
	// TODO check error
	InflateRect(&rFill[0], -1, -1);
	if (progress != -1)
		rFill[0].right -= (rFill[0].right - rFill[0].left) * (100 - progress) / 100;
	else {
		LONG barWidth;
		LONG pieceWidth;

		// TODO explain all this
		// TODO this should really start the progressbar scrolling into view instead of already on screen when first set
		rFill[1] = rFill[0];		// save in case we need it
		barWidth = rFill[0].right - rFill[0].left;
		pieceWidth = barWidth / indeterminateSegments;
		rFill[0].left += indeterminatePos % barWidth;
		if ((rFill[0].left + pieceWidth) >= rFill[0].right) {
			// make this piece wrap back around
			nFill++;
			rFill[1].right = rFill[1].left + (pieceWidth - (rFill[0].right - rFill[0].left));
		} else
			rFill[0].right = rFill[0].left + pieceWidth;
	}
	for (i = 0; i < nFill; i++)
		if (theme != NULL) {
			hr = DrawThemeBackground(theme, s->dc,
				PP_FILL, PBFS_NORMAL,
				&rFill[i], NULL);
			if (hr != S_OK) {
				logHRESULT(L"DrawThemeBackground() fill", hr);
				goto fail;
//.........这里部分代码省略.........
开发者ID:NoSuchProcess,项目名称:libui,代码行数:101,代码来源:tabledraw.cpp

示例2: WndProc


//.........这里部分代码省略.........
		leftMouse=true;
        rightMouse=false;
		if(lPunktow >= sizeof(Punkty)/sizeof(POINT)) lPunktow = 0; // przepe³nienie tablicy klikniêæ
		Punkty[lPunktow].x = LOWORD(lParam); // zapisanie wspó³rzêdnych kursora w tablicy klikniêæ
		Punkty[lPunktow].y = HIWORD(lParam);
		rozmiary[lPunktow] = ii;
		//if (negatyw) negatywT[lPunktow] = true;
		//else negatywT[lPunktow] = false;

		lPunktow++;
		InvalidateRect(Okno, NULL, leftMouse); // wymuszenie meldunku WM_PAINT
		return 0;

	case WM_RBUTTONDOWN: // obs³uga wciœniêcia prawego przycisku myszki
        leftMouse=false;
        rightMouse=true;
        if(lPunktow2 >= sizeof(Punkty2)/sizeof(POINT)) lPunktow2 = 0; // przepe³nienie tablicy klikniêæ
        Punkty2[lPunktow2].x = LOWORD(lParam); // zapisanie wspó³rzêdnych kursora w tablicy klikniêæ
        Punkty2[lPunktow2].y = HIWORD(lParam);
        lPunktow2++;
        InvalidateRect(Okno, NULL, rightMouse); // wymuszenie meldunku WM_PAINT
        return 0;

	  case WM_PAINT: // obs³uga odœwie¿enia okna
		  {	PAINTSTRUCT Paint;
			HDC Kontekst = BeginPaint(Okno, &Paint);
			char Tekst[] = "Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon";
			POINT Wielokat1[] = {{100, 100}, {120+i, 100}, {120+i, 150+i/2}, {170+i, 100},{190+i*2, 100}, {120+i, 170+i}, {190+i*2, 280+i}, {170+i, 280+i},{120+i, 200+i+i/2}, {120+i, 280+i}, {100, 280+i}};	
			POINT Wielokat2[] = {{200+i*2, 100}, {220+i*3, 100}, {220+i*3, 260}, {260+i*3, 240},{320+i*3, 260}, {320+i*3, 100}, {340+i*4, 100}, {340+i*4, 280+i},{320+i*3, 280+i}, {260+i*3, 260+i}, {220+i*3, 280+i}, {200+i*2, 280+i}};
			POINT Wielokat1m[] = {{100, 100}, {120, 100}, {120, 150}, {170, 100},{190, 100}, {120, 170}, {190, 280}, {170, 280},{120, 200}, {120, 280}, {100, 280}};
			POINT Wielokat2m[] = {{200, 100}, {220, 100}, {220, 260}, {260, 240},{320, 260}, {320, 100}, {340, 100}, {340, 280},{320, 280}, {260, 260}, {220, 280}, {200, 280}};
				
			HBRUSH Pedzel = CreateSolidBrush(RGB(255,0,0)); // czerwony pêdzel
			HBRUSH Pedzel1 = CreateSolidBrush(RGB(0,0,255));
			HBRUSH Pedzel2 = CreateSolidBrush(RGB(0,255,255));
			HBRUSH Pedzel3 = CreateSolidBrush(RGB(255,255,0));
			HPEN Pioro2 = CreatePen(PS_SOLID, 2, RGB(0,255,255));
			HPEN Pioro3 = CreatePen(PS_SOLID, 2, RGB(255,255,0));
			SelectObject(Kontekst, GetStockObject(NULL_PEN));
			SetBkMode(Kontekst, TRANSPARENT);
			
			HRGN Region0 = CreatePolygonRgn(Wielokat1, 11, WINDING);
			HRGN Region1 =  CreatePolygonRgn(Wielokat2, 12, WINDING);
			HRGN Region2 = CreateRectRgn(0, 0, 0, 0); // pusty region
			//HRGN Region3 = CreatePolygonRgn(Wielokat1m, 11, WINDING);
			//HRGN Region4 =  CreatePolygonRgn(Wielokat2m, 12, WINDING);
			//HRGN RegionT = CreateRectRgn(0, 0, 0, 0); // pusty region
			
			for(int n=0; n<lPunktow; n++)
			{	
				
				OffsetRgn(Region0, Punkty[n].x-200, Punkty[n].y-200);
				OffsetRgn(Region1, Punkty[n].x-200, Punkty[n].y-200);
				CombineRgn(Region2, Region1, Region0, RGN_OR);
				//SelectClipRgn(Kontekst, Region2);
				//SelectObject(Kontekst, GetStockObject(WHITE_BRUSH)); // standardowy bia³y pêdzel
				//PaintRgn(Kontekst, Region2);
				//FrameRgn(Kontekst, Region2, Pedzel, 15, 15);
				SelectClipRgn(Kontekst, Region0);
				SelectObject(Kontekst, Pedzel);
				PaintRgn(Kontekst, Region0);
				SelectClipRgn(Kontekst, Region1);
				SelectObject(Kontekst, Pedzel1);
				PaintRgn(Kontekst, Region1);
				//CombineRgn(RegionT, RegionT, Region2, RGN_OR);
				SelectClipRgn(Kontekst, Region2);
				WORD Odstep = HIWORD(GetDialogBaseUnits());
				for(int y = 0; y < 850; y = y+Odstep) TextOut(Kontekst, 0, y, Tekst, strlen(Tekst));
				OffsetRgn(Region0, -Punkty[n].x+200, -Punkty[n].y+200);
				OffsetRgn(Region1, -Punkty[n].x+200, -Punkty[n].y+200);
			}

			 for(int j=0; j<lPunktow2; j++){    
				SetViewportOrgEx(Kontekst,Punkty2[j].x-500,Punkty2[j].y-400,NULL);
				SelectObject(Kontekst, Pioro2);
				Polygon(Kontekst, Wielokat1m, 11);
				SelectObject(Kontekst, Pioro3);
				Polygon(Kontekst, Wielokat2m, 12);
                

			 }

			DeleteObject(Pedzel);
			DeleteObject(Pedzel1);
			DeleteObject(Pedzel2);
			DeleteObject(Pedzel3);
			DeleteObject(Pioro2);
			DeleteObject(Pioro3);
			EndPaint(Okno, &Paint);
		}
		return 0;
  	
	  case WM_DESTROY: // obs³uga zamkniêcia okna - wygenerowanie meldunku WM_QUIT
		PostQuitMessage (0) ;
		return 0;
    
	  default: // standardowa obs³uga wszystkich pozosta³ych meldunków
		return DefWindowProc(Okno, KodMeldunku, wParam, lParam);
	}
}
开发者ID:wolkat,项目名称:grk-cwiczenia,代码行数:101,代码来源:GDI.cpp

示例3: WindowProc

//--------------------------------------------------------------------------
// WindowProc() -> Processa as mensagens enviadas para o programa
//--------------------------------------------------------------------------
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  // Variáveis para manipulação da parte gráfica do programa
  HDC hDC = NULL;
  PAINTSTRUCT psPaint;

  // Canetas e pincéis
  HPEN hPen = NULL;
  HPEN hPenOld = NULL;
  HBRUSH hBrush = NULL;
  HBRUSH hBrushOld = NULL;
  
  // Verifica qual foi a mensagem enviada
  switch(uMsg)
  {

    case WM_CREATE: // Janela foi criada
    {
      // Retorna 0, significando que a mensagem foi processada corretamente
      return(0);
    } break;
	
    case WM_PAINT: // Janela (ou parte dela) precisa ser atualizada
    {
	  // Obtém identificador do DC e preenche PAINTSTRUCT
      hDC = BeginPaint(hWnd, &psPaint);

	  // Cria e seleciona nova caneta no DC e salva caneta antiga
	  hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
	  hPenOld = (HPEN)SelectObject(hDC, hPen);

	  // Move “cursor invisível” para (100, 100)
	  MoveToEx(hDC, 100, 100, NULL);
	  // Desenha quatro retas, formando um losango
	  LineTo(hDC, 70, 120);
	  LineTo(hDC, 100, 140);
	  LineTo(hDC, 130, 120);
	  LineTo(hDC, 100, 100);

	  // Define pontos do losango
	  POINT ptLosango[4];
	  ptLosango[0].x = 20;
	  ptLosango[0].y = 70;
	  ptLosango[1].x = 50;
	  ptLosango[1].y = 90;
	  ptLosango[2].x = 80;
	  ptLosango[2].y = 70;
	  ptLosango[3].x = 50;
	  ptLosango[3].y = 50;

	  // Move “cursor invisível” para (50, 50)
	  MoveToEx(hDC, 50, 50, NULL);
	
	  // Desenha quatro retas formadas pelos pontos do vetor ptLosango[4],
	  // formando o losango
	  PolylineTo(hDC, ptLosango, 4);

	  // Restaura caneta antiga e deleta nova caneta
	  SelectObject(hDC, hPenOld);
	  DeleteObject(hPen);

	  // Libera DC e valida área
      EndPaint(hWnd, &psPaint);

      return(0);
    } break;

    case WM_CLOSE: // Janela foi fechada
    {
      // Destrói a janela
      DestroyWindow(hWnd);

      return(0);
    } break;
	
    case WM_DESTROY: // Janela foi destruída
    {
      // Envia mensagem WM_QUIT para o loop de mensagens
      PostQuitMessage(0);

      return(0);
    } break;

    default: // Outra mensagem
    {
      /* Deixa o Windows processar as mensagens que não foram verificadas na função */
	  return(DefWindowProc(hWnd, uMsg, wParam, lParam));
    }

  }
}
开发者ID:AndersonFirmino,项目名称:progw32api,代码行数:94,代码来源:prog05-2.cpp

示例4: gwdraw

static void gwdraw(GUIWIN *gw, long fg, long bg, int bits, Char *text, int len)

{
    register int    i;
    GUI_WINDOW      *gwp = (GUI_WINDOW *)gw;
    COLORREF        fgc, bgc;
    HBRUSH	    hBrush, hPrevBrush;
    HPEN            hPen, hPrevPen;
    HDC		    hDC;
    HFONT           hFont;
    RECT            rect;
    int             ileft;
    int             xleft, xcenter, xright, ytop, ycenter, ybottom, radius;
    UINT	    options;

    /* Italics are slanted rightward from the bottom of the character cell.
     * We'd like for them to look slanted from the center of the characters,
     * and we can achieve that effect by shifting italic text slightly leftward.
     */
    ileft = 0;
    if ((bits & COLOR_GRAPHIC) != COLOR_GRAPHIC && (bits & COLOR_ITALIC))
        ileft = (gwp->ycsize - 3) / 6; /* just a guess */

    /* Convert fg and bg args into COLORREF values */
    fgc = (COLORREF)fg;
    bgc = (COLORREF)bg;

    /* compute the update RECT */
    rect.top = gwp->currow * gwp->ycsize;
    rect.left = gwp->curcol * gwp->xcsize + gwp->xcsize / 2;
    rect.bottom = rect.top + gwp->ycsize;
    rect.right = rect.left + gwp->xcsize * len;

    /* Get the window's DC */
    hDC = GetDC (gwp->clientHWnd);
    SetMapMode (hDC, MM_TEXT);

    /* hide caret */
    if (gwp->cursor_type != CURSOR_NONE && gwp->clientHWnd == GetFocus ())
    {
        HideCaret (gwp->clientHWnd);
        gwp->cursor_type = CURSOR_NONE;
    }

    /* graphic chars are a special case */
    if ((bits & COLOR_GRAPHIC) == COLOR_GRAPHIC)
    {
        /* Strip out the COLOR_GRAPHIC bits */
        bits &= ~COLOR_GRAPHIC;

        /* Erase the area */
#ifdef FEATURE_IMAGE
        if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg)
        {
            gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled);
        }
        else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg)
        {
            gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled);
        }
        else
#endif
        {
            hBrush = CreateSolidBrush (bgc);
            FillRect (hDC, &rect, hBrush);
            DeleteObject(hBrush);
        }

        /* Select the foreground color */
        hPen = CreatePen(PS_SOLID, 0, fgc);
        hPrevPen = SelectObject(hDC, hPen);

        /* Find special points in the first character cell */
        radius = gwp->xcsize / 3;
        xleft = rect.left;
        xright = xleft + gwp->xcsize;
        xcenter = (xleft + xright) / 2;
        ytop = rect.top;
        ybottom = rect.bottom;
        ycenter = (ytop + ybottom) / 2;

        /* For each graphic character... */
        for (i = 0; i < len; text++, i++)
        {
            /* Draw line segments, as appropriate for this character */
            if (strchr("123456|", *text))
            {
                MoveToEx(hDC, xcenter, ytop, NULL);
                LineTo(hDC, xcenter, ycenter);
            }
            if (strchr("456789|", *text))
            {
                MoveToEx(hDC, xcenter, ycenter, NULL);
                LineTo(hDC, xcenter, ybottom);
            }
            if (strchr("235689-", *text))
            {
                MoveToEx(hDC, xleft, ycenter, NULL);
                LineTo(hDC, xcenter, ycenter);
            }
//.........这里部分代码省略.........
开发者ID:mbert,项目名称:elvis,代码行数:101,代码来源:guiwin.c

示例5: CreatePen

void C3dMazeEffect::DrawMazeGaps(HDC hDC)
{
	int i, j;

	HPEN hPen = CreatePen(PS_SOLID, 1, MAZE_GRID_COLOR);
	HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);

	const int xOffset = GetClientArea().right - m_pMaze->GetMazeSize()*MAZE_GRID_SIZE -1;
	const int yOffset = GetClientArea().top;

	// horizontal gaps
	for(i=0; i<m_pMaze->GetMazeSize()+1; i++)
	{
		for(j=0; j<m_pMaze->GetMazeSize(); j++)
		{
			if(m_pMaze->IsGap(j, i, TRUE))
			{
				MoveToEx(hDC, xOffset+j*MAZE_GRID_SIZE, yOffset+i*MAZE_GRID_SIZE, NULL);
				LineTo(hDC, xOffset+(j+1)*MAZE_GRID_SIZE, yOffset+i*MAZE_GRID_SIZE);
			}
		}
	}

	// vertical gaps
	for(i=0; i<m_pMaze->GetMazeSize(); i++)
	{
		for(j=0; j<m_pMaze->GetMazeSize()+1; j++)
		{
			if(m_pMaze->IsGap(j, i, FALSE))
			{
				MoveToEx(hDC, xOffset+j*MAZE_GRID_SIZE, yOffset+i*MAZE_GRID_SIZE, NULL);
				LineTo(hDC, xOffset+j*MAZE_GRID_SIZE, yOffset+(i+1)*MAZE_GRID_SIZE);
			}
		}
	}

	{	// original pos
		HBRUSH hBrush = CreateSolidBrush(MAZE_ORIGINAL_POS_COLOR);
		HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
		SelectObject(hDC, GetStockObject(NULL_PEN));

		int x, y;
		m_pMaze->GetOriginalPos(x, y);

		Ellipse(hDC,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE - MAZE_ORIGINAL_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE - MAZE_ORIGINAL_POS_SIZE/2,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE + MAZE_ORIGINAL_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE + MAZE_ORIGINAL_POS_SIZE/2);

		SelectObject(hDC, hOldBrush);
		DeleteObject(hBrush);
	}

	{	// target pos
		HBRUSH hBrush = CreateSolidBrush(MAZE_TARGET_POS_COLOR);
		HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
		SelectObject(hDC, GetStockObject(NULL_PEN));

		int x, y;
		m_pMaze->GetTargetPos(x, y);

		Ellipse(hDC,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE - MAZE_TARGET_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE - MAZE_TARGET_POS_SIZE/2,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE + MAZE_TARGET_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE + MAZE_TARGET_POS_SIZE/2);

		SelectObject(hDC, hOldBrush);
		DeleteObject(hBrush);
	}

	SelectObject(hDC, hOldPen);
	DeleteObject(hPen);
}
开发者ID:kaifengz,项目名称:candy,代码行数:75,代码来源:3dMazeEffect.cpp

示例6: WndProc

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;
	RECT rect;
	SHORT vkShift=0;
	
	HFONT hfOld;
	long lfHeight;
	int iDevCap;
	LOGFONT logfont = { 0 };
    COLORREF oldTextColor;
	COPYDATASTRUCT* copyData;
	TCHAR* szTemp=new TCHAR(MAX_PATH);

	INITCOMMONCONTROLSEX InitCtrlEx;

	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
	InitCtrlEx.dwICC  = ICC_PROGRESS_CLASS;
	InitCommonControlsEx(&InitCtrlEx);

	HPEN myPen, oldPen;

	switch (message) 
    {
        case WM_CREATE:
			//do font calculation
			hdc=GetWindowDC(hWnd);
			iDevCap=GetDeviceCaps(hdc, LOGPIXELSY);	//pixels per inch
			lfHeight = -((long)fontHeight * (long)iDevCap) / 72L;
			GetObject (GetStockObject (SYSTEM_FONT), sizeof (LOGFONT), (PTSTR) &logfont) ;
			//	HFONT hf = CreateFontIndirect(&logfont);
			logfont.lfHeight=lfHeight;
			hFont=CreateFontIndirect(&logfont);
			ReleaseDC(NULL,hdc);

			DEBUGMSG(1, (L"Create hWnd=%i\r\n", hWnd));
			if(iTimeOut>0)
				startThread(hWnd);

			if(bUseProgress){
				//progressBar
				hProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL,
								WS_CHILD | WS_VISIBLE,
								xProgress, yProgress, xProgressWidth, yProgressHeight,
								hWnd, NULL, g_hInst, NULL);
				SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
				SendMessage(hProgress, PBM_SETPOS, iProgressVal, 0);
			}
			break;
		case WM_COPYDATA:
			copyData=(COPYDATASTRUCT*)lParam;
			myMsg _mymsg;
			if(copyData->dwData==1234)	//that's right
			{
				memcpy(&_mymsg, copyData->lpData, sizeof(myMsg));
			}
			if(_mymsg.iVal==0){		//text message
				if(wcslen(_mymsg.szText)>0)
					wcscpy(szMessageText, _mymsg.szText);
				GetClientRect(hWnd, &rect);
				InvalidateRect(hWnd, &rect, TRUE);
			}
			else if(_mymsg.iVal==1){		//progress message
				if(wcslen(_mymsg.szText)>0)
					wcscpy(szTemp, _mymsg.szText);
				iProgressVal=_wtoi(szTemp);
				SendMessage(hProgress, PBM_SETPOS, iProgressVal, 0);
			}
			break;			
        case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);
            
            // TODO: Add any drawing code here...
			GetClientRect(hWnd, &rect);
			//shrink text area if progressbar is there
			if(bUseProgress && hProgress!=NULL){
				rect.bottom-=yProgressHeight;
			}
			//draw rectangle
			myPen = CreatePen(PS_SOLID, 1, RGB(0,0,0));
			oldPen = (HPEN)SelectObject(hdc,myPen);
			SelectObject(hdc, hBackcolor);
			Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
			//shrinkRect(&rect, 1);
			//Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
			//a drop shadow
			rect.right-=1;rect.bottom-=1;
			Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
			rect.right-=1;rect.bottom-=1;
//.........这里部分代码省略.........
开发者ID:hjgode,项目名称:showwin,代码行数:101,代码来源:showWin.cpp

示例7: WndProc

LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
	{
		HDC hdc;
		PAINTSTRUCT ps;
		RECT rc;
		HBRUSH hBrush, hBrushOld;
		HPEN hPen, hPenOld;
		LOGBRUSH lgBrush;
		int index;
		static BioAPI_UUID_PTR uuid;
		BioAPI_RETURN bioReturn;
		TCHAR szUserName[100];
		BioAPI_VERSION Version;

		BioAPI_BIR_HANDLE EnrolledTemplate, CapturedTemplate, ProcessedBir;

		BioAPI_INPUT_BIR birEnroll, birCapture, InputBirProcessed;
		BioAPI_BIR_HEADER birHeader;
		BioAPI_FAR MaxFAR, AchievedFAR;

		BioAPI_BOOL bResponse;
		BioAPI_BOOL bPrecedence = BioAPI_TRUE;

		static BioAPI_BSP_SCHEMA * CurrSchema;

		switch (iMsg)
			{
			case WM_PAINT :
				hdc = BeginPaint(hwnd, &ps);
				GetClientRect(hwnd, &rc);
				lgBrush.lbStyle = BS_SOLID;
				lgBrush.lbColor = GetSysColor(COLOR_3DFACE);
				hBrush = CreateBrushIndirect(&lgBrush);
				hPen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DFACE));
				hPenOld = SelectObject(hdc, hPen);
				hBrushOld = SelectObject(hdc, hBrush);
				Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
				SelectObject(hdc, hBrushOld);
				SelectObject(hdc, hPenOld);
				DeleteObject(hBrush);
				DeleteObject(hPen);
				EndPaint(hwnd, &ps);
				return 0;

			case WM_COMMAND :
				switch (HIWORD (wParam))
					{
					case CBN_SELCHANGE :
						ReleaseBSP(&uuid);

						// Retrieve the index of the item selected
						index = SendMessage(hEnumTech, CB_GETCURSEL, 0, 0);
						// Retrieve a pointer to the uuid for the module
						CurrSchema = (BioAPI_BSP_SCHEMA *)SendMessage(hEnumTech, CB_GETITEMDATA, index, 0);
						uuid = (BioAPI_UUID *)malloc(sizeof(BioAPI_UUID));
						if(uuid == NULL)
						{
							MessageBox(hwnd, TEXT("Unable to allocate memory to load the module identifier"),
										TEXT("BioAPI Sample"), MB_OK);
							return 0;
						}
						BioAPI_CopyUuid(uuid, CurrSchema->ModuleId);
						bioReturn = BioAPI_ModuleLoad(uuid, 0, NULL/*(BioAPI_ModuleEventHandler)BiometricEventHandler*/, 0);

						if(BioAPI_OK != bioReturn)
							{
								PrintErrorCode(bioReturn);
								free(uuid);
								uuid = NULL;
								return 0;
							}
//						wsprintf(szCurrHandle, TEXT("Current Handle: 0x%X"), hBtCurrent);
//						SetWindowText(hCurrHbt, szCurrHandle);

						Version.Major = BioAPI_MAJOR;
						Version.Minor = BioAPI_MINOR;
						bioReturn = BioAPI_ModuleAttach(uuid, &Version, &BioAPIWinMemoryFuncs,
										0,
										0,0,0,
										NULL,
										0,
										NULL,
										&gModuleHandle);
						if(BioAPI_OK != bioReturn)
							{
								PrintErrorCode(bioReturn);
								BioAPI_ModuleUnload (uuid, NULL, 0);
								free(uuid);
								uuid = NULL;
								return 0;
							}

						break;

					case BN_CLICKED:
						switch (LOWORD (wParam))
							{
								case IDOK :
									ReleaseBSP(&uuid);
									EndDialog(hwnd, 0);
//.........这里部分代码省略.........
开发者ID:ozgend,项目名称:hive,代码行数:101,代码来源:main.c

示例8: CheckMessageBoxProc

/**
 * Below CheckMessageBoxProc adds everyones favorite "don't show again" checkbox to the dialog
 * much of the layout code (especially for XP and older windows versions) is copied with changes
 * from a GPL'ed project emabox at SourceForge.
 **/
LRESULT CALLBACK CheckMessageBoxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_COMMAND:
		{
			if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == 2025)
			{
				const LRESULT res = SendMessage((HWND)lParam, BM_GETSTATE, 0, 0);
				bool bCheckedAfter = ((res & BST_CHECKED) == 0);
				
				// Update usedata
				ExMessageBox::SetUserData((void*)(bCheckedAfter ? BST_CHECKED : BST_UNCHECKED)); //-V204
				
				SendMessage((HWND)lParam, BM_SETCHECK, bCheckedAfter ? BST_CHECKED : BST_UNCHECKED, 0);
			}
		}
		break;
		case WM_ERASEBKGND:
		{
			// Vista+ has grey strip
#ifdef FLYLINKDC_SUPPORT_WIN_XP
			if (CompatibilityManager::isOsVistaPlus())
#endif
			{
				RECT rc = {0};
				HDC dc = (HDC)wParam;
				
				// Fill the entire dialog
				GetClientRect(hWnd, &rc);
				FillRect(dc, &rc, GetSysColorBrush(COLOR_WINDOW));
				
				// Calculate strip height
				RECT rcButton = {0};
				GetWindowRect(FindWindowEx(hWnd, NULL, L"BUTTON", NULL), &rcButton);
				int stripHeight = (rcButton.bottom - rcButton.top) + 24;
				
				// Fill the strip
				rc.top += (rc.bottom - rc.top) - stripHeight;
				FillRect(dc, &rc, GetSysColorBrush(COLOR_3DFACE));
				
				// Make a line
				HGDIOBJ oldPen = SelectObject(dc, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)));
				MoveToEx(dc, rc.left - 1, rc.top, (LPPOINT)NULL);
				LineTo(dc, rc.right, rc.top);
				DeleteObject(SelectObject(dc, oldPen));
				return S_OK;
			}
		}
		break;
		case WM_CTLCOLORSTATIC:
		{
			// Vista+ has grey strip
			if (
#ifdef FLYLINKDC_SUPPORT_WIN_XP
			    CompatibilityManager::isOsVistaPlus() &&
#endif
			    ((HWND)lParam == GetDlgItem(hWnd, 2025)))
			{
				HDC hdc = (HDC)wParam;
				SetBkMode(hdc, TRANSPARENT);
				return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
			}
		}
		break;
		case WM_INITDIALOG:
		{
			RECT rc = {0};
			HWND current = NULL;
			int iWindowWidthBefore;
			int iWindowHeightBefore;
			int iClientHeightBefore;
			int iClientWidthBefore;
			
			pair<LPCTSTR, UINT> checkdata = (*(pair<LPCTSTR, UINT>*)ExMessageBox::GetUserData());
			
			GetClientRect(hWnd, &rc);
			iClientHeightBefore = rc.bottom - rc.top;
			iClientWidthBefore = rc.right - rc.left;
			
			GetWindowRect(hWnd, &rc);
			iWindowWidthBefore = rc.right - rc.left;
			iWindowHeightBefore = rc.bottom - rc.top;
			
			// Create checkbox (resized and moved later)
			HWND check = CreateWindow(L"BUTTON", checkdata.first, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_VCENTER | BS_CHECKBOX,
			                          CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
			                          hWnd, (HMENU)2025, GetModuleHandle(NULL), NULL
			                         );
			                         
			// Assume checked by default
			SendMessage(check, BM_SETCHECK, checkdata.second, 0); //-V106
			ExMessageBox::SetUserData((void*)checkdata.second); //-V204
			
			// Apply default font
//.........这里部分代码省略.........
开发者ID:snarkus,项目名称:flylinkdc-r5xx,代码行数:101,代码来源:ExMessageBox.cpp

示例9: PopupWndProc

LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

	switch (message)
	{
	case WM_TIMER:
		if (animationDone) break;
		nameListPos += GFX::TextSpeed;
		if (nameListPos > (kidList.nRecords-1)) {
			nameListPos = (float) (kidList.nRecords - 1);
			KillTimer(hWnd, timerID);
			timerID = NULL;
			animationDone = true;
			showCreditBox = true;
		}
		InvalidateRect(hWnd, NULL, false);
		break;
	case WM_CREATE:
		break;
	case WM_PAINT:
	{
		PAINTSTRUCT ps;
		HDC hdc = BeginPaint(hWnd, &ps);

		// Create an off-screen DC for double-buffering
		HDC hdcM = CreateCompatibleDC(hdc);
		RECT cR;  GetClientRect(hWnd, &cR);
		HBITMAP hbmMem = CreateCompatibleBitmap(hdc, cR.right, cR.bottom);
		HGDIOBJ hOld = SelectObject(hdcM, hbmMem);

		HBRUSH oldB = (HBRUSH) SelectObject(hdcM, CreateSolidBrush(GFX::backgr));
		HPEN oldP = (HPEN) SelectObject(hdcM, CreatePen(PS_SOLID, 1, GFX::backgr));
		
		Rectangle(hdcM, 0, 0, cR.right+1, cR.bottom+1);
		SetMapMode(hdcM, MM_TEXT);
		HFONT font = CreateFont((UINT)(cR.bottom * GFX::TextHeight), 0, 0, 0, GFX::TextWeight,
			GFX::isItalic, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
			CLEARTYPE_QUALITY, DEFAULT_PITCH | GFX::TextFamily, NULL);
		HFONT oldF = (HFONT)SelectObject(hdcM, font);
		SetTextColor(hdcM, GFX::textcolor);
		SetBkColor(hdcM, GFX::backgr);
		// draw two names, the floor of nameListPos and the ceil of nameListPos
		UINT n1 = (int)nameListPos;  UINT n2 = n1 + 1;
		float fp = nameListPos - n1;
		if ( (n1 >= 0) && (n1 < kidList.nRecords)) {
			RECT cR1 = cR;
			float off = fp * cR.bottom;
			cR1.top -= (int) off; cR1.bottom -= (int) off;
			DrawText(hdcM, kidList.pRecords[n1]->name, wcslen(kidList.pRecords[n1]->name)
				, &cR1, DT_CENTER | DT_VCENTER);
		}
		if ((n2 >= 0) && (n2 < kidList.nRecords)) {
			RECT cR2 = cR;
			float off = ((fp-1.0f) * cR.bottom);
			cR2.top -= (int) off; cR2.bottom -= (int) off;
			DrawText(hdcM, kidList.pRecords[n2]->name, wcslen(kidList.pRecords[n2]->name)
				, &cR2, DT_CENTER | DT_VCENTER);
		}


		DeleteObject(SelectObject(hdcM, oldB));
		DeleteObject(SelectObject(hdcM, oldP));
		DeleteObject(SelectObject(hdcM, oldF));

		// Transfer the off-screen DC to the screen
		BitBlt(hdc, 0, 0, cR.right, cR.bottom, hdcM, 0, 0, SRCCOPY);

		// Free-up the off-screen DC
		SelectObject(hdcM, hOld);
		DeleteObject(hbmMem);
		DeleteDC(hdcM);

		EndPaint(hWnd, &ps);
		if (showCreditBox) {
			showCreditBox = false;
			UINT msg = MessageBox(hWnd, L"Did student answer?", L"Credit"
				, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL);
			UINT n = kidList.nRecords - 1;
			switch (msg) {
			case IDYES:
				kidList.pRecords[n]->credits++;
			case IDNO:
				kidList.pRecords[n]->turns++;
				break;
			}
			PostQuitMessage(0);
		}
	}
	break;
	case WM_ERASEBKGND:
		return true;
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
开发者ID:morrisslutsky,项目名称:NowUGo,代码行数:100,代码来源:Popup.cpp

示例10: switch

BOOL CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{

	switch (message)
	{
		case WM_INITDIALOG:
		{
			int nColor;
			for (nColor = 0 ; nColor < int(sizeof(colourItems)/sizeof(DWORD)) ; nColor++)
			{
				::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_ADDSTRING, nColor, (LPARAM) "");
				::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETITEMDATA , nColor, (LPARAM) colourItems[nColor]);
				//if (g_bgColor == colourItems[nColor])
					//::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETCURSEL, nColor, 0);
			}
			//::SetCapture(_hSelf);
			return TRUE;
		}

		case WM_CTLCOLORLISTBOX:
			return (LRESULT) CreateSolidBrush(GetSysColor(COLOR_3DFACE));

		case WM_DRAWITEM:
		{
			HDC hdc;
			COLORREF	cr;
			HBRUSH		hbrush;

			DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
			hdc = pdis->hDC;
			RECT rc = pdis->rcItem;

			// Transparent.
			SetBkMode(hdc,TRANSPARENT);

			// NULL object
			if (pdis->itemID == UINT(-1)) return 0;

			switch (pdis->itemAction)
			{
				case ODA_DRAWENTIRE:
					switch (pdis->CtlID)
					{
						case IDC_COLOUR_LIST:
							rc = pdis->rcItem;
							cr = (COLORREF) pdis->itemData;
							InflateRect(&rc, -3, -3);
							hbrush = CreateSolidBrush((COLORREF)cr);
							FillRect(hdc, &rc, hbrush);
							DeleteObject(hbrush);
							FrameRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH));
							break;

						NO_DEFAULT_CASE;
					}
					// *** FALL THROUGH ***
					//lint -fallthrough
				case ODA_SELECT:
					rc = pdis->rcItem;
					if (pdis->itemState & ODS_SELECTED)
					{
						rc.bottom --;
						rc.right --;
						// Draw the lighted side.
						HPEN hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
						HPEN holdPen = (HPEN)SelectObject(hdc, hpen);
						MoveToEx(hdc, rc.left, rc.bottom, NULL);
						LineTo(hdc, rc.left, rc.top);
						LineTo(hdc, rc.right, rc.top);
						SelectObject(hdc, holdPen);
						DeleteObject(hpen);
						// Draw the darkened side.
						hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
						holdPen = (HPEN)SelectObject(hdc, hpen);
						LineTo(hdc, rc.right, rc.bottom);
						LineTo(hdc, rc.left, rc.bottom);
						SelectObject(hdc, holdPen);
						DeleteObject(hpen);
					}
					else
					{
						hbrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
						FrameRect(hdc, &rc, hbrush);
						DeleteObject(hbrush);
					}
					break;
				case ODA_FOCUS:
					rc = pdis->rcItem;
					InflateRect(&rc, -2, -2);
					DrawFocusRect(hdc, &rc);
					break;
				default:
					break;
			}
			return TRUE;
		}

		case WM_COMMAND:
			switch (LOWORD(wParam))
            {
//.........这里部分代码省略.........
开发者ID:TodWulff,项目名称:npp-community,代码行数:101,代码来源:ColourPopup.cpp

示例11: WindowProcedure


//.........这里部分代码省略.........


		if (idChild == ID_BUTTON_AUTORUN){ // если захотели автозагрузку
			LRESULT result = SendMessageA(hwndChild, BM_GETCHECK, 0, 0);
			if (result == BST_CHECKED){ //если галочка ставится
				char *szFileName = malloc(MAX_LENGTH);
				if (!szFileName){
					CloseWindowMy(hwnd);







					break;
				}
				memset(szFileName, 0, MAX_LENGTH);


				GetModuleFileNameA(NULL, szFileName, MAX_PATH);

				if (SetAutoRunToReg((LPBYTE)szFileName, strlen(szFileName)) == MYERROR){//добавляем наше приложение в автозагрузку
					glbPaintError = MYERROR;
					SendMessageA(hwndChild, BM_SETCHECK, 0, 0); // если вдруг что-то пошло не так, выводим ошибку
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0,0);



				}
				else{
					glbPaintError = SUCCESS;
					InvalidateRect(hwnd, 0,0);
					SendMessageA(hwnd, WM_PAINT, 0, 0);
				}
			}
			else {
				if (SetAutoRunToReg(NULL, 0) == MYERROR){//удаляем наше приложение из автозагрузки dsfdsSDFDSFsdfdasdsadASDSADfdfdsfSDFDSS
					glbPaintError = MYERROR;
					SendMessageA(hwndChild, BM_SETCHECK, 1, 0);
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0,0);

				}
				else{
					glbPaintError = SUCCESS;
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0, 0);


				}

			}
		}
		break;
	}




	case WM_PAINT:{


		HDC hdc = BeginPaint(hwnd, &ps);
		HBRUSH hBrush = CreateSolidBrush(RGB(0xff, 0xff, 0xff));
		HPEN hPen = CreatePen(PS_SOLID, 2, RGB(0xff, 0xff, 0xff));
		SelectObject(hdc, hPen);
		SelectObject(hdc, hBrush);        


		 
		WINDOWINFO wi;
		GetWindowInfo(hwnd, &wi);
		int w = wi.rcClient.right - wi.rcClient.left;
		int h = wi.rcClient.bottom - wi.rcClient.top;

		Rectangle(hdc, 0, 0, w, h);
		TextOutA(hdc, 10, 10, "Клавиша для переключения:", 25);
		TextOutA(hdc, 10, 30, "Для смены клавиши, нажмите мышкой на рамку,", 42);
		TextOutA(hdc, 10, 50, "Затем нажмите нужную клавишу из списка:", 39);
		TextOutA(hdc, 10, 70, "1. Shift", 8);
		TextOutA(hdc, 10, 85, "2. Pause", 8);
		TextOutA(hdc, 10, 100, "3. ctrl", 7);
		TextOutA(hdc, 10, 130, "Запуск Свичера при загрузке Windows:", 36);


		if (glbPaintError == MYERROR){

			TextOutA(hdc, 10, 115, "Не удается изменить состояние автозагрузки.", 43);

		}
		EndPaint(hwnd, &ps);
	}

	default:
		return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}
开发者ID:gazoon,项目名称:switch,代码行数:101,代码来源:window.c

示例12: myWindowProc


//.........这里部分代码省略.........
				goto mousemove;
			}
			break;
		case WM_MOUSEMOVE:
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;
			if ((coord_t)HIWORD(lParam) >= GDISP_SCREEN_HEIGHT)
				break;
		mousemove:
			priv->mousex = (coord_t)LOWORD(lParam);
			priv->mousey = (coord_t)HIWORD(lParam);
			if ((gmvmt(priv->mouse)->d.flags & GMOUSE_VFLG_NOPOLL))		// For normal setup this is always TRUE
				_gmouseWakeup(priv->mouse);
			break;
	#endif

	case WM_SYSKEYDOWN:
	case WM_KEYDOWN:
	case WM_SYSKEYUP:
	case WM_KEYUP:
		break;
	case WM_CHAR:
	case WM_DEADCHAR:
	case WM_SYSCHAR:
	case WM_SYSDEADCHAR:
		break;

	case WM_ERASEBKGND:
		// Pretend we have erased the background.
		// We know we don't really need to do this as we
		// redraw the entire surface in the WM_PAINT handler.
		return TRUE;

	case WM_PAINT:
		// Get our GDisplay structure
		g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
		priv = (winPriv *)g->priv;

		// Paint the main window area
		WaitForSingleObject(drawMutex, INFINITE);
		dc = BeginPaint(hWnd, &ps);
		BitBlt(dc, ps.rcPaint.left, ps.rcPaint.top,
			ps.rcPaint.right - ps.rcPaint.left,
			(ps.rcPaint.bottom > GDISP_SCREEN_HEIGHT ? GDISP_SCREEN_HEIGHT : ps.rcPaint.bottom) - ps.rcPaint.top,
			priv->dcBuffer, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);

		// Paint the toggle area
		#if GINPUT_NEED_TOGGLE
			if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) {
				pen = CreatePen(PS_SOLID, 1, gdispColor2Native(Black));
				hbrOn = CreateSolidBrush(gdispColor2Native(Blue));
				hbrOff = CreateSolidBrush(gdispColor2Native(Gray));
				old = SelectObject(dc, pen);
				MoveToEx(dc, 0, GDISP_SCREEN_HEIGHT, &p);
				LineTo(dc, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT);
				for(pos = 0, bit=1; pos < wWidth; pos=rect.right, bit <<= 1) {
					rect.left = pos;
					rect.right = pos + GDISP_SCREEN_WIDTH/8;
					rect.top = GDISP_SCREEN_HEIGHT;
					rect.bottom = GDISP_SCREEN_HEIGHT + WIN32_BUTTON_AREA;
					FillRect(dc, &rect, (priv->toggles & bit) ? hbrOn : hbrOff);
					if (pos > 0) {
						MoveToEx(dc, rect.left, rect.top, &p);
						LineTo(dc, rect.left, rect.bottom);
					}
				}
				DeleteObject(hbrOn);
				DeleteObject(hbrOff);
				SelectObject(dc, old);
			}
		#endif
		EndPaint(hWnd, &ps);
		ReleaseMutex(drawMutex);
		break;

	case WM_DESTROY:
		// Get our GDisplay structure
		g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
		priv = (winPriv *)g->priv;

		// Restore the window and free our bitmaps
		SelectObject(priv->dcBuffer, priv->dcOldBitmap);
		DeleteDC(priv->dcBuffer);
		DeleteObject(priv->dcBitmap);

		// Cleanup the private area
		gfxFree(priv);

		// Quit the application
		PostQuitMessage(0);

		// Actually the above doesn't work (who knows why)
		ExitProcess(0);
		break;

	default:
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}
	return 0;
}
开发者ID:houzhenggang,项目名称:MikroChibiOS,代码行数:101,代码来源:gdisp_lld_Win32.c

示例13: CreatePen

Cgdi::Cgdi()
{
  m_BlackPen = CreatePen(PS_SOLID, 1, colors[black]);
  m_WhitePen = CreatePen(PS_SOLID, 1, colors[white]);
  m_RedPen = CreatePen(PS_SOLID, 1, colors[red]);
  m_GreenPen = CreatePen(PS_SOLID, 1, colors[green]);
  m_BluePen = CreatePen(PS_SOLID, 1, colors[blue]);
  m_GreyPen = CreatePen(PS_SOLID, 1, colors[grey]);
  m_PinkPen = CreatePen(PS_SOLID, 1, colors[pink]);
  m_YellowPen = CreatePen(PS_SOLID, 1, colors[yellow]);
  m_OrangePen = CreatePen(PS_SOLID, 1, colors[orange]);
  m_PurplePen = CreatePen(PS_SOLID, 1, colors[purple]);
  m_BrownPen = CreatePen(PS_SOLID, 1, colors[brown]);
  
  m_DarkGreenPen = CreatePen(PS_SOLID, 1, colors[dark_green]);

  m_LightBluePen = CreatePen(PS_SOLID, 1, colors[light_blue]);
  m_LightGreyPen = CreatePen(PS_SOLID, 1, colors[light_grey]);
  m_LightPinkPen = CreatePen(PS_SOLID, 1, colors[light_pink]);

  m_ThickBlackPen = CreatePen(PS_SOLID, 2, colors[black]);
  m_ThickWhitePen = CreatePen(PS_SOLID, 2, colors[white]);
  m_ThickRedPen = CreatePen(PS_SOLID, 2, colors[red]);
  m_ThickGreenPen = CreatePen(PS_SOLID, 2, colors[green]);
  m_ThickBluePen = CreatePen(PS_SOLID, 2, colors[blue]);

  m_GreenBrush = CreateSolidBrush(colors[green]);
  m_RedBrush   = CreateSolidBrush(colors[red]);
  m_BlueBrush  = CreateSolidBrush(colors[blue]);
  m_GreyBrush  = CreateSolidBrush(colors[grey]);
  m_BrownBrush = CreateSolidBrush(colors[brown]);
  m_YellowBrush = CreateSolidBrush(colors[yellow]);
  m_LightBlueBrush = CreateSolidBrush(colors[light_blue]);
  m_DarkGreenBrush = CreateSolidBrush(colors[dark_green]);
  m_OrangeBrush = CreateSolidBrush(colors[orange]);
  m_PurpleBrush = CreateSolidBrush(colors[purple]);

  m_tmpPen = CreatePen(PS_SOLID,1,RGB(0,0,0));
  m_tmpBrush = CreateSolidBrush(RGB(0,0,0));

  m_hdc = NULL;
}
开发者ID:rianneogi,项目名称:Scrabble,代码行数:42,代码来源:Cgdi.cpp

示例14: WndProc

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static POINT point;
	static POINT pointOld;
	static BOOL bCapture;
	static HFONT hFont;
	static TCHAR szText[1024];
	switch (msg)
	{
	case WM_CREATE:
		hFont = CreateFont(64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("メイリオ"));
		break;
	case WM_LBUTTONDOWN:
		if (!bCapture)
		{
			point.x = LOWORD(lParam);
			point.y = HIWORD(lParam);
			SetCapture(hWnd);
			bCapture = 1;
		}
		break;
	case WM_RBUTTONUP:
		if (bCapture)
		{
			ReleaseCapture();
			bCapture = 0;
		}
		SendMessage(hWnd, WM_CLOSE, 0, 0);
		break;
	case WM_PAINT:
	{
		PAINTSTRUCT ps;
		const HDC hdc = BeginPaint(hWnd, &ps);
		const HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
		RECT rect;
		GetClientRect(hWnd, &rect);
		DrawText(hdc, szText, -1, &rect, DT_WORDBREAK);
		SelectObject(hdc, hFontOld);
		EndPaint(hWnd, &ps);
	}
	break;
	case WM_MOUSEMOVE:
		if (bCapture)
		{
			const HDC hdc = GetDC(hWnd);
			const HPEN hPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
			const HPEN hPenOld = (HPEN)SelectObject(hdc, hPen);
			MoveToEx(hdc, point.x, point.y, 0);
			LineTo(hdc, pointOld.x, pointOld.y);
			SelectObject(hdc, hPenOld);
			DeleteObject(hPen);
			MoveToEx(hdc, point.x, point.y, 0);
			LineTo(hdc, LOWORD(lParam), HIWORD(lParam));
			const HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
			const double dAngle = atan2((double)(point.x - LOWORD(lParam)), (double)(point.y - HIWORD(lParam)));
			const double dDistance = sqrt((double)((point.x - LOWORD(lParam))*(point.x - LOWORD(lParam)) + (point.y - HIWORD(lParam))*(point.y - HIWORD(lParam))));
			swprintf_s(szText, 1024,
				TEXT("角度 %f 度\r\n")
				TEXT("角度 %f ラジアン\r\n")
				TEXT("距離 %f ピクセル\r\n"),
				(dAngle + PI / 2.0)*180.0 / PI,
				dAngle + PI / 2.0,
				dDistance + 1.0
				);
			RECT rect;
			GetClientRect(hWnd, &rect);
			DrawText(hdc, szText, -1, &rect, DT_WORDBREAK);
			SelectObject(hdc, hFontOld);
			ReleaseDC(hWnd, hdc);
			pointOld.x = LOWORD(lParam);
			pointOld.y = HIWORD(lParam);
		}
		break;
	case WM_LBUTTONUP:
		if (bCapture)
		{
			ReleaseCapture();
			bCapture = 0;
			InvalidateRect(hWnd, 0, 1);
		}
		break;
	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE)
		{
			SendMessage(hWnd, WM_CLOSE, 0, 0);
		}
		else if (wParam == 'C')
		{
			if (GetKeyState(VK_CONTROL)<0)
			{
				const int nLen = lstrlen(szText);
				const HGLOBAL hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(TCHAR)*(nLen + 1));
				const LPTSTR lpszBuf = (LPTSTR)GlobalLock(hMem);
				lstrcpy(lpszBuf, szText);
				GlobalUnlock(hMem);
				OpenClipboard(NULL);
				EmptyClipboard();
				SetClipboardData(CF_UNICODETEXT, hMem);
				CloseClipboard();
			}
//.........这里部分代码省略.........
开发者ID:kenjinote,项目名称:Measure,代码行数:101,代码来源:Source.cpp

示例15: OnPaint

LRESULT OnPaint(HWND hWnd,WPARAM wParam,LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    int idx;
    HPEN hPen,hOldPen;
    HBRUSH hBrush,hOldBrush;
    RECT crt;
    HDC hMemDC;
    HBITMAP hOldBitmap;
    int x,y;
    BITMAPFILEHEADER *fh;
    BITMAPINFOHEADER *ih;
    int bx,by;
    BYTE *pRaster;
    HFONT hFont,hOldFont;
    int FontHeight;
    int FontIdx;
    LOGFONT tFont;

    hdc=BeginPaint(hWnd, &ps);
    hMemDC=CreateCompatibleDC(hdc);
    GetClientRect(hWnd,&crt);
    if (hBackBit == NULL) {
        hBackBit=CreateCompatibleBitmap(hdc,crt.right,crt.bottom);
    }
    hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBackBit);
    FillRect(hMemDC,&crt,GetSysColorBrush(COLOR_WINDOW));

    if (bGridLine) {
        hPen=CreatePen(PS_SOLID,1,RGB(192,192,192));
        hOldPen=(HPEN)SelectObject(hMemDC,hPen);
        for (y=0; y<crt.bottom; y=y+GridLineY*GridY) {
            MoveToEx(hMemDC,0,y,NULL);
            LineTo(hMemDC,crt.right,y);
        }
        for (x=0; x<crt.right; x=x+GridLineX*GridX) {
            MoveToEx(hMemDC,x,0,NULL);
            LineTo(hMemDC,x,crt.bottom);
        }
        DeleteObject(SelectObject(hMemDC,hOldPen));
    }

    SetStretchBltMode(hMemDC,StretchMode);
    SetBkMode(hMemDC,TRANSPARENT);
    for (idx=0; idx<arNum; idx++) {
        if (arObj[idx]->LineColor == (COLORREF)-1) {
            hPen=(HPEN)GetStockObject(NULL_PEN);
        } else {
            hPen=CreatePen(PS_INSIDEFRAME,arObj[idx]->LineWidth,arObj[idx]->LineColor);
        }
        hOldPen=(HPEN)SelectObject(hMemDC,hPen);
        if (arObj[idx]->PlaneColor == (COLORREF)-1) {
            hBrush=(HBRUSH)GetStockObject(NULL_BRUSH);
        } else {
            hBrush=CreateSolidBrush(arObj[idx]->PlaneColor);
        }
        hOldBrush=(HBRUSH)SelectObject(hMemDC,hBrush);
        switch (arObj[idx]->Type) {
        case DT_LINE:
            if ((arObj[idx]->Flag & 0x3) == DS_LT || (arObj[idx]->Flag & 0x3) == DS_RB) {
                MoveToEx(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,NULL);
                LineTo(hMemDC,arObj[idx]->rt.right,arObj[idx]->rt.bottom);
            } else {
                MoveToEx(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.bottom,NULL);
                LineTo(hMemDC,arObj[idx]->rt.right,arObj[idx]->rt.top);
            }
            break;
        case DT_ELLIPSE:
            Ellipse(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
                    arObj[idx]->rt.right,arObj[idx]->rt.bottom);
            break;
        case DT_RECTANGLE:
            Rectangle(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
                      arObj[idx]->rt.right,arObj[idx]->rt.bottom);
            break;
        case DT_BITMAP:
            fh=(BITMAPFILEHEADER *)arObj[idx]->Bitmap;
            pRaster=(PBYTE)fh+fh->bfOffBits;
            ih=(BITMAPINFOHEADER *)((PBYTE)fh+sizeof(BITMAPFILEHEADER));
            bx=ih->biWidth;
            by=ih->biHeight;
            StretchDIBits(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
                          arObj[idx]->rt.right-arObj[idx]->rt.left,
                          arObj[idx]->rt.bottom-arObj[idx]->rt.top,0,0,bx,by,
                          pRaster,(BITMAPINFO *)ih,DIB_RGB_COLORS,SRCCOPY);
            break;
        case DT_META:
            PlayPlaceableMeta(hMemDC,arObj[idx]->Meta,arObj[idx]->Len,&arObj[idx]->rt);
            break;
        case DT_TEXT:
            FillRect(hMemDC,&arObj[idx]->rt,hBrush);
            FontHeight=arObj[idx]->FontSize*GetDeviceCaps(hMemDC,LOGPIXELSY)/72;
            FontIdx=FindFontFromFace(arObj[idx]->FontFace);
            if (FontIdx!=-1) {
                tFont=logfont[FontIdx];
                tFont.lfHeight=FontHeight;
                tFont.lfWidth=0;
                hFont=CreateFontIndirect(&tFont);
                hOldFont=(HFONT)SelectObject(hMemDC,hFont);
//.........这里部分代码省略.........
开发者ID:MaybeS,项目名称:when_i_was_a_kid,代码行数:101,代码来源:ApiDraw.cpp


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