|
You could add the SND_LOOP flag to make it play continuously.
To stop playback, call PlaySound() with the first parm NULL.
For better control you may need to use the Waveform-Audio Interface[^] or DirectSound etc.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Does anyone know how to programatically register a PKCS#12 file?
|
|
|
|
|
|
Yes, I know that this is not standard, but the keyboard of the computer in which the program will run has no tab key...
OK, I'm using the PreTranslateMessage and doing this:
if (pMsg->wParam == VK_UP)
{
GetNextDlgTabItem(this->GetFocus(),TRUE)->SetFocus();
return FALSE;
}
if (pMsg->wParam == VK_DOWN)
{
GetNextDlgTabItem(this->GetFocus(),FALSE)->SetFocus();
return FALSE;
}
and it works except for a little detail:
if you put the focus on a button using tab it gains the blue border (typical in WinXP) and when you leave a button using tab it loses that blue border.
When I place the focus on a button using any of the cursor keys (VK_UP or VK_DOWN) the blue border appears, but when I leave that button the blue border continue being there.
Any idea on why do this happens?
As always thank you in advance...
|
|
|
|
|
Try removing the return FALSE in both options in the PreTranslateMesaage.
|
|
|
|
|
It makes exactly the same...
Thank you for your feedback...
|
|
|
|
|
Hi,
I'm trying to change the background color of a button (CButton type).
In order to acheive that,I'm using the ON_WM_CTLCOLOR() message,
but i'm unable to change the background color.
My code is as follow (directly from the MSDN...with few changes) :
HBRUSH CFailureListFeasibilityDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CBrush brush;
if (pWnd->GetDlgCtrlID() == IDC_MYBUTTON)
{
pDC->SetTextColor(RGB(0, 250, 250));
pDC->SetBkColor(RGB(255,0,0));
brush.CreateSolidBrush(RGB(0,0,0));
hbr = brush;
}
return hbr;
}
When debugging,I'm entering the "if" statement,but the backgroung color
remains the same.
Can anyone help me?
With best regards,
Eli
|
|
|
|
|
Hi,
looks to me like an allocation issue. You are casting your local CBrush object into a brush handle - which one will become invalid at the end of the method, since the CBrush destructor will be called.
Using
<br />
hbr = CreateSolidBrush(RGB(0,0,0));
instead of
brush.CreateSolidBrush(RGB(0,0,0));<br />
hbr = brush;
should solve this problem.
However, I just looked into the MSDN Lib example to CWnd::OnCtlColor(...) and their Brush was defined in the header of the class, so the OnCtlColor caller most probably will not delete the Brush after using it. So using GDI's CreateSolidBrush(...) directly will cause a memory leak? It's probably best you do it exactly as in their example ... . I'm now , this should be such an easy thing ...
Andreas
-- modified at 6:27 Sunday 29th April, 2007
|
|
|
|
|
Hi,
First,thanks for your quick reply.
I don't think this is a memory leak problem,since the posted code works fine
for static control(when changing the "if" statement to check for IDC_STATIC,
which is a static control inside my form).
maybe CWnd::OnCtlColor(...) is not the right handler for that purpose?
I tried to handle the WM_BN_PAINT message but the method for that message
never being called....
thanks anyway...
Eli.
|
|
|
|
|
Yesterday I asked something similar in this same forum... PJ Arends answered me that the button controls don't react to those messages if you are not using them in OwnerDraw... (I was trying to do a text color change in a checkbox, but it seems that a checkbox is a button...
Well, at the end he recommended me to use CButtonST 3.9 class, you can find it in the CP button controls section.
PS:
I've used that control some times and it worked perfectly.
Hope this helps.
|
|
|
|
|
Hi Joan,
Thanks for your reply...
I've used CButtonST for several projects,and it is very good control.
The problem is that I can't use "open source" controls in my project(safety
issues... ).
I tried the OwnerDraw option, but my application always crashes...
Is there any tutorial about owner draw controls??
With best regards,
Eli
|
|
|
|
|
I have never used ownerdrawn controls, but I'm sure that you can find some information in the msdn or here in the CP... sorry for that...
Best regards... and luck!
|
|
|
|
|
The button background color is not the color used on the face of the button, which is what it sounds like you want to change. If you're using a theme with non-rectangular buttons, you can just barely see 1 or 2 pixels of background color around the outside of the button. If you want to change the face color, you'll need to owner-draw the button.
|
|
|
|
|
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.
|
|
|
|
|