⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cxx

📁 windows mobile phone source code
💻 CXX
字号:
/*
 * main.cxx
 *
 * PWLib application source file for $$PRODUCT_NAME$$
 *
 * Main program entry point.
 *
 * Copyright $$YEAR$$ $$MANUFACTURER$$
 *
 * $Log$
 */

#include <$$HEADER_FILE$$>
#include "main.h"
$$IF(IS_GUI)
#include "resources.h"
$$ENDIF
$$IF(HAS_HTTP)
#include "custom.h"
$$ENDIF


PCREATE_PROCESS($$APP_CLASS_NAME$$);

$$IF(HAS_HTTP)
const WORD DefaultHTTPPort = 6666;
$$ENDIF


$$APP_CLASS_NAME$$::$$APP_CLASS_NAME$$()
$$IF(HAS_HTTP)
  : $$PARENT_APP_CLASS$$(ProductInfo)
$$ELSE
  : $$PARENT_APP_CLASS$$("$$MANUFACTURER$$", "$$PRODUCT_NAME$$", 1, 0, AlphaCode, 1)
$$ENDIF
{
}

$$IF(IS_SERVICE)

BOOL $$APP_CLASS_NAME$$::OnStart()
{
  GetFile().GetDirectory().Change();
$$IF(HAS_HTTP)

  httpNameSpace.AddResource(new PHTTPDirectory("data", "data"));
  httpNameSpace.AddResource(new PServiceHTTPDirectory("html", "html"));
$$ENDIF

  return $$PARENT_APP_CLASS$$::OnStart();
}


void $$APP_CLASS_NAME$$::OnStop()
{
  $$PARENT_APP_CLASS$$::OnStop();
}


$$IF(HAS_HTTP)

void $$APP_CLASS_NAME$$::OnConfigChanged()
{
}


PString $$APP_CLASS_NAME$$::GetPageGraphic()
{
  return $$APP_CLASS_NAME$$::GetPageGraphic();
}


void $$APP_CLASS_NAME$$::AddUnregisteredText(PHTML &)
{
}


BOOL $$APP_CLASS_NAME$$::Initialise(const char * initMsg)
{
  //  create the home page
  static const char welcomeHtml[] = "welcome.html";
  if (PFile::Exists(welcomeHtml))
    httpNameSpace.AddResource(new PServiceHTTPFile(welcomeHtml, TRUE), PHTTPSpace::Overwrite);
  else {
    PHTML html;
    html << PHTML::Title("Welcome to "+GetName())
         << PHTML::Body()
         << "<CENTER>\r\n"
         << PHTML::Heading(1) << "Welcome to "
         << gifHTML
         << PHTML::Heading(1)
         << PProcess::GetOSClass() << ' ' << PProcess::GetOSName()
         << " Version " << GetVersion(TRUE) << PHTML::BreakLine()
         << ' ' << compilationDate.AsString("d MMMM yy")
         << PHTML::BreakLine()
         << "by"
         << PHTML::BreakLine()
         << PHTML::Heading(3)
         << PHTML::HotLink(GetHomePage()) << GetManufacturer() << PHTML::HotLink()
         << PHTML::Heading(3)
         << PHTML::HotLink(PString("mailto:")+GetEMailAddress()) << GetEMailAddress() << PHTML::HotLink()
         << PHTML::Paragraph()
         << PHTML::HRule()
         << PHTML::Paragraph()

         << PHTML::HotLink("http://www.equival.com.au/$$PRODUCT_NAME$$/relnotes/" + GetVersion(TRUE) + ".html")
         << "Release notes" << PHTML::HotLink()
         << " on this version of " << GetProductName() << " are available."
         << PHTML::Paragraph()
         << PHTML::HRule()
         << GetCopyrightText()
         << PHTML::Body();
    httpNameSpace.AddResource(new PServiceHTTPString("welcome.html", html), PHTTPSpace::Overwrite);
  }

  // set up the HTTP port for listening & start the first HTTP thread
  if (ListenForHTTP(DefaultHTTPPort))
    PSYSTEMLOG(Info, "Opened master socket for HTTP: " << httpListeningSocket->GetPort());
  else {
    PSYSTEMLOG(Fatal, "Cannot run without HTTP port: " << httpListeningSocket->GetErrorText());
    return FALSE;
  }

  PSYSTEMLOG(Info, "Service " << GetName() << ' ' << initMsg);
  return TRUE;
}

$$ENDIF
$$ENDIF

void $$APP_CLASS_NAME$$::Main()
{
$$IF(HAS_HTTP)
  Suspend();
$$ENDIF
$$IF(IS_GUI)
  SetAboutDialogID(IDD_ABOUT);

  PNEW MainWindow(GetArguments());

  PApplication::Main();
$$ENDIF
}

$$IF(IS_GUI)

MainWindow::MainWindow(PArgList & /*args*/)
{
  SetTitle(PResourceString(IDS_TITLE));
  SetIcon(PIcon(IDI_MAIN_WINDOW));
  SetMenu(new MainMenu(this));

  UpdateCommandSources();
  ShowAll();
}


void MainWindow::NewCmd(PMenuItem &, INT)
{
  // New document
}


void MainWindow::OpenCmd(PMenuItem &, INT)
{
  POpenFileDialog dlg(this);
  if (dlg.RunModal()) {
    // Open existing document
  }
}


void MainWindow::CloseCmd(PMenuItem &, INT)
{
  // Close document
}


void MainWindow::SaveCmd(PMenuItem &, INT)
{
  // Save current document
}


void MainWindow::SaveAsCmd(PMenuItem &, INT)
{
  PSaveFileDialog dlg(this);
  if (dlg.RunModal()) {
    // Save document to new name
  }
}


void MainWindow::PrintCmd(PMenuItem &, INT)
{
  PPrintJobDialog dlg(this, printInfo);
  if (dlg.RunModal()) {
    printInfo = dlg.GetPrintInfo();
    PPrintCanvas canvas("$$PRODUCT_NAME$$", printInfo);

    // Add printing code here
  }
}


void MainWindow::PrinterSetupCmd(PMenuItem &, INT)
{
  PPrinterSetupDialog dlg(this, printInfo);
  if (dlg.RunModal())
    printInfo = dlg.GetPrintInfo();
}


void MainWindow::ExitCmd(PMenuItem &, INT)
  // The Exit menu ... well ... exits.
{
  owner->Terminate();
}


void MainWindow::CopyCmd()
{
  PClipboard clip(this);
  // Do something with the clipboard
}


BOOL MainWindow::CanCopy()
{
  // If want copy menu enabled
  return TRUE;
}


void MainWindow::PasteCmd()
{
  PClipboard clip(this);
  // Do something with the clipboard
}


BOOL MainWindow::CanPaste()
{
  // If want paste menu enabled, ie clipboard has right format
  return TRUE;
}

$$ENDIF

// End of File ///////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -