| |

VerySource

 Forgot password?
 Register
Search
View: 737|Reply: 4

What should I do?

[Copy link]

2

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-17 22:00:02
| Show all posts |Read mode
If you enter a string from the editbox in window A and click OK, it will be displayed in the editbox in window B. . .
  
  What should I do? I've included the header file, declaring the objects, but still haven't figured it out. help ~~
Reply

Use magic Report

0

Threads

55

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-1-28 07:18:01
| Show all posts
Call the pointer of window B in window A, and assign the edit box content of window A to the edit box of window B
Reply

Use magic Report

0

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-29 10:09:01
| Show all posts
Agree upstairs
Reply

Use magic Report

2

Threads

19

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-30 13:27:01
| Show all posts
Can also send messages
If both window A and window B should be members of the main window class

Define the message name:
#define message name (e.g. UWM_SEND_AWND_TEXT) (WM_APP + 0x100)

// Main window class
Class The main window class (such as CMainFrame or CMyMainDlg, etc.)
{
   CAwnd m_aWnd;
   CBwnd m_bWnd;
proteted:
   afx_msg LRESULT [Get message function name] (WPARAM, LPARAM);
   
}

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

// Get the message function entity
LRESULT main window class :: get message function name (WPARAM wParam, LPARAM lParam)
{
         // Only the example here is a CString type object, if it is an arbitrary type object such as CRect, it will become
         // CRect * pRect = (CRect) wParam; CRect m_rect = * pRect; ...
LPCTSTR * pText = (LPCTSTR *) wParam;
CString getText = * pText;
         
         m_bWnd. Function to set value (getText); // Implement the string wParam from Form A to Form B

        return 0;
}



Class CAwnd
{

}

CAwnd :: the name of the function to be sent
{
  UpdateData (TRUE);
  [Variable type to be transmitted] myObj; // such as CString myObj; CRect myObj, etc.
  :: SendMessage (AfxGetApp ()-> GetMainWnd ()-> GetSafeHwnd (), message name, (WPARAM)&myObj, 0);
}

class CBwnd
{

}
CBwnd :: function to set value (CString getStr)
{
   m_edtStr1 = getStr;
   UpdateDate (FALSE);
}
Reply

Use magic Report

2

Threads

19

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-30 15:00:01
| Show all posts
If it is not a member variable of the main window
Just move the message response function in the main window class to the CBwnd class
Send a message to the handle of the CBwnd object in the CAwnd class.
:: SendMessage (m_Bwnd.GetSafeHwnd (), message name, (WPARAM)&myObj, 0);
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