Board index » cppbuilder » VCL and console programs?

VCL and console programs?


2004-01-27 06:11:27 AM
cppbuilder11
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,
 
 

Re:VCL and console programs?

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.
 

Re:VCL and console programs?

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" < XXXX@XXXXX.COM >wrote in message
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.
 

{smallsort}

Re:VCL and console programs?

"Glenreel" < XXXX@XXXXX.COM >wrote in message
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
 

Re:VCL and console programs?

Thanks, Gambit.
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Glenreel" < XXXX@XXXXX.COM >wrote in message
news:40159098$ XXXX@XXXXX.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 <filecomp.h>

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


Gambit


 

Re:VCL and console programs?

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!!"<<std::endl;
++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: XXXX@XXXXX.COM
C++Builder, C++BuilderX, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------