📄 voice.c
字号:
#include <windows.h>
#include <windowsx.h>
#include <share.h>
#include <memory.h>
#include <winnt.h>
#include <limits.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <conio.h>
#include <time.h>
#include <sys/stat.h>
#include "tw8vid.h"
#include ".\mysql\include\mysql.h"
#include "resource.h"
#include "Globe.h"
#include "Voice.h"
#define far
HANDLE hInst;
HMENU hMenu;
static HWND MainhWnd;
static HWND hChannelWnd,hMessageWnd;
HWND hWndModeless_About=NULL;
DB_Str system_db; //系统数据库连接接口
PORT Channel_info[MAXCHANNEL]; //记费声明
int ServiceNum; //有效服务信息数
ServiceStr Service_info[MAXSERVICENUM]; //服务信息清单
/****************************************************************
* Name : WinMain
* Input Parms : HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow
* Description : the application's entry
* :
*****************************************************************/
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
HACCEL hAccel;
hMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MDIMAINMENU)); //主窗口菜单
hAccel=LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCEL)); //快捷键资源初始化
if(!hPrevInstance)
{
if(!InitApplication(hInstance))
return(FALSE);
}
if(!InitInstance(hInstance,nCmdShow))
return(FALSE);
CenterWindow (MainhWnd);
InitDBSet();
InitSys();
while(GetMessage(&msg, //启动消息循环
NULL,
0,
0))
{ //检查并处理无模式对话框“关于”窗口消息
if(!IsWindow(hWndModeless_About)||!IsDialogMessage(hWndModeless_About,&msg)
||!TranslateAccelerator(MainhWnd,hAccel,&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return(msg.wParam);
}
/****************************************************************
* Name : InitApplication
* Input Parms : hInstance
* Description : describing main window's style and register the window class
* :
*****************************************************************/
BOOL InitApplication(HINSTANCE hInstance)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_BIG));
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = GetStockObject(GRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MainWndClass";
if(!RegisterClass(&wc))
return FALSE;
return TRUE;
}
/****************************************************************
* Name : InitInstance
* Input Parms : HINSTANCE hInstance,int nCmdShow
* Description : Create Frame window
* :
*****************************************************************/
BOOL InitInstance(HINSTANCE hInstance,
int nCmdShow)
{
hInst=hInstance;
MainhWnd=CreateWindow(
"MainWndClass",
"兄弟合谊通信",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
hMenu,
hInstance,
NULL); //创建主窗口
if(!MainhWnd)
return(FALSE);
ShowWindow(MainhWnd,nCmdShow); //显示主窗口
// ShowWindow(MainhWnd,SW_MAXIMIZE); //最大化窗口
SetWindowFonts((HWND) MainhWnd);
UpdateWindow(MainhWnd); //更新窗口
return(TRUE);
}
/****************************************************************
* Name : MainWndProc
* Input Parms : HWND,UINT,WPARAM,LPARAM
* Description : the Frame windows's process
* :
*****************************************************************/
LRESULT CALLBACK MainWndProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
char str[100];
int nItem;
switch(message)
{
case WM_CREATE: //处理主窗口创建完成消息事件
hMessageWnd = CreateWindow("LISTBOX", //create the message window
(LPSTR) MessageTitle,
MessageWinstyle,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hWnd,
(HMENU) NULL,
hInst,
NULL);
//Show the window
ShowWindow(hMessageWnd, SW_SHOWNORMAL);
//Set the font of the created child windows
SetWindowFonts((HWND) hMessageWnd);
//voice Channel Status windows
hChannelWnd = CreateWindow("LISTBOX", //create the channel window
(LPSTR) ChannelTitle,
ChannelWinstyle,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hWnd,
(HMENU) NULL,
hInst,
NULL);
//Show the window
//ShowWindow(hChannelWnd, TRUE);
ShowWindow(hChannelWnd, SW_SHOWNORMAL);
//Set the font of the created child windows
SetWindowFonts((HWND) hChannelWnd);
//设主、客窗口位置
SetWindowSIZE((HWND) hWnd,(HWND) hChannelWnd,(HWND) hMessageWnd);
wsprintf(str,"wait for a moment,system now initialize...");
Msg_display(str);
break;
case WM_SIZE:
SetWindowSIZE((HWND) hWnd,(HWND) hChannelWnd,(HWND) hMessageWnd); //设置客户窗口位置
break;
case WM_COMMAND: //窗口菜单消息
switch(LOWORD(wParam))
{
case IDM_SETCHANNELIDLE: //“设通道空闲”菜单项
nItem = SendMessage(hChannelWnd,LB_GETCURSEL,0,0);
wsprintf(str,"Set Channel %d to Idle",nItem);
Msg_display(str);
break;
case IDM_EXIT: //“退出”菜单项
SendMessage(hWnd,WM_CLOSE,0,0L);
break;
case IDM_MDITILE: //"并列子窗口"菜单项
SetWindowSIZE((HWND) hWnd,(HWND) hChannelWnd,(HWND) hMessageWnd); //设置客户窗口位置
break;
case IDM_REFRESHSERVICE: //服务信息器刷新处理模块
Refrush_Service();
break;
case IDM_DBCFG: //数据库连接设置
DialogBox(hInst,MAKEINTRESOURCE(IDD_DBCFG),hWnd,
(DLGPROC)SetDBState_Proc);
break;
case IDM_ABOUT: //"关于"菜单项
if(!IsWindow(hWndModeless_About))
{
hWndModeless_About=CreateDialog(hInst,MAKEINTRESOURCE(ABOUT),
hWnd,(DLGPROC)modeless_About_Proc);
CenterWindow (hWndModeless_About);
ShowWindow(hWndModeless_About,SW_SHOW);
}
break;
default: //处理缺省消息
//*
if((HWND)lParam != hChannelWnd)
{
time_t ltime;
long int time1;
time( <ime );//Time in seconds since UTC 1/1/70
time1=ltime;
//Test
//-------------------------------------------------------------------------------
_strdate( Channel_info[5].InDate ); //model of 05/03/94
_strtime( Channel_info[5].InTime ); //model of 21:51:03
//在这里改写、添加,通道&系统信息窗口内容
wsprintf(str,"Chan: %d %15s %12s %12shave been in services since %9s %ld",
5,Channel_info[5].CallerNum,"CalledNum",Channel_info[5].InTime,Channel_info[5].InDate,time1);
//model of: "Chan: 5 13320291670 66668888 have been in services since 21:51:03"
Channel_Msg_display(5,str);
//-------------------------------------------------------------------------------
Msg_display(str);
wsprintf(str,"%s","Sorry, Now nothing do here");
Msg_display(str);
}
//*/
return (DefWindowProc (hWnd,message,wParam,lParam));
}
break;
case WM_CLOSE:
DestroyWindow (hWnd);
break;
case WM_QUERYENDSESSION:
if(MessageBox(MainhWnd,"您是否真要退出本程序?",TEXT(" 操作确认"),MB_OKCANCEL) == 1)
DestroyWindow (hWnd);
break;
case WM_DESTROY:
ExitSys(); //结束语音服务
PostQuitMessage (0);
break;
default:
return (DefWindowProc (hWnd,message,wParam,lParam));
}
return 0;
}
/****************************************************************
* Name : SetDBState_Proc
* Input Parms : HWND,UINT,WPARAM,LPARAM
* Description : Set states for link to Mysql
* :
*****************************************************************/
BOOL APIENTRY SetDBState_Proc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
char szBuffer[MAXSIZE];
char ControlFile[MAXSIZE];
switch(message)
{
case WM_INITDIALOG:
CenterWindow(hDlg);
//把编辑控件中可输入的字符数目限定为n个
SendDlgItemMessage(hDlg,IDC_DB_SERVER,
EM_SETLIMITTEXT,
(WPARAM) 20,
(LPARAM) 0);
SendMessage(GetDlgItem(hDlg,IDC_DB_SERVER),
WM_SETTEXT,0,(LPARAM) system_db.DB_SERVER);
//把编辑控件中可输入的字符数目限定为n个
SendDlgItemMessage(hDlg,IDC_DB_USER,
EM_SETLIMITTEXT,
(WPARAM) 20,
(LPARAM) 0);
SendMessage(GetDlgItem(hDlg,IDC_DB_USER),
WM_SETTEXT,0,(LPARAM) system_db.DB_USER);
//把编辑控件中可输入的字符数目限定为n个
SendDlgItemMessage(hDlg,IDC_DB_PWD,
EM_SETLIMITTEXT,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -