Hi,
I have a C++ program that runs fine on Windows 2000 for about 5 yrs now and PC is old, I want to replace this PC and Windows 2000 with a new PC and XP, but when I run this program, it hangs at SetDlgItemText() when it displays a message on screen. If I kill this displaying message then the program continue to run and run fine.
I know very little about C++, I have been using C. Please advise how to make this function to exit correctly as it does on Windows 2000.
Thanks so much.
TTAM
2 2076 Banfa 9,065
Expert Mod 8TB
How about you post the code in question.
Thanks for helping me out.
I deleted a lot of code out of this program, so the post doesn't get too long,
I hope that it still has enough info to see the problem.
Thanks so much,
---------------------------------------------------------------------------------------------------------- -
/////////////////////////////////////////////////////////////////////////////
-
// CDigPotDlg dialog
-
-
CDigPotDlg::CDigPotDlg(CWnd* pParent /*=NULL*/)
-
: CDialog(CDigPotDlg::IDD, pParent)
-
{
-
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-
}
-
-
-
void CDigPotDlg::DoDataExchange(CDataExchange* pDX)
-
{
-
CDialog::DoDataExchange(pDX);
-
}
-
-
-
BEGIN_MESSAGE_MAP(CDigPotDlg, CDialog)
-
ON_WM_PAINT()
-
ON_WM_QUERYDRAGICON()
-
ON_MESSAGE( WM_SERIAL_RX_NOTIFY,OnRxNotify)
-
ON_MESSAGE( WM_TX_NOTIFY,OnTxNotify)
-
ON_MESSAGE( WM_FRAMING_ERROR_NOTIFY,OnFramingErrorNotify)
-
ON_MESSAGE( WM_PARITY_ERROR_NOTIFY,OnParityErrorNotify)
-
ON_MESSAGE( WM_HARDWARE_OVERRUN_ERROR_NOTIFY,OnHardwareOverrunErrorNotify)
-
ON_MESSAGE( WM_SOFTWARE_OVERRUN_ERROR_NOTIFY,OnSoftwareOverrunErrorNotify)
-
ON_MESSAGE( WM_BREAK_DETECT_NOTIFY,OnBreakDetectNotify)
-
END_MESSAGE_MAP()
-
-
-
/////////////////////////////////////////////////////////////////////////////
-
// CDigPotDlg message handlers
-
-
BOOL CDigPotDlg::OnInitDialog()
-
{
-
CDialog::OnInitDialog();
-
-
m_iPortEvent = OPENPORT;
-
-
g_eventwait.ResetEvent();
-
-
SetIcon(m_hIcon, TRUE);
-
SetIcon(m_hIcon, FALSE);
-
-
-
beginPotCal();
-
-
return TRUE;
-
}
-
-
-
// 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 CDigPotDlg::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 CDigPotDlg::OnQueryDragIcon()
-
{
-
return (HCURSOR) m_hIcon;
-
}
-
-
-
-
/*******************************************************************************
-
* OnRxNotify(): When data is received from the port, window sends a message
-
* which calls this fuction. OnRxNotify tells the application
-
* what is the next step.
-
********************************************************************************/
-
LRESULT CDigPotDlg::OnRxNotify( WPARAM wParam, LPARAM lParam )
-
{
-
-
if (EPOT == true)
-
{
-
EPOT = false;
-
exit_attn();
-
_exit(1);
-
}
-
-
if(m_calOffset == true)
-
{
-
-
if (m_count == 0)
-
{
-
if(m_result < 0.1)
-
{
-
failure();
-
_exit(1);
-
}
-
}
-
-
-
if(m_result <= adjLimit && result >= -adjLimit)
-
{
-
storeAllWiperNV();
-
complete();
-
_exit(1);
-
}
-
}
-
return 1;
-
}
-
-
-
/********************************************************************************
-
* OnTxNotify(): When data is Transmitted to the port, window sends a message
-
* which calls this fuction. This function checks for the errors.
-
*********************************************************************************/
-
LRESULT CDigPotDlg::OnTxNotify( WPARAM state, LPARAM )
-
{
-
if ( !m_bErrorNotification )
-
{
-
return 0;
-
}
-
return 1;
-
}
-
-
-
/********************************************************************************
-
* beginPotCal(): Opens the USB communication port and begin the Cal
-
*********************************************************************************/
-
void CDigPotDlg::beginPotCal()
-
{
-
-
calOffset();
-
}
-
-
-
/********************************************************************************
-
* OnDestroy() - Call internally by windows. Destroys the dialog window.
-
*********************************************************************************/
-
void CDigPotDlg::OnDestroy()
-
{
-
CDialog::OnDestroy();
-
if ( m_pPort )
-
{
-
delete m_pPort;
-
m_pPort = 0;
-
}
-
}
-
-
-
/********************************************************************************
-
* calOffset() - Setup the application for a offset adjustment.
-
*********************************************************************************/
-
void CDigPotDlg::calOffset()
-
{
-
-
/* Let the operator know the adjustment has begun.
-
*/
-
SetDlgItemText( IDC_STATIC, "Adjusting Offset");
-
-
if(!writeDPvoltageDivider())
-
{
-
failure();
-
}
-
}
-
-
-
/*******************************************************************************
-
* writeVale() - Write a value to the EEPROM location
-
********************************************************************************/
-
void CDigPotDlg::writeValue()
-
{
-
/* Let the operator know the adjustment has begun.
-
*/
-
SetDlgItemText( IDC_STATIC, "Write value to EEPROM");
-
-
aa_Write(byte,devAddr,m_byteAddress);
-
}
-
-
-
/*******************************************************************************
-
* readValue() - Read a value to the EEPROM location
-
********************************************************************************/
-
void CDigPotDlg::readValue()
-
{
-
-
/* Send the command to retrieve value
-
*/
-
SetDlgItemText( IDC_STATIC, "Read value from EEPROM");
-
-
aa_Read(devAddr);
-
}
-
-
-
/********************************************************************************
-
* failure() - This function is called when an error occur
-
********************************************************************************/
-
void CDigPotDlg::failure()
-
{
-
fputs("fail\n",m_fp);
-
fputs((LPCTSTR)m_message,m_fp);
-
fclose(m_fp);
-
-
delete m_pPort;
-
m_pPort = 0;
-
m_iPortEvent = OPENPORT;
-
-
/* Exit the application
-
*/
-
OnOK();
-
}
-
-
-
/********************************************************************************
-
* exit_attn() - Exit the program and close the port
-
********************************************************************************/
-
void CDigPotDlg::exit_attn()
-
{
-
-
if ( m_pPort )
-
{
-
delete m_pPort;
-
m_pPort = 0;
-
m_iPortEvent = OPENPORT;
-
}
-
-
/* Exit the application
-
*/
-
CDialog::OnOK();
-
return;
-
}
-
-
-
/*******************************************************************************
-
* complete() is called when an adjustment has been completed
-
********************************************************************************/
-
void CDigPotDlg::complete()
-
{
-
-
/* Close the comm port
-
*/
-
if ( m_pPort )
-
{
-
delete m_pPort;
-
m_pPort = 0;
-
m_iPortEvent = OPENPORT;
-
}
-
-
/* Exit the application
-
*/
-
OnOK();
-
}
-
-
-
-
LRESULT CDigPotDlg::OnParityErrorNotify( WPARAM, LPARAM )
-
{
-
int result = m_pPort->ParityError( true );
-
return 1;
-
}
-
-
LRESULT CDigPotDlg::OnFramingErrorNotify( WPARAM, LPARAM )
-
{
-
int result = m_pPort->FramingError( true );
-
return 1;
-
}
-
-
LRESULT CDigPotDlg::OnHardwareOverrunErrorNotify( WPARAM, LPARAM )
-
{
-
int result = m_pPort->HardwareOverrunError( true );
-
return 1;
-
}
-
-
LRESULT CDigPotDlg::OnSoftwareOverrunErrorNotify( WPARAM, LPARAM )
-
{
-
int result = m_pPort->SoftwareOverrunError( true );
-
return 1;
-
}
-
-
LRESULT CDigPotDlg::OnBreakDetectNotify( WPARAM, LPARAM )
-
{
-
int result = m_pPort->BreakDetect( true );
-
return 1;
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Xzyx987X |
last post by:
Sorry if this is off topic for this group, but I couln't find any place
better for directing question on Windows API programming. Here's the
problem, I am calling the SetDlgItemText() function to...
|
by: Stuart McGraw |
last post by:
I am having a problem creating Access tables linked to a
Mysql database. I get the widow to select a Data Source,
click on the (system) DSN I created (and tested ok), and
click ok. The Database...
|
by: ssg31415926 |
last post by:
I need to compare two string arrays defined as string such that the
two arrays are equal if the contents of the two are the same, where
order doesn't matter and every element must be unique.
...
|
by: gnuist006 |
last post by:
I have some code like this:
(if (test)
(exit)
(do something))
or
(if (test)
|
by: Laurent Deniau |
last post by:
I would like to know if the use of the pointer ref in the function
cleanup() below is valid or if something in the norm prevents this
kind of cross-reference during exit(). I haven't seen anything...
|
by: yawnmoth |
last post by:
To quote from <http://php.net/function.include>,
"Because include() is a special language construct, parentheses are
not needed around its argument. Take care when comparing return
value."
...
|
by: =?Utf-8?B?U3RldmVEQjE=?= |
last post by:
Hi all.
I'm using VS 2008 Express C++.
I created a console application back in 1999, and updated it for VC++ 6.0 in
2001.
I've updated again this past month, and have found enough differences...
|
by: mathieu |
last post by:
Hi there,
I am trying to reuse a piece of code that was designed as an
application. The code is covered with 'exit' calls. I would like to
reuse it as a library. For that I renamed the 'main'...
|
by: Matthew Fitzgibbons |
last post by:
Matthew Fitzgibbons wrote:
Here's a modified example that _almost_ works:
#!/usr/bin/env python
import code
import time
import threading
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |