|
Thanks for that. I think it put me on the right track, although I was unable to check for the nesting because I didn't know where to put the increments / decrements.
I have a listening thread which listens for an RX event and reads (overlapped) the data.
Other threads can issue overlapped writes to the same port, whose access is protected with a critical section.
However, I suspect that my problem my come from the fact that I'm using the same event handle for all the instances of overlapped reads / writes.
I could be wrong about this, my understanding of overlapped I/O is limited :s
Does this make sense?
|
|
|
|
|
The problem seems to be resolved.
I am concluding that the multiple use of the same event handle in overlapped I/O caused stack corruption and the process would crash silently. A week of testing after correcting the overlapped I/O has shown that the application is now stable.
Thanks for all the help
|
|
|
|
|
i guess your threads are eating up the stack so it ends.
-> To DO: debug at most your thread terminations for leaking memory.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi All
I have download some example code from net.When i try to complie this code then i getting error this.
error PRJ0019: A tool returned an error code from "Performing Custom Build Step"
|
|
|
|
|
open up the project's properties, look at the custom build steps and see what it's trying to do.
|
|
|
|
|
There is normal setting
Performing Custom Build Step nothing special setting there.Please give me more tips.
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
I want to confine mouse movement. Let's say I want to confine mouse movement to x-direction (so only horizontal movement is possible) when pressing a certain button. This should work globally. What I mean with that is, that I want to use this in any windows program. Let's take MS Paint as an example: When my program runs and I press the certain button, the movement of the mouse should be restricted to horizontal movement. So when drawing a straight horizontal line should be the result.
My research so far led me to ClipCursor, but ClipCursor seems to only affect the mousecursor, not the raw data. So returning to the example of MS Paint the following happens:
The cursor moves on the horizontal line, but the mouse data received by paint is different: So if you move the mouse slightly in y-direction this still affects the line drawn, also the mouse cursor itself does not indicate that (stays on the straight line). So the result is not a straight line as expected.
Does anybody know how to solve that problem ? (as ClipCursor does not confine the raw data sent to an application, it seems to be the wrong routine for doing that)
Thanks in advance.
|
|
|
|
|
HHOOK WINAPI SetWindowsHookEx(
__in int idHook,
__in HOOKPROC lpfn,
__in HINSTANCE hMod,
__in DWORD dwThreadId
);
http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx[^]
and then look at: WH_MOUSE or WH_MOUSE_LL to get what you need. WH_MOUSE_LL gives a little bit more information, but may not be needed in your application.
|
|
|
|
|
Thanks for the answer. I could use one more hint. To modify the mouse data with let's say WH_MOUSE_LL I have to use my own custom CallBack function and modify the POINT pt of the MSLLHOOKSTRUCT pointed to by lParam, which has been passed to the CallBack function, right? Or did I get something wrong about how to restrict the movement correctly?
|
|
|
|
|
If i remember correctly yes that would be how you would restrict the movement.
|
|
|
|
|
Additionally to what elchupathingy said, you might also try to globally hook[^] GetCursorPos[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Selectively injecting a DLL and hooking the functions you need is IMO the better solution. More complicated than using SetWindowHookEx, but will not have the overhead and annoying problems that are associated with global hooks...IE getting the mouse stuck on your horizontal plane, which I think is not what is to happen.
|
|
|
|
|
Wouldn't he still need to use a hook to modify the mouse-input messages? I mean, the coords "encoded" in the message params probably come from somewhere else than GetCursorPos, do they not? Wouldn't btw selectively injecting the DLL instead of trying this globally with every process make it less "global"?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
He could hook the actual function it self by using a DLL, messy but could work well and to make this global you can keep an array of processes and check for new ones and inject into the new ones.
Or, looking back at what you have said another way to do it would be to use SetWindowHookEx and pass the thread ID of the process that is to be injected into. [^]
I just feel that this particular program could cause problems in other programs if it were a global hook, and that it only needs to be applied to specific processes rather than all running processes. From the example of the op with mspaint.
Also the call chain for GetCursorPos is:
GetCursorPos -> NtUserCallOneParam( DWORD dwParam, DWORD routine )
So, a hook on NtUserCallOneParam could be used to modify the mouse position that is returned.
|
|
|
|
|
Hi,
my application is a win32 appln. I have added try-catch loop. But its showing the following error.Please help me to resolve this error.
Code:
try
{
fn();
}
catch(CException exp)
{
exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL);
wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn");
WriteLog(0,lpszLogMsg);
return;
}
Error:
error C2061: syntax error : identifier 'CException'
error C2310: catch handlers must specify one type
error C2227: left of '->GetErrorMessage' must point to class/struct/union
error C2317: 'try' block starting on line '474' has no catch handlers
|
|
|
|
|
try
{
fn();
}
catch(Exception *exp)
{
exp->GetErrorMessage(lpszErr,sizeof(lpszErr),NULL);
wsprintf(lpszLogMsg,"%s\\%s",lpszErr,"fn");
WriteLog(0,lpszLogMsg);
return;
}
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
now the errors has gone.Can you please tell me how to get the error message.
ni CExeception we are having GetErrorMessage() fn. Similarly, what is the fn in exception class to get the error message?
|
|
|
|
|
Print this line to get the error message
exp->Message
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
The exception type you are trying to catch has to be defined. The error simply reads: I don't know what CException is.
You might be missing an #include , defining CException .
There is no predefined exception class in C++ as in many other languages. In C++ you can throw whatever object you want; int, const char*, CMyComplexClass...
Always try to catch exceptions by reference instead of by value. That will avoid a lot of unnecessary copying of data. catch(CException &exp)
|
|
|
|
|
To amplify Niklas' answer a bit...
Throw by value, catch by reference. If you do this:
- It removes copying of the exception, reducing the chance of further exceptions being thrown
- You can catch families of exceptions polymorphically
Cheers,
Ash
|
|
|
|
|
HI All,
I have drawn an image using GDI+. I want a rectangle in the middle of image and alpha blending on remaining part of image.
I got stuck and want idae from yourside. please guide to do that.
|
|
|
|
|
Here is a nice article with example that might help.
Alpha Blending using GDI+[^]
PURPOSE: Delays program execution until designated condition is indicated.
|
|
|
|
|
Hi friends, here is my query...
I am working on win32. I am writing an application to read some data from registry. It is working on 32 bit machines. But it is not working on 64 bit machines. I am using the below API to read the data.
RegQueryValueEx(hKey, pszEntry, NULL, NULL, (LPBYTE)pData, 200)
Is there any problem with the last parameter size (200). What size to be passed as parameter.
Thanks in advance.
Regards
Sairam M.
|
|
|
|
|
msr_codeproject wrote: Is there any problem with the last parameter size (200). What size to be passed as parameter.
This parameter should be the address of (pointer to) a variable that contains the length of the buffer, as described here[^]. If this size is not large enough for the result then the call will fail and the required size will be entered into the variable. Thus if you make a call with the variable set to zero you can find out how big the buffer needs to be and allocate as appropriate.
BTW I'm not sure why your question got downvoted so I have upped it to compensate.
It's time for a new signature.
|
|
|
|