Solved

How to assign a bitmap to the TDBImage?

Posted on 2002-03-19
7
206 Views
Last Modified: 2010-04-05
Hi all,
How to assign a bitmap to the TDBImage?
Now I use the following code, But I don't want to use the Clipboard, How to change it?

Thanks, Bin

--------------------->
  if OpenPictureDialog.Execute then
  begin
    with ImagePhoto do  //ImagePhoto is TDBImage
    begin
      Picture.LoadFromFile(OpenPictureDialog.FileName);
      CopyToClipboard;
      PasteFromClipboard;
    end;
  end;
---------------------<
0
Comment
Question by:xbbin
  • 4
  • 3
7 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 30 total points
ID: 6879507
if OpenPictureDialog.Execute then
begin
  TBlobField(Dataset.FieldByName('Photo')).LoadfromFile(OpenPictureDialog.filename);
end;

meikl ;-)

   
0
 

Author Comment

by:xbbin
ID: 6880016
Hi meikl,
Can you help me more? I will award you more points.

How to show the Image(TDBImage field) by some conditions?
Now I have to drop a TDBImage on the form, and drop a TImage on the TDBImage. The code as following, I don't like this way.

procedure DataSetAfterScroll(DataSet: TDataSet);
begin
  if DataSetEventMessage.AsString <> 'Normal' then
  begin
    EmpNoEdit.Text := '';
    EmpNameEdit.Text := '';
    Bitmap := TBitmap.Create;
    try
      with EmpPicture do  //EmpPicture  is TImage
      begin
        Bitmap.Width := Width;
        Bitmap.Height := Height;
        Picture.Bitmap := Bitmap;
      end;              //Clear the Image
    finally
      Bitmap.Free;
    end;
    end
    else
    begin
      EmpNoEdit.Text := DataSetEmpNo.AsString;
      EmpNameEdit.Text := DataSetEmpName.AsString;
      EmpPicture.Picture := DataSetEmpDBPhotoImage.Picture; //EmpPicture  is TImage
    end;
end;
0
 

Author Comment

by:xbbin
ID: 6881463
Hi meikl?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6888604
sorry, did not get any notification :-(
was just about reviewing my paq

can you explain a bit more, what you want to do?
which conditions?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6888623
about the timage to clear

EmpPicture.Picture.Assign(Nil);
(thats just from head yet)

this should replace this code
----
try
     with EmpPicture do  //EmpPicture  is TImage
     begin
       Bitmap.Width := Width;
       Bitmap.Height := Height;
       Picture.Bitmap := Bitmap;
     end;              //Clear the Image
   finally
     Bitmap.Free;
   end;
----

meikl ;-)
0
 

Author Comment

by:xbbin
ID: 6888685
Hi meikl,
I had already sloved this, I used "DataSetEmpDBPhotoImage.Clear".    

Thanks, bin
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6889121
well
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now