Solved

URGENT PLEASE - Image over controls in a form

Posted on 2002-06-13
8
143 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:sruel
8 Comments
 
LVL 34

Expert Comment

by:Slick812
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.
0
 
LVL 1

Expert Comment

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

Author Comment

by:sruel
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...
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:Cynna
ID: 7078033
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)
0
 
LVL 34

Expert Comment

by:Slick812
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);
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
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 50 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);
var
  Rgn1: HRGN;
  arrayPts: Array[0..2] of TPoint;
begin
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);
end;

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.
0
 
LVL 12

Expert Comment

by:Lee_Nover
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
0
 
LVL 2

Expert Comment

by:mikepj
ID: 7082734
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
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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