Exemple #1
0
DWORD WINAPI ThreadProcCircle(LPVOID pParam){
 	HWND hWnd = g_hWnd;
	HDC hdc = g_hdc;
	PAINTSTRUCT ps;
	HBRUSH hBrush;
	SetDCBrushColor(hdc, BLACK);
	hBrush = GetStockBrush(DC_BRUSH);
	SelectObject(hdc, hBrush);
	struct LOC{
		int x, y;
	}M, N;
	const double pi = 3.14159265358979;
	M.x = 750;
	M.y = 250;
	//以(M.x,M.y)为圆心,以R为半径,描点画圆
	//共描720个点,隔0.5度(STEP)描一次
	double angle = -pi, R = 160, STEP = (pi * 0.5) / 180;
	while (angle - 180 < 1e10){
		N.x = M.x + R * sin(angle);
		N.y = M.y + R * cos(angle);
		angle += STEP;
		SetPixel(hdc, N.x, N.y, BLACK);
		Sleep(50);
	}
	DeleteObject(hBrush);
	EndPaint(hWnd, &ps);
	ReleaseDC(hWnd, hdc);
	return 0;
}
Exemple #2
0
DWORD WINAPI ThreadProcSquare(LPVOID pParam){
	HWND hWnd = g_hWnd;
	HDC hdc = g_hdc;;
	PAINTSTRUCT ps;
	HBRUSH hBrush;
	SetDCBrushColor(hdc, BLACK);
	hBrush = GetStockBrush(DC_BRUSH);
	SelectObject(hdc, hBrush);
	int x, y;
	//顺时针方向描点画矩形
	for (x = 160; x < 340; x++){
		SetPixel(hdc, x, 160, BLACK);
		Sleep(50);
	}
	for (y = 160; y < 340; y++){
		SetPixel(hdc, 340, y, BLACK);
		Sleep(50);
	}
	for (x = 340; x > 160; x--){
		SetPixel(hdc, x, 340, BLACK);
		Sleep(50);
	}
	for (y = 340; y > 160; y--){
		SetPixel(hdc, 160, y, BLACK);
		Sleep(50);
	}
	DeleteObject(hBrush);
	EndPaint(hWnd, &ps);
	ReleaseDC(hWnd, hdc);
	return 0;
}
void drawrect(HDC hdc,int x1,int y1,int x2,int y2,int color1,int color2,int w,int rn)
{
    HPEN newpen,oldpen;
    HBRUSH oldbrush;
    uintptr_t *r;
    unsigned r32;

    oldbrush=(HBRUSH)SelectObject(hdc,GetStockObject(color1&0xFF000000?NULL_BRUSH:DC_BRUSH));
    if(!oldbrush)log_err("ERROR in drawrect(): failed SelectObject(GetStockObject)\n");
    r32=SetDCBrushColor(hdc,color1);
    if(r32==CLR_INVALID)log_err("ERROR in drawrect(): failed SetDCBrushColor\n");

    newpen=CreatePen(w?PS_SOLID:PS_NULL,w,color2);
    if(!newpen)log_err("ERROR in drawrect(): failed CreatePen\n");
    oldpen=(HPEN)SelectObject(hdc,newpen);
    if(!oldpen)log_err("ERROR in drawrect(): failed SelectObject(newpen)\n");

    if(rn)
        RoundRect(hdc,x1,y1,x2,y2,rn,rn);
    else
        Rectangle(hdc,x1,y1,x2,y2);

    r=SelectObject(hdc,oldpen);
    if(!r)log_err("ERROR in drawrect(): failed SelectObject(oldpen)\n");
    r=SelectObject(hdc,oldbrush);
    if(!r)log_err("ERROR in drawrect(): failed SelectObject(oldbrush)\n");
    r32=DeleteObject(newpen);
    if(!r32)log_err("ERROR in drawrect(): failed SelectObject(newpen)\n");
}
Exemple #4
0
static LRESULT WINAPI wmp_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg) {
    case WM_PAINT: {
        PAINTSTRUCT ps;
        HFONT font;
        RECT rect;
        HDC hdc;

        TRACE("WM_PAINT\n");

        GetClientRect(hwnd, &rect);
        hdc = BeginPaint(hwnd, &ps);

        SelectObject(hdc, GetStockObject(DC_BRUSH));
        SetDCBrushColor(hdc, RGB(255,0,0));
        SetBkColor(hdc, RGB(255,0,0));

        font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
        SelectObject(hdc, font);

        Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
        DrawTextA(hdc, "FIXME: WMP", -1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);

        DeleteObject(font);
        EndPaint(hwnd, &ps);
        break;
    }
    }

    return DefWindowProcW(hwnd, msg, wParam, lParam);

}
Exemple #5
0
/* Функция отрисовки геометрического объекта.
 * АРГУМЕНТЫ:
 *   - указатель на структуру для загружаемой геометрии:
 *       as4GOBJ *GObj;
 *   - контекст устройства вывода:
 *       HDC hDC;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
VOID AS4_RndGObjDraw( as4GOBJ *GObj, HDC hDC )
{
  INT i;
  POINT *pts;

  if ((pts = (POINT *) malloc(sizeof(POINT) * GObj->NumOfV)) == NULL)
    return;

  AS4_RndMatrSetup();

  for (i = 0; i < GObj->NumOfV; i++)
  {
    pts[i] = AS4_RndWorldToScreen(GObj->V[i]);
    /*Ellipse(hDC, pts[i].x - s, pts[i].y - s, pts[i].x + s, pts[i].y + s);/**/
  }
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SetDCBrushColor(hDC, RGB(24, 55, 24));
  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCPenColor(hDC, RGB(255, 153, 24));
  for (i = 0; i < GObj->NumOfF; i++)
  {
    INT n0 = GObj->F[i][0], n1 = GObj->F[i][1], n2 = GObj->F[i][2];
    MoveToEx(hDC, pts[n0].x, pts[n0].y, NULL);
    LineTo(hDC, pts[n1].x, pts[n1].y);
    LineTo(hDC, pts[n2].x, pts[n2].y);
    LineTo(hDC, pts[n0].x, pts[n0].y);/**/
    /*Polygon(hDC, pt, 3);/**/
  }
  free(pts);
} /* End of 'AS4_RndGObjDraw' function */
/* Unit render function.
 * ARGUMENTS:
 *   - self-pointer to unit object:
 *       al5UNIT_BALL *Uni;
 *   - animation context:
 *       al5ANIM *Ani;
 * RETURNS: None.
 */
