in reply to Re: Prototype problem for XS module
in thread Prototype problem for XS module

Fair enough. It works with my XS code as well. (Also true that windows.h is pulled in by default.)

Now my main problem with NOTIFYICONDATA itself that it needs a hWnd parameter. In other words if I want to have a notify icon I have to have a main window. Currently I have a standalone application which creates a notify icon:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR + lpCmdLine, int nCmdShow) { INITCOMMONCONTROLSEX icc; WNDCLASSEX wc; LPCTSTR MainWndClass = TEXT("Template"); HWND hWnd; HACCEL hAccelerators; HMENU hSysMenu; MSG msg; // Initialise common controls. icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&icc); // Class for our main window. wc.cbSize = sizeof(wc); wc.style = 0; wc.lpfnWndProc = &MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE +(IDI_APPICON), IMAGE_ICON, 0, 0, LR_SHARED); wc.hCursor = (HCURSOR) LoadImage(NULL, IDC_ARROW, IMAGE +_CURSOR, 0, 0, LR_SHARED); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU); wc.lpszClassName = MainWndClass; wc.hIconSm = (HICON) LoadImage(hInstance, MAKEINTRESOUR +CE(IDI_APPICON), IMAGE_ICON, 16, 16, LR_SHARED); // Register our window classes, or error. if (! RegisterClassEx(&wc)) { MessageBox(NULL, TEXT("Error registering window class."), TEXT +("Error"), MB_ICONERROR | MB_OK); return 0; } // Create instance of main window. hWnd = CreateWindowEx(0, MainWndClass, MainWndClass, WS_OVERLAPPED +WINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 200, NULL, NULL, +hInstance, NULL); // Error if window creation failed. if (! hWnd) { MessageBox(NULL, TEXT("Error creating main window."), TEXT("Er +ror"), MB_ICONERROR | MB_OK); return 0; } // Create notify icon NOTIFYICONDATA nid; nid.cbSize = sizeof(NOTIFYICONDATA); nid.hWnd = hWnd; nid.uID = 100; nid.uVersion = NOTIFYICON_VERSION; nid.uCallbackMessage = WM_MYMESSAGE; nid.hIcon = LoadIcon(NULL, IDI_APPLICATION); wcscpy(nid.szTip, TEXT("Notify Icon")); nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; Shell_NotifyIcon(NIM_ADD, &nid); // Load accelerators. hAccelerators = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_AC +CELERATOR)); // Add "about" to the system menu. hSysMenu = GetSystemMenu(hWnd, FALSE); InsertMenu(hSysMenu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); InsertMenu(hSysMenu, 6, MF_BYPOSITION, ID_HELP_ABOUT, TEXT("About" +)); // Show window and force a paint. ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Main message loop. while(GetMessage(&msg, NULL, 0, 0) > 0) { if (! TranslateAccelerator(msg.hwnd, hAccelerators, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } // Finished so withdraw notify icon Shell_NotifyIcon(NIM_DELETE, &nid); return (int) msg.wParam; }
However in the XS code I guess I can't have a WinMain function.

Replies are listed 'Best First'.
Re^3: Prototype problem for XS module
by Anonymous Monk on Feb 06, 2012 at 08:47 UTC