Link to home
Start Free TrialLog in
Avatar of sruel
sruel

asked on

URGENT PLEASE - Image over controls in a form

Hi,

I have a form that contains a grid, an image and some buttons.

I want to move the image at runtime over the other controls, EVEN OVER the grid.

How can I do that ?

Thanks
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

a TImage is Not a WinControl, so you might try putting the Image on a TPanel (which is a WinControl) and making the panel the size of the image, then moving the Panel around, you can reduce the panel borders if you don't want to see the panel.
Do you want to move Image programmaticaly or with a mouse?
Avatar of sruel
sruel

ASKER

I want to move Image programmaticaly ...

Also, my image is a triangle. If I put it on a frame, there will be 2 "empty" spaces in the left and rigth upper corner and i want to see what is behind this...
sruel,

TImage is not windowed control, so it can never be visible on top of windowed controls (that is, most of visible VCL components, not only TStringGrid).
What you need is transparent windowed control, which has to be created from scratch. This is not few lines of code, so I don't think you should create your class dynamically.

Since you tagged your post URGENT i presume you don't have time to create your own component. This free component does exactly what you want:
 
   http://www.zecos.com/files/transppanel.zip

(Readme.txt will tell you all you need to know)
are there anymore design specs that you havent mentionded like  the transparent triangle edges? You can set you Panel's shape with a region. This makees a Star shape panel

procedure TForm1.ButtonClick(Sender: TObject);
const
  RadConvert = PI/180;
  Degrees    = 360;
  MaxLines   = 100;
var
  rgn: HRGN;
  x, y, xCenter,
  yCenter, radius,
  pts, I: Integer;
  angle, rotation: Extended;
  DoStarShape: Boolean;
  arPts   : Array[0..MaxLines] of TPoint;
begin
DoStarShape := True;
    xCenter := (Image3.BoundsRect.Right- Image3.BoundsRect.Left) div 2;
  yCenter := (Image3.BoundsRect.Bottom - Image3.BoundsRect.Top) div 2;
  if DoStarShape then
    begin
      rotation := Degrees/(12);
      pts := 2 * 6;
    end
  else
    begin
      rotation := Degrees/6;
      pts := 6 {points in Star}
    end;
  radius := yCenter;

  for I := 0 to pts - 1 do begin
    if DoStarShape then
      if (I mod 2) = 0 then //which means that
        radius := Round(radius/2)
      else
        radius := yCenter;

    angle := ((I * rotation) + 90) * RadConvert;
    x := xCenter + Round(cos(angle) * radius);
    y := yCenter - Round(sin(angle) * radius);
    arPts[I].X := x;
    arPts[I].Y := y;
  end;

rgn := CreatePolygonRgn(arPts, pts, WINDING);
  SetWindowRgn(Panel1.Handle, rgn, TRUE);
end;

 - - - - - - - -  - - - - - - - -  - - -

but you could simplify it to a triangle
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)
why not simply draw that triangle bitmap on the forms canvas ?
that way it will be always on top
and I'm guessing that triangle image is some sort of a pointer (pointing at controls) ?
you can use the froms canvas functions like Canvas.Draw(...params...);
before each draw invalidate the area you previously painted on so it gets updated
Hi,

Do you want to draw in a string grid (like to show a status graphic of some kind)?

I admit to not having read everything which has been said but when I need to draw on a grid, I use the OnSelectCell to prevent the user from selecting the cell (that would cause the InPlaceEditor to activate, thereby hiding my graphic.

Then I use the OnDrawCell to paint the graphic in the cell.

MP