|
Is it possible to check if the microphone is in use?
|
|
|
|
|
This sound familiar!
First, how are you opening the microphone device?
Assuming that you are using waveInOpen(...) it will return MMSYSERR_ALLOCATED if someone else already has a handle to the microphone.
If waveInOpen is not the way you are using the Mic then let us know in what context you are using it so that we can give an intelegent answer.
AliR.
Visual C++ MVP
-- modified at 16:59 Wednesday 19th July, 2006
|
|
|
|
|
Hi fellows.
I have a treeview(populated) and I would like to select a single node I have this code:
<br />
case WM_NOTIFY:<br />
{<br />
TV_ITEM tempTvItem;<br />
char cTemp[256]="";<br />
unsigned int uiVal = 0;<br />
LPNMHDR notifyMessageStruct = (LPNMHDR)lParam;<br />
if(notifyMessageStruct->hwndFrom == treeViewHwnd)<br />
{<br />
if(notifyMessageStruct->code == NM_CLICK)<br />
{<br />
nodeSelected = (HTREEITEM)SendDlgItemMessage(treeViewHwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_CARET, (LPARAM)nodeSelected);<br />
tempTvItem.mask = TVIF_TEXT|TVIF_HANDLE;<br />
tempTvItem.hItem = nodeSelected;<br />
tempTvItem.pszText = cTemp;<br />
tempTvItem.cchTextMax = 256;<br />
SendMessage(treeViewHwnd, TVM_GETITEM, 0, (LPARAM)&tempTvItem);<br />
MessageBox(NULL, tempTvItem.pszText, "", MB_OK);<br />
...<br />
My problem is that the select part. The node isn`t selected and in the MessageBox nothing is shown.
What`s the problem? I want when I select the node it remais highlighted and selected.
|
|
|
|
|
Where did you get IDC_TREE1 from??
If you are using a CTreeView view, why aren't you using GetTreeCtrl()->SelectItem(...);?
AliR.
Visual C++ MVP
|
|
|
|
|
I`m not using CTreeView, I`m creating the treeview with CreateWindowEx function. and in the HMENU part
I include the IDC_TREE1 like the ID of the window.....
Like this:
<br />
treeViewHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_SHOWSELALWAYS|TVS_TRACKSELECT|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 400, myRect.bottom, hwnd, (HMENU)IDC_TREE1, hCurrentInstance, NULL);<br />
-- modified at 17:19 Wednesday 19th July, 2006
|
|
|
|
|
In that case try this
nodeSelected = (HTREEITEM)SendMessage(treeViewHwnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)nodeSelected);
AliR.
Visual C++ MVP
|
|
|
|
|
Ali unhappilly, this code doesn`t work too....
I`m almost changing to TreeView_SelectItem....
|
|
|
|
|
Hi, am new to MS VC++, and I need to interface a PC to a handeheld GPS device (Garmin etrex). Am using a serial to USB cable, and I can connect using hyperterminal so HW is ok. However, when I try to use some example code supplied on the Garmin website, I cant connect! The relevant code fragment is (I believe):
HDEVINFO theDevInfo = SetupDiGetClassDevs((GUID*) &GUID_DEVINTERFACE_GRMNUSB, NULL, NULL, DIGCF_ALLCLASSES );
SP_DEVICE_INTERFACE_DATA theInterfaceData;
theInterfaceData.cbSize = sizeof( theInterfaceData );
if( !SetupDiEnumDeviceInterfaces( theDevInfo, NULL, (GUID* &GUID_DEVINTERFACE_GRMNUSB, &theInterfaceData ) && GetLastError() == ERROR_NO_MORE_ITEMS )
{
gHandle = 0;
return;
}
--------------
Garmin tech support wont help and any help would be GREATLY appreciated
Thanks! Dinesh
|
|
|
|
|
hey man,
why do you want to do this? Garmin products have features other than navigation?
btw, I have a garmin streetpilot i5 and it works very well.
|
|
|
|
|
dinesh_pam wrote: if( !SetupDiEnumDeviceInterfaces( theDevInfo, NULL, (GUID* &GUID_DEVINTERFACE_GRMNUSB, &theInterfaceData ) && GetLastError() == ERROR_NO_MORE_ITEMS )
{
gHandle = 0;
return;
}
In the above try this so see what the error exactly is:
<br />
if( !SetupDiEnumDeviceInterfaces( theDevInfo, NULL, (GUID* &GUID_DEVINTERFACE_GRMNUSB, &theInterfaceData ) )<br />
{<br />
if(GetLastError()== ERROR_NO_MORE_ITEMS) <br />
{<br />
printf("**Error: couldn't find device(no more items), (0)\n");<br />
SetupDiDestroyDeviceInfoList(theDevInfo);<br />
gHandle = 0;<br />
return -1;<br />
}<br />
else<br />
{<br />
printf("**Error: couldn't enum device, (%d)\n"), GetLastError());<br />
SetupDiDestroyDeviceInfoList(theDevInfo);<br />
gHandle = 0;<br />
return -1;<br />
}<br />
}<br />
Kitty5
|
|
|
|
|
thank you kindly for the reply. The error is couldnt find device. i.e. "**Error: couldn't find device(no more items), (0)"
Is there anyway I could just read the virtual COM port like hyperterminal is doing instead of this?
Dinesh
|
|
|
|
|
Not quite sure how to:
dinesh_pam wrote: Is there anyway I could just read the virtual COM port like hyperterminal is doing instead of this?
However:
Did you include the file that contains the device's GUID?
It's usually a .h file that looks like:
<br />
#ifdef DEFINE_GUID<br />
<br />
DEFINE_GUID(GUID_DEVINTERFACE_ALTGENERIC, 0xaf1b231e, 0x1180, 0x420b, 0x8c, 0xb6, 0x2e, 0xd2, 0xa5, 0x3f, 0x9f, 0x92);<br />
<br />
#endif<br />
If you don't have a GUID for your device the PC will not be able to create a handle to the device. The handle is what give you the ability to communicate to the device.
Also, make sure that you: #include "INITGUID.H" in that GUID .h file.
Kitty5
|
|
|
|
|
Thanks, but all that's done further up in the file.
I'm really frustrated with this. I find it hard to believe such a simple task can be so complicated.. Anybody else help me out please?
Dinesh
|
|
|
|
|
Well your call to SetupDiEnumDeviceInterfaces does not have matching parenthesis so something very wrong is there.
You are not checking the HDEVINFO return value so you may not even have a valid handle to pass to SetupDiEnumDeviceInterfaces
HDEVINFO hDevInfoSet = SetupDiGetClassDevs(&guid, NULL, NULL, DIGCF_ALLCLASSES );
if( INVALID_HANDLE_VALUE == hDevInfoSet)
{
DWORD dwErr = ::GetLastError();
}
else
{ ...}
You are not initializing the SP_DEVICE_INTERFACE_DATA structure which is probably not a problem but you never know.
SP_DEVICE_INTERFACE_DATA devInterfaceData = {0};
devInterfaceData.cbSize = sizeof(devInterfaceData);
|
|
|
|
|
Background:
I first created an MDI MFC application called test.
I then created a dialog named: IDD_MANUAL_CDIN.
This does simple data exchange:
User inputs a string in edit box1 (i.e. hello).
User clicks on "SEND" button.
User should see in edit box2 "I typed: hello".
I then created a class for that dialog which is implemented in manual.cpp:
<br />
#include "stdafx.h"<br />
#include "test.h"<br />
#include "manual.h"<br />
<br />
IMPLEMENT_DYNAMIC(manual, CDialog)<br />
<br />
manual::manual(CWnd* pParent )<br />
: CDialog(manual::IDD, pParent)<br />
, m_nIn(_T("init"))<br />
, m_nSent(_T("I sent "))<br />
{}<br />
<br />
void manual::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Text(pDX, IDC_IN, m_nIn);<br />
DDX_Text(pDX, IDC_SENT, m_nSent);<br />
}<br />
<br />
BEGIN_MESSAGE_MAP(manual, CDialog)<br />
ON_BN_CLICKED(IDC_BUTTON_SEND, &manual::OnButtonSend)<br />
END_MESSAGE_MAP()<br />
<br />
void manual::OnManual()<br />
{<br />
manual manualDlg;<br />
manualDlg.DoModal();<br />
}<br />
<br />
void manual::OnButtonSend()<br />
{<br />
AfxMessageBox(tempSend);
AfxMessageBox(m_nIn);
m_nSent += m_nIn;<br />
}<br />
and manual.h:
<br />
class manual : public CDialog<br />
{<br />
DECLARE_DYNAMIC(manual)<br />
<br />
public:<br />
manual(CWnd* pParent = NULL);
virtual ~manual();<br />
afx_msg void OnManual();<br />
<br />
enum { IDD = IDD_MANUAL_CDIN };<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
DECLARE_MESSAGE_MAP()<br />
public:<br />
CString m_nIn;<br />
CString m_nSent;<br />
afx_msg void OnButtonSend();<br />
};<br />
I then changed the toolbar created by the MFC App wizard so that when you click one button it will open a dialog that corresponds to that button.
All this code is in the test.cpp file:
I do:
<br />
#include "manual.h"<br />
BEGIN_MESSAGE_MAP(CSpaceCubeDataRxApp, CWinApp)<br />
ON_COMMAND(ID_MCD_INPUT, &manual::OnManual)<br />
ON_COMMAND(ID_APP_ABOUT, &CtestApp::OnAppAbout)<br />
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)<br />
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)<br />
END_MESSAGE_MAP()<br />
Question:
After compiling I go to type in the string "hello" and click send and nothing pops up in edit box2. I know the "SEND" button function works b/c of the DEBUG AfxMessageBox the I put in it. Nothing is assigned to the variable m_nIn. The data exchange isn't working.
What am I missing?
Kitty5
|
|
|
|
|
|
DUH!
I knew it was something simple...
Kitty5
|
|
|
|
|
Ok, I've figured out how to get the dialog boxes to exchange data.
Now I'm trying to figure out how when you have one dialog box open how you can open another one while the 1st box is still open and functioning.
Right now when I have a dialog box open I can only work in the one box and can't click on anything outside it (i.e. clicking on the toolbar to open another dialog box or getting the about box to come up isn't working...)
I guess I'm looking for making these dialog boxes work like child forms in an MDI MFC App.
Thanks,
Kitty5
-- modified at 9:17 Friday 21st July, 2006
|
|
|
|
|
kitty5 wrote: void manual::OnManual()
{
manual manualDlg;
manualDlg.DoModal();
}
Is this right? I've never seen a dialog's method bring up another instance of itself.
Why do you not have two CEdit member variables in manual , one for each of the edit controls?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: kitty5 wrote:
void manual::OnManual()
{
manual manualDlg;
manualDlg.DoModal();
}
Is this right? I've never seen a dialog's method bring up another instance of itself.
I copied exactly what the MFC App wizard did for the AboutBox that it provides.
DavidCrow wrote: Why do you not have two CEdit member variables in manual, one for each of the edit controls?
Yes, one for each edit control... Actually, I changed the "Variable Type" to CString and the "Category" to Value (This was all done when you right click on the edit box and click on "Add Variable".
Did I do something wrong?
Kitty5
|
|
|
|
|
kitty5 wrote: I copied exactly what the MFC App wizard did for the AboutBox that it provides.
Unlikely. That code would most likely resemble:
void CMyDialog::OnManual()
{
CAboutDlg about;
about.DoModal();
} Note how the two dialog objects are different.
kitty5 wrote: Yes, one for each edit control... Actually, I changed the "Variable Type" to CString and the "Category" to Value (This was all done when you right click on the edit box and click on "Add Variable".
Did I do something wrong?
I personally do not use CString for edit controls. That's what CEdit was designed for. Use its SetWindowText() method, rather than UpdateData() , and you'll have far less problems.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I am using Visual C++ 2005 to write code a win32 console application.
There was an error message about the power function when I compiled the code. It is: error c2668: 'pow' :ambiguous call to overloaded function.
The statement is:
tempDistance += pow((data[selectedInstance][k]-data[j][k]),2);
I used various headers like: cmath and math.h
but the error message remained the same.
What is the cause of the error? I've checked the syntax and it seems correct.
-- modified at 13:30 Wednesday 19th July, 2006
|
|
|
|
|
KaKa` wrote: There was an error message about the power function when I compiled the code. It is: error c2668: 'pow' :ambiguous call to overloaded function.
Apparently there's more than one pow() function. Which one do you want to use?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how is defined the data matrix (what type) ?
i think it contains values other than int , that's why the compiler doesn't know which function to call (pow(int, int) or pow(double, double) ?? ).
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
I'm thinking that it could have something to do with your data types... are all your variables "int", or are you mixing types?
Patrick
|
|
|
|
|