summaryrefslogtreecommitdiff
path: root/WindozeCE/WinAdapterDlg.cpp
blob: de603c72ad5cb5960aa3ef7e49f07b5098b900cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// $Id$
// WinAdapterDlg.cpp : implementation file
//

#include "stdafx.h"
#include "WinAdapter.h"
#include "WinAdapterDlg.h"
#include "ace/ARGV.h" 
#include "ACEApp.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

static CWnd *host_window_ = 0;

UINT worker (void * arg)
{
  ACE_ARGV cmd_line ((TCHAR *) arg);
  extern int ace_ce_main (int, ASYS_TCHAR *[]);

  int retv =  ace_ce_main (cmd_line.argc (), cmd_line.argv ());
  host_window_->SetDlgItemText (IDC_START, TEXT ("Stopped"));

  return retv;

//   Sleep (500);
//   for (size_t i = 0; i < cmd_line.argc (); i++, Sleep (500))
//     ACE_DEBUG ((LM_DEBUG, TEXT ("The %d command arg is \"%s\""),
//                 i, cmd_line.argv ()[i]));

//   return 0;
//   CString *msg = 0;
//   while (1)
//     {
//       Sleep (500);
//       msg = new CString;
//       SYSTEMTIME curtime;
//       GetLocalTime (&curtime);
//       msg->Format (TEXT ("Time: %02d:%02d:%02d.%03d"), curtime.wHour,
//                    curtime.wMinute, curtime.wSecond,
//                    curtime.wMilliseconds);
//       ACE_DEBUG ((LM_DEBUG, TEXT ("(%P|%t) Test logging: %s\n"), *msg));
//       delete msg;
//     }
//   return 0;
}
                 
  

/////////////////////////////////////////////////////////////////////////////
// CWinAdapterDlg dialog

CWinAdapterDlg::CWinAdapterDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CWinAdapterDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CWinAdapterDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CWinAdapterDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CWinAdapterDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CWinAdapterDlg, CDialog)
	//{{AFX_MSG_MAP(CWinAdapterDlg)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_START, OnStart)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWinAdapterDlg message handlers

BOOL CWinAdapterDlg::OnInitDialog()
{
  CDialog::OnInitDialog();

  // Set the icon for this dialog.  The framework does this automatically
  //  when the application's main window is not a dialog
  SetIcon(m_hIcon, TRUE);       // Set big icon
  SetIcon(m_hIcon, FALSE);      // Set small icon
	
  this->SetDlgItemText (IDC_TEXT_DISP, 
                        TEXT ("A really long string that will hopefully show whether this kind of string can be fit and wrap around a simple TEXT object within a Dialog box.  If this doesn't work, we'll see what to do next."));
  CenterWindow(GetDesktopWindow()); // center to the hpc screen

  this->ace.set_window (this, NC_ACE_NOTIFY, INC_ACE_LOGMSG);
  this->ace.set_self_default ();
  host_window_ = this;
  return TRUE;  // return TRUE  unless you set the focus to a control
}

void CWinAdapterDlg::OnTimer(UINT nIDEvent) 
{
//   CWnd *text = this->GetDlgItem (IDC_TEXT_DISP);
//   text->ModifyStyle (WS_VISIBLE, SS_CENTER, 0);
//   this->UpdateWindow ();
}

BOOL CWinAdapterDlg::OnCommand(WPARAM wParam, LPARAM lParam) 
{
  static BOOL got_cmd = FALSE;
  int notify = HIBYTE (wParam);
  int id = LOBYTE (wParam);

  if (notify == NC_ACE_NOTIFY && id == INC_ACE_LOGMSG)
    {
      CString *msg = (CString *) lParam ;
      this->SetDlgItemText (IDC_TEXT_DISP, *msg);
      delete msg;
      return TRUE;
    }
  return CDialog::OnCommand(wParam, lParam);
}

void CWinAdapterDlg::OnStart() 
{
  static BOOL once = FALSE;

  if (! once)
    {
      CString cmdline;
      this->GetDlgItemText (IDC_CMDLINE, cmdline);
      AfxBeginThread (worker, (void *) (LPCTSTR) cmdline);
      this->SetDlgItemText (IDC_START, TEXT ("Running..."));
      once = TRUE;
    }
}