[delphi] - grafisch, welke zijn geregistreerd

Pagina: 1
Acties:

  • MisterE
  • Registratie: April 2002
  • Laatst online: 28-08 19:15
is er een manier om er achter te komen welke bestandsformaten gerigstreerd zijn (die je bv. ziet wanneer je een openpicturedialoog opent)
Ik wil dat namelijk weten voor het drag&drop in mijn app. Dat ie alleen die bestanden toevoegd ipv. alle bestanden die ie nu accepteerd.

  • LordLarry
  • Registratie: Juli 2001
  • Niet online

LordLarry

Aut disce aut discede

Het registreren gaat dmv TPicture.RegisterFileFormat
En de functies
GraphicFilter
GraphicExtension
GraphicFileMask
uit de Graphics unit kunnen die informatie terughalen.
Als je er TGraphic aan meegeeft krijg je alle geregistreerde formaten terug.

We adore chaos because we like to restore order - M.C. Escher


  • Tomatoman
  • Registratie: November 2000
  • Laatst online: 01-09 21:18

Tomatoman

Fulltime prutser

Een voorbeeld bij de functie EnumClipboardFormats in het boek The Tomes of Delphi 3: Win32 Core API van Larry Diehl:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
procedure TForm1.Button1Click(Sender: TObject);
const
  {an array defining all of the predefined clipboard format names}
  PredefinedClipboardNames: array[1..17] of string = ('CF_TEXT', 'CF_BITMAP',
                                    'CF_METAFILEPICT', 'CF_SYLK', 'CF_DIF',
                                    'CF_TIFF', 'CF_OEMTEXT', 'CF_DIB',
                                    'CF_PALETTE', 'CF_PENDATA', 'CF_RIFF',

                                    'CF_WAVE', 'CF_UNICODETEXT',
                                    'CF_ENHMETAFILE', 'CF_HDROP', 'CF_LOCALE',
                                    'CF_MAX');
var
  FormatID: UINT;                     // holds a clipboard format ID
  FormatName: array[0..255] of char;  // holds a clipboard format name
  Len: Integer;                       // the length of a clipboard format name

begin
  {clear out the list box}
  ListBox1.Items.Clear;

  {display the number of formats on the clipboard}
  Label1.Caption := 'Total Formats Available: '+IntToStr(CountClipboardFormats);

  {open the clipboard}
  OpenClipboard(0);

  {retrieve the first available clipboard format}
  FormatID := EnumclipboardFormats(0);

  {retrieve all clipboard formats}
  while (FormatID <> 0 ) do

  begin
    {get the name of the clipboard format. note that this will only
     return a format name if it is a registered format, not one
     of the predefined formats}
    Len := GetClipboardFormatName(FormatID,FormatName,255);

    {if len is equal to zero then it's a predefined format}
    if Len = 0 then
      ListBox1.Items.Add(PredefinedClipboardNames[FormatID]+' (Predefined)'+
                         ' [' + IntToStr(FormatID)+ ']')

    else
      {otherwise it contains a registered format name}
      ListBox1.Items.Add(FormatName+' [' + IntToStr(FormatID)+ ']');

    {retrieve the next available clipboard format}
    FormatID:=EnumclipboardFormats(FormatID);
  end;

  {we are done with the enumeration, so close the clipboard}
  CloseClipboard;
end;

Functies die hiermee samenhangen zijn RegisterClipboardFormat, CountClipboardFormats en GetClipboardFormatName. Deze zijn allemaal gedeclareerd in windows.pas.

Hopelijk wordt dit nog niet als schending van het auteursrecht gezien :X.

Een goede grap mag vrienden kosten.