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

📄 dial.cpp

📁 语音卡的拨号检测示例程序,单线程拨号示例.d80a/d161a
💻 CPP
字号:
//////////////////////////////////////////////////
//Dial.cpp
#include <windows.h>
#include <commdlg.h>
#include <commctrl.h>
#include <windowsx.h>

#include "resource.h"
#include "dial.h"
#include "d.h"
#include "..\\..\\..\\..\\inc\\tc08a32.h"

BOOL bHaveLoadDriver;
HINSTANCE hInst;
HINSTANCE hLib;
HWND hGWnd;
extern WORD TotalLine;

extern void yzResetChannel(int channelID);

int PASCAL WinMain(	HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdParam, int nCmdShow)
{
	static char szAppName[] = "Dial";
	HWND        hwnd;
	MSG         msg;
	WNDCLASS    wndclass;
	char strSys[200];

//	Unused(lpszCmdParam);

	if (!hPrevInstance)
	{
		wndclass.style         = CS_HREDRAW | CS_VREDRAW;
		wndclass.lpfnWndProc   = (WNDPROC)WndProc;
		wndclass.cbClsExtra    = 0 ;
		wndclass.cbWndExtra    = DLGWINDOWEXTRA;
		wndclass.hInstance     = hInstance;
		wndclass.hIcon         = LoadIcon (hInstance, "IDI_DIAL");
		wndclass.hCursor       = LoadCursor (NULL, IDI_APPLICATION);
		wndclass.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
		wndclass.lpszMenuName  = NULL;
		wndclass.lpszClassName = szAppName;

		ATOM a=RegisterClass (&wndclass);
	}

	GetSystemDirectory(strSys,200);
	strcat(strSys,"\\comctl32.dll");
	hLib = LoadLibrary(strSys);

	hInst = hInstance;
	hwnd = CreateDialog(hInstance, "DIAL", 0, NULL);
	hGWnd=hwnd;

	SetFocus( GetDlgItem (hwnd, IDC_CHANNEL) ) ; 
	
	ShowWindow (hwnd, nCmdShow);
	UpdateWindow(hwnd);
	
	bHaveLoadDriver=yzInitSystem();
	if(!bHaveLoadDriver) 
		PostQuitMessage(0);

	//FARPROC lpProc;
	//lpProc = MakeProcInstance((FARPROC)TimerProc, hInstance);
	SetTimer(hwnd,ID_TIME,100,TimerProc); 

	bool bShift = false;
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		HWND hCurFocus, hNextFocus;
		if ( 16 == LOWORD(msg.wParam) && msg.message==WM_KEYDOWN)	//Shift down
		{
			bShift = true;
		}
		if ( 16 == LOWORD(msg.wParam) && msg.message==WM_KEYUP)	//Shift up
		{
			bShift = false;
		}
		if ( 9 == LOWORD(msg.wParam) && msg.message==WM_KEYDOWN)	//tab
		{
			hCurFocus = GetFocus();
			hNextFocus = GetNextDlgTabItem (hGWnd, hCurFocus, bShift);
			SetFocus ( hNextFocus );
		}
		if ( 13 == LOWORD(msg.wParam) && msg.message==WM_KEYDOWN)	//return
		{
			hCurFocus = GetFocus();
			if( hCurFocus == GetDlgItem(hGWnd,ID_HANGUP) || hCurFocus == GetDlgItem(hGWnd,ID_OK) )
			{
				PostMessage(hCurFocus, BM_CLICK, 0, 0);
			}
			else
			{
				//SetFocus ( GetDlgItem(hGWnd,IDC_DIAL) );
				//yzDialOut();
				PostMessage(GetDlgItem(hGWnd,IDC_DIAL), BM_CLICK, 0, 0);
			}
		}
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam ;
}
VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{ 
	if(idEvent!=ID_TIME) return;
	yzDoWork();
}

LRESULT CALLBACK  WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
	int i;
	switch (message)
	{
	 	case WM_DESTROY :
			KillTimer(hwnd,ID_TIME);
			if(bHaveLoadDriver) yzExitSystem();
			PostQuitMessage (0) ;
			return 0 ;
			break;
		case WM_COMMAND:
			if(LOWORD(wParam)==ID_OK)
			{
				KillTimer(hwnd,ID_TIME);
				if(bHaveLoadDriver) yzExitSystem();
				PostQuitMessage(0);
			}
			else if(LOWORD(wParam)==ID_HANGUP)
			{
				for (i = 0; i < TotalLine; i ++)	yzResetChannel(i);
			}
			else if(LOWORD(wParam)==IDC_DIAL)
				yzDialOut();
			return 0;
			break;
		default:
			return DefWindowProc (hwnd, message, wParam, lParam) ;
			break;
	}
}



⌨️ 快捷键说明

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