SOL9 Sample: TextField

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL++2000
// 2000.02.18


#include <sol\ApplicationView.h>
#include <sol\TextField.h>
#include <sol\FlowLayout.h>
#include <sol\Static.h>
#include "resource.h"

namespace SOL {

class AppView :public ApplicationView {
private:
  FlowLayout  flowLayout;
  Static    label;
  TextField  textField;


public:
  /**
   * Constructor
   */
  AppView(Application& applet, const TCHAR* name, Args& args)
    :ApplicationView(applet, name, args)
  {
    setLayout(&flowLayout);

    Args ar;
    label.create(this, _T("ProgramName to run"), ar);
    add(label);

    ar.reset();
    ar.set(XmNwidth, 300);
    textField.create(this, NULL, ar);
    textField.limitText(256);
    add(textField);

    textField.addCallback(XmNactivateCallback, this,
      (Callback)&AppView::exec, NULL);
    
    addCallback(XmNmenuCallback, IDM_EXIT, this,
      (Callback)&AppView::exit, NULL);

  }

private:
  void exec(Action& action)
  {
    TCHAR text[1024];
    textField.getText(text, CountOf(text)); //2012/06/25
    ::ShellExecute(NULL, _T("open"), text, NULL, NULL, SW_SHOW);

  }

};

}

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

    Args args;
    args.set(XmNbackground, (ulong)(COLOR_BTNFACE+1));
    args.set(XmNwidth, 500);
    args.set(XmNheight, 200);
    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.