int FindReplDlg::GetFindText(CComboBox& wnd, bsString& text) { int len; char *tp; int sel = wnd.GetCurSel(); if (sel == -1) { len = wnd.GetWindowTextLength()+1; tp = new char[len]; wnd.GetWindowText(tp, len); sel = wnd.FindStringExact(-1, tp); if (sel == -1) { sel = wnd.InsertString(0, tp); wnd.SetCurSel(sel); } int cnt; while ((cnt = wnd.GetCount()) >= 20) wnd.DeleteString(cnt-1); } else { len = wnd.GetLBTextLen(sel)+1; tp = new char[len]; wnd.GetLBText(sel, tp); } text.Attach(tp); return sel; }
void CPriorityTag::OnButtonSelectprioritytagOk() { // TODO: Add your control notification handler code here GAL_ERROR hError; ptrArm_UI_Update_Priority->priority_tag = m_cbPriorityTag.GetItemData(m_cbPriorityTag.GetCurSel()); if ((proc_obj_arm_ui_update_priority(m_lpAccountData->GetHandle(),ptrArm_UI_Update_Priority, &hError)) == GAL_SUCCESS) { CComboBox *pmyPriorityItemComboBox = (CComboBox *)GetDlgItem(IDC_COMBO_SELECTPRIORITYTAG_PRIORITYTAG_VALUE); for (int i=0;i < pmyPriorityItemComboBox->GetCount();i++) { if ((int)(pmyPriorityItemComboBox->GetItemData(i)) == ptrArm_UI_Update_Priority->priority_tag) { CString combotext; int n = pmyPriorityItemComboBox->GetLBTextLen( i ); pmyPriorityItemComboBox->GetLBText( i, combotext.GetBuffer(n) ); strcpy(cellvalue,combotext); combotext.ReleaseBuffer(); } } } CDialog::OnOK(); }
void CVisualPage::OnCamSetupButton() { CComboBox * box = (CComboBox*)(GetDlgItem(IDC_RECORDING_COMBO)); int i = box->GetCurSel(); int n = box->GetLBTextLen(i); CString s; box->GetLBText(i, s.GetBuffer(n)); PString setupDeviceName = s; s.ReleaseBuffer(); if (setupDeviceName.IsEmpty()) return; if (setupDeviceName.Find("fake") == 0) return; if (setupDeviceName.Find("monitor") == 0) return; if (setupDeviceName.Find("zmonitor") == 0) return; PTRACE(4,"PVidDirectShow\tCurrent device: " << setupDeviceName); HRESULT hr; IBaseFilter * pFilter = NULL; IMoniker *pMoniker =NULL; ICreateDevEnum *pDevEnum =NULL; IEnumMoniker *pClassEnum = NULL; ULONG cFetched; ::CoInitialize(NULL); // Create the system device enumerator hr = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, IID_ICreateDevEnum, (void **) &pDevEnum); if (FAILED(hr)) { ::CoUninitialize(); return; } // Create an enumerator for the video capture devices hr = pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pClassEnum, 0); if (FAILED(hr)) { ::CoUninitialize(); return; } if (pClassEnum == NULL) { ::CoUninitialize(); return; } PTRACE(4,"PVidDirectShow\tEntering device enumeration loop..."); while (1) { // Get the next device hr = pClassEnum->Next(1, &pMoniker, &cFetched); if (hr != S_OK) { PTRACE(4, "PVidDirectShow\tGetInputDeviceNames() No more video capture device"); break; } // Get the property bag IPropertyBag *pPropBag; hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag)); if (FAILED(hr)) { PTRACE(4,"PVidDerectShow\tBindToStorage failed, continue"); pMoniker->Release(); continue; } // Find the description or friendly name. VARIANT DeviceName; DeviceName.vt = VT_BSTR; hr = pPropBag->Read(L"Description", &DeviceName, NULL); if (FAILED(hr)) hr = pPropBag->Read(L"FriendlyName", &DeviceName, NULL); if (SUCCEEDED(hr)) { char *pDeviceName = BSTR_to_ANSI(DeviceName.bstrVal); if (pDeviceName) { PTRACE(4, "PVidDirectShow\tGetInputDeviceNames() Found this capture device '"<< pDeviceName <<"'"); if(PString(pDeviceName) == setupDeviceName) { PTRACE(4, "PVidDirectShow\tCamera Setup: device found"); pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**) &pFilter); ISpecifyPropertyPages *p_spec; CAUUID cauuid; HRESULT hr = pFilter->QueryInterface( IID_ISpecifyPropertyPages, (void **)&p_spec ); if( !FAILED(hr) ) if( SUCCEEDED(p_spec->GetPages( &cauuid )) ) { if( cauuid.cElems > 0 ) { HWND hwnd_desktop = ::GetDesktopWindow(); OleCreatePropertyFrame( hwnd_desktop, 30, 30, NULL, 1, (LPUNKNOWN *)(&pFilter), cauuid.cElems, cauuid.pElems, 0, 0, NULL ); CoTaskMemFree( cauuid.pElems ); } p_spec->Release(); } } free(pDeviceName); } } pPropBag->Release(); pMoniker->Release(); } ::CoUninitialize(); }