SOL9 Sample: DropClient

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



// SOL++2000 
// 2000.02.18


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

namespace SOL {

class DropClient :public ApplicationView {

  TCHAR string[MAX_PATH];
  long dropFiles(Event& event) 
  {
    TCHAR fileName[MAX_PATH];
    DropFiles drop((HDROP)event.getWParam());
    fileName[0] = ZERO;
    int num = drop.queryFile(0, fileName, CountOf(fileName)); //2012/06/26
    POINT pt;
    drop.queryPoint(&pt);
    if(num > 0) {
      _stprintf_s(string, CountOf(string), _T("Pos %d %d name %s"), 
        (short)pt.x, (short)pt.y, fileName);
      setText(string);  
      update(NULL);
    }
    return NULL;
  }

  long paint(Event& event)
  {
    PaintDC pdc(this);
    if(string[0] != ZERO) {
      pdc.textOut(10, 10, string, strlen(string));
    }
    return NULL;
  }

  public:
  DropClient(Application& applet, const TCHAR* label, Args& args)
    :ApplicationView(applet, label, 
        args.set(XmNexStyle,(ulong)WS_EX_ACCEPTFILES))
  {
    string[0] = ZERO;
    addEventHandler(WM_PAINT, this, (Handler)&DropClient::paint, NULL);
    addEventHandler(WM_DROPFILES, this, (Handler)&DropClient::dropFiles, NULL);
    addCallback(XmNmenuCallback, IDM_EXIT, this, 
        (Callback)&DropClient::exit, NULL);
  }
};

}

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

    Args args;
    DropClient dropClient(applet, name, args);
    dropClient.realize();

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


Last modified: 1 Feb 2017

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