URGENT PLEASE - Image over controls in a form

Posted on 2002-06-13
Medium Priority
Last Modified: 2010-04-04

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 ?

Question by:sruel
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 34

Expert Comment

ID: 7077192
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.

Expert Comment

ID: 7077346
Do you want to move Image programmaticaly or with a mouse?

Author Comment

ID: 7077736
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...
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 7078033

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:

(Readme.txt will tell you all you need to know)
LVL 34

Expert Comment

ID: 7079228
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);
  RadConvert = PI/180;
  Degrees    = 360;
  MaxLines   = 100;
  rgn: HRGN;
  x, y, xCenter,
  yCenter, radius,
  pts, I: Integer;
  angle, rotation: Extended;
  DoStarShape: Boolean;
  arPts   : Array[0..MaxLines] of TPoint;
DoStarShape := True;
    xCenter := (Image3.BoundsRect.Right- Image3.BoundsRect.Left) div 2;
  yCenter := (Image3.BoundsRect.Bottom - Image3.BoundsRect.Top) div 2;
  if DoStarShape then
      rotation := Degrees/(12);
      pts := 2 * 6;
      rotation := Degrees/6;
      pts := 6 {points in Star}
  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)
        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;

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

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

but you could simplify it to a triangle
LVL 34

Accepted Solution

Slick812 earned 200 total points
ID: 7080018
Here's the code in the Form create to make a Triangle shaped Panel3 with Image3 on it.

procedure TForm1.FormCreate(Sender: TObject);
  Rgn1: HRGN;
  arrayPts: Array[0..2] of TPoint;
arrayPts[0].y := 0;
arrayPts[0].x := Image3.Width div 2;

arrayPts[1].y := Image3.Height;
arrayPts[1].x := 0;

arrayPts[2].y := Image3.Height;
arrayPts[2].x := Image3.Width;

Rgn1 := CreatePolygonRgn(arrayPts, 3, WINDING);
SetWindowRgn(Panel3.Handle, Rgn1, False);

if you want to make a region shape from a bitmap image then it gets harder. I can post the code for that if you need it.
LVL 12

Expert Comment

ID: 7080134
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

Expert Comment

ID: 7082734

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.


Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question