|
i've just doing a project like yours. i have refer to live555.com for my server and rtp directshow filter for my client
|
|
|
|
|
Thanks for giving time on this thread.
If you don't mind,will you please share some code snippet? so that I can understand better.
|
|
|
|
|
please help me to color the Subitem text of CListCtrl .
I m derived a Class from CListCtrl and write a code on its Custom draw but its not color the ListCtrl subitem text color
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF clrNewTextColor, clrNewBkColor;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
CString strTemp="";
if(pLVCD->iSubItem==8)
{
strTemp = GetItemText(nItem,pLVCD->iSubItem);
if(strTemp == "Y")
{
clrNewTextColor = RGB(0,0,255);
clrNewBkColor = RGB(255,255,255);
}
else
{
clrNewTextColor = RGB(0,0,0);
clrNewBkColor = RGB(255,255,255);
}
}
else
{
clrNewTextColor = RGB(0,0,0); clrNewBkColor = RGB(255,255,255); }
pLVCD->clrText = clrNewTextColor;
pLVCD->clrTextBk = clrNewBkColor;
*pResult = CDRF_DODEFAULT;
}
please help me correct me where I am wrong
|
|
|
|
|
Le@rner wrote: ...but its not color the ListCtrl subitem text color What color is it? What color do you want it to be?
What is the value of pLVCD->nmcd.dwDrawStage ? Of pLVCD->iSubItem ? Of strTemp ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
When changing colors, you must return CDRF_NEWFONT to notify the control that they has been changed (see last sentence at MSDN article Using Custom Draw[^]).
|
|
|
|
|
Hi All
When I draw button with style :
ModifyStyle(0, BS_OWNERDRAW);
but function DrawItem : no message ODS_DEFAULT.
I can't draw state default of button .
Example : Dialog have edit control and button.
With button no custom : Windows draw focus default button and focus edit control.
With button custom : I can't draw state focus of button when focus edit control .Need press TAB draw state focus of button.
Can you help me ?
Thank.
|
|
|
|
|
Some code segment in chapter 10 of "Windows via C/C++"(5th Edition) is
CEnsureCloseFile hFileSrc = CreateFile(pszFileSrc,
GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_NO_BUFFERING |
FILE_FLAG_OVERLAPPED, NULL);
Here "CEnsureCloseFile" is a class. The Author define Template class "CEnsureCleanup" which was used to clean some objects, then use a this Template define class CEnsureCloseFile
My question is why the HANDLE created by "CreateFile" can be assigned to object hFileSrc . It seems rare. Do you offen do sth like this?
|
|
|
|
|
Since it's just a pointer, it can be set to anything that can handle that appropriately (the constructor for this object likely takes in that type of HANDLE). His class probably just makes sure a file is properly closed without requiring you to explicitly close the file (open file handles can be an issue).
http://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B)[^]
|
|
|
|
|
|
digitalspace.xjtu wrote: why the HANDLE created by "CreateFile" can be assigned to object hFileSrc .
because the class has an overloaded '=' operator.
i don't have the source, but i imagine it looks like this:
TYPE operator=(TYPE t) {
Cleanup();
m_t = (UINT_PTR) t;
return(*this);
}
i do stuff like this all the time. i have dozen of little classes designed to take a handle of some kind in the constructor and then call the appropriate release/delete in the destructor.
|
|
|
|
|
Oh, it is operator overload , thank you very much
|
|
|
|
|
Hi to all,
I am able to generate DSA 512 bit KeyPair using crypto++ using the following code
<br />
<br />
bool CreateDSAKeys()<br />
{<br />
<br />
CryptoPP::AutoSeededX917RNG<CryptoPP::AES> prng;<br />
<br />
try<br />
{<br />
<br />
CryptoPP::GDSA<CryptoPP::SHA1>::GroupParameters pqg;<br />
pqg.GenerateRandom (prng, CryptoPP::MakeParameters(CryptoPP::Name::ModulusSize (), 512)(CryptoPP::Name::SubgroupOrderSize (), 160));<br />
<br />
OutputData(output, "P ", pqg.GetModulus (), pqg.GetModulus ().ByteCount ());<br />
OutputData(output, "Q ", pqg.GetSubgroupOrder(), pqg.GetSubgroupOrder ().ByteCount ());<br />
OutputData(output, "G ", pqg.GetSubgroupGenerator(), pqg.GetSubgroupGenerator ().ByteCount ());<br />
<br />
CryptoPP::GDSA<CryptoPP::SHA1>::Signer priv;<br />
priv.AccessKey().GenerateRandom(prng, pqg);
DSA::Verifier pub(priv);<br />
<br />
OutputData(output, "X ", priv.GetKey().GetPrivateExponent(), priv.GetKey().GetPrivateExponent().ByteCount ());<br />
OutputData(output, "Y ", pub.GetKey().GetPublicElement(), pub.GetKey().GetPublicElement().ByteCount ());<br />
}<br />
}<br />
But, The length of the PrivateKey x Parameter and the length of the Q parameter are not equal and the values of group parameters are also not constant.
can any one suggest me a way to solve this problem.
Thanks in advance.
|
|
|
|
|
Hi All,
when I build visual studio to create exe file .Then I run exe file ,It will have a process . and I continue to run exe file again . Therefore i will have two process for exe file .
How to Create Single Process in C++ ?
I think we can check process currently if process exist we exit new process.
I try to use singleton but i can not create single process.
Do you have any way ?
Thanks
Thong LT
|
|
|
|
|
|
|
Could someone tell me what is going on here? Please.
I am trying to output audio frequency using waveOutWrite. I am using callback function.
Works as expected.
Now I would like to output the audio using the “loop” parameter in the header.
The header sets WHDR_DONE flag when the loop is done.
Now I needed to “translate “ WHDR_DONE flag to the callabck WOM_DONE message for further processing .
I couldn't make the callback work on event so I used this.( I'll try it again).
<b>I have used this „event“ , it partially works but I have no idea why.</b>
HANDLE event;
event = CreateEvent(NULL, TRUE, FALSE, NULL);
DWORD dwWaitResult;
Callback function:
void CALLBACK C_AssynchPlay2::CallbackWaveOutProc(HWAVEOUT hwo,
UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
TRACE("\nvoid CALLBACK C_AssynchPlay2::CallbackWaveOutProc...");
if (uMsg == WOM_DONE)
{
AfxMessageBox("finished "); // gets here
return;
}
Output audio function:
bRC = TRUE;
TRACE("\nInitialize pcm %i ",i );
pcm[i].lFreq = Freq;
pcm[i].dDelay = 1; // Delay; must be < 1
pcm[i].whdr.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP ;
pcm[i].whdr.dwLoops = 5; // works
if(!pcm[i].C_CreateSinus())
TRACE("\nFailed pcm[i].C_CreateSinus() %i ", i );
HANDLE event;
event = CreateEvent(NULL, TRUE, FALSE, NULL);
DWORD dwWaitResult;
mmres = waveOutPrepareHeader(hwout, & pcm[i].whdr, sizeof(WAVEHDR));
if (mmres != MMSYSERR_NOERROR) {ASSERT(0); bOK = FALSE;}
mmres = waveOutWrite(hwout, & pcm[i].whdr, sizeof(WAVEHDR));
TRACE("\nWait event ");
dwWaitResult = WaitForSingleObject(event,INFINITE); //sets WOM_DONE in callback
From here this code never gets processed
TRACE("\nWait event OK ");
AfxMessageBox("Wait event.... ");
return bRC;
Many thanks for your help.
Cheers
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: dwWaitResult = WaitForSingleObject(event,INFINITE); //sets WOM_DONE in callback
You're waiting for an event to be set for an infinite amount of time. I think that it's not returning because the event is never set, and as such the code doesn't progress further to execute your AfxMessageBox.
Have you verified that the WaitForSingleObject call actually returns?
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
That is my main question. When I comment the WaitForSingleObject out the WOM_DONE get set immediatelly after the waveOutWrite. Not waiting for the header loop flag to indicate completion of the loop. There is no mechanism to control that in that case.
It all indicates that the event never gets set as you pointed out.
I have not checked for memory leaks either, mainly beacause the CALLBACK process function gets terminated , for now.
I think I need to go back to try CALLBACK on event instead of just plain CALLBACK function.
|
|
|
|
|
In the case you've provided, the WaitForSingleObject will wait forever (due to the INFINITE time specification), or until the event that's it's waiting on to be "set". Ideally, you should be changing the state of this event in another thread, and the wait will end.
Are you performing everything in the same thread? That's not how it's intended to work.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Yes, it is all done in the same thread.
This callback function starts the audio process and "monitors" the completion of the audio buffer which is set to output about 1 second of audio.
mmres = waveOutOpen(&hwout, WAVE_MAPPER, &wfme,
(DWORD) CallbackWaveOutProc, 0x12345, CALLBACK_FUNCTION);
The issue is that I want to utilize "loop" feature of this audio buffer and output the audio for more then 1 second. Without the "wait for event" the waveOutWrite returns immediately after the audio output starts, setting the WOM_DONE in the callback function.
Inserting the wait for event let the waveOutWrite generate the WOM_DONE AFTER the WHDR_DONE is asserted.
I did write simple wait loop to monitor this WHDR_DONE flag and it worked, but I thought I could use Windows event to do same. It does what I want, but I just do not understand how it does it.
Vaclav
|
|
|
|
|
I want to write program which would completely wipe out my hard disk and the data on the hard disk should not be recoverable once wiped. I want to implement this in c/c++.
|
|
|
|
|
|
I would guess that the only totally wipe would be using "format".
Definitely not in favor of the above link "toy program".
|
|
|
|
|
Step 1: Backup your drives.
This is meant as a humorous reminder. Seriously, don't run a single test before you are sure you have a working backup.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
There's an open source project called DBAN that does this...
http://www.dban.org/[^]
http://en.wikipedia.org/wiki/Darik's_Boot_and_Nuke[^]
Since it's open source, you should be able to look through the source to see how they accomplish this (if you're trying to learn). If you're just trying to blast some old disks, you can just download it and use it, it works VERY WELL (be careful).
|
|
|
|
|