Click here to Skip to main content
15,914,444 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: How to control attribute initialization order for controls? Pin
Patrick Etc.10-Jan-08 12:31
Patrick Etc.10-Jan-08 12:31 
GeneralRe: How to control attribute initialization order for controls? Pin
RichardM110-Jan-08 12:48
RichardM110-Jan-08 12:48 
QuestionHow to comunicate between two Windows Forms in BOTH directions???? Pin
szymon7910-Jan-08 8:12
szymon7910-Jan-08 8:12 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Dave Kreskowiak10-Jan-08 10:36
mveDave Kreskowiak10-Jan-08 10:36 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
szymon7910-Jan-08 10:57
szymon7910-Jan-08 10:57 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
RichardM110-Jan-08 11:19
RichardM110-Jan-08 11:19 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
szymon7910-Jan-08 11:43
szymon7910-Jan-08 11:43 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
RichardM110-Jan-08 12:13
RichardM110-Jan-08 12:13 
You have a seperate "person.h" that defines the class "person".
Both form1 and form2 include person.h.
Form1 also includes form2.h, since it will have to create one, but it never needs to know more than the constructor.
Form2 updates itself from person, and from change events from person. Form1 does the same. So again, they have no knowledge of the internals of the other.
Bear with me on this, I have not done c++ in a while, and not without an IDE in an even longer time, so this is more psuedo code than code, or maybe it is a hybrid with c#.

person.h
class person<br />
{<br />
  public person(string name, DateTime birthday); // constructor<br />
  void SetName(string name);<br />
  string GetName();<br />
  void SetBDay(DateTime birthday);<br />
  string GetBDay();<br />
  // callBackType is declared elsewhere and is just a standard event.<br />
  void AddBDayChangeCallBack(callBackType callBack);<br />
  void DelBDayChangeCallBack(callBackType callBack);<br />
}


person.cpp
class person<br />
{<br />
  private string m_name = "";<br />
  private DateTime m_birthDay = new DateTime();<br />
  private callBackTypeList m_bDayChangeCallbacks = new callBackTypeList();<br />
<br />
  public constructor person(string name, DateTime birthday)<br />
  {<br />
    SetName(name);<br />
    SetBDay(birthday);<br />
  }<br />
  void SetName(string name){}<br />
  string GetName(){}<br />
  void SetBDay(DateTime birthday)<br />
  {<br />
    m_birthDay = birthday;<br />
    foreach(callBackType event in m_bDayChangeCallbacks)<br />
    {<br />
      // sorry, I forgot the real syntax for invoking function pointers.<br />
      invoke(event(this)); <br />
    }<br />
  }<br />
  string GetBDay(){}<br />
  void AddBDayChangeCallBack(callBackType callBack)<br />
  {<br />
    bDayChangeCallbacks.Add(callBack);<br />
  }<br />
  void DelBDayChangeCallBack(callBackType callBack)<br />
  {<br />
    bDayChangeCallbacks.Remove(callBack);<br />
  }<br />
}


So form1 and form2 both include person.h.
form1.h and form2.h do not expose any of the components of the forms, just constructors/destructors.
The form2 constructor takes a person as a parameter, and that is how it is notified of the person, though you could also have a "void SetPerson(person perp);" definition somewhere.

Wow. That is too bad they flatten indentation.

I want to die like my Grandfather.
Peaceful, Sleeping.
Not screaming like his passengers.

GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Luc Pattyn10-Jan-08 12:14
sitebuilderLuc Pattyn10-Jan-08 12:14 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
RichardM110-Jan-08 12:20
RichardM110-Jan-08 12:20 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Patrick Etc.10-Jan-08 12:25
Patrick Etc.10-Jan-08 12:25 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Luc Pattyn10-Jan-08 12:56
sitebuilderLuc Pattyn10-Jan-08 12:56 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Luc Pattyn10-Jan-08 12:55
sitebuilderLuc Pattyn10-Jan-08 12:55 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
RichardM110-Jan-08 13:08
RichardM110-Jan-08 13:08 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Luc Pattyn10-Jan-08 13:13
sitebuilderLuc Pattyn10-Jan-08 13:13 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
RichardM110-Jan-08 13:30
RichardM110-Jan-08 13:30 
Generalscholar & gentleman Pin
Luc Pattyn10-Jan-08 13:43
sitebuilderLuc Pattyn10-Jan-08 13:43 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Dave Kreskowiak10-Jan-08 13:11
mveDave Kreskowiak10-Jan-08 13:11 
QuestionEnding C# app gracefully on shutdown Pin
Clutchplate10-Jan-08 7:44
Clutchplate10-Jan-08 7:44 
GeneralRe: Ending C# app gracefully on shutdown Pin
Luc Pattyn10-Jan-08 8:22
sitebuilderLuc Pattyn10-Jan-08 8:22 
GeneralRe: Ending C# app gracefully on shutdown Pin
Clutchplate11-Jan-08 5:49
Clutchplate11-Jan-08 5:49 
GeneralRe: Ending C# app gracefully on shutdown Pin
Clutchplate11-Jan-08 6:58
Clutchplate11-Jan-08 6:58 
GeneralRe: Ending C# app gracefully on shutdown Pin
Luc Pattyn11-Jan-08 7:33
sitebuilderLuc Pattyn11-Jan-08 7:33 
Generalweb services in windows application Pin
caradri10-Jan-08 0:45
caradri10-Jan-08 0:45 
GeneralRe: web services in windows application Pin
Kschuler10-Jan-08 9:56
Kschuler10-Jan-08 9:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.