BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Please help a newbie...

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
dave
Guest





PostPosted: Thu Oct 23, 2003 4:05 pm    Post subject: Please help a newbie... Reply with quote



I am writing a component. One of the properties is SaveFileName. I declared
it as a TFilename. But in the object inspector i cannot get it to display
the open file dialog to select the file. My code is as follows:

unit HL7Converter;
{$R HL7CONVERTER.dcr}
interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
THL7Converter = class(TComponent)
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;

private
FSegmentID : String;
FFieldNumbers : TStringList;
FHL7Filename : string;
FSaveFileName : TFileName;
FOutputType : string;
FOutputDelim : string;
FUseHL7 : boolean;
FAllSegments : boolean;

procedure SetSegmentID(Value: string);
procedure SetSaveFileName(Value : TFileName);
Procedure SetHL7Filename(value : string);
procedure SetOutputType(Value : string);
procedure SetOutputDelim(Value : string);
procedure SetUseHL7(Value : Boolean);
procedure SetAllSegments(Value : Boolean);
procedure SetFieldNumbers(Value : TStringList);
protected
{ Protected declarations }
public
{ Public declarations }
published
property SegmentID : string read FSegmentID write SetSegmentID;
property SaveFileName : TFileName read FSaveFileName write
SetSaveFileName;
property HL7Filename : string read FHL7Filename write SetHL7Filename;
property OutputType : string read FOutputType write SetOutputType;
property OutputDelimiter : string read FOutputDelim write
SetOutputDelim;
property UseHL7Format : Boolean read FUseHL7 write SetUseHL7 default
False;
property AllSegments : Boolean read FAllSegments write SetAllSegments
default false;
property FieldNumbers : TStringList read FFieldNumbers write
SetFieldNumbers;
end;

procedure Register;

implementation

procedure Register;
begin

RegisterComponents('DLB Components', [THL7Converter]);

end;

{ THL7Converter }

constructor THL7Converter.Create(AOwner: TComponent);
begin
inherited;
FFieldNumbers := TStringList.Create;
end;

destructor THL7Converter.Destroy;
begin
inherited;
FFieldNumbers.Destroy;
end;



procedure THL7Converter.SetAllSegments(Value: Boolean);
begin
FAllSegments := Value;
end;

procedure THL7Converter.SetFieldNumbers(Value: TStringList);
begin
if Value <> nil then begin
FFieldNumbers.Assign(Value);
end;
end;

procedure THL7Converter.SetHL7Filename(value: string);
var
MyOpenDLG :TOpenDialog;
begin
MyOpenDLG := TOpenDialog.Create(self);
MyOpenDLG.Filter := 'HL7 Files (*.hl7)|*.hl7';
if MyOpenDLG.Execute then begin
value := MyOpenDLG.FileName;
FHL7Filename := value;
end;
end;

procedure THL7Converter.SetOutputDelim(Value: string);
begin
FOutputDelim := Value;
end;

procedure THL7Converter.SetOutputType(Value: string);
begin
FOutputType := Value;
end;

procedure THL7Converter.SetSaveFileName(Value: TFileName);

begin

FSaveFileName := value;

end;

procedure THL7Converter.SetSegmentID(Value: string);
begin
FSegmentID := Value;
end;

procedure THL7Converter.SetUseHL7(Value: Boolean);
begin
FUseHL7 := Value;
end;

end.



What am i missing?

Thanks in advance,
Dave


Back to top
Ignacio Vazquez
Guest





PostPosted: Thu Oct 23, 2003 5:17 pm    Post subject: Re: Please help a newbie... Reply with quote



"dave" <dbracken (AT) infonowsolutions (DOT) com> wrote in message
[email]3f97fc39 (AT) newsgroups (DOT) borland.com[/email]...
Quote:
What am i missing?

Probably a property editor that allows you to do so. I believe that JVCL has one:

http://jvcl.sourceforge.net/

Cheers,
Ignacio

--
The strange part isn't so much that he had an accent. No accent was
detectable. It was just sounds and burbs and gurgles coming from him. He
was a like a chubby, old R2-D2.
- La Üter



Back to top
dave
Guest





PostPosted: Thu Oct 23, 2003 5:34 pm    Post subject: Re: Please help a newbie... Reply with quote



Ok. I originally had it declared as a string, and just called an opendialog
in my setsavefilename procedure. But this method would show the multi-line
caption / text editor. Is there a way to just suppress that? So that
clicking the property in the object inspector opens just the open dialog?

If not, how do i add the property editor to my component? (sorry, have never
done this before)

Thanks again,
Dave

"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote

Quote:
"dave" <dbracken (AT) infonowsolutions (DOT) com> wrote in message
[email]3f97fc39 (AT) newsgroups (DOT) borland.com[/email]...
What am i missing?

Probably a property editor that allows you to do so. I believe that JVCL
has one:

http://jvcl.sourceforge.net/

Cheers,
Ignacio

--
The strange part isn't so much that he had an accent. No accent was
detectable. It was just sounds and burbs and gurgles coming from him. He
was a like a chubby, old R2-D2.
- La Üter





Back to top
Ignacio Vazquez
Guest





PostPosted: Thu Oct 23, 2003 6:00 pm    Post subject: Re: Please help a newbie... Reply with quote

"dave" <dbracken (AT) infonowsolutions (DOT) com> wrote in message
[email]3f981120 (AT) newsgroups (DOT) borland.com[/email]...
Quote:
Ok. I originally had it declared as a string, and just called an
opendialog in my setsavefilename procedure. But this method would show the
multi-line caption / text editor. Is there a way to just suppress that? So
that clicking the property in the object inspector opens just the open
dialog?

You don't want to do this, because the dialog box will open even if you
assign a value to the property.

Quote:
If not, how do i add the property editor to my component? (sorry, have
never done this before)

Well, I just dug through the JVCL, and it seems that I might be wrong about
it registering a generic property editor. But no matter. To add a property
editor you need to create a separate design-time package that registers the
property editor with the type. If you don't mind a bit of reliance on the
JVCL, the following code should do it:

unit Whatever;

interface

procedure Register;

implementation

uses
JvDsgnEditors;

procedure Register;
begin
RegisterPropertyEditor(TypeInfo(string), THL7Converter, 'SaveFileName',
TJvFilenameProperty);
end;

end.

The rest of the info about creating a package can be found look up
"packages, creating". Make sure you indicate that you want the package to be
design-time only. Then once you've built the package, install it. Oh, and
also add JvCoreDxD to the package's requires clause.

Cheers,
Ignacio

--
The strange part isn't so much that he had an accent. No accent was
detectable. It was just sounds and burbs and gurgles coming from him. He
was a like a chubby, old R2-D2.
- La Üter



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.