Passing data btwn 2 independent classes

I have a CEditDoc class and a CListBox class which are independent of one another. I only need to pass strings between them. I have seen code that manually writes and reads from global memory to pass data but that seems too heavy and messy for something as simple as this. Anyone have any suggestions or insight for an C++/MFC way of doing this?
hi,
This thing is not at all simple. Are these classes load in same process or different, is the same application using them, are they in same machine or different? Your solution depends upon all these factors.
Ive got a litle something identical to your items here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <radc++.h> 

/*
	It is suggested that you try understanding Simple Form and Menus examples first
	and then get to this example.
	
	NOTE: This program may crash if file size is larger than 65535 (65.5 kb), becuase
	richtextbox by default accomodates 65535 bytes. Use RichTextBox::setLimit() to accomodate
	number of characters.
*/

Form form1("Mini NotePad Example - RAD C++ Example");

Menu menu(form1);
MenuItem __File,__Open,__Save,__Exit,__Help,__About;
RichTextBox txt("", AUTO_ID, 0, 0, 0, 0, form1);

FormProcedure form1Proc(FormProcArgs) {
	ON_CLOSE() 	Application.close();

	ON_COMMAND_BY(__Exit) Application.close();
	ON_COMMAND_BY(__About) 
           form1.infoBox("Mini NotePad Example - RAD C++ 1.2\r\n\r\nby www.radcpp.com");

	ON_COMMAND_BY (__Open) {
		if(form1.open()) {                 //yes user selected file
			BinaryData bin;
			bin.loadFile(form1.fileName);  //load selected file
			txt.text = bin.c_str();        //get NULL terminated string only
			bin.clear();                   //release the memory
			form1.caption = form1.fileName;
		}
	}
	ON_COMMAND_BY (__Save) {
		if(form1.save()) {                 //yes user selected file to save
			BinaryData bin;
			String data = txt.text;
			bin.add((UCHAR *)data.c_str(),data.length);         //get NULL terminated string and save to file
			bin.writeFile(form1.fileName);                
			bin.clear();                   //release the memory
			form1.caption = form1.fileName;
		}
	}	
	ON_RESIZE() txt.fitExact();
	return 0;
}

rad_main()

		form1.procedure = form1Proc;
		txt.fitExact();
		
        //main menus
		__File = menu.add("&File");
		__Help = menu.add("&Help");
		
        //sub-menus tracked	 
        __Open = __File.add("&Open",AUTO_ID);
        __Save = __File.add("&Save",AUTO_ID);
                 __File.addSeparator();
		__Exit = __File.add("E&xit",AUTO_ID);	 
		__About = __Help.add("&About",AUTO_ID);	 
		

		
rad_end()


This isnt much but its a Mini NotePad where you can save the documents as anything you like
Topic archived. No new replies allowed.