Home > Software engineering > CSerialPort problem: how to call in a dialog box, another dialog box to write a serial port function
CSerialPort problem: how to call in a dialog box, another dialog box to write a serial port function
Time:10-03
I did an MFC project, which contains multiple button pop-up dialog box, I put the CSerialPort class in one dialog box: Create an object CSerialPort m_Port; And add a serial port data receiving the response function afx_msg LONG OnCommunication (WPARAM ch, LPARAM port); Now, I need another dialog box to write a serial port operation, the use of is m_Port WriteToPort strdata, strlen (); But always wrong? Could you tell me what predecessors the cause of the error? Starting with how to solve? Thank you very much! An error condition is illustrated below:
CodePudding user response:
Do you want to look like this: The class function { Class variables - & gt; Function () is, in fact is equal to this - & gt; Class variables - & gt; Function (); } Your second dialog box is not corresponding to this pointer,
Below is the pseudo code Method one: Class A {
Public: M_port;
};
A g_DlgA;
B: : Test {
G_DlgA. M_port - & gt; WritePort ();
}
Method 2:
Class A {
Private: M_port;
Public WritePort () { M_port. WritePort (); }
};
A g_DlgA;
B: : Test {
G_DlgA. WritePort ();
}
CodePudding user response:
CSerialPort m_Port;//do you use inside another class defined global! You describe the inside of the code don't see issues with debugging information
CodePudding user response:
Define a pointer dialog, and then the corresponding dialog pointer into, again calling pointer call m_port write, In addition, why do you want to put the writing to another dialog box inside, have what necessary?