Registriert seit: 9. Jul 2004
Ort: Aken (Anhalt-Bitterfeld)
1.335 Beiträge
Delphi XE5 Professional
|
Re: NonVCL OpenDialog
1. Mär 2009, 19:41
Zitat von Corpsman:
Delphi-Quellcode:
dialog := gtk_file_chooser_dialog_new ('Open File',
0,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_OPEN, [GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL]);
Das zweite Argument ist
GtkWindow *parent
Dürfte wohl nicht 0 sein.
In dem FileChooser Example (C:\lazarus\fpc\2.2.3\source\packages\gtk2\example s\filechooser\simple.pas) gibt es diese procedure:
Delphi-Quellcode:
* File dialog-callback. *)
procedure dialog_callback (widget : PGtkWidget;
data : gpointer); cdecl;
var
dialog : PGtkWidget;
window : PGtkWindow;
action : gint;
filename : Pgchar;
begin
{ Get a pointer to the main window }
window := g_object_get_data (G_OBJECT(widget), MAIN_WINDOW_KEY);
action := gint (data);
case action of
ACTION_OPEN:
begin
dialog := gtk_file_chooser_dialog_new ('Open File',
window,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_OPEN, [GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL]);
end; { ACTION_OPEN}
ACTION_SAVE:
begin
dialog := gtk_file_chooser_dialog_new ('Save File',
window,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_SAVE, [GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL]);
end; { ACTION_SAVE }
else begin
{ This should never happen }
g_print ('Something is wrong here!!!.'#13#10);
g_print ('No dialog created.'#13#10);
{writeln crashes on my system running linux --- check why }
exit;
end;
end; { case }
if gtk_dialog_run (GTK_DIALOG (dialog)) = GTK_RESPONSE_ACCEPT then
begin
filename := gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
g_print ('Filename %s selected.'#13#10, [filename]);
// writeln ('File ', filename, ' selected.');
// ToDO:
// writeln crashes... check why
g_free (filename);
end;
gtk_widget_destroy (dialog);
end;
Du solltest also
Delphi-Quellcode:
var
window : PGtkWindow;
begin
{ Get a pointer to the main window }
window := g_object_get_data (G_OBJECT(widget), MAIN_WINDOW_KEY);
dialog := gtk_file_chooser_dialog_new ('Open File',
window,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_OPEN, [GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL]);
einfügen
Gruss Garfield
Ubuntu 22.04: Laz2.2.2/FPC3.2.2 - VirtBox6.1+W10: D7PE, DXE5Prof
|
|
Zitat
|