|
I assume that means that I need to go back to the initial value of the pointer (the one that was returned from the function) before deleting it... is that correct?
What I'm getting from these responses it that I should do a "delete" for each node pointer in the array first, then a "delete[]" on the array pointer itself as opposed to "delete"...
Let me know if that's all ok. Thanks!
|
|
|
|
|
MALDATA wrote: I assume that means that I need to go back to the initial value of the pointer (the one that was returned from the function) before deleting it... is that correct?
Yes.
MALDATA wrote: What I'm getting from these responses it that I should do a "delete" for each node pointer in the array first, then a "delete[]" on the array pointer itself as opposed to "delete"...
Yes, that's because new goes with delete , and new[] goes with delete[] .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
what I'm trying to so is set up my complete Dialog before it is shown to the user.
Hence, I want to populate some CStatic's and a CEdit. However, I keep getting an Assert error when I populate the CStatic with text. (haven't gotten to the other CStatic's and CEdit yet).
To summarize what I've got and to pick on the first Assert error
the Dialog Editor shows that the static text ID is: IDC_FW_VERSION
within the Dialog's .h file, the static text is listed as:
public: CStatic m_staticFwVersion;
within the Dialog's .cpp file, ::DoDataExchange():
DDX_Control(pDX, IDC_FW_VERSION, m_staticFwVersion);
However, this code (within OnInitDialog) fails every time with the Assert error:
<br />
CString strVersion;<br />
strVersion.Format("FW Ver %x.%02x, CheckSum = %03x, POST %x %s%s", <br />
(Attributes.VersionNumber >> 8) & 0xff,<br />
(Attributes.VersionNumber >> 0) & 0xff,<br />
nChecksum, nPostResult,(!nPostResult) ? "PASS" : "FAIL",PostResults);<br />
m_staticFwVersion.SetWindowText(strVersion);<br />
the CString comes out to be a typical null terminated string.
The debugger shows me the failure point:
void CWnd::SetWindowText(LPCTSTR lpszString)<br />
{<br />
ENSURE(this);<br />
ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
both, m_hWnd and m_pCtrlSite are 0
so where should I initialize the static texts ?
|
|
|
|
|
OnInitDialog is the right place to do this. try stepping into that DDX_Control call, to make sure it's really linking the control to that variable.
|
|
|
|
|
I've put a breakpoint at :
void S2000_CP_DLG::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_FW_VERSION, m_staticFwVersion);
DDX_Control(pDX, IDC_MESSAGES, m_editMessages);
}
and it doesn't hit after :
m_staticFwVersion.SetWindowText(strVersion);
|
|
|
|
|
make sure you're calling UpdateData
|
|
|
|
|
That worked
BOOL MY_DLG::OnInitDialog()<br />
{<br />
BOOL bSuccess;<br />
bSuccess = UpdateData(FALSE);<br />
.<br />
.<br />
.<br />
}
|
|
|
|
|
Hi..
If u want to diplay 'strVersion' on Static Control, just go with SetDlgItemText.
|
|
|
|
|
As has been said, SetDlgItemText is the way to go if you only want to set the static's text once.
But your current problem is probably that DoDataExchange hasn't been called yet.
CDialog::OnInitDialog calls UpdateData (FALSE) which in turn calls DoDataExchange. I bet you've added your code before the CDialog::OnInitDialog that the MFC wizards put in for you.
Iain.
|
|
|
|
|
abiemann wrote: However, I keep getting an Assert error when I populate the CStatic with text.
Most likely because the control does not yet exist.
abiemann wrote: However, this code (within OnInitDialog) fails every time with the Assert error:
Does this code get called after CDialog::OnInitDialog() is called?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
this code:
#include "myDlg.h"
....
BOOL CSistemaPOSDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN
{
switch ( pMsg->wParam )
{
case 106: // '*' was pressed - Asterisc numeric keyboard
CallMyDlg();
break;
case VK_RETURN:
.........
break;
default:
break;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CSistemaPOSDlg::CallMyDlg()
{
CmyDlg pDlg;
pDlg.DoModal()
}
Pretranslate return me an Assertion failed when return from myDlg!! Way??
|
|
|
|
|
What is the reason for the assertion? Where does it occur?
Is there a reason you need to handle messages in PreTranslateMessage()
instead of handling them the usual MFC way?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Just try to call the CDialog::PreTranslateMessage(pMsg) before the CallMyDlg(). I think the problem is because the DoModal will initiate a different message loop, thus the current message may be handled by this second message loop. So when the CDialog::PreTranslateMessage is called, the current message will be different or none. (Only a guess ) )
- NS -
|
|
|
|
|
Does Exist a way to release, or kill the loop from myDlg before return to the parent?
|
|
|
|
|
You mean exit from the application?
Or simply skip the current loop of PreTranslateMsg?
- NS -
|
|
|
|
|
the current loop, may be only with return;
|
|
|
|
|
I think you need to skip the * key hit, right? If so you can just assign pMsg->message = WM_NULL. Then the allowing the current loop to continue.
- NS -
|
|
|
|
|
I have an application where we display the image from a framegrabber. Before it used to work fine, but last week I reinstalled XP since my RAID0 has failed. Now, whenever I run the SAME applicaiton it shows the video fine, but freezes briefly whenever I use any drop down menus on the application's interface and then runs fine again. THis happens only for drop down menus while it works fine when I use any other scroll bars and slide bars, buttons on the interface.
Has anyone came across such a problem before?? The only difference is new XP installation.
thanks
Pavan
|
|
|
|
|
HI,
I'M Studing a course to prevent SQL INJECTION
if anyone can help me with finding open source Code (of an app) in C++
That's doing Blind QSL Injection :
U Enter a URL, & it Checks :
1. if an SQL is availble
2. if ( *2 == TRUE ){DO a Blind SQL INjection Till u Secseed and gives INFO )
TNKS
kobkob
|
|
|
|
|
Greetings everyone,
Using MFC, I want to post a windows message which is same as a keyboard input. So that, another thread, which reads the keyboard inputs, will get the input as if it is from the keyboard.
Could someone please help? Thanks a lot.
Best regards,
zwl
|
|
|
|
|
What about keybd_event() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for the tip. I will try.
Regards,
|
|
|
|
|
|
I am very new to VC, I am trying to load a jpg and display it
I am trying to create from the class CImage m_Image; in the opendocument
section
when trying to build my project I get undeclared identifier
do I need to use the include with the name of the mfc
could you tell what this name is and where to putit in the file
Simon Smith
|
|
|
|
|
Does #include <atlimage.h> help?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|