Click here to Skip to main content
15,917,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralPreTranslateMessage in ocx Pin
Dudi Avramov27-Aug-03 0:54
Dudi Avramov27-Aug-03 0:54 
GeneralRe: PreTranslateMessage in ocx Pin
igor196027-Aug-03 9:17
igor196027-Aug-03 9:17 
GeneralRe: PreTranslateMessage in ocx Pin
Dudi Avramov27-Aug-03 21:10
Dudi Avramov27-Aug-03 21:10 
GeneralRe: PreTranslateMessage in ocx Pin
igor196028-Aug-03 8:26
igor196028-Aug-03 8:26 
GeneralRe: PreTranslateMessage in ocx Pin
Dudi Avramov30-Aug-03 19:30
Dudi Avramov30-Aug-03 19:30 
GeneralCustom CWnd - Z-Order Pin
Andrew Birt27-Aug-03 0:49
Andrew Birt27-Aug-03 0:49 
GeneralRe: Custom CWnd - Z-Order Pin
l a u r e n27-Aug-03 7:56
l a u r e n27-Aug-03 7:56 
GeneralThreading problem (Threads, Dialogs and Messages) Pin
d-mon27-Aug-03 0:27
d-mon27-Aug-03 0:27 
Hi!

I created a dialog with a button. When I press that button the thread is started (it opens a dialog with progress bar and abort button - it's basically to show the progress of some lenghty operation that can be aborted (something like Copy in Total Commander).

The code works fine in Debug mode, but it doesn't work in Release mode (you have to set: Property Pages for project->C/C++->Optimization->Optimization to Disabled (/0d), so that it works.
Can anyone explain me why is that?

Here is a code I wrote:
//header of CthreadprogressdlgDlg
afx_msg void OnBnClickedButton1();
LRESULT EndWorkDlg(WPARAM, LPARAM);
CWorkDlg dlg; //the dialog with progress bar and abort button

//implementation
BEGIN_MESSAGE_MAP(CthreadprogressdlgDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
ON_MESSAGE(WORK_END_DLG, EndWorkDlg) //THIS
END_MESSAGE_MAP()

void CthreadprogressdlgDlg::OnBnClickedButton1()
{
dlg.DoModal();
}

LRESULT CthreadprogressdlgDlg::EndWorkDlg(WPARAM, LPARAM)
{
dlg.EndDialog(IDOK);
return 0;
}

//WorkDlg header
afx_msg void OnBnClickedOk();
bool work;
static UINT Go( LPVOID pParam );

//WorkDlg implementation
BOOL CWorkDlg::OnInitDialog()
{
CDialog::OnInitDialog();

AfxBeginThread(Go, static_cast<LPVOID>(this), THREAD_PRIORITY_NORMAL); //this

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

void CWorkDlg::OnBnClickedOk()
{
work = false;
}

UINT CWorkDlg::Go( LPVOID pParam )
{
CWorkDlg *pD = static_cast<CWorkDlg*>(pParam);
while(pD->work) //some long long operation (and the progress bar shows how long it is) Smile | :)
{

}
pD->GetParent()->SendMessage(WORK_END_DLG);
pD->work = true; //reset, so that it will run the next time.
return 0;
}


Does maybe anyone know a better way to do this?
GeneralRe: Threading problem (Threads, Dialogs and Messages) Pin
Neville Franks27-Aug-03 2:24
Neville Franks27-Aug-03 2:24 
GeneralRe: Threading problem (Threads, Dialogs and Messages) Pin
John M. Drescher27-Aug-03 4:54
John M. Drescher27-Aug-03 4:54 
GeneralRe: Threading problem (Threads, Dialogs and Messages) Pin
d_mon@email.si27-Aug-03 9:27
sussd_mon@email.si27-Aug-03 9:27 
GeneralRe: Threading problem (Threads, Dialogs and Messages) Pin
Neville Franks27-Aug-03 10:24
Neville Franks27-Aug-03 10:24 
GeneralRe: Threading problem (Threads, Dialogs and Messages) Pin
valikac27-Aug-03 12:53
valikac27-Aug-03 12:53 
Generallinking error Pin
bhawin1327-Aug-03 0:04
bhawin1327-Aug-03 0:04 
GeneralRe: linking error Pin
Ryan Binns27-Aug-03 0:45
Ryan Binns27-Aug-03 0:45 
Generallinking error Pin
bhawin1327-Aug-03 0:02
bhawin1327-Aug-03 0:02 
GeneralRe: linking error Pin
Alexander M.,27-Aug-03 13:02
Alexander M.,27-Aug-03 13:02 
GeneralExperts please help.. Pin
rohit.dhamija26-Aug-03 23:56
rohit.dhamija26-Aug-03 23:56 
GeneralRe: Experts please help.. Pin
Magnus Westin27-Aug-03 2:45
Magnus Westin27-Aug-03 2:45 
Generalsome predefinitions Pin
FlyingDancer26-Aug-03 23:09
FlyingDancer26-Aug-03 23:09 
GeneralRe: some predefinitions Pin
Ryan Binns27-Aug-03 0:52
Ryan Binns27-Aug-03 0:52 
GeneralRe: some predefinitions Pin
FlyingDancer27-Aug-03 2:32
FlyingDancer27-Aug-03 2:32 
Questionunicode value ??? Pin
Manikandan26-Aug-03 22:57
Manikandan26-Aug-03 22:57 
AnswerRe: unicode value ??? Pin
Anonymous27-Aug-03 3:51
Anonymous27-Aug-03 3:51 
QuestionHow to rigister the auto-hide style window? Pin
Hendy_So26-Aug-03 22:37
Hendy_So26-Aug-03 22:37 

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.