Exemplo n.º 1
0
void __fastcall TAboutForm::FormCreate(TObject *Sender)
{
	HRGN rgn = CreateRoundRectRgn(0, 0, Width, Height, 20, 20);
    SetWindowRgn(Handle, rgn, true);

//    DoubleBuffered = true;

    char str[256-32];
    for (int i=32; i<256; i++)
    	str[i-32] = i;
//    str[256-32] = 0; // -?

    b = new Graphics::TBitmap;
    b->Width = PB->Width;
    b->Height = PB->Height;
    b->PixelFormat = pf24bit;

	CANVAS = b->Canvas;
    CANVAS->Brush->Color = Color;
    CANVAS->Brush->Style = bsSolid;
    CANVAS->Font = PB->Font;

    TH = CANVAS->TextHeight(str)+DELTA;

    Yn = PB->Height;
    Index = 0;

    CANVAS->Brush->Style = bsClear;
    CANVAS->Pen->Color = Color;
}
Exemplo n.º 2
0
LRESULT CEICFrameWindow::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	SIZE szRoundCorner = m_pm.GetRoundCorner();
#if defined(UI_BUILD_FOR_WIN32) && !defined(UI_BUILD_FOR_WINCE)
	if( !::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0) )
	{
		RECT rcClient;
		::GetClientRect(*this, &rcClient);
#if 0
		RECT rcClient;
		::GetClientRect(*this, &rcClient);
		RECT rc = { rcClient.left, rcClient.top + szRoundCorner.cx, rcClient.right, rcClient.bottom };
		HRGN hRgn1 = ::CreateRectRgnIndirect( &rc );
		HRGN hRgn2 = ::CreateRoundRectRgn(rcClient.left, rcClient.top, rcClient.right + 1, rcClient.bottom - szRoundCorner.cx, szRoundCorner.cx, szRoundCorner.cy);
		::CombineRgn( hRgn1, hRgn1, hRgn2, RGN_OR );
		::SetWindowRgn(*this, hRgn1, TRUE);
		::DeleteObject(hRgn1);
		::DeleteObject(hRgn2);
#else
		HRGN hRGN = CreateRoundRectRgn(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom, szRoundCorner.cx, szRoundCorner.cy);
		::SetWindowRgn(*this,hRGN,TRUE);
		::DeleteObject(hRGN);
#endif
	}
