void CSelectDB::OnSelect() { OPENFILENAME FileName; TCHAR szFileName[400]; TCHAR szDir[400]; memset(&FileName, 0, sizeof(FileName)); memset(szFileName, 0, sizeof(szFileName)); memset(&szDir, 0, sizeof(szDir)); FileName.lStructSize = sizeof(FileName); FileName.lpstrTitle = _T("Open Database"); FileName.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST; FileName.nMaxFile = 400; FileName.lpstrFile = szFileName; FileName.lpstrInitialDir = szDir; FileName.lpstrFilter = _T("Database Files (.MDB)\0*.mdb"); FileName.lpstrDefExt = _T("mdb"); if(GetOpenFileName(&FileName) == 0) return; CString csPath(FileName.lpstrFile); if(ValidDB(csPath) == FALSE) { MessageBox(_T("Invalid Database"), _T("Ditto"), MB_OK); m_ePath.SetFocus(); } else m_ePath.SetWindowText(csPath); }
/* Function name : CXML::GetNode Description : This is a helper function which, gives the pointer to node. : searching for node can be started either from the current node : or it may be started from the Root Node depending on the value of : bCurrentNodeAsBase. Return type : bool Argument : CString csPathToNode Argument : LPCTSTR lpszAttribute Argument : LPCTSTR lpszValue Argument : bool bCurrentNodeAsBase Tested : Ok */ bool CXML::GetNode(IXMLDOMNode ** pNode,CString &rcsPathToNode,LPCTSTR lpszAttribute,LPCTSTR lpszValue,bool bCurrentNodeAsBase ) { IXMLDOMNode * pBaseNode = NULL; CString csPath(""); if(bCurrentNodeAsBase) { if(!m_pICurrentNode) return false; pBaseNode = m_pICurrentNode; if(lpszAttribute) csPath.Format("./%s[@%s = \"%s\"]",rcsPathToNode,lpszAttribute,lpszValue); else csPath.Format("./%s",rcsPathToNode); } else { if(!m_pIRootNode) return false; pBaseNode = m_pIRootNode; if(lpszAttribute) csPath.Format("/%s[@%s = \"%s\"]",rcsPathToNode,lpszAttribute,lpszValue); else csPath.Format("/%s",rcsPathToNode); } pBaseNode->AddRef(); BSTR bsPathToNode = csPath.AllocSysString(); m_hr = pBaseNode->selectSingleNode(bsPathToNode,pNode); SysFreeString(bsPathToNode); pBaseNode ->Release(); if (!SUCCEEDED(m_hr) || !(*pNode)) return false; return true; }
BOOL CZRegHelper::CheckFileRelation(const wchar_t *ext,const wchar_t *appKey) { BOOL nRet = FALSE; HKEY hExtKey; wchar_t szPath[_MAX_PATH]; DWORD dwSize=sizeof(szPath); if(ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,ext,&hExtKey)) { RegQueryValueEx(hExtKey,NULL,NULL,NULL,(LPBYTE)szPath,&dwSize); RegCloseKey(hExtKey); CString csPath(szPath); if(0 == csPath.CompareNoCase(appKey) && ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,appKey,&hExtKey)) { nRet=TRUE; RegCloseKey(hExtKey); } return nRet; } return nRet; }
void CreateToolbars() { IAcadMenuGroup *mnuGrp = NULL; if (!getAcadMenuGroup(&mnuGrp)) return ; //now get all the popup menus IAcadToolbars *tlbrs = NULL; HRESULT hr = S_OK; hr = mnuGrp->get_Toolbars(&tlbrs); mnuGrp->Release(); //let us create toolbars for polysamp IAcadToolbar *tlbr = NULL; hr = tlbrs->Add(L"POLYSAMP APPLICATION", &tlbr); if FAILED(hr) return; tlbrs->Release(); //now add toolbar buttons IAcadToolbarItem *button=NULL; VARIANT index; index.vt = VT_I4; index.lVal = 100l; VARIANT vtFalse; vtFalse.vt = VT_BOOL; vtFalse.boolVal = VARIANT_FALSE; TCHAR szFileName[MAX_PATH]; GetModuleFileName(GetModuleHandle(_T("asdkPolyUi.arx")),szFileName,MAX_PATH); CString csPath(szFileName); csPath=csPath.Left(csPath.ReverseFind(_T('\\'))); //x64 binaries are created within x64\ folder #if defined(_WIN64) || defined(_AC64) csPath=csPath.Left(csPath.ReverseFind(_T('\\'))); #endif csPath=csPath.Left(csPath.ReverseFind(_T('\\'))+1); hr = tlbr->AddToolbarButton(index, L"POLY", L"Creates poly entity", L"_poly ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly1.ico")),CComBSTR(csPath+_T("1_Poly1.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"DRAGPOLY", L"Creates poly entity using dragging", L"_dragpoly ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly2.ico")),CComBSTR(csPath+_T("1_Poly2.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"POLYEDIT", L"Edits poly entity", L"_POLYEDIT ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly3.ico")),CComBSTR(csPath+_T("1_Poly3.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"TRANSACT", L"Test Transaction on poly entity", L"_TRANSACT ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly4.ico")),CComBSTR(csPath+_T("1_Poly4.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"HILITPOLY", L"Hilight poly entity", L"_HILITPOLY ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly5.ico")),CComBSTR(csPath+_T("1_Poly5.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"HILITSOLID", L"Hilight solid entity", L"_HILITSOLID ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly6.ico")),CComBSTR(csPath+_T("1_Poly6.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"CREATEINSERT", L"Creates inserted entity", L"_CREATEINSERT ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly7.ico")),CComBSTR(csPath+_T("1_Poly7.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"HILITINSERT", L"Highlight inserted entity", L"_HILITINSERT ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly8.ico")),CComBSTR(csPath+_T("1_Poly8.ico"))); button->Release(); hr = tlbr->AddToolbarButton(index, L"USEDRAGDATA", L"Test user dragging mechanism", L"_USEDRAGDATA ", vtFalse, &button); hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly1.ico")),CComBSTR(csPath+_T("1_Poly1.ico"))); button->Release(); tlbr->Dock(acToolbarDockLeft); tlbr->Release(); return; }