Home > Software engineering >  Everyone a great god for help!!!!!! I in MFC dialog box procedure, in the OnTimer call Invalidate (F
Everyone a great god for help!!!!!! I in MFC dialog box procedure, in the OnTimer call Invalidate (F

Time:09-24

Everyone a great god for help!!!!!! I in MFC dialog box procedure, in the OnTimer call Invalidate (FALSE) in the OnPaint drawing, why the mouse to widen or narrow window, graphical display ah, how the data changes displayed?

CodePudding user response:

Invalidate (TRUE);//not FALSE

CodePudding user response:

Invalidate (TRUE); So it is no use I was inside the ontimer every 1 second read serial data, and then draw in the onpaint, not real-time display, have to change the window size to display

CodePudding user response:

Onpaint drawing in the serial data not related!

CodePudding user response:

Is drawn directly in the dialog? Or the use of controls? Had better have the code, so analysis problems

CodePudding user response:

 
//SerialTestDlg. CPP: implementation file
//

# include "stdafx. H"
# include "SerialTest. H"
# include "SerialTestDlg. H"
# include "afxdialogex. H"

# ifdef _DEBUG
# define new DEBUG_NEW
# endif


//for application "about" menu item CAboutDlg dialog

The class CAboutDlg: public CDialogEx
{
Public:
CAboutDlg ();

//data dialog
Enum {IDD=IDD_ABOUTBOX};

Protected:
Virtual void DoDataExchange (CDataExchange * symbol;//support DDX/DDV

//implementation
Protected:
DECLARE_MESSAGE_MAP ()
};

CAboutDlg: : CAboutDlg () : CDialogEx CAboutDlg: : (IDD)
{
}

Void CAboutDlg: : DoDataExchange (CDataExchange * symbol)
{
CDialogEx: : DoDataExchange (symbol);
}

BEGIN_MESSAGE_MAP (CAboutDlg CDialogEx)
END_MESSAGE_MAP ()


//CSerialTestDlg dialog



CSerialTestDlg: : CSerialTestDlg (pParent/*=NULL CWnd * */)
: CDialogEx (CSerialTestDlg: : IDD, pParent)
, m_setOk (false)
, m_strTXData (_T (" "))
, m_strRXData (_T (" "))
, m_strRXData2 (_T (" "))
, m_strRXData3 (_T (" "))
{
M_hIcon=AfxGetApp () - & gt; LoadIcon (IDR_MAINFRAME);
}

Void CSerialTestDlg: : DoDataExchange (CDataExchange * symbol)
{
CDialogEx: : DoDataExchange (symbol);
DDX_Control (symbol, IDC_COMBO_COM m_comboCom);
DDX_Control (symbol, IDC_MSCOMM1 m_ctrlComm);
DDX_Text (symbol, IDC_EDIT_TXDATA m_strTXData);
DDX_Text (symbol, IDC_EDIT_RXDATA m_strRXData);
DDX_Text (symbol, IDC_EDIT_RXDATA2 m_strRXData2);
DDX_Text (symbol, IDC_EDIT_RXDATA3 m_strRXData3);
}

BEGIN_MESSAGE_MAP (CSerialTestDlg CDialogEx)
ON_WM_SYSCOMMAND ()
ON_WM_PAINT ()
ON_WM_QUERYDRAGICON ()
//ON_BN_CLICKED (IDC_BUTTON1, & amp; CSerialTestDlg: : OnBnClickedButton1)
ON_CBN_SELCHANGE (IDC_COMBO_COM, & amp; CSerialTestDlg: : OnCbnSelchangeComboCom)
ON_BN_CLICKED (IDC_BUTTON_SEND, & amp; CSerialTestDlg: : OnBnClickedButtonSend)
ON_BN_CLICKED (IDC_BUTTON_CLEANUP, & amp; CSerialTestDlg: : OnBnClickedButtonCleanup)
ON_EN_CHANGE (IDC_EDIT_TXDATA, & amp; CSerialTestDlg: : OnEnChangeEditTxdata)
ON_WM_TIMER ()
ON_BN_CLICKED (IDC_BUTTON_STOP, & amp; CSerialTestDlg: : OnBnClickedButtonStop)
END_MESSAGE_MAP ()


//CSerialTestDlg message handler

BOOL CSerialTestDlg: : OnInitDialog ()
{
CDialogEx: : OnInitDialog ();

//will "about... "Menu item added to the system menu,

//IDM_ABOUTBOX must be in the system command range,
ASSERT ((IDM_ABOUTBOX & amp; 0==IDM_ABOUTBOX xfff0));
ASSERT (IDM_ABOUTBOX & lt; 0 xf000);

CMenu * pSysMenu=GetSystemMenu (FALSE);
If (pSysMenu!=NULL)
{
BOOL bNameValid;
Cstrings strAboutMenu;
BNameValid=strAboutMenu. LoadString (IDS_ABOUTBOX);
ASSERT (bNameValid);
if (! StrAboutMenu. IsEmpty ())
{
PSysMenu - & gt; The AppendMenu (MF_SEPARATOR);
PSysMenu - & gt; AppendMenu (MF_STRING IDM_ABOUTBOX, strAboutMenu);
}
}

//set this dialog ICONS, when the application is the main window is not a dialog, the framework will automatically
//do this
SetIcon (m_hIcon, TRUE);//set the large icon
SetIcon (m_hIcon, FALSE);//set the small icon

//TODO: add additional initialization code in the

M_comboCom. AddString (_T (" COM1 "));//for the combo box control list box to add list items
M_comboCom. AddString (_T (" COM2 "));
M_comboCom. AddString (_T (" COM3 "));
M_comboCom. AddString (_T (" COM4 "));
M_comboCom. AddString (_T (" COM5 "));
M_comboCom. AddString (_T (" COM6 "));
M_comboCom. AddString (_T (" COM7 "));
M_comboCom. AddString (_T (" COM8 "));
M_comboCom. AddString (_T (" COM9 "));
M_comboCom. AddString (_T (" \ \ \ \. \ \ COM10 "));
M_comboCom. AddString (_T (" \ \ \ \. \ \ COM11 "));
M_comboCom. AddString (_T (" \ \ \ \. \ \ COM12 "));
M_comboCom. AddString (_T (" \ \ \ \. \ \ COM13 "));
M_comboCom. AddString (_T (" \ \ \ \. \ \ COM14 "));
//SetTimer (1, 1000, NULL);
Return TRUE;//unless set focus to the control, return TRUE
}

Void CSerialTestDlg: : OnSysCommand (UINT nID, LPARAM LPARAM)
{
If ((nID & amp; 0 xfff0)==IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
DlgAbout. DoModal ();
}
The else
{
CDialogEx: : OnSysCommand (nID, lParam);
}
}

//if the dialog box to add a minimize button, you need the following code
//to draw the icon, to use the document/view model of MFC application,
//it will be done automatically by the framework,

Void CSerialTestDlg: : OnPaint ()
{

//CPaintDC dc (this);//for drawing device context
CClientDC dc (this);
+ 20 CRect newrect_one (I, j, I, j + 30);

Dc. MoveTo (500, 250);
Dc. LineTo (500, 0);
Dc. MoveTo (560, 250);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related