Quote:Original post by slippnslide
Yes, I see it, but it's not working when I implement it into my code.
That's not very specific. What does the compiler say? Does it compile at all?
Quote:Original post by slippnslide
Yes, I see it, but it's not working when I implement it into my code.
case WM_SYSCOMMAND: { if(wParam == SC_MINIMIZE) { ShowWindow(hWnd, SW_HIDE); } break;
Quote:Project : Win32 Application
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\John\Desktop\derp--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
main.cpp: In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
main.cpp:57: warning: passing NULL used for non-pointer converting 1 of `HWND__* CreateWindowExA(DWORD, const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'
Compiling: Win32GUI.rc
Linking executable: C:\Documents and Settings\John\Desktop\derp\Win32GUI.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 1 warnings
// include the basic windows header file#include <windows.h>#include <windowsx.h>#include <shellapi.h>#include "resource.h"#define WM_TRAYMESSAGE (WM_USER + 1)// for NOTIFYICONDATANOTIFYICONDATA nid;// the WindowProc function prototypeLRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);// the entry point for any Windows programint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ // the handle for the window, filled by a function HWND hWnd; // this struct holds information for the window class WNDCLASSEX wc; // clear out the window class for use ZeroMemory(&wc, sizeof(WNDCLASSEX)); // fill in the struct with the needed information wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WindowProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszClassName = "WindowClass1"; // register the window class RegisterClassEx(&wc); // create the window and use the result as the handle hWnd = CreateWindowEx(NULL, "WindowClass1", // name of the window class "Our First Windowed Program", // title of the window WS_OVERLAPPEDWINDOW, // window style 300, // x-position of the window 300, // y-position of the window 500, // width of the window 400, // height of the window NULL, // we have no parent window, NULL NULL, // we aren't using menus, NULL hInstance, // application handle NULL); // used with multiple windows, NULL // fill the struct for NOTIFYICONDATA with the needed info nid.cbSize = sizeof(NOTIFYICONDATA); nid.hWnd = hWnd; nid.uID = 0; nid.uFlags = NIF_ICON | NIF_TIP; nid.uCallbackMessage = WM_TRAYMESSAGE; HICON hIco = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON)); nid.hIcon = hIco; strncpy( nid.szTip, "App name", 64 ); // display the window on the screen ShowWindow(hWnd, nCmdShow); Shell_NotifyIcon(NIM_ADD, &nid); if(hIco) { DestroyIcon(hIco); } // enter the main loop: // this struct holds Windows event messages MSG msg; // wait for the next message in the queue, store the result in 'msg' while(GetMessage(&msg, NULL, 0, 0)) { // translate keystroke messages into the right format TranslateMessage(&msg); // send the message to the WindowProc function DispatchMessage(&msg); } // return this part of the WM_QUIT message to Windows return msg.wParam;}// this is the main message handler for the programLRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ // sort through and find what code to run for the message given switch(message) { // this message is read when the window is closed case WM_DESTROY: { // close the application entirely Shell_NotifyIcon(NIM_DELETE, &nid); PostQuitMessage(0); return 0; } break; /* case WM_TRAYMESSAGE: { if(lParam == WM_LBUTTONDOWN) { Shell_NotifyIcon(NIM_DELETE, &nid); } } break;*/ case WM_SIZE: { if(wParam == SIZE_MINIMIZED) { ShowWindow(hWnd, SW_HIDE); } } break; } // Handle any messages the switch statement didn't return DefWindowProc (hWnd, message, wParam, lParam);}