コード例 #1
0
ファイル: olesvr2.cpp プロジェクト: rickerliang/OpenNT
void COleServerItem::OnShow()
{
	ASSERT_VALID(this);

	// attempt in place activation (if not supported, fall back on "Open")
	COleServerDoc* pDoc = GetDocument();
	if (!pDoc->ActivateInPlace())
	{
		// by default OnShow() maps to OnOpen() if in-place activation
		//  not supported
		OnOpen();
	}
}
コード例 #2
0
void CTabSample::OnBnClickedCheckMatrixnetwork()
{
	// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
	BOOL bStatus = (BOOL)::SendMessage(GetDlgItem(IDC_CHECK_MATRIXNETWORK)->GetSafeHwnd(),   BM_GETCHECK,   0,   0);
	if (bStatus == TRUE)
	{
		OnOpen();
	}
	else
	{
		OnStop();
	}
}
コード例 #3
0
 void WebsocketTransport::AddEventListeners() {
     ws_->set_on_open([this]{
         OnOpen();
     });
     ws_->set_on_close([this]{
         OnClose();
     });
     ws_->set_on_message([this](const Websocket::Message & message){
         OnData(message);
     });
     ws_->set_on_error([this](const std::string & error){
         OnError(Format("websocket error: %s", error.c_str()));
     });
 }
