// GuiApp.cpp : ÂĘĎňËŽË├│╠đ˛Á─╚Ű┐┌ÁŃíú
//
#include "stdafx.h"
#include "GuiApp_English.h"
int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine, int nCmdShow)
{
XInitXCGUI(); //initial
CUSBRelayWnd MyWnd;
if(MyWnd.Create())
{
XRunXCGUI(); //run gui
}
return 0;
}
//create main window
BOOL CUSBRelayWnd::Create()
{
m_hWindow = XWnd_CreateWindow(0, 0, 290, 430, L"USB Relay Manager"); //main window
if(m_hWindow)
{
XWnd_EnableDragBorder(m_hWindow, FALSE);
XWnd_EnableMaxButton(m_hWindow, FALSE);
//1. create find device button
m_hFindDeviceBtn = XBtn_Create(10, 10, 90, 25, L"Find device", m_hWindow);
//register the button click event
XCGUI_RegEleEvent(m_hFindDeviceBtn, XE_BNCLICK, &CUSBRelayWnd::OnFindDeviceBtnClick);
//2. create the device list combobox
m_hDeviceListBox = XComboBox_Create(110, 10, 150, 25, m_hWindow);
//3. create open device button
m_hOpenDeviceBtn = XBtn_Create(10, 45, 90, 25, L"open device", m_hWindow);
//register the button click event
XCGUI_RegEleEvent(m_hOpenDeviceBtn, XE_BNCLICK, &CUSBRelayWnd::OnOpenDeviceBtnClick);
//4. create open status label
m_hOpenStatus = XEle_Create(110, 45, 50, 25, m_hWindow);
XEle_SetBkColor(m_hOpenStatus, RGB(255, 0, 0));
//5. create close device button
m_hOpenDeviceBtn = XBtn_Create(170, 45, 90, 25, L"close device", m_hWindow);
//disable before open a device
//register the button click event
XCGUI_RegEleEvent(m_hOpenDeviceBtn, XE_BNCLICK, &CUSBRelayWnd::OnCloseDeviceBtnClick);
int pos_text_x = 10;
int pos_open_btn_x = 105;
int pos_status_label_x = 170;
int pos_close_btn_x = 200;
int pos_y = 80;
//6. create the buttons and lables for all relay
for (int i = 0; i < 8; i++)
{
wchar_t relayName[20] = {0};
wsprintf(relayName, L"Realy %d", i+1);
m_hRelayText[i] = XEdit_Create(pos_text_x, pos_y, 90, 25, m_hWindow);
XEdit_SetText(m_hRelayText[i], relayName);
m_hRelayOpenBtn[i] = XBtn_Create(pos_open_btn_x, pos_y, 60, 25, L"open", m_hWindow);
XCGUI_RegEleEvent(m_hRelayOpenBtn[i], XE_BNCLICK, &CUSBRelayWnd::OnOpenRelayBtnClick);
m_hRelayStatusLabel[i] = XEle_Create(pos_status_label_x, pos_y, 25, 25, m_hWindow);
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(255, 0, 0));
m_hRelayCloseBtn[i] = XBtn_Create(pos_close_btn_x, pos_y, 60, 25, L"close", m_hWindow);
XCGUI_RegEleEvent(m_hRelayCloseBtn[i], XE_BNCLICK, &CUSBRelayWnd::OnCloseRelayBtnClick);
pos_y += 30;
}
//7. create open-all relay button
m_hOpenAllRelayBtn = XBtn_Create(10, pos_y+10, 120, 50, L"Open All", m_hWindow);
XCGUI_RegEleEvent(m_hOpenAllRelayBtn, XE_BNCLICK, &CUSBRelayWnd::OnOpenAllRelayBtnClick);
//8. create close-all relay button
m_hCloseAllRelayBtn = XBtn_Create(140, pos_y+10, 120, 50, L"Close All", m_hWindow);
XCGUI_RegEleEvent(m_hCloseAllRelayBtn, XE_BNCLICK, &CUSBRelayWnd::OnCloseAllRelayBtnClick);
//initial usb_relay_device lib
usb_relay_init();
XWnd_ShowWindow(m_hWindow, SW_SHOW); //¤ď╩ż┤░┐┌
return true;
}
return false;
}
BOOL CUSBRelayWnd::OnFindDeviceBtnClick( HELE hEle,HELE hEleEvent )
{
if (m_bOpened)
{
XMessageBox(XEle_GetHWindow(hEle), L"Close Current Device First", L"Attention", XMB_OK);
return TRUE;
}
if (m_pDeviceList)
{
usb_relay_device_free_enumerate(m_pDeviceList);
m_pDeviceList = NULL;
}
m_pDeviceList = usb_relay_device_enumerate();
if (m_pDeviceList)
{
struct usb_relay_device_info *cur_device = m_pDeviceList;
while (cur_device)
{
XComboBox_AddString( m_hDeviceListBox, (wchar_t*)(Ansi2WChar((char*)(cur_device->serial_number)).c_str()) );
m_mapIndexToDevice[Ansi2WChar((char*)(cur_device->serial_number))] = cur_device;
cur_device = cur_device->next;
}
}
return TRUE;
}
BOOL CUSBRelayWnd::OnOpenDeviceBtnClick( HELE hEle,HELE hEleEvent )
{
if (m_bOpened)
{
XMessageBox(XEle_GetHWindow(hEle), L"Close Current Device First", L"Attention", XMB_OK);
return TRUE;
}
int index = XComboBox_GetSelectItem(m_hDeviceListBox);
if (index > -1)
{
wchar_t *serial = XComboBox_GetItemText(m_hDeviceListBox, index);
std::map<wstring ,struct usb_relay_device_info*>::const_iterator fd = m_mapIndexToDevice.find(wstring(serial));
if (fd != m_mapIndexToDevice.end())
{
//1. open usb relay device
m_hCurDevice = usb_relay_device_open(fd->second);
if (m_hCurDevice)
{
//2. Get status
unsigned int status = 0;
if (0 == usb_relay_device_get_status(m_hCurDevice, &status))
{
for (int i = 0; i < fd->second->type; i++)
{
if ((1<<i) & status)
{
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(0, 255, 0));
XEle_RedrawEle(m_hRelayStatusLabel[i], TRUE);
}
}
XEle_SetBkColor(m_hOpenStatus, RGB(0, 255, 0));
XEle_RedrawEle(m_hOpenStatus, TRUE);
m_bOpened = TRUE;
m_hCureDeviceIndex = fd->second->type;
}
else
{
usb_relay_device_close(m_hCurDevice);
m_hCurDevice = 0;
XMessageBox(XEle_GetHWindow(hEle), L"Open Device Error!!", L"Error", XMB_OK);
}
}
else
{
XMessageBox(XEle_GetHWindow(hEle), L"Open Device Error!!", L"Error", XMB_OK);
}
}
else
{
XMessageBox(XEle_GetHWindow(hEle), L"The Device is not valid", L"Error", XMB_OK);
}
}
else
{
XMessageBox(XEle_GetHWindow(hEle), L"Select the device first", L"Error", XMB_OK);
}
return TRUE;
}
BOOL CUSBRelayWnd::OnCloseDeviceBtnClick( HELE hEle,HELE hEleEvent )
{
if (!m_bOpened)
{
XMessageBox(XEle_GetHWindow(hEle), L"Open Device First", L"Error", XMB_OK);
return TRUE;
}
usb_relay_device_close(m_hCurDevice);
m_hCurDevice = 0;
m_bOpened = FALSE;
XEle_SetBkColor(m_hOpenStatus, RGB(255, 0, 0));
XEle_RedrawEle(m_hOpenStatus, TRUE);
for (int i = 0; i < m_hCureDeviceIndex; i++)
{
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(255, 0, 0));
XEle_RedrawEle(m_hRelayStatusLabel[i], TRUE);
}
return TRUE;
}
BOOL CUSBRelayWnd::OnOpenRelayBtnClick( HELE hEle, HELE hEleEvent )
{
if (!m_bOpened)
{
XMessageBox(XEle_GetHWindow(hEle), L"Open Device First", L"Error", XMB_OK);
return TRUE;
}
for (int i = 0; i < 8; i++)
{
if (hEle == m_hRelayOpenBtn[i])
{
int ret = usb_relay_device_open_one_relay_channel(m_hCurDevice, i+1);
if (ret == 0)
{
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(0, 255, 0));
XEle_RedrawEle(m_hRelayStatusLabel[i],TRUE);
}
}
}
return TRUE;
}
BOOL CUSBRelayWnd::OnCloseRelayBtnClick( HELE hEle, HELE hEleEvent )
{
if (!m_bOpened)
{
XMessageBox(XEle_GetHWindow(hEle), L"Open Device First", L"Error", XMB_OK);
return TRUE;
}
for (int i = 0; i < 8; i++)
{
if (hEle == m_hRelayCloseBtn[i])
{
int ret = usb_relay_device_close_one_relay_channel(m_hCurDevice, i+1);
if (ret == 0)
{
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(255, 0, 0));
XEle_RedrawEle(m_hRelayStatusLabel[i],TRUE);
}
}
}
return TRUE;
}
BOOL CUSBRelayWnd::OnOpenAllRelayBtnClick( HELE hEle, HELE hEleEvent )
{
if (!m_bOpened)
{
XMessageBox(XEle_GetHWindow(hEle), L"Open Device First", L"Error", XMB_OK);
return TRUE;
}
int ret = usb_relay_device_open_all_relay_channel(m_hCurDevice);
if (ret == 0)
{
for(int i = 0; i < m_hCureDeviceIndex; i++)
{
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(0, 255, 0));
XEle_RedrawEle(m_hRelayStatusLabel[i], TRUE);
}
}
return TRUE;
}
BOOL CUSBRelayWnd::OnCloseAllRelayBtnClick( HELE hEle, HELE hEleEvent )
{
if (!m_bOpened)
{
XMessageBox(XEle_GetHWindow(hEle), L"Open Device First", L"Error", XMB_OK);
return TRUE;
}
int ret = usb_relay_device_close_all_relay_channel(m_hCurDevice);
if (ret == 0)
{
for(int i = 0; i < m_hCureDeviceIndex; i++)
{
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(255, 0, 0));
XEle_RedrawEle(m_hRelayStatusLabel[i], TRUE);
}
}
return TRUE;
}
Ly8gR3VpQXBwLmNwcCA6IMOCxJjEjsWIw4vFvcOL4pSc4pSC4pWgxJHLm8OB4pSA4pWaxbDilJDilIzDgcWDw63DugovLwoKI2luY2x1ZGUgInN0ZGFmeC5oIgojaW5jbHVkZSAiR3VpQXBwX0VuZ2xpc2guaCIKCmludCBBUElFTlRSWSBfdFdpbk1haW4oSElOU1RBTkNFIGhJbnN0YW5jZSxISU5TVEFOQ0UgaFByZXZJbnN0YW5jZSxMUFRTVFIgbHBDbWRMaW5lLCBpbnQgbkNtZFNob3cpCnsKCVhJbml0WENHVUkoKTsgLy9pbml0aWFsCgoJQ1VTQlJlbGF5V25kICBNeVduZDsKCWlmKE15V25kLkNyZWF0ZSgpKQoJewoJCVhSdW5YQ0dVSSgpOyAvL3J1biBndWkKCX0KCXJldHVybiAwOwp9CgovL2NyZWF0ZSBtYWluIHdpbmRvdwpCT09MIENVU0JSZWxheVduZDo6Q3JlYXRlKCkKewoJbV9oV2luZG93ID0gWFduZF9DcmVhdGVXaW5kb3coMCwgMCwgMjkwLCA0MzAsIEwiVVNCIFJlbGF5IE1hbmFnZXIiKTsgLy9tYWluIHdpbmRvdwoJaWYobV9oV2luZG93KQoJewoJCVhXbmRfRW5hYmxlRHJhZ0JvcmRlcihtX2hXaW5kb3csIEZBTFNFKTsKCQlYV25kX0VuYWJsZU1heEJ1dHRvbih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GF0dXNMYWJlbFtpXSwgUkdCKDI1NSwgMCwgMCkpOwoJCQlYRWxlX1JlZHJhd0VsZShtX2hSZWxheVN0YXR1c0xhYmVsW2ldLCBUUlVFKTsKCQl9Cgl9CglyZXR1cm4gVFJVRTsKfQ==
Main.java:4: error: illegal character: \35
#include "stdafx.h"
^
Main.java:4: error: class, interface, or enum expected
#include "stdafx.h"
^
Main.java:5: error: illegal character: \35
#include "GuiApp_English.h"
^
Main.java:11: error: class, interface, or enum expected
CUSBRelayWnd MyWnd;
^
Main.java:12: error: class, interface, or enum expected
if(MyWnd.Create())
^
Main.java:15: error: class, interface, or enum expected
}
^
Main.java:17: error: class, interface, or enum expected
}
^
Main.java:23: error: class, interface, or enum expected
if(m_hWindow)
^
Main.java:26: error: class, interface, or enum expected
XWnd_EnableMaxButton(m_hWindow, FALSE);
^
Main.java:29: error: class, interface, or enum expected
m_hFindDeviceBtn = XBtn_Create(10, 10, 90, 25, L"Find device", m_hWindow);
^
Main.java:31: error: class, interface, or enum expected
XCGUI_RegEleEvent(m_hFindDeviceBtn, XE_BNCLICK, &CUSBRelayWnd::OnFindDeviceBtnClick);
^
Main.java:34: error: class, interface, or enum expected
m_hDeviceListBox = XComboBox_Create(110, 10, 150, 25, m_hWindow);
^
Main.java:37: error: class, interface, or enum expected
m_hOpenDeviceBtn = XBtn_Create(10, 45, 90, 25, L"open device", m_hWindow);
^
Main.java:39: error: class, interface, or enum expected
XCGUI_RegEleEvent(m_hOpenDeviceBtn, XE_BNCLICK, &CUSBRelayWnd::OnOpenDeviceBtnClick);
^
Main.java:42: error: class, interface, or enum expected
m_hOpenStatus = XEle_Create(110, 45, 50, 25, m_hWindow);
^
Main.java:43: error: class, interface, or enum expected
XEle_SetBkColor(m_hOpenStatus, RGB(255, 0, 0));
^
Main.java:46: error: class, interface, or enum expected
m_hOpenDeviceBtn = XBtn_Create(170, 45, 90, 25, L"close device", m_hWindow);
^
Main.java:50: error: class, interface, or enum expected
XCGUI_RegEleEvent(m_hOpenDeviceBtn, XE_BNCLICK, &CUSBRelayWnd::OnCloseDeviceBtnClick);
^
Main.java:52: error: class, interface, or enum expected
int pos_text_x = 10;
^
Main.java:53: error: class, interface, or enum expected
int pos_open_btn_x = 105;
^
Main.java:54: error: class, interface, or enum expected
int pos_status_label_x = 170;
^
Main.java:55: error: class, interface, or enum expected
int pos_close_btn_x = 200;
^
Main.java:57: error: class, interface, or enum expected
int pos_y = 80;
^
Main.java:60: error: class, interface, or enum expected
for (int i = 0; i < 8; i++)
^
Main.java:60: error: class, interface, or enum expected
for (int i = 0; i < 8; i++)
^
Main.java:60: error: class, interface, or enum expected
for (int i = 0; i < 8; i++)
^
Main.java:63: error: class, interface, or enum expected
wsprintf(relayName, L"Realy %d", i+1);
^
Main.java:65: error: class, interface, or enum expected
m_hRelayText[i] = XEdit_Create(pos_text_x, pos_y, 90, 25, m_hWindow);
^
Main.java:66: error: class, interface, or enum expected
XEdit_SetText(m_hRelayText[i], relayName);
^
Main.java:68: error: class, interface, or enum expected
m_hRelayOpenBtn[i] = XBtn_Create(pos_open_btn_x, pos_y, 60, 25, L"open", m_hWindow);
^
Main.java:69: error: class, interface, or enum expected
XCGUI_RegEleEvent(m_hRelayOpenBtn[i], XE_BNCLICK, &CUSBRelayWnd::OnOpenRelayBtnClick);
^
Main.java:71: error: class, interface, or enum expected
m_hRelayStatusLabel[i] = XEle_Create(pos_status_label_x, pos_y, 25, 25, m_hWindow);
^
Main.java:72: error: class, interface, or enum expected
XEle_SetBkColor(m_hRelayStatusLabel[i], RGB(255, 0, 0));
^
Main.java:74: error: class, interface, or enum expected
m_hRelayCloseBtn[i] = XBtn_Create(pos_close_btn_x, pos_y, 60, 25, L"close", m_hWindow);
^
Main.java:75: error: class, interface, or enum expected
XCGUI_RegEleEvent(m_hRelayCloseBtn[i], XE_BNCLICK, &CUSBRelayWnd::OnCloseRelayBtnClick);
^
Main.java:77: error: class, interface, or enum expected
pos_y += 30;
^
Main.java:78: error: class, interface, or enum expected
}
^
Main.java:82: error: class, interface, or enum expected
XCGUI_RegEleEvent(m_hOpenAllRelayBtn, XE_BNCLICK, &CUSBRelayWnd::OnOpenAllRelayBtnClick);
^
Main.java:85: error: class, interface, or enum expected
m_hCloseAllRelayBtn = XBtn_Create(140, pos_y+10, 120, 50, L"Close All", m_hWindow);
^
Main.java:86: error: class, interface, or enum expected
XCGUI_RegEleEvent(m_hCloseAllRelayBtn, XE_BNCLICK, &CUSBRelayWnd::OnCloseAllRelayBtnClick);
^
Main.java:89: error: class, interface, or enum expected
usb_relay_init();
^
Main.java:91: error: class, interface, or enum expected
XWnd_ShowWindow(m_hWindow, SW_SHOW); //????????
^
Main.java:92: error: class, interface, or enum expected
return true;
^
Main.java:93: error: class, interface, or enum expected
}
^
Main.java:95: error: class, interface, or enum expected
}
^
Main.java:102: error: class, interface, or enum expected
return TRUE;
^
Main.java:103: error: class, interface, or enum expected
}
^
Main.java:108: error: class, interface, or enum expected
m_pDeviceList = NULL;
^
Main.java:109: error: class, interface, or enum expected
}
^
Main.java:112: error: class, interface, or enum expected
if (m_pDeviceList)
^
Main.java:115: error: class, interface, or enum expected
while (cur_device)
^
Main.java:118: error: class, interface, or enum expected
m_mapIndexToDevice[Ansi2WChar((char*)(cur_device->serial_number))] = cur_device;
^
Main.java:120: error: class, interface, or enum expected
cur_device = cur_device->next;
^
Main.java:121: error: class, interface, or enum expected
}
^
Main.java:125: error: class, interface, or enum expected
}
^
Main.java:132: error: class, interface, or enum expected
return TRUE;
^
Main.java:133: error: class, interface, or enum expected
}
^
Main.java:136: error: class, interface, or enum expected
if (index > -1)
^
Main.java:139: error: class, interface, or enum expected
std::map<wstring ,struct usb_relay_device_info*>::const_iterator fd = m_mapIndexToDevice.find(wstring(serial));
^
Main.java:140: error: class, interface, or enum expected
if (fd != m_mapIndexToDevice.end())
^
Main.java:144: error: class, interface, or enum expected
if (m_hCurDevice)
^
Main.java:148: error: class, interface, or enum expected
if (0 == usb_relay_device_get_status(m_hCurDevice, &status))
^
Main.java:150: error: class, interface, or enum expected
for (int i = 0; i < fd->second->type; i++)
^
Main.java:150: error: class, interface, or enum expected
for (int i = 0; i < fd->second->type; i++)
^
Main.java:155: error: class, interface, or enum expected
XEle_RedrawEle(m_hRelayStatusLabel[i], TRUE);
^
Main.java:156: error: class, interface, or enum expected
}
^
Main.java:159: error: class, interface, or enum expected
XEle_RedrawEle(m_hOpenStatus, TRUE);
^
Main.java:160: error: class, interface, or enum expected
m_bOpened = TRUE;
^
Main.java:161: error: class, interface, or enum expected
m_hCureDeviceIndex = fd->second->type;
^
Main.java:162: error: class, interface, or enum expected
}
^
Main.java:166: error: class, interface, or enum expected
m_hCurDevice = 0;
^
Main.java:167: error: class, interface, or enum expected
XMessageBox(XEle_GetHWindow(hEle), L"Open Device Error!!", L"Error", XMB_OK);
^
Main.java:168: error: class, interface, or enum expected
}
^
Main.java:174: error: class, interface, or enum expected
}
^
Main.java:179: error: class, interface, or enum expected
}
^
Main.java:184: error: class, interface, or enum expected
}
^
Main.java:187: error: class, interface, or enum expected
}
^
Main.java:194: error: class, interface, or enum expected
return TRUE;
^
Main.java:195: error: class, interface, or enum expected
}
^
Main.java:198: error: class, interface, or enum expected
m_hCurDevice = 0;
^
Main.java:199: error: class, interface, or enum expected
m_bOpened = FALSE;
^
Main.java:200: error: class, interface, or enum expected
XEle_SetBkColor(m_hOpenStatus, RGB(255, 0, 0));
^
Main.java:201: error: class, interface, or enum expected
XEle_RedrawEle(m_hOpenStatus, TRUE);
^
Main.java:203: error: class, interface, or enum expected
for (int i = 0; i < m_hCureDeviceIndex; i++)
^
Main.java:203: error: class, interface, or enum expected
for (int i = 0; i < m_hCureDeviceIndex; i++)
^
Main.java:203: error: class, interface, or enum expected
for (int i = 0; i < m_hCureDeviceIndex; i++)
^
Main.java:206: error: class, interface, or enum expected
XEle_RedrawEle(m_hRelayStatusLabel[i], TRUE);
^
Main.java:207: error: class, interface, or enum expected
}
^
Main.java:210: error: class, interface, or enum expected
}
^
Main.java:217: error: class, interface, or enum expected
return TRUE;
^
Main.java:218: error: class, interface, or enum expected
}
^
Main.java:219: error: class, interface, or enum expected
for (int i = 0; i < 8; i++)
^
Main.java:219: error: class, interface, or enum expected
for (int i = 0; i < 8; i++)
^
Main.java:224: error: class, interface, or enum expected
if (ret == 0)
^
Main.java:227: error: class, interface, or enum expected
XEle_RedrawEle(m_hRelayStatusLabel[i],TRUE);
^
Main.java:228: error: class, interface, or enum expected
}
^
Main.java:232: error: class, interface, or enum expected
}
^
Main.java:239: error: class, interface, or enum expected
return TRUE;
^
Main.java:240: error: class, interface, or enum expected
}
^
Main.java:241: error: class, interface, or enum expected
for (int i = 0; i < 8; i++)
^
100 errors