#endif
	bHandled = FALSE;
	return 0;
}
Exemplo n.º 3
0
void CFileAskDlg::SetDlgReign()
{
	int UI_ROUNDRECT_WIDTH = 16;
	int UI_ROUNDRECT_HEIGHT = 16;

	CRect rc;
	POINT Points[6];
	GetClientRect(&rc);

	HRGN rgn1 = CreateRoundRectRgn(0, 0, rc.Width() / 2, rc.Height() / 2, UI_ROUNDRECT_WIDTH, UI_ROUNDRECT_HEIGHT);
	Points[0].x = 0;
	Points[0].y = UI_ROUNDRECT_HEIGHT;
	Points[1].x = 0;
	Points[1].y = rc.Height() + UI_ROUNDRECT_HEIGHT;
	Points[2].x = rc.Width() + UI_ROUNDRECT_WIDTH;
	Points[2].y = rc.Height() + UI_ROUNDRECT_HEIGHT;
	Points[3].x = rc.Width() + UI_ROUNDRECT_WIDTH;
	Points[3].y = 0;
	Points[4].x = UI_ROUNDRECT_WIDTH;
	Points[4].y = 0;
	Points[5].x = UI_ROUNDRECT_WIDTH;
	Points[5].y = UI_ROUNDRECT_HEIGHT;
	HRGN rgn2 = CreatePolygonRgn(Points, 6, ALTERNATE);
	CombineRgn(rgn1, rgn1, rgn2, RGN_OR);
	SetWindowRgn(rgn1, TRUE);

	DeleteObject(rgn2);
}
Exemplo n.º 4
0
const BOOL VentanaDump::Mostrar(const TCHAR *PathDump) { 
	
	
	
	_PathDump = PathDump;
	UINT YC = 6;
	if (Sistema.App.Config.UtilizarBarraTituloWindows == true) { 
		CrearVentana(0, TEXT("BubaTronik_VentanaDump"), WS_OVERLAPPED | WS_SYSMENU, IDIOMA__ERROR_GRAVE, DWL_CENTRADO, DWL_CENTRADO, 547, 150, 0);
		YC = 80;
	}
	else {
		CrearVentana(0, TEXT("BubaTronik_VentanaDump"), WS_POPUP, IDIOMA__ERROR_GRAVE, DWL_CENTRADO, DWL_CENTRADO, 543, 145, 0);
		HRGN Region = CreateRoundRectRgn(0, 0, 544, 146, 11, 11);
		SetWindowRgn(_hWnd, Region, false);
		YC = 100;
	}
	if (_hWnd == NULL) return FALSE;
	_Barra.CrearBarraEx(WS_CHILD | WS_VISIBLE, _hWnd, 10, YC, 522, 8, ID_BARRA_DUMP, DWL_BARRAEX_PROGRESO_HORIZONTAL, 0, 1000);
	_BotonGuardar.CrearBotonEx(WS_CHILD | WS_VISIBLE, _hWnd, IDIOMA__ENVIAR, 196, YC + 13, 70, 20, 101);
	_BotonTerminar.CrearBotonEx(WS_CHILD | WS_VISIBLE, _hWnd, IDIOMA__TERMINAR, 276, YC + 13, 70, 20, 100);

	Visible(true);
	_BotonGuardar.AsignarFoco();
	return TRUE;
};
Exemplo n.º 5
0
HRGN WINAPI
CreateEllipticRgnIndirect( const RECT *rect )
{
    return CreateRoundRectRgn( rect->left, rect->top, rect->right,
				 rect->bottom, rect->right - rect->left,
				 rect->bottom - rect->top );
}
Exemplo n.º 6
0
BOOL OnCalendarInitDialog(HWND hwndDlg, HWND hwndFocus, LPARAM lParam)
{
	//Initialize common controls
	INITCOMMONCONTROLSEX InitCtrlEx;
	HRGN hRgn;RECT rRect;
	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
	InitCtrlEx.dwICC  =  ICC_BAR_CLASSES;
	InitCommonControlsEx(&InitCtrlEx);
	GetLocalTime (&sCurrentDay);		
	GetClientRect(hwndDlg,&rRect);
	//GetWindowRect(hwndDlg,&rRect);
	rRect.left+=GetSystemMetrics(SM_CXDLGFRAME);
	rRect.top+=GetSystemMetrics(SM_CYSIZE)+GetSystemMetrics(SM_CYDLGFRAME);
	rRect.right+=GetSystemMetrics(SM_CXDLGFRAME);
	rRect.bottom+=GetSystemMetrics(SM_CYSIZE)+GetSystemMetrics(SM_CYDLGFRAME);

	hRgn=CreateRoundRectRgn(rRect.left,rRect.top,rRect.right,rRect.bottom,20,20);
	SetWindowRgn(hwndDlg,hRgn,TRUE);
	DeleteObject(hRgn);

	hPopUpMenu=LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_CalendarMenu));

	hOldProc=(WNDPROC)SetWindowLong(GetDlgItem(hwndDlg,IDC_Calendar),GWL_WNDPROC,(LONG)SubClassProc); 

	rDateRects=new RECT[33];

	hToolTipWindow= CreateWindowEx(WS_EX_TRANSPARENT, TOOLTIPS_CLASS, NULL,WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,hwndDlg, NULL, g_hInstance,NULL);
	SetWindowPos(hToolTipWindow, HWND_TOPMOST,0, 0, 0, 0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
	return TRUE;
}
Exemplo n.º 7
0
HRGN WINAPI duRgn::GetHRgn(int nWidth, int nHeight)
{
	duRect rectNew;
	rectNew.SetRect(0, 0, nWidth+1, nHeight+1);

	HRGN hRgnLeftBottom = NULL;
	HRGN hRgnRightBottom = NULL;

	if (lstrcmpi(m_szType, _T("roundrect")) == 0)
		return CreateRoundRectRgn(rectNew.left, rectNew.top, rectNew.right, rectNew.bottom, m_nRoundX, m_nRoundY);
	else if (lstrcmpi(m_szType, _T("halfroundrect")) == 0)
	{
		HRGN hRgn = CreateRoundRectRgn(rectNew.left, rectNew.top, rectNew.right, rectNew.bottom, m_nRoundX, m_nRoundY);
		hRgnLeftBottom = CreateRectRgn(rectNew.left, rectNew.bottom - m_nRoundY, rectNew.left + m_nRoundX, rectNew.bottom);
		
		if (hRgn && hRgnLeftBottom)
		{
			int nRegion = CombineRgn(hRgn, hRgn, hRgnLeftBottom, RGN_OR);
			if (nRegion == NULLREGION || ERROR)
			{
				SAFE_DELETE_OBJECT(hRgnLeftBottom);
				return NULL;
			}

			hRgnRightBottom = CreateRectRgn(rectNew.right - m_nRoundX, rectNew.bottom - m_nRoundY,  rectNew.right, rectNew.bottom);
			if (hRgnRightBottom)
			{
				nRegion = CombineRgn(hRgn, hRgn, hRgnRightBottom, RGN_OR);
				if (nRegion == NULLREGION || ERROR)
				{
					SAFE_DELETE_OBJECT(hRgnLeftBottom);
					SAFE_DELETE_OBJECT(hRgnRightBottom);
					return NULL;
				}
				
				m_hRgn = hRgn;
			}
		}
	}
	else if (lstrcmpi(m_szType, _T("style")) == 0)
		return GetStyleHRgn(nWidth, nHeight);

	SAFE_DELETE_OBJECT(hRgnLeftBottom);
	SAFE_DELETE_OBJECT(hRgnRightBottom);

	return m_hRgn;
}
Exemplo n.º 8
0
int WinGui::Window::setRoundRectRgn(int wh){
	HRGN rrRgn = CreateRoundRectRgn(0, 0, width, height, wh, wh);

	SetWindowRgn(hWnd, rrRgn, true);
	InvalidateRect(hWnd, 0, false);

	return 0;
}
Exemplo n.º 9
0
void SetWindowEllispeFrame(HWND hwnd, int nWidthEllipse, int nHeightEllipse)
{
    HRGN hRgn;
    RECT rect;
	
    GetWindowRect(hwnd, &rect);
	
    hRgn = CreateRoundRectRgn(0, 0, rect.right - rect.left, rect.bottom - rect.top, nWidthEllipse, nHeightEllipse);
    SetWindowRgn(hwnd, hRgn, TRUE);
	
	// 	CString msg;
	// 	msg.Format("%d %d", rect.left, rect.right);
	// 	AfxMessageBox(msg);
}
Exemplo n.º 10
0
void CSkinDialog::OnSize(UINT nType, int cx, int cy)
{
    CXTPDialog::OnSize(nType, cx, cy);

    if(CImgSkin::IsLoaded())
    {
        CRect Rect;
        GetWindowRect(&Rect);
        SetWindowRgn(CreateRoundRectRgn(0, 0, Rect.Width(), Rect.Height(), m_mapRect["RoundCorner"].Width, m_mapRect["RoundCorner"].Height), TRUE);
        Invalidate(TRUE);
    }

    m_anchor.OnSize();
}
Exemplo n.º 11
0
LRESULT CALLBACK AvatarTrackBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if (!IsWindowEnabled(hwnd))
		return mir_callNextSubclass(hwnd, AvatarTrackBarWndProc, msg, wParam, lParam);

	static int oldVal = -1;
	switch (msg) {
	case WM_MOUSEWHEEL:
	case WM_KEYDOWN:
	case WM_KEYUP:
		if (!IsWindowVisible(hwndBox))
			break;

	case WM_MOUSEMOVE:
		{
			TRACKMOUSEEVENT tme;
			tme.cbSize = sizeof(tme);
			tme.dwFlags = TME_LEAVE;
			tme.dwHoverTime = HOVER_DEFAULT;
			tme.hwndTrack = hwnd;
			_TrackMouseEvent(&tme);

			int newVal = (BYTE)SendMessage(hwnd, TBM_GETPOS, 0, 0);
			if (oldVal != newVal) {
				if (oldVal < 0)
					SetWindowLongPtr(hwndBox, GWLP_USERDATA, 0);

				RECT rc; GetWindowRect(hwnd, &rc);
				SetWindowPos(hwndBox, NULL,
					(rc.left+rc.right-newVal)/2, rc.bottom+2, newVal, newVal,
					SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_SHOWWINDOW);

				HRGN rgn = CreateRoundRectRgn(0, 0, newVal, newVal, 2 * PopupOptions.avatarRadius, 2 * PopupOptions.avatarRadius);
				SetWindowRgn(hwndBox, rgn, TRUE);
				InvalidateRect(hwndBox, NULL, FALSE);
				oldVal = newVal;
			}
		}
		break;

	case WM_MOUSELEAVE:
		SetWindowRgn(hwndBox, NULL, TRUE);
		ShowWindow(hwndBox, SW_HIDE);
		oldVal = -1;
		break;
	}
	return mir_callNextSubclass(hwnd, AvatarTrackBarWndProc, msg, wParam, lParam);
}
HRGN FWindowsWindow::MakeWindowRegionObject() const
{
	HRGN Region;
	if ( RegionWidth != INDEX_NONE && RegionHeight != INDEX_NONE )
	{
		if (IsMaximized())
		{
			int32 WindowBorderSize = GetWindowBorderSize();
			Region = CreateRectRgn( WindowBorderSize, WindowBorderSize, RegionWidth - WindowBorderSize, RegionHeight - WindowBorderSize );
		}
		else
		{
			const bool bUseCornerRadius  = 
#if ALPHA_BLENDED_WINDOWS
				// Corner radii cause DWM window composition blending to fail, so we always set regions to full size rectangles
				Definition->TransparencySupport != EWindowTransparency::PerPixel &&
#endif
				Definition->CornerRadius > 0;

			if( bUseCornerRadius )
			{
				// @todo mac: Corner radius not applied on Mac platform yet

				// CreateRoundRectRgn gives you a duff region that's 1 pixel smaller than you ask for. CreateRectRgn behaves correctly.
				// This can be verified by uncommenting the assert below
				Region = CreateRoundRectRgn( 0, 0, RegionWidth+1, RegionHeight+1, Definition->CornerRadius, Definition->CornerRadius );

				// Test that a point that should be in the region, is in the region
				// check(!!PtInRegion(Region, RegionWidth-1, RegionHeight/2));
			}
			else
			{
				Region = CreateRectRgn( 0, 0, RegionWidth, RegionHeight );
			}
		}
	}
	else
	{
		RECT rcWnd;
		GetWindowRect( HWnd, &rcWnd );
		Region = CreateRectRgn( 0, 0, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top );
	}

	return Region;
}
Exemplo n.º 13
0
static HRGN MakeBalloonRegion(int width,int height,int radius,int AlignStyle,
                              int TailSize,int TailX,int TailY)
{
  POINT Tail[3];
  HRGN hrgnRect,hrgnTail;
  int top,bottom,rad;

  // attach the tail to the balloon
  switch (AlignStyle) {
  case BAA_TOP:
    top=TailSize;
    bottom=height;
    Tail[0].y=Tail[2].y=top;
    break;
  case BAA_BOTTOM:
    top=0;
    bottom=height-TailSize;
    Tail[0].y=Tail[2].y=bottom-1;
    break;
  } /* switch */
  // point tail to left/right, depending on its position
  rad=(radius+1)/2;                     // ellipse diameter to radius (round up)
  Tail[0].x= (TailX>width/2+8) ? TailX-TailSize-4 : TailX+TailSize;
  if (Tail[0].x>width-rad-TailSize)     // clamp base of tail inside the balloon
    Tail[0].x=width-rad-TailSize;
  if (Tail[0].x<rad)
    Tail[0].x=rad;
  Tail[2].x=Tail[0].x+TailSize;
  if (Tail[2].x>width-rad)              // adjust for very narrow balloons
    Tail[2].x=width-rad;
  Tail[1].x=TailX;
  Tail[1].y=TailY;

   // create combined region
   if (radius<=0)
     hrgnRect=CreateRectRgn(0,top,width,bottom);
   else
     hrgnRect=CreateRoundRectRgn(0,top,width,bottom,radius,radius);
   hrgnTail=CreatePolygonRgn(Tail,3,ALTERNATE);
   CombineRgn(hrgnRect,hrgnRect,hrgnTail,RGN_OR);

   DeleteObject(hrgnTail);
   return hrgnRect;
}
Exemplo n.º 14
0
static void hugsprim_CreateRoundRectRgn_7(HugsStackPtr hugs_root)
{
    HsInt32 arg1;
    HsInt32 arg2;
    HsInt32 arg3;
    HsInt32 arg4;
    HsInt32 arg5;
    HsInt32 arg6;
    HsPtr res1;
    arg1 = hugs->getInt32();
    arg2 = hugs->getInt32();
    arg3 = hugs->getInt32();
    arg4 = hugs->getInt32();
    arg5 = hugs->getInt32();
    arg6 = hugs->getInt32();
    res1 = CreateRoundRectRgn(arg1, arg2, arg3, arg4, arg5, arg6);
    hugs->putPtr(res1);
    hugs->returnIO(hugs_root,1);
}
Exemplo n.º 15
0
HRGN FWindowsWindow::MakeWindowRegionObject() const
{
	HRGN Region;
	if ( RegionWidth != INDEX_NONE && RegionHeight != INDEX_NONE )
	{
		if (IsMaximized())
		{
			int32 WindowBorderSize = GetWindowBorderSize();
			Region = CreateRectRgn( WindowBorderSize, WindowBorderSize, RegionWidth - WindowBorderSize, RegionHeight - WindowBorderSize );
		}
		else
		{
			if( Definition->CornerRadius > 0 )
			{
				// @todo mac: Corner radius not applied on Mac platform yet

				// CreateRoundRectRgn gives you a duff region that's 1 pixel smaller than you ask for. CreateRectRgn behaves correctly.
				// This can be verified by uncommenting the assert below
				Region = CreateRoundRectRgn( 0, 0, RegionWidth+1, RegionHeight+1, Definition->CornerRadius, Definition->CornerRadius );

				// Test that a point that should be in the region, is in the region
				// check(!!PtInRegion(Region, RegionWidth-1, RegionHeight/2));
			}
			else
			{
				Region = CreateRectRgn( 0, 0, RegionWidth, RegionHeight );
			}
		}
	}
	else
	{
		RECT rcWnd;
		GetWindowRect( HWnd, &rcWnd );
		Region = CreateRectRgn( 0, 0, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top );
	}

	return Region;
}
Exemplo n.º 16
0
void LoginForm::setFrameRegion()
{
#ifdef WIN32
	wxRect wbr = getWindowsBorderRect();
	wxPoint br = wbr.GetBottomRight();

	br.x += 2;
	br.y += 2;

	wxRegion region = CreateRoundRectRgn(wbr.x, wbr.y, br.x, br.y, 5, 5);

	// Windows takes ownership of the region, so
	// we'll have to make a copy of the region to give to it.
	DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, nullptr);
	RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
	::GetRegionData(GetHrgnOf(region), noBytes, rgnData);
	HRGN hrgn = ::ExtCreateRegion(nullptr, noBytes, rgnData);
	delete[] (char*) rgnData;

	// Now call the shape API with the new region.
	::SetWindowRgn((HWND)GetHWND(), hrgn, FALSE);