コード例 #4
0
ファイル: textbuf.cpp プロジェクト: EdgarTx/wx
bool wxTextBuffer::Create()
{
    // buffer name must be either given in ctor or in Create(const wxString&)
    wxASSERT( !m_strBufferName.empty() );

    // if the buffer already exists do nothing
    if ( Exists() ) return false;

    if ( !OnOpen(m_strBufferName, WriteAccess) )
        return false;

    OnClose();
    return true;
}
コード例 #5
0
ファイル: BookmarksView.cpp プロジェクト: drealeed/eclide
void CBookmarksView::OnContextMenu(HWND /*phWnd*/, CPoint pPoint)
{
    WTL::CMenu m;
    m.LoadMenu(IDR_POPUP_BOOKMARKS);
    bool noCount = m_list.GetItemCount() == 0;
    bool noSelection = m_list.GetSelectedCount() == 0;
    m.EnableMenuItem(ID_BOOKMARKS_OPEN, noCount || noSelection ? MF_DISABLED : MF_ENABLED);
    m.EnableMenuItem(ID_BOOKMARKS_SAVE, noCount ? MF_DISABLED : MF_ENABLED);
    m.EnableMenuItem(ID_BOOKMARKS_CLEAR, noCount ? MF_DISABLED : MF_ENABLED);
    m.EnableMenuItem(ID_BOOKMARKS_LOADMERGE, noCount ? MF_DISABLED : MF_ENABLED);
    m.EnableMenuItem(ID_BOOKMARKS_DELETEFROMLIST, noCount || noSelection ? MF_DISABLED : MF_ENABLED);

    unsigned int id = m.GetSubMenu(0).TrackPopupMenuEx(TPM_RETURNCMD, pPoint.x, pPoint.y, m_hWnd, NULL);
    switch (id)
    {
    case ID_BOOKMARKS_OPEN:
    {
        OnOpen();
    }
    break;
    case ID_BOOKMARKS_SAVE:
    {
        OnSaveFile();
    }
    break;
    case ID_BOOKMARKS_LOAD:
    {
        OnLoadFile();
    }
    break;
    case ID_BOOKMARKS_LOADMERGE:
    {
        OnLoadFile(true);
    }
    break;
    case ID_BOOKMARKS_DELETEFROMLIST:
    {
        OnDeleteLines();
    }
    break;
    case ID_BOOKMARKS_CLEAR:
    {
        if (MessageBox(CLEAR_BOOKMARKS_MSG, _T("Warning"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) != IDYES) {
            return;
        }
        OnClear(NULL, NULL, NULL);
    }
    break;
    }
}
コード例 #6
0
ファイル: shellfolder.cpp プロジェクト: vbaderks/msf
    HRESULT OnDfmInvokeAddedCommand(HWND hwnd, IDataObject* pdataobject, int nId)
    {
        switch (nId)
        {
            case ID_DFM_CMD_OPEN:
                OnOpen(hwnd, pdataobject);
                break;

            default:
                ATLASSERT(false); // unknown command id detected.
                break;
        }

        return S_OK;
    }
コード例 #7
0
void PoeditApp::OnOpen(wxCommandEvent& event)
{
    TRY_FORWARD_TO_ACTIVE_WINDOW( OnOpen(event) );

    wxString path = wxConfig::Get()->Read("last_file_path", wxEmptyString);
    wxString name = wxFileSelector(_("Open catalog"),
                    path, wxEmptyString, wxEmptyString,
                    _("GNU gettext catalogs (*.po)|*.po|All files (*.*)|*.*"),
                    wxFD_OPEN | wxFD_FILE_MUST_EXIST);

    if (!name.empty())
    {
        wxConfig::Get()->Write("last_file_path", wxPathOnly(name));
        OpenFile(name);
    }
}
コード例 #8
0
ファイル: textbuf.cpp プロジェクト: EdgarTx/wx
bool wxTextBuffer::Open(const wxMBConv& conv)
{
    // buffer name must be either given in ctor or in Open(const wxString&)
    wxASSERT( !m_strBufferName.empty() );

    // open buffer in read-only mode
    if ( !OnOpen(m_strBufferName, ReadAccess) )
        return false;

    // read buffer into memory
    m_isOpened = OnRead(conv);

    OnClose();

    return m_isOpened;
}
コード例 #9
0
ファイル: ComboBox.cpp プロジェクト: spacechase0/SFGUI
void ComboBox::HandleMouseButtonEvent( sf::Mouse::Button button, bool press, int /*x*/, int /*y*/ ) {
	if( !press || ( button != sf::Mouse::Left ) ) {
		return;
	}

	if( GetState() == ACTIVE ) {
		m_active = false;

		if( ( m_highlighted_item != NONE ) && ( m_active_item != m_highlighted_item ) ) {
			m_active_item = m_highlighted_item;
			OnSelect();
		}

		m_highlighted_item = NONE;

		if( IsMouseInWidget() ) {
			SetState( PRELIGHT );
		}
		else {
			SetState( NORMAL );
		}

		Invalidate();

		return;
	}

	if( IsMouseInWidget() ) {
		m_active = true;
		m_highlighted_item = NONE;

		SetState( ACTIVE );

		OnOpen();

		if( m_queue ) {
			// Set Z Layer to 1, above all "normal" widgets.
			m_queue->SetZOrder( 1 );
		}

		Invalidate();
	}
}
コード例 #10
0
ファイル: syncacceptor.cpp プロジェクト: ecilaz/ecila
bool_t SyncAcceptor::Open(unsigned short port, const char *ip)
{
	bool_t ret = FALSE;

	ret = sock_.Open();
	if(!ret) { ECILA_TRACE(); return FALSE; }

	ret = sock_.Bind(port, ip);
	if(!ret) { ECILA_TRACE(); return FALSE; }

	ret = sock_.SetNonBlock(TRUE);
	if(!ret) { ECILA_TRACE(); return FALSE; }

	ret = sock_.Listen(MAX_BACK_LOG);
	if(!ret) { ECILA_TRACE(); return FALSE; }

	ret = OnOpen(0);
	if(!ret) { ECILA_TRACE(); return FALSE; }

	return TRUE;
}
コード例 #11
0
ファイル: App.cpp プロジェクト: chrisoldwood/WCL
bool CApp::Open()
{
	// If not set yet, default title to application filename.
	if (m_strTitle.Empty())
		m_strTitle = CPath::Application().FileName().ToUpper();

	const DWORD dwMinMajor = 4;
	const DWORD dwMinMinor = 71;

	DWORD dwMajor, dwMinor;

	// Get COMCTL32.DLL version.
	if (!m_oComCtl32.IsLoaded() || !m_oComCtl32.GetVersion(dwMajor, dwMinor))
	{
		FatalMsg(TXT("This application requires at least v%u.%u of COMCTL32.DLL."), dwMinMajor, dwMinMinor);
		return false;
	}

	// Check COMCTL32.DLL version.
	if ( (dwMajor < dwMinMajor) || ((dwMajor == dwMinMajor) && (dwMinor < dwMinMinor)) )
	{
		FatalMsg(TXT("This application requires at least v%u.%u of COMCTL32.DLL."), dwMinMajor, dwMinMinor);
		return false;
	}

	DWORD dwICC = ICC_DATE_CLASSES | ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_TAB_CLASSES;

	// Initialise COMCTL32.DLL window classes.
	if (!m_oComCtl32.Initialise(dwICC))
	{
		FatalMsg(TXT("Failed to initialise COMCTL32.DLL"));
		return false;
	}

	// Call application method.
	if (!OnOpen())
		return false;

	return true;
}
コード例 #12
0
    void WebsocketTransport::Open() {
        auto thiz = std::static_pointer_cast<WebsocketTransport>(shared_from_this());
        
        auto query = MergeQuery(socket_->options().query.value(), "");
        
        websocket_ = Websocket::Create(PrepareUrl() + query, "");
        websocket_->set_on_open([thiz](){
            thiz->OnOpen();
            thiz->socket()->SetBuffer(false);
        });
        websocket_->set_on_message([thiz](const Websocket::Message & message){
            thiz->OnData(ToString(*message.data));
        });
        websocket_->set_on_close([thiz](){
            thiz->OnClose();
            thiz->socket()->SetBuffer(true);
        });
        websocket_->set_on_error([thiz](const std::string & error){
            thiz->OnError(error);
        });

    }
コード例 #13
0
ファイル: olesvr2.cpp プロジェクト: rickerliang/OpenNT
void COleServerItem::OnDoVerb(LONG iVerb)
{
	switch (iVerb)
	{
	// open - maps to OnOpen
	case OLEIVERB_OPEN:
	case -OLEIVERB_OPEN-1:  // allows positive OLEIVERB_OPEN-1 in registry
		OnOpen();
		break;

	// primary, show, and unknown map to OnShow
	case OLEIVERB_PRIMARY:  // OLEIVERB_PRIMARY is 0 and "Edit" in registry
	case OLEIVERB_SHOW:
		OnShow();
		break;

	// hide maps to OnHide
	case OLEIVERB_HIDE:
	case -OLEIVERB_HIDE-1:  // allows positive OLEIVERB_HIDE-1 in registry
		OnHide();
		break;

	default:
		// negative verbs not understood should return E_NOTIMPL
		if (iVerb < 0)
			AfxThrowOleException(E_NOTIMPL);

		// positive verb not processed --
		//  according to OLE spec, primary verb should be executed
		//  instead.
		OnDoVerb(OLEIVERB_PRIMARY);

		// also, OLEOBJ_S_INVALIDVERB should be returned.
		AfxThrowOleException(OLEOBJ_S_INVALIDVERB);
	}
}
コード例 #14
0
ファイル: WpdObjectResources.cpp プロジェクト: kcrazy/winekit
HRESULT WpdObjectResources::DispatchWpdMessage(
    const PROPERTYKEY&     Command,
    IPortableDeviceValues* pParams,
    IPortableDeviceValues* pResults)
{

    HRESULT hr = S_OK;

    if (hr == S_OK)
    {
        if (Command.fmtid != WPD_CATEGORY_OBJECT_RESOURCES)
        {
            hr = E_INVALIDARG;
            CHECK_HR(hr, "This object does not support this command category %ws",CComBSTR(Command.fmtid));
        }
    }

    if (hr == S_OK)
    {
        if (IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_GET_SUPPORTED))
        {
            hr = OnGetSupportedResources(pParams, pResults);
            CHECK_HR(hr, "Failed to get supported resources");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_GET_ATTRIBUTES))
        {
            hr = OnGetAttributes(pParams, pResults);
            if(FAILED(hr))
            {
                CHECK_HR(hr, "Failed to get resource attributes");
            }
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_OPEN))
        {
            hr = OnOpen(pParams, pResults);
            CHECK_HR(hr, "Failed to open resource");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_READ))
        {
            hr = OnRead(pParams, pResults);
            CHECK_HR(hr, "Failed to read resource data");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_WRITE))
        {
            hr = OnWrite(pParams, pResults);
            CHECK_HR(hr, "Failed to write resource data");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_CLOSE))
        {
            hr = OnClose(pParams, pResults);
            CHECK_HR(hr, "Failed to close resource");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_DELETE))
        {
            hr = OnDelete(pParams, pResults);
            CHECK_HR(hr, "Failed to delete resources");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_CREATE_RESOURCE))
        {
            hr = OnCreate(pParams, pResults);
            CHECK_HR(hr, "Failed to create resource");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_REVERT))
        {
            hr = OnRevert(pParams, pResults);
            CHECK_HR(hr, "Failed to revert resource operation");
        }
        else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_RESOURCES_SEEK))
        {
            hr = OnSeek(pParams, pResults);
            CHECK_HR(hr, "Failed resource seek operation");
        }
        else
        {
            hr = E_NOTIMPL;
            CHECK_HR(hr, "This object does not support this command id %d", Command.pid);
        }
    }
    return hr;
}
コード例 #15
0
DMainWindow::DMainWindow(QWidget* parent_widget)
	: QMainWindow(parent_widget)
{
	m_ui = std::make_unique<Ui::DMainWindow>();
	m_ui->setupUi(this);

	Resources::Init();
	UpdateIcons();
	setWindowIcon(Resources::GetIcon(Resources::DOLPHIN_LOGO));

	// Create the GameList
	m_game_tracker = new DGameTracker(this);
	m_ui->centralWidget->addWidget(m_game_tracker);
	m_game_tracker->ScanForGames();
	m_game_tracker->SelectLastBootedGame();

	// Setup the GameList style switching actions
	QActionGroup* gamelistGroup = new QActionGroup(this);
	gamelistGroup->addAction(m_ui->actionListView);
	gamelistGroup->addAction(m_ui->actionTreeView);
	gamelistGroup->addAction(m_ui->actionGridView);
	gamelistGroup->addAction(m_ui->actionIconView);

	// TODO: save/load this from user prefs!
	m_ui->actionListView->setChecked(true);
	OnGameListStyleChanged();

	// Connect all the signals/slots
	connect(this, SIGNAL(CoreStateChanged(Core::EState)), this, SLOT(OnCoreStateChanged(Core::EState)));

	connect(m_ui->actionOpen, SIGNAL(triggered()), this, SLOT(OnOpen()));
	connect(m_ui->actionBrowse, SIGNAL(triggered()), this, SLOT(OnBrowse()));
	connect(m_ui->actionExit, SIGNAL(triggered()), this, SLOT(OnExit()));

	connect(m_ui->actionListView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));
	connect(m_ui->actionTreeView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));
	connect(m_ui->actionGridView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));
	connect(m_ui->actionIconView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));

	connect(m_ui->actionPlay, SIGNAL(triggered()), this, SLOT(OnPlay()));
	connect(m_ui->actionPlay_mnu, SIGNAL(triggered()), this, SLOT(OnPlay()));
	connect(m_game_tracker, SIGNAL(StartGame()), this, SLOT(OnPlay()));
	connect(m_ui->actionStop, SIGNAL(triggered()), this, SLOT(OnStop()));
	connect(m_ui->actionStop_mnu, SIGNAL(triggered()), this, SLOT(OnStop()));
	connect(m_ui->actionReset, SIGNAL(triggered()), this, SLOT(OnReset()));

	connect(m_ui->actionWebsite, SIGNAL(triggered()), this, SLOT(OnOpenWebsite()));
	connect(m_ui->actionOnlineDocs, SIGNAL(triggered()), this, SLOT(OnOpenDocs()));
	connect(m_ui->actionGitHub, SIGNAL(triggered()), this, SLOT(OnOpenGitHub()));
	connect(m_ui->actionSystemInfo, SIGNAL(triggered()), this, SLOT(OnOpenSystemInfo()));
	connect(m_ui->actionAbout, SIGNAL(triggered()), this, SLOT(OnOpenAbout()));
	connect(m_ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(OnOpenAboutQt()));

	// Update GUI items
	emit CoreStateChanged(Core::CORE_UNINITIALIZED);

	// Platform-specific stuff
