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 

VCL and console programs?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Glenreel
Guest





PostPosted: Mon Jan 26, 2004 10:11 pm    Post subject: VCL and console programs? Reply with quote



This may be a dumb question but can I use non visual components with a
console program?

I have a file component that I'd like to use but I'm not sure how to go
about it. Even though it's non visual it still want's a form to drop it on.

If this is a dumb question please don't be too brutal. :-)Thanks,


Back to top
Hans Galema
Guest





PostPosted: Mon Jan 26, 2004 10:24 pm    Post subject: Re: VCL and console programs? Reply with quote



Glenreel wrote:
Quote:
... can I use non visual components with a
console program?

Yes. Examples have been given to use i.e. TServerSocket/TClientSocket
in a console application.

Quote:
I have a file component

Aha, where did you get it from ? What is a file component ?

Quote:
that I'd like to use but I'm not sure how to go
about it.

Doesn't it come with a helpfile or examples ?

Quote:
Even though it's non visual it still want's a form to drop it on.

Did the help tell that ? Please show.

Hans.

Back to top
Glenreel
Guest





PostPosted: Mon Jan 26, 2004 11:07 pm    Post subject: Re: VCL and console programs? Reply with quote




Thanks for replying.
I haven't looked at TServerSocket/TClientSocket but I will.

I downloaded a VCL component from Torry's called TFileFind. I used the
pascal source file to build the component. You drop the component on a
form, supply the path/file info and the component will search for the file
you specify. It has 2 events, one for filefound and one for directory
change.

I have no problem using the component with a form but I didn't have any idea
how to use it with a console application. I hope this helps explain my
problem.

Thanks,




"Hans Galema" <dontusethis (AT) dontusethis (DOT) nl> wrote

Quote:
Glenreel wrote:
... can I use non visual components with a
console program?

Yes. Examples have been given to use i.e. TServerSocket/TClientSocket
in a console application.

I have a file component

Aha, where did you get it from ? What is a file component ?

that I'd like to use but I'm not sure how to go
about it.

Doesn't it come with a helpfile or examples ?

Even though it's non visual it still want's a form to drop it on.

Did the help tell that ? Please show.

Hans.



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Jan 26, 2004 11:28 pm    Post subject: Re: VCL and console programs? Reply with quote


"Glenreel" <kawade (AT) garverengineers (DOT) com> wrote


Quote:
can I use non visual components with a console program?

Yes.

Quote:
I have a file component that I'd like to use but I'm not sure how
to go about it.

Create an instance of it dynamically at runtime via the 'new' operator. For
example:

#include <filecomp.h>

int main()
{
TFileComponent *comp = new TFileComponent(NULL);
// use comp as needed...
delete comp;
}


Gambit



Back to top
Glenreel
Guest





PostPosted: Tue Jan 27, 2004 5:24 am    Post subject: Re: VCL and console programs? Reply with quote

Thanks, Gambit.

"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote

Quote:

"Glenreel" <kawade (AT) garverengineers (DOT) com> wrote in message
news:40159098$1 (AT) newsgroups (DOT) borland.com...

can I use non visual components with a console program?

Yes.

I have a file component that I'd like to use but I'm not sure how
to go about it.

Create an instance of it dynamically at runtime via the 'new' operator.
For
example:

#include
int main()
{
TFileComponent *comp = new TFileComponent(NULL);
// use comp as needed...
delete comp;
}


Gambit





Back to top
Michel Leunen
Guest





PostPosted: Tue Jan 27, 2004 8:23 am    Post subject: Re: VCL and console programs? Reply with quote

Glenreel wrote:
Quote:
This may be a dumb question but can I use non visual components with a
console program?

Yes, you can. Just create an instance of the component dynamically.
Be aware that some components even non visual need a message loop to
work properly. It's the case with the TTimer component for instance.
Here is a sample code on how to use a TTimer in a console application:

#include <vcl.h>
#include <iostream>
#include <windows.h>

class Event
{
private:
int Count;
public:
void __fastcall TimerEvent(TObject *Sender);
__fastcall Event():Count(0){};
};
void __fastcall Event::TimerEvent(TObject *Sender)
{
if(Count==10)PostMessage(0,WM_QUIT,0,0);
std::cout<<"Timer fired!!"< ++Count;
}

int main()
{
Event event;
TTimer *timer=new TTimer(0);
timer->Interval=1000;
timer->OnTimer=event.TimerEvent;
timer->Enabled=true;

MSG msg;
while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}

Michel
--
----------------------------------------
Michel Leunen
mailto:michel (AT) leunen (DOT) com
C++Builder, C++BuilderX, BCC5.5.1 Web site:
http://www.leunen.com/
----------------------------------------


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) 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.