当前位置: 首页>>代码示例>>C++>>正文


C++ TDocument::SetTemplate方法代码示例

本文整理汇总了C++中TDocument::SetTemplate方法的典型用法代码示例。如果您正苦于以下问题:C++ TDocument::SetTemplate方法的具体用法?C++ TDocument::SetTemplate怎么用?C++ TDocument::SetTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TDocument的用法示例。


在下文中一共展示了TDocument::SetTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetCurrentDoc

//
/// SelectAnySave() is called to get a template. Then the Commit() function is called
/// for the current document.
//
void
TDocManager::FileSaveAs()
{
  TDocument* doc = GetCurrentDoc();
  if (doc) {
    TDocTemplate* tpl = SelectAnySave(*doc, true);
    if (tpl) {
      if (tpl != doc->Template)
        doc->SetTemplate(tpl);       // replace existing template
      if (doc->Commit(true))         // force rewrite to new path
        PostEvent(dnRename, *doc); // WM_OWLDOCUMENT
    }
  }
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:18,代码来源:docmanag.cpp

示例2: td

//
/// CreateDoc creates a document based on the directory path and the specified
/// template. The flags parameter contains one of the document template constants
/// that determines how the document is created.
//
TDocument*
TDocManager::CreateDoc(TDocTemplate* tpl, LPCTSTR path,
                       TDocument* parent, long flags)
{
  if (!tpl) {
    TRACEX(OwlDocView, 0, _T("CreateDoc(): NULL template specified!"));
    return 0;
  }

  // Creation step 0: Inform docmanager that we're about to create a document
  // and allow docmanager to veto
  //
  if (!CreatingDoc(tpl)) {
    TRACEX(OwlDocView, 1, _T("CreateDoc(): Creation vetoed."));
    return 0;
  }

  // Creation step 1: Construct the document, passing in the parent document
  // Put together a dummy parent document if no parent doc was specified in
  // order to allow us to pass in the DocManager pointer hidden in the parent
  // doc
  //
  TDocument* doc;
  if (!parent){
    TDocument td(this);
     doc = tpl->ConstructDoc(&td);
  }
  else
    doc = tpl->ConstructDoc(parent);

  if (!doc) {
    TRACEX(OwlDocView, 0, _T("CreateDoc(): ConstructDoc call failed"));
    return 0;
  }

  // Creation step2: Initialize the document
  //
  doc->SetTemplate(tpl);
  return InitDoc(doc, path, flags);
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:45,代码来源:docmanag.cpp

示例3: while

//
/// Method invoked when specified document is about to be closed.
/// Updates the document with any changes and prompts the user for confirmation of
/// updates.
/// Returns 'true' if DocManager should proceed with the closing
/// stages of the document, or 'false' otherwise.
//
bool
TDocManager::FlushDoc(TDocument& doc)
{
  while (doc.IsDirty()) {
    int saveOrNot = doc.IsEmbedded() ?
                      IDYES :
                      PostDocError(doc, IDS_DOCCHANGED, MB_YESNOCANCEL);

    switch (saveOrNot) {
      case IDYES:
        // Prompt the user for filename in save-as situation
        //
        if (!doc.IsEmbedded() && doc.GetDocPath() == 0) {

        // !BB
        // !BB It does not make sense to invoke SelectAnySave
        // !BB with false here... This would allow the user
        // !BB to switch to any available template when saving the
        // !BB document. In other words, a user would be allowed to
        // !BB save a .TXT file as a .PTS file although they are
        // !BB not related whatsoever...
        // !BB
        // !BB I'm switching this to use true - let me know if you
        // !BB know of a reason for the prior behaviour.
        // !BB

#if defined(OLD_DOCVIEW)
          TDocTemplate* tpl = SelectAnySave(doc, false);
#else
          TDocTemplate* tpl = SelectAnySave(doc, true);
#endif
          if (!tpl)
            continue;

          // !BB
          // !BB The following is suspicious: Is there a reason
          // !BB to allow the user to switch the template in the first
          // !BB place?? OK, if everyone agrees that same TDocument-derived
          // !BB type implies compatible document, that would be OK.
          // !BB However, that's not what we've encouraged. Our own
          // !BB examples use the same TFileDocument for incompatible
          // !BB document types. Hence, if an app. has a
          // !BB TBitmapView/TFileDocument and a TTextView/TFileDocument pair,
          // !BB the following would allow the user to save a text file as a .BMP
          // !BB Ack!!
          // !BB If the following is really the intent, then DV users must be
          // !BB conscious that they will more often than not be using TFileDocument-
          // !BB derived documents as a method to specify compatible and incompatible
          // !BB document types.
          //
          if (tpl != doc.Template)
            doc.SetTemplate(tpl);
        }
        if (doc.Commit())
          return true;
        continue;

      case IDNO:
        if (doc.Revert(true))
          return true;
        return false;

      case IDCANCEL:
        return false;
    }
  }
  return true;
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:75,代码来源:docmanag.cpp


注:本文中的TDocument::SetTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。