Re: document class
Or in other words: the CStringList in the XML Class, includes all user
information at startup (loaded from the xml file). After that each
class will get their specific data in the OnNewDocument method
BOOL CMIAppDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
//parse the whole xml file -> XmlFile is now a global variable of the
XML File class
if(!(XmlFile.LoadUserXml()))
return FALSE;
//init display (getting the information from the xml
list)
DisplayInfo.Init(XmlFile.GetParamsForDisplay());
NetworkInfo.Init(XmlFile.GetParamsForNetwork());
return TRUE;
}
By the way is this a good place to init all classes? NetworkInfo,
DisplayInfo, XmlFile are global variables of their specific class - no
longer a member of the document class.
The user open the dialog for the display settings, set some other
parameters for the display; -> after clicking on OK button the display
class will get these new information and will call the xml file class
by the global xml file class variable to store these values in the
CStringlist (CXML File class). After that the CXML File class will
open the xml file again and store these new information in the xml
file.
If the user change some values by the webserver -> he will generate a
post message to the http-socket class -> this class will send these
new information to the visible window class. From there I will call
the CNetwork class to check if these information are valid (for
example if the ip addr is valid and so on), after that I will send the
checked information to the xml class to update the CStringList.
LRESULT CMIVisWnd::OnSetDataFromHttp(WPARAM wParam, LPARAM lParam)
{
CStringList *slist = (CStringList *)wParam;
if(!(NetworkInfo.CheckIfParamsValid(slist)))
return FALSE;
//if valid then send these information to the xml list to store
these information
XmlFile.SetParams(slist);
//send a message back to the http thread class -> the user will
rxd the same page with the updated values and a message if everthing
was ok
CStringArray *sArr = (CStringArray *)XmlFile.GetArray();
::PostThreadMessage(lParam, UWM_HTTP_XML_FILE, (WPARAM)sArr, 0);
//setup all views
doc->SetViews();
return TRUE;
}
Should I also call the document method to update the views after these
new information are stored in the xml stringlist?
The document class do not need these new information, because if the
document class will call OnUpdateViews() - I will use the global
variable from the XML file class to get these values.
void CMIAppDoc::SetViews()
{
CStringList *slist = XmlFile.GetXmlDataForView();
UpdateAllViews(Null, UPD_PARAMS, slist );
}
Is it possible to use this local CStringList to update the views; or
do I have to install a protected member in the document class
(CStringList sListUpdViews)?
class CMIAppDoc : public CDocument
{
protected:
CStringList sListUpdViews
}
best regards
Hans