Example #1
0
//
//	timer - used to animate the fade in/out of the transparent window
//
LRESULT DockPanel_Timer(DOCKPANEL *dpp, UINT_PTR id)
{
	extern HWND hwndAnimPanel;
	HWND hwndParam = (HWND)id;

	// get current alpha value
	BYTE alpha = (BYTE)GetWindowLongPtr(hwndParam, GWLP_USERDATA);
	BLENDFUNCTION blendPixelFunction = { AC_SRC_OVER, 0, -1, AC_SRC_ALPHA };		

	if(hwndAnimPanel != hwndParam || alpha == 0)
	{
		KillTimer(dpp->hwndPanel, id);
		DestroyWindow(hwndParam);
		return 0;
	}

	// adjust alpha value towards '0'
	alpha = alpha < 24 ? 0 : alpha - 24;
	SetWindowLongPtr(hwndParam, GWLP_USERDATA, alpha);

	// update the layered window transparency
	blendPixelFunction.SourceConstantAlpha = alpha;
	UpdateLayeredWindow(hwndParam, 0, 0, 0, 0, 0, 0, &blendPixelFunction, ULW_ALPHA);

	return 0;
}
Example #2
0
BOOL CNotificationDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_NOACTIVATE);
	SetWindowLong(GetSafeHwnd(), GWL_STYLE, WS_POPUP);
	RECT rect;
	SystemParametersInfo(SPI_GETWORKAREA, NULL, &rect, NULL);
	SetWindowPos(CWnd::FromHandle(HWND_TOPMOST), rect.right-200, rect.bottom-(95*idx)+30, 0, 0, /*SWP_NOZORDER|*/SWP_NOSIZE|SWP_NOACTIVATE);
	ShowWindow(SW_SHOWNA);

		CDC scrdc;
	scrdc.Attach(::GetDC(0));
	BLENDFUNCTION func;
	func.BlendOp=AC_SRC_OVER;
	func.AlphaFormat=AC_SRC_ALPHA;
	func.SourceConstantAlpha=0;
	func.BlendFlags=0;
	UpdateLayeredWindow(&scrdc, &CPoint(rect.right-200, rect.bottom-(95*idx)+30), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA);
	::ReleaseDC(0, scrdc);

	TRACKMOUSEEVENT tme;
	memset(&tme, 0, sizeof(TRACKMOUSEEVENT));
	tme.cbSize=sizeof(TRACKMOUSEEVENT);
	tme.dwFlags=TME_LEAVE;
	tme.hwndTrack=GetSafeHwnd();
	::TrackMouseEvent(&tme);
	cls=false;
	StartTransitionIn();

	//return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
	return FALSE;
}
Example #3
0
void NewConsole::redrawCallback()
{
	std::shared_ptr<ConsoleWnd> activeConsole = activeConsole_.lock();
	if(!activeConsole)
		return;
	redrawQueued_ = false;

	RECT rt;
	GetWindowRect(mainWnd_, &rt);
	int width = rt.right - rt.left;
	int height = rt.bottom - rt.top;
	if(!mainBitmap_)
	{
		HDC desktopDC = GetDC(nullptr);
		mainBitmap_ = CreateCompatibleBitmap(desktopDC, width, height);
		ReleaseDC(nullptr, desktopDC);
		SelectObject(mainDC_, mainBitmap_);
	}

	activeConsole->drawScreenContents(mainDC_, 0, 0, width, height, 0, 0);

	BLENDFUNCTION bf;
	bf.AlphaFormat = AC_SRC_ALPHA;
	bf.BlendFlags = 0;
	bf.BlendOp = AC_SRC_OVER;
	bf.SourceConstantAlpha = 255;

	POINT pt = {0, 0};
	POINT origin = {rt.left, rt.top};
	SIZE size = {width, height};
	UpdateLayeredWindow(mainWnd_, mainDC_, &origin, &size, mainDC_, &pt, RGB(0, 0, 0), &bf, ULW_ALPHA);
}
Example #4
0
void CWebWindow::_paintLayeredDC(HDC hdc, HDC sourceDC)
{
    RECT rectDest;
    GetWindowRect(m_hwnd, &rectDest);

    SIZE sizeDest = { rectDest.right - rectDest.left, rectDest.bottom - rectDest.top };
    POINT pointDest = { rectDest.left, rectDest.top };
    POINT pointSource = { 0, 0 };

    //HDC hdcScreen = GetDC(NULL);
    //HDC hdcMemory = CreateCompatibleDC(hdcScreen);
    //HBITMAP hbmpMemory = CreateCompatibleBitmap(hdcScreen, sizeDest.cx, sizeDest.cy);
    //HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMemory, hbmpMemory);
    //BitBlt(hdcMemory, 0, 0, sizeDest.cx, sizeDest.cy, wkeGetViewDC(this), 0, 0, SRCCOPY);

    BLENDFUNCTION blend = { 0 };
    memset(&blend, 0, sizeof(blend));
    blend.BlendOp = AC_SRC_OVER;
    blend.SourceConstantAlpha = 255;
    blend.AlphaFormat = AC_SRC_ALPHA;
    UpdateLayeredWindow(m_hwnd, hdc, &pointDest, &sizeDest, sourceDC, &pointSource, RGB(0,0,0), &blend, ULW_ALPHA);

    //SelectObject(hdcMemory, (HGDIOBJ)hbmpOld);
    //DeleteObject((HGDIOBJ)hbmpMemory);
    //DeleteDC(hdcMemory);

    //ReleaseDC(NULL, hdcScreen);
}
Example #5
0
	void DoPaint()
	{
		RECT rcClient = { 0 };
		::GetClientRect(m_hWnd, &rcClient);
		DWORD dwWidth = rcClient.right - rcClient.left;
		DWORD dwHeight = rcClient.bottom - rcClient.top;

		HDC hDcPaint = ::GetDC(m_hWnd);
		HDC hDcBackground = ::CreateCompatibleDC(hDcPaint);
		COLORREF* pBackgroundBits;
		HBITMAP hbmpBackground = CreateMyBitmap(hDcPaint, dwWidth, dwHeight, &pBackgroundBits);
		::ZeroMemory(pBackgroundBits, dwWidth * dwHeight * 4);
		HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hDcBackground, hbmpBackground);
		SetBkMode(hDcBackground, OPAQUE);
		m_pm.GetRoot()->SetPos(rcClient);
		m_pm.GetRoot()->DoPaint(hDcBackground, rcClient);
		
		PaintArrow(hDcBackground, rcClient);
		ResetAlpha((BYTE*)pBackgroundBits, dwWidth, dwHeight);

		RECT rcWnd = { 0 };
		::GetWindowRect(m_hWnd, &rcWnd);

		BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
		POINT ptPos = { rcWnd.left, rcWnd.top };
		SIZE sizeWnd = { dwWidth, dwHeight };
		POINT ptSrc = { 0, 0 };
		UpdateLayeredWindow(m_hWnd, hDcPaint, &ptPos, &sizeWnd, hDcBackground, &ptSrc, 0, &bf, ULW_ALPHA);

		::SelectObject(hDcBackground, hOldBitmap);
		if (hDcBackground != NULL) ::DeleteDC(hDcBackground);
		if (hbmpBackground != NULL) ::DeleteObject(hbmpBackground);
		::ReleaseDC(m_hWnd, hDcPaint);
	}
