Click here to Skip to main content
15,920,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Calculating an angle of a line Pin
NeverFall1-Jun-05 22:11
NeverFall1-Jun-05 22:11 
GeneralCGdiObject::CreateStockObject Pin
Stlan1-Jun-05 19:26
Stlan1-Jun-05 19:26 
GeneralRe: CGdiObject::CreateStockObject Pin
super1-Jun-05 20:50
professionalsuper1-Jun-05 20:50 
GeneralRe: CGdiObject::CreateStockObject Pin
HumanOsc1-Jun-05 21:38
HumanOsc1-Jun-05 21:38 
GeneralRe: CGdiObject::CreateStockObject Pin
super1-Jun-05 21:46
professionalsuper1-Jun-05 21:46 
GeneralRe: CGdiObject::CreateStockObject Pin
Stlan1-Jun-05 22:09
Stlan1-Jun-05 22:09 
QuestionHow Can I add Random Mode? Pin
Keitaro211-Jun-05 19:06
Keitaro211-Jun-05 19:06 
AnswerRe: How Can I add Random Mode? Pin
Cedric Moonen1-Jun-05 21:17
Cedric Moonen1-Jun-05 21:17 
Stack overflow happens in general when you have an infinite recursion (a function that calls itself that calls itself that....). Here in your code, you are calling OnNext until you get a different number of the song that is currently played (or at least, this is want you are trying to do).
First thing, don't call OnNext but rather but the selection of a new song number in a loop. This is really horrible (I mean by code):

if( m_nPlayIndexTemp != m_nPlayIndex )
{
m_nPlayIndex = m_nPlayIndexTemp;
}
else
{
OnNext();
}


rather replace it by something like that:

while (true)
{
     m_nPlayIndexTemp =  CalculateRandomNumberHere();
     if (m_nPlayIndexTemp != m_nPlayIndex)
         break;
}


Second, the way you use for calculate random numbers is false:
rand()%theApp.GetMainDlg()->m_pDlg_PlayList->m_PlayList.GetCount();

The modulo operator (%) will give you the remainder of the division. So for example if you have 1 song in the playlist, and rand() gives you 123456, the result will be 123456. Mhh, a little bit outside the bounds of your playlist no ?
Better use something like that:

rand()*nCount/RAND_MAX;
GeneralRe: How Can I add Random Mode? Pin
recoup_this2-Jun-05 2:24
recoup_this2-Jun-05 2:24 
Questionis it possible to know which disc inserted to dvd-r drive? Pin
baboguru1-Jun-05 18:59
baboguru1-Jun-05 18:59 
AnswerRe: is it possible to know which disc inserted to dvd-r drive? Pin
kakan2-Jun-05 3:24
professionalkakan2-Jun-05 3:24 
GeneralCOM Exe Link error Pin
VCSharp0071-Jun-05 18:07
VCSharp0071-Jun-05 18:07 
GeneralRe: COM Exe Link error Pin
Christian Graus1-Jun-05 18:16
protectorChristian Graus1-Jun-05 18:16 
GeneralRe: COM Exe Link error Pin
VCSharp0071-Jun-05 21:00
VCSharp0071-Jun-05 21:00 
GeneralRe: COM Exe Link error Pin
NormDroid1-Jun-05 23:23
professionalNormDroid1-Jun-05 23:23 
GeneralRe: COM Exe Link error Pin
VCSharp0072-Jun-05 3:13
VCSharp0072-Jun-05 3:13 
GeneralHi All Pin
Sreekanth Muralidharan1-Jun-05 18:01
Sreekanth Muralidharan1-Jun-05 18:01 
GeneralRe: Hi All Pin
ThatsAlok1-Jun-05 19:18
ThatsAlok1-Jun-05 19:18 
GeneralAbout <b>FindFirstChangeNotification</b> and <b>ReadDirectoryChangeW</b> Pin
a_du1-Jun-05 16:31
a_du1-Jun-05 16:31 
GeneralRe: About <b>FindFirstChangeNotification</b> and <b>ReadDirectoryChangeW</b> Pin
ThatsAlok1-Jun-05 18:51
ThatsAlok1-Jun-05 18:51 
GeneralRe: About <b>FindFirstChangeNotification</b> and <b>ReadDirectoryChangeW</b> Pin
a_du1-Jun-05 23:41
a_du1-Jun-05 23:41 
GeneralRe: About <b>FindFirstChangeNotification</b> and <b>ReadDirectoryChangeW</b> Pin
ThatsAlok1-Jun-05 23:55
ThatsAlok1-Jun-05 23:55 
GeneralRe: About <b>FindFirstChangeNotification</b> and <b>ReadDirectoryChangeW</b> Pin
S. Senthil Kumar1-Jun-05 23:45
S. Senthil Kumar1-Jun-05 23:45 
GeneralRe: About <b>FindFirstChangeNotification</b> and <b>ReadDirectoryChangeW</b> Pin
ThatsAlok1-Jun-05 23:57
ThatsAlok1-Jun-05 23:57 
GeneralPostMessage causing hang... Pin
Ian Bowler1-Jun-05 16:25
Ian Bowler1-Jun-05 16:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.