|
you can make it a windows application instead of a console application.
|
|
|
|
|
In other words, if you make it a windows application, but don't create a window, it will be really hidden! The task name will show up in task bar, but there will be no visible widnow.
Now, the soapbox. The Kodak EasyShare shoftware does this crap. And, every time I go to shutdown my wife's Windows XP box, I get a warning about "user has 1 program running you could lose data .. blah blah blah..." and this is very annoying, because an INEXPERIENCED user would be scrathing their head trying to figure out where is the G_____N app that is running??
So, I would also encourage you to diligently process any notifications or other events (difficult if no window..) that he system would send you regarding shutting down or logging off.
No shirt, no shoes, no brains, no service.
|
|
|
|
|
Say your application name is MyProg.Exe, and is located in C:\Program Files\My Company, then add an entry for your program in the following registry key, as follows.
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\"C:\Program Files\My Company\MyProg.exe"
Windows will run any program inside this key automatically, on startup. I dont know what kind of an app it is. If it has nothing to do with the user, then it would be better to make it as a service.
Regards,
Rajesh R. Subramanian.
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Hi All,
I am a novice and would appreciate any help you guys can give me here. I want to write a code which will tell me with which window the user is currently interacting. The code I am using is
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
int test;
HWND hwnd;
MSG Msg;
TCHAR szBuf[80];
int nMaxCount;
DWORD d;
int nCmdShow;
while(1)
{
hwnd=GetActiveWindow();
if(hwnd == NULL)
{
MessageBox(NULL, "No window is currently active!","Error!" MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
test=GetWindowText(hwnd,szBuf,80);
}
}
Here GetActiveWindow returns NULL .If I use GetForegroundWindow, I get the handle of the IDE i.e VC++ and so on. How do I write a code which will tell me which is the window the user is currently interacting with?. My ultimate aim is to figure out which is the currently active window and grab images from the window. So in this case would I need to run an exe from my main code which will give me the handle to the active window? Any better idea how do I do it? Waiting for replies from the experts out there!!
-confused newbie
|
|
|
|
|
GetActiveWindow returns windows relative the the current thread, not the entire system.
From the docs:
The GetActiveWindow function retrieves the window handle to the active window attached to the calling thread's message queue.
Syntax
HWND GetActiveWindow(VOID);
Return Value
The return value is the handle to the active window attached to the calling thread's message queue. Otherwise, the return value is NULL.
GetForegroundWindow is the one you want to use. The docs say:
The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
|
|
|
|
|
Hey Ahz,
Thanks for clearing tht up!!!!. Now assuming I use GetForegroundWindow, I get the handle to the foreground window. In my case I get the handle to the VC IDE becuase thats the window I am currently interacting.I want to have a standalone application that will run in the background and give me the handle to the foreground window.. how do i do that?. Or can I launch this exe from another program. The issue is something like this...anytime a user is interacting with a window, I need to get a handle to that window and then selectively capture some graphics from that window. How do i proceed in this case? THanks!!!
|
|
|
|
|
just run your program from the Run key or place it in all-users startup directory.
Look into using SetWindowsHookEx
|
|
|
|
|
Hey Ahz, I will try using SetWindowsHookEx and see. Thanks. Can you give me a high level idea how my program should look like..I mean how do I implement it. For ex should I have a seperate application for letting me know which is the active window and should my main prog run this exe, get the handle from it (is this possible?) use the handle to grab some image from the window and then do some processing on the image...Yeah m a confused newbie so pls bear with my inane questions! THanks again!
|
|
|
|
|
wilbur_logan wrote: I want to have a standalone application that will run in the background and give me the handle to the foreground window.. how do i do that?.
Clearly, you need to write a system wide hook. Depending on your need, it may be a keyboard hook, a mouse hook, or etc etc.
Regards,
Rajesh R. Subramanian.
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
-- modified at 23:23 Wednesday 21st December, 2005
|
|
|
|
|
Thanks for all the suggestions guys!
|
|
|
|
|
|
std::vector<MyClass> foo;
int someIndex = 10;
foo.erase(foo.begin() + someIndex);
-- modified at 15:40 Wednesday 21st December, 2005
|
|
|
|
|
|
|
|
Helo!
What should i do to notify an envent to de Frame when y click left mouse on a view
thanks!
|
|
|
|
|
handle WM_LBUTTONDOWN
if using MFC: add an OnLButtonDown handler
|
|
|
|
|
thanks!
but wat i need is to resize the windowframe when i click on the client area
|
|
|
|
|
Look into the CFrameWnd::RecalcLayout function.
No shirt, no shoes, no brains, no service.
|
|
|
|
|
|
For MFC, use CListBox::InsertString() . Otherwise, send the control a LB_INSERTSTRING message.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
DeleteString() and InsertString()
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
|
Strings are numbered from zero to count_of_strings minus one, so to replace a string at a certain index, first delete the existing string, then insert the replacement
int SwapString(CListBox &Box, int Index, LPCTSTR NewString)
{
ASSERT (Index < Box.GetCount());
Box.DeleteString(Index);
return Box.InsertString(Index, NewString);
} If you insert the replacement string first, you then have to increase the index value before you delete the old string or else you will just end up deleting the string you just inserted.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|