#ifdef Q_OS_MACX
	m_ui->toolbar->setMovable(false);
#endif
}
コード例 #16
0
// 初始化
void CTabSample::OnInit(void)
{
	// 控件选择
	for (int k=0; k<GraphViewNum; k++)
	{
		ProcessMessages();
		m_iSelectObject[k] = 0;
		m_iSelectObjectNoise[k] = 0;
		m_iButtonIDFDU[k] = IDC_BUTTON_FDU1 + k;
		m_iCheckIDInstrumentFDU[k] = IDC_CHECK_GRAPHVIEW1 + k;
		m_iCheckIDNoiseFDU[k] = IDC_CHECK_NOISE1 + k;
	}

	CString strtmp = _T("");
	for (int i=0; i<GraphViewNum; i++)
	{
		ProcessMessages();
		strtmp.Format(_T("仪器%d"), i+1);
		char* pchar = strtmp.GetBuffer(0); 
		strcpy_s(m_cSelectObjectName[i],pchar);
	}
	
	// 得到当前路径
	char cSaveToFilePath[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, cSaveToFilePath);
	m_csSaveFilePath = cSaveToFilePath;
	
	m_oThreadManage.m_oADCDataRecThread.m_pOScopeCtrl = &m_dlgADCData.m_OScopeCtrl;
	m_dlgADCData.m_ADCDataRecThread = &m_oThreadManage.m_oADCDataRecThread;

	// 得到本机IP地址
	char		name[255]; 
	CString		ip; 
	PHOSTENT	hostinfo; 
	if(   gethostname   (name, sizeof(name)) == 0) 
	{ 
		if((hostinfo = gethostbyname(name)) != NULL) 
		{ 
			ip = inet_ntoa(*(struct in_addr*)*hostinfo-> h_addr_list); 
		} 
	} 
	m_oThreadManage.m_HeadFrameSocket.m_csIPSource = ip;

	m_oThreadManage.m_TailFrameSocket.m_csIPSource = ip;
	m_oThreadManage.m_TailTimeFrameSocket.m_csIPSource = ip;
	m_oThreadManage.m_oSysTimeSocket.m_csIPSource = ip;
	m_oThreadManage.m_oADCDataRecThread.m_csIPSource = ip;

	m_oThreadManage.m_oSysTimeSocket.m_pADCSet = &m_oADCSet;
	m_oThreadManage.m_IPSetSocket.m_pADCSet = &m_oADCSet;


	CString str;
	str.Format("0x%04x", m_uiSendPort);
	GetDlgItem(IDC_EDIT_SENDPORT)->SetWindowText(str);

	str.Format("%d", m_uiADCFileLength);
	GetDlgItem(IDC_EDIT_ADCSAVEFRAMENB)->SetWindowText(str);

	m_iconFDUDisconnected = AfxGetApp()->LoadIcon(IDI_ICON1);
	m_iconFDUConnected = AfxGetApp()->LoadIcon(IDI_ICON2);
	m_iconLAUXDisconnected = AfxGetApp()->LoadIcon(IDI_ICON3);
	m_iconLAUXConnected = AfxGetApp()->LoadIcon(IDI_ICON4);
	
	m_oThreadManage.m_oInstrumentList.m_iconFDUDisconnected = m_iconFDUDisconnected;
	m_oThreadManage.m_oInstrumentList.m_iconLAUXDisconnected = m_iconLAUXDisconnected;
	m_oThreadManage.m_oInstrumentList.m_pwnd = this;
	m_oThreadManage.m_IPSetSocket.m_iconFDUConnected = m_iconFDUConnected;
	m_oThreadManage.m_IPSetSocket.m_iconLAUXConnected= m_iconLAUXConnected;
	m_oThreadManage.m_IPSetSocket.m_pwnd = this;
	m_oThreadManage.m_HeadFrameSocket.m_pwnd = this;

	
	m_oThreadManage.m_oSysTimeSocket.m_pSelectObject = m_iSelectObject;
	m_oThreadManage.m_oADCDataRecThread.m_pSelectObject = m_iSelectObject;
	m_oThreadManage.m_IPSetSocket.m_pSelectObject = m_iSelectObject;
	m_oThreadManage.m_oADCDataRecThread.m_pSelectObjectNoise = m_iSelectObjectNoise;
	for(int i=0; i<GraphViewNum; i++)
	{
		m_oThreadManage.m_oADCDataRecThread.m_cSelectObjectName[i] = m_cSelectObjectName[i];
		m_oThreadManage.m_oInstrumentList.m_iButtonIDFDU[i] = m_iButtonIDFDU[i];
		m_oThreadManage.m_IPSetSocket.m_iButtonIDFDU[i] = m_iButtonIDFDU[i];
		m_oThreadManage.m_oInstrumentList.m_iCheckIDInstrumentFDU[i] = m_iCheckIDInstrumentFDU[i];
		m_oThreadManage.m_IPSetSocket.m_iCheckIDInstrumentFDU[i] = m_iCheckIDInstrumentFDU[i];
	}
	CButton* iconbutton = NULL;
	CStatic* iconstatic = NULL;
	CButton* pButton = NULL;
	
	iconstatic =(CStatic*)this->GetDlgItem(IDC_STATIC_LAUX);
	iconstatic->SetIcon(m_iconLAUXDisconnected);
	iconstatic = NULL;
	
	for (int i=0; i<GraphViewNum; i++)
	{
		ProcessMessages();
		iconbutton = (CButton*)this->GetDlgItem(m_iButtonIDFDU[i]);
		iconbutton->SetIcon(m_iconFDUDisconnected);
		iconbutton = NULL;
		pButton = (CButton*)GetDlgItem(m_iCheckIDInstrumentFDU[i]);
		pButton->SetCheck(0);
		pButton = NULL;
		pButton = (CButton*)GetDlgItem(m_iCheckIDNoiseFDU[i]);
		pButton->SetCheck(0);
		pButton = NULL;
	}
	delete iconstatic;
	delete iconbutton;
	delete pButton;

	m_oThreadManage.OnInit();
	OnOpen();
	// 监测尾包定时器
	SetTimer(4, 1000, NULL);
	OnDisableButtons();
}
コード例 #17
0
void CTabSample::OnInit(void)
{
	m_iGraphViewId[0] = IDC_GRAPHSHOW1;
	m_iGraphViewId[1] = IDC_GRAPHSHOW2;
	m_iGraphViewId[2] = IDC_GRAPHSHOW3;
	m_iGraphViewId[3] = IDC_GRAPHSHOW4;

	for (int i=0; i<GraphViewNum;i++)
	{
		m_dSampleData[i].reserve(10240);
	}

	// 输入控件ID
	m_iMathId[0][0] = IDC_STATIC_AVERAGE1;
	m_iMathId[0][1] = IDC_STATIC_RMS1;
	m_iMathId[0][2] = IDC_STATIC_MAX1;
	m_iMathId[0][3] = IDC_STATIC_MIN1;

	m_iMathId[1][0] = IDC_STATIC_AVERAGE2;
	m_iMathId[1][1] = IDC_STATIC_RMS2;
	m_iMathId[1][2] = IDC_STATIC_MAX2;
	m_iMathId[1][3] = IDC_STATIC_MIN2;

	m_iMathId[2][0] = IDC_STATIC_AVERAGE3;
	m_iMathId[2][1] = IDC_STATIC_RMS3;
	m_iMathId[2][2] = IDC_STATIC_MAX3;
	m_iMathId[2][3] = IDC_STATIC_MIN3;

	m_iMathId[3][0] = IDC_STATIC_AVERAGE4;
	m_iMathId[3][1] = IDC_STATIC_RMS4;
	m_iMathId[3][2] = IDC_STATIC_MAX4;
	m_iMathId[3][3] = IDC_STATIC_MIN4;

	// 控件选择
	for (int k=0; k<GraphViewNum; k++)
	{
		m_iSelectObject[k] = 0;
		m_iSelectObjectNoise[k] = 0;
	}
	m_cSelectObjectName[0] = _T("仪器一");
	m_cSelectObjectName[1] = _T("仪器二");
	m_cSelectObjectName[2] = _T("仪器三");
	m_cSelectObjectName[3] = _T("仪器四");

	// 得到当前路径
	char cSaveToFilePath[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, cSaveToFilePath);
	m_csSaveFilePath = cSaveToFilePath;
	CScrollBar*pSB =(CScrollBar*)GetDlgItem(IDC_SCROLLBAR_GRAPHVIEW); 
	pSB->SetScrollRange(m_uiScrollBarMin,m_uiScrollBarMax); 


	// 创建绘图控件并设置相关参数
	CreateGraph(GraphViewNum, m_iGraphViewId, m_OScopeCtrl);
	// customize the control
	SetRange(-2.5, 2.5, 1, GraphViewNum, m_OScopeCtrl) ;
	SetYUnits("Y", GraphViewNum, m_OScopeCtrl) ;
	SetXUnits("X", GraphViewNum, m_OScopeCtrl) ;
	SetBackgroundColor(RGB(0, 0, 64), GraphViewNum, m_OScopeCtrl) ;
	SetGridColor(RGB(192, 192, 255), GraphViewNum, m_OScopeCtrl) ;
	SetPlotColor(RGB(255, 255, 255), GraphViewNum, m_OScopeCtrl) ;

	// 得到本机IP地址
	char		name[255]; 
	CString		ip; 
	PHOSTENT	hostinfo; 
	if(   gethostname   (name, sizeof(name)) == 0) 
	{ 
		if((hostinfo = gethostbyname(name)) != NULL) 
		{ 
			ip = inet_ntoa(*(struct in_addr*)*hostinfo-> h_addr_list); 
		} 
	} 
	m_oThreadManage.m_HeadFrameSocket.m_csIPSource = ip;

	m_oThreadManage.m_TailFrameSocket.m_csIPSource = ip;
	m_oThreadManage.m_TailTimeFrameSocket.m_csIPSource = ip;
	m_oThreadManage.m_oSysTimeSocket.m_csIPSource = ip;
	m_oThreadManage.m_ADCDataSocket.m_csIPSource = ip;

	m_oThreadManage.m_oSysTimeSocket.m_pADCSet = &m_oADCSet;


	CString str;
	str.Format("0x%04x", 0x8202);
	GetDlgItem(IDC_EDIT_SENDPORT)->SetWindowText(str);

	str.Format("%d", 406);
	GetDlgItem(IDC_EDIT_ADCSAVEFRAMENB)->SetWindowText(str);

	m_iconDisconnected = AfxGetApp()->LoadIcon(IDI_ICON1);
	m_iconConnected = AfxGetApp()->LoadIcon(IDI_ICON2);
	
	m_oThreadManage.m_oInstrumentList.m_iconDisconnected = m_iconDisconnected;
	m_oThreadManage.m_oInstrumentList.m_pwnd = this;
	m_oThreadManage.m_IPSetSocket.m_iconConnected = m_iconConnected;
	m_oThreadManage.m_IPSetSocket.m_pwnd = this;
//	m_oThreadManage.m_ADCDataSocket.m_pwnd = this;

	m_oThreadManage.m_ADCDataSocket.m_pSelectObject = m_iSelectObject;
	m_oThreadManage.m_ADCDataSocket.m_pSelectObjectNoise = m_iSelectObjectNoise;
	for(int i=0; i<GraphViewNum; i++)
	{
		m_oThreadManage.m_ADCDataSocket.m_pSampleData[i] = &m_dSampleData[i];
		m_oThreadManage.m_ADCDataSocket.m_pOScopeCtrl[i] = &m_OScopeCtrl[i];
		m_oThreadManage.m_ADCDataSocket.m_cSelectObjectName[i] = m_cSelectObjectName[i];
	}


	CStatic* icon;
	icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT1);
	icon->SetIcon(m_iconDisconnected);

	icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT2);
	icon->SetIcon(m_iconDisconnected);

	icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT3);
	icon->SetIcon(m_iconDisconnected);

	icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT4);
	icon->SetIcon(m_iconDisconnected);

	m_oThreadManage.OnInit();
	OnOpen();
	// 监测尾包定时器
	SetTimer(4, 1000, NULL);
}
コード例 #18
0
void CNetscapeSrvrItem::OnDoVerb(LONG iVerb)
{
	switch (iVerb)
	{
	// open - maps to OnOpen
	case OLEIVERB_OPEN:
	case -OLEIVERB_OPEN-1:  // allows positive OLEIVERB_OPEN-1 in registry
		OnOpen();
		break;

	// primary, show, and unknown map to OnShow
	case OLEIVERB_PRIMARY:  // OLEIVERB_PRIMARY is 0 and "Edit" in registry
	case OLEIVERB_SHOW:
	case OLEIVERB_UIACTIVATE: {
		COleServerDoc* pDoc = GetDocument();
		m_ShowUI = TRUE;
		OnShow();
		break;
	}					  

	case OLEIVERB_INPLACEACTIVATE: {
		COleServerDoc* pDoc = GetDocument();
		m_ShowUI = FALSE;
		OnShow();
		break;
   }

	// hide maps to OnHide
	case OLEIVERB_HIDE:
	case -OLEIVERB_HIDE-1:  // allows positive OLEIVERB_HIDE-1 in registry
		OnHide();
		break;


	case NO_UI_EMBEDDING:	{
		//Get InPlaceFrame ptr.
		CGenericDoc *pDoc = GetDocument();
		ASSERT(pDoc);

		POSITION pos = pDoc->GetFirstViewPosition();
		CView *pView = pDoc->GetNextView(pos);
		ASSERT(pView);

		m_ShowUI = FALSE;

		OnShow();

		CInPlaceFrame *pFrm = (CInPlaceFrame *)pView->GetParent();
		ASSERT(pFrm);

		pFrm->DestroyResizeBar();

		break;
		}
	default:
		// negative verbs not understood should return E_NOTIMPL
		if (iVerb < 0)
			AfxThrowOleException(E_NOTIMPL);

		// positive verb not processed --
		//  according to OLE spec, primary verb should be executed
		//  instead.
		OnDoVerb(OLEIVERB_PRIMARY);

		// also, OLEOBJ_S_INVALIDVERB should be returned.
		AfxThrowOleException(OLEOBJ_S_INVALIDVERB);
	}
}
コード例 #19
0
ファイル: ctlinplc.cpp プロジェクト: Rupan/winscp
HRESULT COleControl::OnActivateInPlace(BOOL bUIActivate, LPMSG pMsg)
{
#ifdef _AFXDLL
	if (m_bOpen)
	{
		m_pWndOpenFrame->SetActiveWindow();
		SendAdvise(OBJECTCODE_SHOWWINDOW);
		return S_OK;
	}
#endif

	// Initialize pointer to in-place site, if necessary.
	if (m_pInPlaceSite == NULL)
	{
		if (m_pClientSite == NULL)
			return E_UNEXPECTED;

		if ((GetControlFlags() & windowlessActivate) &&
			SUCCEEDED(m_pClientSite->QueryInterface(IID_IOleInPlaceSiteWindowless,
			reinterpret_cast<void**>(&m_pInPlaceSiteWndless))))
		{
			m_bInPlaceSiteWndless = m_bInPlaceSiteEx = TRUE;
		}
		else if ((GetControlFlags() & noFlickerActivate) &&
			SUCCEEDED(m_pClientSite->QueryInterface(IID_IOleInPlaceSiteEx,
			reinterpret_cast<void**>(&m_pInPlaceSiteEx))))
		{
			m_bInPlaceSiteEx = TRUE;
		}
		else if (SUCCEEDED(m_pClientSite->QueryInterface(IID_IOleInPlaceSite,
			reinterpret_cast<void**>(&m_pInPlaceSite))))
		{
			m_bInPlaceSiteEx = FALSE;
		}
		else
		{
			m_pInPlaceSite = NULL;
			return E_FAIL;
		}
	}

	ASSERT(m_pInPlaceSite != NULL);

	if ((m_bInPlaceActive && !bUIActivate) || m_bUIActive)
	{
		CWnd* pWndOuter = GetOuterWindow();
		HWND hwndParent;
		if ((pWndOuter != NULL) &&
			SUCCEEDED(m_pInPlaceSite->GetWindow(&hwndParent)) &&
			(hwndParent == ::GetParent(pWndOuter->m_hWnd)))
		{
			::SetWindowPos(pWndOuter->m_hWnd, NULL, 0, 0, 0, 0,
				SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|
				SWP_SHOWWINDOW);
			OnSetObjectRects(m_rcPos, NULL);
			return S_OK;
		}
	}

	// Check if container allows windowless activation.
	if (m_bInPlaceSiteWndless)
	{
		if (m_pInPlaceSiteWndless->CanWindowlessActivate() != S_OK)
			m_bInPlaceSiteWndless = FALSE;
	}

	HRESULT hr = E_FAIL;
	if (m_pInPlaceSite != NULL)
		hr = m_pInPlaceSite->CanInPlaceActivate();

	if (hr != NOERROR)
	{
		// Site doesn't allow in-place activation.
		return OnOpen(FALSE, pMsg);
	}

	if (!m_bInPlaceActive)
	{
		if (m_bInPlaceSiteEx)
		{
			// flicker-free and/or windowless activation
			BOOL bNoRedraw;
			m_pInPlaceSiteEx->OnInPlaceActivateEx(&bNoRedraw,
				m_bInPlaceSiteWndless ? ACTIVATE_WINDOWLESS : 0);
			if (GetControlFlags() & noFlickerActivate)
				m_bNoRedraw = bNoRedraw;
		}
		else
		{
			// old-style activation
			m_pInPlaceSite->OnInPlaceActivate();
		}
	}

	HWND hwndParent = NULL;

	if (SUCCEEDED(m_pInPlaceSite->GetWindow(&hwndParent)))
	{
		CRect rcClip;
		m_frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);

		RELEASE(m_pInPlaceFrame);
		RELEASE(m_pInPlaceDoc);

		if (SUCCEEDED(m_pInPlaceSite->GetWindowContext(
						&m_pInPlaceFrame, &m_pInPlaceDoc,
						&m_rcPos, &rcClip, &m_frameInfo)))
		{
			ASSERT(m_pInPlaceFrame != NULL);

			CRect rectClip;
			if (!m_bInPlaceSiteWndless)
			{
				_GetClippingCoordinates(&m_rcPos, &rcClip, rectClip,
					&m_ptOffset);
				m_bInPlaceActive = CreateControlWindow(hwndParent, m_rcPos,
					rectClip);
			}
			else
			{
				m_bInPlaceActive = TRUE;
			}

			if (m_bInPlaceActive)
			{
				if (bUIActivate)
				{
					if (m_bInPlaceSiteEx)
					{
						if (m_pInPlaceSiteEx->RequestUIActivate() != S_OK)
							m_pInPlaceSite->OnUIDeactivate(FALSE);
					}

					BuildSharedMenu();

					m_bUIActive = TRUE;
					m_pInPlaceSite->OnUIActivate();

					m_pInPlaceFrame->SetActiveObject(
						&m_xOleInPlaceActiveObject, NULL);
					if (m_pInPlaceDoc != NULL)
						m_pInPlaceDoc->SetActiveObject(
							&m_xOleInPlaceActiveObject, NULL);

					if (m_hWnd != NULL)
					{
						BOOL bHandles = AmbientShowGrabHandles();
						BOOL bHatching = AmbientShowHatching();

						if (bHandles || bHatching)
							CreateTracker(bHandles, bHatching, rcClip);
					}

					AddFrameLevelUI();

					if (bUIActivate != -1 &&
						(m_hWnd != NULL) && !IsChild(GetFocus()))
					{
						SetFocus();
					}
				}

				// Pass thru the window message that caused us to be activated
				if ((m_hWnd != NULL || m_bInPlaceSiteWndless) && (pMsg != NULL))
					ForwardActivationMsg(pMsg);

				// Send appropriate notifications...
				SendAdvise(OBJECTCODE_SHOWOBJECT);

				return S_OK;
			}
		}
	}

	RELEASE(m_pInPlaceFrame);
	RELEASE(m_pInPlaceDoc);

	return E_FAIL;
}
コード例 #20
0
ファイル: TabSample.cpp プロジェクト: svn2github/jy00755131
// 初始化
//************************************
// Method:    OnInit
// FullName:  CTabSample::OnInit
// Access:    public
// Returns:   void
// Qualifier:
// Parameter: void
//************************************
void CTabSample::OnInit(void)
{
    CString strtmp = _T("");
    // 得到当前路径
    char cSaveToFilePath[MAX_PATH];
    // 得到本机IP地址
// 	char		name[256];
// 	PHOSTENT	hostinfo;
    CString ip = IPHostAddr;
    CString str = _T("");
    // 控件选择
    for (int k=0; k<InstrumentNum; k++)
    {
        ProcessMessages();
        m_iSelectObject[k] = 0;
        m_iSelectObjectNoise[k] = 0;
        m_iButtonIDFDU[k] = IDC_BUTTON_FDU1 + k;
        m_iCheckIDInstrumentFDU[k] = IDC_CHECK_GRAPHVIEW1 + k;
        m_iCheckIDNoiseFDU[k] = IDC_CHECK_NOISE1 + k;
    }

    GetCurrentDirectory(MAX_PATH, cSaveToFilePath);
    m_csSaveFilePath = cSaveToFilePath;

    for (int i=0; i<InstrumentNum; i++)
    {
        m_dlgADCGraphShow[i].m_pADCDataRecThread = &m_oThreadManage.m_oADCDataRecThread;
    }
    // @@@@@@@@@需要改进,有时候会卡住

// 	if(   gethostname(name, sizeof(name)) == 0)
// 	{
// 		if((hostinfo = gethostbyname(name)) != NULL)
// 		{
// 			ip = inet_ntoa(*(struct in_addr*)*hostinfo-> h_addr_list);
// 		}
// 	}

    m_oThreadManage.m_oHeadFrameSocket.m_csIPSource = ip;
    m_oThreadManage.m_oTailFrameSocket.m_csIPSource = ip;
    m_oThreadManage.m_oTailTimeFrameSocket.m_csIPSource = ip;
    m_oThreadManage.m_oSysTimeSocket.m_csIPSource = ip;
    m_oThreadManage.m_oADCDataRecThread.m_csIPSource = ip;
    m_oThreadManage.m_oHeartBeatThread.m_csIPSource = ip;
    m_oThreadManage.m_oADCSetSocket.m_csIPSource = ip;

    str.Format(_T("0x%04x"), m_uiSendPort);
    GetDlgItem(IDC_EDIT_SENDPORT)->SetWindowText(str);

    str.Format(_T("%d"), m_uiADCFileLength);
    GetDlgItem(IDC_EDIT_ADCSAVEFRAMENB)->SetWindowText(str);

    m_iconFDUDisconnected = AfxGetApp()->LoadIcon(IDI_ICON1);
    m_iconFDUConnected = AfxGetApp()->LoadIcon(IDI_ICON2);
    m_iconLAUXDisconnected = AfxGetApp()->LoadIcon(IDI_ICON3);
    m_iconLAUXConnected = AfxGetApp()->LoadIcon(IDI_ICON4);

    m_oThreadManage.m_oInstrumentList.m_iconFDUDisconnected = m_iconFDUDisconnected;
    m_oThreadManage.m_oInstrumentList.m_iconLAUXDisconnected = m_iconLAUXDisconnected;
    m_oThreadManage.m_oInstrumentList.m_pwnd = this;
    m_oThreadManage.m_oIPSetSocket.m_iconFDUConnected = m_iconFDUConnected;
    m_oThreadManage.m_oIPSetSocket.m_iconLAUXConnected= m_iconLAUXConnected;
    m_oThreadManage.m_oIPSetSocket.m_pwnd = this;
    m_oThreadManage.m_oHeadFrameSocket.m_pwnd = this;
    m_oThreadManage.m_oSysTimeSocket.m_pwnd = this;

    m_oThreadManage.m_oADCSetSocket.m_pSelectObject = m_iSelectObject;
    m_oThreadManage.m_oIPSetSocket.m_pSelectObject = m_iSelectObject;
    for(int i=0; i<InstrumentNum; i++)
    {
        m_oThreadManage.m_oInstrumentList.m_iButtonIDFDU[i] = m_iButtonIDFDU[i];
        m_oThreadManage.m_oIPSetSocket.m_iButtonIDFDU[i] = m_iButtonIDFDU[i];
        m_oThreadManage.m_oInstrumentList.m_iCheckIDInstrumentFDU[i] = m_iCheckIDInstrumentFDU[i];
        m_oThreadManage.m_oIPSetSocket.m_iCheckIDInstrumentFDU[i] = m_iCheckIDInstrumentFDU[i];
    }

    OnResetCheckButton();
    OnResetButtonIcon();
    m_oThreadManage.OnInit();

    OnOpen();

    // 监测尾包定时器
    SetTimer(TabSampleTailMonitorTimerNb, TabSampleTailMonitorTimerSet, NULL);
    OnDisableButtons();
}
コード例 #21
0
BOOL CIOCPFileAccessor::Open(LPCTSTR lpFileName,
		  DWORD dwDesiredAccess, 
		  DWORD dwShareMode, 
		  LPSECURITY_ATTRIBUTES lpSecurityAttributes, 
		  DWORD dwCreationDisposition, 
		  DWORD dwFlagsAndAttributes,
		  int DataQueueSize,
		  int RequestQueuSize,
		  int ErrorQueuSize)
{

	if(m_FileHandle!=INVALID_HANDLE_VALUE)
	{
		Close();
	}

	if(GetServer()==NULL)
		return FALSE;

	if(m_pIOCPEventRouter==NULL)
	{
		m_pIOCPEventRouter=GetServer()->CreateEventRouter();	
		m_pIOCPEventRouter->Init(this);
	}

	if(!m_DataQueue.Create(DataQueueSize))
	{
		PrintNetLog(0,_T("CIOCPFileAccessor::创建数据缓冲失败"));
		return FALSE;
	}
	if(RequestQueuSize==0)
	{		
		m_UseAsyncQuery=true;
		PrintNetLog(0,_T("CIOCPFileAccessor::开启异步请求模式"));
	}
	else
	{
		m_UseAsyncQuery=false;
		if(!m_RequestQueue.Create(RequestQueuSize))
		{
			PrintNetLog(0,_T("CIOCPFileAccessor::创建请求缓冲失败"));
			return FALSE;
		}
	}
	if(!m_ErrorQueue.Create(ErrorQueuSize))
	{
		PrintNetLog(0,_T("CIOCPFileAccessor::创建错误缓冲失败"));
		return FALSE;
	}


	

	dwFlagsAndAttributes|=FILE_FLAG_OVERLAPPED;

	m_FileHandle=::CreateFile(lpFileName,dwDesiredAccess,dwShareMode,lpSecurityAttributes,
		dwCreationDisposition,dwFlagsAndAttributes,NULL);

	if(m_FileHandle==INVALID_HANDLE_VALUE)
	{
		UINT ErrorCode=GetLastError();
		PrintNetLog(0,_T("CIOCPFileAccessor::打开文件失败%u"),ErrorCode);
		PushError(FET_SYSTEM_ERROR,ErrorCode);
		return FALSE;
	}

	if(!GetServer()->BindFile(m_FileHandle))
	{
		Close();
		return FALSE;		
	}
	m_ReadPosition.QuadPart=0;
	m_WritePosition.QuadPart=0;
	OnOpen();
	return TRUE;
}