Click here to Skip to main content
15,902,275 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Saving Bitmap image data to HGLOBAL Pin
alleyes21-Jan-10 5:54
professionalalleyes21-Jan-10 5:54 
GeneralRe: Saving Bitmap image data to HGLOBAL Pin
Mark Salsbery21-Jan-10 6:05
Mark Salsbery21-Jan-10 6:05 
GeneralRe: Saving Bitmap image data to HGLOBAL Pin
Mark Salsbery21-Jan-10 6:19
Mark Salsbery21-Jan-10 6:19 
GeneralRe: Saving Bitmap image data to HGLOBAL Pin
alleyes21-Jan-10 9:20
professionalalleyes21-Jan-10 9:20 
GeneralRe: Saving Bitmap image data to HGLOBAL Pin
alleyes20-Jan-10 7:34
professionalalleyes20-Jan-10 7:34 
GeneralRe: Saving Bitmap image data to HGLOBAL Pin
Mark Salsbery20-Jan-10 7:40
Mark Salsbery20-Jan-10 7:40 
GeneralRe: Saving Bitmap image data to HGLOBAL Pin
alleyes20-Jan-10 7:51
professionalalleyes20-Jan-10 7:51 
QuestionFade TabPage between TabControl's tab selection Pin
roshihans15-Jan-10 19:02
roshihans15-Jan-10 19:02 
After searching on the internet, the possible solution that come out is by using TabPage.DrawToBitmap, put the bitmap in a PictureBox, set the position of PictureBox to the same location of TabPage, and fade it. The code is below :
System::Void tabControl1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e)
{
	alphaBlend = 250;
	repaint = true;
	
	// set TabPicture visibility, location, and size
	TabPictureBox->Visible = true;
	int posX = tabControl1->Location.X + tabControl1->TabPages[tabControl1->SelectedIndex]->Margin.Left + 1;
	int posY = tabControl1->Location.Y + tabControl1->ItemSize.Height + 1 + 
		tabControl1->TabPages[tabControl1->SelectedIndex]->Margin.Top;
	TabPictureBox->Location = System::Drawing::Point(posX, posY);
	TabPictureBox->Size = tabControl1->TabPages[tabControl1->SelectedIndex]->Size;
	
	// set Bitmap
	TabBitmap = gcnew Bitmap(tabControl1->TabPages[tabControl1->SelectedIndex]->Width, 
		tabControl1->TabPages[tabControl1->SelectedIndex]->Height);			
	tabControl1->TabPages[tabControl1->SelectedIndex]->DrawToBitmap(TabBitmap,
			Rectangle(0, 0, tabControl1->TabPages[tabControl1->SelectedIndex]->Width, 
				tabControl1->TabPages[tabControl1->SelectedIndex]->Height));
	
	while (alphaBlend > 0)
	{				
		alphaBlend = alphaBlend - 25;
		TabPictureBox->Refresh();
	}

	TabPictureBox->Visible = false;
	repaint = false;
}

System::Void TabPictureBox_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e)
{
	if (repaint)
	{
		if (TabBitmap != nullptr)
		{
			Bitmap^ temp = gcnew Bitmap(TabBitmap);
			Graphics^ bitmapGraphics = Graphics::FromImage(temp);
			if (alphaBlend < 0) alphaBlend = 0;
			SolidBrush^ greyBrush = gcnew SolidBrush(Color::FromArgb(alphaBlend, Color::White));
			bitmapGraphics->CompositingMode = CompositingMode::SourceOver;
			bitmapGraphics->FillRectangle(greyBrush, Rectangle(0, 0, TabBitmap->Width, TabBitmap->Height));
			e->Graphics->CompositingQuality = CompositingQuality::GammaCorrected;
			e->Graphics->DrawImage(temp, 0, 0);
		}
	}
}


The problem is that each time I select the tabPage, my CPU usage spike to 70 - 80% and the fading effect is kind of slow. Is there any solution to fix it so that I can draw the bitmap faster and with minimum CPU usage (less than 50%)?

Thanks.
QuestionI need an ebay program Pin
totolcm13-Jan-10 2:22
totolcm13-Jan-10 2:22 
QuestionCreating image file from pointer to HGLOBAL Pin
alleyes10-Jan-10 12:28
professionalalleyes10-Jan-10 12:28 
AnswerRe: Creating image file from pointer to HGLOBAL Pin
Mark Salsbery12-Jan-10 9:59
Mark Salsbery12-Jan-10 9:59 
GeneralRe: Creating image file from pointer to HGLOBAL Pin
alleyes12-Jan-10 10:25
professionalalleyes12-Jan-10 10:25 
GeneralRe: Creating image file from pointer to HGLOBAL [modified] Pin
Mark Salsbery12-Jan-10 10:34
Mark Salsbery12-Jan-10 10:34 
GeneralRe: Creating image file from pointer to HGLOBAL Pin
alleyes12-Jan-10 10:52
professionalalleyes12-Jan-10 10:52 
GeneralRe: Creating image file from pointer to HGLOBAL Pin
alleyes20-Jan-10 3:02
professionalalleyes20-Jan-10 3:02 
GeneralRe: Creating image file from pointer to HGLOBAL Pin
Mouzam Basheer23-May-16 20:40
Mouzam Basheer23-May-16 20:40 
QuestionGetting screen width and height Pin
m_mun7-Jan-10 4:12
m_mun7-Jan-10 4:12 
AnswerRe: Getting screen width and height Pin
Luc Pattyn7-Jan-10 4:19
sitebuilderLuc Pattyn7-Jan-10 4:19 
AnswerRe: Getting screen width and height Pin
Andreoli Carlo17-Jan-10 22:41
professionalAndreoli Carlo17-Jan-10 22:41 
QuestionSystem::String ^ to LPCWSTR conversion? Pin
Mattzimmerer6-Jan-10 22:27
Mattzimmerer6-Jan-10 22:27 
AnswerRe: System::String ^ to LPCWSTR conversion? Pin
Richard MacCutchan7-Jan-10 0:25
mveRichard MacCutchan7-Jan-10 0:25 
GeneralRe: System::String ^ to LPCWSTR conversion? Pin
Mattzimmerer7-Jan-10 9:14
Mattzimmerer7-Jan-10 9:14 
GeneralRe: System::String ^ to LPCWSTR conversion? Pin
Richard MacCutchan7-Jan-10 9:54
mveRichard MacCutchan7-Jan-10 9:54 
AnswerRe: System::String ^ to LPCWSTR conversion? [modified] Pin
Mark Salsbery7-Jan-10 9:35
Mark Salsbery7-Jan-10 9:35 
QuestionRe: System::String ^ to LPCWSTR conversion? Pin
Mattzimmerer7-Jan-10 9:59
Mattzimmerer7-Jan-10 9:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.