|
I do not know if this will work.
Anyway, try this:
((ProgressDialog *)lparam)->PostMessage(WM_COMMAND,IDOK);
this is this.
|
|
|
|
|
Thank you khan++ - PostMessage has fixed the problem.
I still wondered what was wrong with EndDialog??!!
|
|
|
|
|
No problem with the code.
Please paste the stack trace and ProgressDialog class.
Rahim Rattani
Software Engineer,
Matrix Systems (Pvt) Ltd.,
Karachi - Pakistan
|
|
|
|
|
Hmm.., ((ProgressDialog *)lparam)->PostMessage(WM_COMMAND,IDOK) fixes the problem, but what was wrong with EndDialog?!
Stack trace:
USER32! 77d562cf()
CDialog::EndDialog(int)
ReadDeviceThread(void *)
_threadstart(void *)
KERNEL32!7c80b50b()
----------------------------
ProgressDialog.cpp
----------------------------
// ProgressDialog.cpp : implementation file
//
#include "stdafx.h"
#include "monitor.h"
#include "ProgressDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ProgressDialog dialog
ProgressDialog::ProgressDialog(CWnd* pParent /*=NULL*/)
: CDialog(ProgressDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(ProgressDialog)
m_text = _T("");
//}}AFX_DATA_INIT
}
void ProgressDialog::OnFinalRelease()
{
// When the last reference for an automation object is released
// OnFinalRelease is called. The base class will automatically
// deletes the object. Add additional cleanup required for your
// object before calling the base class.
CDialog::OnFinalRelease();
}
void ProgressDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ProgressDialog)
DDX_Control(pDX, IDC_MPROGRESS, m_bar);
DDX_Text(pDX, IDC_MPROGTEXT, m_text);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ProgressDialog, CDialog)
//{{AFX_MSG_MAP(ProgressDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ProgressDialog message handlers
int ProgressDialog::DoModal(char *txt)
{
m_text = txt;
//m_bar.SetRange(0,100);
//m_bar.SetPos(0);
return CDialog::DoModal();
}
void ProgressDialog::SetText(char *txt)
{
m_text = txt;
UpdateData(FALSE);
}
void ProgressDialog::SetPos(int pos)
{
m_bar.SetPos(pos);
}
void ProgressDialog::OnCancel()
{
// TODO: Add extra cleanup here
StopAcc = 0;
CancelProgressModal = 1;
Sleep(4); // a little delay to stop a collision
CDialog::OnCancel();
}
void ProgressDialog::SetRange(int min, int max)
{
m_bar.SetRange(min, max);
}
----------------------------
ProgressDialog.h
----------------------------
#if !defined(AFX_PROGRESSDIALOG_H__13AB40A1_4F1A_11D2_932F_F4950FC10000__INCLUDED_)
#define AFX_PROGRESSDIALOG_H__13AB40A1_4F1A_11D2_932F_F4950FC10000__INCLUDED_
#include "stdafx.h"
#include "resource.h"
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// ProgressDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// ProgressDialog dialog
class ProgressDialog : public CDialog
{
// Construction
public:
void SetRange(int min, int max);
ProgressDialog(CWnd* pParent = NULL); // standard constructor
void SetText(char *txt);
void SetPos(int pos);
// Dialog Data
//{{AFX_DATA(ProgressDialog)
enum { IDD = IDD_PROGRESS };
CProgressCtrl m_bar;
CString m_text;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ProgressDialog)
public:
virtual void OnFinalRelease();
virtual int DoModal(char *txt);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(ProgressDialog)
virtual void OnCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROGRESSDIALOG_H__13AB40A1_4F1A_11D2_932F_F4950FC10000__INCLUDED_)
|
|
|
|
|
How can i change printing preferences (paper size, orientation etc.)of Microsoft word using MFC program.
We Believe in Excellence
|
|
|
|
|
hi
I have created mfc dialog based application.IN that i have set the bitmaps on dialog box and i am creating dyanmic buttons on that . I am able to see the dynamic buttons but the buttons which i have pasted on dialog box on the bitmaps are not seen.
When i run the application I can see the dialog with bitmaps an dynamic buttons but the buttons already on dialog are seen when i click on dialog box or move it.
It means it is the problem of re-painting.I tried a lot but was not successful. Can anyone help in solving the same.
Best Regards
jhon
|
|
|
|
|
.....i dunno if thiz will help but try thiz out......
each button is derived from a Cwnd class,so we manually put in the code to show the button window as the topmost window.....
and put the code in ur OnInitDialog() function,
GetDlgItem(IDOK)->SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
hope that solvez ur problem.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
hi
no, my problem has not solved.
See i have dialog box and had set the bitmap to whole dialog and then OnInitDialog i have set the bitmaps to the buttons also.First time the buttons are not seen but when i click on dialog they are seen but if i move again they disappear.
waiting for reply
|
|
|
|
|
Try repainting the buttons in OnEraseBkgnd() after drawing the background for the main dialog.
If that fails, try repainting the buttons in OnPaint();
this is this.
|
|
|
|
|
The controls are drawn in tab-order. So, make sure that the bitmaps tab position is before any control that needs to be drawn on top of it.
Selecting Clip Siblings might also work, but I have not varified that.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
hi andrew
thanx for the suggestions.
it worked fine
cheers
Ganesh
|
|
|
|
|
|
look at the following article :
http://www.codeproject.com/com/jscalls.asp
|
|
|
|
|
Ya, I had looked on that article, but I don't want browser interfaces and GUI, is there a way to execute javascript by command line programs, with efficiency using microsoft javascript interpreter.
http://www.priyank.in/
|
|
|
|
|
I am doing ISAPI filter to customize authentication users. Problem now is I want to connect to database to search valid users. My database is MS Access. How can i write the code in Visual C++?
Help me...
Thanks
LeeHerng
|
|
|
|
|
I wouldn't imagine the fact that you're within an ISAPI filter would matter all that much. Just look up some of the many samples on the web ( or even right here on Code Project ) to use an Access database, and then copy it into your code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am using Dev-CPP 4.9.9.2. Whenever i try to use openthread, it says "[linker error] Undefined reference to 'OpenThread'"
What is wrong? OpenProcess works fine, so i dont know whats wrong with openthread...
|
|
|
|
|
OpenThread is only for Windows 2000+, and ME according to the docs, yet OpenProcess has been available since Windows 95. You are not linking to it probably because your WINVER macros are defined as 0x400 (Windows 95 and higher). Up the version on them.
|
|
|
|
|
Ah! Thank you very much, that fixed it completely!
|
|
|
|
|
Hello everyone:
i have a modal dialog which contains many controls for user to operate on so as to continue the work.Now i want to let it embed into the frame,not floating on the screen any more,just like a formview.some one told me to change the dialog as a formview,but there are quite a lot of code i have wrritten based on that dialog.
should i changed it in to a cformview?if that,how can i create it to fit the frame,because on the left side is a big dlgbar.
i am sooooo confused now.is there anyone who can help me?anhthing will be appreciated ,thankx in advance!!!!!!!!!!!
|
|
|
|
|
A formview is basically a surface that you can add controls to like a dialog box, but within a normal windows app, which means you can have tool bars, menus, etc. I'd say that the best thing to do is to make a new formview application, and see if you can copy and paste your control layout between projects. That may work. If not, I'd certainly suggest that a formview is what you need to do anyhow, painful as that may be. You should be able to copy a lot of the code though, just handle the same events, and copy and paste your code between them. If you know how to plumb the MFC message handlers yourself, you can probably do it all by hand.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks for your reply,Christian Graus
can you give me some samples or articles on how to create it ,especially on how to set it the proper size and position?
|
|
|
|
|
I'm not sure what the issue is ? Use SetWindowPos to change the size of your window, and it's position, if required. Why do you need to do this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thank you.just as i have referenced before,i want my modal dialog not to float on the screen any more,but to be a part of my frame,which can be resized like a formview. howerver, i don't know howto create it use a function like DoModal().Is there any one who can help me?Thanks in advance!
|
|
|
|
|
You can't, because it will be embedded in your frame. Your best bet would be to use a formview, and then resize the dialog when a button is pushed to show/hide the section that you're wanting to put in your dialog. To do this, either put the stuff you want to show/hide at the far bottom or far right of the form (so it's easy to size the form to hide it ), or put everything else onto a panel, so you can resize the panel to cover/show the controls in question at the top or left of the form. The second way is better, then you can get everything else to autosize on the panel, and only have to manually move one control.
Christian Graus - Microsoft MVP - C++
|
|
|
|