C
[COLOR=red][COLOR=Black]#include <string.h>
#include <windows.h>
#include <shellapi.h>
#define WM_SHELLNOTIFY WM_USER+5
HINSTANCE hInst;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
HWND glob;
NOTIFYICONDATA nid = {0};
HMENU hPopup;
char winclass[] = "Lutschendes Prog";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR CmdLine, int nCmdShow) {
MSG msg;
BOOL bRet;
hInst=hInstance;
HWND hWnd;
int xwin=0;
int ywin=0;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = winclass;
RegisterClass (&wc);
xwin=GetSystemMetrics(SM_CXSCREEN);
ywin=GetSystemMetrics(SM_CYSCREEN);
xwin /= 2;
xwin -= 200; //400 Breit
ywin /= 2;
ywin -= 50; //100 Hoch
hWnd = CreateWindow (winclass, "WinClipper", WS_OVERLAPPEDWINDOW, xwin, ywin, 400, 100, NULL, NULL, hInstance, NULL);
glob=hWnd;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while( (bRet = GetMessage(&msg, NULL, 0, 0)) != 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
HDC hdc;
PAINTSTRUCT ps;
HBRUSH hbr;
RECT crect, wrect;
POINT pt;
if (msg == WM_SIZE && wParam==SIZE_MINIMIZED) {
hPopup=CreatePopupMenu();
AppendMenu(hPopup,MF_STRING,1000,"&Close Server");
ShowWindow(hWnd, SW_HIDE);
nid.cbSize=sizeof(NOTIFYICONDATA);
nid.uID=100;
sprintf(nid.szTip,"Hallo");
nid.uFlags=NIF_ICON;
nid.hIcon=LoadIcon (NULL, IDI_APPLICATION);
Shell_NotifyIcon(NIM_ADD, &nid);
}
if (msg == WM_DESTROY) {
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}[/COLOR] [/COLOR]
Alles anzeigen
das Fenster verschwindet, wie es soll, das Tray erscheint, wie es soll, und verschwindet dann, sobald man mit der Maus drüber geht, was es nicht soll. Warum verschindet das Tray?