Example #1
0
void showImage(HWND hDlg, char* image, Docklet* docklet)
{
	// Get the background color
	Color* background = new Color();
	background->SetFromCOLORREF(GetSysColor(COLOR_BTNFACE));

#define ICON_SIZE_PREVIEW 96
	// Create the bitmap
	Bitmap bitmap(ICON_SIZE_PREVIEW, ICON_SIZE_PREVIEW);
	Graphics bitmapGraphics(&bitmap);
	SolidBrush solidBrush(*background);
	bitmapGraphics.FillRectangle(&solidBrush, 0, 0, ICON_SIZE_PREVIEW, ICON_SIZE_PREVIEW);

	RectF rect(0.0f, 0.0f, (REAL)ICON_SIZE_PREVIEW, (REAL)ICON_SIZE_PREVIEW);

	if (strcmp(image, "") == 0)
	{
		CGdiPlusBitmapResource* res = new CGdiPlusBitmapResource();
		res->Load(IDB_BACKGROUND, _T("PNG"), dllInstance);

		bitmapGraphics.DrawImage(res->m_pBitmap, rect, 0.0f, 0.0f, (REAL)res->m_pBitmap->GetWidth(), (REAL)res->m_pBitmap->GetHeight(), UnitPixel);

		delete res;
	}
	else
	{
		Bitmap* img = docklet->LoadGDIPlusImage(image);
		bitmapGraphics.DrawImage(img, rect, 0.0f, 0.0f, (REAL)img->GetWidth(), (REAL)img->GetHeight(), UnitPixel);

		delete img;
	}

	HBITMAP hBitmap;
	bitmap.GetHBITMAP(*background, &hBitmap);

	// Display the image
	SendDlgItemMessage(hDlg, IDC_DOCKLET_IMAGE, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM) hBitmap);
	delete(background);
}
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
					LPSTR lpszArgument, int nFunsterStil)
					//int _tmain(int argc, TCHAR *argv[]) 
{ 
	try{
		MyRegisterClass(hThisInstance);

		Gdiplus::GdiplusStartupInput gdiSI;
		Gdiplus::GdiplusStartupOutput gdiSO;
		ULONG_PTR gdiToken;
		ULONG_PTR gdiHookToken;
		gdiSI.SuppressBackgroundThread = TRUE;
		Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO);
		gdiSO.NotificationHook(&gdiHookToken);


		CSplashWnd splash;

		Gdiplus::Bitmap* pImage;

		if (_access("splash.png", 0)==-1)
		{			
			CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource;
			if (pBitmap->Load(SPLASH_GIF))
			{
				pImage = pBitmap->m_pBitmap;
			}
		}else{
			pImage = Gdiplus::Bitmap::FromFile(L"splash.png");
		}

		splash.SetImage(pImage);
		splash.SetWindowName(L"Marktfuehrer wird geladen...");

		delete pImage; // you are free to delete now
		



		if (checkIfProcessIsAlreadyRunning())
		{
			::MessageBox(NULL, L"Die Anwendung wurde bereits geladen...", L"Info", MB_ICONINFORMATION);
			exit(0);
		}else
		{
			splash.Show();
			CreateChildProcess();

			BOOL loaded = FALSE;
			UINT progressTotal = 0;
			UINT oldProgress = -1;

			// Main message loop:
			while (GetMessage(&msg, NULL, 0, 0))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}

			gdiSO.NotificationUnhook(gdiHookToken);
			Gdiplus::GdiplusShutdown(gdiToken);

			exit(0);
			return (int) msg.wParam;
		}
	}
	catch(exception& e){
		::MessageBox(NULL, L"Die Anwendung konnte die Ladeanzeige nicht finden. Der Marktführer wurde dennoch gestartet. Das kann einen Momemt dauern. Dabei wir Ihnen kein Ladebildschirm gezeigt.", L"Failed", MB_ICONSTOP);
		exit(0);
		return (int) msg.wParam;
	}

} 
Example #3
0
void showInfo(HWND hDlg, PLUGIN_DATA *data, int selected)
{
	int size = 128;

	// Load the background image
	CGdiPlusBitmapResource* image = new CGdiPlusBitmapResource();
	image->Load(IDB_BACKGROUND, _T("PNG"), dllInstance);

	if (image->m_pBitmap != NULL) {
		// Get the background color
		Color* background = new Color();
		background->SetFromCOLORREF(GetSysColor(COLOR_BTNFACE));

		// Create the bitmap
		Bitmap bitmap(size+64,size+64);
		Graphics bitmapGraphics(&bitmap);
		SolidBrush solidBrush(*background);
		bitmapGraphics.FillRectangle(&solidBrush, 0, 0, image->m_pBitmap->GetHeight()+64, image->m_pBitmap->GetWidth()+64);

		// Apply color transformation and draw the icon
		RectF rect(0.0f, 0.0f, (REAL)size+64, (REAL)size+64);
		ImageAttributes attributes;
		ColorMatrix colorMatrix = {
				0.45f, 0.33f, 0.33f, 0.0f, 0.0f,
				0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
				0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
				0.0f, 0.0f, 0.0f, 0.1f, 0.0f,
				0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

		attributes.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeDefault);
		bitmapGraphics.DrawImage(image->m_pBitmap, rect, 0, 0, (REAL)image->m_pBitmap->GetHeight(), (REAL)image->m_pBitmap->GetWidth(), UnitPixel, &attributes, NULL, NULL);

		// Init Brushes & Font
		SolidBrush  blackBrush(Color(255, 0, 0, 0));
		SolidBrush  whiteBrush(Color(128, 160, 160, 160));
		FontFamily  fontFamily(L"Arial");
		Font        font(&fontFamily, 13, FontStyleBold, UnitPixel);

		// Draw the name, author, version and notes
		Docklet::DOCKLET_INFO info = Docklet::GetInformationFromDll((char*)data->docklets[selected].path);

		USES_CONVERSION;

		wchar_t name[200];
		wcscpy_s(name, L"");
		wcscat_s(name, CA2W(info.name));

		wchar_t notes[500];
		wcscpy_s(notes, L"");
		wcscat_s(notes, CA2W(info.notes));

		wchar_t author[200];
		wcscpy_s(author, L"By ");
		wcscat_s(author, CA2W(info.author));

		int major = info.version/100;
		int minor = info.version - 100*major;

		wchar_t version[40];
		wcscpy_s(version, L"");
		if (minor > 9)
			swprintf_s(version, L"Version %d.%d", major, minor);
		else
			swprintf_s(version, L"Version %d.0%d", major, minor);

		////////////////////////////////////////////////////////////////////////////
		bitmapGraphics.DrawString((WCHAR *)&name, -1, &font, PointF(1.0f, 1.0f), &whiteBrush);
		bitmapGraphics.DrawString((WCHAR *)&name, -1, &font, PointF(0.0f, 0.0f), &blackBrush);

		bitmapGraphics.DrawString((WCHAR *)&author, -1, &font, PointF(1.0f, 21.0f), &whiteBrush);
		bitmapGraphics.DrawString((WCHAR *)&author, -1, &font, PointF(0.0f, 20.0f), &blackBrush);

		bitmapGraphics.DrawString((WCHAR *)&version, -1, &font, PointF(1.0f, 41.0f), &whiteBrush);
		bitmapGraphics.DrawString((WCHAR *)&version, -1, &font, PointF(0.0f, 40.0f), &blackBrush);

		RectF rect1(1.0f, 101.0f, 200.0f, 200.0f);
		RectF rect2(0.0f, 100.0f, 200.0f, 200.0f);
		bitmapGraphics.DrawString((WCHAR *)&notes, -1, &font, rect1, StringFormat::GenericDefault(), &whiteBrush);
		bitmapGraphics.DrawString((WCHAR *)&notes, -1, &font, rect2, StringFormat::GenericDefault(), &blackBrush);
		////////////////////////////////////////////////////////////////////////////

		HBITMAP hBitmap;
		bitmap.GetHBITMAP(*background, &hBitmap);

		// Display the image
		SendDlgItemMessage(hDlg, IDC_ICON_PIC, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM) hBitmap);
		delete(background);
	}
	delete(image);
}