DestroyWindow(hStartWnd); hStartWnd = NULL;
DestroyWindow(hwnd);
MainProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam){	static BOOL PrefWndShow;	// PrintfDebugWnd("MainProc: Mess%lx WPARAM%lx LPARAM%lx\n",uMess,wParam,lParam);	switch (uMess)	{      case WM_INITDIALOG:		PrefWndShow = FALSE;		update_subwindow();		MainWndUpdateConsoleButton();		MainWndUpdateTracerButton();		MainWndUpdateListButton();		MainWndUpdateDocButton();		MainWndUpdateWrdButton();		MainWndUpdateSoundSpecButton();		InitPanelWnd(hwnd);		InitCanvasWnd(hwnd);		InitMainToolbar(hwnd);		InitSubWndToolbar(hwnd);	    {			HMENU hMenu = GetSystemMenu(hwnd, FALSE);#if 1			RemoveMenu(hMenu,SC_MAXIMIZE,MF_BYCOMMAND);			RemoveMenu(hMenu,SC_SIZE,MF_BYCOMMAND);#else			EnableMenuItem(hMenu, SC_MAXIMIZE, MF_BYCOMMAND	| MF_GRAYED);			EnableMenuItem(hMenu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED);#endif			EnableMenuItem(hMenu, SC_MOVE, MF_BYCOMMAND | MF_GRAYED);			InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0);			InsertMenu(hMenu, 0, MF_BYPOSITION, SC_SCREENSAVE, "Screen Saver");			InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0);			InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, IDM_STOP, "Stop");			InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, IDM_PAUSE, "Pause");			InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, IDM_PREV, "Prev");			InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, IDM_NEXT, "Next");			InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, IDM_PLAY, "Play");			DrawMenuBar(hwnd);    	}			{				RECT d_rc, w_rc;				GetClientRect ( GetDesktopWindow (), &d_rc );				GetWindowRect ( hwnd, &w_rc );				d_rc.right -= w_rc.right - w_rc.left;				d_rc.bottom -= w_rc.bottom - w_rc.top;				if ( MainWndInfo.PosX < d_rc.left ) MainWndInfo.PosX = d_rc.left; 				if ( MainWndInfo.PosX > d_rc.right ) MainWndInfo.PosX = d_rc.right; 				if ( MainWndInfo.PosY < d_rc.top ) MainWndInfo.PosY = d_rc.top; 				if ( MainWndInfo.PosY > d_rc.bottom ) MainWndInfo.PosY = d_rc.bottom; 				SetWindowPosSize(GetDesktopWindow(),hwnd,MainWndInfo.PosX, MainWndInfo.PosY );			}		return FALSE;	  HANDLE_MSG(hwnd,WM_COMMAND,MainCmdProc);	  case WM_DESTROY:		if(save_playlist_once_before_exit_flag) {			save_playlist_once_before_exit_flag = 0;			w32gSaveDefaultPlaylist();		}		INISaveMainWnd();		break;	  case WM_CLOSE:		if(save_playlist_once_before_exit_flag) {			save_playlist_once_before_exit_flag = 0;			w32gSaveDefaultPlaylist();		}		DestroyWindow(hStartWnd);		hStartWnd = NULL;		break;      case WM_SIZE:		if(wParam == SIZE_MINIMIZED){			if ( IsVisiblePrefWnd () )				PrefWndShow = TRUE;			else				PrefWndShow = FALSE;			HidePrefWnd ();			update_subwindow();			OnHide();		} else if ( wParam == SIZE_RESTORED ) {			if ( PrefWndShow ) {				ShowPrefWnd ();			}		}		return FALSE;	  case WM_MOVE:		if ( ! IsIconic(hwnd) ) {			RECT rc;			GetWindowRect(hwnd,&rc);			MainWndInfo.PosX = rc.left;			MainWndInfo.PosY = rc.top;		}		break;      case WM_QUERYOPEN:		OnShow();		return FALSE;      case WM_DROPFILES:		w32g_send_rc(RC_EXT_DROP, (int32)wParam);		return FALSE;      case WM_HSCROLL: {		  int nScrollCode = (int)LOWORD(wParam);		  int nPos = (int) HIWORD(wParam);		  HWND bar = (HWND)lParam;		  if(bar != hMainWndScrollbarProgressWnd)			  break;		  switch(nScrollCode)		  {			case SB_THUMBTRACK:			case SB_THUMBPOSITION:			  progress_jump = nPos;			  break;			case SB_LINELEFT:			  progress_jump = GetScrollPos(bar, SB_CTL) - 1;			  if(progress_jump < 0)				  progress_jump = 0;			  break;			case SB_PAGELEFT:			  progress_jump = GetScrollPos(bar, SB_CTL) - 10;			  if(progress_jump < 0)				  progress_jump = 0;			  break;			case SB_LINERIGHT:			  progress_jump = GetScrollPos(bar, SB_CTL) + 1;			  break;			case SB_PAGERIGHT:			  progress_jump = GetScrollPos(bar, SB_CTL) + 10;			  break;			case SB_ENDSCROLL:			  if(progress_jump != -1)			  {				  w32g_send_rc(RC_JUMP, progress_jump * play_mode->rate);				  SetScrollPos(hMainWndScrollbarProgressWnd, SB_CTL,							   progress_jump, TRUE);				  progress_jump = -1;			  }			  break;		  }		  break;		}	  break;	  case WM_VSCROLL: {		int nScrollCode = (int) LOWORD(wParam);		int nPos = (int) HIWORD(wParam);		HWND bar = (HWND) lParam;		static int pos = -1;		if(bar != hMainWndScrollbarVolumeWnd)			break;		switch(nScrollCode)		{		  case SB_THUMBTRACK:		  case SB_THUMBPOSITION:			pos = nPos;			break;		  case SB_LINEUP:		  case SB_PAGEUP:			pos = GetScrollPos(bar, SB_CTL) - 5;			if(pos < 0)				pos = 0;			break;		  case SB_LINEDOWN:		  case SB_PAGEDOWN:			pos = GetScrollPos(bar, SB_CTL) + 5;			if(pos > W32G_VOLUME_MAX)				pos = W32G_VOLUME_MAX;			break;		  case SB_ENDSCROLL:			if(pos != -1)			{				w32g_send_rc(RC_CHANGE_VOLUME,							 (W32G_VOLUME_MAX - pos) - amplification);				SetScrollPos(bar, SB_CTL, pos, TRUE);				pos = -1;			}			break;		}	  }	  break;	  case WM_SYSCOMMAND:		switch(wParam){		  case IDM_STOP:		  case IDM_PAUSE:		  case IDM_PREV:		  case IDM_PLAY:		  case IDM_NEXT:		  case IDM_FOREWARD:		  case IDM_BACKWARD:			SendMessage(hwnd,WM_COMMAND,wParam,(LPARAM)NULL);			break;		  default:			break;		}		return FALSE;      case WM_NOTIFY:		switch(wParam) {		  case IDC_TOOLBARWINDOW_MAIN:{			  LPTBNOTIFY TbNotify = (LPTBNOTIFY)lParam;			  switch(TbNotify->iItem){				case IDM_BACKWARD:				  if(TbNotify->hdr.code==TBN_BEGINDRAG){#ifdef W32GUI_DEBUG					  //PrintfDebugWnd("IDM_BACKWARD: BUTTON ON\n");#endif					  PlayerBackward(0,0,0,0,0);					  PlayerForwardAndBackwardEventID =						  timeSetEvent(100, 100, PlayerBackward, 0, TIME_PERIODIC);				  }				  if(PlayerForwardAndBackwardEventID != 0)					  if(TbNotify->hdr.code==TBN_ENDDRAG){#ifdef W32GUI_DEBUG						  //PrintfDebugWnd("IDM_BACKWARD: BUTTON OFF\n");#endif						  timeKillEvent(PlayerForwardAndBackwardEventID);						  PlayerForwardAndBackwardEventID = 0;					  }				  break;				case IDM_FOREWARD:				  if(TbNotify->hdr.code ==TBN_BEGINDRAG &&					 PlayerForwardAndBackwardEventID == 0){#ifdef W32GUI_DEBUG					  //PrintfDebugWnd("IDM_FOREWARD: BUTTON ON\n");#endif					  PlayerForward(0,0,0,0,0);					  PlayerForwardAndBackwardEventID =						  timeSetEvent(100,300,PlayerForward,0,TIME_PERIODIC);				  }				  else if((TbNotify->hdr.code == TBN_ENDDRAG ||						   TbNotify->hdr.code == NM_CLICK ||						   TbNotify->hdr.code == NM_RCLICK) &&						  PlayerForwardAndBackwardEventID != 0)				  {#ifdef W32GUI_DEBUG					  //PrintfDebugWnd("IDM_FOREWARD: BUTTON OFF\n");#endif					  timeKillEvent(PlayerForwardAndBackwardEventID);					  PlayerForwardAndBackwardEventID = 0;				  }				  break;				default:				  break;			  }		    }			break; /* end of case IDC_TOOLBARWINDOW_MAIN */		  default:			break;		}		return FALSE;	case WM_SHOWWINDOW:	{		BOOL fShow = (BOOL)wParam;		if ( fShow ) {			if ( PrefWndShow ) {				ShowPrefWnd ();			} else {				HidePrefWnd ();			}		} else {			if ( IsVisiblePrefWnd () )				PrefWndShow = TRUE;			else				PrefWndShow = FALSE;			HidePrefWnd ();		}		break;	}		break;      default:		return FALSE;    }	return FALSE;}