|
Hi,
I have written a program to add an icon in the system tray.
But i want the icon to remain in the systray even after i exit the application and the application should start on clicking the icon.
how can i do that?
Thanks
U get wht u Give
|
|
|
|
|
Write a handler for WM_SYSCOMMAND and in it check nID. if it is SC_CLOSE, dont shut down the application, just hide it or minimize it to system tray, whatever you want to do.
"I would luv to change the world, but they wont give me the source code"
My Articles
|
|
|
|
|
Just don't exit the application. Hide the main window when user wants to exit. Show it when user clicks on icon.
--OR--
Write another app, which also has the same icon in the tray. Just a small app which never shows its interface, it is hidden. When user exits main app, it starts this small app before exiting. When user clicks on icon, this small app starts the main app, and exits itself.
Good code for life.
|
|
|
|
|
charu123 wrote:
But i want the icon to remain in the systray even after i exit the application
You can't do that. Tray icons work by sending window messages, so if your app exits there is no longer a window to send messages to.
You'll need two apps, your main app, and one that's responsible for the tray icon.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
plz tell me how to concatenate 2 values in vc++?
suppose i display in the editbox value 123..
and the next time i display 34.
i want that to come as combined like "123 34"
plz help me with this!!!!!!!
|
|
|
|
|
Let the str is DDX variable of your Edit Box.
Now Let you have updated your edit box with 123.
i.e. this way
str="123";
this->UpdateData(FALSE);
now you want to concatenate the 34 in that box
call
UpdateData(TRUE);
str+="34";
//again update the values
UpdateData(FALSE);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
but my values r in double....
i want the double values to b concatenated
|
|
|
|
|
With double is just impossible ! What happens in this case:
Value1 = 2.1234
Value2 = 5.5678
??? What will you do with your floating points ??
|
|
|
|
|
double d1 = 123.0;
double d2 = 34.0;
char s[16];
sprintf(s, "%.0f %.0f", d1, d2); // 123 34
or with MFC:
CString str;
str.Format(%.0f %.0f", d1, d2); // 123 34
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
ThatsAlok wrote:
Let the str is DDX variable of your Edit Box.
Now Let you have updated your edit box with 123.
i.e. this way
str="123";
this->UpdateData(FALSE);
now you want to concatenate the 34 in that box
call
UpdateData(TRUE);
str+="34";
//again update the values
UpdateData(FALSE);
Alok,
Don think i'm bashing at your reply. But the suggestion you gave does not follow any standards of MFC dialog based programming. Just to retrieve a variable and update it back again you are calling UpdateData three times !!!. This can have serious consiquences, since all other CDialogs variables are also effected by this, which will not be desired at most time.
suhredayan There is no spoon.
|
|
|
|
|
suhredayan® wrote:
Don think i'm bashing at your reply
No Buddy, No hard feeling critisism helps in improving Programming!, you are always always welcome to correct me when ever i am wrong!
suhredayan® wrote:
Just to retrieve a variable and update it back again you are calling UpdateData three times !!!.
I just given a small overview how to solve the problem. anyway we can use GetWindowText too or raw apis like GetDlgItem*
suhredayan® wrote:
This can have serious consiquences, since all other CDialogs variables are also effected by this, which will not be desired at most time.
Yeah, you are 100% correct! How Silly i am
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
You have a lot of different solutions...
Are the two 'values' you are speaking purely value (no string I mean) ? And the 'output' is expressed as a string or still a value ??
If these are string, you can use the strcat function.
If these are integers, a solution would be to find out the number of digits used by the second value, then multiply the first value by 10 power this number and then finally add the second number to the previous result:
34 -> 2 digits (10^2 = 100)
123 * 100 = 12300
123 + 34 = 12334 (the number you wanted)
To find the number of digits, use the following algorithm:
int digits = ceil(log(10,Value));
Hope this helps
|
|
|
|
|
You can convert a number to a string with _itoa (for integers look MSDN for other types) or with the Format member of the CString class:
int number = 123;
CString s;
s.Format("%d", number);
Then you concatenate the strings and convert the result back, for example with _atoi.
Hope this helps.
MS
|
|
|
|
|
hello,
what i have is a list of all open windows and running processes. i have a hwnd to each window and its processid. all what i need - i thought.
my problem is, i want to list all running tasks in a listbox and show each window´s icon in the listbox... but how to get the icon? i used attached the handle to the window with an CWnd and called hIcon = pWnd.GetIcon(true); - after that i detached that handle from the CWnd... but it only work at 2 apps ;o) so: how to get ann icon of another running process/window???
i searched the net all the night and didn´t found any interesting articles...
cheers,
vertex_x
|
|
|
|
|
AfxGetInstance...()->LoadIcon()
i don't remember exactly the fisrt function name, but it might be something like this...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
you ment AfxGetApp()? that works only on your own created process as far as i know... i don´t know a way to do something linke CWnd::AfxGetApp()->... also ::AfxGetApp is no function in the global namespace...
thanks 4 reading ;o)
cheers,
arné
|
|
|
|
|
hum, yes your right...
what about LoadModule() ? (or smthing similar ? )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Check out for this api
[ExtractIcon]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I get nice results by using SendMessage with WM_GETICON. If that is invalid there is always GetClassLong with an index of GCL_HICON.
HICON icon;
icon = (HICON) ::SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0);
icon = (HICON) ::GetClassLong(hwnd, GCL_HICON);
|
|
|
|
|
thats it! thanks a lot! )
hIcon = (HICON)::SendMessage(hwnd, WM_GETICON, ICON_BIG, 0);
if(hIcon == NULL)
hIcon = (HICON)::GetClassLong(hwnd, GCL_HICON);
if(hIcon == NULL)
hIcon = (HICON)::GetClassLong(::GetParent(hwnd), GCL_HICON);
works - no just looking when hIcon is still NULL, if there is a ICON_SMALL )
cheers and thanx
vertex_x
|
|
|
|
|
thanks friend this helped me too...
|
|
|
|
|
Hi guys
I am facing a problem on how to make the Bitmap Added without disappearing when i minimize or maximize screen or just moving the program. My Bitmap graphics always disappear, i do not know how to use UpdateWindow Function to prevent this from happening can i have any demo projects that can guide me through this problem
Thank You
|
|
|
|
|
Hi,
Did you tried to redraw the bitmap window?
In your OnPaint() function try : m_BitmapWindow.RedrawWindow();
Regards,
Eli
|
|
|
|
|
I did not use OnPaint Function to create the bitmaps
I created a ShowBitmap(int x, int y, int type) function and some parameters for displaying the Bitmap, so what kind of other Functions would you recommend for me? Can UpdateWindows() be use?
|
|
|
|
|
I did not use OnPaint Function to create the bitmaps
I created a ShowBitmap(int x, int y, int type) function and some parameters for displaying the Bitmap, so what kind of other Functions would you recommend for me? Can UpdateWindows() be use?
|
|
|
|