| |

VerySource

 Forgot password?
 Register
Search
View: 679|Reply: 5

Newbie question: How to pass the message ??? What message is drawn by drawing

[Copy link]

3

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-21 08:40:01
| Show all posts |Read mode
Please brother door to help me with this newbie.
I receive data from the serial port (in the View class), a data is received in the View, a message is sent to the Dialog, and a point is drawn in the Dialog to achieve real-time effects.
Wondering: What message should I send? How to send it?
Sorry, I didn't learn VC for a long time and didn't know much.
I beg everyone to help, anxious.
Reply

Use magic Report

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-31 13:54:01
| Show all posts
Message can be customized, WM_USER + X
Reply

Use magic Report

2

Threads

19

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-31 14:18:01
| Show all posts
Define the message name:
#define message name (e.g. UWM_SEND_LINE) (WM_APP + 0x100)

// Receive message window class
Class CMyDialog
{

proteted:
   afx_msg LRESULT [Get message function name] (WPARAM, LPARAM);
   
}

// BEGIN_MESSAGE_MAP (CMyDialog, CDialog)
ON_MESSAGE (message name, get message function name)
// END_MESSAGE_MAP ()

// Get the message function entity
LRESULT CMyDialog :: Get message function name (WPARAM wParam, LPARAM lParam)
{
         // The example here is only a CPoint type object.If it is an arbitrary type object such as CRect, it will become
         // CRect * pRect = (CRect) wParam; CRect m_rect = * pRect; ...
LPCTSTR * pPoint = (LPCTSTR *) wParam;
CPoint point1 = * Point;
         
        // poin1 is the point value you want to get
       
       // ........................................
          
        return 0;
}





CMyView :: Name of function to pass point value ()
{
  CPoint myPoint; // Also CRect myObj, etc.
  :: SendMessage (Dialog object name.GetSafeHwnd (), message name, (long)&myPoint, 0);
  // If you don't get the dialog object name variable, you can send this message to the main frame window to relay it.
 // It should be easy to get the dialog object variables
 // :: SendMessage (AfxGetMaiWnd ()-> GetSafeHwnd (), message name, (long)&myPoint, 0);
}
Reply

Use magic Report

2

Threads

19

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-31 15:00:02
| Show all posts
In the code
LPCTSTR * pPoint = (LPCTSTR *) wParam;
Should be
CPoint * pPoint = (CPoint *) wParam;
Reply

Use magic Report

3

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-2-1 12:18:01
| Show all posts
Thanks for your tears! Thank you! Thanks for helping me to be a novice to learn VC while doing Bishe to cope with the teacher!
I'll go back and try it right away.
There are still two months, and Bishe will be miserable if he can't do it, unless he spends money to find someone to help. . .
Alas, I regret not having studied well.
Thank you very much,mystonelh!
Reply

Use magic Report

3

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-3-5 14:45:01
| Show all posts
So thank you
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list