|
Hi!
I need your advice...
My MFC application loads one child dialog from dll.
All goes fine until i do not use keyboard
When i try to use it the dialog doesn't receive focus at all.
Well, i've overloaded the OnSetFocus() of a parent window to set the focus to my child dialog. Child dialog receives now focus, but after the next Tab it lose the focus (focus goes to the next control of the parent window, not child dlg).
How can i fix it?
|
|
|
|
|
ho. I got one question. Can you tell me how to do export a dialog from dll?
|
|
|
|
|
What did you mean?
To export dialog resource or what?
For example, if you just wanna create dialog window you can export some function like this:
HWND CreateMyDialog(HWND hwndParent)
{
HWND hWndDlg = CreateDialog( hInstDll,MAKEINTRESOURCE( IDD_OPTIONS_DLG ),
hwndParent, DlgProc );
return hWndDlg;
}
Where
hInstDll - handle to your dll (for example, you can pass it as the second parameter of the CreateMyDialog()).
DlgProc() - your dialog window procedure (it is in your dll too)
IDD_OPTIONS_DLG - dialog resource (also in your dll)
That is what I did...
PS: if you wanna use CDialog, then you can easily attach CDialog object in your application to any HWND, using CDialog::Attach();
That is what i did.
|
|
|
|
|
I mean I want to export the entire class ,ofcourse contain the resourece and the class. I think I have gotten some tips from your code. thanks
|
|
|
|
|
I need to determine whether or not a user profile is a mandatory profile (a read-only roaming profile). Unfortunately, a profile with a .man extension is not conclusive (this only means the profile was mandatory at some point, but may not be currently mandatory).
I think I need to get this information from the server but I don't know how to go about this.
Thanks!
-Ian
|
|
|
|
|
I am grasping for a solution here...
OK -- got an app with an embedded browser control (you know the IE one).
It updates with messages from our server -- but there's a problem. It clicks. Well, Windows issues a sound event when this updates.
And it's annoying.
Does anyone know of a way to disable the sound events associated with the IE control. I guess I wouldn't want to disable it globally -- just for my control.
Thanks in advance!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weijzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
While there's probably a better/cleaner solution, you might check the HKEY_CURRENT_USER\AppEvents\Schemes\Apps\Explorer\Navigating\.current registry key.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hey
Atm i'm working on a image processing project and i hit some snags. The interface of the program is created with MFC and GDI+, for the processing bit i created my own classes and functions and shoved them in one DLL. Since my classes and GDI+ have some similarities i tried to put my stuff in a namespace. So in stdafx.h i put the headers of the classes i want to import, in a namespace (implicit linking). This gives linker errors saying it cannot find certain functions. A solution would be to place all my code in a namespace already before compiling the dll. Is there a way around this, like that you choose between placing it in a namespace or not?
There is another strange thing. Apparently, when having this dll and calling for example 'bitmap = new Bitmap(..)', new returns NULL, while directly placing all my stuff in the project without the dll it works fine. Any thoughts on that?
|
|
|
|
|
Every example of using Keyboard hooks with MFC seems to be in a DLL. Is there any reason for this? I'm trying to do it in a separate class so my program will be all together. How do you do this? I've pasted what I have so far but the error i get is:
error C2664: 'SetWindowsHookExA' : cannot convert parameter 2 from 'long (int,unsigned int,long)' to 'long (__stdcall *)(int,unsigned int,long)'
None of the functions with this name in scope match the target type
//Keyboard hook callback
LRESULT CALLBACK CKeyboardHook::KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
try
{
KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
if (nCode >= 0)
{
if (wParam == WM_KEYDOWN)
{
BOOL bControlKeyDown = FALSE;
// Check to see if the CTRL key is pressed
bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
if ((pkbhs->vkCode == VK_F) && bControlKeyDown)
{
SendMessage(hWnd,UWM_SETVISIBLE, 0, 0);
ShowWindow(hWnd, SW_RESTORE);
}
}
}
}
catch(...)
{
}
return CallNextHookEx( hkb, nCode, wParam, lParam );
}
BOOL CKeyboardHook::InstallHook()
{
HINSTANCE ppI = AfxGetInstanceHandle();
hkb=SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc,ppI,0);
return TRUE;
}
---- and in the header:
class CKeyboardHook
{
public:
CKeyboardHook();
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
BOOL InstallHook();
...
|
|
|
|
|
c121hains wrote:
Every example of using Keyboard hooks with MFC seems to be in a DLL. Is there any reason for this?
Yes. Global hooks are part of a chain. The hook procedure must be exported in a DLL in order for Windows to call it.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Ohhh i see.
There's a setting in visual studio (statically link objects or something) so that i can compile my EXE and DLL into one EXE right? How do i do this?
|
|
|
|
|
"Dynamic linking" is the process that Windows uses to link a function call in one module to the actual function in the library module. "Static linking" occurs at compile/link time when you link various object (.OBJ) modules, run-time library (.LIB) files to create a Windows .EXE file. Dynamic linking occurs at run time. With static linking, the linker copies the code for the function into the application's executable file. With dynamic linking, a link is established when the program is loaded into memory or while it is running. So even though you can static link your DLL to your EXE, you still need a DLL that contains the exported hook function.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
That's not true. You can export the function in your EXE just as well, a DLL and EXE are basically the same, they just have different entry points and are treated differently by Windows' PE loader. I tried the exact same thing with the keyboardhook once this guy is trying and it worked fine, in one EXE. The problem is, when I tried it without MFC for some reason it didn't work, but it did work with MFC. The hook function was simply in my EXE's export table, so windows just loaded the same EXE that made the call for the hooking registration in memory (or used the same copy i dunno what it does exactly) and used that function as the hook procedure.
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
I tried the exact same thing with the keyboardhook once this guy is trying and it worked fine, in one EXE.
Did you use a local or a global hook? The former will work in both a DLL and an EXE, while the latter will only work in a DLL.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
The keyboard hook proc must be either a global function or a static member of your class.
Also, hooks are in dll's if they are global hooks (work no matter where teh input focus is). If the hook is in your .exe then it will only catch keyboard events when the exe has the keyboard focus.
|
|
|
|
|
|
Aside from msdn.microsoft.com[^], can you be a bit more specific? Win32 SDK is a very broad term.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
I've used this small site in the past:
Catch 22
Painted on the side of a dog trainer's van: SIT HAPPENS
|
|
|
|
|
This site is great.
Thanks.
|
|
|
|
|
I have to add a column/bar chart into an MFC42 VC++6 dialog app. What kind of component/ocx/library would you chose to do that?
Thanks,
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Hi All
Does anyone know how to programmatically set the size of a dialog box ??
thanks
Si
|
|
|
|
|
|
MoveWindow() ???
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
I don't want to use firewall to reject SYN connection.
Can I use SPI(service provider interface )to achieve reject connection ?
If could make it,please tell me how to do it.
Thanks a lot.
|
|
|
|