Click here to Skip to main content
15,887,485 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is exe file aligned in size? Pin
krmed1-Oct-09 0:25
krmed1-Oct-09 0:25 
GeneralRe: Is exe file aligned in size? Pin
David Crow1-Oct-09 2:16
David Crow1-Oct-09 2:16 
QuestionComboBox speed issue with XP style Pin
user94130-Sep-09 4:49
user94130-Sep-09 4:49 
QuestionUsing CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart30-Sep-09 4:16
Neil Urquhart30-Sep-09 4:16 
AnswerRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
sashoalm30-Sep-09 4:29
sashoalm30-Sep-09 4:29 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart30-Sep-09 4:39
Neil Urquhart30-Sep-09 4:39 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
David Crow30-Sep-09 5:43
David Crow30-Sep-09 5:43 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart30-Sep-09 6:44
Neil Urquhart30-Sep-09 6:44 
Having produced a reduced version of my dialog I have tracked to source of the exception.

It seems using UpdateData(FALSE) in the OnChangeEdit1() is the source of the problem. Without it I don't get the exception. Its probably not required anyhow. I don't understand why it only causes the problem when the string in the edit control is empty.

This is the code which causes the exception :

// CEditTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CEditTest.h"
#include "CEditTestDlg.h"

// Update timer
#define IDT_UPDATE	1000
#define UPDATE_INTERVAL 1000

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCEditTestDlg dialog

CCEditTestDlg::CCEditTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCEditTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCEditTestDlg)
	m_edit1 = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	bDlgInitDone = FALSE ;

}

void CCEditTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCEditTestDlg)
	DDX_Control(pDX, IDC_SPIN1, m_spin1);
	DDX_Text(pDX, IDC_EDIT1, m_edit1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCEditTestDlg, CDialog)
	//{{AFX_MSG_MAP(CCEditTestDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_TIMER()
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCEditTestDlg message handlers

BOOL CCEditTestDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here

	m_spin1.SetRange(1,99) ;

	// Set the update timer
	SetTimer(IDT_UPDATE, UPDATE_INTERVAL, NULL) ;

	bDlgInitDone = TRUE ;

	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CCEditTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CCEditTestDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CCEditTestDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CCEditTestDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	
	switch (nIDEvent) {
	case IDT_UPDATE :
		// Reset this timeout
		KillTimer(nIDEvent) ;

		UpdateData(TRUE) ;
		UpdateData(FALSE) ;

		// Set the update timer again
		SetTimer(IDT_UPDATE, UPDATE_INTERVAL, NULL) ;

		break ;

	default :
		CDialog::OnTimer(nIDEvent);
	}	
}

void CCEditTestDlg::OnChangeEdit1() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	if(bDlgInitDone) UpdateData(TRUE) ;
	TRACE("value is %d\n", m_edit1) ;

	
}

AnswerRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
David Crow30-Sep-09 6:50
David Crow30-Sep-09 6:50 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart4-Oct-09 20:59
Neil Urquhart4-Oct-09 20:59 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
David Crow5-Oct-09 2:49
David Crow5-Oct-09 2:49 
AnswerRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart30-Sep-09 5:24
Neil Urquhart30-Sep-09 5:24 
QuestionBarcode generator library Pin
Marc Soleda30-Sep-09 3:23
Marc Soleda30-Sep-09 3:23 
AnswerRe: Barcode generator library Pin
includeh1030-Sep-09 5:14
includeh1030-Sep-09 5:14 
AnswerRe: Barcode generator library Pin
Alan Balkany5-Oct-09 4:34
Alan Balkany5-Oct-09 4:34 
QuestionPure virtual Function ?? Pin
Game-point30-Sep-09 3:21
Game-point30-Sep-09 3:21 
AnswerRe: Pure virtual Function ?? Pin
David Crow30-Sep-09 3:25
David Crow30-Sep-09 3:25 
AnswerRe: Pure virtual Function ?? Pin
CPallini30-Sep-09 7:14
mveCPallini30-Sep-09 7:14 
QuestionHow to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
Kushagra Tiwari30-Sep-09 3:10
Kushagra Tiwari30-Sep-09 3:10 
AnswerRe: How to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
David Crow30-Sep-09 3:30
David Crow30-Sep-09 3:30 
AnswerRe: How to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
kilt30-Sep-09 4:30
kilt30-Sep-09 4:30 
AnswerRe: How to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
Randor 30-Sep-09 19:49
professional Randor 30-Sep-09 19:49 
Questionhow convert char[] to LPWSTR for create file !? Pin
hadi kazemi30-Sep-09 2:34
hadi kazemi30-Sep-09 2:34 
AnswerRe: how convert char[] to LPWSTR for create file !? Pin
Hristo-Bojilov30-Sep-09 2:39
Hristo-Bojilov30-Sep-09 2:39 
AnswerRe: how convert char[] to LPWSTR for create file !? Pin
Richard MacCutchan30-Sep-09 2:44
mveRichard MacCutchan30-Sep-09 2:44 

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.