From: "Earl F. Glynn" Newsgroups: borland.public.delphi.documentation Subject: Error in TBitmap.SaveToClipboardFormat Help example since D3 Date: Sat, 5 Jul 2003 02:06:28 -0500 Lines: 156 Organization: efg's Computer Lab Xref: newsgroups.borland.com borland.public.delphi.documentation:1633 In D7 Professional, try this: Help | Delphi Help | Index | TBitmap Select topic: SaveToClipboardFormat | Display The Delphi syntax is correct, but the example is not: procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle; var APalette: HPALETTE); override; Select Delphi example (ignore C++ example and C++ syntax ) Here's the SaveToClipboardFormat example from the help documentation: procedure TForm1.Button1Click(Sender: TObject); var MyFormat : Word; Bitmap : TBitMap; AData,APalette : THandle; begin Bitmap := TBitmap.Create; try Bitmap.LoadFromFile('c:\Program Files\Common Files\Borland Shared\Images\Splash\256color\factory.bmp'); Bitmap.SaveToClipBoardFormat(MyFormat,AData,APalette); ClipBoard.SetAsHandle(MyFormat,AData); finally Bitmap.Free; end; end; Why doesn't this example have the needed "uses" statement? (FWIW, there are other Help examples that don't show which units are needed -- this is quite frustrating.) USES clipbrd; With the needed "uses", this code doesn't compile. The following error is seen: [Error] Unit1.pas(38): Types of actual and formal var parameters must be indentical I'd guess a novice might not know to change AData,APalette : THandle; to AData: THandle; APalette: hPalette; In D6, help you don't need to ignore the C++ example, but the same problem exists. The syntax is correct in help, but the code in the example doesn't compile and must be changed (and the "uses" must be added, too.). D5 has the same problem as D6. In D4 the same problem existed. The relative path seems to be wrong on my D4 installation since files were moved to C:\Program Files\Commons Files\Borland: Bitmap.LoadFromFile('..\Images\Splash\256color\factory.bmp'); Needed to be: Bitmap.LoadFromFile('C:\Program Files\Common Files\Borland Shared\Images\Splash\256Color\factory.bmp'); The D3 online help said this (as does the D7 online help): procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle; var APalette: HPALETTE); override; The D3 Code compiled and executed since back then a THandle and a hPalette must have been equivalent: USES Clipbrd; // Missing in D3 and later Help example procedure TForm1.Button1Click(Sender: TObject); var MyFormat : Word; Bitmap : TBitMap; AData,APalette : THandle; // compiles OK in D3 but not D4, D5, D6, D7 begin try Bitmap := TBitmap.Create; Bitmap.LoadFromFile('C:\Program Files\Borland\Delphi 3\Images\Splash\256color\factory.bmp'); Bitmap.SaveToClipBoardFormat(MyFormat,AData,APalette); ClipBoard.SetAsHandle(MyFormat,AData); finally Bitmap.Free; end; end; In the D3 help, the "TRY" above should have been after the TBitmap.Create, instead of before - and even gave a warning in D3. The fix now required in D7 (and D4/D5/D6) and which would have worked in D3: APalette: hPalette; This problem didn't exist in D2 since D2's TBitmap didn't support a SaveToClipBoardFormat method. So maybe this can somehow get fixed in the D8 help? -- Sure wish there was an online version of help that was updated the day after such a problem was discovered. -- efg -- Earl F. Glynn, Overland Park, KS USA efg's Computer Lab: http://www.efg2.com/Lab Mirror: http://homepages.borland.com/efg2lab/Default.htm