static VOID AL5_UnitRender( al5UNIT_BALL_CONT *Uni, al5ANIM *Ani )
{
  VEC p = VecAddVec(Uni->Pos, Uni->Shift);
  
  SetDCBrushColor(Ani->hDC, Uni->Color);
  Ellipse(Ani->hDC, p.X - 20, p.Y - 20, p.X + 20, p.Y + 20);
} /* End of 'AL5_UnitRender' function */
Exemple #7
0
	void ICtrl::_CtrlColor(Message* msg,ICtrl*){
		::SetTextColor((HDC)msg->wParam,FontColor);
		::SetBkMode((HDC)msg->wParam,TRANSPARENT);
		HBRUSH bk = (HBRUSH)GetStockObject(DC_BRUSH);
		SetDCBrushColor((HDC)msg->wParam,BkColor);
		msg->Result = (INT_PTR)bk;
	}
LRESULT COverlappedWindow::OnControlColorEdit(HDC hdc)
{
	SetBkColor(hdc, backgroundColor);
	SetDCBrushColor(hdc, backgroundColor);
	SetTextColor(hdc, fontColor);
	return reinterpret_cast<LRESULT>(GetStockObject(DC_BRUSH));
}
Exemple #9
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       pd6UNIT_BALL *Uni;
 *   - указатель на контекст анимации:
 *       pd6ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID PD6_RectUnitRender( pd6UNIT_RECT *Uni, pd6ANIM *Ani )
{
  DBL shift = fabs(sin(Uni->PhaseShift + (DBL)clock() / CLOCKS_PER_SEC * 3)) * 30;

  SetDCBrushColor(Ani->hDC, Uni->Color);
  Rectangle(Ani->hDC, Uni->Pos.X - 5 - shift, Uni->Pos.Y - 5, Uni->Pos.X + 5, Uni->Pos.Y + 5 - shift);
} /* End of 'PD6_AnimUnitRender' function */
void iupwinDrawParentBackground(Ihandle* ih, HDC hDC, RECT* rect)
{
  unsigned char r=0, g=0, b=0;
  char* color = iupBaseNativeParentGetBgColorAttrib(ih);
  iupStrToRGB(color, &r, &g, &b);
  SetDCBrushColor(hDC, RGB(r,g,b));
  FillRect(hDC, rect, (HBRUSH)GetStockObject(DC_BRUSH));
}
void CGradientEditor::CStepHandle::OnDraw(HDC hDC, const LPRECT clientRect)
{
	int xSrc = dragging ? WIDTH : 0;
	UpdateBounds();
	MaskBlt(hDC, bounds.left, bounds.top, WIDTH, HEIGHT, parent->shBitmapDC, xSrc, 0, parent->shBmpMask, xSrc, 0, MAKEROP4(SRCCOPY, 0xAA0029));
	SetBrushOrgEx(hDC, -20, 0, NULL);
	SelectObject(hDC, GetStockObject(DC_BRUSH));
	SetDCBrushColor(hDC, gradient->GetStepColor(stepID));
	WorkingMaskBlt(hDC, bounds.left, bounds.top, WIDTH, HEIGHT, hDC, xSrc, 0, parent->shBmpColorMask, xSrc, 0, MAKEROP4(PATCOPY, 0xAA0029));
}
void ProjectTreeItem::DrawItem(HDC dc)
{       
    if(selected)DrawFocusedItem(dc);
	SetDCBrushColor(dc, GetBackgroundColor());
	Rectangle(dc, left, top, right, bottom - 13);
    
	SetBkMode(dc, TRANSPARENT);
	HGDIOBJ old = SelectObject(dc, s_hFont);
	loadngo::gui::NativeString title(m_pTask->GetTitle());
	TextOut(dc, left + 10, top + 3, title, _tcslen(title));
	SelectObject(dc, old);
	
	RECT r2 = {left, bottom - 12, right, bottom};
	PaintStatusGraph(dc, r2, left, bottom - 13);

	//PaintRectangle(0, dc, left, bottom - 12, right - left, 17, 0x00303030);  
	SetDCBrushColor(dc, 0x00000000);
	FrameRect(dc, this, static_cast<HBRUSH>(GetStockObject(DC_BRUSH)));	
}
void OnPaint(HWND hwnd) {
  PAINTSTRUCT ps;
  BeginPaint(hwnd, &ps);
  RECT rc;
  GetClientRect(hwnd, &rc);
  COLORREF bg = (COLORREF)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  SetDCBrushColor(ps.hdc, bg);
  FillRect(ps.hdc, &rc, GetStockBrush(DC_BRUSH));
  EndPaint(hwnd, &ps);
}
Exemple #14
0
LRESULT CALLBACK Toolw::tooltipLabelProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	RECT client;
	FwCHAR *tip = NULL;
	CREATESTRUCT *cs;

	switch(message){
		case WM_CREATE:
			Core::self->getToolws()->getToolwset()->add(hDlg);

			cs = (LPCREATESTRUCT)lParam;
			tip = (FwCHAR *)cs->lpCreateParams;

			GetClientRect(hDlg,&client);

			if( tip != NULL ){
				Core::self->CreateWindowExSubstituteFont(
					NULL,
					IDCL_STATIC,
					tip->toWCHAR(),
					WS_CHILD | WS_VISIBLE | SS_CENTER,
					client.left,
					client.top,
					client.right,
					client.bottom,
					hDlg,
					NULL,
					Core::self->getInstance(),
					NULL
					);

				SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
				ShowWindow(hDlg,SW_SHOW);
			}
			else {
				DestroyWindow(hDlg);
			}
			break;
		case WM_CTLCOLORSTATIC:
			SetBkMode((HDC)wParam,TRANSPARENT);
			SetDCBrushColor((HDC)wParam,GetSysColor(COLOR_INFOBK));
			SetTextColor((HDC)wParam,GetSysColor(COLOR_INFOTEXT));
			return (LRESULT)GetStockObject(DC_BRUSH);
		case WM_NCACTIVATE:
			return Core::self->getToolws()->overrideNCActivate(hDlg,wParam,lParam);
		case WM_ENABLE:
			return Core::self->getToolws()->overrideEnable(hDlg,wParam,lParam);
		case WM_DESTROY:
			Core::self->getToolws()->getToolwset()->remove(hDlg);
			break;
		default:
			return DefWindowProc(hDlg,message,wParam,lParam);
	}
	return 0;
}
Exemple #15
0
void DrawEye(HDC hDC, INT Xm, INT Ym, INT Xc, INT Yc, INT W, INT H, INT R)
{
  int xe, ye;
  double len = sqrt((Xc - Xm) * (Xc - Xm) + (Yc - Ym) * (Yc - Ym)), si, co;
  SelectObject(hDC, GetStockObject(NULL_PEN));
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SetDCPenColor(hDC, RGB(255, 255, 255));
  SetDCBrushColor(hDC, RGB(255, 255, 255));
  

}
Exemple #16
0
static int winValCtlColor(Ihandle* ih, HDC hdc, LRESULT *result)
{
  COLORREF cr;
  if (iupwinGetParentBgColor(ih, &cr))
  {
    SetDCBrushColor(hdc, cr);
    *result = (LRESULT)GetStockObject(DC_BRUSH);
    return 1;
  }
  return 0;
}
Exemple #17
0
static void winTabsDrawPageBackground(Ihandle* ih, HDC hDC, RECT* rect)
{
  unsigned char r=0, g=0, b=0;
  char* color = iupAttribGetInheritNativeParent(ih, "BGCOLOR");
  if (!color) color = iupAttribGetInheritNativeParent(ih, "BACKGROUND");
  if (!color) color = iupAttribGet(ih, "BACKGROUND");
  if (!color) color = IupGetGlobal("DLGBGCOLOR");
  iupStrToRGB(color, &r, &g, &b);
  SetDCBrushColor(hDC, RGB(r,g,b));
  FillRect(hDC, rect, (HBRUSH)GetStockObject(DC_BRUSH));
}
// Use GDI to draw in video frame
void	GdiDraw (IDeckLinkVideoFrame* theFrame)
{
	BITMAPINFOHEADER bmi;
	
	ZeroMemory(&bmi, sizeof(bmi));
	bmi.biSize = sizeof(bmi);
	bmi.biWidth = theFrame->GetWidth();
	bmi.biHeight = theFrame->GetHeight();
	bmi.biPlanes = 1;
	bmi.biBitCount = 32;
	bmi.biCompression = BI_RGB;
	bmi.biSizeImage = (bmi.biWidth * bmi.biHeight * 4);
	
	HDC hdc = CreateCompatibleDC(NULL);
	BYTE* pbData = NULL;
	BYTE* pbDestData = NULL;

	RECT fillRect1 = {50, 50, 100, 100};
	RECT fillRect2 = {100, 100, 150, 150};
	RECT fillRect3 = {150, 150, 200, 200};

	HBITMAP hbm = CreateDIBSection(hdc, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, (void**)&pbData, NULL, 0);
	SelectObject(hdc, hbm);

	HBRUSH		backBrush = (HBRUSH)GetStockObject(DC_BRUSH);
	
	TextOut(hdc, bmi.biWidth/2, bmi.biHeight/2, _T("Hello, world!"), 13);	// Place string in centre of screen

	SetDCBrushColor(hdc, RGB(0, 200, 240));								// create square
	FillRect(hdc, &fillRect1, backBrush);
	SetDCBrushColor(hdc, RGB(180, 130, 130));							// create square
	FillRect(hdc, &fillRect2, backBrush);
	SetDCBrushColor(hdc, RGB(0, 120, 242));								// create square
	FillRect(hdc, &fillRect3, backBrush);

	Ellipse(hdc, 200, 200,300,300);										// create ellipse

	theFrame->GetBytes((void**)&pbDestData);							// get frame buffer pointer
	memcpy(pbDestData, pbData, bmi.biSizeImage); 
	DeleteObject(SelectObject(hdc, hbm));								// delete attached GDI object
}
Exemple #19
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       od6UNIT_COW *Unit;
 *   - указатель на контекст анимации:
 *       od6ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID CowUnitRender( od6UNIT_COW *Unit, od6ANIM *Ani )
{
  INT i, N = 0;
  VEC p = {1, 0, 0};
  POINT pt;
  static DBL Delta = 0.1;

  Delta += Ani->JZ * Ani->GlobalDeltaTime;


  OD6_RndMatrView = MatrViewLookAt(VecMulMatr(VecSet(0, 0, Ani->JX * Delta + 15), MatrRotateX(90 * Ani->JY)), VecSet(0, 0, 0), VecSet(0, 1, 0));
  OD6_RndMatrWorld = MatrRotateZ(-Ani->Time);
  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));

  SetDCBrushColor(Ani->hDC, RGB(255, 255, 255));
  SetDCPenColor(Ani->hDC, RGB(255, 255, 255));

  srand(30);
  for (i = 0; i < N; i++)
  {
    p.X = 2.0 * rand() / RAND_MAX - 1 ;
    p.Y = 2.0 * rand() / RAND_MAX - 1 ;
    p.Z = 2.0 * rand() / RAND_MAX - 1 ;
    pt = OD6_RndWorldToScreen(p);
    if (i == 0)
      MoveToEx(Ani->hDC, pt.x , pt.y, NULL);
    else
      LineTo(Ani->hDC, pt.x , pt.y);
  }
  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC);
 /*
  OD6_RndMatrWorld = MatrRotateZ(-Ani->GlobalTime / 60);
  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));

  SetDCBrushColor(Ani->hDC, RGB(0, 255, 255));
  SetDCPenColor(Ani->hDC, RGB(0, 255, 255));

  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC);

  OD6_RndMatrWorld = MatrRotateZ(-Ani->GlobalTime / 60 / 60);
  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));

  SetDCBrushColor(Ani->hDC, RGB(255, 255, 0));
  SetDCPenColor(Ani->hDC, RGB(255, 255, 0));

  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC);

  OD6_RndMatrWorld = MatrRotateY(Ani->Time * 30);

  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));
  OD6_RndMatrWorld = MatrMulMatr(MatrTranslate(0.0, 0.0, 3 * 3.30), OD6_RndMatrWorld);
  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC); */  
} /* End of 'CowUnitRender' function */
Exemple #20
0
void MyField::DrawField(CPaintDC &dc)
{
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			SetDCPenColor(dc, RGB(0, 0, 0));
			SetDCBrushColor(dc, RGB(255, 255, 255));
			dc.Rectangle(i * RectSize, j * RectSize,
				i * RectSize + RectSize, j * RectSize + RectSize);
			if (arrVector[row*j + i] == 1) 
			{
				SetColor(dc);
				DrawRectByCoordanates(dc, i, j);
				SetDefaultColor(dc);
			}
		}
	}
	SetDCPenColor(dc, RGB(0, 0, 0));
	SetDCBrushColor(dc, RGB(0, 0, 0));
}
Exemple #21
0
static void winButtonDrawText(Ihandle* ih, HDC hDC, int rect_width, int rect_height, int border, UINT itemState)
{
  int xpad = ih->data->horiz_padding + border, 
      ypad = ih->data->vert_padding + border;
  int x, y, width, height, shift = 0;
  COLORREF fgcolor;

  char* title = iupAttribGet(ih, "TITLE");
  if (title)
  {
    int style = 0;
    HFONT hFont = (HFONT)iupwinGetHFontAttrib(ih);
    char* str = iupStrProcessMnemonic(title, NULL, 0);   /* remove & */
    iupdrvFontGetMultiLineStringSize(ih, str, &width, &height);
    if (str && str!=title) free(str);

    if (itemState & ODS_DISABLED)
      fgcolor = GetSysColor(COLOR_GRAYTEXT);
    else
      fgcolor = ih->data->fgcolor;

    if (itemState & ODS_SELECTED && !iupwin_comctl32ver6)
      shift = 1;

    if (itemState & ODS_NOACCEL && !iupwinGetKeyBoardCues())
      style |= DT_HIDEPREFIX;

    x = winButtonCalcAlignPosX(ih->data->horiz_alignment, rect_width, width, xpad, shift);
    y = winButtonCalcAlignPosY(ih->data->vert_alignment, rect_height, height, ypad, shift);

    if (ih->data->horiz_alignment == IUP_ALIGN_ACENTER)
      style |= DT_CENTER;  /* let DrawText do the internal horizontal alignment, usefull for multiple lines */
    else if (ih->data->horiz_alignment == IUP_ALIGN_ARIGHT)
      style |= DT_RIGHT;

    iupwinDrawText(hDC, title, x, y, width, height, hFont, fgcolor, style);
  }
  else
  {
    /* fill with the background color if defined at the element */
    char* bgcolor = iupAttribGet(ih, "BGCOLOR");
    if (bgcolor)
    {
      RECT rect;
      unsigned char r=0, g=0, b=0;
      iupStrToRGB(bgcolor, &r, &g, &b);
      SetDCBrushColor(hDC, RGB(r,g,b));
      SetRect(&rect, xpad, ypad, rect_width - xpad, rect_height - ypad);
      FillRect(hDC, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
    }
  }
}
Exemple #22
0
static int winTabsCtlColor(Ihandle* ih, HDC hdc, LRESULT *result)
{
  /* works only when NOT winTabsUsingXPStyles */
  unsigned char r, g, b;
  char* color = iupBaseNativeParentGetBgColorAttrib(ih);
  if (iupStrToRGB(color, &r, &g, &b))
  {
    SetDCBrushColor(hdc, RGB(r,g,b));
    *result = (LRESULT)GetStockObject(DC_BRUSH);
    return 1;
  }
  return 0;
}
Exemple #23
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hDC;
    PAINTSTRUCT ps;
    int wmId, wmEvent;

    switch (message)
    {
    case WM_CREATE:
        break;

    case WM_CHAR:
        if (wParam == VK_ESCAPE)
            DestroyWindow(hWnd);
        break;

    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);

        switch (wmId)
        {
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;

        case WM_PAINT:
            {
                HBRUSH brush;

                hDC = BeginPaint(hWnd, &ps);

                SelectObject(hDC, GetStockObject(DC_BRUSH));
                SetDCBrushColor(hDC, RGB(255, 0, 0));
                GetDCBrushColor(hDC);

                EndPaint(hWnd, &ps);
                break;
            }

        case WM_DESTROY:
            PostQuitMessage(0);
            break;

        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }

    return 0;
}
Exemple #24
0
/* Draw object functioln.
 * ARGUMENTS: None.
 * RETURNS: None.
 */
