📄 voice.c
字号:
(WPARAM) 16,
(LPARAM) 0);
SendMessage(GetDlgItem(hDlg,IDC_DB_PWD),
WM_SETTEXT,0,(LPARAM) system_db.DB_PWD);
//把编辑控件中可输入的字符数目限定为n个
SendDlgItemMessage(hDlg,IDC_DB_DATABASE,
EM_SETLIMITTEXT,
(WPARAM) 20,
(LPARAM) 0);
SendMessage(GetDlgItem(hDlg,IDC_DB_DATABASE),
WM_SETTEXT,0,(LPARAM) system_db.DB_DATABASE);
return(TRUE);
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
GetCurrentDirectory(200,szBuffer);//取得执行文件的路径
wsprintf(ControlFile,"%s%s",szBuffer,"\\voice.ini");
SendDlgItemMessage(hDlg,IDC_DB_SERVER,WM_GETTEXT,
(WPARAM) 80,(LPARAM) system_db.DB_SERVER);
WritePrivateProfileString("DB_SET","SERVER",system_db.DB_SERVER,ControlFile);//写ini文件项值
SendDlgItemMessage(hDlg,IDC_DB_USER,WM_GETTEXT,
(WPARAM) 80,(LPARAM) system_db.DB_USER);
WritePrivateProfileString("DB_SET","USER",system_db.DB_USER,ControlFile);//写ini文件项值
SendDlgItemMessage(hDlg,IDC_DB_PWD,WM_GETTEXT,
(WPARAM) 80,(LPARAM) system_db.DB_PWD);
WritePrivateProfileString("DB_SET","PASSWORD",system_db.DB_PWD,ControlFile);//写ini文件项值
SendDlgItemMessage(hDlg,IDC_DB_DATABASE,WM_GETTEXT,
(WPARAM) 80,(LPARAM) system_db.DB_DATABASE);
WritePrivateProfileString("DB_SET","DATABASE",system_db.DB_DATABASE,ControlFile);//写ini文件项值
EndDialog(hDlg,FALSE);
return(TRUE);
case IDCANCEL:
EndDialog(hDlg,FALSE);
return(TRUE);
}
break;
}
return(FALSE);
}
BOOL APIENTRY modeless_About_Proc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
return(TRUE);
case WM_COMMAND:
if(LOWORD(wParam)==IDOK||LOWORD(wParam)==IDCANCEL)
{
DestroyWindow(hDlg);
hWndModeless_About=NULL;
return(TRUE);
}
break;
}
return(FALSE);
}
/****************************************************************
* Name : SetWindowFonts
* Input Parms : None.
* Description : Sets the font of the created windows. Each
* : child window created should have a call here.
*****************************************************************/
void SetWindowFonts(HWND hWnd)
{
HANDLE handle;
/* Get the handle to the stock font ANSI_VAR_FONT */
handle = GetStockObject(ANSI_VAR_FONT);
/* This Message uses the above handle to the ANSI VAR FONT
for the child windows specified in the call. One of these
messages should be sent for each child window created.
By setting LPARAM to TRUE, the window is redrawn immediately
with the new font. */
//SendMessage(D4XhChildWnd, WM_SETFONT, (WPARAM)handle, (LPARAM)TRUE);
SendMessage(hWnd, WM_SETFONT, (WPARAM)handle, (LPARAM)TRUE);
}
/****************************************************************
* Name : SetWindowSIZE
* Input Parms : None.
* Description : Sets the RECT of the created windows and MDI windows.
* :
*****************************************************************/
void SetWindowSIZE(HWND _hWnd,HWND _hChannelWnd,HWND _hMessageWnd)
{
RECT RectWnd;
GetClientRect(_hWnd,&RectWnd);
// GetWindowRect(_hWnd,&RectWnd);
MoveWindow(_hChannelWnd,
CHILD_WND_FREE_WIDTH,
CHILD_WND_FREE_HEIGHT,
(RectWnd.right-RectWnd.left)/2 - CHILD_WND_FREE_WIDTH-10,
RectWnd.bottom - RectWnd.top - CHILD_WND_FREE_HEIGHT-10,
TRUE);
MoveWindow(_hMessageWnd,
(RectWnd.right-RectWnd.left)/2 + CHILD_WND_FREE_WIDTH-10,
CHILD_WND_FREE_HEIGHT,
(RectWnd.right-RectWnd.left)/2 - CHILD_WND_FREE_WIDTH-10,
RectWnd.bottom - RectWnd.top - CHILD_WND_FREE_HEIGHT-10,
TRUE);
return;
}
/****************************************************************
* Name : CenterWindow
* Input Parms : (HWND)
* Description : In this function, we save the instance handle in a global variable and
* create and display the main program window.
* This functionwill center one window over another ensuring that
* the placement of the window is within the 'working area', meaning
* that it is both within the display limits of the screen, and not
* obscured by the tray or other framing elements of the desktop.
* :
*****************************************************************/
BOOL CenterWindow (HWND hwndChild)
{
RECT rChild, rWorkArea;
int wChild, hChild;
BOOL bResult;
// Get the Height and Width of the child window
GetWindowRect (hwndChild, &rChild);
wChild = rChild.right - rChild.left;
hChild = rChild.bottom - rChild.top;
// Get the limits of the 'workarea'
bResult = SystemParametersInfo(
SPI_GETWORKAREA, // system parameter to query or set
sizeof(RECT),
&rWorkArea,
0);
if (!bResult) {
rWorkArea.right = GetSystemMetrics(SM_CXSCREEN);
rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN);
}
// Set it, and return
return MoveWindow (hwndChild,(rWorkArea.right-wChild)/2, (rWorkArea.bottom-hChild)/2, wChild, hChild,TRUE);
}
/****************************************************************
* Name : Msg_display
* Input Parms : string
* Description : Show System's message in Message window
* :
*****************************************************************/
void Msg_display(LPSTR string)
{
int index;
SendMessage(hMessageWnd, LB_ADDSTRING, (WPARAM)0, (LPARAM)string);
index = SendMessage (hMessageWnd, LB_GETCARETINDEX, 0,0);
if (index>200) {
SendMessage (hMessageWnd, LB_DELETESTRING, (WPARAM)0, 0);
}
SendMessage(hMessageWnd, LB_SETCARETINDEX, (WPARAM)++index, (LPARAM)FALSE);
}
/****************************************************************
* Name : Channel_Msg_display
* Input Parms : channel number,string
* Description : Show System's message in Message window
* :
*****************************************************************/
void Channel_Msg_display(int ch,LPSTR string)
{
SendMessage(hChannelWnd, LB_DELETESTRING, (WPARAM) ch, (LPARAM) 0);
SendMessage(hChannelWnd, LB_INSERTSTRING, (WPARAM) ch, (LPARAM) string);
}
/****************************************************************
* Name : InitDBSet
* Input Parms : None.
* Description : InitDBSet
* :
*****************************************************************/
void InitDBSet()
{
char szBuffer[MAXSIZE];
char str[20];
char ControlFile[MAXSIZE];
// GetModuleFileName(NULL,szBuffer,200); //取得执行文件名的路径如c:\a\a.exe
// SetCurrentDirectory("D:\\TWvoice\\HW_mysql\\Debug\\"); //设置当前文件路径
// GetCurrentDirectory(200,szBuffer); //取得执行文件的路径
// if (szBuffer [strlen (szBuffer) - 1] != '\\')
// strcat (szBuffer, "\\") ;
GetCurrentDirectory(200,szBuffer);//取得执行文件的路径
wsprintf(ControlFile,"%s%s",szBuffer,"\\voice.ini");
Msg_display(ControlFile);
GetPrivateProfileString("DB_SET","SERVER","",str,20,ControlFile);
strcpy(system_db.DB_SERVER,str);
GetPrivateProfileString("DB_SET","USER","",str,20,ControlFile);
strcpy(system_db.DB_USER,str);
GetPrivateProfileString("DB_SET","PASSWORD","",str,20,ControlFile);
strcpy(system_db.DB_PWD,str);
GetPrivateProfileString("DB_SET","DATABASE","",str,20,ControlFile);
strcpy(system_db.DB_DATABASE,str);
system_db.DB_port = 0;
strcpy(system_db.DB_unix_socket,"NULL");
system_db.DB_client_flag = 0;
}
/****************************************************************
* Name : InitSys
* Input Parms : None.
* Description : InitSys
* :
*****************************************************************/
void InitSys()
{
int i;
char str[100];
int ChannelNum;
//----------------------------------------------------------------------------
/*/for : test code
int ch=6;
//在这里开始启动服务进程
startin[ch].cb = sizeof(STARTUPINFO);
startin[ch].lpReserved = NULL;
startin[ch].lpDesktop = NULL;
startin[ch].lpTitle = NULL;
startin[ch].dwFlags = STARTF_USESHOWWINDOW;
startin[ch].cbReserved2 = 0;
startin[ch].lpReserved2 = NULL;
startin[ch].wShowWindow = SW_SHOWMINIMIZED;
_ProcessServiceID[ch] =
CreateProcess(NULL,
"Child.exe", //具体进程名
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&startin[ch],
&prinfo[ch]);
Sleep(100);
if(_ProcessServiceID[ch])
{
PostThreadMessage((DWORD)(prinfo[ch].dwThreadId),WM_COMMAND,(WPARAM) 19790917,(LPARAM) ch);
chInfo[ch].working= 1; //当前通道服务进程开始工作
}
//------------------------------------------------*/
TV_Disable(); //首先完成初始化工作,再关闭系统中断,使所有函数调用无效
//Sleep(1000);
if ((ChannelNum = TV_Installed()) == 0) //判断驱动程序安装否,并返回可用通道数
{
wsprintf(str,"...............................................................");
Msg_display(str);
wsprintf(str,"ERROR: TW8VID driver not installed");
Msg_display(str);
// wsprintf(str,"语音卡驱动程序尚未安装,即将退出!");
// MessageBox(MainhWnd,str,"系统信息",MB_OK);
// SendMessage(MainhWnd,WM_CLOSE,0,0L); //退出主程序
}
else
{
wsprintf(str,"...............................................................");
Msg_display(str);
wsprintf(str,"There are %d channels",ChannelNum);
Msg_display(str);
TV_Initialize(); //初始化所有电话卡
/*****************************************************************************
* 加密段
*
*
******************************************************************************/
/*****************************************************************************
* 根据当地市话局地情况,设置系统相关参数代码段
*
*
******************************************************************************/
TV_CompressRatio (RATE_64K);
for(i=0; i<MAXCHANNEL; i++)
{
ChannelInit(i); //自定义函数:初始化通道状态标记
workPara[i] = i;
workHandle[i] = CreateThread(NULL,0,WorkThread //为每个通道建立线程
,&(workPara[i]),CREATE_SUSPENDED,&(workID[i]));
if( workHandle[i] == NULL) //检测每个线程是否建立成功
{
wsprintf(str,"ERROR: Create Thread for Channel %d Error",i);
Msg_display(str);
Sleep(2000);
SendMessage(MainhWnd,WM_CLOSE,0,0L); //退出程序
}
SetThreadPriority(workHandle[i],THREAD_PRIORITY_NORMAL);//设置线程属性,并启动
ResumeThread(workHandle[i]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -