中国最大的web开发资源网站及技术社区,
< 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;
}