15,979
社区成员
发帖
与我相关
我的任务
分享
void CMyStatic::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ShowWindow(FALSE);
Invalidate();
CStatic::OnLButtonDblClk(nFlags, point);
}
1.重载CStatic类的cpp文件
// MyStatic.cpp : implementation file
BEGIN_MESSAGE_MAP(CMyStatic, CWnd)
//{{AFX_MSG_MAP(CMyStatic)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_LBUTTONDBLCLK()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyStatic message handlers
void CMyStatic::OnPaint()
{
CNetWatcherViewerView *pView=(CNetWatcherViewerView *)((CMainFrame *)AfxGetMainWnd())->GetActiveView() ;
CPaintDC dc(this); // device context for painting
CNetWatcherViewerDoc* pDoc = (CNetWatcherViewerDoc*)((CView*)GetParent())->GetDocument();
if( pDoc->m_bRecvFlag){
DrawCurve(dc);
}
}
void CMyStatic::DrawCurve(CPaintDC& dc)
{
//图像的绘制部分
}
BOOL CMyStatic::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
GetClientRect(rect);
pDC->FillSolidRect(rect,RGB(230,230,230));
return TRUE;
//return FALSE;
//return CWnd::OnEraseBkgnd(pDC);
}
void CMyStatic::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ShowWindow(SW_HIDE);
CWnd::OnLButtonDblClk(nFlags, point);
}
2.视图类的cpp文件
// NetWatcherViewerView.cpp : implementation of the CNetWatcherViewerView class
//
/////////////////////////////////////////////////////////////////////////////
// CNetWatcherViewerView
IMPLEMENT_DYNCREATE(CNetWatcherViewerView, CScrollView)
BEGIN_MESSAGE_MAP(CNetWatcherViewerView, CScrollView)
//{{AFX_MSG_MAP(CNetWatcherViewerView)
ON_WM_ERASEBKGND()
ON_COMMAND(IDC_BUTTON3, ButtonCheck_choice1)
ON_COMMAND(IDC_BUTTON3, UpButtonCheck_choice1)
ON_COMMAND(ID_CONFIG_VIEW_SIGNALTIME, OnConfigViewSignaltime)
ON_UPDATE_COMMAND_UI(ID_CONFIG_VIEW_SIGNALTIME, OnUpdateConfigViewSignaltime)
ON_COMMAND(ID_CONFIG_VIEW_FFT, OnConfigViewFft)
ON_UPDATE_COMMAND_UI(ID_CONFIG_VIEW_FFT, OnUpdateConfigViewFft)
ON_WM_TIMER()
ON_COMMAND(ID_CONFIG_CHANNELCONFIG, OnConfigChannelconfig)
ON_COMMAND(IDC_BUTTON4, ButtonCheck_choice2)
ON_COMMAND(IDC_BUTTON4, UpButtonCheck_choice2)
ON_COMMAND(IDC_BUTTON5, ButtonCheck_choice3)
ON_COMMAND(IDC_BUTTON6, ButtonCheck_choice4)
ON_COMMAND(IDC_BUTTON6, UpButtonCheck_choice4)
ON_COMMAND(IDC_BUTTON7, ButtonCheck_choice5)
ON_COMMAND(IDC_BUTTON7, UpButtonCheck_choice5)
ON_COMMAND(IDC_BUTTON8, ButtonCheck_choice6)
ON_COMMAND(IDC_BUTTON8, UpButtonCheck_choice6)
ON_COMMAND(IDC_BUTTON9, ButtonCheck_choice7)
ON_COMMAND(IDC_BUTTON9, UpButtonCheck_choice7)
ON_COMMAND(IDC_BUTTON10, ButtonCheck_choice8)
ON_COMMAND(IDC_BUTTON10, UpButtonCheck_choice8)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
ON_MESSAGE(WM_RECVDATAOK, OnRecvDataOK)
ON_COMMAND_RANGE(IDC_BUTTON1, IDC_BUTTON10, OnButton)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNetWatcherViewerView construction/destruction
CNetWatcherViewerView::CNetWatcherViewerView()
{
// TODO: add construction code here
}
CNetWatcherViewerView::~CNetWatcherViewerView()
{
}
BOOL CNetWatcherViewerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx=::GetSystemMetrics(SM_CXFULLSCREEN);
cs.cy=::GetSystemMetrics(SM_CYFULLSCREEN);
m_iClientW =cs.cx ; m_iClientH =cs.cy ;
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CNetWatcherViewerView drawing
void CNetWatcherViewerView::OnDraw(CDC* pDC)//重绘函数
{
CNetWatcherViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
SetTimer(0,1000,NULL); //1000 ms = 1 s
//int nLen=m_pView->m_edit4.GetWindowTextLength();
//pText="hello\r\n";
//m_pView->m_edit4.SetSel(nLen, nLen);
//m_pView->m_edit4.ReplaceSel(pText);
//m_pView->m_edit4()
//m_pView->m_edit4.SetSel(nLen, nLen);
//if( pDoc->m_bRecvFlag){
//DrawCurve(pDC, m_uiChannelIndex);
//////////////////////////////////////////////////////////////////////////
//}
}
void CNetWatcherViewerView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CChannelConfigDlg m_ChannelConfigDlg(this);
CSize sizeTotal;
connect_state="正在监听";
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
m_static_channel1.Create("Static",WS_CHILD|WS_VISIBLE|WS_BORDER|SS_NOTIFY, CRect (80,80,m_iClientW-80,(m_iClientH/2-50)/8+80),this,IDC_STATIC_CHANNEL1);
BOOL CNetWatcherViewerView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
if (m_gEraseBk)
{
pDC->FillSolidRect(0,0,m_iClientW,m_iClientH,RGB(0,78,115));//(左上角X,Y,widith,height,color)
m_gEraseBk = FALSE;
}
return TRUE;
}
void CNetWatcherViewerView::Refresh()
{
if (m_doubleclick==TRUE)
Invalidate();
}
ON_COMMAND(IDC_STATIC_CHANNEL1, Refresh)
afx_msg void Refresh();
m_static_channel1.CreateEx(WS_EX_CLIENTEDGE, "Static", "",WS_CHILD|WS_VISIBLE|WS_BORDER|SS_NOTIFY, CRect (80,80,m_iClientW-80,(m_iClientH/2-50)/8+80),this,IDC_STATIC_CHANNEL1);
m_static_channel1.m_uiChannelIndex=1;