| |

VerySource

 Forgot password?
 Register
Search
Author: bluekaze

DoModal () problem

[Copy link]

0

Threads

17

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-7-12 21:30:01
| Show all posts
Thewqkbosssmethod is good. It is best not to let two different things have too many connections. You can modify the dialog constructor to pass the pointer of the selected item.
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-13 23:30:01
| Show all posts
Add #include XX.h to the CPP file of the child window where XX.h is your parent window file, so that in the child window program you can use ((Cxx*)GetParent())-> to access the parent window Any public variable. Note that the header file can only be added in the cpp file
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-13 23:45:01
| Show all posts
It seems that I forgot to order something. If GETPARENT() cannot be used, you can add functions or variables in the child window, and save the pointer of the parent window before DOMODAL.
Reply

Use magic Report

2

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-25 11:15:01
| Show all posts
How to pass parameters
Is it to define a global variable?
Reply

Use magic Report

0

Threads

17

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-7-25 12:15:01
| Show all posts
Modify Dialog's constructor to pass parameters. Try not to use global variables.
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-25 15:00:01
| Show all posts
Add in the window conversion function. That is, if you click a button to convert the window, then add it in the button's message response function. As follows:
    UpdateData();


::SendMessage(m_hWnd, WM_CLOSE, 0, 0); //Hide the current window
     
     CTest1 dlg;//The class to call the window
To
dlg.m_copy = m_str;//m_str is the current window variable, m_copy is the variable to call the window

dlg.DoModal();//Call the dialog box of CTest1 class

m_str&m_copy is best to be of CString type, and both are int type!!!!
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