Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2016, 01:38 PM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 382
Default Resources

I have Res file which have text which I load into Memo at run time . . is possible if add more lines into memo and save back to resources.
Reply With Quote
  #2  
Old 07-02-2016, 08:09 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

I don't think you can save it back.
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #3  
Old 07-02-2016, 08:24 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

However, you can save it to an external file and later load it again.

Code:
Memo1.Lines.SaveToFile('C:\MyFile.txt');

//and later load it again:

Memo1.Lines.LoadFromFile('C:\MyFile.txt');
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #4  
Old 07-02-2016, 08:28 PM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 382
Default

Code:
s:=TResourceStream.Create(hinstance, 'MyText', RT_RCDATA);
memo1.lines.loadfromstream(s);
here MyText is now in Memo1

after modifying memo, is possible to save it so that when next time exe. is launched saved effects will be there in memo i tried this way nothing happens

Code:
var
  stream: TMemoryStream;
begin
  stream := TMemoryStream.Create;
  try
    memo1.Lines.SaveToStream(stream);
    stream.Position := 0;
Reply With Quote
  #5  
Old 07-02-2016, 08:31 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

See my last post. It's so easy. Better/easier than using streams.
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #6  
Old 07-02-2016, 08:33 PM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 382
Default

that is not what i want .. by the way if not possible ..forgetting concept any more
Reply With Quote
  #7  
Old 07-02-2016, 10:02 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

See http://delphi.about.com/od/windowssh...dll_basics.htm
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #8  
Old 07-04-2016, 12:12 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

Even if it's possible, it's not something you want to do!!!

If you want to load and save stuff use the things that are used for such purpose (ini/txt, registry or even a database), but don't try and figure out some other solution that will give you lots of troubles (for example, your application must run as administrator, just for something as basic as saving some memo contents)
Reply With Quote
  #9  
Old 07-05-2016, 02:52 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default

I totally agree with Norrit because a resource is allocated and complied into your *.EXE at compile time and expecting a resource to adjust its size, and you cannot adjust/rewrite a exec file that is opened under windows. So use a *.ini and use a TStringList or TImageList system to manage the data or something.

Last edited by lexd; 07-05-2016 at 02:54 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 01:03 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.