Example #1
0
void SimpleQt::onFirstStartup()
{
    int retVal = ap_DeviceProbe(NULL);
    if (retVal == AP_CAMERA_SUCCESS)
    {
        m_hApBase = ap_Create(0);
        if (m_hApBase == NULL)
        {
             QMessageBox msgBox;
             msgBox.setText("Camera initialization error! SimpleQT will close.");
             msgBox.setIcon(QMessageBox::Critical);
             msgBox.exec();
             this->close();
             return;
        }
        ap_SetCallback_MultipleChoice(m_hApBase, MultipleChoice_Callback, this);
        ap_SetCallback_ErrorMessage(m_hApBase, ErrorMessage_Callback, this);
        ap_LoadIniPreset(m_hApBase, NULL, NULL);
        CreateInfoDlg();
        onPlay();
        return;
    } else
    {
         QMessageBox msgBox;
         msgBox.setText("Unable to either detect a sensor or find a matching SDAT file.\nSimpleQT will close.");
         msgBox.setIcon(QMessageBox::Critical);
         msgBox.exec();
         this->close();
    }
}
Example #2
0
BOOL CpermoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	//AllocConsole();
	//freopen("CONOUT$","w",stdout);
	//bIsWindowsVistaOrGreater = false;
	//判断操作系统版本
// 	DWORD dwVersion = 0;
// 	DWORD dwMajorVersion = 0;
//     DWORD dwMinorVersion = 0; 
// 	dwVersion = ::GetVersion();
// 	dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
//     //dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
// 	if (dwMajorVersion > 5)
// 	{
// 		bIsWindowsVistaOrGreater = true;
// 	}
	/*
	If dwMajorVersion = 6 And dwMinorVersion = 1 Then GetWinVersion = "windows 7"
    If dwMajorVersion = 6 And dwMinorVersion = 0 Then GetWinVersion = "windows vista"
    If dwMajorVersion = 5 And dwMinorVersion = 1 Then GetWinVersion = "windows xp"
    If dwMajorVersion = 5 And dwMinorVersion = 0 Then GetWinVersion = "windows 2000"
	*/
	BOOL bRet = FALSE;
	::SystemParametersInfo(SPI_GETWORKAREA, 0, &rWorkArea, 0);   // 获得工作区大小
	bRet = SetWorkDir();
	if (!bRet)
	{
		AfxMessageBox(_T("额...初始化失败!"));
		return FALSE;
	}
	OpenConfig();
	InitSize();
	CreateInfoDlg();
	GetWindowRect(&rCurPos);
	if (!::GetSystemTimes(&preidleTime, &prekernelTime, &preuserTime))
	{
		return -1;
	}
	m_SubMenu_NetPort.CreatePopupMenu();
	MFNetTraffic m_cTrafficClassTemp;
	//更新:增加对所有发现的网络接口监控遍历,防止监控的接口非连接网络的接口
	double tottraff = 0, maxtmp = 0;
	CString tmp, tmp2;
	int nCount = m_cTrafficClassTemp.GetNetworkInterfacesCount();
	for (int i = 0; i <= nCount; i++)
	{
		if ((tottraff = m_cTrafficClassTemp.GetInterfaceTotalTraffic(i) / (1024.0*1024.0)) > 0)
		{
			if (tottraff > maxtmp)
			{
				maxtmp = tottraff;
				SelectedInterface = i;
				isOnline = TRUE;
			}
		}
		m_cTrafficClassTemp.GetNetworkInterfaceName(&tmp, i);
		tmp2.Format(_T("%s : %.1f MB"), tmp, tottraff);
		m_SubMenu_NetPort.AppendMenu(MF_STRING, i + START_INDEX, tmp2);
	}
	//创建菜单
	InitPopMenu(nCount);
	//默认置顶
	if (bTopmost)
	{
		SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
		m_Menu.CheckMenuItem(IDM_TOPMOST, MF_BYCOMMAND | MF_CHECKED);
	}
	if (bAutoHide)
	{
		m_Menu.CheckMenuItem(IDM_AUTOHIDE, MF_BYCOMMAND | MF_CHECKED);
	}
	if (0 == nShowWay)
	{
		m_Menu.CheckMenuItem(IDM_SHOWBYHOVER, MF_BYCOMMAND | MF_CHECKED);
	}
	else
	{
		m_Menu.CheckMenuItem(IDM_SHOWBYLDOWN, MF_BYCOMMAND | MF_CHECKED);
	}
	if (bShowNetInfo)
	{
		m_Menu.CheckMenuItem(IDM_SHOWNETINFO, MF_BYCOMMAND | MF_CHECKED);
	}
	else
	{
		m_Menu.CheckMenuItem(IDM_SHOWNETINFO, MF_BYCOMMAND | MF_UNCHECKED);
	}
	m_Menu.CheckMenuItem(nSkin, MF_BYCOMMAND | MF_CHECKED); // 在前面打钩 
	m_Menu.CheckMenuItem(IDM_FONTSIZE12 + nFontSize - 12, MF_BYCOMMAND | MF_CHECKED);
	IfAutoRun();//判断是否已经开机自启
	isOnline = TRUE;

	//设置网络监控类型
	m_cTrafficClassDown.SetTrafficType(MFNetTraffic::IncomingTraffic);
	m_cTrafficClassUp.SetTrafficType(MFNetTraffic::OutGoingTraffic);

	//取消任务栏显示
	SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, WS_EX_TOOLWINDOW);
	//每隔一秒刷新CPU和网络信息
	SetTimer(1, 1000, NULL);
	//刷新内存信息
	SetTimer(2, 5000, NULL);
	
	::SetWindowLong( m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
	::SetLayeredWindowAttributes( m_hWnd, 0, nTrans, LWA_ALPHA); // 120是透明度,范围是0~255
	m_Menu.CheckMenuItem(IDM_TRANS0+(255-nTrans)/25, MF_BYCOMMAND | MF_CHECKED);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}