using an object inside a console application

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?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Not that I know of.
Unless you create a form first of course...
This 'clumsy' code will work though:

var m: TMemo;
  m := TMemo.Create(nil);
  m.ParentWindow := GetDesktopWindow;;

I don' see a reason why you want to do this..?
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

urifAuthor Commented:
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
What about passing the application object?

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.
If I understand corectly a parent has to be a window, no? - but an owner is any TComponent descendant?

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.
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, that won't work. Crashes as soon as you try to add a line:


Strangly enough

  memo.text := 'somettext';

works ok.
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.

urifAuthor Commented:
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?

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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
urifAuthor Commented:
it might be worth a try
i'll let you know tomorrow

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.  Open since September, 2001 with no help provided, want a refund?  Current, new question added  Open, nothing added  Open, nothing added  You said you'd try the advice tomorrow, that was in July, 2001  Open since May, 2001  Locked, awaiting your response since May, 2001  Nothing added since January, 2001 and looks like a refund/deletion makes sense so you can repost if still needed.  Locked since 12/23/2000, you said it worked, but never accepted and graded the proposed answer.  Please do.  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.  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.


EE Moderator

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.