|
Problem : my hook procedure is not working when the main window losts focus or minimized...
description:
i have written a global hook procedure to track the keystrokes. the hook procedure resides in a dll and i am calling it from the main window. from the dll i am displaying the keycode using a messagebox. it is working globally... then problem is when i tried to write the keypress to a file it is working but when the main window losts focus the keystrokes are not written to the file but it displayed... i tried to pass the value to the main window using WM_COPYDATA but neither of the options helped... i was able to reveice the WM_COPYDATA message in the main window only when the window is active and when my window goes inactive it dosent work... how to solve this... i am using dev C++ ide... i am using C style and not c++ or MFC...what should be done to make the main window always receive messages from the hook procedure???
|
|
|
|
|
Hi to All,
How to manage Bitrate through Programming?
In my application during runtime, I am generating some data & transfering it to (any type of) Output (like IP Output, any type of Output Card, or writting a File). I have done it, but I want to transfer data at particular Bitrate to the Output.
Consider that I am sending generated data to IP, so how I can achieve it's transfer at particular bitrate?
When I was trying to transfer data at 2Mbps OR 3Mbps using MachineCycles & Sleep(1) at getting output bitrate as 749 Kbps with 1% Processing. But when I remove Sleep(1) I am getting out bitrate as 1.9Mbps OR 2.9 Mbps (respectively), with 61% of Procssing.
What is the solution to achieve bitrate transfer with low Processing?
|
|
|
|
|
In my program I've got a base class (all member methods are pure virtual) which a number of classes are derived from. In a seperate class I want to have an array which contains pointers to these classes, i.e. it doesn't create the objects just has a pointer to them. My code loks like this so far:
<br />
class BaseClass<br />
{<br />
public:<br />
BaseClass( ) ;<br />
<br />
virtual<br />
~BaseClass( ) ;<br />
<br />
virtual void<br />
EveryClassNeedsThis ( ) = 0 ;<br />
<br />
private:<br />
BaseClass( const BaseClass &source ) ;<br />
<br />
BaseClass& <br />
BaseClass::operator= ( const BaseClass &rhs ) ;<br />
<br />
} ;<br />
<br />
class DerivedClassA : public BaseClass<br />
{<br />
public:<br />
DerivedClassA ( ) ;<br />
<br />
virtual<br />
~DerivedClassA ( ) ;<br />
<br />
void<br />
EveryClassNeedsThis ( ) ;<br />
<br />
private:<br />
DerivedClassA ( const DerivedClassA &source ) ;<br />
<br />
DerivedClassA & <br />
DerivedClassA ::operator= ( const DerivedClassA &rhs ) ;<br />
} ;<br />
<br />
class ArrayClass<br />
{<br />
public:<br />
ArrayClass ( ) ;<br />
<br />
virtual<br />
~ArrayClass ( ) ;<br />
<br />
void<br />
AddToArray ( BaseClass *obj )<br />
<br />
private:<br />
ArrayClass( const ArrayClass &source ) ;<br />
<br />
ArrayClass& <br />
ArrayClass::operator= ( const ArrayClass &rhs ) ;<br />
<br />
BaseClass *m_DerivedObjects ;<br />
} ;<br />
In the implementation for AddToArray I have
<br />
{<br />
m_DerivedObjects = obj ;<br />
}<br />
but i get an access violation on this, so can anyone spot what I'm doing wrong?
TIA,
Andy
|
|
|
|
|
morning blues even worse than I thought!
<br />
void<br />
AddToArray ( BaseClass *obj,<br />
int pos )<br />
<br />
BaseClass *m_DerivedObjects<br />
should be
<br />
BaseClass *m_DerivedObjects [10] ;<br />
and
<br />
m_DerivedObjects = obj ;<br />
should be:
<br />
m_DerivedObjects [pos] = obj ;<br />
|
|
|
|
|
If you want to manipulate an array of objects (or pointers to objects if you want to use polymorphism), I highly suggest that you take a look at the container classes from the STL: vector, list, ...
Everything has been implemented and has been used by a lot of developers, so, chances of bugs are close to zero.
|
|
|
|
|
Hi,
thanks for your reply, found out it wasn't the array causing the problem but that I was calling a non static method in a non-static manor (also the variables are not static either).
cheers,
|
|
|
|
|
My advice remains valid even if you found the bug . Why reinvent the wheel when something free exist ?
|
|
|
|
|
Hai i have some problem here.
1.
using namespace std;
int main()
{
char name[50];
char lastname[50];
char fullname[150];
char university[50];
char uni[100];
int age;
cout<<"Enter first name:";
cin.getline(name,50);
cout<<"Enter last name:";
cin.getline(lastname,50);
cout<<"Enter age:";
cin>>age;
cout<<"Enter University:";
cin.getline(university,20);
strcpy(fullname,name);
strcat(fullname, " ");
strcat(fullname,lastname);
cout<<"Your name:"<<fullname<<endl;
cout<<"your="" age:"<<age<<endl;
="" cout<<"study:"<<university<<endl;
}
2.
using="" namespace="" std;
int="" main()
{
="" char="" name[50];
="" lastname[50];
="" fullname[150];
="" university[50];
="" uni[100];
="" int="" age;
="" cout<<"enter="" first="" name:";
="" cin.getline(name,50);
="" last="" cin.getline(lastname,50);
="" university:";
="" cin.getline(university,20);=""
="" age:";
="" cin="">>age;
strcpy(fullname,name);
strcat(fullname, " ");
strcat(fullname,lastname);
cout<<"Your name:"<
|
|
|
|
|
Try cin.ignore() or use fflush(stdin) to clear the buffer.
|
|
|
|
|
thank you so much......now i have an idea...
thank you
mazeed
|
|
|
|
|
thank you,
it is work..
i'm using cin.ignore()..
thank you so much...
mazeed
|
|
|
|
|
Why are you using char[] variables with C++ when string variables would be way more efficient? Yeah, it's only a few hundred bytes, but that, coupled with not having to use strcxx() , is a good reason to switch.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all:
I'm wondering how's the following code snippet could finish returning the final 'nn' to the caller, since I did not explicitly return 'nn' on each recursive call.
int ss(int n)<br />
{<br />
int nn;<br />
if (n)<br />
nn = (n + ss(n - 1));<br />
else<br />
return 0;<br />
}<br />
<br />
int n = ss(4);
|
|
|
|
|
Actually it returns 0 on my system.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
LiYS wrote: I'm wondering how's the following code snippet could finish returning the final 'nn' to the caller, since I did not explicitly return 'nn' on each recursive call.
Compiler should issue warning about return path.
Prasad
MS MVP - VC++
|
|
|
|
|
I guess accumulator register is used to store the return value,
Since the code donot execute the return statement except at the last,
the previous result in the accumulator n+ss(n-1) is taken as return value.
Thus we get the currect value. If you used return 1; instead of return 0;
you get 1 + the result;
Best Regards
Raj
|
|
|
|
|
Yes, I guess you're right, add the following asm statement makes the program result logical to me. But what's the theory behind this?
int sum(int n)
{
int nn;
int dummy = 0;
if (n)
{
nn = (n + sum(n - 1));
__asm
{
mov eax, 0
}
}
else
return 0;
}
|
|
|
|
|
There is nothing theoritical, It depends on the implementation of the compiler.
if _asm::call is the opcode for a function call, then it has to place its return value in some register/memory location;
I guessed it is some where on the return mechanism and verified in code dissassembly.
int n = ss(4); will be something like
push 4
call ss
mov dword ptr [n],eax
After a call, we need the return value, called subroutine places its return value in eax.
Iam not sure, the theory of VC++ compiler is available open, but i believe this depends on the compiler implementation, for instance gcc compiler may not behave the same, hence most compiler flashes warning some thing like "not all code path returns value"
Best Regards
Raj
|
|
|
|
|
simply add some accumulator register involving operation next to nn = (n + ss(n - 1));
like another addition. It won't work as you expected.
|
|
|
|
|
Hi All,
first time building a DLL not to mention C++ program and I'm having a little trouble trying to get the parameters passed to it.
I'm using VC++ 6.0. I created this via a 'Regular DLL using shared MFC DLL'
Upon running it basically creates an application class, then creates a dialog box. This piece works!
Now, I need to pass it three parameters to use though out the program, do I create a new method within the application class to grab these values? (If so can someone give me some example on what I need in this method) Or have I gone the wrong way in trying to build this? All examples I have read are fairly simple DLLs with functions, mine is based on classes.
Any help would be greatly appreciated
Hayden
|
|
|
|
|
Hayden25 wrote: Now, I need to pass it three parameters...
You'll need to do this via an exported function.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
how can i determine wheather the cd door is ejected or not
|
|
|
|
|
nitinmx wrote: how can i determine wheather the cd door is ejected or not
See here[^].
|
|
|
|
|
Rather than guess/query what state it's in, why not simply put it into the state you need? There's no harm in opening a door that's alread open, or closing a door that's already closed.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
I have a strange problem. When I use the function _vsntprintf_s in my program. the program finishes without any error messages..
if I use _vsntprintf the whole things works as expected. Has anyone an idea?
I want to use the secure verision because here I have the possibilty to use _TRUNCATE, which I really need...
<br />
dwLen = _vsntprintf((TCHAR*)logEntry.message, sizeof(logEntry.message) / sizeof(TCHAR), szFormatString, args);<br />
dwLen = _vsntprintf_s((TCHAR*)logEntry.message, sizeof(logEntry.message), _TRUNCATE, szFormatString, args);
best regards
Hansjörg
|
|
|
|