|
This should be a simple question.
I have set up a global hook using the WH_GETMESSAGE flag (no problem there). After I have processed the message in my hook function, how do I remove it from the message queue so that it not processed by the application
(The message is a WM_KEYDOWN message trapping the VK_UP and VK_DOWN keys).
---
Blessed are those who can laugh at themselves, for they shall never cease to be amused
|
|
|
|
|
I think you might need to use WH_KEYBOARD.
From "INFO: Importance of Calling DefHookProc()" in the MSDN:
<snip>
"Only a keyboard hook (WH_KEYBOARD) can suppress a keyboard event by not calling DefHookProc() and returning a 1. When the system gets a value of 1 from a keyboard hook callback function, it discards the message. "
</snip>
oops - wrong snip! - the above was for win 3.0
"For Win32, mouse and keyboard hooks can suppress messages by return value and do not have to call CallNextHookEx(), unless they want to pass the message on. Other hooks, like WH_CALLWNDPROC, don't need to call CallNextHookEx(), because it will be called by the system. However, all hooks should call CallNextHookEx() immediately if nCode<0."
Someday I hope to be able to get a post right on the first attempt!
|
|
|
|
|
Hi all,
My source code won't work, what is my wrong ?
My database is Access 2000.
pApp->pConnection->Open(_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Server.mdb;"), _bstr_t(""), _bstr_t(""), adConnectUnspecified);
pApp->pRecordsetACTION->Open(_variant_t(_bstr_t("SELECT * FROM ACTION")), pApp->pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText);
Help me !!!
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
When you say it won't work, what does it do ? What errors do your connection object contain ( they are flags in the object ) ? Are both pointers OK ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hi Christian ...
My source code haven't error in compiling ...
But when my program want to run, have crash !!!
My English is VERY BAD, sorry
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
My English is VERY BAD, sorry
That's fine, I'm sure it's better than if I was trying to speak whatever your first language is
I had a LOT of trouble with ADO because it crashes whenever you get ANYTHING wrong in the strings you pass in. These should always be in a try/catch, and you should try to get error info if you can. Either way, you should trace into the program to see which command is crashing, and use the debugger to verify that the two pointers are OK. Also, if you type err, hr into the variable watch window, it will show the HRESULT returned by your last COM call ( ADO being a COM object ).
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thanks for your advices
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I think you should try to set the CursorLocation of the Recordset to adUseClient because
a Access Database does not work correct with CursorLocation adUseServer !
pApp->pRecordsetACTION->CursorLocation = adUseClient;
pApp->pRecordsetACTION->Open(_variant_t(_bstr_t("SELECT * FROM ACTION")), pApp
->pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText);
Greetings Hiasi !
|
|
|
|
|
Thanks for your help !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi,
When you create a new Multi Document MFC app, compile and run it a child window immediately appears in the main window. Where is the best place to stop this from happening?
Thanks,
Jim
|
|
|
|
|
For a quick try, comment these lines in ::InitInstance() of your application class:
Hope this helps.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Hi,
Commenting out the command line dispatch may be a little to invasive. Instead leave Fazlul's code uncommented and place this above it:
if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
-Kevin
|
|
|
|
|
I agree, this is a better solution.
Thanks.
// Fazlul
|
|
|
|
|
Hi to all !!!
I'm currently trying to code a Winsock server application. I'm using the main process thread to listen to incoming connection. When a connection is detected (i'm using WSAAsyncSelect) i spawn a new UI thread that will process that connection. I do not want a window to appear but i'm creating a dummy window because I need the message map...
But the problem i'm having right now is that the messages for the WSAAsyncSelect goes to the dummy window and not to the UI thread message map...
Here is how I create the dummy window...
//-------------------------------------------------
bool CConnection::InitDummyWnd(void)
{
m_pDummyDlg = new CDummyDlg;
if (!m_pDummyDlg->Create(IDD_DUMMY, NULL))
return false;
m_pMainWnd = (CWnd *)m_pDummyDlg;
m_pMainWnd->SubclassWindow(m_pDummyDlg->GetSafeHwnd());
m_pMainWnd->ShowWindow(SW_SHOW);
return true;
}
bool CConnection::PrepareWSAAsync(void)
{
if (WSAAsyncSelect(m_sock.getSocket(), m_pMainWnd->GetSafeHwnd(), WSA_THREADSOCKETEVENT,
FD_READ | FD_WRITE | FD_CLOSE) == SOCKET_ERROR)
{
WORD err = WSAGetLastError();
return false;
}
return true;
}
//------------------------------------------------------------
How can I make sure that the thread message map gets all the winsock message instead of the dummy window message map ???
Thanks for any advice !
Luc B.
|
|
|
|
|
It is the call WSAAsyncSelect(m_sock.getSocket(), m_pMainWnd->GetSafeHwnd(),...) that is telling Winsock to send notifications to your dummy window. The problem is that WSAAsyncSelect needs a valid HWND to send the notifications to. One workaround for this is having PreTranslateMessage overriden so that it intercepts messages intended to the dummy window from Winsock, like this:
BOOL CConection::PreTranslateMessage(MSG *pMsg)
{
if(pMsg->message==WSA_THREADSOCKETEVENT){
pMsg->hwnd=0;
}
return 0;
} Haven't checked it out myself, so it'd be great if you tell us back whether this works.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Nope doesn't work. My CConnection::PreTranslateMessage never gets called !?!?!
|
|
|
|
|
Hmmm... Do you mean CConnection::PreTranslateMessage never ever gets called (for this or for any other message) and yet the Winsock messages make their way to the dummy window message map? At least some standard messages delivered to the dummy window upon creation should go across PreTranslateMessage .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How can I find out what the color of the desktop icons' text is? It looks like GetSysColor won't do it. Any help is greatly appreciated.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
The icon text color appears to be derived from the desktop background color. I think it's either black or white, depending on the desktop background.
/ravi
"There's always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
But how do I find out if its black or white? Also, there is a utility called SetTextColor made by Pact Software www.12ghosts.com which says they send a message to the desktop telling it to change the icon text color...how do they do that? Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Do you know how to get the hue/luminance of a color? That is what its based on. Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
|
I'm having some difficulties sending large amounts of data (>40,000 bytes) to a server using CAsyncSocket in MFC. The client has no problem sending all the bytes, but when the server receives the bytes, the OnReceive function is called 4 times: each receive brings in about 10,000 bytes. However, after the first chunk is received (that one is OK), the rest of the received chunks are empty (don't have the numbers I am expecting). Any ideas on what might be going on?
Thanks in advance...
Nathan Brown
Southern Company
Technical Services
|
|
|
|
|
Just keeping this thread active...
|
|
|
|
|
I have been given a DLL project given to me that should be able to communicate through the web to a firmware device. I am familiar with Winsock, but I am not sure what type of dll to use and if I will encure any problems when spawning threads. Is Winsock thread safe? Please help.
|
|
|
|