Read value out of form's DFM at runtime?


Is there a supported way to read a value out of a form's DFM at runtime

The property i'm after is put a published property, but only exists because
it was added as a "fake" property using:

procedure TCustomForm.DefineProperties(Filer: TFiler);
begin
...
Filer.DefineProperty('TextHeight', ReadTextHeight, WriteTextHeight, not
IsControl);
...
end;

Now i can't use
TStream.ReadComponent
TStream.ReadComponentRes
or the
ReadComponentResEx
procedure because these return a component, and the property is not
available as a property.

Which is why i think there must be a way get at the value of a component's
"fake" properties by talking to the component. Something like:

TextHeight := Form1.GetDFMProperty('TextHeight');
or
Caption := Form1.GetDFMProperty('Caption');


In reality i know there is a zero percent chance of a method like that
existing. So then i could get the form's DFM text resource out of my
executable directly and either parse it myself, or create a TReader and copy
all the guts that loads a form component - but it's not a *correct* way to
do things. There would be a case where there's a form that does something i
don't expect. (like being the form dfm resource being in binary rather than
text).


So, is there a *nice* way to read a value out of a form's DFM at runtime

Posted On: Tuesday 16th of October 2012 03:39:09 AM Total Views:  176
View Complete with Replies

RELATED TOPICS OF Delphi Programming PROGRAMMING LANGUAGE




Codegear should really read this

Well, Delphi should/could fulfil a few wishes here - the question is - will the influencers step up to the challenge: http://tech.slashdot.org/article.pl.../05/05/2335252 Why do they not read Slashdot A readership of supposedly 30+ million ... Again, a total disregard for marketing - and yes, before anybody says anything, we can all help. Besters Jon
VIEWS ON THIS POST

62

Posted on:

Wednesday 3rd October 2012
View Replies!

functions in multithread applications

I wondered if using functions at the same time from threads can cause errors. I'm asking this question because sometimes i got "Invalid floating point operation" from MilliSecondsBetween function. Do i need to use synchronization for calling this function what happens if two threads enter a function at the same time As my second question is GetMem function in Delphi ThreadSafe
VIEWS ON THIS POST

140

Posted on:

Wednesday 3rd October 2012
View Replies!

replacement for TTimer that uses thread

, I am only looking for a good ttimer component that uses thread and if possible free.
VIEWS ON THIS POST

211

Posted on:

Wednesday 3rd October 2012
View Replies!

Thread management in non-windowed class

I want to create a thread in a non-windowed class and pass messages back to the class instance at various points in the thread's execution. I know how to do this in a windowed class, and it seems to me that all I should really have to do is create (somehow) a genuine fake window handle. Is that what I want to do If so, how If not, how do I pass messages back to my non-windowed class John
VIEWS ON THIS POST

93

Posted on:

Friday 5th October 2012
View Replies!

Is the code within Thread Safe ?

Ladies / Gentlemen Could someone or several someones please take a look at the following code and tell me if this is thread safe and if not why not and how to correct it.
VIEWS ON THIS POST

218

Posted on:

Friday 5th October 2012
View Replies!

Threads

I have two components. A and B. A uses ttimer and is inside B. If I want put B in thread, I must replace ttimer with threaded timer, and thats OK. TA=class OnTimerEvent:TNotifyEvent; end; TB=class (tthread) private A:TA; public procedure Donotify(sender:tobject); InformMainThread:TnotifyEvent; end; Component A timer event should call B.Donotify, and inside B.Donotify InformMainThread should fire in main thread. How to solve this Using synchronization, criticalsections
VIEWS ON THIS POST

47

Posted on:

Friday 5th October 2012
View Replies!

Proper Thread termination

