阅读:2008回复:5
表达式属性查询对话框(VC)
<P>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);</P> <P>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 }</P> <P>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<n;i++) { if(tdrecs.GetFieldType(i)<20) { str1=tdrecs.GetFieldName(i); m_fieldname.InsertString(i,str1); } } m_fieldname.SelectString(-1,fieldname); }</P> <P>void CSELDLG::Comble3add() { m_text.ResetContent(); CString str1; <A>file://m_fieldname.GetWindowText</A>(str); CMoMapLayer layer(m_map3.GetLayers().Item(COleVariant(TEXT(layername)))); CMoRecordset recs(layer.GetRecords()); int i=0; recs.MoveFirst(); while(!recs.GetEof()) { <A>file://m_text.DeleteString</A>(i); CString str1=recs.GetFields().Item(COleVariant(TEXT(fieldname))).GetValueAsString(); m_text.InsertString(i,str1); recs.MoveNext(); i+=1; }</P> <P>}</P> <P>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(); }</P> <P>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); }</P> <P>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); } }</P> <P> 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); }</P> <P>BEGIN_EVENTSINK_MAP(CSELDLG, CDialog) <A>file://{{</A>AFX_EVENTSINK_MAP(CSELDLG) ON_EVENT(CSELDLG, IDC_MAP1, 4 /* AfterTrackingLayerDraw */, OnAfterTrackingLayerDrawMap1, VTS_I4) <A>file://}}</A>AFX_EVENTSINK_MAP END_EVENTSINK_MAP()</P> <P>CSELDLG::CSELDLG(CView* pView) { } BOOL CSELDLG::Create() { return CDialog::Create(CSELDLG::IDD); }</P> <P> 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); } }</P> <P>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); <A>file://m_map3.FlashShape</A>(point,3); m_map3.DrawShape(point,sym); } else if(afields.Item(COleVariant(TEXT("Shape"))).GetType()==23) { CMoPolygon shape(field1.GetValue().pdispVal); <A>file://m_map3.FlashShape</A>(shape,3); m_map3.DrawShape(shape,sym); } else { CMoLine line(field1.GetValue().pdispVal); <A>file://m_map3.FlashShape</A>(line,3); m_map3.DrawShape(line,sym); } m_selection.MoveNext(); } m_selection=NULL; }</P> <P>void CSELDLG::OnChongzhi() { // TOD Add your control notification handler code here m_fieldname.ResetContent(); m_oper.ResetContent(); m_text.ResetContent(); } </P> |
|
1楼#
发布于:2004-09-28 08:39
<P><img src="images/post/smile/dvbbs/em01.gif" /></P><P><img src="images/post/smile/dvbbs/em02.gif" /></P>
|
|
|
2楼#
发布于:2004-09-28 08:51
<img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em02.gif" />
|
|
|
3楼#
发布于:2004-09-29 20:15
<P>好东东啦</P><img src="images/post/smile/dvbbs/em01.gif" />
|
|
|
4楼#
发布于:2004-11-08 17:38
<img src="images/post/smile/dvbbs/em02.gif" />
|
|
5楼#
发布于:2007-11-18 21:02
有没有C#的啊 哭
|
|