Example #6
0
static int winDialogSetOpacityImageAttrib(Ihandle *ih, const char *value)
{
  HBITMAP hBitmap = (HBITMAP)iupImageGetImage(value, ih, 0);
  if (!hBitmap)
    return 0;
  else
  {
    BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
    POINT ptSrc = { 0, 0 };

    HDC hDC = GetDC(NULL);
    HDC hMemDC = CreateCompatibleDC(hDC);
    HBITMAP oldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
    int img_w, img_h, bpp;
    SIZE size;

    iupdrvImageGetInfo(hBitmap, &img_w, &img_h, &bpp);
    size.cx = img_w;
    size.cy = img_h;

    UpdateLayeredWindow(ih->handle, hDC, NULL, &size, hMemDC, &ptSrc, RGB(0, 0, 0), &blend, ULW_ALPHA);

    SelectObject(hMemDC, oldBitmap);
    DeleteDC(hMemDC);
    ReleaseDC(NULL, hDC);

    return 1;
  }
}
Example #7
0
void onFrame(pixel *pixels) {
	
	/*
	// This is where all the drawing takes place
	pixel *p;
	// +0.005 each frame
	static float frameOffset = 0;
	float px; // % of the way across the bitmap
	float py; // % of the way down the bitmap
	for (int x = 0; x < width; ++x) {
	for (int y = 0; y < height; ++y) {
	p = &pixels[y * width + x];
	px = float(x) / float(width);
	py = float(y) / float(height);
	p->r = unsigned char(((cos(px + frameOffset * 10) / sin(py + frameOffset)) * cos(frameOffset * 3) * 10) * 127 + 127);
	p->g = ~p->r;
	p->b = 255;
	}
	}
	frameOffset += 0.005f;
	*/
	
	drawBackground(bgBmpWidth, bgBmpHeight, stencilBmpWidth, stencilBmpHeight, mW, mH, gazeX, gazeY, desiredColor, outBmpBytes);

	// "flush" what was just created, to screen
	static BLENDFUNCTION blendFunc = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
	static POINT ptDst = { mX, mY };
	static POINT ptZero = { 0, 0 };
	static SIZE siz = { mW, mH };

	UpdateLayeredWindow(hwnd, NULL, &ptDst, &siz, hdcOutBmp, &ptZero, 0, &blendFunc, ULW_ALPHA);

}
Example #8
0
void LayoutSubviews() {
    RECT client;
    GetClientRect(g_hMainWindow, &client);
    int width = client.right, height = client.bottom;
    MoveWindow(g_hProjectListView, kProjectListX, kProjectListY, kProjectListW, kProjectListH, TRUE);

    HDC hdcScreen = GetDC(NULL);
    HDC hDC = CreateCompatibleDC(hdcScreen);
    HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, width, height);
    HBITMAP hBmpOld = (HBITMAP)SelectObject(hDC, hBmp);

    HDC hDC2 = CreateCompatibleDC(hdcScreen);
    HBITMAP hBmpOld2 = (HBITMAP)SelectObject(hDC2, g_hMainWindowBgBitmap);


    // Call UpdateLayeredWindow
    BLENDFUNCTION blend = {0};
    blend.BlendOp = AC_SRC_OVER;
    blend.SourceConstantAlpha = 255;
    blend.AlphaFormat = AC_SRC_ALPHA;
    POINT ptPos = {0, 0};
    SIZE sizeWnd = {width, height};
    POINT ptSrc = {0, 0};
    UpdateLayeredWindow(g_hMainWindow, hdcScreen, NULL, NULL, hDC, &ptSrc, 0, &blend, ULW_ALPHA);

    SelectObject(hDC, hBmpOld);
    DeleteObject(hBmp);
    DeleteDC(hDC);
    ReleaseDC(NULL, hdcScreen);
}
Example #9
0
void MCStack::composite(void)
{
	if (m_window_shape == nil || m_window_shape -> is_sharp || m_window_shape -> handle == nil)
		return;

	POINT t_offset;
	POINT t_location;
	SIZE t_size;

	HDC t_dst_dc;
	t_dst_dc = ((MCScreenDC *)MCscreen) -> getdsthdc();

	HGDIOBJ t_old_dst;
	Pixmap t_pixmap;
	t_pixmap = (Pixmap)m_window_shape -> handle;
	t_old_dst = SelectObject(t_dst_dc, t_pixmap -> handle . pixmap);

	t_offset . x = 0;
	t_offset . y = 0;
	t_location . x = rect . x;
	t_location . y = rect . y;
	t_size . cx = m_window_shape -> width;;
	t_size . cy = m_window_shape -> height;

	BLENDFUNCTION t_blend;
	t_blend . BlendOp = AC_SRC_OVER;
	t_blend . BlendFlags = 0;
	t_blend . SourceConstantAlpha = blendlevel * 255 / 100;
	t_blend . AlphaFormat = AC_SRC_ALPHA;

	UpdateLayeredWindow((HWND)window -> handle . window, t_dst_dc, &t_location, &t_size, t_dst_dc, &t_offset, 0, &t_blend, ULW_ALPHA);

	SelectObject(t_dst_dc, t_old_dst);
}
// Calls UpdateLayeredWindow to set a bitmap (with alpha) as the content of the splash window.
static void SetSplashImage(HWND hwndSplash, HBITMAP hbmpSplash)