If a thread is running while the user is trying to close the application how do I terminate the thread properly I do the following but i get the "Thread Error: Handle is invalid(6)". procedure EnsureFree; begin if (AnimationThread nil) then begin AnimationThread.Terminate; AnimationThread.WaitFor; AnimationThread := nil; end; { ... } end; EnsureFree is called when the app is closing. AnimationThread is a unit variable set to nil via Thread's OnTerminate event. If i don't use the WaitFor method the Memory manager reports that the thread has leaked.
VIEWS ON THIS POST

36

Posted on:

Friday 5th October 2012
View Replies!

How to know is code is thread safe

I use code below in Threads to execute program and wait till it finish job. I am not sure is this code is thread safe, it use many calls to system and sometimes it gives "Out of memory" error on sleep(1000), throught this code works without problems in "normal" app. function ShellExecAndWait(App, Params: string; Visibility: Integer; var ResultingExitCode: DWord): Boolean; var Msg: TMsg; E: TShellExecuteInfo; begin try FillChar(E, SizeOf(E), 0); {Superfulous, but what the heck!} E.cbSize := sizeof(E); E.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_NO_UI; E.wnd := 0; {Still not sure about leaving this at zero} E.lpVerb := nil; {Defaults to 'open'} E.lpFile := PChar(App); {Application or document to open} E.lpParameters := PChar(Params); {Optional Command line parameter to pass} E.lpDirectory := nil; {Defaults to current directory} E.nShow := Visibility; {E.g. SW_SHOW or SW_HIDE} if ShellExecuteEx(@E) then begin repeat while PeekMessage(Msg, 0, 0, 0, pm_Remove) do begin if Msg.Message = wm_Quit then Halt(Msg.WParam); TranslateMessage(Msg); DispatchMessage(Msg); end; sleep(1000); until (WaitForSingleObject(E.hProcess, 50) WAIT_TIMEOUT); GetExitCodeProcess(E.hProcess, ResultingExitCode); Result := True; {ShellExecuteEx succeeded} end else begin ResultingExitCode := 1; {Just so that it is not left undefined} Result := False; {ShellExecuteEx failed} TerminateProcess(E.hProcess, 0); end; finally CloseHandle(E.hProcess); {Prevent leakage} end; end;
VIEWS ON THIS POST

90

Posted on:

Saturday 6th October 2012
View Replies!

Not sure is function accessed as thread safe

