Click here to Skip to main content
15,901,373 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to get a dynamic created control's dc Pin
paraGOD13-Nov-05 3:55
paraGOD13-Nov-05 3:55 
AnswerRe: How to get a dynamic created control's dc Pin
douglasjordan13-Nov-05 11:46
douglasjordan13-Nov-05 11:46 
GeneralRe: How to get a dynamic created control's dc Pin
paraGOD13-Nov-05 16:25
paraGOD13-Nov-05 16:25 
GeneralRe: How to get a dynamic created control's dc Pin
jhwurmbach13-Nov-05 21:58
jhwurmbach13-Nov-05 21:58 
QuestionBad Loop help please Pin
B.F.13-Nov-05 1:51
B.F.13-Nov-05 1:51 
AnswerRe: Bad Loop help please Pin
Gary R. Wheeler13-Nov-05 1:55
Gary R. Wheeler13-Nov-05 1:55 
GeneralRe: Bad Loop help please Pin
B.F.13-Nov-05 2:17
B.F.13-Nov-05 2:17 
GeneralRe: Bad Loop help please Pin
Gary R. Wheeler13-Nov-05 2:44
Gary R. Wheeler13-Nov-05 2:44 
I think I've figured it out. Here's your original code:
void CZmurfDICEDlg::OnD20() 
{
  int ret;
  for(int k=0; k < m_E20; k++) //edit box, integer, where I want to set the # of throws
  {
    UpdateData(TRUE);
    m_strET=""; //edit box that get each value at a turn (visible-false)
    srand((unsigned)clock());
    ret=rand()%20+1;
    m_strET.Format("%d ",ret);
    m_strMessage=m_strMessage+m_strET; //edit box ,the dice throw result can be seen
  }
  UpdateData(FALSE);
}
Calling UpdateData(TRUE) inside the loop resets all of the member values to whatever is on the screen, which clears out what you've been calculating in the loop. Also, you don't need to seed the random number generator each iteration of the loop. Try this instead:
void CZmurfDICEDlg::OnD20() 
{
  int ret;
  UpdateData(TRUE);
  srand((unsigned)clock());
  m_strMessage="";
  for(int k=0; k < m_E20; k++) //edit box, integer, where I want to set the # of throws
  {
    m_strET=""; //edit box that get each value at a turn (visible-false)
    ret=rand()%20+1;
    m_strET.Format("%d ",ret);
    m_strMessage=m_strMessage+m_strET; //edit box ,the dice throw result can be seen
  }
  UpdateData(FALSE);
}
Using this logic, m_strET will display the last value calculated, and m_strMessage should display the list.


Software Zen: delete this;
GeneralRe: Bad Loop help please (side note) Pin
Gary R. Wheeler13-Nov-05 2:47
Gary R. Wheeler13-Nov-05 2:47 
GeneralRe: Bad Loop help please (side note) Pin
B.F.13-Nov-05 4:37
B.F.13-Nov-05 4:37 
GeneralRe: Bad Loop help please Pin
lklf13-Nov-05 16:51
lklf13-Nov-05 16:51 
AnswerRe: Bad Loop help please Pin
chamilkab13-Nov-05 18:00
chamilkab13-Nov-05 18:00 
Questionproblems with ST_SplitterWnd and CFrameWnd Pin
#937013-Nov-05 1:34
#937013-Nov-05 1:34 
AnswerRe: problems with ST_SplitterWnd and CFrameWnd Pin
Gary R. Wheeler13-Nov-05 2:01
Gary R. Wheeler13-Nov-05 2:01 
GeneralRe: problems with ST_SplitterWnd and CFrameWnd Pin
#937013-Nov-05 4:18
#937013-Nov-05 4:18 
QuestionOPC XML DA Client - Managed C++ Implementation Pin
exetera13-Nov-05 0:38
exetera13-Nov-05 0:38 
QuestionDouble Buffering Pin
Akilez12-Nov-05 22:17
Akilez12-Nov-05 22:17 
AnswerRe: Double Buffering Pin
Jack Puppy13-Nov-05 1:37
Jack Puppy13-Nov-05 1:37 
AnswerRe: Double Buffering Pin
Michael Dunn13-Nov-05 12:31
sitebuilderMichael Dunn13-Nov-05 12:31 
QuestionHow to use _inp and _outp in VC++ Pin
vikas amin12-Nov-05 21:43
vikas amin12-Nov-05 21:43 
AnswerRe: How to use _inp and _outp in VC++ Pin
Gary R. Wheeler13-Nov-05 2:17
Gary R. Wheeler13-Nov-05 2:17 
AnswerRe: How to use _inp and _outp in VC++ Pin
douglasjordan13-Nov-05 15:32
douglasjordan13-Nov-05 15:32 
AnswerRe: How to use _inp and _outp in VC++ Pin
ThatsAlok13-Nov-05 17:32
ThatsAlok13-Nov-05 17:32 
AnswerRe: How to use _inp and _outp in VC++ Pin
normanS13-Nov-05 19:07
normanS13-Nov-05 19:07 
QuestionHow to manage the code in VC++ Pin
vikas amin12-Nov-05 19:12
vikas amin12-Nov-05 19:12 

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.