Click here to Skip to main content
16,007,885 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Any 'C' equivalent to Code Project Pin
Rickard Andersson205-Dec-01 21:27
Rickard Andersson205-Dec-01 21:27 
GeneralHTTP file download flow control help needed Pin
Wolfram Steinke5-Dec-01 13:48
Wolfram Steinke5-Dec-01 13:48 
GeneralRe: HTTP file download flow control help needed Pin
Joaquín M López Muñoz5-Dec-01 19:16
Joaquín M López Muñoz5-Dec-01 19:16 
GeneralRe: HTTP file download flow control help needed Pin
Wolfram Steinke6-Dec-01 10:33
Wolfram Steinke6-Dec-01 10:33 
GeneralRe: HTTP file download flow control help needed Pin
markkuk6-Dec-01 20:53
markkuk6-Dec-01 20:53 
GeneralRe: HTTP file download flow control help needed Pin
Wolfram Steinke6-Dec-01 21:07
Wolfram Steinke6-Dec-01 21:07 
GeneralRe: HTTP file download flow control help needed Pin
Ravi Bhavnani6-Dec-01 10:50
professionalRavi Bhavnani6-Dec-01 10:50 
GeneralDialog buttons problem Pin
et5-Dec-01 13:24
et5-Dec-01 13:24 
Last month I posted a problem about my dialog buttons not responsive. Thanks to reply posted by Christian, that's solved by using a worker thread.

I'm now having a couple of problems after solving the above. Hope someone can advise.

The worker thread is started when the user clicks on the CONVERT button. I then change the Cancel to be the default button, so that a simple Enter
would abort the very lengthy conversion.

void CConvert::OnConvert()
{
// start the worker thread
AfxBeginThread(MyThreadProc,this);

// change the buttons
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(FALSE);
m_ok.EnableWindow(FALSE);
m_cancel.SetButtonStyle(BS_DEFPUSHBUTTON);
m_cancel.SetFocus();
}

// my worker thread
UINT MyThreadProc (LPVOID pParam)
{
CConvert * pObject = (CConvert*)pParam;
pObject->DoConvert();
return 0;
}

// my original code to do all the conversion
BOOL CConvert::DoConvert(void)
{
// lots of code up here not shown
//

if (AbortFlag)
{
// conversion was cancelled. Dialog box is gone.
return FALSE;
}
else
{ // normal completion. Dialog box still visible.
// make the OK button default
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(TRUE);
m_cancel.SetButtonStyle(BS_PUSHBUTTON);
m_ok.SetButtonStyle(BS_DEFPUSHBUTTON);
m_ok.EnableWindow(TRUE);
m_ok.SetFocus();
// UpdateData(FALSE); // Cause Assertion Fail. Why?
}
return TRUE;
}


1/ After sucessful conversion the OK button is shown as the Default button, but when I hit Enter, conversion starts again. Seems like the focus is still on the Convert button. How come?

2/ I tried UpdateData(FALSE) but it caused an Assertation Fail. Why?

3/ I think I'm wrong to put all these button manipulations in the worker thread. Maybe I should be using a timer in the Dialog to periodically check on the status of the worker thread and then do these manipulations after the thread is done. Your advise please.

GeneralRe: Try to use SendMessage(...) Pin
Masaaki Onishi5-Dec-01 18:58
Masaaki Onishi5-Dec-01 18:58 
GeneralRe: Dialog buttons problem Pin
Michael Dunn5-Dec-01 19:16
sitebuilderMichael Dunn5-Dec-01 19:16 
GeneralDialog Menu Question Pin
Vu Nguyen5-Dec-01 12:45
Vu Nguyen5-Dec-01 12:45 
GeneralRe: Dialog Menu Question Pin
Michael Dunn5-Dec-01 16:18
sitebuilderMichael Dunn5-Dec-01 16:18 
GeneralHelp/Opion Needed Pin
gordingin5-Dec-01 11:39
gordingin5-Dec-01 11:39 
GeneralRe: Help/Opion Needed Pin
Nemanja Trifunovic5-Dec-01 11:50
Nemanja Trifunovic5-Dec-01 11:50 
GeneralDynamic CScrollBar in a CView object Pin
James Simms5-Dec-01 10:22
James Simms5-Dec-01 10:22 
Generalthe invisible button --action thriller Pin
ahoodin5-Dec-01 7:12
ahoodin5-Dec-01 7:12 
GeneralRe: the invisible button --action thriller Pin
Ganesh Ramaswamy5-Dec-01 8:17
Ganesh Ramaswamy5-Dec-01 8:17 
GeneralRe: the invisible button --action thriller Pin
ahoodin5-Dec-01 8:22
ahoodin5-Dec-01 8:22 
GeneralRe: the invisible button --action thriller Pin
Ganesh Ramaswamy5-Dec-01 8:27
Ganesh Ramaswamy5-Dec-01 8:27 
GeneralRe: the invisible button --action thriller Pin
ahoodin6-Dec-01 11:00
ahoodin6-Dec-01 11:00 
GeneralRe: the invisible button --action thriller Pin
Alvaro Mendez6-Dec-01 10:19
Alvaro Mendez6-Dec-01 10:19 
GeneralRe: the invisible button --action thriller Pin
ahoodin6-Dec-01 10:57
ahoodin6-Dec-01 10:57 
Generalrowdy radio buttons Pin
ahoodin5-Dec-01 7:11
ahoodin5-Dec-01 7:11 
GeneralDisconnect Pin
Rickard Andersson205-Dec-01 6:32
Rickard Andersson205-Dec-01 6:32 
GeneralRe: Disconnect Pin
Michael P Butler5-Dec-01 8:13
Michael P Butler5-Dec-01 8:13 

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.