{
	// get the size of the bitmap
	BITMAP bm;
	GetObject(hbmpSplash, sizeof(bm), &bm);
	SIZE sizeSplash = { bm.bmWidth, bm.bmHeight };

	// get the primary monitor's info
	POINT ptZero = { 0 };
	HMONITOR hmonPrimary = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
	MONITORINFO monitorinfo = { 0 };
	monitorinfo.cbSize = sizeof(monitorinfo);
	GetMonitorInfo(hmonPrimary, &monitorinfo);

	// center the splash screen in the middle of the primary work area
	const RECT & rcWork = monitorinfo.rcWork;
	POINT ptOrigin;
	ptOrigin.x = rcWork.left + (rcWork.right - rcWork.left - sizeSplash.cx) / 2;
	ptOrigin.y = rcWork.top + (rcWork.bottom - rcWork.top - sizeSplash.cy) / 2;

	// create a memory DC holding the splash bitmap
	HDC hdcScreen = GetDC(NULL);
	HDC hdcMem = CreateCompatibleDC(hdcScreen);
	HBITMAP hbmpOld = (HBITMAP) SelectObject(hdcMem, hbmpSplash);

	// paint the window (in the right location) with the alpha-blended bitmap
	UpdateLayeredWindow(hwndSplash, hdcScreen, &ptOrigin, &sizeSplash,
		hdcMem, &ptZero, RGB(0, 0, 0), NULL, ULW_OPAQUE);

	// delete temporary objects
	SelectObject(hdcMem, hbmpOld);
	DeleteDC(hdcMem);
	ReleaseDC(NULL, hdcScreen);
}
Example #11
0
void CNotificationWnd::DoTransitionIn(){
	RECT rect;
	GetWindowRect(&rect);
	int src_y=rect.top;
	int dst_y=-30;
	for(int i=0;i<50;i++){
		int y=EaseOut(i, src_y, dst_y+1, 50);
		SetWindowPos(NULL, rect.left, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
		CDC scrdc;
	scrdc.Attach(::GetDC(0));
		BLENDFUNCTION func;
	func.BlendOp=AC_SRC_OVER;
	func.AlphaFormat=AC_SRC_ALPHA;
	func.SourceConstantAlpha=EaseOut(i, 0, 255, 50);
	func.BlendFlags=0;
	UpdateLayeredWindow(&scrdc, &CPoint(rect.left, y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA);
	::ReleaseDC(0, scrdc);

		_sleep(10);
	}

	for(int i=0;i<300;i++){
		_sleep(10);
		if(needClose)break;
	}

	while(mouseInside && !needClose){
		_sleep(10);
	}
	if(!this)return;

	for(int i=0;i<50;i++){
		CDC scrdc;
	scrdc.Attach(::GetDC(0));
		BLENDFUNCTION func;
	func.BlendOp=AC_SRC_OVER;
	func.AlphaFormat=AC_SRC_ALPHA;
	func.SourceConstantAlpha=EaseIn(i, 255, -255, 50);
	func.BlendFlags=0;
	UpdateLayeredWindow(&scrdc, &CPoint(rect.left, src_y+dst_y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA);
	::ReleaseDC(0, scrdc);

		_sleep(10);
	}
	SendMessage(WM_CLOSE);
}
Example #12
0
bool UpdateLayeredWindowT(HWND hWnd, HDC hdcDst, POINT *pptDst, SIZE* psize, HDC hdcSrc, POINT* pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags)
{
	typedef BOOL(WINAPI * lpfnUpdateLayeredWindow)(HWND hWnd, HDC hdcDst, POINT *pptDst, SIZE* psize, HDC hdcSrc, POINT* pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
	lpfnUpdateLayeredWindow UpdateLayeredWindow;
	HMODULE hUser32 = GetModuleHandle(_T("user32.dll"));
	UpdateLayeredWindow = (lpfnUpdateLayeredWindow)GetProcAddress(hUser32, "UpdateLayeredWindow");
	UpdateLayeredWindow(hWnd, hdcDst, pptDst, psize, hdcSrc, pptSrc, crKey, pblend, dwFlags);
	FreeLibrary(hUser32);
	return true;
}
Example #13
0
void cgGdiplusRender::Display()
{
	SIZE size={m_nWidth, m_nHeight};
	POINT pt={0, 0};

	//更新窗口
	if (!UpdateLayeredWindow( m_hWnd, NULL, NULL,
		&size, (HDC)m_pkBkSurface->GetContent(), &pt, 0, &m_kBlend, 2))
	{
		DWORD dwError = ::GetLastError();
		dwError = dwError;
	}
}
// Calls UpdateLayeredWindow to set a bitmap (with alpha) as the content of the splash window.
void CSplashScreen::SetSplashImage(HWND hwndSplash, HBITMAP hbmpSplash)
{
	// get the size of the bitmap
	BITMAP bm;
	POINT ptZero = { 0 };

	GetObject(hbmpSplash, sizeof(bm), &bm);

	SIZE sizeSplash = { bm.bmWidth, bm.bmHeight };

	// get the primary monitor's info
	HMONITOR hmonPrimary = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
	MONITORINFO monitorinfo = { 0 };
	monitorinfo.cbSize = sizeof(monitorinfo);
	GetMonitorInfo(hmonPrimary, &monitorinfo);

	// center the splash screen in the middle of the primary work area
	const RECT & rcWork = monitorinfo.rcWork;
	POINT ptOrigin;

	ptOrigin.x = rcWork.left + (rcWork.right - rcWork.left - sizeSplash.cx) / 2;
	ptOrigin.y = rcWork.top + (rcWork.bottom - rcWork.top - sizeSplash.cy) / 2;

	// create a memory DC holding the splash bitmap
	HDC hdcScreen = GetDC(NULL);
	HDC hdcMem = CreateCompatibleDC(hdcScreen);
	HBITMAP hbmpOld = (HBITMAP) SelectObject(hdcMem, hbmpSplash);

	// use the source image's alpha channel for blending
	m_blend.BlendOp = AC_SRC_OVER;
	m_blend.SourceConstantAlpha = 0xff;
	m_blend.AlphaFormat = AC_SRC_ALPHA;

	// paint the window (in the right location) with the alpha-blended bitmap
	UpdateLayeredWindow(hwndSplash, hdcScreen, &ptOrigin, &sizeSplash,hdcMem, &ptZero, RGB(0, 0, 0), &m_blend, ULW_ALPHA);

	// delete temporary objects
	SelectObject(hdcMem, hbmpOld);
	DeleteDC(hdcMem);
	ReleaseDC(NULL, hdcScreen);

	::SetWindowPos(hwndSplash ,       // handle to window
				HWND_TOPMOST,  // placement-order handle
				ptOrigin.x,     // horizontal position
				ptOrigin.y,      // vertical position
				sizeSplash.cx,  // width
				sizeSplash.cy, // height
				SWP_SHOWWINDOW); // window-positioning options);
}
bool CSplashScreen::FadeWindowOut(HWND hWnd) {
	DWORD dtNow = GetTickCount();
	if (dtNow >= m_nFadeoutEnd) 
	{
		return true;
	} 
	else
	{ 
		double fade = ((double)m_nFadeoutEnd - (double)dtNow) / (double)m_nFadeoutTime;
		m_blend.SourceConstantAlpha = (byte)(255 * fade);
		
		UpdateLayeredWindow(hWnd, NULL, NULL, NULL,NULL, NULL, RGB(0, 0, 0), &m_blend, ULW_ALPHA);
		return false;
	} 
	
}
Example #16
0
void UpdatePanelTrans(HWND hwndPanel, RECT *rect)
{
	POINT ptZero = { 0, 0 };
	COLORREF crKey = RGB(0, 0, 0);

	const BYTE SourceConstantAlpha = 220;//255;
	BLENDFUNCTION blendPixelFunction = { AC_SRC_OVER, 0, 0, AC_SRC_ALPHA };
	blendPixelFunction.SourceConstantAlpha = SourceConstantAlpha;
	RECT rect2;
	//rect->right = rect->left + 316;
	//rect->bottom = rect->top + 382;

	POINT pt;
	pt.x = rect->left;
	pt.y = rect->top;
	SIZE sz;
	sz.cx = GetRectWidth(rect);
	sz.cy = GetRectHeight(rect);

	HDC hdcSrc = GetDC(0);
	HDC hdcMem = CreateCompatibleDC(hdcSrc);
	HBITMAP hbm;
	HANDLE hold;

	GetClientRect(hwndPanel, &rect2);
	hbm = MakeDockPanelBitmap(rect);
	hold = SelectObject(hdcMem, hbm);

	//FillRect(hdcMem, &rect, GetSysColorBrush(COLOR_HIGHLIGHT));
	//SetWindowLongPtr(hwndPanel, GWL_EXSTYLE, GetWindowLongPtr(hwndPanel, GWL_EXSTYLE) | WS_EX_LAYERED);

	UpdateLayeredWindow(hwndPanel,
		hdcSrc,
		&pt, //pos
		&sz, //size
		hdcMem,
		&ptZero,
		crKey,
		&blendPixelFunction,
		ULW_ALPHA);

	SelectObject(hdcMem, hold);
	DeleteDC(hdcMem);
	ReleaseDC(0, hdcSrc);
}
void UpdateGLWindow(HWND hWnd)
{
		HDC hdc = GetWindowDC(hWnd);

			BLENDFUNCTION bfunc;
			bfunc.AlphaFormat = 0;
			bfunc.BlendFlags = 0;
			bfunc.BlendOp = AC_SRC_OVER;
			bfunc.SourceConstantAlpha = 255;

			POINT ptPos = {128,128};
			SIZE ptSize = {512,512} ;
		

		 UpdateLayeredWindow(hWnd, NULL, NULL, &ptSize, hdc, &ptPos, 0,
            &bfunc, ULW_ALPHA);

				ReleaseDC(hWnd, hdc);

	}
Example #18
0
void MCStack::composite(void)
{
	if (m_window_shape == nil || m_window_shape -> is_sharp || m_window_shape -> handle == nil)
		return;

	POINT t_offset;
	POINT t_location;
	SIZE t_size;

	HDC t_dst_dc;
	t_dst_dc = ((MCScreenDC *)MCscreen) -> getdsthdc();

	HGDIOBJ t_old_dst;
	HBITMAP t_bitmap;
	t_bitmap = (HBITMAP)m_window_shape -> handle;
	t_old_dst = SelectObject(t_dst_dc, t_bitmap);

	MCRectangle t_device_stack_rect;
	t_device_stack_rect = MCGRectangleGetIntegerInterior(MCResUserToDeviceRect(rect));

	MCRectangle t_device_shape_rect;
	t_device_shape_rect = MCGRectangleGetIntegerBounds(MCResUserToDeviceRect(MCRectangleMake(0, 0, m_window_shape->width, m_window_shape->height)));

	t_offset . x = 0;
	t_offset . y = 0;
	t_location . x = t_device_stack_rect . x;
	t_location . y = t_device_stack_rect . y;
	t_size . cx = t_device_shape_rect . width;;
	t_size . cy = t_device_shape_rect . height;

	BLENDFUNCTION t_blend;
	t_blend . BlendOp = AC_SRC_OVER;
	t_blend . BlendFlags = 0;
	t_blend . SourceConstantAlpha = blendlevel * 255 / 100;
	t_blend . AlphaFormat = AC_SRC_ALPHA;

	UpdateLayeredWindow((HWND)window -> handle . window, t_dst_dc, &t_location, &t_size, t_dst_dc, &t_offset, 0, &t_blend, ULW_ALPHA);

	SelectObject(t_dst_dc, t_old_dst);
}
Example #19
0
bool ieImageDIB::DrawLayeredWindow(HWND hwnd, ieXY *pxyWinPos, ieWH *pwhWinSize, ieXY xyPan) const
{
	POINT ptPan = { xyPan.nX, xyPan.nY };
	ptPan.x += xyOffs.nX;
	ptPan.y += xyOffs.nY;

	SIZE szWinSize, *pszWinSize = nullptr;
	if (pwhWinSize) {
		pszWinSize = &szWinSize;
		szWinSize.cx = min(pwhWinSize->nX, wh.nX);
		szWinSize.cy = min(pwhWinSize->nY, wh.nY);
	}

	POINT ptWinPos, *pptWinPos = nullptr;
	if (pxyWinPos) {
		pptWinPos = &ptWinPos;
		ptWinPos.x = pxyWinPos->nX;
		ptWinPos.y = pxyWinPos->nY;
	}

	if (bDrawOutline) {
		ptPan.x--;
		ptPan.y--;
		if (pptWinPos) {
			pptWinPos->x--;
			pptWinPos->y--;
		}
		if (pszWinSize) {
			pszWinSize->cx += 2;
			pszWinSize->cy += 2;
		}
	}

	bool bMoveOnly = !pszWinSize;
	bool bAlphaTransp = (AlphaType() != ieAlphaType::None) && !pCLUT;

	BLENDFUNCTION bf = { AC_SRC_OVER, 0, 0xFF, AC_SRC_ALPHA };

	return UpdateLayeredWindow(hwnd, NULL, pptWinPos, pszWinSize, bMoveOnly ? NULL : hMemDC, bMoveOnly ? NULL : &ptPan, 0, (bAlphaTransp ? &bf : NULL), bMoveOnly ? 0 : (bAlphaTransp ? ULW_ALPHA : ULW_OPAQUE)) != FALSE;
}
Example #20
0
void PopupWnd2::updateLayered(BYTE opacity)
{
	if (!m_hwnd) return;

	if (SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)) {
		RECT rc; GetWindowRect(m_hwnd, &rc);
		POINT ptDst = { rc.left, rc.top };
		POINT ptSrc = { 0, 0 };

		BLENDFUNCTION blend;
		blend.BlendOp = AC_SRC_OVER;
		blend.BlendFlags = 0;
		blend.SourceConstantAlpha = opacity; // m_options->UseTransparency ? opacity : 255;
		blend.AlphaFormat = AC_SRC_ALPHA;

		UpdateLayeredWindow(m_hwnd, NULL, &ptDst, &m_sz,
			m_bmpAnimate ? m_bmpAnimate->getDC() : m_bmp->getDC(),
			&ptSrc, 0xffffffff, &blend, ULW_ALPHA);

		UpdateWindow(m_hwnd);
	}
}
Example #21
0
void QSkinObject::updateAlpha()
{
	
	//this makes the alpha blending work. just gdi funktions and a conversation from QPixmap to HBITMAP. not really interresting
	
		
	 HBITMAP oldBitmap;
	 HBITMAP hBitmap;	
     SIZE size;
     size.cx = widgetMask.width();
     size.cy = widgetMask.height();
     HDC screenDc = GetDC(NULL);
     POINT pointSource;
     pointSource.x = 0;
     pointSource.y = 0; 
     POINT topPos;
     topPos.x = skinWidget->x();
     topPos.y = skinWidget->y();	
     HDC memDc = CreateCompatibleDC(screenDc);
     BLENDFUNCTION blend;
     blend.BlendOp             = AC_SRC_OVER;
     blend.BlendFlags          = 0;
     blend.SourceConstantAlpha = 255;
     blend.AlphaFormat         = AC_SRC_ALPHA;
	 hBitmap = widgetMask.toWinHBITMAP(QPixmap::PremultipliedAlpha);  // grab a GDI handle from this GDI+ bitmap
	 oldBitmap = (HBITMAP)SelectObject(memDc, hBitmap);
	 
	UpdateLayeredWindow(skinWidget->winId(), screenDc,  &topPos,  &size, memDc,  &pointSource, 0, &blend, ULW_ALPHA);
	
	// 
	ReleaseDC( NULL, screenDc);
	if (hBitmap != NULL)
	{
		SelectObject(memDc, oldBitmap);
		//DeleteObject(hBitmap); // The documentation says that we have to use the Windows.DeleteObject... but since there is no such method I use the normal DeleteObject from Win32 GDI and it's working fine without any resource leak.
		DeleteObject(hBitmap);
	}
	DeleteDC(memDc); 
}
Example #22
0
void CWebWindow::_onPaintUpdated(const HDC hdc, int x, int y, int cx, int cy)
{
    if (WS_EX_LAYERED == (WS_EX_LAYERED & GetWindowLong(m_hwnd, GWL_EXSTYLE)))
    {
        RECT rectDest;
        GetWindowRect(m_hwnd, &rectDest);

        SIZE sizeDest = { rectDest.right - rectDest.left, rectDest.bottom - rectDest.top };
        POINT pointDest = { rectDest.left, rectDest.top };
        POINT pointSource = { 0, 0 };

        HDC hdcScreen = GetDC(NULL);
        //HDC hdcMemory = CreateCompatibleDC(hdcScreen);
        //HBITMAP hbmpMemory = CreateCompatibleBitmap(hdcScreen, sizeDest.cx, sizeDest.cy);
        //HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMemory, hbmpMemory);
        //BitBlt(hdcMemory, 0, 0, sizeDest.cx, sizeDest.cy, wkeGetViewDC(this), 0, 0, SRCCOPY);

        BLENDFUNCTION blend = { 0 };
        memset(&blend, 0, sizeof(blend));
        blend.BlendOp = AC_SRC_OVER;
        blend.SourceConstantAlpha = 255;
        blend.AlphaFormat = AC_SRC_ALPHA;
        UpdateLayeredWindow(m_hwnd, hdcScreen, &pointDest, &sizeDest, (HDC)wkeGetViewDC(this), &pointSource, RGB(0,0,0), &blend, ULW_ALPHA);

        //SelectObject(hdcMemory, (HGDIOBJ)hbmpOld);
        //DeleteObject((HGDIOBJ)hbmpMemory);
        //DeleteDC(hdcMemory);

        ReleaseDC(NULL, hdcScreen);
    }
    else
    {
        InvalidateRect(m_hwnd, NULL, FALSE);
    }

    if (m_originalPaintUpdatedCallback)
        m_originalPaintUpdatedCallback(this, m_originalPaintUpdatedCallbackParam, hdc, x, y, cx, cy);
}
Example #23
0
File: win.c Project: zero-ui/btplay
ZuiVoid ZuiOsUpdateWindow(ZuiWindow Window, ZuiRect UpdateRect) {
	if (Window) {
		if (Window->OsWindow->Layered) {
			/*分层窗口*/
			BLENDFUNCTION Blend;
			Blend.AlphaFormat = AC_SRC_ALPHA;
			Blend.BlendFlags = 0;
			Blend.BlendOp = 0;
			Blend.SourceConstantAlpha = Window->Alpha;

			POINT pt1 = { Window->Rect.Left, Window->Rect.Top };
			POINT pt2 = { 0, 0 };
			SIZE sz = { Window->Rect.Width, Window->Rect.Height };
			HDC SrcDC = Window->GraphicsWindow->hdc;
			UpdateLayeredWindow(Window->OsWindow->hWnd,
				Window->OsWindow->hDC,
				&pt1,
				&sz,
				SrcDC,
				&pt2,
				0,
				&Blend,
				ULW_ALPHA);
		}
		else {
			/*普通窗口*/
			ZRect _UpdateRect;
			if (NULL == UpdateRect) {
				_UpdateRect = Window->Rect;
				_UpdateRect.Left = 0;
				_UpdateRect.Top = 0;
				UpdateRect = &_UpdateRect;
			}
			BitBlt(Window->OsWindow->hDC, UpdateRect->Left, UpdateRect->Top, UpdateRect->Width, UpdateRect->Height, Window->GraphicsWindow->hdc, UpdateRect->Left, UpdateRect->Top, SRCCOPY);
		}
	}
}
Example #24
0
void CRenderUtility::UpdateLayerWnd( HWND& hWnd,HDC& hSrcDc,SIZE& size )
{
	if(NULL == hWnd || !::IsWindow(hWnd)) return;

	BLENDFUNCTION blend = { 0 };  
	blend.BlendOp = AC_SRC_OVER;
	blend.BlendFlags = 0;
	blend.AlphaFormat = AC_SRC_ALPHA;
	blend.SourceConstantAlpha = 255;

	POINT ptSrc = { 0 };
	POINT ptDest = { 0 };
	HDC hDstDc = ::GetDC(hWnd);


	RECT rtWindowRect = { 0 };
	::GetWindowRect(hWnd,&rtWindowRect);
	ptDest.x = rtWindowRect.left;
	ptDest.y = rtWindowRect.top;

	//SIZE size = { RECT_WIDTH(rct),RECT_HEIGHT(rct)};
	UpdateLayeredWindow(hWnd,hDstDc,&ptDest,&size,hSrcDc,&ptSrc,NULL,&blend,ULW_ALPHA);
	::DeleteDC(hDstDc);
}
Example #25
0
    void End() {
        RECT rc;
        GetWindowRect(hWnd_, &rc);

        HDC dc;
        pGDITarget_->GetDC(
            D2D1_DC_INITIALIZE_MODE_COPY,
            &dc);

        POINT zero = {};
        SIZE size = {rc.right - rc.left, rc.bottom - rc.top};
        BLENDFUNCTION blend = { AC_SRC_OVER, 0, 0xff, AC_SRC_ALPHA };
        BOOL ret = UpdateLayeredWindow(hWnd_, NULL, NULL, &size, dc, &zero, 0, &blend, ULW_ALPHA);
        RECT nullRect = {};
        pGDITarget_->ReleaseDC(&nullRect);

        if (SUCCEEDED(hr)) {
            hr = pRT_->EndDraw(
                 );
        }
        if (FAILED(hr)) {
            DiscardDeviceResources();
        }
    }
Example #26
0
/// Function name  : drawSplashWindow
// Description     : Paints the splash window and the progress of the load game data operation
// 
// HWND  hWnd  : [in] Splash window
// 
VOID  drawSplashWindow(SPLASH_WINDOW_DATA*  pWindowData)
{
   BLENDFUNCTION  oBlendData;             // Alpha blending data
   DC_STATE*      pDCState;               // DC state
   POINT          ptOrigin;               // Drawing origin into the memory DC
   SIZE           siWindowSize;           // Size of the splash window
   RECT           rcProgressText;         // Progress stage text drawing rectangle
   TCHAR*         szProgressText;         // Progress stage text
   HDC            hScreenDC,
                  hMemoryDC;              // Memory DC
   UINT           iCurrentProgress,       // Operation progress : 0 <= n <= 10000
                  iProgressBarLength;     // Length of the progress bar, in pixels

   // Prepare
   utilZeroObject(&oBlendData, BLENDFUNCTION);
   siWindowSize = siLogoBitmap;
   ptOrigin.x = 0;
   ptOrigin.y = 0;

   /// Create DC, Pen, Font, Bitmap and progress text
   hScreenDC      = GetDC(NULL);
   hMemoryDC      = CreateCompatibleDC(hScreenDC);
   pDCState       = utilCreateDeviceContextState(hMemoryDC);
   szProgressText = loadString(getCurrentOperationStageID(getMainWindowData()->pOperationPool), 128);

   /// Create bitmap
   pWindowData->hLogoBitmap = (HBITMAP)LoadImage(getResourceInstance(), TEXT("LOGO_BITMAP"), IMAGE_BITMAP, siLogoBitmap.cx, siLogoBitmap.cy, LR_CREATEDIBSECTION);
   
   // Setup DC
   utilSetDeviceContextBitmap(pDCState, pWindowData->hLogoBitmap);
   utilSetDeviceContextPen(pDCState, pWindowData->hProgressPen);
   utilSetDeviceContextFont(pDCState, pWindowData->hProgressFont, clProgressBar);
   utilSetDeviceContextBackgroundMode(pDCState, TRANSPARENT);

   // Request per-pixel alpha blending
   oBlendData.BlendOp             = AC_SRC_OVER;
   oBlendData.AlphaFormat         = AC_SRC_ALPHA;
   oBlendData.SourceConstantAlpha = 255;

   // Calculate progress and text rectangles
   iCurrentProgress   = getCurrentOperationProgress(getMainWindowData()->pOperationPool);
   iProgressBarLength = (ptProgressBarEnd.x - ptProgressBarStart.x) * iCurrentProgress / iProgressBarMaximum;
   SetRect(&rcProgressText, ptProgressBarStart.x - 20, ptProgressBarStart.y + 3, ptProgressBarEnd.x + 20, ptProgressBarEnd.y + 20);

   /// [PROGRESS] Draw progress bar
   MoveToEx(hMemoryDC, ptProgressBarStart.x, ptProgressBarStart.y, NULL);
   LineTo(hMemoryDC, (ptProgressBarStart.x + iProgressBarLength), ptProgressBarEnd.y);

   /// [TEXT] Draw progress text
   DrawText(hMemoryDC, szProgressText, lstrlen(szProgressText), &rcProgressText, DT_SINGLELINE WITH DT_CENTER);

   /// [LOGO] Paint alpha-blended logo
   if (!UpdateLayeredWindow(pWindowData->hWnd, NULL, NULL, &siWindowSize, hMemoryDC, &ptOrigin, 0, &oBlendData, ULW_ALPHA))
      ERROR_CHECK("updating layered window", FALSE);

   // [CHECK] Are we running in windows 7 or newer?
   if (getAppWindowsVersion() >= WINDOWS_7)
      /// [WINDOWS 7] Display progress in the taskbar
      utilSetWindowProgressValue(getAppWindow(), iCurrentProgress, iProgressBarMaximum);

   // Cleanup
   utilDeleteDeviceContextState(pDCState);
   DeleteDC(hMemoryDC);
   DeleteBitmap(pWindowData->hLogoBitmap);
   ReleaseDC(NULL, hScreenDC);
   utilDeleteString(szProgressText);
}
Example #27
0
void CStatsOverlayWindow::Update(unsigned int frames)
{
	auto windowRect = GetWindowRect();

	auto screenDc = Framework::Win32::CClientDeviceContext(NULL);
	auto memDc = Framework::Win32::CMemoryDeviceContext(screenDc);
	auto memBitmap = Framework::Win32::CBitmap(CreateCompatibleBitmap(screenDc, windowRect.Width(), windowRect.Height()));
	memDc.SelectObject(memBitmap);
	memDc.SelectObject(m_font);
	SetTextColor(memDc, RGB(0xFF, 0xFF, 0xFF));
	SetBkColor(memDc, RGB(0, 0, 0));

	{
		std::lock_guard<std::mutex> profileZonesLock(m_profilerZonesMutex);

		uint64 totalTime = 0;

		for(const auto& zonePair : m_profilerZones)
		{
			const auto& zoneInfo = zonePair.second;
			totalTime += zoneInfo.currentValue;
		}

		static const uint64 timeScale = 1000000;

		//float avgFrameTime = (static_cast<double>(totalTime) /  static_cast<double>(m_frames * timeScale));
		//profilerTextResult = string_format(_T("Avg Frame Time: %0.2fms"), avgFrameTime);

		int x = m_renderMetrics.marginX;
		int y = m_renderMetrics.marginY;
		for(const auto& zonePair : m_profilerZones)
		{
			const auto& zoneInfo = zonePair.second;
			float avgRatioSpent = (totalTime != 0) ? static_cast<double>(zoneInfo.currentValue) / static_cast<double>(totalTime) : 0;
			float avgMsSpent = (frames != 0) ? static_cast<double>(zoneInfo.currentValue) / static_cast<double>(frames * timeScale) : 0;
			float minMsSpent = (zoneInfo.minValue != ~0ULL) ? static_cast<double>(zoneInfo.minValue) / static_cast<double>(timeScale) : 0;
			float maxMsSpent = static_cast<double>(zoneInfo.maxValue) / static_cast<double>(timeScale);
			memDc.TextOut(x + 0  , y, string_cast<std::tstring>(zonePair.first).c_str());
			memDc.TextOut(x + (m_renderMetrics.fontSizeX * 10), y, string_format(_T("%6.2f%%"), avgRatioSpent * 100.f).c_str());
			memDc.TextOut(x + (m_renderMetrics.fontSizeX * 20), y, string_format(_T("%6.2fms"), avgMsSpent).c_str());
			memDc.TextOut(x + (m_renderMetrics.fontSizeX * 30), y, string_format(_T("%6.2fms"), minMsSpent).c_str());
			memDc.TextOut(x + (m_renderMetrics.fontSizeX * 40), y, string_format(_T("%6.2fms"), maxMsSpent).c_str());
			y += m_renderMetrics.fontSizeY + m_renderMetrics.spaceY;
		}

		{
			float totalAvgMsSpent = (frames != 0) ? static_cast<double>(totalTime) / static_cast<double>(frames * timeScale) : 0;
			memDc.TextOut(x + (m_renderMetrics.fontSizeX * 20), y, string_format(_T("%6.2fms"), totalAvgMsSpent).c_str());
			y += m_renderMetrics.fontSizeY + m_renderMetrics.spaceY;
		}

		for(auto& zonePair : m_profilerZones) { zonePair.second.currentValue = 0; }
	}

	POINT dstPt = { windowRect.Left(), windowRect.Top() };
	SIZE dstSize = { windowRect.Width(), windowRect.Height() };
	POINT srcPt = { 0, 0 };

	BOOL result = UpdateLayeredWindow(m_hWnd, screenDc, &dstPt, &dstSize, memDc, &srcPt, RGB(0, 0, 0), nullptr, ULW_COLORKEY);
	assert(result == TRUE);
}
/* The function makes the window visible if it is hidden
 or is not yet shown. */
void
SplashRedrawWindow(Splash * splash)
{
    if (!SplashIsStillLooping(splash)) {
        KillTimer(splash->hWnd, 0);
    }

    if (splash->currentFrame < 0) {
        return;
    }

    SplashUpdateScreenData(splash);
    if (splash->isLayered) {
        BLENDFUNCTION bf;
        POINT ptSrc;
        HDC hdcSrc = CreateCompatibleDC(NULL), hdcDst;
        BITMAPINFOHEADER bmi;
        void *bitmapBits;
        HBITMAP hBitmap, hOldBitmap;
        RECT rect;
        POINT ptDst;
        SIZE size;

        bf.BlendOp = AC_SRC_OVER;
        bf.BlendFlags = 0;
        bf.AlphaFormat = AC_SRC_ALPHA;
        bf.SourceConstantAlpha = 0xFF;
        ptSrc.x = ptSrc.y = 0;

        memset(&bmi, 0, sizeof(bmi));
        bmi.biSize = sizeof(BITMAPINFOHEADER);
        bmi.biWidth = splash->width;
        bmi.biHeight = -splash->height;
        bmi.biPlanes = 1;
        bmi.biBitCount = 32;
        bmi.biCompression = BI_RGB;

        //      FIXME: this is somewhat ineffective
        //      maybe if we allocate memory for all frames as DIBSections,
        //      then we could select the frames into the DC directly

        hBitmap = CreateDIBSection(NULL, (BITMAPINFO *) & bmi, DIB_RGB_COLORS,
                &bitmapBits, NULL, 0);
        memcpy(bitmapBits, splash->screenData,
                splash->screenStride * splash->height);
        hOldBitmap = (HBITMAP) SelectObject(hdcSrc, hBitmap);
        hdcDst = GetDC(splash->hWnd);

        GetWindowRect(splash->hWnd, &rect);

        ptDst.x = rect.left;
        ptDst.y = rect.top;

        size.cx = splash->width;
        size.cy = splash->height;

        UpdateLayeredWindow(splash->hWnd, hdcDst, &ptDst, &size,
                hdcSrc, &ptSrc, 0, &bf, ULW_ALPHA);

        ReleaseDC(splash->hWnd, hdcDst);
        SelectObject(hdcSrc, hOldBitmap);
        DeleteObject(hBitmap);
        DeleteDC(hdcSrc);
    }
    else {
       InvalidateRect(splash->hWnd, NULL, FALSE);
       if (splash->maskRequired) {
            HRGN hRgn = CreateRectRgn(0, 0, 0, 0);

            CombineRgn(hRgn, splash->frames[splash->currentFrame].hRgn,
                    splash->frames[splash->currentFrame].hRgn, RGN_COPY);
            SetWindowRgn(splash->hWnd, hRgn, TRUE);
        } else {
            SetWindowRgn(splash->hWnd, NULL, TRUE);
        }
        UpdateWindow(splash->hWnd);
    }
    if (!IsWindowVisible(splash->hWnd)) {
        POINT cursorPos;
        ShowWindow(splash->hWnd, SW_SHOW);
        // Windows won't update the cursor after the window is shown,
        // if the cursor is already above the window. need to do this manually.
        GetCursorPos(&cursorPos);
        if (WindowFromPoint(cursorPos) == splash->hWnd) {
            // unfortunately Windows fail to understand that the window
            // thread should own the cursor, even though the mouse pointer
            // is over the window, until the mouse has been moved.
            // we're using SetCursorPos here to fake the mouse movement
            // and enable proper update of the cursor.
            SetCursorPos(cursorPos.x, cursorPos.y);
            SetCursor(LoadCursor(NULL, IDC_WAIT));
        }
    }
    if (SplashIsStillLooping(splash)) {
        int time = splash->time +
            splash->frames[splash->currentFrame].delay - SplashTime();

        if (time < 0)
            time = 0;
        SetTimer(splash->hWnd, 0, time, NULL);
    }
}
Example #29
0
bool Balloon::DrawAlphaBlend()
{
  RECT clientrt, contentrt;
  POINT srcPt;
  SIZE wndSz;
  BLENDFUNCTION bf;
  CLIENTINFO clientInfo;
  FORMATINFO formatInfo;
  int alpha = (pSettings->GetAlpha() * 255) / 100;

  if (!GetClientRect(balloonWnd, &clientrt))
  {
    return false;
  }

  HDC hdc = CreateCompatibleDC(NULL);
  HBITMAP hbitmap = EGCreateBitmap(0x00, RGB(0, 0, 0), clientrt);
  HGDIOBJ hobj = SelectObject(hdc, hbitmap);

  CopyRect(&contentrt, &clientrt);
  EGFrameRect(hdc, &contentrt, 255, pSettings->GetBorderColor(), 1);
  InflateRect(&contentrt, -1, -1);
  if (ELToLower(pSettings->GetGradientMethod()) == TEXT("solid"))
  {
    EGFillRect(hdc, &clientrt, alpha, pSettings->GetGradientFrom());
  }
  else
    EGGradientFillRect(hdc, &contentrt, alpha, pSettings->GetGradientFrom(),
                       pSettings->GetGradientTo(), 0, pSettings->GetGradientMethod());

  formatInfo.horizontalAlignment = EGDAT_LEFT;
  formatInfo.verticalAlignment = EGDAT_TOP;
  formatInfo.font = CreateFontIndirect(pSettings->GetInfoFont());
  formatInfo.color = pSettings->GetTextColor();
  formatInfo.flags = DT_WORDBREAK;
  clientInfo.hdc = hdc;
  CopyRect(&clientInfo.rt, &infoRect);
  clientInfo.bgAlpha = alpha;
  EGDrawAlphaText(255, clientInfo, formatInfo, info);
  DeleteObject(formatInfo.font);

  formatInfo.font = CreateFontIndirect(pSettings->GetInfoTitleFont());
  formatInfo.flags = DT_SINGLELINE;
  CopyRect(&clientInfo.rt, &titleRect);
  EGDrawAlphaText(255, clientInfo, formatInfo, infoTitle);
  DeleteObject(formatInfo.font);

  if (icon)
  {
    DrawIconEx(hdc, 5, 5, icon, iconWidth, iconHeight, 0, NULL, DI_NORMAL);
  }

  bf.BlendOp = AC_SRC_OVER;
  bf.BlendFlags = 0;
  bf.AlphaFormat = AC_SRC_ALPHA;  // use source alpha
  bf.SourceConstantAlpha = 255;

  wndSz.cx = clientrt.right;
  wndSz.cy = clientrt.bottom;
  srcPt.x = 0;
  srcPt.y = 0;

  UpdateLayeredWindow(balloonWnd, NULL, NULL, &wndSz, hdc, &srcPt, 0, &bf, ULW_ALPHA);

  // do cleanup
  SelectObject(hdc, hobj);
  DeleteDC(hdc);
  DeleteObject(hbitmap);

  return true;
}
void CWindowWithShadow::CWndShadow::DoPaint( RECT* prcPaint )
{
	//COMMON_TRACE(L"Paint--------");
	if ((GetWindowLong(GetHWND(), GWL_EXSTYLE) & WS_EX_LAYERED) == 0)
		SetWindowLong(GetHWND(), GWL_EXSTYLE, GetWindowLong(GetHWND(), GWL_EXSTYLE) | WS_EX_LAYERED);

	if (prcPaint == NULL)
		GetWindowRect(GetHWND(), prcPaint);
	if (::IsRectEmpty(prcPaint))
		return;
	int iWidth = prcPaint->right - prcPaint->left;
	int iHeight = prcPaint->bottom - prcPaint->top;
	if (m_hmpOffscreen != NULL)
	{
		::SelectObject(m_hDcOffScreen, m_hbmpOffscreenOld);
		::DeleteObject(m_hmpOffscreen);
		::DeleteDC(m_hDcOffScreen);
	}
	if (m_hDcPaint ==  NULL)
		m_hDcPaint = GetDC(GetHWND());

	BITMAPINFO bmi = { 0 };
	bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bmi.bmiHeader.biWidth = iWidth;
	bmi.bmiHeader.biHeight = iHeight;
	bmi.bmiHeader.biPlanes = 1;
	bmi.bmiHeader.biBitCount = 32;
	bmi.bmiHeader.biCompression = BI_RGB;
	bmi.bmiHeader.biSizeImage = iWidth * iHeight * (bmi.bmiHeader.biBitCount/8);
	m_hmpOffscreen = ::CreateDIBSection(m_hDcPaint, &bmi, DIB_RGB_COLORS, (LPVOID*) &m_pDibOffScreen, NULL, 0);

	m_hDcOffScreen = CreateCompatibleDC(m_hDcPaint);
	m_hbmpOffscreenOld = (HBITMAP)SelectObject(m_hDcOffScreen, m_hmpOffscreen);

	RECT rcClient;
	GetClientRect(GetHWND(), &rcClient);

	if (m_PaintManager.GetResourcePath().IsEmpty())
	{	// 允许更灵活的资源路径定义
		CDuiString strResourcePath=m_PaintManager.GetInstancePath();
		m_PaintManager.SetResourcePath(strResourcePath.GetData());
	}
	DuiLib::CRenderEngine::DrawImageString(m_hDcOffScreen, &m_PaintManager,  rcClient, *prcPaint, L"file='bk_shadow.png' corner='10,10,10,10'");
	//FillRect(m_hDcOffScreen, &rcClient, (HBRUSH)GetStockObject(BLACK_BRUSH));

	POINT ptDest = {prcPaint->left, prcPaint->top};
	::ClientToScreen(GetHWND(), &ptDest);
	POINT ptSrc = {0, 0};
	SIZE sz = {rcClient.right-rcClient.left, rcClient.bottom-rcClient.top};

	BLENDFUNCTION bfUpdate;
	bfUpdate.BlendOp = AC_SRC_OVER;
	bfUpdate.AlphaFormat = AC_SRC_ALPHA;
	bfUpdate.BlendFlags = 0;
	bfUpdate.SourceConstantAlpha = 255;
	BOOL bRet = UpdateLayeredWindow(GetHWND(), m_hDcPaint, NULL, &sz, m_hDcOffScreen, &ptSrc, 0, &bfUpdate,ULW_ALPHA);

// 	HDC hDCScreen = GetDC(NULL);
// 	BitBlt(hDCScreen, 100,100, 100, 100, m_hDcOffScreen, 0, 0, SRCCOPY);
// 	ReleaseDC(NULL, hDCScreen);
}