SOL9 Sample: Menu

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * Menu.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
// 2000.02.18
// 2012/06/28

#define COMMONCONTROLS_V6

#include <sol\ApplicationView.h>
#include "resource.h"

namespace SOL {

class AppView :public ApplicationView {

private:

  void  open(Action& action) 
  {
    showMessageDialog(getText(), (const TCHAR*)action.getData());
  }

  void  save(Action& action) 
  {
    showMessageDialog(getText(), (const TCHAR*)action.getData(), 
      MB_OK|MB_ICONSTOP);
  }

  void  saveAs(Action& action) 
  {
    showMessageDialog(getText(), (const TCHAR*)action.getData(),
      MB_OK|MB_ICONINFORMATION);
  }

  void  select(Action& action) 
  {
    const TCHAR* msg = (const TCHAR*)action.getData();  
    if (showMessageDialog(getText(), msg,
      MB_OKCANCEL|MB_ICONQUESTION) == IDOK) {
      exit(action);
    }
  }

public:
  AppView(Application& applet, const TCHAR* label, Args& args)
    :ApplicationView(applet, label, args)
  {
    // Register a menu callback by using XmNmenuCallback name.
    addCallback(XmNmenuCallback, IDM_OPEN, this,
      (Callback)&AppView::open, _T("File - Open"));
    addCallback(XmNmenuCallback, IDM_SAVE, this,
      (Callback)&AppView::save, _T("File - Save"));
    addCallback(XmNmenuCallback, IDM_SAVEAS, this,
      (Callback)&AppView::saveAs,_T("File - Save As"));

    addCallback(XmNmenuCallback, IDM_EXIT, this,
      (Callback)&AppView::select, _T("Are you sure to exit?"));
  }
};

}

//
void  Main(int argc, TCHAR** argv)
{
  ModuleFileName module(argv[0]);
  const TCHAR* name = module.getFileName();
  try {

    Application applet(name, argc, argv);
    Args args;
    AppView appview(applet, name, args);
    appview.realize();
    applet.run();

  } catch (Exception& ex) {
    caught(ex);
  } catch (...) {
    caught(UnknownException());
  }
}


Last modified: 1 Feb 2017

Copyright (c) 2017 Antillia.com ALL RIGHTS RESERVED.