In the message map definition use: ON_CONTROL_RANGE(EN_KILLFOCUS, IDE_BOX1, IDE_BOX4, OnKillFocusEdit)
and declare the handler as: OnKillFocusEdit(UINT nID)
This will reflect EN_KILLFOCUS notification message from all controls in range IDE_BOX1 - IDE_BOX4 and pass the appropriate ID to nID parameter.
"A piece of paper is an ink-lined plane.
An inclined plane is slope up.
A slow pup is a lazy dog.
Q.E.D.: A piece of paper is a lazy dog."
Whether or not the concatination works here has nothing to do with the Execute method. The Execute method is not involved in the concatination of "Select * from table where ID='" + val, it would be called with the result of the concatination as a parameter.
I have created a service out of a program using the program SRVANY.EXE.
When you click the minimise button of the program, an icon of the program is automatically added to the tray bar. When you double click the icon, the program is shown.
Now, when i minimise the program, which runs as interactive service with local system account .. it is added to the tray bar. When i log out and then log in, the icon is removed from the tray bar and i still can see the program (process) in my task manager so it still runs.
I thought my code removed the icon itself, so i checked that but the 'WM_DESTROY' isn't send by the system when you logout so my program doesn't remove it itself (Windows does).
Is there any way around this? And does anyone know which messages the service manager sends to the program to stop or reboot? I would highly appreciate any help.
I guess it is due to recreation of the tasktray and you are not notified and you are not putting ur icon back on the tasktray....
you should listen to the user defined message with message string "TaskbarCreated"
const UINT WM_TASKBARCREATE = RegisterWindowMessage(_T("TaskbarCreated"));
when you get this message update the taskbar icon.
Yes, now i get the Windows message that the tray bar is created and i add my icon to it. So that problem is solved Thanks alot!
However, i got one problem left. Every time when i run the service and log off and then i login a second time .. the program is shown correctly with an interface (interactive using local system account). But i can't use the menu .. it's somehow impossible to use the menu or do some actions with the program. How is this possible? (never had that problem until i used it as service)
I only have this weird problem on my computer. On any other computer it works great.
I am using SetWindowsHookEx(...) to set WH_CBT hook, but the problem is that it never get called in system context. But only works on my application's main window. Don't know whats wrong? May be i am missing a simple thing that is causing the hook to install as system wide.
Here is the piece of code i am using to install the hook
//Installs the hook
//g_hInstDll is set to hInstance in DllMain() g_hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)Dll_HookProc,(HMODULE)g_hInstDll,0);
Is there anything specific i need to do in order to install hook system wide?
well static can be or is unnecessary but exporting the Hook proc doesn't make any sense, coz the calling application can only set the hook or remove the hook, hook proc will be used internally, so i think need not to export the hook proc.
Anyway thanks a lot for the reply, if you have some suggestion like setting up my project (i am using VC++ 6 may be i am not setting up the project), then it might be helpful.
if you can send me the basic code for your hook dll (Only hook setup code), it can solve the issue.
My basic code is the same as yours apart from the definition of the hook function.
The DLL will be loaded into the adderess space of all the other application running on your system, they will call the hook function so exporting it could make a difference. Try it, it will only take a minute to test it.
I have solved my problem, infact there was no problem at all. What i was trying to do was to debug a system wide installed hook in the VC debugger, which is not possible as such, so all the events i got were from the application i was dubugging in context with. So if i run the program (not debug it), it works fine. Thanks a lot for your patience and help. Now the real problem is still there, how to debug my program (system wide hook)?
I switch the default desktop to mine,and i produce taskbar myself.So i want to receive some message when system shell is ready to launch an application and to terminate an application.
how can i do? hook? or other?