⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 w32g_syn.c

📁 MIDI解码程序(用VC编写)
💻 C
📖 第 1 页 / 共 4 页
字号:
		Sleep ( sleep_time );	}}void w32g_syn_ctl_pass_playing_list ( int n_, char *args_[] ){	int i;#ifndef TWSYNSRV	w32g_syn_status = syn_AutoStart ? run : stop;#else	w32g_syn_status = run;#endif	for (;;) {		int breakflag = 0;		switch ( w32g_syn_status ) {		default:		case quit:			breakflag = 1;			break;		case run:			{				int result;				char args_[MAX_PORT][10];				char *args[MAX_PORT];				if ( w32g_syn_port_num <= 0 ) {					w32g_syn_status = stop;					break;				} else if ( w32g_syn_port_num > MAX_PORT ) {					w32g_syn_port_num = MAX_PORT;				}				for ( i = 0; i < MAX_PORT; i ++ ) {					args[i] = args_[i];					sprintf ( args[i], "%d", w32g_syn_id_port[i] );				}				SetPriorityClass ( GetCurrentProcess(), processPriority );				SetThreadPriority ( w32g_syn.syn_hThread, syn_ThreadPriority );				result = ctl_pass_playing_list2 ( w32g_syn_port_num, args );				SetPriorityClass ( GetCurrentProcess(), NORMAL_PRIORITY_CLASS );				SetThreadPriority ( w32g_syn.syn_hThread, THREAD_PRIORITY_NORMAL );				if ( result == 2 ) {					w32g_syn_status = stop;				}			}			break;		case stop:			{			w32g_syn_message_t msg;			if ( w32g_message_get ( &msg ) ) {				if ( msg.cmd == W32G_SYN_START ) {					w32g_syn_status = run;					break;				} else {					if ( msg.cmd == W32G_SYN_QUIT ) {						w32g_syn_status = quit;						break;					}				}			}			Sleep ( 500 );			}			break;		}		if ( breakflag )			break;	}#ifndef TWSYNSRV	while ( w32g_syn.quit_state < 1 ) {		PostThreadMessage ( w32g_syn.gui_dwThreadId, MYWM_QUIT, 0, 0 );		Sleep ( 300 );	}#endif	if ( w32g_syn.quit_state < 2 ) w32g_syn.quit_state = 2;}int w32g_syn_do_before_pref_apply ( void ){	w32g_syn_status_prev = none;	for (;;) {		if ( w32g_syn_status == quit )			return -1;		if ( msg_loopbuf_hMutex == NULL ) {			msg_loopbuf_hMutex = CreateMutex ( NULL, TRUE, NULL );		} else {			WaitForSingleObject ( msg_loopbuf_hMutex, INFINITE );		}		if ( w32g_syn_status_prev == none ) 			w32g_syn_status_prev = w32g_syn_status;		if ( w32g_syn_status == stop ) {			return 0;		}		ReleaseMutex ( msg_loopbuf_hMutex );		w32g_message_set ( W32G_SYN_STOP );		Sleep ( 100 );	}}int w32g_syn_do_after_pref_apply ( void ){	ReleaseMutex ( msg_loopbuf_hMutex );	if ( w32g_syn_status_prev == run ) {		w32g_message_set ( W32G_SYN_START );		Sleep ( 100 );	}	return 0;}#ifdef HAVE_SYN_CONSOLE// ****************************************************************************// Edit Ctl.void VprintfEditCtlWnd(HWND hwnd, char *fmt, va_list argList){	 char buffer[BUFSIZ], out[BUFSIZ];	 char *in;	 int i;	 if(!IsWindow(hwnd))		  return;	 vsnprintf(buffer, sizeof(buffer), fmt, argList);	 in = buffer;	 i = 0;	 for(;;){		  if(*in == '\0' || i>sizeof(out)-3){				out[i] = '\0';				break;		  }		  if(*in=='\n'){				out[i] = 13;				out[i+1] = 10;				in++;				i += 2;				continue;		  }		  out[i] = *in;		  in++;		  i++;	 }	 Edit_SetSel(hwnd,-1,-1);	 Edit_ReplaceSel(hwnd,out);}void PrintfEditCtlWnd(HWND hwnd, char *fmt, ...){    va_list ap;    va_start(ap, fmt);    VprintfEditCtlWnd(hwnd,fmt,ap);    va_end(ap);}#if 1void PutsEditCtlWnd(HWND hwnd, char *str){	char *in = str;	int i;	char out[BUFSIZ];	i = 0;	for(;;){		if(*in == '\0' || i>sizeof(out)-3){			out[i] = '\0';			break;    }  	if(*in=='\n'){    	out[i] = 13;    	out[i+1] = 10;			in++;      i += 2;      continue;    }    out[i] = *in;		in++;    i++;  }	if(IsWindow(hwnd)){		Edit_SetSel(hwnd,-1,-1);		Edit_ReplaceSel(hwnd,out);	}}#elsevoid PutsEditCtlWnd(HWND hwnd, char *str){	if(!IsWindow(hwnd))		return;	PrintfEditCtlWnd(hwnd,"%s",str);}#endifvoid ClearEditCtlWnd(HWND hwnd){	char pszVoid[]="";	if(!IsWindow(hwnd))		return;	if(IsWindow(hwnd)){//		Edit_SetSel(hwnd,0,-1);		Edit_SetSel(hwnd,-1,-1);	}	Edit_SetText(hwnd,pszVoid);}static void VersionWnd(HWND hParentWnd){	char VersionText[2024];  sprintf(VersionText,"TiMidity++ %s%s" NLS NLS"TiMidity-0.2i by Tuukka Toivonen <tt@cgs.fi>." NLS"TiMidity Win32 version by Davide Moretti <dave@rimini.com>." NLS"TiMidity Windows 95 port by Nicolas Witczak." NLS"Twsynth by Keishi Suenaga <s_keishi@mutt.freemail.ne.jp>." NLS"Twsynth GUI by Daisuke Aoki <dai@y7.net>." NLS" Japanese menu, dialog, etc by Saito <timidity@flashmail.com>." NLS"TiMidity++ by Masanao Izumo <mo@goice.co.jp>." NLS,(strcmp(timidity_version, "current")) ? "version " : "", timidity_version);	MessageBox(hParentWnd, VersionText, "Version", MB_OK);}static void TiMidityWnd(HWND hParentWnd){	char TiMidityText[2024];  sprintf(TiMidityText," TiMidity++ %s%s -- MIDI to WAVE converter and player" NLS" Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>" NLS" Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>" NLSNLS" Win32 version by Davide Moretti <dmoretti@iper.net>" NLS" GUI by Daisuke Aoki <dai@y7.net>." NLS" Modified by Masanao Izumo <mo@goice.co.jp>." NLSNLS" This program is free software; you can redistribute it and/or modify" NLS" it under the terms of the GNU General Public License as published by" NLS" the Free Software Foundation; either version 2 of the License, or" NLS" (at your option) any later version." NLSNLS" This program is distributed in the hope that it will be useful," NLS" but WITHOUT ANY WARRANTY; without even the implied warranty of"NLS" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the" NLS" GNU General Public License for more details." NLSNLS" You should have received a copy of the GNU General Public License" NLS" along with this program; if not, write to the Free Software" NLS" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA" NLS,(strcmp(timidity_version, "current")) ? "version " : "", timidity_version	);	MessageBox(hParentWnd, TiMidityText, "TiMidity", MB_OK);}// ***************************************************************************//// Console Window//// ***************************************************************************// ---------------------------------------------------------------------------// variablesstatic int ConsoleWndMaxSize = 64 * 1024;static HFONT hFontConsoleWnd = NULL;// ---------------------------------------------------------------------------// prototypes of functionsstatic BOOL CALLBACK ConsoleWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);static void ConsoleWndAllUpdate(void);static void ConsoleWndVerbosityUpdate(void);static void ConsoleWndVerbosityApply(void);static void ConsoleWndValidUpdate(void);static void ConsoleWndValidApply(void);static void ConsoleWndVerbosityApplyIncDec(int num);static int ConsoleWndInfoReset(HWND hwnd);static int ConsoleWndInfoApply(void);void ClearConsoleWnd(void);// ---------------------------------------------------------------------------// Global Functions// Initializationvoid InitConsoleWnd(HWND hParentWnd){	if (hConsoleWnd != NULL) {		DestroyWindow(hConsoleWnd);		hConsoleWnd = NULL;	}	switch(PlayerLanguage){  	case LANGUAGE_ENGLISH:		hConsoleWnd = CreateDialog  			(hInst,MAKEINTRESOURCE(IDD_DIALOG_CONSOLE_EN),hParentWnd,ConsoleWndProc);		break; 	default:	case LANGUAGE_JAPANESE:		hConsoleWnd = CreateDialog  			(hInst,MAKEINTRESOURCE(IDD_DIALOG_CONSOLE),hParentWnd,ConsoleWndProc);	break;	}	ShowWindow(hConsoleWnd,SW_HIDE);	UpdateWindow(hConsoleWnd);	ConsoleWndVerbosityApplyIncDec(0);	CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, ConsoleWndFlag);	Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT), ConsoleWndMaxSize);}// Window Procedurestatic BOOL CALLBACKConsoleWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam){	switch (uMess){	case WM_INITDIALOG:		PutsConsoleWnd("Console Window\n");		ConsoleWndAllUpdate();		return FALSE;	case WM_COMMAND:		switch (LOWORD(wParam)) {		case IDCLOSE:			ShowWindow(hwnd, SW_HIDE);			break;		case IDCLEAR:			ClearConsoleWnd();			break;		case IDC_CHECKBOX_VALID:			ConsoleWndValidApply();			break;		case IDC_BUTTON_VERBOSITY:			ConsoleWndVerbosityApply();			break;		case IDC_BUTTON_INC:			ConsoleWndVerbosityApplyIncDec(1);			break;		case IDC_BUTTON_DEC:			ConsoleWndVerbosityApplyIncDec(-1);			break;		default:			break;		}		switch (HIWORD(wParam)) {		case EN_ERRSPACE:			ClearConsoleWnd();			PutsConsoleWnd("### EN_ERRSPACE -> Clear! ###\n");			break;		default:			break;		}		break;	case WM_SIZE:		ConsoleWndAllUpdate();		return FALSE;	case WM_MOVE:		break;	// See PreDispatchMessage() in w32g2_main.c	case WM_SYSKEYDOWN:	case WM_KEYDOWN:	{		int nVirtKey = (int)wParam;		switch(nVirtKey){			case VK_ESCAPE:				SendMessage(hwnd,WM_CLOSE,0,0);				break;		}	}		break;	case WM_DESTROY:		break;	case WM_CLOSE:		ShowWindow(hConsoleWnd, SW_HIDE);		break;	case WM_SETFOCUS:		HideCaret(hwnd);		break;	case WM_KILLFOCUS:		ShowCaret(hwnd);		break;	default:		return FALSE;	}	return FALSE;}// puts()void PutsConsoleWnd(char *str){	HWND hwnd;	if(!IsWindow(hConsoleWnd) || !ConsoleWndFlag)		return;	hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT);	PutsEditCtlWnd(hwnd,str);}// printf()void PrintfConsoleWnd(char *fmt, ...){	HWND hwnd;	va_list ap;	if(!IsWindow(hConsoleWnd) || !ConsoleWndFlag)		return;	hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT);	va_start(ap, fmt);	VprintfEditCtlWnd(hwnd,fmt,ap);	va_end(ap);}// Clearvoid ClearConsoleWnd(void){	HWND hwnd;	if(!IsWindow(hConsoleWnd))		return;	hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT);	ClearEditCtlWnd(hwnd);}// ---------------------------------------------------------------------------// Static Functionsstatic void ConsoleWndAllUpdate(void){	ConsoleWndVerbosityUpdate();	ConsoleWndValidUpdate();	Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT_VERBOSITY),3);	Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT),ConsoleWndMaxSize);}static void ConsoleWndValidUpdate(void){	if(ConsoleWndFlag)		CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, 1);	else		CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, 0);}static void ConsoleWndValidApply(void){	if(IsDlgButtonChecked(hConsoleWnd,IDC_CHECKBOX_VALID))		ConsoleWndFlag = 1;	else		ConsoleWndFlag = 0;}static void ConsoleWndVerbosityUpdate(void){	SetDlgItemInt(hConsoleWnd,IDC_EDIT_VERBOSITY,(UINT)ctl->verbosity, TRUE);}static void ConsoleWndVerbosityApply(void){	char buffer[64];	HWND hwnd;	hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT_VERBOSITY);	if(!IsWindow(hConsoleWnd)) return;	if(Edit_GetText(hwnd,buffer,60)<=0) return;	ctl->verbosity = atoi(buffer);	ConsoleWndVerbosityUpdate();}static void ConsoleWndVerbosityApplyIncDec(int num){	if(!IsWindow(hConsoleWnd)) return;	ctl->verbosity += num;	RANGE(ctl->verbosity, -1, 4);	ConsoleWndVerbosityUpdate();}#endif // HAVE_SYN_CONSOLE#endif // IA_W32G_SYN

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -