[lazarus] dialogs 0.2

Shane Miller smiller at lakefield.net
Wed May 19 21:07:36 EDT 1999


YIPPPPPEEEE!!!!!!   I got FILE - OPEN to work.....and FILE SAVE!!!!!

YAHOO!!!!!.......I noticed that some of my code was incorrect when I was
looking at TEditor and changing it to use the new dialogs.pp file.  I fixed
it (simple error) and I then realized how to get the save to work.....

I have updated CVS.  I'm not sure if it will work on the latest FPC make or
not.  I have been having trouble with them lately.

Try pulling it and compiling and let me know.

Shane

-----Original Message-----
From: Shane Miller <smiller at lakefield.net>
To: lazarus at miraclec.com <lazarus at miraclec.com>
Date: Wednesday, May 19, 1999 5:41 PM
Subject: Re: [lazarus] dialogs 0.2


>possible break through...please stand by....
>
>Shane
>
>-----Original Message-----
>From: Shane Miller <smiller at lakefield.net>
>To: lazarus at miraclec.com <lazarus at miraclec.com>
>Date: Wednesday, May 19, 1999 5:29 PM
>Subject: Re: [lazarus] dialogs 0.2
>
>
>>Sergio, I like what you did with the dialgs.pp file.  but...I had to
change
>>it a bit.  If I tried to run it the way you said it would crash when it
>>looked at FFilename, possibly because the pchar wasn't already created and
>>had no memory associated with it, so I made it a string, adjusted the
>>set_file_selection and set_file_selection procedures and it worked
>>wonderfully....better than my solution.  I will send the forms.pp and
>>editor.pp to cliff to include into the CVS if I can't get it to update
from
>>here...
>>
>>
>>Shane
>>
>>-----Original Message-----
>>From: Sergio A. Kessler <sak at perio.unlp.edu.ar>
>>To: Lazarus mailing list <lazarus at miraclec.com>
>>Date: Wednesday, May 19, 1999 3:32 PM
>>Subject: [lazarus] dialogs 0.2
>>
>>
>>>
>>>Oh, man, this is working really nice, even if the stupid user
>>>close the window.
>>>
>>>test with:
>>>
>>>Procedure TEditor.LoadFile;
>>>begin
>>>     Writeln('--> Enterring TEditor.Loadfile (should be
>>dFromFile( 
>>>fname))');
>>>     OpenFileDialog1 := TOpenFileDialog.Create(Self);
>>>     OpenFil
eDialog1.Title := 'Select a file';
>>>     OpenFileDialog1.Filter := '*.pp';
>>>     if OpenFileDialog1.Execute then
>>>     begin
>>>          Writeln('--> in OpenFileDialog1.Execute');
>>>     end;
>>>     Writeln('--> out of OpenFileDialog1.Execute');
>>>     OpenFileDialog1.Free;
>>>End;
>>>
>>>
>>>
>>>attached (really this time) and pasted here:
>>>
>>>//==================================================================
>>>//
>>>//     Dialogs Unit
>>>//
>>>//     Contains : TOpenFileDialog
>>>//
>>>//
>>>//     Authors: Sergio A. Kessler, ...
>>>//
>>>//
>>>//     Licensee: in consideration.
>>>//
>>>//     Version: 0.2
>>>//
>>>//==================================================================
>>>
>>>
>>>uni
>t dialogs;
>>>
>>>{$mode objfpc}
>>>
>>>interface
>>>
>>>uses
>>>    gtk, classes, Controls, vclGlobals;
>>>
>>>
>>>type
>>> TCustomDialog = class(TWinControl)
>>> private
>>> FUserChoice: integer;
>>> FFileName : PChar;
>>> FTitle: PChar;
>>> FFilter: PChar;
>>>         function gtk_Ok( widget: PGtkWidget) : Boolean; cdecl;
>>> function gtk
>>_Cancel( widget: PGtkWidget) : Boolean; cdecl;
>>> function gtk_Close( widget: PGtkWidget) : Boolean; cdecl;
>>> protected
>>> public
>>> constructor Create(AOwner : TComponent); override;
>>> destructor destroy; override;
>>> property FileName : PChar read FFileName write FFileName;
>>> property Title : PChar read FTitle write FTitle;
>>> property Filter : PChar read FFilter write FFilter;
>>> end;
>>>
>>> TOpenFileDialog  = class(TCustomDialog)
>>> private
>>> procedure gtk_create;
>>> procedure gtk_destroy;
>>> public
>>> constructor Create (AOwner : TComponent); override;
>>> destructor destroy; override;
>>>
>>> Function Execute : boolean;
>>> end;
>>>
>>>
>>>Implementation
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>function TCustomDialog.gtk_Ok( widget: PGtkWidget) : Boolean; cdecl;
>>>begin
>>>     writeln('--> in gtk_ok');
>>>     FUserChoice := 1;
>>>end;
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>function TCustomDialog.gtk_Cancel( widget: PGtkWidget) : Boolean; cdecl;
>>>begin
>>>     writeln('--> in gtk_cancel');
>>>     FUserChoice := 2;
>>>end;
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>function TCustomDialog.gtk_Close( widget: PGtkWidget) : Boolean; cdecl;
>>>begin
>>>     writeln('--> in gtk_close');
>>>     FUserChoice := 3;
>>>end;
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>constructor TCustomDialog.Create (AOwner : TComponent);
>>>begin
>>>     // the TCustomDialog should not create the file_selection
>>>     inherited Create(AOwner);
>>>End;
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>destructor TCustomDialog.destroy;
>>>begin
>>>     inherited Destroy;
>>>End;
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>
>>>constructor TOpenFileDialog.Create (AOwner : TComponent);
>>>begin
>>>     inherited Create(AOwner);
>>>     gtk_create;
>>>end;
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>destructor TOpenFileDialog.destroy;
>>>begin
>>>     gtk_destroy;
>>>     inherited Destroy;
>>>end;
>>>
>>>//-----------------------------------------------------------------------
-
>-
>>-
>>>--
>>>
>>>Function TOpenFileDialog.Execute : boolean;
>>>begin
>>>     if not (GTK_IS_FILE_SELECTION( FComponent)) then gtk_create;
>>>
>>>     if FTitle <> '' then
>>>     begin
>>>
k_window_set_title( @((PGtkFileSelection( FComponent))^.Window),
>>>                              FTitle);
>>>     end;
>>>
>>>     if FFileName <> '' then
>>>     begin
>>>        gtk_file_selection_set_filename( PGtkFileSelection( FComponent),
>>>                                         FFileName);
>>>     end;
>>>
>>>     if FFilter <> '' then
>>>     begin
>>>        gtk_file_selection_complete( PGtkFileSelection( FComponent),
>>>                                     FFilter);
>>>     end;
>>>
>>>     FUserChoice := 0;
>>>     writeln('--> about to file_sel_show');
>>>     gtk_widget_show( FComponent);
>>>     repeat
>>>          gtk_main_iteration;
>>>     until FUserChoice <> 0;
>>>
>>>     writeln('--> about to file_sel_hide');
>>>     if (FUserChoice <> 3) then gtk_widget_hide( FComponent);
>>>
>>>     Execute := (FUserChoice = 1);
>>>     if Execute then
>>>     begin
>>>          FFileName :=
>>file_selection_get_filename( PGtkFileSelection( 
>>>FComponent));
>>>     end;
>>>end;
>>>
>>>
>>>Procedure TOpenFileDialog.gtk_create;
>>>begin
>>>     FComponent := gtk_file_selection_new( FTitle);
>>>     
>>>     gtk_windo
>w_set_modal( @((PGtkFileSelection( FComponent))^.Window),
>>>True);
>>>
>>>
>signal_connect_object( gtk_object( 
>>>(PGtkFileSelection(FComponent))^.ok_button),
>>>                                'clicked',
>>>                                gtk_signal_func( @gtk_ok),
>>>                                gtk_object( self));
>>>                                       
>>>     gtk_signal_connect_object( gtk_object( 
>>>(PGtkFileSelection(FComponent))^.cancel_button),
>>>                           
>>     'clicked',
>>>                                gtk_signal_func( @gtk_cancel),
>>>                                gtk_object( self));
>>>
>>>     gtk_signal_connect_object( gtk_object( FComponent),
>>>                                'destroy',
>>>                                gtk_signal_func( @gtk_close),
>>>                                gtk_object( self));
>>>end;
>>>
>>>
>>>Procedure TOpenFileDialog.gtk_destroy;
>>>begin
>>>     if (GTK_IS_FILE_SELECTION( FComponent)) then
>>>     begin
>>>         writeln('--> destroying file_selection');
>>>
>>signal
_handlers_destroy( gtk_object( 
>>>(PGtkFileSelection(FComponent))^.ok_button));
>>>         gtk_signal_handlers_destroy( gtk_object( 
>>>(PGtkFileSelection(FComponent))^.cancel_button));
>>>         gtk_signal_handlers_destroy( gtk_object( FComponent));
>>>         gtk_widget_destroy( PGtkWidget( FComponent));
>>>     end;
>>>end;
>>>
>>>end.
>>>
>>
>>
>>_________________________________________________________________
>>     To unsubscribe: mail lazarus-request at miraclec.com with
>>                "unsubscribe" as the Subject
>>    archives at http://www.miraclec.com/list_archives/lazarus
>>
>
>
>_________________________________________________________________
>     To unsubscribe: mail lazarus-request at miraclec.com with
>                "unsubscribe" as the Subject
>    archives at http://www.miraclec.com/list_archives/lazarus
>







More information about the Lazarus mailing list