#endif // LINUX TODO
}
Exemplo n.º 17
0
void CEnteringRoomDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
	CDialog::OnShowWindow(bShow, nStatus);
	if ( bShow )
	{		
		CString strDeferPicPath = DeferPicPathMgr->GetDefaultPicPathRandom() ;
		if ( m_pPic != NULL )
		{
			delete m_pPic ;
			m_pPic = NULL ;
		}
		m_pPic = new ImageEx( strDeferPicPath ) ;
		if ( m_pPic )
		{
			SetWindowPos( NULL , 0 , 0 , m_pPic->GetWidth() + m_imgMidLeft->GetWidth() * 2 + 1, 
				          m_pPic->GetHeight() + m_imgTopMid->GetHeight() * 2 + 1, SWP_NOMOVE ) ;
			/*SetWindowPos( NULL , 0 , 0 , m_pPic->GetWidth(), 
				m_pPic->GetHeight(), SWP_NOMOVE ) ;*/
			if (m_hrgn)
			{
				DeleteObject(m_hrgn);
			}
			CRect rc(0,0,0,0);
			GetClientRect(&rc);
			m_hrgn = CreateRoundRectRgn(rc.left, rc.top, rc.right, rc.bottom, 4, 4);
			SetWindowRgn(m_hrgn, TRUE);
			
			SetTimer( ENTER_ROOM_TIMER , 100 , NULL ) ;
		}
	}
	else
	{
		KillTimer( ENTER_ROOM_TIMER ) ;
	}
	// TODO: 在此处添加消息处理程序代码
	CenterWindow(m_pHallDlg); //居中显示
}
Exemplo n.º 18
0
//
//   FUNCTION: InitInstance(HINSTANCE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	hInst = hInstance; // Store instance handle in our global variable

	hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
		500, 500, win_width, win_height, NULL, NULL, hInstance, NULL);
	if (!hWnd)
	{
		return FALSE;
	}
	// Remove borders
	SetWindowLong(hWnd, GWL_STYLE, WS_POPUP | WS_MINIMIZEBOX);
	SetWindowLong(hWnd, GWL_EXSTYLE, 0);
	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);
	//create a ball instance
	ball = CreateWindow(L"ballclass", szTitle, WS_VISIBLE|WS_CHILD,
		184, 50, ball_diameter, ball_diameter, hWnd, NULL, GetModuleHandle(NULL), NULL);
	//make window round
	SetWindowRgn(ball,(HRGN)CreateRoundRectRgn(0,0,ball_diameter,ball_diameter,ball_diameter,ball_diameter),TRUE);
	ShowWindow(ball, nCmdShow);
	UpdateWindow(ball);
	//create a pallet instance
	pallet = CreateWindow(L"palletclass", szTitle, WS_VISIBLE|WS_CHILD,
		150, win_height-25, pallet_width, pallet_height, hWnd, NULL, GetModuleHandle(NULL), NULL);
	ShowWindow(pallet, nCmdShow);
	UpdateWindow(pallet);
	SetFocus(pallet);
	//create a pallet2 instance
	pallet2 = CreateWindow(L"pallet2class", szTitle, WS_VISIBLE|WS_CHILD,
		150, 5, pallet_width, pallet_height, hWnd, NULL, GetModuleHandle(NULL), NULL);
	ShowWindow(pallet2, nCmdShow);
	UpdateWindow(pallet2);

	return TRUE;
}
Exemplo n.º 19
0
LRESULT CALLBACK _export BalloonProc(HWND hwnd, UINT message, WPARAM wParam,
                                     LPARAM lParam)
{
static DWORD lasttime;  // ??? should be a property
static POINT ttpos;
  RECT rect;
  POINT point;
  int x, y, width, height;
  SIZE size;
  LPSTR ptr;
  char text[256];

  switch (message) {
  case WM_CREATE: {
    HFONT hfont = CreateFont(-11, 0, 0, 0, FW_NORMAL, FALSE, 0, 0, DEFAULT_CHARSET,
                             OUT_DEFAULT_PRECIS, CLIP_CHARACTER_PRECIS,
                             PROOF_QUALITY, FF_DONTCARE, "MS Sans Serif");
    SetProp(hwnd,MAKEINTRESOURCE(atomFont),hfont);
    break;
  } /* case */

  case WM_DESTROY: {
    HFONT hfont = (HFONT)GetProp(hwnd,MAKEINTRESOURCE(atomFont));
    if (hfont)
      DeleteObject(hfont);
    RemoveProp(hwnd,MAKEINTRESOURCE(atomAlignStyle));
    RemoveProp(hwnd,MAKEINTRESOURCE(atomTailSize));
    RemoveProp(hwnd,MAKEINTRESOURCE(atomTimeout));
    RemoveProp(hwnd,MAKEINTRESOURCE(atomFont));
    break;
  } /* case */

  case WM_ERASEBKGND:
    return 0L;

  case WM_LBUTTONDOWN:
  case WM_RBUTTONDOWN:
  case WM_LBUTTONUP:
  case WM_RBUTTONUP:
    ShowWindow(hwnd, SW_HIDE);
    if (IsWindow(GetParent(hwnd)))
      PostMessage(GetParent(hwnd), BAN_VISIBLE, (WPARAM)hwnd, 0L);
    break;

  case WM_WINDOWPOSCHANGING:
  case WM_WINDOWPOSCHANGED:
    return 0L;

  case WM_PAINT: {
    PAINTSTRUCT ps;
    COLORREF clrBackgr;
    HBRUSH hbrBackgr;
    HRGN hrgn;
    int AlignStyle=(int)GetProp(hwnd,MAKEINTRESOURCE(atomAlignStyle));
    HFONT hfont = (HFONT)GetProp(hwnd,MAKEINTRESOURCE(atomFont));

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

    clrBackgr=GetNearestColor(hdc, RGB(255,255,192));
    hbrBackgr = CreateSolidBrush(clrBackgr);
    #if defined __WIN32__
      hrgn=CreateRectRgn(0,0,1,1);
      GetWindowRgn(hwnd,hrgn);      /* Win32-only */
    #else
      #if BM_RADIUS==0
        hrgn=CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
      #else
        hrgn=CreateRoundRectRgn(rect.left, rect.top, rect.right, rect.bottom, BM_RADIUS, BM_RADIUS);
      #endif
    #endif
    FillRgn(hdc,hrgn,hbrBackgr);
    FrameRgn(hdc,hrgn,GetStockObject(BLACK_BRUSH),1,1);
    DeleteObject(hbrBackgr);

    hfont = SelectObject(hdc, hfont);
    GetWindowText(hwnd, text, sizeof text);
    GetTextExtentPoint(hdc, text, lstrlen(text), &size);
    SetBkMode(hdc, TRANSPARENT);
    y=BM_MARGINTOP;
    if (AlignStyle==BAA_TOP) {
      int TailSize=(int)GetProp(hwnd,MAKEINTRESOURCE(atomTailSize));
      y+=TailSize;
    } /* if */
    for (ptr=strtok(text,"\n"); ptr!=NULL; ptr=strtok(NULL,"\n"), y+=size.cy) {
      GetTextExtentPoint(hdc, ptr, lstrlen(ptr), &size);
      x = ((rect.right-rect.left) - size.cx) / 2;
      TextOut(hdc, x, y, ptr, lstrlen(ptr));
    } /* for */
    SelectObject(hdc, hfont);

    EndPaint(hwnd, &ps);
    break;
  } /* case */

  case WM_TIMER: {
    DWORD timeout=(DWORD)GetProp(hwnd,MAKEINTRESOURCE(atomTimeout));
    DWORD curtime=GetTickCount();
    GetCursorPos(&point);
    if (timeout==0)
      break;
    if (curtime >= lasttime+timeout)
      SendMessage(hwnd, BAM_SHOW, 0, 0L);
    break;
  } /* if */

  case BAM_SETPOS:
    ttpos=*(LPPOINT)lParam;
    break;

  case BAM_SHOW:
    if (wParam) {
      HDC hdc;
      HRGN hrgn;
      int AlignStyle=(int)GetProp(hwnd,MAKEINTRESOURCE(atomAlignStyle));
      int TailSize=(int)GetProp(hwnd,MAKEINTRESOURCE(atomTailSize));
      HFONT hfont=(HFONT)GetProp(hwnd,MAKEINTRESOURCE(atomFont));
      ASSERT(lParam!=0);
      lstrcpy(text, (LPSTR)lParam);
      SetWindowText(hwnd, text);
      InvalidateRect(hwnd, NULL, FALSE);
      hdc = GetDC(hwnd);
      hfont = SelectObject(hdc, hfont);
      for (ptr=strtok(text,"\n"), width=height=0; ptr!=NULL; ptr=strtok(NULL,"\n")) {
        GetTextExtentPoint(hdc, ptr, lstrlen(ptr), &size);
        width = max(width, size.cx);
        height += size.cy;
      } /* for */
      SelectObject(hdc, hfont);
      ReleaseDC(hwnd, hdc);
      width += 2*BM_MARGINX;
      height += BM_MARGINTOP + BM_MARGINBOTTOM;
      #if 0
        // round width up to multiple of 16 pixels and height up to a multiple
        // of 8 pixels
        width+=16-1;
        width=width - (width%16);
        height+=8-1;
        height=height - (height%8);
      #endif
      // also add the tail size to the height
      height+=TailSize;
      // check alignment
      switch (AlignStyle) {
      case BAA_TOP:
        x = ttpos.x - width/4;
        y = ttpos.y;
        break;
      case BAA_BOTTOM:
        x = ttpos.x - width/4;
        y = ttpos.y - height;
        break;
      } /* switch */
      // check screen position against the screen size (width)
      if (x < 0)
        x = 0;
      else if (x+width >= GetSystemMetrics(SM_CXSCREEN)-1)
        x = GetSystemMetrics(SM_CXSCREEN) - width - 1;
      if (y < 0)
        y = 0;
      else if (y+height >= GetSystemMetrics(SM_CYSCREEN)-1)
        y = GetSystemMetrics(SM_CYSCREEN) - height - 1;
      GetWindowRect(hwnd,&rect);  // get first, check later (for new region)
      SetWindowPos(hwnd, HWND_TOPMOST, x, y, width, height, SWP_SHOWWINDOW|SWP_NOACTIVATE);
      hrgn=MakeBalloonRegion(width+1,height+1,BM_RADIUS,AlignStyle,TailSize,ttpos.x-x,ttpos.y-y);
      ASSERT(hrgn!=NULL);
      SetWindowRgn(hwnd, hrgn, TRUE);
      UpdateWindow(hwnd);
      lasttime=GetTickCount();
    } else {
      ShowWindow(hwnd, SW_HIDE);
      lasttime=GetTickCount();
    } /* if */
    break;

  default:
    return DefWindowProc(hwnd, message, wParam, lParam);
  } /* switch */
  return 0L;
}
Exemplo n.º 20
0
INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch ( msg ) {
	case WM_INITDIALOG: 
		TranslateDialogDefault( hwndDlg );
		{
			Utils_RestoreWindowPositionNoSize(hwndDlg, 0, MODULE, "Notify");
			SetFocus(GetDlgItem(hwndDlg, IDC_SNOOZE));

			WindowData *wd = new WindowData;
			wd->moving = false;
			wd->alarm = 0;
			wd->win_num = win_num++;

			if (wd->win_num > 0) {
				RECT r;
				GetWindowRect(hwndDlg, &r);
				r.top += 20;
				r.left += 20;

				SetWindowPos(hwndDlg, 0, r.left, r.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
				Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "Notify");
			}

			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)wd);

			// options
			SendMessage(hwndDlg, WMU_SETOPT, 0, 0);
		
			// fonts
			SendMessage(hwndDlg, WMU_SETFONTS, 0, 0);
		}
		return FALSE;

	case WMU_REFRESH:
		InvalidateRect(hwndDlg, 0, TRUE);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		{
			HDC hdc = (HDC)wParam;
			HWND hwndCtrl = (HWND)lParam;

			if (hBackgroundBrush) {
				if (hTitleFont && GetDlgItem(hwndDlg, IDC_TITLE) == hwndCtrl)
					SetTextColor(hdc, title_font_colour);
				else if (hWindowFont)
					SetTextColor(hdc, window_font_colour);

				SetBkMode(hdc, TRANSPARENT);
				return (BOOL)hBackgroundBrush;
			}
		}
		break;
	case WM_CTLCOLORDLG:
		if (hBackgroundBrush)
			return (BOOL)hBackgroundBrush;
		break;
	case WMU_SETFONTS:
		// fonts
		if (hWindowFont)
			SendMessage(hwndDlg, WM_SETFONT, (WPARAM)hWindowFont, TRUE);
		if (hTitleFont)
			SendDlgItemMessage(hwndDlg, IDC_TITLE, WM_SETFONT, (WPARAM)hTitleFont, TRUE);

		if (hBackgroundBrush) {
			SetClassLong(hwndDlg, GCLP_HBRBACKGROUND, (LONG)hBackgroundBrush);
			InvalidateRect(hwndDlg, 0, TRUE);
		}
		return TRUE;

	case WMU_SETOPT:
		{
			Options *opt;
			if (lParam) opt = (Options *)lParam;
			else opt = &options;
			
			// round corners
			if (opt->aw_roundcorners) {
				HRGN hRgn1;
				RECT r;
				int v,h;
				int w=10;
				GetWindowRect(hwndDlg,&r);
				h=(r.right-r.left)>(w*2)?w:(r.right-r.left);
				v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top);
				h=(h<v)?h:v;
				hRgn1=CreateRoundRectRgn(0,0,(r.right-r.left+1),(r.bottom-r.top+1),h,h);
				SetWindowRgn(hwndDlg,hRgn1,1);
			}
			else {
				HRGN hRgn1;
				RECT r;
				int v,h;
				int w=10;
				GetWindowRect(hwndDlg,&r);
				h=(r.right-r.left)>(w*2)?w:(r.right-r.left);
				v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top);
				h=(h<v)?h:v;
				hRgn1=CreateRectRgn(0,0,(r.right-r.left+1),(r.bottom-r.top+1));
				SetWindowRgn(hwndDlg,hRgn1,1);
			}
			// transparency
		
