|
I wrote a test mfc project based on dialog, just one main dialog, three check boxes on it.
in .h file I define a bool var.
BOOL m_fCheck[3];
and a function:
afx_msg void OnCheck();
in .cpp file :
(1) in constructor:
for ( int i = 0; i < 3; i++ )
m_fCheck[i] = FALSE;
(2) in DoDataExchange
void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
for ( int i=0; i<3; i++ )
DDX_Check(pDX, IDC_CHECK1 + i, m_fCheck[i]);
}
(3) On Message Map
ON_CONTROL_RANGE(BN_CLICKED, IDC_CHECK1, IDC_CHECK3, OnCheck)
(4) OnCheck() function
void CTestDlg::OnCheck()
{
}
???: When I run this test program in debug mode, I click any check box and has
no error. But when I run this program in release mode:
A fatal error occured:
First-chance exception in ChtVCData.exe: 0xC0000096: Privileged Instruction.
I do one test today.
I change macro
ON_CONTROL_RANGE(BN_CLICKED, IDC_CHECK1, IDC_CHECK3, OnCheck)
to :
ON_BN_CLICKED(IDC_CHECK1, OnCheck)
ON_BN_CLICKED(IDC_CHECK2, OnCheck)
ON_BN_CLICKED(IDC_CHECK3, OnCheck)
And then I run in debug an release mode, no error found again. Now I can asure that the problem is on the macro
ON_CONTROL_RANGE(BN_CLICKED, IDC_CHECK1, IDC_CHECK3, OnCheck)
it equals
the three macro
ON_BN_CLICKED(IDC_CHECK1, OnCheck)
ON_BN_CLICKED(IDC_CHECK2, OnCheck)
ON_BN_CLICKED(IDC_CHECK3, OnCheck)
YES OR NO ?
----------------------------------------
Don't let habit prevent you from trying something new.
|
|
|
|
|
See here[^]. Your message handler is wrong. The handler for a *_RANGE macro has one UINT parameter, which is the control ID.
|
|
|
|
|
Thank you very much for reply. I have already solved this problem. You said right, The handler for a *_RANGE macro has one UINT parameter, which is the control ID.
----------------------------------------
Don't let habit prevent you from trying something new.
|
|
|
|
|
Hi all:
For me, the following decision is difficult to make.
My codes starts here:
typedef struct _wordRec {
char *word;
int count;
}WordRec;
static WordRec *wordTable;
My codes end here.
I need to dynamically allocate memory for a large number of WordRec structures, whose very first structure is pointed by *wordTable, and keep them organized in a table without altering the 'typedef' structure I was given.
There is no pointer in the WordRec structure definition, how can I possibly relate two or more WordRec struct variables together?
Thank you
|
|
|
|
|
Why R U very much concerned with adding a pointer in the structure
_wordRec?
Regards,
Arun Kumar.A
|
|
|
|
|
Hi:
Thank you for replying my post.
The reason for me to be concerned with adding a pointer is that:
I am also required to, at a later stage of the program, do a search on the collection of words I created. I think if there is no pointer, it is not possible to do a throughout search? I am thinking:
struct _wordTable{
char *char;
int count;
WordRec* next;
};
So I can use a 'for' loop:
struct _wordTable *ptr;
for (ptr = first_of_wordTable; ptr != NULL; ptr = ptr->next){Do whatever}
But I am not allowed to modify the structure, so it is difficult for me even envisage how to 'link' the words together.
Thanks
|
|
|
|
|
If U don't want to alter the structure _wordTable,
U can create another structure like,
struct _links
{
struct _wordTable *ptrNext_wordTable;
struct _links *ptrNext_links;
};
Thus we can link all the _links with the pointer
ptrNext_links.
Use the ptrNext_wordTable to store the references of _wordTable.
Regards,
Arun Kumar.A
|
|
|
|
|
Thank you Arun.
You have been most helpful.
|
|
|
|
|
I want to develop a small chat room.There,when one person is saying,others could listen to him. And the program should deal with the status of all the person(offline,logout,login).
It should work well in the internet not only on LAN.
Some body would give me some advise?Thanks
|
|
|
|
|
You probably need to
Capture audio
compress audio
send audio
receive audio
uncompress audio
render (playback) audio
Which part is giving you trouble? You need to come up with some protocol for delivering the
appropriate data between peers.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
the most trouble is that I must enable one client send the audio pack to other clients(up to 15 clients),
I want to using RTP/RTCP protol.
I'm in trouble.
Need your hand.
Thank you.
|
|
|
|
|
|
I need to "move" a little to right the place that my item will be draw in run time.
What i mean is that in drawing some list item - i want to move the drawing item to right a little bit ==> I thought to use method ::OnCustomDraw(...) to change the drawing CRECT coordination
( something like Rec.x += 20 ) - but i don't see any affect on the my UI.
Someone can help me ?
Thanks.
|
|
|
|
|
Hi,
I connect to the Internet using RasDial and I close the connection using RasHangUp.
Everything works fine so far, BUT when I "connect, disconnect, connect, disconnect, .. and so on" then RasDial returns the Error #678. So, what can I do to fix this problem?
The time between all reconnects is approx 3 seconds. (not much time, but this should normally not cause any problems i think!? i don t know )
Thank you in advance for your help.
|
|
|
|
|
I also had trouble using the RasDial etc. functions. I then tried the Ras Dialup Class from the Ultimate Toolbox[^] which solved the problems I was having.
It's not rocket surgery!
Within you lies the power for good, use it!!!
|
|
|
|
|
Thanks but this did not solve the problem.
I have to wait 10-20 seconds and then I can reconnect.
|
|
|
|
|
What I want to do is check if the microphone is currently receiving input. I don't need to know what that input is or do anything with the input. Just a true/false as to whether or not it is currently receiving input at the moment I check. This is for Windows.
I've been searching for many hours on a way to do this - I've looked at countless pages about the Windows Mixer API and checked out a little bit about MCI, but it's all extremely confusing to me. Any help would be really appreciated, even if it's just to direct me to a better place to ask (like an audio programming forum).
|
|
|
|
|
You'll need to capture data from the microphone device and examine the audio samples and decide
if it's receiving input (maybe based on a threshold or some other way).
To get the audio samples, there's a variety of methods. Two common ways are
1) Windows Multimedia: Recording Waveform Audio[^]
2) DirectSound[^]
If those are confusing then you'll probably need to choose a method and study!
If you have more specific questions about parts you don't understand, there's lots of people here
that can help.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark. I somehow completely missed the DirectSound section of MSDN. I will check that out.
|
|
|
|
|
I'm develop some ActiveX that act like tree but also have header.
My ActiveX base class is SysListView32.
I don't understand how can i get access to the listView control ?
In this function i load the SysListView32
BOOL CTreeListViewCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszClass = _T("SysListView32");
return COleControl::PreCreateWindow(cs);
}
I must draw the control that i writing by myself ? can i use the control draw that i already have in the SysListView32 ?
I try to use some MFC class that the base class of it is CListCtrl - i check this MFC class and all work fine. Can i marge between those 2 project ( the MFC and my new ActiveX control ) ?
Thanks for any help.
|
|
|
|
|
Hi all:
Here is my question.
struct _wordTable {
char *word;
int count;
};
/*I need to dynamically allocate memory for every _wordTable structure.*/
/*What I have done is:*/
struct _wordTable *word_ptr = NULL;
word_ptr = malloc(sizeof(struct _wordTable));
if (word_ptr != NULL) {
word_ptr->word = malloc(wordSize * sizeof(char) + 1); /* wordSize if the length of the char string pointed by *word.*/
}
/*Is my coding OK? Since it worries me that I allocated memory for the struct first, followed by allocation of its string.*/
Thanks
|
|
|
|
|
It will not create any problem, since U R allocating 2 bytes of memory for the pointer "word" in the structure.
sizeof(struct _wordTable) -> This will always evaluates to 4 bytes
irrespective of the size of the string that "word" is pointing to.
Regards,
Arun Kumar.A
|
|
|
|
|
Hi:
Thank you. I was confused here for a second.
Thank you a lot, Arun.
|
|
|
|
|
Arun.Immanuel wrote: This will always evaluates to 4 bytes
Actually it will be 8 bytes when 32 bit addressing is used:
a pointer is usually stored as 4 bytes and the int is also 4 bytes.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
That will work.
Here is a better design that MS used for years.
typedef struct _wordTable {
int count;
char word[1];
} WORDTABLE;
WORDTABLE *word_ptr = malloc(sizeof(WORDTABLE) + wordSize);
if( word_ptr )
word_ptr->count = wordSize;
With this method you allocate both at the same time and do not have to add 1, because the extra byte it is part of the structure.
Note: You do not need to multiply by sizeof(char) on most compilers, because it is equal to 1.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|