case WM_TRAY_NOTIFY: switch (lparam) {  case WM_RBUTTONDOWN: break;   case WM_LBUTTONUP: if (IsWindowVisible(mainWindow)) { ShowWindow(mainWindow, SW_HIDE); UpdateWindow(mainWindow); } else { ShowWindow(mainWindow, SW_NORMAL); UpdateWindow(mainWindow); } break; }  return TRUE;
LRESULT CALLBACK wpWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ){	LOGFONT lfont;	NMHDR *notify = (NMHDR*)lparam;	HDC dc;		switch( msg )	{	case WM_CTLCOLORSTATIC:		if ((HWND)lparam == lblUptime) {			dc = (HDC)wparam;			//SelectObject( dc, GetStockObject(ANSI_VAR_FONT) );			SetTextColor(dc, RGB(0xAF, 0xAF, 0xAF));			SetBkMode( dc, TRANSPARENT );			//SelectObject( dc, GetStockObject( SYSTEM_FONT ) );			return (LRESULT)hbBackground;		} else if ((HWND)lparam == statusIcon) {			dc = (HDC)wparam;			SetBkMode( dc, TRANSPARENT );			return (LRESULT)hbBackground;		}		return DefWindowProc( hwnd, msg, wparam, lparam );	case WM_COMMAND:		if( handleMenuSelect( wparam ) )			return 0;		break;	case WM_CREATE:		hLogo = LoadBitmap( appInstance, MAKEINTRESOURCE( IDB_LOGO ) );		// Create Richedit Box		logWindow = CreateWindow( RICHEDIT_CLASS, 0, ES_LEFT|ES_MULTILINE|ES_AUTOVSCROLL|ES_READONLY|WS_CHILD|WS_VISIBLE|WS_VSCROLL, 0, 0, 10, 10, hwnd, (HMENU)CONTROL_LOGWINDOW, appInstance, 0 );		if( logWindow == 0 )		{			MessageBox( 0, QString( "Couldn't create the logwindow: " + getErrorString() ).latin1(), "Wolfpack", MB_OK|MB_ICONERROR );			DestroyWindow( hwnd );			return TRUE;		}		logLimit = SendMessage( logWindow, EM_GETLIMITTEXT, 0, 0 );		// Set up the fonts we need		ZeroMemory(&lfont, sizeof(LOGFONT));		qstrcpy(lfont.lfFaceName, "Arial");		lfont.lfQuality = ANTIALIASED_QUALITY;		lfont.lfHeight = -MulDiv(10, GetDeviceCaps(GetWindowDC(hwnd), LOGPIXELSY), 72);		arialFont = CreateFontIndirect( &lfont );		ZeroMemory( &lfont, sizeof( LOGFONT ) );		qstrcpy( lfont.lfFaceName, "Fixedsys" );		lfont.lfQuality = ANTIALIASED_QUALITY;		font = CreateFontIndirect( &lfont );		if ( !font )		{			ZeroMemory( &lfont, sizeof( LOGFONT ) );			qstrcpy( lfont.lfFaceName, "Courier" );			font = CreateFontIndirect( &lfont );		}           		// Set the font of our logwindow		SendMessage( logWindow, WM_SETFONT, (WPARAM)font, 0 );		SendMessage( logWindow, EM_SETBKGNDCOLOR, 0, (LPARAM)RGB(0,0,0) );		// Default Charformat        ZeroMemory( &cf, sizeof( CHARFORMAT ) );        cf.cbSize = sizeof( CHARFORMAT );        cf.dwMask = CFM_COLOR;        cf.crTextColor = RGB( 0xAF,0xAF,0xAF ); 		SendMessage( logWindow, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf );		SendMessage( logWindow, EM_AUTOURLDETECT, TRUE, 0 );		SendMessage( logWindow, EM_SETEVENTMASK, 0, ENM_LINK|ENM_MOUSEEVENTS|ENM_KEYEVENTS );		// Create InputWindow		inputWindow = CreateWindow( "EDIT", 0, ES_LEFT|ES_AUTOHSCROLL|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_TABSTOP, 0, 0, 10, 10, hwnd, (HMENU)CONTROL_INPUT, appInstance, 0 );		bmpLogo = CreateWindow( "STATIC", 0, SS_BITMAP|WS_CHILD|WS_VISIBLE, 0, 0, 586, 87, hwnd, 0, appInstance, 0 );		SendMessage( bmpLogo, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hLogo );		statusIcon = CreateWindow("STATIC", 0, SS_ICON|WS_CHILD|WS_VISIBLE, 380, 15, 0, 0, hwnd, 0, appInstance, 0);		SendMessage(statusIcon, STM_SETIMAGE, IMAGE_ICON, (LPARAM)iconRed);		lblUptime = CreateWindow( "STATIC", 0, WS_CHILD|WS_VISIBLE, 400, 15, 250, 25, hwnd, 0, appInstance, 0 );		SendMessage( lblUptime, WM_SETFONT, (WPARAM)arialFont, 0 );		// Set up our timer to refresh the nice Uptime Counter		uptimeTimer = SetTimer( NULL, 0, 500, 0 );		return 0;	// Autosize our Window Elements	case WM_SIZE:		if( logWindow && inputWindow && wparam != SIZE_MINIMIZED && wparam != SIZE_MAXHIDE )		{			unsigned int width = LOWORD( lparam );			unsigned int height = HIWORD( lparam );			// Measure the Height of our Input Field			if( !inputHeight )			{				HFONT font = (HFONT)SendMessage( mainWindow, WM_GETFONT, 0, 0 );				if( !font )					font = (HFONT)GetStockObject( SYSTEM_FONT );				LOGFONT logfont;				if( GetObject( font, sizeof( LOGFONT ), &logfont ) == sizeof( LOGFONT ) )					inputHeight = logfont.lfHeight + 4;			}			// Note: 88 pixel spacer are always on top			MoveWindow( logWindow, 0, 88, width, height - inputHeight - 88, TRUE );			MoveWindow( inputWindow, 0, height - inputHeight, width, inputHeight, TRUE );		}		return 0;	case WM_PAINT:		drawWindow( hwnd );		return DefWindowProc( hwnd, msg, wparam, lparam );	case WM_NOTIFY:		if( wparam == CONTROL_LOGWINDOW )		{					if( notify->code == EN_LINK )			{				ENLINK *link = (ENLINK*)notify;				if( link->msg == WM_LBUTTONDOWN )				{					char *string = new char[ ( link->chrg.cpMax - link->chrg.cpMin ) + 1 ];										TEXTRANGE tr;					tr.chrg = link->chrg;					tr.lpstrText = string;					SendMessage( logWindow, EM_GETTEXTRANGE, 0, (LPARAM)&tr );					// String contains the link					ShellExecute( mainWindow, "open", string, 0, 0, SW_NORMAL );					delete [] string;				}							}			else if( notify->code == EN_MSGFILTER )			{				/*MSGFILTER *msg = (MSGFILTER*)notify;				// Append to the Input Control				if( msg->msg == WM_CHAR )				{					SendMessage( inputWindow, WM_SETFOCUS, 0, 0 );					SendMessage( inputWindow, WM_CHAR, msg->wParam, msg->lParam );				}*/			}		}		return 0;			case WM_CLOSE:		keeprun = 0;				if (canClose) {			DestroyWindow( mainWindow );		}		return 1;	case WM_DESTROY:		KillTimer(NULL, uptimeTimer);		DestroyMenu(hmMainMenu);		DeleteObject(hLogo);		DeleteObject(hbSeparator);		DeleteObject(hbBackground);		DeleteObject(iconRed);		DeleteObject(iconGreen);		keeprun = 0;		PostQuitMessage(0);		return 0;	}	return DefWindowProc( hwnd, msg, wparam, lparam ); }