Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 1999-05

dialogs 0.2

9 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sergio A. Kessler

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 LoadFromFile(
fname))');
     OpenFileDialog1 := TOpenFileDialog.Create(Self);
     OpenFileDialog1.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
//
//==================================================================
unit 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 gtk_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 := gtk_file_selection_get_filename( PGtkFileSelection( FComponent)); end; end; Procedure TOpenFileDialog.gtk_create; begin FComponent := gtk_file_selection_new( FTitle); gtk_window_set_modal( @((PGtkFileSelection( FComponent))^.Window), True); gtk_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'); gtk_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. -------------- next part -------------- A non-text attachment was scrubbed... Name: bin00003.bin Type: application/octet-stream Size: 5267 bytes Desc: "Dialogs.pp" Url : http://localhost/pipermail/lazarus/attachments/19990519/4cd35d98/bin00003.bin

Reply by email

Shane Miller

possible break through...please stand by....

Shane

Earlier message 291 lines
-----Original Message----- From: Shane Miller To: 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 >To: Lazarus mailing list >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); >> OpenFileDialog1.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 >> gtk_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 with > "unsubscribe" as the Subject > archives at http://www.miraclec.com/list_archives/lazarus >

Reply by email

Shane Miller

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

Earlier message 254 lines
-----Original Message----- From: Sergio A. Kessler To: Lazarus mailing list 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); > OpenFileDialog1.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 >// >//================================================================== > > >unit 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 > gtk_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_window_set_modal( @((PGtkFileSelection( FComponent))^.Window), >True); > > gtk_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. >

Reply by email

Sergio A. Kessler
to Shane Miller

"Shane Miller" el d�a Wed, 19 May 1999 19:21:40 -0700, escribi�:

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,

from inside or from outside ?
(I'm assuming that you was not trying to access FFileName from outside)

sorry, but I don't like very much your @FFileName+1 ...

anyone know why a PChar( string) doesn't compile ?

Sergio

Reply by email

Sergio A. Kessler
to Shane Miller: I think the problem is because it doesn't have any memory associated with it when it's…

"Shane Miller" el d�a Thu, 20 May 1999 14:56:58 -0500, escribi�:

I think the problem is because it doesn't have any memory associated with

it when it's created. It's nil, and when you assign something to it without allocating memory for it, it dumps. It would work fine if we did the stralloc first, but I didn't want to mess with it. I don't like the @FFileName+1 either Sergio but it's a temporary fix for now. Better than leaving it to crash.

ok, I will try to review this tonigth...
And remember that you MUST comment the lines in controls.pp that is creating a file_selection. The TOpenDialog create itself.

btw, Shane, can you press the Enter key sometimes when you write email :) (believe me that is hard to read a single loooong line)

Sergio

Reply by email

Shane Miller

I think the problem is because it doesn't have any memory associated with it when it's created. It's nil, and when you assign something to it without allocating memory for it, it dumps. It would work fine if we did the stralloc first, but I didn't want to mess with it. I don't like the @FFileName+1 either Sergio but it's a temporary fix for now. Better than leaving it to crash.

Shane

Reply by email

Shane Miller

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

Earlier message 322 lines
-----Original Message----- From: Shane Miller To: 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 >To: >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 >>To: Lazarus mailing list >>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 with >> "unsubscribe" as the Subject >> archives at http://www.miraclec.com/list_archives/lazarus >> > > >_________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.miraclec.com/list_archives/lazarus >

Reply by email

Baeseman, Cliff

Nope it will not autocast it to a pchar for some reason. I had to use stuff like strpcopy and such to get around stuff like that.

Cliff

Earlier message 28 lines
-----Original Message----- From: Sergio A. Kessler Sent: Thursday, May 20, 1999 2:25 PM To: Subject: Re: [lazarus] dialogs 0.2 "Shane Miller" el d�a Wed, 19 May 1999 19:21:40 -0700, escribi�: >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, from inside or from outside ? (I'm assuming that you was not trying to access FFileName from outside) sorry, but I don't like very much your @FFileName+1 ... anyone know why a PChar( string) doesn't compile ? Sergio _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Shane Miller
>> "Sergio A. Kessler" 05/20 3:21 PM >>>

"Shane Miller" el d�a Thu, 20 May 1999 14:56:58 -0500, escribi�:

I think the problem is because it doesn't have any memory associated with

it when it's created. It's nil, and when you assign something to it without allocating memory for it, it dumps. It would work fine if we did the stralloc first, but I didn't want to mess with it. I don't like the @FFileName+1 either Sergio but it's a temporary fix for now. Better than leaving it to crash.

ok, I will try to review this tonigth...
And remember that you MUST comment the lines in controls.pp that is creating a file_selection. The TOpenDialog create itself.

btw, Shane, can you press the Enter key sometimes when you write email :) (believe me that is hard to read a single loooong line)

Sorry, my email program line wraps. :-)

Shane

Reply by email