![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 4
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
~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 |
|
|
|
|
|
#3 |
|
Newbie
|
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.... |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jan 2005
Posts: 4
Rep Power: 0
![]() |
thanx drew lander
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|