#ifdef WS_EX_LAYERED 
			SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) | WS_EX_LAYERED);
#endif
#ifdef LWA_ALPHA
			SetLayeredWindowAttributes(hwndDlg, RGB(0,0,0), (int)((100 - opt->aw_trans) / 100.0 * 255), LWA_ALPHA);
#endif
		}
		return TRUE;

	case WMU_SETALARM:
		{
			ALARM *data = (ALARM *)lParam;
			SetWindowText(hwndDlg, data->szTitle);
			HWND hw = GetDlgItem(hwndDlg, IDC_TITLE);
			SetWindowText(hw, data->szTitle);

			SetDlgItemText(hwndDlg, IDC_ED_DESC, data->szDesc);
			((WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA))->alarm = data;

			if (data->action & AAF_SOUND && options.loop_sound) {
				if (data->sound_num <= 3)
					SetTimer(hwndDlg, ID_TIMER_SOUND, SOUND_REPEAT_PERIOD, 0);	
				else if (data->sound_num == 4) 
					SetTimer(hwndDlg, ID_TIMER_SOUND, SPEACH_REPEAT_PERIOD, 0);	
			}

			hw = GetDlgItem(hwndDlg, IDC_SNOOZE);
			EnableWindow(hw, !(data->flags & ALF_NOSNOOZE));
			ShowWindow(hw, (data->flags & ALF_NOSNOOZE) ? SW_HIDE : SW_SHOWNA);
		}
		return TRUE;

	case WMU_FAKEALARM:
		{
			SetWindowText(hwndDlg, TranslateT("Example alarm"));
			SetDlgItemText(hwndDlg, IDC_TITLE, TranslateT("Example alarm"));
			SetDlgItemText(hwndDlg, IDC_ED_DESC, TranslateT("Some example text. Example, example, example."));
		}
		return TRUE;

	case WM_TIMER: 
		if (wParam == ID_TIMER_SOUND) {
			WindowData *dw = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
			if (dw) {
				ALARM *data = dw->alarm;
				if (data && data->action & AAF_SOUND) {
					if (data->sound_num <= 3) {
						char buff[128];
						mir_snprintf(buff, SIZEOF(buff), "Triggered%d", data->sound_num);
						SkinPlaySound(buff);
					}
					else if (data->sound_num == 4) {
						if (data->szTitle != NULL && data->szTitle[0] != '\0') {
							if (ServiceExists("Speak/Say")) {
								CallService("Speak/Say", 0, (LPARAM)data->szTitle);
							}
						}
					}
				}
			}
		}
		return TRUE;

	case WM_MOVE:
		Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "Notify");
		break;

	case WMU_ADDSNOOZER:
		{
			WindowData *wd = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
			if (wd) {
				ALARM *data = wd->alarm;

				if (data) {
					// add snooze minutes to current time
					FILETIME ft;
					GetLocalTime(&data->time);
					SystemTimeToFileTime(&data->time, &ft);
					ULARGE_INTEGER uli;
					uli.LowPart = ft.dwLowDateTime;
					uli.HighPart = ft.dwHighDateTime;

					// there are 10000000 100-nanosecond blocks in a second...
					uli.QuadPart += mult.QuadPart * (int)(wParam);

					ft.dwHighDateTime = uli.HighPart;
					ft.dwLowDateTime = uli.LowPart;

					FileTimeToSystemTime(&ft, &data->time);

					data->occurrence = OC_ONCE;
					data->snoozer = true;
					data->flags = data->flags & ~ALF_NOSTARTUP;

					data->id = next_alarm_id++;

					append_to_list(data);
				}
			}
		}
		return TRUE;

	case WM_COMMAND:
		if ( HIWORD( wParam ) == BN_CLICKED ) {
			switch( LOWORD( wParam )) {
			case IDCANCEL:  // no button - esc pressed
			case IDOK:		// space?
			case IDC_SNOOZE:
				SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)options.snooze_minutes, 0);
				//drop through
			case IDC_DISMISS:
				{
					WindowData *window_data = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
					KillTimer(hwndDlg, ID_TIMER_SOUND);
					if (window_data) {
						if (window_data->alarm) {
							free_alarm_data(window_data->alarm);
							delete window_data->alarm;
						}
						delete window_data;
					}
					SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);

					win_num--;
					//EndDialog(hwndDlg, IDOK); // not modal!
					WindowList_Remove(hAlarmWindowList, hwndDlg);
					DestroyWindow(hwndDlg);
				}
				break;
			case IDC_SNOOZELIST:
				{
					POINT pt, pt_rel;
					GetCursorPos(&pt);				
					pt_rel = pt;
					ScreenToClient(hwndDlg,&pt_rel);

					HMENU hMenu = CreatePopupMenu();
					MENUITEMINFO mmi = {0};
					mmi.cbSize = sizeof(mmi);
					mmi.fMask = MIIM_ID | MIIM_STRING;

#define AddItem(x)							\
		mmi.wID++;							\
		mmi.dwTypeData = TranslateT(x);		\
		mmi.cch = ( UINT )mir_tstrlen(mmi.dwTypeData);	\
		InsertMenuItem(hMenu, mmi.wID, FALSE, &mmi);

					AddItem(LPGEN("5 mins"));
					AddItem(LPGEN("15 mins"));
					AddItem(LPGEN("30 mins"));
					AddItem(LPGEN("1 hour"));
					AddItem(LPGEN("1 day"));
					AddItem(LPGEN("1 week"));

					TPMPARAMS tpmp = {0};
					tpmp.cbSize	= sizeof(tpmp);
					LRESULT ret = (LRESULT)TrackPopupMenuEx(hMenu, TPM_RETURNCMD, pt.x, pt.y, hwndDlg, &tpmp);
					switch(ret) {
						case 0: DestroyMenu(hMenu); return 0; // dismis menu
						case 1: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)5, 0); break;
						case 2: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)15, 0); break;
						case 3: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)30, 0); break;
						case 4: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)60, 0); break;
						case 5: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24), 0); break;
						case 6: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24 * 7), 0); break;
					}

					DestroyMenu(hMenu);

					SendMessage(hwndDlg, WM_COMMAND, IDC_DISMISS, 0);
				}
				break;
			}
		}
		return TRUE;

	case WM_MOUSEMOVE:
		if (wParam & MK_LBUTTON) {
			SetCapture(hwndDlg);

			POINT newp;
			newp.x = (short)LOWORD(lParam);
			newp.y = (short)HIWORD(lParam);

			ClientToScreen(hwndDlg, &newp);

			WindowData *window_data = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
			if (!window_data->moving)
				window_data->moving = true;
			else {
				RECT r;
				GetWindowRect(hwndDlg, &r);
				
				SetWindowPos(hwndDlg, 0, r.left + (newp.x - window_data->p.x), r.top + (newp.y - window_data->p.y), 0, 0, SWP_NOSIZE | SWP_NOZORDER);
			}
			window_data->p.x = newp.x;
			window_data->p.y = newp.y;			
		}
		else {
			ReleaseCapture();
			WindowData *window_data = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
			window_data->moving = false;
		}
		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 21
0
void CMyButton::DrawButton(HDC hDestDC)
{
	CRect rc;
	GetClientRect(rc);
	int nWindth=rc.Width();
	int nHeight=rc.Height();
	HDC hDC=CreateCompatibleDC(hDestDC);//创建兼容DC,采用双缓冲画出
	HDC hMaskDC=CreateCompatibleDC(hDestDC);
	HBITMAP hBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hMaskBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hOldBitmap=(HBITMAP)SelectObject(hDC,hBitmap);
	HBITMAP hOldMaskBitmap=(HBITMAP)SelectObject(hMaskDC,hMaskBitmap);
	SetBkMode(hDC,TRANSPARENT);

	//把父窗口的背景图复制到按钮的DC上,实现视觉透明----------------
	CShellDlg* pParent=(CShellDlg*)GetParent();
	CPoint pt(0,0);
	MapWindowPoints(pParent,&pt,1);
	pParent->m_bkImage.BitBlt(hDC,rc,pt,SRCCOPY);


	//-------------------------------------------------------------
	int nAlpha=100;//0--255
	int nOffset=0;

	HBRUSH hbr=CreateSolidBrush(m_bkColor);
	FillRect(hMaskDC,&rc,hbr);
	DeleteObject(hbr);

	if(m_bDisable){
		nAlpha=0;//100
	}else if(m_bDown){
		nAlpha=0;//180
		nOffset=1;
	}else if(m_bOver){
		nAlpha=0;//150
	}else{
		nAlpha=0;//100
	}
	BLENDFUNCTION blend;
	memset( &blend, 0, sizeof( blend) );
	blend.BlendOp= AC_SRC_OVER;
	blend.SourceConstantAlpha= nAlpha; // 透明度 最大255

	HRGN hRgn=CreateRoundRectRgn(0,0,nWindth,nHeight,3,3);
	SelectClipRgn (hDC,hRgn);
	AlphaBlend (hDC,0,0,nWindth,nHeight,hMaskDC, 0,0,nWindth,nHeight,blend);

	CString strText;
	GetWindowText(strText);
	if(strText!=_T("")){
		rc.InflateRect(-2,-2);
		rc.OffsetRect(nOffset,nOffset);
		HFONT hFont=(HFONT)SendMessage(WM_GETFONT);
		if(!hFont)hFont=(HFONT)GetStockObject(DEFAULT_GUI_FONT);
		HFONT hOldFont=(HFONT)SelectObject(hDC,hFont);
		::SetTextColor(hDC,m_textColor);
		::DrawText(hDC,strText,-1,&rc,DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_WORD_ELLIPSIS);
		::SelectObject(hDC,hOldFont);
	}
	SelectClipRgn (hDC,NULL);
	DeleteObject(hRgn);
	//复制到控件的DC上------------------------
	BitBlt(hDestDC,0,0,nWindth,nHeight,hDC,0,0,SRCCOPY);
	//删除资源,释放内存-----------------------
	SelectObject(hDC,hOldBitmap);
	DeleteObject(hBitmap);
	DeleteDC(hDC);
	SelectObject(hMaskDC,hOldMaskBitmap);
	DeleteObject(hMaskBitmap);
	DeleteDC(hMaskDC);

}
Exemplo n.º 22
0
LRESULT CALLBACK
WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	PAINTSTRUCT	ps;
	HDC		hdc;
#if CLIENT3D | IMAGE | GRAPH3D
	RECT		rc;
#endif
#if GRAPH3D
	static int	countup = 1;
	int		id;
	static vec1 	gx, gy;
#endif
#if TIMERDEMO
	static POINT	mousept;
#endif
#if ARCDEMO
	static int	startdegrees = 0;
	static int	enddegrees = 30;
#endif

	switch( msg) {
#if TIMERDEMO
	case WM_CREATE:
		SetTimer(hwnd, 1, 100, NULL);
		mousept.x = 60;
		mousept.y = 20;
		break;

	case WM_TIMER:
#if GRAPH3D
		GetClientRect(hwnd, &rc);
		if(countup) {
			mousept.y += 20;
			if(mousept.y >= rc.bottom) {
				mousept.y -= 20;
				countup = 0;
			}
		} else {
			mousept.y -= 20;
			if(mousept.y < 20) {
				mousept.y += 20;
				countup = 1;
			}
		}
		SendMessage(hwnd, WM_MOUSEMOVE, 0,
			MAKELONG(mousept.x, mousept.y));
#endif
#if ARCDEMO
		startdegrees += 10;
		if(startdegrees >= 360)
			startdegrees = 0;
		enddegrees += 15;
		if(enddegrees >= 360)
			enddegrees = 0;
		InvalidateRect(hwnd, NULL, TRUE);
#endif
		break;

	case WM_DESTROY:
		KillTimer(hwnd, 1);
		break;
#endif /* TIMERDEMO*/
	case WM_SIZE:
		break;

	case WM_MOVE:
		break;

#if CLIENT3D
	case WM_SETFOCUS:
		PostMessage((HWND)wp, WM_PAINT, 0, 0L);
		break;

	case WM_KILLFOCUS:
		PostMessage((HWND)wp, WM_PAINT, 0, 0L);
		break;
	case WM_ERASEBKGND:
		if(GetFocus() != hwnd)
			return DefWindowProc(hwnd, msg, wp, lp);
		return 1;
#endif
#if GRAPH3D
	case WM_ERASEBKGND:
		if((GetWindowLong(hwnd, GWL_ID) & 03) == 1)
			return 1;
		return DefWindowProc(hwnd, msg, wp, lp);
#endif
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);

#if CLIENT3D
		if(GetFocus() == hwnd) {
			GetClientRect(hwnd, &rc);
			Draw3dShadow(hdc, rc.left, rc.top,
				rc.right-rc.left, rc.bottom-rc.top,
				GetSysColor(COLOR_3DDKSHADOW),
				GetSysColor(COLOR_3DLIGHT));
			InflateRect(&rc, -1, -1);
			FillRect(hdc, &rc, GetStockObject(GRAY_BRUSH));
		}
#endif
#if IMAGE
		GetClientRect(hwnd, &rc);
		DrawDIB(hdc, rc.left+2, rc.top+2, image2);
#endif
#if ARCDEMO
{
	int x, y, w, h;
	RECT rc;

	if(hdc != NULL) {
		GetWindowRect(hwnd, &rc);
		rc.top += 13;
		InflateRect(&rc, -3, -3);
		/*Ellipse(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top);*/
		/*Arc(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
		/*Pie(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/

		x = rc.left;
		y = rc.top;
		w = rc.right - rc.left;
		h = rc.bottom - rc.top;
		w += 10;
		GdSetForeground(GdFindColor(RGB(0,255,0)));
		GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
			enddegrees*64, MWPIE);
		GdSetForeground(GdFindColor(RGB(0,0,0)));
		GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
			enddegrees*64, MWARCOUTLINE);
		/*GdSetForeground(GdFindColor(RGB(255,255,255)));*/
		/*GdPoint(hdc->psd, x+w/2, y+h/2);*/
	}
	EndPaint(hwnd, &ps);
	break;
}
#endif /* ARCDEMO*/
#if GRAPH3D
		id = (int)GetWindowLong(hwnd, GWL_ID) & 03;
		init3(hdc, id == 1? hwnd: NULL);
		switch(id) {
		case 0:
			rose(1.0, 7, 13);
			break;
		case 1:
			/*look3(0.5, 0.7, 1.5);*/
			/*look3(0.2, -2 * gy, 1.0+gx);*/
			look3(-2 * gx, -2 * gy, 1.2);
			drawgrid(-8.0, 8.0, 10, -8.0, 8.0, 10);
			break;
		case 2:
			setcolor3(BLACK);
			circle3(1.0);
			break;
		case 3:
			setcolor3(BLUE);
			daisy(1.0, 20);
			break;
		}

#if CLIPDEMO
		if(id == 1) {
			HRGN	hrgn, hrgn2;

			/* create circular clip region for effect*/
			GetClientRect(hwnd, &rc);
			InflateRect(&rc, -80, -80);
			switch((int)GetWindowLong(hwnd, GWL_ID)) {
			default:
				hrgn = CreateEllipticRgnIndirect(&rc);
				break;
			case 5:
				hrgn = CreateRoundRectRgn(rc.left, rc.top,
					rc.right, rc.bottom, 100, 100);
				break;
			case 1:
				hrgn = CreateRectRgnIndirect(&rc);
				break;
			}

			/* erase background, clip out blit area*/
			GetClientRect(hwnd, &rc);
			hrgn2 = CreateRectRgnIndirect(&rc);
			SelectClipRgn(hdc, hrgn2);
			ExtSelectClipRgn(hdc, hrgn, RGN_XOR);
			DeleteObject(hrgn2);

			GetClientRect(hwnd, &rc);
			FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH));

			/* clip in only blit area*/
			SelectClipRgn(hdc, hrgn);
			DeleteObject(hrgn);
		}
#endif /* CLIPDEMO*/

		paint3(hdc);

