Home > Software engineering >  How the data sharing between m f c window
How the data sharing between m f c window

Time:09-29

May be the message mechanism are not familiar with, in my present cognitive, MFC window class to instantiate an object first, and then call him, according to

I have a aDlg class, there are bDlg b, cDlg c two window class object,

Before I talk to other Windows is achieved by global variable data interaction, but project needs no global variables, now, I want to ask next

How to get in b c data,,,

Will handle the compulsory c type into a message, and then sent to b is feasible, and seek advice

CodePudding user response:

Can I take a custom message to interaction
Define the message
Message mapping function
SendMessage


CodePudding user response:

If it is a window, you can create a custom message mapping, then the other to get the window handle of the window, you can send this window corresponds to the message, at the same time bring data

CodePudding user response:

Pointer to a with b, c, b also set a pointer, c also set a pointer, the b through a can use c pointer

CodePudding user response:

In the main class defined in a subclass object, unified by the main class pointer call
Ensure that each class object data is only a copy

CodePudding user response:

Pointer, brother

CodePudding user response:

Pointer, interprocess communications,

Pointer is a direct way,
Interprocess communication is a bit complicated, need to transfer window handle and make agreement, relatively a bit complicated,

CodePudding user response:

Window way of sharing data between a lot of, if the two window object exist at the same time, it can be through the pointer, or message, etc. Complex and socket, file, pipe Shared memory. And so on.

Does not use global variables, you can use the singleton pattern, or directly using a static member.

CodePudding user response:

Transfer data with a pointer to a pointer to b module, the module b to c module, in this way, each module can access Shared data, message or call can be

CodePudding user response:

Can in each window by sending a message

CodePudding user response:

SendMessage/PostMessage, assignment variables, global variables, the common reading and writing the same file, what of, can

CodePudding user response:

Global variables can be realized, now there is no global variables, then use a static variable to achieve,
Window message, of course, is a good method,

CodePudding user response:

News, pipes, Shared memory can be,

CodePudding user response:

1, a global variable
2, read and write files
3, the socket
4, scrapbooking

CodePudding user response:

Define a specialized management class, the result of data from this class to share

CodePudding user response:

Shared memory,

CodePudding user response:

Interface, feel with good news,
  • Related