lame problem :/

  • Thread starter Thread starter ErUs
  • Start date Start date
E

ErUs

Im too new to work out how to do this.
i have
try {
Bitmap *logopic = new Bitmap(S"logopic.bmp");
e->Graphics->DrawImage(logopic, 0, 0, WINDOW_WI,
WINDOW_HI);
} catch (Exception* e) {
MessageBox::Show("Failed to load
logopic.bmp");
this->Close();
}

i want a
[code:1:43bc4086fd]private: Bitmap *logopic;[/code:1:43bc4086fd]
then
[code:1:43bc4086fd]logopic = new
Bitmap(S"logopic.bmp");[/code:1:43bc4086fd]
sorta thing
so that i dont have to creat a Bitmap then load the pic every time i
want to use it.
plz help :o
*---------------------------------*
Posted at: http://www.GroupSrv.com
*---------------------------------*
 
Add a private member variable with type Bitmap* to the class, m_bitmap for
example, and initialize it to null. Then when you need to use the bitmap
check if m_bitmap points to null, if not load the bitmap like you are doing
now.


Bitmap* m_Bitmap = null;

//When you need the bitmap...
if (!m_Bitmap)
Bitmap *m_Bitmap = new Bitmap(S"logopic.bmp");

e->Graphics->DrawImage(m_Bitmap, 0, 0, WINDOW_WI,WINDOW_HI);

Another option, maybe more efficient, is to initialize m_Bitmap to the
bitmap in the constructor.


--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
 
that works great thanks,
but i have another problem,
i am trying to paint to my window outside of the private: System::Void
Form1_Paint_1(System::Object * sender,
System::Windows::Forms::PaintEventArgs * e)

so far i have
Bitmap* paintsurface = new Bitmap( 400, 300
);
Graphics *graph = Graphics::FromImage(paintsurface);
graph->Clear( Color::Black );

but this doesnt work i cant draw anything :(
plz help :(
 
Back
Top