Could use a hand...
Guys & Gals,
I'm in need of a little advice. I'm writing a
keyboard handler. Something very basic to take care of user input, etc...
The way I have my project set up, I've declared the function InputHandler() in a DLL and called it within the message pump in WinMain(). For the most part, I've never had to much problems with DLLs but for some reason the function seems not to be recognized this time around.
Briefly, this is what the InputHandler function looks like...
------------------------------------------------------
InputHandler()
{
if (Keys[VK_ESCAPE]) SendMessage (hwnd,WM_CLOSE,0,0);
}
------------------------------------------------------
I have a feeling the problem lies somewhere with 'hwnd'.
Could this be the case?
If it is I'm lost for understanding because I declared hwnd globally under a header of mine, like so ...
---------------
HWND hwnd;
---------------
Anyway this is my dilemma for the day
Thanks in advance.
~Will be glad when he can OFFER advice instead of being doomed to always ask for it~
-Miraj
Edited by - Miraj on 1/27/00 6:19:50 PM
-Miraj
hmmmmmmm. Im no expert but i think you are right in suspecting hwnd. The handle may be global to your main app, but that dosent mean the DLL can see it does it? Ive always had to pass any variables my DLLs will work on, explicitly to them as i call their functions so maybe...
InputHandler(HWND hwnd)
{
if (Keys[VK_ESCAPE]) SendMessage (hwnd,WM_CLOSE,0,0);
}
will work. Its only a 2 minute thing to test so give it a try! but having said all this, id recommend using DirectInput anyway, its much better.
As a second tip, a good way of discovering HWND problems, is to output the handle values to disk at the two points and check whether or not the values match, that way you know your messages are turningup at the right window (or not).
http://www.positech.co.uk
InputHandler(HWND hwnd)
{
if (Keys[VK_ESCAPE]) SendMessage (hwnd,WM_CLOSE,0,0);
}
will work. Its only a 2 minute thing to test so give it a try! but having said all this, id recommend using DirectInput anyway, its much better.
As a second tip, a good way of discovering HWND problems, is to output the handle values to disk at the two points and check whether or not the values match, that way you know your messages are turningup at the right window (or not).
http://www.positech.co.uk
Hi Cliffski,
Thanks for the response.
I tried what you suggested and it worked!
Seems I still have so much to learn, heh...
This is a very good thing. I have a ton of code in place that depend on the DLLs functionality, I was getting a little worried I might have to scrap it and start from the bottom up again.
I''ll try DirectInput as well. I should have taken that course of action too, heh. Thanks again!
-Miraj
Thanks for the response.
I tried what you suggested and it worked!
Seems I still have so much to learn, heh...
This is a very good thing. I have a ton of code in place that depend on the DLLs functionality, I was getting a little worried I might have to scrap it and start from the bottom up again.
I''ll try DirectInput as well. I should have taken that course of action too, heh. Thanks again!
-Miraj
-Miraj
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement