Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Tray Icon

pjn9656pjn9656 Member Posts: 11
Here we go again:
I would like to load a tray icon. I will be using hide in the showwindow and just need to show the icon and allow the user to right click to end program. The default windows icon would be perfect. Can someone show me coded for this. I thought i had it wheni loked at the Notify icon structure but no go. I have the simpleest window.

#include

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)

{

WNDCLASS WndClass;
WndClass.style = 0;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.lpfnWndProc = WndProc;
WndClass.hInstance = hInstance;
WndClass.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
WndClass.lpszMenuName = 0;
WndClass.lpszClassName = "WinProg";


RegisterClass(&WndClass);

HWND hWindow;

hWindow = CreateWindow("WinProg","Window",WS_OVERLAPPEDWINDOW,0,0,400,400,NULL,NULL,hInstance,NULL);

ShowWindow(hWindow, nCmdShow);

UpdateWindow(hWindow);

MSG Message;

while (GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}

return (Message.wParam);

}

LRESULT CALLBACK WndProc(HWND hWnd,UINT uiMessage,WPARAM wParam, LPARAM lParam)

{



switch(uiMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;

default:
return DefWindowProc(hWnd,uiMessage,wParam,lParam);

}
}

Comments

  • carlycarly Member Posts: 46
    It's a Win32 FAQ, since 1995.
    See on Win32 reference group (news://nntp.aioe.org/comp.os.ms-windows.programmer.win32)
Sign In or Register to comment.