Vahid
Vahid

Reputation: 584

Draw an invisible control on a canvas in Delphi

I made a calendar component for Delphi. Now I want to add a visual effect to it while changing months (like Windows Vista standard calendar).

Now I want to create an invisible duplicate of the component and draw that one on the canvas to use it for the visual effect. I tried BitBlt function but it does not work because the control is invisible. Is there any way to draw an invisible control on a canvas?

Upvotes: 3

Views: 1406

Answers (2)

NGLN
NGLN

Reputation: 43649

In addition to Rob's correct answer, may I present two alternatives?

  1. The arrows and month name do not seem to scroll, so let's call them the header of the component and make it a subcontrol of the component. Subsequently, make the days a subcontrol too. Now it is possible to place two day-controls adjacent to the one shown. Because they are beyond the bounds of the component, these aside placed day-controls are hidden, but become visible as soon as they move. At the end of the scroll operation, move the outmost to the other side and set its month appropriately.

  2. Move the painting of the days to a separate routine with a month-like parameter. When scrolling, call that routine twice.

Upvotes: 2

Rob Kennedy
Rob Kennedy

Reputation: 163277

Call the control's PaintTo method. That's for descendants of TWinControl.

I don't see an analogous method for TGraphicControl descendants, but since those always require a TWinControl parent, you could just call PaintTo on the parent control to get an image of the TGraphicControl child.

Upvotes: 5

Related Questions