#endif /* GRAPH3D*/
		EndPaint(hwnd, &ps);
		break;

	case WM_LBUTTONDOWN:
		break;

	case WM_MOUSEMOVE:
#if GRAPH3D
		if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) {
			POINT pt;

			POINTSTOPOINT(pt, lp);
			GetClientRect(hwnd, &rc);
			gx = (vec1)pt.x / rc.right;
			gy = (vec1)pt.y / rc.bottom;
			InvalidateRect(hwnd, NULL, FALSE);
			mousept.x = pt.x;
			mousept.y = pt.y;
		}
#endif
		break;

	case WM_LBUTTONUP:
		break;

	case WM_RBUTTONDOWN:
		break;

	default:
		return DefWindowProc( hwnd, msg, wp, lp);
	}
	return( 0);
}
Exemplo n.º 23
0
HRGN WINAPI
CreateEllipticRgn( INT left, INT top, INT right, INT bottom )
{
    return CreateRoundRectRgn(left, top, right, bottom, right-left, bottom-top);
}
Exemplo n.º 24
0
BOOL CDlg_Skin_Dlg3::OnInitDialog()
{
    CDialog::OnInitDialog();

    //窗体居中显示
    CRect Rect;
    GetWindowRect(&Rect);
    int x = Rect.left -(853 + 2 - Rect.Width()) / 2;
    int y = Rect.top  -(602 + 2 - Rect.Height()) / 2;
    if (x < 0)	x = 0;
    if (y < 0)	y = 0;
    MoveWindow(x, y, 853 + 2, 602 + 2);
    this->CenterWindow();

    //窗体圆角
    HRGN hRgn = CreateRoundRectRgn(0, 0, 853 + 2, 602 + 2, 15, 15);
    SetWindowRgn(hRgn, TRUE);

    m_hDC = m_xtDC.Init(NULL, this->m_hWnd);
    m_hCompDC = m_xtDC.AddCompDC();
    m_hBmpDC = m_xtDC.AddPngDC(0, IDB_UI_PNG_GAME);
    ::BitBlt(m_hCompDC, 0, 0, 853, 602, m_hBmpDC, 0, 0, SRCCOPY);

    m_btnMin.Initial(791, 6, 20, 20, 339, 743, &m_xtDC, _T("最小化"));
    m_btnClose.Initial(819, 6, 20, 20, 400, 743, &m_xtDC, _T("关闭"));
    m_btnSet.Initial(665, 2, 56, 26, 1, 743, &m_xtDC, _T("设置"));
    m_btnHelp.Initial(721, 2, 56, 26, 170, 743, &m_xtDC, _T("帮助"));
    m_btnCamera[0].Initial(292, 235, 17, 17, 211, 771, &m_xtDC, _T("照像机"));
    m_btnCamera[1].Initial(447, 235, 17, 17, 211, 771, &m_xtDC, _T("照像机")) ;
    m_btnCamera[2].Initial(602, 235, 17, 17, 211, 771, &m_xtDC, _T("照像机"));
    m_btnVidicon[0].Initial(311, 235, 17, 17, 159, 771, &m_xtDC, _T("录像机"));
    m_btnVidicon[1].Initial(466, 235, 17, 17, 159, 771, &m_xtDC, _T("录像机"));
    m_btnVidicon[2].Initial(621, 235, 17, 17, 159, 771, &m_xtDC, _T("录像机"));
    m_btnCameraBig.Initial(786, 318, 26, 26, 80, 771, &m_xtDC, _T("照像机"));
    m_btnVidiconBig.Initial(816, 318, 26, 26, 1, 771,  &m_xtDC, _T("录像机"));
    m_btnStart.Initial(588, 534, 54, 54, 1, 604, &m_xtDC, _T("准备"));
    m_btnSend.Initial(545, 564, 43, 25, 1, 716, &m_xtDC, _T("发送"));
    m_btnSendSecret.Initial(815, 574, 24, 20, 391, 716, &m_xtDC, _T("发送密秘信息"));

    CString strHeads(_T("用户ID,80;用户昵称,110;房间,30;坐位,30;积分,30;局数,30;级别,30;金币,50;"));
    m_lstUser.Initial(4, 312, 172, 274, 1, 799, &m_xtDC, strHeads);

    CString strText;
    for (int i = 0; i < 250; i++)
    {
        strText.Format(_T("User %d"), i);
        m_lstUser.InsertItem(i, strText);
    }

    m_cbMessage.Initial(195, 567, 340, 100, 461, 743, &m_xtDC);
    m_cbMessage.AddString(_T("我是水民啊,不要杀我,验我也没用!"));
    m_cbMessage.AddString(_T("我是好人身份"));
    m_cbMessage.AddString(_T("大家为我掰票啊,体现你们价值的时候到啦!"));

    m_cbSecretMessage.Initial(669, 575, 135, 100, 461, 743, &m_xtDC);
    m_cbSecretMessage.AddString(_T("兄弟快给个建议!"));
    m_cbSecretMessage.AddString(_T("我没想好,你推一个人吧!"));
    m_cbSecretMessage.AddString(_T("验谁啊?"));
    m_cbSecretMessage.AddString(_T("我要跳警!叫他们跟我,你就给我杀"));
    m_cbSecretMessage.AddString(_T("我要认匪,我去引开他们的注意力!"));
    m_cbSecretMessage.AddString(_T("杀谁啊?"));
    m_cbSecretMessage.AddString(_T("一会我挖个坑叫他们往里跳!!"));

    //---------------------------------------------------------------------------------------

    HBITMAP hMaskBmp = ::CreateBitmap(160, 32, 1, 1, NULL);
    if (NULL == hMaskBmp) return FALSE;

    HDC hMaskDC = ::CreateCompatibleDC(m_hDC);
    if (NULL == hMaskDC) return FALSE;

    HBITMAP hOldMaskBmp = (HBITMAP)::SelectObject(hMaskDC, hMaskBmp);

    ::SetBkColor(m_hBmpDC, RGB(96, 123, 159));

    ::BitBlt(hMaskDC, 0, 0, 160, 32, m_hBmpDC, 464, 771, SRCCOPY);

    ::BitBlt(m_hCompDC, 355, 288, 32, 32, m_hBmpDC, 464, 771, SRCINVERT);
    ::BitBlt(m_hCompDC, 355, 288, 32, 32, hMaskDC, 0, 0, SRCAND);
    ::BitBlt(m_hCompDC, 355, 288, 32, 32, m_hBmpDC, 464, 771, SRCINVERT);

    ::SelectObject(hMaskDC, hOldMaskBmp);

    ::DeleteDC(hMaskDC);
    ::DeleteObject((HGDIOBJ)hMaskBmp);

    return TRUE;
}
Exemplo n.º 25
0
static void BoxPreview_OnPaint(HWND hwnd, HDC mydc, int mode)
{
	RECT rc;

	switch (mode) {
	case 0:
		{ // Avatar
			HDC hdcAvatar = CreateCompatibleDC(mydc);
			HBITMAP hbmSave = (HBITMAP)SelectObject(hdcAvatar, hbmNoAvatar);
			GetClientRect(hwnd, &rc);
			BITMAP bmp;
			GetObject(hbmNoAvatar, sizeof(bmp), &bmp);
			StretchBlt(mydc, 0, 0, rc.right, rc.bottom, hdcAvatar, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY);
			SelectObject(hdcAvatar, hbmSave);
			DeleteDC(hdcAvatar);
			HRGN rgn = CreateRoundRectRgn(0, 0, rc.right, rc.bottom, 2 * PopupOptions.avatarRadius, 2 * PopupOptions.avatarRadius);
			FrameRgn(mydc, rgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
			DeleteObject(rgn);
			break;
		}
	case 1:
		{ // Opacity
			HBRUSH hbr = CreateSolidBrush(fonts.clBack);
			HFONT hfnt = (HFONT)SelectObject(mydc, fonts.title);
			GetClientRect(hwnd, &rc);
			FillRect(mydc, &rc, hbr);
			DrawIconEx(mydc, 10, (rc.bottom-rc.top-16)/2, IcoLib_GetIcon(ICO_POPUP_ON,0), 16, 16, 0, hbr, DI_NORMAL);
			SetBkMode(mydc, TRANSPARENT);
			GetClientRect(hwnd, &rc);
			rc.left += 30; // 10+16+4 -- icon
			rc.right -= (rc.right-rc.left)/3;
			rc.bottom -= (rc.bottom-rc.top)/3;
			DrawText(mydc, _T(MODULNAME_LONG), lstrlen(_T(MODULNAME_LONG)), &rc, DT_CENTER|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER);
			GetClientRect(hwnd, &rc);
			rc.left += 30; // 10+16+4 -- icon
			rc.left += (rc.right-rc.left)/3;
			rc.top += (rc.bottom-rc.top)/3;
			DrawText(mydc, _T(MODULNAME_LONG), lstrlen(_T(MODULNAME_LONG)), &rc, DT_CENTER|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER);
			GetClientRect(hwnd, &rc);
			FrameRect(mydc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
			SelectObject(mydc, hfnt);
			DeleteObject(hbr);
		}
		break;

	case 2:
		{ // Position
			HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
			GetClientRect(hwnd, &rc);
			FillRect(mydc, &rc, hbr);
			DeleteObject(hbr);

			hbr = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
			GetClientRect(hwnd, &rc);
			rc.right -= 100;
			rc.top += 100;
			FillRect(mydc, &rc, hbr);
			DeleteObject(hbr);

			HPEN hpen = (HPEN)SelectObject(mydc, CreatePen(PS_DOT, 1, RGB(0,0,0)));
			MoveToEx(mydc,   0, 100, NULL);
			LineTo  (mydc, 201, 100);
			MoveToEx(mydc, 100,   0, NULL);
			LineTo  (mydc, 100, 201);
			DeleteObject(SelectObject(mydc, hpen));

			HRGN hrgn = CreateRectRgn(0,0,0,0);
			GetWindowRgn(hwnd, hrgn);
			FrameRgn(mydc, hrgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
			DeleteObject(hrgn);
		}
		break;
	}
}
Exemplo n.º 26
0
/*
 * Class:     sage_UIManager
 * Method:    setCompoundWindowRegion
 * Signature: (J[Ljava/awt/Rectangle;[IZ)V
 */
JNIEXPORT void JNICALL Java_sage_UIManager_setCompoundWindowRegion(JNIEnv *env, jclass jc,
																   jlong winID, jobjectArray jrects, jintArray roundness,
																   jboolean dontRepaint)
{
	HWND hwnd = (HWND) winID;
	HRGN compRgn = NULL;
	jint arrayLen;
	if (jrects == NULL || ((arrayLen = env->GetArrayLength(jrects)) == 0))
	{
		if (!SetWindowRgn(hwnd, CreateRectRgn(0,0,0,0), TRUE))
		{
			slog((env, "SetWindowRgn failed with %d\r\n", GetLastError()));
		}
		return;
	}
	
	jint* nativeRound = env->GetIntArrayElements(roundness, NULL);
	static jclass rectClass = (jclass) env->NewGlobalRef(env->FindClass("java/awt/Rectangle"));
	static jfieldID rectX = env->GetFieldID(rectClass, "x", "I");
	static jfieldID rectY = env->GetFieldID(rectClass, "y", "I");
	static jfieldID rectW = env->GetFieldID(rectClass, "width", "I");
	static jfieldID rectH = env->GetFieldID(rectClass, "height", "I");
	for (int i = 0; i < arrayLen; i++)
	{
		jobject currRect = env->GetObjectArrayElement(jrects, i);
		jint currX, currY;
		currX = env->GetIntField(currRect, rectX);
		currY = env->GetIntField(currRect, rectY);
		HRGN currRegn;
		if (nativeRound[i])
		{
			currRegn = CreateRoundRectRgn(currX, currY, currX + env->GetIntField(currRect, rectW),
				currY + env->GetIntField(currRect, rectH), nativeRound[i], nativeRound[i]);
		}
		else
		{
			currRegn = CreateRectRgn(currX, currY, currX + env->GetIntField(currRect, rectW),
				currY + env->GetIntField(currRect, rectH));
		}
		if (!currRegn)
		{
			slog((env, "CreateRectRgn failed with %d\r\n", GetLastError()));
		}
		if (arrayLen == 1)
		{
			// This used to be TRUE, but I think that's the double flashy cause
			// when the OSD is being displayed cause it triggers a second repaint
			if (!SetWindowRgn(hwnd, currRegn, !dontRepaint))
			{
				slog((env, "SetWindowRgn 2 failed with %d\r\n", GetLastError()));
			}
			env->ReleaseIntArrayElements(roundness, nativeRound, NULL);
			return;
		}
		if (i == 0)
		{
			compRgn = currRegn;
		}
		else
		{
			if (!CombineRgn(compRgn, compRgn, currRegn, RGN_OR))
			{
				slog((env, "CombineRgn 2 failed %d\r\n", GetLastError()));
			}
			DeleteObject(currRegn);
		}
	}
	// This used to be TRUE, but I think that's the double flashy cause
	// when the OSD is being displayed cause it triggers a second repaint
	if (!SetWindowRgn(hwnd, compRgn, !dontRepaint))
	{
		slog((env, "SetWindowRgn 3 failed with %d\r\n", GetLastError()));
	}
	env->ReleaseIntArrayElements(roundness, nativeRound, NULL);
}
Exemplo n.º 27
0
void CTransButton::DrawButton(HDC hDestDC)
{
	CRect rc;
	GetClientRect(rc);
	
	int nWindth=rc.Width();
	int nHeight=rc.Height();
	
	HDC hDC=CreateCompatibleDC(hDestDC);//创建兼容DC,采用双缓冲画出	
	HBITMAP hBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hOldBitmap=(HBITMAP)SelectObject(hDC,hBitmap);

	SetBkMode(hDC,TRANSPARENT);
	//把父窗口的背景图复制到按钮的DC上,实现视觉透明----------------
	CPoint pt(0,0);
	MapWindowPoints(m_pParentWnd,&pt,1);
	if(g_pBackDC)
	{
		BitBlt(hDC,0,0,nWindth,nHeight,g_pBackDC->GetSafeHdc(),
			pt.x,pt.y,SRCCOPY);
	}
	//-------------------------------------------------------------
	HDC hMaskDC=CreateCompatibleDC(hDestDC);
	HBITMAP hMaskBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hOldMaskBitmap=(HBITMAP)SelectObject(hMaskDC,hMaskBitmap);
	int nAlpha=100;//0--255
	int nOffset=0;
	if (m_BkPic.IsEmpty())
	{
		HBRUSH hbr=CreateSolidBrush(m_bkColor);
		FillRect(hMaskDC,&rc,hbr);
		DeleteObject(hbr);
	}
	else
	{
		CDC *pDC = CDC::FromHandle(hMaskDC);
		CImage img;
		HRESULT hResult = img.Load(m_BkPic);
		if(SUCCEEDED(hResult))
		{
			pDC->SetStretchBltMode(STRETCH_HALFTONE);
			img.Draw(pDC->m_hDC, 0, 0, rc.Width(), rc.Height(), 0, 0, img.GetWidth(), img.GetHeight());
		}
		else
		{
			//加载默认按钮背景图片
			CDoFile doFile;
			CString path = doFile.GetExeFullFilePath();
			path += _T("\\背景\\按钮背景图片.bmp");
			hResult = img.Load(path);
			if(SUCCEEDED(hResult))
			{
				pDC->SetStretchBltMode(STRETCH_HALFTONE);
				img.Draw(pDC->m_hDC, 0, 0, rc.Width(), rc.Height(), 0, 0, img.GetWidth(), img.GetHeight());
			}
			else
			{
				HBRUSH hbr=CreateSolidBrush(m_bkColor);
				FillRect(hMaskDC,&rc,hbr);
				DeleteObject(hbr);
			}
		}
	}

	if(m_bDisable){
		nAlpha=m_nAlpha;
	}else if(m_bDown){
		nAlpha=180;
		nOffset=1;
	}else if(m_bOver){
		nAlpha=150;
	}else{
		nAlpha=m_nAlpha;
	}

	BLENDFUNCTION blend;
	memset( &blend, 0, sizeof( blend) );
	blend.BlendOp= AC_SRC_OVER;
	blend.SourceConstantAlpha= nAlpha; // 透明度 最大255

	HRGN hRgn;
	switch(m_ButtonType)
	{
	case enumRoundRectButton:
		hRgn=CreateRoundRectRgn(0,0,nWindth,nHeight,5,5);
		break;
	case enumRectButton:
		hRgn=CreateRectRgn(0,0,nWindth,nHeight);
		break;
	case enumEllipseButton:
		hRgn=CreateEllipticRgn(0,0,nWindth,nHeight);
		break;
	default:
		break;
	}
	SelectClipRgn (hDC,hRgn);
	//实现透明
	AlphaBlend (hDC,0,0,nWindth,nHeight,hMaskDC,0,0,nWindth,nHeight,blend);
	/////////////
	SelectObject(hMaskDC,hOldMaskBitmap);
	DeleteObject(hMaskBitmap);
	DeleteDC(hMaskDC);
	//////////////显示文字
	CString strText;
	GetWindowText(strText);
	if(strText!=_T(""))
	{
		rc.InflateRect(-2,-2);
		rc.OffsetRect(nOffset,nOffset);
		CFont font;
		font.CreateFontIndirect(&m_lfFont);
		HFONT hOldFont=(HFONT)SelectObject(hDC,font);
		::SetTextColor(hDC,m_textColor);
		::DrawText(hDC,strText,-1,&rc,DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_WORD_ELLIPSIS);
		::SelectObject(hDC,hOldFont);
	}
	SelectClipRgn (hDC,NULL);
	DeleteObject(hRgn);//释放HRGN
	//复制到控件的DC上------------------------
	BitBlt(hDestDC,0,0,nWindth,nHeight,hDC,0,0,SRCCOPY);
	//回收资源
	SelectObject(hDC,hOldBitmap);
	DeleteObject(hBitmap);
	DeleteDC(hDC);
}
Exemplo n.º 28
0
static void _AniAva_RenderAvatar(ANIAVA_WINDOWINFO * dat, HDC hdcParent /* = NULL*/, RECT * rcInParent /* = NULL */ )
{
	if (dat->bPaused>0)	{	dat->bPended=TRUE;	return; 	}
	else dat->bPended=FALSE;
	
	if ( IMMEDIATE_DRAW && hdcParent == NULL ) return;
	GdiFlush();
#ifdef _DEBUG
	__AniAva_DebugRenderStrip();
#endif
	if (dat->bPlaying && IsWindowVisible(dat->hWindow))
	{
		POINT ptWnd={0};
		SIZE szWnd={dat->rcPos.right-dat->rcPos.left,dat->rcPos.bottom-dat->rcPos.top};
		BLENDFUNCTION bf={AC_SRC_OVER, 0,g_CluiData.bCurrentAlpha*dat->bAlpha/256, AC_SRC_ALPHA };
		POINT pt_from={0,0};
		HDC hDC_animation=GetDC(NULL);
		HDC copyFromDC;
		RECT clistRect;
		HDC tempDC=NULL;
		HBITMAP hBmp;
		HBITMAP hOldBmp;

		/*
		int x=bf.SourceConstantAlpha;
		x=(49152/(383-x))-129;
		x=min(x,255);	x=max(x,0);
		bf.SourceConstantAlpha=x;
		*/
		if ( AniAva.bFlags == 0 ) //simple and fastest method - no borders, round corners and etc. just copy
		{
			pt_from.x=dat->ptFromPoint.x+dat->currentFrame*dat->sizeAvatar.cx;
			pt_from.y=dat->ptFromPoint.y;
			copyFromDC=AniAva.hAniAvaDC;
		}
		else
		{
			// ... need to create additional hDC_animation
			HRGN hRgn=NULL;
			int cornerRadius= AniAva.cornerRadius;
			tempDC	= CreateCompatibleDC( NULL );
			hBmp	= ske_CreateDIB32( szWnd.cx, szWnd.cy );
			hOldBmp	= (HBITMAP)SelectObject(tempDC,hBmp);
			if ( AniAva.bFlags & AAO_ROUND_CORNERS )
			{
				if (!cornerRadius)  //auto radius
					cornerRadius = min(szWnd.cx, szWnd.cy )/5;
			}
			if ( AniAva.bFlags & AAO_HAS_BORDER )
			{
				// if has borders - create region (round corners) and fill it, remember internal as clipping
				HBRUSH hBrush = CreateSolidBrush( AniAva.borderColor );
				HBRUSH hOldBrush = (HBRUSH)SelectObject( tempDC, hBrush );
				HRGN rgnOutside = CreateRoundRectRgn( 0, 0, szWnd.cx+1, szWnd.cy+1, cornerRadius<<1, cornerRadius<<1);
				hRgn=CreateRoundRectRgn( 1, 1, szWnd.cx, szWnd.cy, cornerRadius<<1, cornerRadius<<1);
				CombineRgn( rgnOutside,rgnOutside,hRgn,RGN_DIFF);
				FillRgn( tempDC, rgnOutside, hBrush);
				ske_SetRgnOpaque( tempDC, rgnOutside, TRUE);
				SelectObject(tempDC, hOldBrush);
				DeleteObject(hBrush);
				DeleteObject(rgnOutside);
			} 
			else if ( cornerRadius > 0 )
			{
				// else create clipping area (round corners)
				hRgn=CreateRoundRectRgn(0, 0, szWnd.cx+1, szWnd.cy+1, cornerRadius<<1, cornerRadius<<1);
			}
			else
			{
				hRgn=CreateRectRgn(0, 0, szWnd.cx+1, szWnd.cy+1);
			}
			// select clip area
			if ( hRgn )
				ExtSelectClipRgn(tempDC, hRgn, RGN_AND);

			if ( AniAva.bFlags & AAO_OPAQUE)
			{
				// if back color - fill clipping area
				HBRUSH hBrush = CreateSolidBrush( AniAva.bkgColor );
				HBRUSH hOldBrush = (HBRUSH)SelectObject( tempDC, hBrush );
				FillRgn( tempDC, hRgn, hBrush );
				ske_SetRgnOpaque( tempDC, hRgn, TRUE );
			}
			// draw avatar
			if ( !(AniAva.bFlags & AAO_OPAQUE) )
				BitBlt(tempDC,0, 0, szWnd.cx, szWnd.cy , AniAva.hAniAvaDC , dat->ptFromPoint.x+dat->sizeAvatar.cx*dat->currentFrame, dat->ptFromPoint.y, SRCCOPY);
			else
			{
				BLENDFUNCTION abf={AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
				ske_AlphaBlend(tempDC,0, 0, szWnd.cx, szWnd.cy , AniAva.hAniAvaDC, dat->ptFromPoint.x+dat->sizeAvatar.cx*dat->currentFrame, dat->ptFromPoint.y, szWnd.cx, szWnd.cy, abf);
			}
			// reset clip area
			if ( hRgn )
			{
				DeleteObject(hRgn);
				hRgn = CreateRectRgn(0, 0, szWnd.cx, szWnd.cy);
				SelectClipRgn(tempDC, hRgn);
				DeleteObject(hRgn);
			}

			if ( ( AniAva.bFlags & AAO_HAS_OVERLAY )
				  && ( dat->overlayIconIdx != -1 )
				  && ( AniAva.overlayIconImageList ) )
			{
				// if overlay - draw overlay icon
				// position - on avatar
				int x=szWnd.cx-ICON_WIDTH;
				int y=szWnd.cy-ICON_HEIGHT;
				ske_ImageList_DrawEx(AniAva.overlayIconImageList,
					dat->overlayIconIdx&0xFFFF,
					tempDC, x, y, ICON_WIDTH, ICON_HEIGHT,
					CLR_NONE, CLR_NONE, ILD_NORMAL);
			}
			copyFromDC=tempDC;
		}
		// intersect visible area
		// update layered window
		GetWindowRect(pcli->hwndContactTree, &clistRect);
		if (dat->rcPos.top<0)
		{
			pt_from.y+=-dat->rcPos.top;
			szWnd.cy+=dat->rcPos.top;
		}
		if (dat->rcPos.bottom>clistRect.bottom-clistRect.top)
		{
			szWnd.cy-=(dat->rcPos.bottom-(clistRect.bottom-clistRect.top));
		}
		ptWnd.x=dat->rcPos.left+clistRect.left;
		ptWnd.y=(dat->rcPos.top>0 ? dat->rcPos.top :0)+clistRect.top;
		if (szWnd.cy>0)
		{
			if ( hdcParent && rcInParent && IMMEDIATE_DRAW )
			{
				if ( AniAva.bFlags & AAO_OPAQUE )
					BitBlt( hdcParent, rcInParent->left, rcInParent->top, szWnd.cx, szWnd.cy, copyFromDC, pt_from.x, pt_from.y, SRCCOPY);
				else
				{
					BLENDFUNCTION abf={AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
					ske_AlphaBlend( hdcParent, rcInParent->left, rcInParent->top, szWnd.cx, szWnd.cy, copyFromDC, pt_from.x, pt_from.y, szWnd.cx, szWnd.cy, abf);
				}
			}
			else if (!g_proc_UpdateLayeredWindow(dat->hWindow, hDC_animation, &ptWnd, &szWnd, copyFromDC, &pt_from, RGB(0,0,0), &bf, ULW_ALPHA ))
			{
				LONG exStyle;
				exStyle=GetWindowLong(dat->hWindow,GWL_EXSTYLE);
				exStyle|=WS_EX_LAYERED;
				SetWindowLong(dat->hWindow,GWL_EXSTYLE,exStyle);
				if ( !IMMEDIATE_DRAW )
					SetWindowPos( pcli->hwndContactTree, dat->hWindow, 0, 0, 0, 0, SWP_ASYNCWINDOWPOS | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING );
				g_proc_UpdateLayeredWindow(dat->hWindow, hDC_animation, &ptWnd, &szWnd, copyFromDC, &pt_from, RGB(0,0,0), &bf, ULW_ALPHA );
			}

			g_CluiData.fAeroGlass = false;
			CLUI_UpdateAeroGlass();
		}
		else
		{
			dat->bPlaying=FALSE;
		}
		ReleaseDC(NULL,hDC_animation);
		if (tempDC)
		{
			SelectObject(tempDC, hOldBmp);
			DeleteObject(hBmp);
			DeleteDC(tempDC);
		}
	}
	if (!dat->bPlaying)
	{
		ShowWindow(dat->hWindow, SW_HIDE);
		KillTimer(dat->hWindow,2);  //stop animation till set pos will be called
	}
	GdiFlush();
}
Exemplo n.º 29
0
void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *options)
{
	if (!av || (w <= 0) || (h <= 0)) return;

	if (!frameCount || !frameDelays || !hBitmap || (cachedWidth != w) || (cachedHeight != h))
	{
		cachedWidth = w;
		cachedHeight = h;
		if (frameDelays) {
			mir_free(frameDelays);
			frameDelays = NULL;
		}
		if (hBitmap) DeleteObject(hBitmap);
		GDIPlus_ExtractAnimatedGIF(av->szFilename, w, h, &hBitmap, &frameDelays, &frameCount, &frameSize);
	}

	if (!frameCount) return;

	HRGN rgn;
	if (options->avatarRadius)
	{
		rgn = CreateRoundRectRgn(x, y, x+w, y+h, 2 * options->avatarRadius, 2 * options->avatarRadius);
		SelectClipRgn(bmp->getDC(), rgn);
	} else
	{
		rgn = CreateRectRgn(x, y, x+w, y+h);
	}

	HDC hdcTmp = CreateCompatibleDC(bmp->getDC());
	SelectObject(hdcTmp, hBitmap);
	SetStretchBltMode(bmp->getDC(), HALFTONE);


	if (av->dwFlags & AVS_PREMULTIPLIED)
	{
		BLENDFUNCTION bf;
		bf.BlendOp = AC_SRC_OVER;
		bf.BlendFlags = 0;
		bf.SourceConstantAlpha = 255;
		bf.AlphaFormat = AC_SRC_ALPHA;
		AlphaBlend(bmp->getDC(), x, y, w, h, hdcTmp, frameSize.cx*activeFrame, 0, frameSize.cx, frameSize.cy, bf);

		if (options->avatarBorders && options->avatarPNGBorders)
		{
			HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder);
			bmp->saveAlpha(x, y, w, h);
			FrameRgn(bmp->getDC(), rgn, hbr, 1, 1); 
			DeleteObject(hbr);
			bmp->restoreAlpha(x, y, w, h);
		}
	}
	else {
		bmp->saveAlpha(x, y, w, h);
		StretchBlt(bmp->getDC(), x, y, w, h, hdcTmp, frameSize.cx*activeFrame, 0, frameSize.cx, frameSize.cy, SRCCOPY);
		if (options->avatarBorders) {
			HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder);
			FrameRgn(bmp->getDC(), rgn, hbr, 1, 1); 
			DeleteObject(hbr);
		}
		bmp->restoreAlpha(x, y, w, h);
	}
	DeleteObject(rgn);
	SelectClipRgn(bmp->getDC(), NULL);
	DeleteDC(hdcTmp);

	activeFrame = (activeFrame + 1) % frameCount;
}
Exemplo n.º 30
0
/*
 * Class:     com_thinkparity_ophelia_browser_util_window_win32_Win32WindowUtil
 * Method:    CreateRoundRectRgn
 * Signature: (IIIIII)J
 */
JNIEXPORT jint JNICALL
Java_com_thinkparity_ophelia_browser_util_window_win32_Win32WindowUtil_CreateRoundRectRgn(JNIEnv* env, jobject refThis, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect, jint nWidthEllipse, jint nHeightEllipse)
{
    return (int) CreateRoundRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, nWidthEllipse, nHeightEllipse);
}