I have TThread class, using it I create threads in app. I also has one function(let's say MyMath) in separated unit where I hold all blogal functions. Is it safe to access such function from thread Should I place this function directlly in Thread class function MyMath(a,b:integer):Integer; begin result:=a+b; end;
VIEWS ON THIS POST

97

Posted on:

Saturday 6th October 2012
View Replies!

Re: Reading Main Form's CheckBox Value in a Thread?

Remy Lebeau (TeamB) wrote: > > "Edward" wrote in message > news:46dd4bd1$1@newsgroups.borland.com... > > > Is it safe for a thread to read a checkbox on main form > > without using synchronize > > No. Unless TTCheckBox.GetCheck just accesses the boolean, instead of calling SenMessage, in which case you're OK. MH. --
VIEWS ON THIS POST

38

Posted on:

Saturday 6th October 2012
View Replies!

how do i tell if a form is already loaded?

Hi , How can I check if a form is already loaded at runtime am using delphi 2007 win32 and my application is SDI Secondly, how can i iterate through all loaded forms (not displayed forms)
VIEWS ON THIS POST

152

Posted on:

Monday 8th October 2012
View Replies!

Invisible read / write property

I want to add a .AsText property to a component (a stringlist holder) so I can do things like string := cpt.AsText and cpt.AsText := string BUT I don't want it showing up in the property editor. Is this possible Roy Lambert
VIEWS ON THIS POST

126

Posted on:

Monday 8th October 2012
View Replies!

Thread sinc and variables

Started to learing about threads and have two questions 1. If I create non-visual component in Thread, then I don't need to sincronize it, right 2. Is it safe to access global variable from Thread example is below var MyVariable:String; //Blogal variable implementation procedure TfrmMain.ButonClick...; begin MyVariable : = Edit.Text; TProcessFilesThread.Create; Close; //Close form, do not wait for thread termination end; procedure TProcessFilesThread.Execute; begin Sleep(10000); MyVariable...//Accesing blogal variable here, second form instance can be executed meantime and new value for MyVariable can be assigned. Is MyVariable variable will be changed in thread also end;
VIEWS ON THIS POST

74

Posted on:

Tuesday 9th October 2012
View Replies!

Help needed with threads

Goal: I've got some code (TProcessor.Process) that takes a while to run, and I want a modal form with a progress bar (ProgressForm) to show the progress of this task. My basic design is to run this method in a thread, i.e.: A thread class (TProcessThread) takes a reference to this object, and in it's Execute method simply calls the long taking method (TProcessor.Process). TProcessor.Process interacts with a TGlobalData class and mainly calls it's Step method. GlobalData fires an event when it's data changes. This event is handled by the TProcessThread and calls a method (via Synchronize) that updates the ProgressBar on the ProgressForm. The whole thing is started by ProgressForm.RunTask which: Creates the thread (TProcessThread) and then calls ShowModal. The thread's OnTerminate event includes code to close the form. This works fine in simple cases, but in my application that includes more complex processing in the "process" method, it sometimes hangs. I have posted a sample application in attachments, which works fine, but I'm hoping that someone with more experience can spot the weakness of this scheme, that results in problems in more complex cases. If I step through the code (and therefore the form in not shown) the problem (mostly) doesn't occur. But if I run normally then it does.
VIEWS ON THIS POST

182

Posted on:

Tuesday 9th October 2012
View Replies!

inherited readonly ?

I am desesperatly seeking a way to quickly publish ancestor properties and make them readonly at will in some child classes... That is : class A protected getvalue setvalue public //
VIEWS ON THIS POST

55

Posted on:

Wednesday 10th October 2012
View Replies!

calling readln causes memoryleak in D5?

Would it be possible that many many calls to readln(myFILE, myString) would cause a memory leak The file is closed other objects are closed, still I loose memory in a function. I have found this on D2 that could be it, testing some things now. http://groups.google.nl/group/comp.l...e87a8c1b5629c1 > But that's in D2, I presume that would be fixed in D5. Anyone an idea
VIEWS ON THIS POST

160

Posted on:

Tuesday 16th October 2012
View Replies!

OT: How read data from a Sartorious BP34000P

I need to read the weigth from a Sartorious BP34000P. Is getting data from the serial port... and I'm complete lost about how do this. The manual say use the ISO/GLP standar. Then talk about paritis and bit. I don't know what to llok so I can learn how do this task. I go to the manfacter website and not found examples of this. -- Usando el revolucionario cliente de correo de Opera: http://www.opera.com/mail/
VIEWS ON THIS POST

64

Posted on:

Tuesday 16th October 2012
View Replies!

Is the code within Thread Safe ?

Ladies / Gentlemen Could someone or several someones please take a look at the following code and tell me if this is thread safe and if not why not and how to correct it.
VIEWS ON THIS POST

200

Posted on:

Tuesday 16th October 2012
View Replies!

THreads, dlls, and UDP

Hej, I have a service appication that starts three threads. These threads all call a DLL to send a message using UDP. The dll uses the UDPClient component (I think its called that). Somewhere in all this I find that the call to send the message via UDP causes an exception. This dll has been used many times over a long period of time, but never from a thread, and never more than once per machine. So I wonder if my dll needs to be "thread safe" and what does this mean Or could it be that the calls to the UDPClient are occuring symultaneously and therefore causing the problem Any advice would be welcome. /Richard
VIEWS ON THIS POST

419

Posted on:

Tuesday 16th October 2012
View Replies!

C fread equivalent in delphi.

I am translating some c code and it is using fread to parse a file..Is there an equivalent routine in delphi .
VIEWS ON THIS POST

292

Posted on:

Tuesday 16th October 2012
View Replies!