|
In case you need a system wide hook, you need to implement the hook function inside a DLL. The function could look sth. like this:
__declspec(dllexport) LRESULT CALLBACK HookFunction(<br />
int code,<br />
WPARAM wParam,<br />
LPARAM lParam)<br />
{<br />
char szVCode[50];<br />
<br />
sprintf(szVCode, "Virtual Key code: %lx", wParam);<br />
MessageBox(NULL, szVCode,"Key stroke", MB_OK);<br />
}
Installing it in your application is done by calling SetWindowsHookEx:
hHookDll = LoadLibrary("hook");<br />
hHookProc = (HOOKPROC) GetProcAddress(hHookDll, "HookFunction");<br />
<br />
hSystemHook = SetWindowsHookEx(WH_KEYBOARD,hHookProc,hHookDll,0);
Finally, don't forget to unload DLL and unset the hook:
UnhookWindowsHookEx(hSystemHook);<br />
FreeLibrary(hHookDll);
If you need some more detailed information, have a look at MSDN - there's lots of stuff about that topic.
|
|
|
|
|
you have to put your system wide keyboard hook in a .dll
http://www.codeguru.com/system/KBHook.html
that has a good example of a system wide keyboard hook , and an application example that uses the dll.
i was able to build my own keyboard hook after going thru that , and ive used it w/ no major problems. note there is a bug in the code there. u need to get rid of hook = NULL; line from dllmain;
hope this helps
todo....
:: insert inpirational text here ::
|
|
|
|
|
I'll try it ... Thank you ... Olaf
|
|
|
|
|
Hello,
I have a problem: I have two separate applications:
1) an ATL explorer shell extension
2) a MFC application which should display the files
Because of project reasons the files have to be different, the
explorer shell extension must be a DLL and the display application
must be a MFC project as EXE.
How can I pass the selected files from the DLL to the EXE?
I first thought of GlobalAlloc but MSDN says that this function
is only provided for 16-bit support.
What would you suggest? Is there a way to share an array? It is a bit difficult to implement an IPC system in this case...
Thanks
-Dominik
|
|
|
|
|
I'd say GlobalAlloc is just fine. IMHO the docs are a little misleading with respect to the applicability of this function (the proposed alternative, HeapAlloc and company, doesn't add much to this for your particular needs).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, everyone!
Where is the the precompiler directive __PTHREADS__ defined?
Defined in compiler? What is the meaning and function of
the precompiler directive __PTHREADS__?
Thanks in advance,
George
|
|
|
|
|
pthreads is a unix threading library, and I can only imagine the application you are trying to compile makes use of the Win32 version of this. __PTHREADS__ will be found wherever the pthread include files are, thats about all that can be said.
|
|
|
|
|
Thanks!
I have another, does Windows use pthreads library?
If I am using Windows version of the project, can
I passby the codes has something to do with pthreads?
Cheers,
Geroge
|
|
|
|
|
Nitpicking: Pthreads is a POSIX standard (IEEE POSIX 1003.1c-1995, also known as the ISO/IEC 9945-1:1996) not a "unix" one.
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Yep, there is a version of the UNIX pthreads available for Win32 at http://sources.redhat.com/pthreads-win32/ You should be able to compile and run just about any application that uses pthreads, although if it uses other unix system calls you might run into problems.
|
|
|
|
|
|
|
Hi friends,
Are there any POP3 supporting MFC classes ?? I want to get copy of mail when the mail lands at the Server. Please suggests any links if available.
Thanks
Satya
|
|
|
|
|
there are many..search in www.codeproject.com/internet you will find many..
cheers
Himanshu
|
|
|
|
|
I try to write double values to a file. The problem is that all values have different precisions.
Example:
double d = 1.234
CString.Format("%.5f", d) causes the output to be 1.23400.
I only want to print 1.234
How can I determine the precision of a given double value?
|
|
|
|
|
What about CString.Format("%ls",d); ?
~RaGE();
|
|
|
|
|
Thanks, Rage, but that doen't work. The Prefic "l" before the type specifier has no effect on the precision. I suppose you meant "%ld" !?
Heiko
|
|
|
|
|
Sorry, i mistake myself with ascanf specifiers. Right code is
str.Format("%g",d); . This gives out 1.234 for double d=1.2340000 or d=1.234 .
~RaGE();
|
|
|
|
|
I've a problem with Property Pages within a Property Sheet.
The Font Property is set to a 10 point Font in the Resource Editor, but the Property Pages still appear in a 8 Point(I think this is default) Font.
Changing the font via SetFond function of the PropertySheet or PropertyPages doesn't change anything.
GetTabControl()->SetFont(&App.m_CLabelBoldFont) only changes the Font of the Labels in the Tab Control.
Does anybody know a solution?
I already thought of looping throug the Elements of the Property Page in the OnInitDialog function, but I don't know how. Even such a solution would be helpful to me. Thanks.
|
|
|
|
|
Here's sth. from MSDN:
"Even if the font of the property pages is changed in the Resource Editor, property pages will be displayed at run time with the system font. If it is necessary to change the font, call SetFont() in OnInitDialog; then use an appropriate MoveWindow() to resize the sheet and move and resize all the controls on the page. Also, the property sheet is set back to its original size whenever a page is activated, so it will be necessary to resize the page in response to a click on the tab control. "
And that's an excerpt from the provided sample, a helper function to set the font (pWnd = pointer to your CPropertySheet):
void ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag)<br />
{<br />
CRect windowRect;<br />
<br />
TEXTMETRIC tmOld, tmNew;<br />
CDC * pDC = pWnd->GetDC();<br />
CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont());<br />
pDC->GetTextMetrics(&tmOld);<br />
pDC->SelectObject(pFont);<br />
pDC->GetTextMetrics(&tmNew);<br />
pDC->SelectObject(pSavedFont);<br />
pWnd->ReleaseDC(pDC);<br />
<br />
long oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading;<br />
long newHeight = tmNew.tmHeight+tmNew.tmExternalLeading;<br />
<br />
if (nFlag != CDF_NONE)<br />
{<br />
CRect clientRect, newClientRect, newWindowRect;<br />
<br />
pWnd->GetWindowRect(windowRect);<br />
pWnd->GetClientRect(clientRect);<br />
long xDiff = windowRect.Width() - clientRect.Width();<br />
long yDiff = windowRect.Height() - clientRect.Height();<br />
<br />
newClientRect.left = newClientRect.top = 0;<br />
newClientRect.right = clientRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;<br />
newClientRect.bottom = clientRect.bottom * newHeight / oldHeight;<br />
<br />
if (nFlag == CDF_TOPLEFT)
{<br />
newWindowRect.left = windowRect.left;<br />
newWindowRect.top = windowRect.top;<br />
newWindowRect.right = windowRect.left + newClientRect.right + xDiff;<br />
newWindowRect.bottom = windowRect.top + newClientRect.bottom + yDiff;<br />
}<br />
else if (nFlag == CDF_CENTER)
{<br />
newWindowRect.left = windowRect.left - <br />
(newClientRect.right - clientRect.right)/2;<br />
newWindowRect.top = windowRect.top -<br />
(newClientRect.bottom - clientRect.bottom)/2;<br />
newWindowRect.right = newWindowRect.left + newClientRect.right + xDiff;<br />
newWindowRect.bottom = newWindowRect.top + newClientRect.bottom + yDiff;<br />
}<br />
pWnd->MoveWindow(newWindowRect);<br />
}<br />
<br />
pWnd->SetFont(pFont);<br />
<br />
CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD);<br />
<br />
while (pChildWnd)<br />
{<br />
pChildWnd->SetFont(pFont);<br />
pChildWnd->GetWindowRect(windowRect);<br />
<br />
CString strClass;<br />
::GetClassName(pChildWnd->m_hWnd, strClass.GetBufferSetLength(32), 31);<br />
strClass.MakeUpper();<br />
if(strClass==_T("COMBOBOX"))<br />
{<br />
CRect rect;<br />
pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect);<br />
windowRect.right = rect.right;<br />
windowRect.bottom = rect.bottom;<br />
}<br />
<br />
pWnd->ScreenToClient(windowRect);<br />
windowRect.left = windowRect.left * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;<br />
windowRect.right = windowRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;<br />
windowRect.top = windowRect.top * newHeight / oldHeight;<br />
windowRect.bottom = windowRect.bottom * newHeight / oldHeight;<br />
pChildWnd->MoveWindow(windowRect);<br />
<br />
pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);<br />
}<br />
}
Hope it'll help you.
|
|
|
|
|
Wow! That was fast. Yes it works! Thanks a lot.
|
|
|
|
|
Hi
I create a splitter wnd with 2 panes. Each pane is a form with a few dialog boxes. When I am at the last dialog item of 1st pane, I want the TAB key to activate the next pane and SetFocus to the first dialog item there. Can someone please tell me how to do so?
Thanks!
|
|
|
|
|
Intercept the WM_KILLFOCUS sent by the dialog item leaving the focus (in MFC with a OnKillFocus ) and set it to the other one with a SetFocus .
~RaGE();
|
|
|
|
|
i am doing an Instant Messenger i have no idea of programming voice in vc++ please help
|
|
|
|
|
There are voice chat samples in the DirectX SDK
--
Help me! I'm turning into a grapefruit!
|
|
|
|