|
Good morning, fellow homo sapiens sapiens and other species
I am a novice c++ programmer who mainly does it for fun.
I am currently working on a small program which displays messages after a certain amount of time
and for a certain amount of time. It's purpose is primarily helping me study and maybe it might
one day function as an alert-messenger.
I basically does this: the user selects the messages that need to be displayed and sets the timer and
the delay between messages. Then the program randomly selects a message and displays that message
for the pre-defined amount of time after which it makes the message disappear and waits for a second
pre-defined amount of time to display the second message.
The problem is that I want it displayed not in the window with the DOS prompt executing my file, but
on the screen. Like those subliminal messaging programs do. How can i now make the string (message) appear on the screen (how do I output it to the screen, not the DOS prompt)? And how do I make it disappear after
the pre-defined amount of time?
One last thing is this question: can I determine the coordinates of this string with gotoxy(x,y)?
If not, how do I do this then?
A well-meaned thanks in advance,
Peter
P.S. My compiler is the Borland C++ 5.5 compiler, in case it's vital to know this. The .exe files are executed in a DOS prompt.
A program is to be written primarily for humans to read, and only secondarily for computers to be able to execute.
|
|
|
|
|
Hi guys, i've an execution error when i use a dll from VB in c++. I've debugged the code and i've seen that the problem is when a callback function is returning...the point is that this callback function only drop down when is called from one of the dll's functions, but is working succesfully with the rest of them.
The functions of de dll are defined like this:
typedef void __stdcall (*funcion_crear)(char*,int,char*);
typedef void __stdcall (*funcion_configurar)(int,int,int,int,int);
typedef void __stdcall (*funcion_cargar)(char*);
typedef void __stdcall (*funcion_guardar)(char*);
typedef int __stdcall (*funcion_entrenar)(char*,char*);
typedef void __stdcall (*funcion_evaluar)(char*);
typedef void __stdcall (*CallVBFunctionStringPtr)(int);
typedef void __stdcall (*CallVBFunctionReportPerformancePtr)(int);
typedef void __stdcall (*CallVBFunctionClassificationResultPtr)(int);
funcion_crear fcrear;
funcion_configurar fconfig;
funcion_entrenar fentrenar;
funcion_evaluar fevaluar;
funcion_guardar fguardar;
funcion_cargar fcargar;
CallVBFunctionStringPtr callstring;
CallVBFunctionReportPerformancePtr callperformance;
CallVBFunctionClassificationResultPtr callresult;
Then, the external callback functions (CallVBxxx) are implemented with this three functions:
void __stdcall fCString (char* cadena,int longitud)
{
}
void __stdcall fCReportPerformance (char* cadenaestado,int longitud,int estado)
{
}
void __stdcall fCResult (int indice_clase)
{
Form1->resultado_RNA=indice_clase;
}
and the funcions are loaded from the main form like this:
fconfig=(funcion_configurar)(GetProcAddress(libreria,"ConfigureParameters"));
fcrear=(funcion_crear)(GetProcAddress(libreria,"create_net"));
fentrenar=(funcion_entrenar)(GetProcAddress(libreria,"train_net"));
fevaluar=(funcion_evaluar)(GetProcAddress(libreria,"test_net_singlevector"));
fguardar=(funcion_guardar)(GetProcAddress(libreria,"save_net"));
fcargar=(funcion_cargar)(GetProcAddress(libreria,"load_net"));
callstring=(CallVBFunctionStringPtr)(GetProcAddress(libreria,"CallVBFunctionStringPtr"));
callperformance=(CallVBFunctionReportPerformancePtr)(GetProcAddress(libreria,"CallVBFunctionReportPerformancePtr"));
callresult=(CallVBFunctionClassificationResultPtr)(GetProcAddress(libreria,"CallVBFunctionClassificationResultPtr"));
if ((callstring==NULL) || (callperformance==NULL) || (callresult==NULL)) ShowMessage("cagada");
callstring(int(&(fCString)));
callperformance(int(&(fCReportPerformance)));
callresult(int(&(fCResult)));
The only function that is dropping down is fevaluar, and the problem is when fCString callfuction is returning...
Can Somebody help me????
thank you very much
Best Regards.
|
|
|
|
|
hi all,
To strip off circular dependency between a C# proj and a C++ proj, I need to define an interface in C++ proj. and implement it with C#. The code is like this:
//in C++ proj.
using namespace A
__gc __interface IA
{
void display();
}
//in C# proj.
public class B : A.IA
{
void display(){}
}
the error message is like this: COM Interop registration failed. Could not find a type library for assembly "A.IA" ...
3q for help!
Dilly
Dilly
|
|
|
|
|
Your Managed C++ interface must be compiled into an assembly (Code Library). Your C# code must reference the compiled assembly to have proper access to the Managed C++ interface.
|
|
|
|
|
3q for help, but I don't know exactly how to compile the managed interface into an assembly (Code Libray) with VS.NET 2003. Could you plz say something more clearly? Thank you!
Dilly
|
|
|
|
|
I create a class library with .net, and I can subclass CA from the library, but still can not implement the interface IA in it. The error is the same:
-----------------------------------------------
COM Interop registration failed. Could not find a type library for assembly 'CodeLibrary'.
Dilly
|
|
|
|
|
If you are using .NET 2.0 Framework, create a new C++/CLI project choosing the project type of "CLR" and the template "Class Library". The wizard will create an empty class in the header file (ending in ".h"). Modify the empty class to be your interface and compile. This process will create an assembly (ending in .dll) that you can use to reference in your C# code.
|
|
|
|
|
#define R(l,r,i) do { l ^= p[i]; r ^= F(l); } while(0)
why a while(0) ?
|
|
|
|
|
|
The do/while is there to provide a block. Without the do/while, this code:
if (somefunc())
R(a,b,c); wouldn't give the right behavior because only the first statement would be inside the if block.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
but it could have provided these instructions into a block ( { } ) without do/while...
#define R(l,r,i) { l ^= p[i]; r ^= F(l); }
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
-- modified at 4:49 Wednesday 8th February, 2006
|
|
|
|
|
Not in all cases. Here's two versions of a macro:
#define FOO1(n) { return n; }<br />
#define FOO2(n) do { return n; } while(0)
Now given these two macros this will not complile:
if ( 1 )
FOO1(1);
else
return 0;
But this will:
if ( 1 )
FOO2(1);
else
return 0;
So there is method to the madness.
Steve
|
|
|
|
|
oh, my mistake...
yeah, the problem comes from the ; following the expansion of the macro...
a ; cannot come just after a } (except in a user-defined type definition - class, struct, enum, union...)
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Hello experts,
I am writing an application in Solaris, which is supposed to work on PrimePower 650 and SunFire 440 machines. The application listens to the events raised by the Hardware and OS in /dev/log. The application listens to the messages logged into /dev/log and do some processing on them. Now, when there is a load condition occuring at /dev/log(i.e. number of messages per second ocurring at /dev/log is high), CPU consumption by my application shoots up to 50%, while my application is expected to consume not more than 1% CPU.
Now, I want to bring down the CPU consumption to 1%. Since the CPU consumtion can vary according to various CPU configurations, i have to ensure that the CPU consumption remains below 1% for low end CPUs.
Thanks in advance.
Currently to solve this problem, i am using the following technique:
1.Process is only reading 5 messages per second from /dev/log and process them. The process sleeps for rest of the time per second.
2. Every 100 messages, the process sleeps for 5 seconds.
This solution brings down the CPU consumption. On some CPU configurations, it is less than 1% CPU consumption. But on others still varies from 3-13%.
Please tell me if the processing delay technique used has some fundamental faults, or what is the correct technique of introducing processing delay for controlling CPU consumption.
Please also tell your suggestions for controlling CPU consumption. I would also appreciate , if you can redirect me to some links where i can find CPU consumption control techniques and fundamentals.
Thanks and regards.
|
|
|
|
|
And cross-posting to multiple forums is considered very rude! Come on, you posted this question in the "Article Requests and Ideas" forum...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi
i am tryin to write a program(personal interest) which generates the strings of length 5 with a given input of 2 strings from a set of strings.
that is, we have 26 alphabets and the input is "a b".
and my desired output should be "a b c d e"(length =5)
and all possible combinations with "a b - - -".
and also output should not contain "a b d c e" if it has "a b c d e".
can anyone help me the loop.
thanking you.
|
|
|
|
|
Consider a library (unmanaged) exports a class. the class is as follows.
class A<br />
{<br />
public:<br />
virtual void funcA()<br />
{<br />
}<br />
<br />
void DoProcessing()<br />
{<br />
funcA();<br />
}<br />
}
Now in native, If i have to override funcA it would be as
class DA : public A<br />
{<br />
public:<br />
virtual void funcA()<br />
{<br />
}<br />
}
Now if i create an object of DA, and call DoProcessing() , funcA() in DA would be called.
Now if I write a managed wrapper over class A as
class _gc MngdA<br />
{<br />
private:<br />
A __nogc* m_pA;<br />
public:<br />
void DoProcessing()<br />
{<br />
m_pA->DoProcessing();<br />
}<br />
}
No if I inherit from MngdA, i dont have any path to override the virtual functions. This means DoProcessing() will always call the funcA() in class A.
I need a mechanism, so that this virtual function call from the native could could be riuted out into managed code and be able to override it from clr languages.
|
|
|
|
|
Well, C++/CLI also has virtual functions. As long as your managed wrappers also have the same inheritance hierarchy.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I think u dint got my question right.
I have updated the question with further explanation if u could plz have a look.
Rahim Rattani
Karachi - Pakistan
|
|
|
|
|
You'd need managed wrappers for both base and derived classes for this particular scenario.
Regards,
Nish
|
|
|
|
|
|
48d2058 wrote: I was wondering if you'd mind finishing this project before 11/2/2006.
ROTFL. This is great.
1. You asked in the C++/CLI forums, your lecturer does not want a managed solution.
2. For you to get to the point of being asked to do this assignment, you must have had a class or two. Where you asleep ?
3. I will do this for you, for $200. I'll charge $400 for the next piece of homework you can't do because you didn't do this one. And my price will continue to double until you go broke, or until you graduate as an unemployable, lazy bum.
Or, you could try to do your own homework and ask specific questions. Then I will help for free.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: I will do this for you, for $200.
Damnit CG, stop reducing hour rates. I was gonna ask him for $400!
Regards,
Nish
|
|
|
|
|
LOL - you've got a point. I'll let all my various project managers know that I won't work for less than $400 an hour, from now on. :P
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Im new to codeproject, I was hoping to get some help. Im tryin to convert the Image into Byte stream and send it to MySQL database. (Hence, so I can send image to database)
MemoryStream^ mst = gcnew MemoryStream();
viewPictureBox->Image->Save(mst,viewPictureBox->Image->RawFormat);
Byte BinaryImg[] = mst->GetBuffer(); <- doesnt like this line
MySqlCommand^ cmd = gcnew MySqlCommand("SELECT * FROM Patient", Mycon);
cmd = gcnew MySqlCommand("INSERT INTO patient(Leftimage) VALUES" + "('"+viewPictureBox+"')", Mycon);
I get the following error:
error C2440: 'initializing' : cannot convert from 'cli::array ^' to 'unsigned char []'
Im using MC++.
Can someone plz give me hand. I was informed that Nish can help me with this porblem !
thanks alot in advance
hbjs
makaveli
-- modified at 21:10 Sunday 5th February, 2006
|
|
|
|