手机看片1024精品国产,丁香婷婷成人,午夜国产一级片,黄色片网站在线免费观看,男人的天堂香蕉在线视频,一级特黄毛片在线,中文日产国产精品久久

智慧服務(wù),成就美好體驗(yàn) 項(xiàng)目咨詢

主頁 > 服務(wù)與支持 > 開發(fā)平臺 > 客戶端SDK參考 > Windows Native SDK > 附錄 HelloWorld文件源碼

入門使用

HelloWorld文件源碼

更新時(shí)間:2019-11-20

eSDK_ECDlg.cpp文件源碼

//c code
// eSDK_ECDlg.cpp : implementation file
//

#include "stdafx.h"
#include "eSDK_EC.h"
#include "eSDK_ECDlg.h"
#include "afxdialogex.h"
#include "tsdk_login_def.h"
#include "tsdk_login_interface.h"
#include "tsdk_error_def.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialogEx
{
public:
    CAboutDlg();

    // Dialog Data
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_ABOUTBOX };
#endif

protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

                                                        // Implementation
protected:
    DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()


// CeSDK_ECDlg dialog



CeSDK_ECDlg::CeSDK_ECDlg(CWnd* pParent /*=NULL*/)
    : CDialogEx(IDD_ESDK_EC_DIALOG, pParent)
{
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CeSDK_ECDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_IPADDRESS1, m_ipCtrlServerIP);
    DDX_Control(pDX, IDC_EDIT1, m_edtServerPort);
    DDX_Control(pDX, IDC_EDIT2, m_edtLoginAccount);
    DDX_Control(pDX, IDC_EDIT3, m_edtPWD);
}

BEGIN_MESSAGE_MAP(CeSDK_ECDlg, CDialogEx)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_BN_CLICKED(IDC_BUTTON1, &CeSDK_ECDlg::OnBnClickedButton1)
END_MESSAGE_MAP()


// CeSDK_ECDlg message handlers

BOOL CeSDK_ECDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    // Add "About..." menu item to system menu.

    // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
        BOOL bNameValid;
        CString strAboutMenu;
        bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
        ASSERT(bNameValid);
        if (!strAboutMenu.IsEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }

    // 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

                                    // TODO: Add extra initialization here

    return TRUE;  // return TRUE  unless you set the focus to a control
}

void CeSDK_ECDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
    else
    {
        CDialogEx::OnSysCommand(nID, lParam);
    }
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CeSDK_ECDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // device context for painting

        SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

        // Center icon in client rectangle
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // Draw the icon
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialogEx::OnPaint();
    }
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CeSDK_ECDlg::OnQueryDragIcon()
{
    return static_cast<HCURSOR>(m_hIcon);
}

void CeSDK_ECDlg::OnBnClickedButton1()
{
    int result = 0;

    CString cstrAccount;
    m_edtLoginAccount.GetWindowText(cstrAccount);
    std::string strAccount = UNICODE2UTF(cstrAccount);

    CString cstrPwd;
    m_edtPWD.GetWindowText(cstrPwd);
    std::string strPwd = UNICODE2UTF(cstrPwd);

    CString cstrServerIp;
    m_ipCtrlServerIP.GetWindowText(cstrServerIp);
    std::string strServerIp = UNICODE2UTF(cstrServerIp);

    CString cstrServerPort;
    m_edtServerPort.GetWindowText(cstrServerPort);
    std::string strServerPort = UNICODE2UTF(cstrServerPort);
    int iServerPort = atoi(strServerPort.c_str());


    TSDK_S_LOGIN_PARAM login_param;
    memset(&login_param, 0, sizeof(login_param));

    login_param.user_id = 1;
    login_param.auth_type = TSDK_E_AUTH_NORMAL;
    strcpy_s(login_param.user_name, TSDK_D_MAX_ACCOUNT_LEN + 1, strAccount.c_str());
    strcpy_s(login_param.password, TSDK_D_MAX_PASSWORD_LENGTH + 1, strPwd.c_str());
    strcpy_s(login_param.server_addr, TSDK_D_MAX_URL_LENGTH + 1, strServerIp.c_str());
    login_param.server_port = iServerPort;
    login_param.server_type = TSDK_E_SERVER_TYPE_PORTAL;

    result = tsdk_login(&login_param);

    if (TSDK_SUCCESS != result)
    {
        AfxMessageBox(_T("login failed"));
    }
}

