Board index » delphi » Problem drawing to main form canvas

Problem drawing to main form canvas

I must be missing something simple, but I just can't get this to work.
I have a bitmap (in "pic"), and I want to draw it to the canvas of the
program's main form (called "form_main"). The line:
form_main.Canvas.Draw(0,0,pic);
Compiles, but does nothing at runtime.

I know my bitmap is okay, because when I draw to an image control on the
form:
form_main.Image1.Canvas.Draw(0,0,pic);
it works just fine.

Is there some secret "AllowDrawing" setting I'm missing somewhere?

Any help appreciated,
Thanks,
-Matt

 

Re:Problem drawing to main form canvas


Quote
Matt wrote:
> I must be missing something simple, but I just can't get this to work.
> I have a bitmap (in "pic"), and I want to draw it to the canvas of the
> program's main form (called "form_main"). The line:
> form_main.Canvas.Draw(0,0,pic);
> Compiles, but does nothing at runtime.

> I know my bitmap is okay, because when I draw to an image control on the
> form:
> form_main.Image1.Canvas.Draw(0,0,pic);
> it works just fine.

> Is there some secret "AllowDrawing" setting I'm missing somewhere?

Where are you placing your drawing code?

Any code that draws on the form's canvas should be in the OnPaint event.

Re:Problem drawing to main form canvas


That did it; thanks.

Quote
"Mauro Patino" <M-Pat...@govst.edu> wrote in message

news:3B967E1F.6C01D34D@govst.edu...
Quote
> Matt wrote:

> > I must be missing something simple, but I just can't get this to work.
> > I have a bitmap (in "pic"), and I want to draw it to the canvas of the
> > program's main form (called "form_main"). The line:
> > form_main.Canvas.Draw(0,0,pic);
> > Compiles, but does nothing at runtime.

> > I know my bitmap is okay, because when I draw to an image control on the
> > form:
> > form_main.Image1.Canvas.Draw(0,0,pic);
> > it works just fine.

> > Is there some secret "AllowDrawing" setting I'm missing somewhere?

> Where are you placing your drawing code?

> Any code that draws on the form's canvas should be in the OnPaint event.

Other Threads