|
Hello,
I am tracking the TME_LEAVE mouse event in my dialog based app but even if it still has focus and I move the mouse to the listbox control then this message fires. Is there anyway to have it work like a "real" leave, say when it leaves my app? Any help is greatly appreciated.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
What would be the best way to pass a callback function to a DLL? I want to do something like this:
In the Dll...
BOOL declspec(dllexport) __stdcall InstallKeyboardHook(HOOKPROC proc)
{
g_hKeyboardHook=SetWindowsHookEx(WH_KEYBOARD, proc, g_hInstance, 0);
return g_hKeyboardHook ? TRUE : FALSE;
}
In the executable, after LoadLibrary and GetProcAddress...
InstallKeyboardHook(MyHookProc);
LRESULT CALLBACK MyHookProc(int code, WPARAM wParam, LPARAM lParam)
{
MessageBeep((UINT)-1);
}
I don't get any errors, but I don't get any beeps from key presses, either. HELP!!!!
Thanks in advance.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
if you want to catch the WM_KEYDOWN or WM_KEYUP before the message is sent to any other window,
Change:
BOOL declspec(dllexport) __stdcall InstallKeyboardHook(HOOKPROC proc)
To:
BOOL declspec(dllexport) __stdcall InstallKeyboardHook()
I guess that YourHookProc is in the executable file, when it should be in the dll.
In the executable,
you should call only InstallHook() and UninstallHook();
BTW:
you should here beep if you hit a key when the thread is on focus.
try creating a MessageBox under the same thread that called InstallHook(...) and hit space when the message box is open.
DONT FORGET:
Turn on you speakers
Let me know if I helped you.
I did this kind of app, but insted of beep I used the ICQ's MsgType.wav
if you want to check it out, let me know
Name: STR
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject"
|
|
|
|
|
The hook function (MyHookProc) needs to be in a DLL if it's a global hook.
> Andrew
"Do you like my mask, it raises the dead...!"
-- Buffy (season 3, Giles)
|
|
|
|
|
when creating the thread function that gets passed to the AfxBeginThread() function, does this function have to be a global function or can it be say a function of a View/Doc class ... or does it matter???
Bryan ~
|
|
|
|
|
It can be a global function or a static member function of a class. However, you can fake a normal member function by passing the address of an object to the thread function, and then use that to access the members of the object.
Hope that helps,
> Andrew
"Do you like my mask, it raises the dead...!"
-- Buffy (season 3, Giles)
|
|
|
|
|
I have a project that I'm working on and I need the background of my SDI (using VC++ and MFC) to be white but I can't seem to figure out how to do this ... any sugestions??
Thanks -
|
|
|
|
|
You should be able to use something similar to the folowing;
BOOL CYourView::OnEraseBkgnd ( CDC * pDC ) {<br />
<br />
CBrush brush;<br />
brush.CreateSolidBrush ( RGB ( 200, 0, 0 ) );<br />
<br />
CBrush * pOldBrush = pDC->SelectObject ( &brush );<br />
<br />
CRect rect;<br />
GetClientRect ( &rect );<br />
pDC->PatBlt ( 0, 0, rect.Width (), rect.Height (), PATCOPY );<br />
<br />
pDC->SelectObject ( pOldBrush );<br />
<br />
return 0;<br />
}
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Hello,
I have a ListView class, displayed in report mode. How can i change the font of the text displayed in columns and header.
Thanks.
Regards,
Ganesh.M.Ramaswamy
|
|
|
|
|
You can do it with the custom draw feature that ListView controls have. Search your docs for the NM_CUSTOMDRAW notification message to get the details.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
After I've added a new class and realize that I didn't build it right, how can I make it go away si I can rebuild it?
Richard
|
|
|
|
|
delete the .cpp and .h, remove the files from your workspace and then delete your project's .clw file.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Hey guys
can anyone tell me why i am getting these compiler errors and how to fix them:-
Linking...
Creating library Debug/Software to Sign and Verify Files.lib and object Debug/Software to Sign and Verify Files.exp
Crypto.obj : error LNK2001: unresolved external symbol __imp__CertOpenSystemStoreA@8
Crypto.obj : error LNK2001: unresolved external symbol __imp__CertFreeCertificateContext@4
Crypto.obj : error LNK2001: unresolved external symbol __imp__CertGetCertificateContextProperty@16
Crypto.obj : error LNK2001: unresolved external symbol __imp__CertEnumCertificatesInStore@8
Debug/Software to Sign and Verify Files.dll : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
Cheeers
Peter
|
|
|
|
|
Hi,
did you specify the crypto API import library in your project settings?
If not - go to project -> settings -> link -> input and add "Crypt32.lib" to list of linked import libs.
Whenever you use specific win32 api functions, you should check the win32 api docs "requirements" section of the functions.
Regards,
A.Focht.
|
|
|
|
|
You are missing a .lib file. I think that you need to link with the crypto32.lib
Cheers
Carlos Antollini.
|
|
|
|
|
Hi,
I've been writing DLL that attaches to any process by using global hook, and I need to handle attach/detach operation. It is working fine except when I abort debugging program with msdev. I'm using Japanese version of msdev so I can't tell you the exact name of menu title to ABORT debugging, but we sometimes do that for various reasons. In that case, DllMain was not called with DLL_PROCESS_DETACH. And it seems DLL is left loaded. (The reason I think so is: I can't delete that DLL file even after I ended my application which unloads all DLLs from memory.) I'm doing this on Win2K. And not that program being debugged with msdev is not a program that loads the DLL and let attach to processes.
Is that a problem by design? If someone knows any documents describing this, please let me know.
Thanks.
Kurotora
|
|
|
|
|
There may be a hint in the TerminateProcess API docs:
TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating.
So, if 'End debugging' command is implemented with a call to TerminateProcess, your DLL won't be nofified.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz,
Thank you giving me hint. Can you/anyone let me clear that DLLs are unloaded but not just notified to it? Basically it should I hope though I had a problem with never-unloading-dll.
Thanks.
I love Code Project, do you?
Kurotora
|
|
|
|
|
Stupid Question but....
Did you use, the FreeLibrary() function in your Aplication?
Regards
Carlos Antollini.
|
|
|
|
|
Carlos,
Yes. My application unloads my DLLs with FreeLibrary() and do this up to 100 times until GetModuleFileName() returns 0 which means my DLLs are unloaded from memory. Normaly it's working fine.
Can anyone know how to unload DLL perfectly without rebooting system?
Thanks.
I love Code Project, do you?
Kurotora
|
|
|
|
|
Let's say I have an application that has an icon added in IE's toolbar. When I click the icon, I'd like it to open my app along with the current URL so my app can use it. Is there a way to do this?
Thanks!
|
|
|
|
|
My dialog bar has various controls, that don't take up the whole screen. When the main frame resizes, I want these controls to reposition themselves so they are relatively centered. For example, if a control's left side, is 150 left of the center of the main frame, I want it to always be 150 left of the center of the main frame, no matter what size the main frame is. I can't seem to come up with a simple way to do this, whereas I do not want to have to create variables for each control.
|
|
|
|
|
I have built a Wizard Dialog and on the front page have 3 drop down boxes and one edit box at the top.
I am trying to force the edit box to take the focus on initdialog but I am having no luck.
I have an edit Control variable and I am setting it to focus and I am setting the return value of OnInitDialog to false, just like you do with normal dialogs, but the second item which is a dropdown list continues to have the foucs.
Any idea why this problem is occuring.
thanks
|
|
|
|
|
Hello, the codegurus around the world.;)
Generally speaking, your approaches should work only when the dialog is created.
In a wizard dialog, if we click the back button to go back to the first page,
OnInitDialog is never called since the dialog is already created.
So, try to chanage the tab order to make Edit box the number one by the resource editor.
Try to put the code - m_MyEdit.SetFocus() before return FALSE;
Try to put the same code in CMyPropertyPage::OnSetActive() for clicking the back
button.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hi, I'm wondering if anyone knows how I can get rid of the initial document window that displays when an MFC MDI program first starts up? I am writing a program that would acquire images from a scanner. It would not make sense to have an empty white canvas before acquring any scans.
I believe there's a function OnDocumentClose function I can use, but I have no idea where I can place such a call. Also, how would I create a new canvas? Is there a "OnDocumentOpen" of sort?
Thanks!
Jerry
|
|
|
|