VOID ObjDraw( HDC hDC, INT H, INT W )
{
  INT i;

  for (i = 0; i < ObjNumOfV; i++)
  {
    /* рисуем точку ObjV[i] */
     
    SelectObject(hDC, GetStockObject(NULL_PEN));
    SelectObject(hDC, GetStockObject(DC_BRUSH));
    SetDCBrushColor(hDC, RGB(0, 0, 0));  
    Ellipse(hDC, ObjV[i].X + W / 2, ObjV[i].Y + H / 2, ObjV[i].X + W / 2 + 5, ObjV[i].Y + H / 2 + 5);
  }              
} /* End of 'ObjDraw' function */
Exemple #25
0
void Arrow( HDC hDC, POINT c, double a, INT r, INT w, COLORREF col )
{
  POINT pt[3];
  double sn = sin(a), csn = cos(a);
  pt[0].x = c.x - w * sn; pt[0].y = c.y + w * csn;
  pt[1].x = c.x + w * sn; pt[1].y = c.y - w * csn;
  pt[2].x = csn * r + c.x;
  pt[2].y = sn * r + c.y;
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCBrushColor(hDC, col);
  SetDCPenColor(hDC, col);
  Polygon(hDC, pt, 3);
}
Exemple #26
0
void CDateBanner::CRightArrowButton::PaintForeground(HDC dc, int w, int h)
{
    DWORD lc1 = c1;
    DWORD lc2 = c2;
    DWORD lc3 = c3;
	DWORD blk = 0;
	DWORD dash = dashColor;
    if(m_state & ButtonMouseOver)
    {
		SetDCPenColor(dc, hiliteFill);
		SetDCBrushColor(dc, hiliteFill);
        Rectangle(dc, 1, 1, w - 1, h - 1);
        if(m_state & ButtonPressed)
		{
			lc1 = lc2 = lc3 = blk;
			dash = hiliteDash;
		}
    }
	SetDCPenColor(dc, dash);
	MoveToEx(dc, 2, 2, 0);
	POINT pts[] = { { w - 2, 2 }, { w - 2, h - 2 }, { 2, h - 2 }, { 2, 2 } };
	PolylineTo(dc, pts, 4);

    HPEN p2 = CreatePen(PS_DASH, 2, lc3);
	HGDIOBJ oldPen = SelectObject(dc, p2);

    MoveToEx(dc, 5, 5, 0);
	LineTo(dc, 15, 20);
	LineTo(dc, 5, 35);

	HPEN p1 = CreatePen(PS_DASH, 2, lc2);
	SelectObject(dc, p1);
	DeleteObject(p2);
	
	MoveToEx(dc, 5, 10, 0);
	LineTo(dc, 25, 20);
	LineTo(dc, 5, 30);

	p2 = CreatePen(PS_DASH, 2, lc1);
	SelectObject(dc, p2);
	DeleteObject(p1);

	MoveToEx(dc, 5, 15, 0);
	LineTo(dc, 35, 20);
    LineTo(dc, 5, 25);

	SelectObject(dc, oldPen);
	DeleteObject(p2);
}
Exemple #27
0
void DrawSelectColor(HWND hDlg, int id, COLORREF col)
{
	RECT rect;

	HWND hwnd = GetDlgItem(hDlg, id);
	HDC hdc = GetDC(hwnd);

	SelectObject(hdc, GetStockObject(BLACK_PEN));
	SetDCBrushColor(hdc, col);
	SelectObject(hdc, GetStockObject(DC_BRUSH));
	GetClientRect(hwnd, &rect);
	Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);

	ReleaseDC(hwnd, hdc);
}
Exemple #28
0
static int winListCtlColor(Ihandle* ih, HDC hdc, LRESULT *result)
{
  COLORREF cr;

  if (iupwinGetColorRef(ih, "FGCOLOR", &cr))
    SetTextColor(hdc, cr);

  if (iupwinGetColorRef(ih, "BGCOLOR", &cr))
  {
    SetBkColor(hdc, cr);
    SetDCBrushColor(hdc, cr);
    *result = (LRESULT)GetStockObject(DC_BRUSH);
    return 1;
  }
  return 0;
}
Exemple #29
0
void _fill(
		HDC      dc,
		RECT    *rc,
		COLORREF cl
	)
{
	HGDIOBJ brsh;

	SetDCBrushColor(dc, cl); 
	SetBkMode(dc, TRANSPARENT);

	brsh = GetStockObject(DC_BRUSH);
	FillRect(dc, rc, brsh);

	return;
}
Exemple #30
0
static void winButtonDrawText(Ihandle* ih, HDC hDC, int rect_width, int rect_height, int border, UINT itemState)
{
  int xpad = ih->data->horiz_padding + border, 
      ypad = ih->data->vert_padding + border;
  int x, y, width, height, shift = 0;
  COLORREF fgcolor;

  char* title = iupdrvBaseGetTitleAttrib(ih);
  if (title)
  {
    HFONT hFont = (HFONT)iupwinGetHFontAttrib(ih);
    char* str = iupStrProcessMnemonic(title, NULL, 0);   /* remove & */
    iupdrvFontGetMultiLineStringSize(ih, str, &width, &height);
    if (str && str!=title) free(str);

    if (itemState & ODS_DISABLED)
      fgcolor = GetSysColor(COLOR_GRAYTEXT);
    else
      fgcolor = ih->data->fgcolor;

    if (itemState & ODS_SELECTED && !iupwin_comctl32ver6)
      shift = 1;

    x = winButtonCalcAlignPosX(ih->data->horiz_alignment, rect_width, width, xpad, shift);
    y = winButtonCalcAlignPosY(ih->data->vert_alignment, rect_height, height, ypad, shift);

    iupwinDrawText(hDC, title, x, y, width, height, hFont, fgcolor, 0);
  }
  else
  {
    /* fill with the background color if defined at the element */
    char* bgcolor = iupAttribGet(ih, "BGCOLOR");
    if (bgcolor)
    {
      RECT rect;
      unsigned char r=0, g=0, b=0;
      iupStrToRGB(bgcolor, &r, &g, &b);
      SetDCBrushColor(hDC, RGB(r,g,b));
      rect.left = xpad;
      rect.top = ypad;
      rect.right = rect_width - xpad;
      rect.bottom = rect_height - ypad;
      FillRect(hDC, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
    }
  }
}