阅读:2018回复:5
表达式属性查询对话框(VC)BOOL CSELDLG::OnInitDialog() { CDialog::OnInitDialog(); // TOD Add extra initialization here CMainFrame* pMainFrame; pMainFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd; m_pView=(CMyFirstMapView*)pMainFrame->GetActiveView(); CMoLayers layers(m_pView->m_map1.GetLayers()); int count = layers.GetCount(); for(short i=count-1;i>-1;i--) { CMoMapLayer layer(layers.Item(COleVariant(i))); m_map3.GetLayers().Add(layer); m_layersel.AddString(layer.GetName()); } m_layersel.SetWindowText("请选择图层 "); m_fieldname.SetWindowText("请选择字段"); m_text.SetWindowText("请选择值"); m_oper.SetWindowText("请选择查询方法"); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSELDLG::OnSellayer()
{
// TOD Add your control notification handler code here
CString str,str1;
m_layersel.GetWindowText(str);
CMoLayers layers(m_map3.GetLayers());
CMoMapLayer layer(layers.Item(COleVariant(TEXT(str))));
m_sel.SetWindowText("您选择了"+str+"图层");
layername=str;
CMoRecordset recs(layer.GetRecords());
CMoTableDesc tdrecs(recs.GetTableDesc());
int n=tdrecs.GetFieldCount();
m_fieldname.ResetContent();
for(short i=0;i void CSELDLG::Comble3add() { m_text.ResetContent(); CString str1; file://m_fieldname.GetWindowText(str); CMoMapLayer layer(m_map3.GetLayers().Item(COleVariant(TEXT(layername)))); CMoRecordset recs(layer.GetRecords()); int i=0; recs.MoveFirst(); while(!recs.GetEof()) { file://m_text.DeleteString(i); CString str1=recs.GetFields().Item(COleVariant(TEXT(fieldname))).GetValueAsString(); m_text.InsertString(i,str1); recs.MoveNext(); i+=1; } } void CSELDLG::OnCloseupFieldname() { // TOD Add your control notification handler code here int nSel; if((nSel=m_fieldname.GetCurSel())!=CB_ERR) { m_fieldname.GetLBText(nSel,fieldname); } else { m_fieldname.ResetContent(); m_fieldname.AddString(fieldname); m_fieldname.SelectString(-1,fieldname); } Comble3add(); } void CSELDLG::OnDropdownOper() { // TOD Add your control notification handler code here m_oper.ResetContent(); m_oper.AddString(">"); m_oper.AddString(">="); m_oper.AddString("="); m_oper.AddString("<"); m_oper.AddString("<="); m_oper.AddString("Like"); m_oper.SelectString(-1,opername); } void CSELDLG::OnCloseupText() { // TOD Add your control notification handler code here int nSel; if((nSel=m_text.GetCurSel())!=CB_ERR) { m_text.GetLBText(nSel,shujuname); } else { m_text.ResetContent(); m_text.AddString(shujuname); m_text.SelectString(-1,shujuname); } } void CSELDLG::OnChaxun() { // TOD Add your control notification handler code here if(layername=="") { MessageBox("select one layer please!"); return; } if(fieldname=="") { MessageBox("select one field please!"); return; } if(shujuname=="") { MessageBox("select one value please!"); return; } if(opername=="") { MessageBox("select one oper please!"); return; } CMoMapLayer layer(m_map3.GetLayers().Item(COleVariant(TEXT(layername)))); CMoRecordset recs(layer.GetRecords()); CMoFields fields(recs.GetFields()); afields=fields; CMoField field(fields.Item(COleVariant(TEXT(fieldname)))); if(field.GetType()==8) { expression=fieldname + " " + opername + " " +"'"+shujuname+"'"+" "; } else { expression=fieldname+""+opername+""+shujuname; } CMoRecordset select(layer.SearchExpression(expression)); m_selection=select; VARIANT va; VariantInit(;va); va.vt=VT_NULL; CMoTrackingLayer tracklayer(m_map3.GetTrackingLayer()); tracklayer.Refresh(true,va); } BEGIN_EVENTSINK_MAP(CSELDLG, CDialog) file://{{AFX_EVENTSINK_MAP(CSELDLG) ON_EVENT(CSELDLG, IDC_MAP1, 4 /* AfterTrackingLayerDraw */, OnAfterTrackingLayerDrawMap1, VTS_I4) file://}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() CSELDLG::CSELDLG(CView* pView) { } BOOL CSELDLG::Create() { return CDialog::Create(CSELDLG::IDD); } void CSELDLG::OnCloseupOper() { // TOD Add your control notification handler code here int nSel; if((nSel=m_oper.GetCurSel())!=CB_ERR) { m_oper.GetLBText(nSel,opername); } else { m_oper.ResetContent(); m_oper.AddString(opername); m_oper.SelectString(-1,opername); } } void CSELDLG::OnAfterTrackingLayerDrawMap1(long hDC) { // TOD Add your control notification handler code here if(LPDISPATCH(m_selection)==0) return; CMoSymbol sym; sym.CreateDispatch(TEXT("MapObjects2.Symbol")); sym.SetColor(0xFF00FF); m_selection.MoveFirst(); sym.SetSymbolType(2); sym.SetStyle(8); while(!m_selection.GetEof()) { CMoFields fields1(m_selection.GetFields()); CMoField field1(fields1.Item(COleVariant(TEXT("Shape")))); if(afields.Item(COleVariant(TEXT("Shape"))).GetType()==21) { CMoPoint point(field1.GetValue().pdispVal); sym.SetSize(8); sym.SetStyle(2); file://m_map3.FlashShape(point,3); m_map3.DrawShape(point,sym); } else if(afields.Item(COleVariant(TEXT("Shape"))).GetType()==23) { CMoPolygon shape(field1.GetValue().pdispVal); file://m_map3.FlashShape(shape,3); m_map3.DrawShape(shape,sym); } else { CMoLine line(field1.GetValue().pdispVal); file://m_map3.FlashShape(line,3); m_map3.DrawShape(line,sym); } m_selection.MoveNext(); } m_selection=NULL; } void CSELDLG::OnChongzhi() { // TOD Add your control notification handler code here m_fieldname.ResetContent(); m_oper.ResetContent(); m_text.ResetContent(); } |
|
1楼#
发布于:2007-11-18 21:02
有没有C#的啊 哭
|
|
3楼#
发布于:2004-09-29 20:15
好东东啦 ![]() |
|
|
4楼#
发布于:2004-09-28 08:51
![]() ![]() |
|
|
5楼#
发布于:2004-09-28 08:39
|
|
|