std::string CeSDK_ECDlg::UNICODE2UTF(const CString& cstr)
{
    char*     pElementText;
    int    iTextLen;
    std::wstring wstr = cstr;
    // wide char to multi char
    iTextLen = WideCharToMultiByte(CP_UTF8,
        0,
        wstr.c_str(),
        -1,
        NULL,
        0,
        NULL,
        NULL);
    pElementText = new char[iTextLen + 1];
    memset((void*)pElementText, 0, sizeof(char) * (iTextLen + 1));
    ::WideCharToMultiByte(CP_UTF8,
        0,
        wstr.c_str(),
        -1,
        pElementText,
        iTextLen,
        NULL,
        NULL);
    std::string strText;
    strText = pElementText;
    delete[] pElementText;
    pElementText = NULL;
    return strText;
}
 

 

eSDK_EC.cpp文件源碼

//c code

// eSDK_EC.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "eSDK_EC.h"
#include "eSDK_ECDlg.h"
#include "tsdk_manager_def.h"
#include "tsdk_manager_interface.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CeSDK_ECApp

BEGIN_MESSAGE_MAP(CeSDK_ECApp, CWinApp)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CeSDK_ECApp construction

CeSDK_ECApp::CeSDK_ECApp()
{
	// support Restart Manager
	m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;

	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}


// The one and only CeSDK_ECApp object

CeSDK_ECApp theApp;


// CeSDK_ECApp initialization

BOOL CeSDK_ECApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();


	AfxEnableControlContainer();

	// Create the shell manager, in case the dialog contains
	// any shell tree view or shell list view controls.
	CShellManager *pShellManager = new CShellManager;

	// Activate "Windows Native" visual manager for enabling themes in MFC controls
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

    (void)InitAllModule();

	CeSDK_ECDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}
	else if (nResponse == -1)
	{
		TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");
		TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n");
	}

	// Delete the shell manager created above.
	if (pShellManager != NULL)
	{
		delete pShellManager;
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

void CeSDK_ECApp::COMPONENT_FN_CALLBACK_PTR(unsigned int msgid, unsigned int param1, unsigned int param2, void *data)
{
    //tsdk上報(bào)的消息,不需要界面層處理的,在service層處理掉
    switch (msgid)
    {
    case TSDK_E_LOGIN_EVT_AUTH_SUCCESS:
    {
        AfxMessageBox(L"Uportal login OK");
        break;
    }
    case TSDK_E_LOGIN_EVT_AUTH_FAILED:
    {
        AfxMessageBox(L"Uportal login Failed");
        break;
    }
    default:
        break;
    }
}

int CeSDK_ECApp::InitAllModule(void)
{
    int ret;
    TSDK_S_APP_INFO_PARAM app_info;
    memset(&app_info, 0, sizeof(app_info));

    app_info.client_type = TSDK_E_CLIENT_PC;
    strcpy_s(app_info.product_name, TSDK_D_MAX_PRODUCT_NAME_LEN + 1, "SoftClient on Desktop");
    app_info.support_audio_and_video_call = 1;
    app_info.support_audio_and_video_conf = 1;
    app_info.support_ctd = 1;
    app_info.support_data_conf = 1;
    app_info.support_rich_media_message = 1;
    app_info.support_enterprise_address_book = 1;
    app_info.support_im = 1;

    ret = tsdk_init(&app_info, COMPONENT_FN_CALLBACK_PTR);
    return ret;
}
 

 

eSDK_ECDlg.h文件源碼

//c code

// eSDK_ECDlg.h : header file
//

#pragma once
#include "afxcmn.h"
#include "afxwin.h"
#include "string"


// CeSDK_ECDlg dialog
class CeSDK_ECDlg : public CDialogEx
{
    // Construction
public:
    CeSDK_ECDlg(CWnd* pParent = NULL);	// standard constructor

                                        // Dialog Data
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_ESDK_EC_DIALOG };
#endif

protected:
    virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


                                                        // Implementation
protected:
    HICON m_hIcon;

    // Generated message map functions
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()
public:
    CIPAddressCtrl m_ipCtrlServerIP;
    CEdit m_edtServerPort;
    CEdit m_edtLoginAccount;
    CEdit m_edtPWD;
    afx_msg void OnBnClickedButton1();
    std::string UNICODE2UTF(const CString& cstr);
};
 

 

eSDK_EC.h文件源碼

//c code

// eSDK_EC.h : main header file for the PROJECT_NAME application
//

#pragma once

#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"		// main symbols


// CeSDK_ECApp:
// See eSDK_EC.cpp for the implementation of this class
//

class CeSDK_ECApp : public CWinApp
{
public:
    CeSDK_ECApp();

    // Overrides
public:
    virtual BOOL InitInstance();

    // Implementation
    int InitAllModule(void);

    DECLARE_MESSAGE_MAP()

    static void COMPONENT_FN_CALLBACK_PTR(unsigned int msgid, unsigned int param1, unsigned int param2, void *data);
};

extern CeSDK_ECApp theApp;