| View previous topic :: View next topic |
| Author |
Message |
Glenreel Guest
|
Posted: Mon Jan 26, 2004 10:11 pm Post subject: VCL and console programs? |
|
|
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
|
Posted: Mon Jan 26, 2004 10:24 pm Post subject: 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.
|
|
| Back to top |
|
 |
Glenreel Guest
|
Posted: Mon Jan 26, 2004 11:07 pm Post subject: 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" <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
|
Posted: Mon Jan 26, 2004 11:28 pm Post subject: Re: VCL and console programs? |
|
|
"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
|
Posted: Tue Jan 27, 2004 5:24 am Post subject: Re: VCL and console programs? |
|
|
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
|
Posted: Tue Jan 27, 2004 8:23 am Post subject: 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!!"<
++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 |
|
 |
|