繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Web Service开发 >> webservice系列教学(12)-如何调用webservice(vc3)

webservice系列教学(12)-如何调用webservice(vc3)

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:7  文字大小:【】【】【
简介:< MClientDlg.cpp>     // MClientDlg.cpp : implementation file // #include "stdafx.h" #include "MClient.h" #include "MClientDlg.h" #include &...

< MClientDlg.cpp>

// MClientDlg.cpp : implementation file

//

#include "stdafx.h"

#include "MClient.h"

#include "MClientDlg.h"

#include "Atlbase.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CMClientDlg dialog

CMClientDlg::CMClientDlg(CWnd* pParent /*=NULL*/)

: CDialog(CMClientDlg::IDD, pParent)

{

//{{AFX_DATA_INIT(CMClientDlg)

m_strParameter = _T("");

m_strURL = _T("");

//}}AFX_DATA_INIT

// Note that LoadIcon does not require a subsequent DestroyIcon in Win32

m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

}

void CMClientDlg::DoDataExchange(CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CMClientDlg)

DDX_Control(pDX, IDC_TREE, m_TreeCtrl);

DDX_Control(pDX, IDC_LISTPARAM, m_Parameters);

DDX_Text(pDX, IDC_PARAMETER, m_strParameter);

DDX_Text(pDX, IDC_URL, m_strURL);

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CMClientDlg, CDialog)

//{{AFX_MSG_MAP(CMClientDlg)

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

ON_BN_CLICKED(IDBROWSE, OnBrowse)

ON_BN_CLICKED(IDC_CLOSE, OnClose)

ON_BN_CLICKED(IDC_EDIT, OnEdit)

ON_BN_CLICKED(IDC_EXECUTE, OnExecute)

ON_NOTIFY(LVN_DELETEITEM, IDC_LISTPARAM, OnDeleteitemListparam)

ON_NOTIFY(TVN_DELETEITEM, IDC_TREE, OnDeleteitemTree)

ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, OnSelchangedTree)

ON_BN_CLICKED(IDLOAD, OnLoad)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CMClientDlg message handlers

BOOL CMClientDlg::OnInitDialog()

{

CDialog::OnInitDialog();

if (ModifyDialog() == -1)

return FALSE;

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

}

// 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 CMClientDlg::OnPaint()

{

if (IsIconic())

{

CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (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

{

CDialog::OnPaint();

}

}

// The system calls this to obtain the cursor to display while the user drags

// the minimized window.

HCURSOR CMClientDlg::OnQueryDragIcon()

{

return (HCURSOR) m_hIcon;

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

// function: CMClientDlg::OnBrowse()

//

// parameters: No Parameters

//

// description: selection of wsdl file

//

// returns: void

//

/////////////////////////////////////////////////////////////////////////////////////////////////////////

void CMClientDlg::OnBrowse()

{

// browse dialog will open and get the selected file

CFileDialog browse(TRUE, _T("wsdl"), NULL, 0, _T("WSDL Files (*.wsdl)|*.wsdl|All files|*.*||"));

if (browse.DoModal() == IDOK)

{

m_strURL = browse.GetPathName();

if (m_strURL.IsEmpty())

return;

UpdateData(FALSE);

OnLoad();

}

return;

}

//////////////////////////////////////////////////////////////////////////////////////////////////

// function: CMClientDlg::OnClose()

//

// parameters: No Parameter

//

// description: called when dialog is being closed, but before close the dialog, tree should be destroyed.

// returns: void

//

//////////////////////////////////////////////////////////////////////////////////////////////////

void CMClientDlg::OnClose()

{

if (!DestroyTree())

return;

CMClientDlg::DestroyWindow();

}

//////////////////////////////////////////////////////////////////////////////////////////////////

// function: CMClientDlg::OnEdit()

//

// parameters: No Parameters

//

// description: Edits parameters of the operation

//

// returns: void

//

//////////////////////////////////////////////////////////////////////////////////////////////////

void CMClientDlg::OnEdit()

{

// get selected row, insert the user input in 3 column of that row

// assign -1 to the selection mark , so next time user has to select a row to insert data

int nSelectedRow ;

LVITEM LVitem;

UpdateData();

if (m_Parameters.GetItemCount() == 0)

return;

nSelectedRow = m_Parameters.GetSelectionMark();

if (nSelectedRow == -1)

return;

assignItem (&LVitem, LVIF_TEXT, nSelectedRow, 2, (LPSTR)(LPCTSTR)m_strParameter, ::SysStringLen((LPWSTR)(LPCTSTR)m_strParameter));

if (m_Parameters.SetItem(&LVitem) == 0)

MSG("Data could not be inserted !");

cleanup :

m_strParameter.Empty();

m_Parameters.SetSelectionMark(-1);

UpdateData(false);

UpdateData();

return;

}

//////////////////////////////////////////////////////////////////////////////////////////////////

// function: CMClientDlg::OnExecute()

//

// parameters: No Parameters

//

// description: pressing Execute button calls this function

// returns: void

//

//////////////////////////////////////////////////////////////////////////////////////////////////

void CMClientDlg::OnExecute()

{

UpdateData();

UpdateData(false);

if (CheckforURL() == -1)

return;

Execute();

return;

}

责任编辑:admin
相关文章