Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 26th, 2005, 6:04 AM   #1
furqanchandio
Newbie
 
furqanchandio's Avatar
 
Join Date: Jan 2005
Posts: 4
Rep Power: 0 furqanchandio is on a distinguished road
windows api programming

hi

i am writing a program using the in VC++ using the windows api

can anyone tell me how to

1) change the positions of the desktop icons
2) get and set the desktop wallpaper
3) how do set my applications icon in the system tray
furqanchandio is offline   Reply With Quote
Old Jan 26th, 2005, 6:49 AM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
~moved
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Jan 26th, 2005, 7:23 AM   #3
drewlander
Newbie
 
drewlander's Avatar
 
Join Date: Jan 2005
Location: Pittsburgh, PA
Posts: 16
Rep Power: 0 drewlander is on a distinguished road
Send a message via AIM to drewlander
Its been a while but I loaded one of my old programs up and will attempt to paste to you what I have for the placing of an icon in the system tray and responding to the messages when a user clicks on that icon:

This goes in your WinMain
//load the icon from a resource
hMainIcon = LoadIcon(hinstance,(LPCTSTR)MAKEINTRESOURCE(IDI_ICON1)); 


structNID.cbSize = sizeof(NOTIFYICONDATA); // sizeof the struct in bytes 
structNID.hWnd = (HWND)hwnd; //handle of the window which will process
this app. messages 
structNID.uID = IDI_ICON1; //ID of the icon that willl appear in the system tray 
structNID.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; //ORing of all the flags 
strcpy(structNID.szTip,"Your Text"); //Text of the tooltip 
structNID.hIcon = hMainIcon; // handle of the Icon to be displayed, obtained from LoadIcon 
structNID.uCallbackMessage = WM_USER_SHELLICON; // user defined message that will be sent as the notification message to the Window Procedure 

	//put the actual icon now
	if(NOTRAY==false)
	{
		Shell_NotifyIcon(NIM_ADD, &structNID); 
	}

And for WinProc to process the messages when a user clicks on the icon in the system tray:

case WM_USER_SHELLICON://case they our over our icon in the system tray
{
 	switch(LOWORD(lParam)) 
	{ 
		//MessageBox(NULL,"IM OVER IT",NULL,NULL);
		case WM_LBUTTONDBLCLK:
	        {
		//open application or do something based on the user double clicking on the icon
		return TRUE; 
		}break;

                case WM_RBUTTONDOWN:	//they right click over our menu
		{
                //get mouse cursor position x and y as lParam has the message itself 
			GetCursorPos(&lpClickPoint);
								
		//place the window/menu there if needed 
								
		//For when the user puts their mouse over our icon in the tray
			hPopMenu = CreatePopupMenu();					InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,ID_OPEN,"O&pen");
								InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,ID_ABOUT,"&About");
								InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,ID_WEBSITE,"&Visit Our Website");
									InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,ID_OPTIONS,"Options");
								InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,ID_CLOSE,"&Close");
							
								
	//workaround for microsoft bug, to hide menu w/o selecting
			SetForegroundWindow(hwnd);
								TrackPopupMenu(hPopMenu,TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_BOTTOMALIGN,lpClickPoint.x, lpClickPoint.y,0,hwnd,NULL);
								SendMessage(hwnd,WM_NULL,0,0);						
				return TRUE; 
		}break;
							
					
	} break;
				
}break;

Then to see if the user clicked on one of the menu items like "open" close" etc...
In case WM_COMMAND:
if(ID_CLOSE == LOWORD(wParam))
	{
	Shell_NotifyIcon(NIM_DELETE,&structNID); //delete our icon
	DestroyWindow(hwnd);					//kill our window
	PostQuitMessage(0);
        }
///you get the idea......

Its been a while, but I think that should be enough to get it so that you can put an icon in the system tray, as long as the icon is in a resource file.

Sorry about the code, I tried for 5 minutes to get it to align right, I do not know how to do it yet at this site. If you have any questons just pm me, but thats the code I have from an old app I have that puts an icon in the system tray.
__________________
On and on....
drewlander is offline   Reply With Quote
Old Jan 30th, 2005, 1:59 PM   #4
furqanchandio
Newbie
 
furqanchandio's Avatar
 
Join Date: Jan 2005
Posts: 4
Rep Power: 0 furqanchandio is on a distinguished road
thanx drew lander
furqanchandio is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:35 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC