Solved

using an object inside a console application

Posted on 2001-07-02
16
176 Views
Last Modified: 2013-11-23
Hello there!

here's my problem:

i have a console application, in this app i need to use an object that one of the arguments in the .create is the owner. when you call this object from a normal GUI app you either pass a tlistview or a tmemo as the owners.

if i pass a nill pointer then it will crash and burn with a horrible exception, and if i change the code so it won't requiere this param then it won't work.

is there anyway i can pass an "owner" comming from a console application?

thx!
0
Comment
Question by:urif
  • 7
  • 5
  • 3
  • +1
16 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6245075
> is there anyway i can pass an "owner" comming from a console application

Not that I know of.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6245076
Unless you create a form first of course...
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6245120
This 'clumsy' code will work though:

var m: TMemo;
begin
  m := TMemo.Create(nil);
  m.ParentWindow := GetDesktopWindow;;
  m.Lines.Add('test');
  writeln(m.Text);
  m.Free;
end.


I don' see a reason why you want to do this..?
0
 

Author Comment

by:urif
ID: 6245224
i don't want to do this, but the code i need in inside a vcl component, and rewrite the whole code it's far more difficult
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6245295
?
0
 
LVL 6

Expert Comment

by:edey
ID: 6245496
What about passing the application object?

GL
Mike
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6245525
Mike, that won't work because there's no window.

urif, I don't understand what you are trying to do. Console apps in VCL doesn't make sense to me.
0
 
LVL 6

Expert Comment

by:edey
ID: 6246606
If I understand corectly a parent has to be a window, no? - but an owner is any TComponent descendant?

GL
Mike
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

by:Epsylon
ID: 6246641
Yes, but that TComponent descendant has an owner too. Just try it: In a Console application, create a TListBox with nil as Owner. Then add an item to the listbox. It will crash.
0
 
LVL 6

Expert Comment

by:edey
ID: 6246664
i can't test it just now as I don't have access to a copy of delphi until tomorrow, but I would think you could do this:

 memo1 := TMemo.create(application);

no?

GL
Mike
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6246720
No, that won't work. Crashes as soon as you try to add a line:

  memo.lines.add('sometext');


Strangly enough

  memo.text := 'somettext';

works ok.
0
 
LVL 6

Expert Comment

by:edey
ID: 6246937
I wonder if it a drawing thing, or related to IStrings?.  I would be tempted to guess the former.  Perhaps urif's mystery object isn't bound so - after all he's coding a console app.

GL
Mike
0
 

Author Comment

by:urif
ID: 6247355
well, thank you all, but you are going to the extreme here.

basically this is it:

i have a unit (pascal??? basic unit???) this unit has the code i need. this code on the create funtion has two paramaters, one is a boolean and the other an object where the rest of the code will save tje putput, this object according to the author is the owner.
this code happens to be a vcl component, that's all, no complications. sorry if i mis-explained.

now, i need to be able to use this from a console application.

any way?

thx!
0
 
LVL 6

Accepted Solution

by:
edey earned 50 total points
ID: 6249073
Without seeing it I can only guess - though perhaps you caould pass a TStringList? It's defined in classes, does no drawing & works just fine in a console.  Without knowing just how this unit "will save the output" I'm just guessing.

GL
Mike
0
 

Author Comment

by:urif
ID: 6249820
it might be worth a try
i'll let you know tomorrow

thanks
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6810639
Please update and finalize your old/open questions, or we'll need to take actions to close them.  I will also be advising our Administration liaison to Email you about the Site Guidelines and the need to maintain your open questions here.  The HELP DESK provides details about this.  These are all your open questions today and I will update them with this information now.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20186749  Open since September, 2001 with no help provided, want a refund?

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20268146  Current, new question added

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20254602  Open, nothing added

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20194330  Open, nothing added

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20144552  You said you'd try the advice tomorrow, that was in July, 2001

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20121071  Open since May, 2001

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20118833  Locked, awaiting your response since May, 2001

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20032671  Nothing added since January, 2001 and looks like a refund/deletion makes sense so you can repost if still needed.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20004063  Locked since 12/23/2000, you said it worked, but never accepted and graded the proposed answer.  Please do.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=11798660  November, 2000 still open.  NOTE* All questions this old (year 2000) have the sort order by user ID versus comment date/time order, so special attention is needed to award the first correct answer.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20122753  Experts helped you here May, 2001, still waiting for you to finalize.

Experts--->  Please add comments so I can decide the fair outcome of all, if these old items remain open by the end of this week.  

If you need my help to split points or otherwise special handle these open items, please comment within them and I'll respond as quickly as I can.

Thanks,

EE Moderator

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now