|
I have developed a MFC application for some equipment. The interface between my application and equipment is through serial COM port. Now problem is like this, whenever I starts the application and one dialog box appears to choose the COM port(there are two ports in one PC). If I clicks on the caption bar of that dialog box by mouse, than it displays a message box showing illegal operation and I have to close the application. Suggest me what can be the problem with my application ?
Otherwise my application is working fine.
Thanks.
Arun
|
|
|
|
|
Build a debug version, enter the debugger when it crashes, and you'll see where the problem is.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I am running the debug version already......
But there is no Retry or Debug button onth illigal message box.
|
|
|
|
|
Show us the source code of the dialog where you choose the serial port ...
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Although this problem is not consistent.
the cpp file is :
// ProtComPortDlg.cpp : implementation file
//
#include "stdafx.h"
#include "FasGui.h"
#include "ProtComPortDlg.h"
#include "MainFrm.h"
#include "Music.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
bool CProtComPortDlg::bFasBmpFlag;
/////////////////////////////////////////////////////////////////////////////
// CProtComPortDlg dialog
CProtComPortDlg::CProtComPortDlg(CWnd* pParent /*=NULL*/)
: CDialog(CProtComPortDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProtComPortDlg)
m_nComPort1 = 1;
m_strPortSystemName = _T("Fas");
//}}AFX_DATA_INIT
}
void CProtComPortDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProtComPortDlg)
DDX_Radio(pDX, IDC_PORTCOM1, m_nComPort1);
DDX_Text(pDX, IDC_PORTSYSTEMNAME, m_strPortSystemName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProtComPortDlg, CDialog)
//{{AFX_MSG_MAP(CProtComPortDlg)
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProtComPortDlg message handlers
BOOL CProtComPortDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SetIcon(AfxGetApp()->LoadIcon(IDR_MAIN),FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CProtComPortDlg::OnCancel()
{
// TODO: Add extra cleanup here
CMusic MusicObj;
strSong = "Utopia.wav";
MusicObj.PlayMusic();
if(AfxMessageBox("This will terminate the application\nContinue with termination...",MB_YESNO|MB_ICONQUESTION) == IDYES)
{
PostQuitMessage(NULL);
}
//CDialog::OnCancel();
}
BOOL CProtComPortDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
::SetCursor(::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CDOT)));
return TRUE;
// return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
I am calling the DoModal() of this class in MainFrm.cpp as:
if(ProtComPortDlgObj.DoModal()==IDOK)
{
//some processing
}
bye
|
|
|
|
|
Maybe the line ::SetCursor(::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CDOT))); in the function BOOL CProtComPortDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) function produce the error ?!?!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
I have a moduless dialog which has WS_CHILD property in a dll and used as an child in a view. when the dialog has focus ,it look the accelerator key massage as a dialog message and does not pass to it's parent(the view),while my purpose is that it should route the msg to the view and the dispatch to any it's child.Please tell me how to achieve this.
some presetive code goes:
In the view class:
<br />
BOOL CTestAccelView::PreTranslateMessage(MSG* pMsg) <br />
{<br />
if(TranslateAccelerator(m_hWnd,m_hAccelTest,pMsg))<br />
return TRUE;<br />
if(m_pTestDlgWnd && m_pTestDlgWnd->GetSafeHwnd() )<br />
if(m_pTestDlgWnd->PreTranslateMessage(pMsg))<br />
return TRUE;<br />
if(m_pTestDlgWnd2 && m_pTestDlgWnd2->GetSafeHwnd())<br />
if(m_pTestDlgWnd2->PreTranslateMessage(pMsg))<br />
return TRUE;<br />
return CView::PreTranslateMessage(pMsg);<br />
}<br />
In the Dialog class:
<br />
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg) <br />
{<br />
if(TranslateAccelerator(m_hWnd,m_hAccelTest,pMsg))<br />
{<br />
return TRUE;<br />
}<br />
if(IsDialogMessage(pMsg))<br />
{<br />
return TRUE;<br />
}<br />
return CWnd::PreTranslateMessage(pMsg);<br />
}<br />
Scratch
|
|
|
|
|
hello @all,
i posted this message yesterday in this forum and i got much assistance, however give it another and easier way, without THEADS.!!
i have a dialogbased program.
there a two buttons (eg. button1 and button2).
if i press button1 first i get a new dialog (ID_DIALOG_COMBO) with a combobox (m_ctrlComboBox ).
if i press the button2 a CString (CString mystring ) should be enterd into the combobox from the ID_DIALOG_COMBO.
how can i do this????
thank you very much
this is only an example, to explain the real background would be take to much time
sunny
|
|
|
|
|
The dialog needs to be modeless, end of story. Someone said that to you yesterday and it's all you need. Once you have a modeless dialog, then you can still press the second button while the dialog is up, and you can create a method on the modeless dialog which takes your string and enters it into your combo box. Call that method when button two is pressed, and you're done.
People suggested you need *threads* to do this ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
thanks for reply.
Christian Graus wrote:
The dialog needs to be modeless
i have modeless dialogs!!!
Christian Graus wrote:
you can create a method on the modeless dialog which takes your string and enters it into your combo box
that is, what i mean! how can i do this? how should the method look like?
thanks
sunny
|
|
|
|
|
public:
void PassText(CString s);
void MyModelessDialog::PassText(CString s)
{
MyComboBox.SetWindowText(s);
}
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
i´m sorry, i do not understand this code example! can i use it in mfc???
thank you very much
sunny
|
|
|
|
|
I'm sorry, but I think you probably need to go back to C++ without MFC, or Windows of any kind, if you do not understand this. That is a friendly suggestion, not an insult.
To put text into the edit area of a combobox, you call it's SetWindowText method. That is an MFC method, and it requires that you've created a variable of type CComboBox in your modeless dialog box. The rest of the function is basic C++, I showed the declaration ( the bit in the .h file ) to show it needs to not be private ( that is not actually true, but it's the simplest way ), and the definition, where all we do is take the string and shove it into the combo box. You then call that method on the combo box in the method the class wizard defines for you for when you push button 2.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
I'm sorry, but I think you probably need to go back to C++ without MFC, or Windows of any kind, if you do not understand this. That is a friendly suggestion, not an insult.
that or i should go to bed earlier. i believes my brain is still sleeping.
first, i will try to go to bed more earlier. ;);)
thanks for your reply! i think your idea is perfekt and i will try it.
sunny
|
|
|
|
|
Sunnygirl wrote:
that or i should go to bed earlier.
Well, that is always an option, I have days like that myself.
Sunnygirl wrote:
i think your idea is perfekt and i will try it.
Good luck - if you get stuck, just ask some more.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
hi all
can i know how do i set the date of my programme so that it can take the date directly from the computer without we ned to set everytime we use the programme.Do i need to ue timer to do that.
pls reply asap
Thank alot!!!!!
diana
|
|
|
|
|
time.h contains an API called time, and one called ( from memory ) globaltime. If you look up time_t in the MSDN, you'll find all you need.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
It's so long since I had to this I have forgotten how to enumerate the com ports that are installed in a machine, including a USB to serial adaptor.
Does anyone have a simple example at their fingertips?
Thanks in advance.
Happy programming!!
|
|
|
|
|
Hi Wolfram,
there are a couple of hints in the Windows DDK documentation.. Try to search MSDN for 'Serenum', maybe this could help you.
Another aproach is try to open all known ports, in most cases it's enough to do this with at least 9 ports (COM1- COM9). If open returns OK, you can use this port, if not, it's already in use or not there...
That's the way I do it in my apps...
Greetings!
Olli!
Olli
Make it idiot proof and someone will make a better idiot......
|
|
|
|
|
The COM1-COM9 is what we did and thought is was a big enough choice to connect a single device up, but we had a bug report that COM10 was missing. Hence I thought if I enumerate what is actually installed there should be no further debate.
Happy programming!!
|
|
|
|
|
Take a look on http://www.codeproject.com/system/enumports.asp
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Thanks
Wonder why that didn't come up when I did a search?
Well I have it now
Happy programming!!
|
|
|
|
|
hi everybody,
i made a couple customized commands on my menu. i bind all the event handlers to the commands and they work correctly.. when i was running/testing my program, i check out the debug/output windows and i noticed i keep on getting error warning messages on the commands that i defined.. can someone please tell me what does this message mean? altho it doesn't affect the functionality of the program, i want to know what does it mean exactly.. thx in advance..
the error message:
Warning: no message line prompt for ID 0x0098.
|
|
|
|
|
When your main frame has a status bar, MFC shows flyby help in the status bar for the selected menu item. The debug msg is saying that you don't have a flyby help string for the menu item with ID 0x98. You can set a help string by double-clicking the menu item in the menu editor, then filling in the "Prompt" field in the property sheet.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Anyone have any references for detecting temperature sensors on a motherboard and reading them??
PRETTY PLEASE
|
|
|
|