|
Hi, I have a problem...
In my application there is a CEdit box and i put text in it, if I cancel this text the application return a Debug error...
There is some initialization that I must do?
Please help me
|
|
|
|
|
fabiotriolo wrote: if I cancel this text
What does 'cancel' mean ? What did you do ?
fabiotriolo wrote: the application return a Debug error...
What error exactly ?
|
|
|
|
|
Its not sufficient for answer
|
|
|
|
|
WhiteSky wrote: Its not sufficient for answer
humm Happy Eid Buddy!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Im wondering we have two messages on same time
|
|
|
|
|
fabiotriolo wrote: if I cancel this text...
Which means what exactly.
If you have an edit control which must contain valid, non-empty data before the dialog can be dismissed, you should disable the OK button until such conditions exist.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I write text in my edit control...if I erase all text from the edit control, my application return this debug error:
DAMAGE: After Normal block(#97) at 0x003D2998
|
|
|
|
|
fabiotriolo wrote: I write text in my edit control...if I erase all text from the edit control, my application return this debug error:
could you show us your actual code?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Can you show your code that has error
|
|
|
|
|
This is the code:
void CwpaguiDlg::OnEnChangeTextUtente()
{
//prendiamo il testo digitato
int len,i, nLineCount = utente.GetLineCount();
CString strText, strLine, str1Text;
for (i=0;i < nLineCount;i++)
{
len = utente.LineLength(utente.LineIndex(i));
utente.GetLine(i, strText.GetBuffer(len), len);
}
strText.ReleaseBuffer(len);
strLine.Format(TEXT("\"%s\""),strText);
|
|
|
|
|
fabiotriolo wrote: CString strText, strLine, str1Text;
for (i=0;i < nLineCount;i++)
{
len = utente.LineLength(utente.LineIndex(i));
utente.GetLine(i, strText.GetBuffer(len), len);
}
strText.ReleaseBuffer(len);
strLine.Format(TEXT("\"%s\""),strText);
you getting buffer many times but releasing only once.. that is cause of Crashing of you application...
code something like this to avoid crash
void CwpaguiDlg::OnEnChangeTextUtente()
{
//prendiamo il testo digitato
int len,i;
int nLineCount = utente.GetLineCount();
CString strText, strLine, str1Text;
for (i=0;i < nLineCount;i++)
{
len = utente.LineLength(utente.LineIndex(i));
LPTSTR pString = strText.GetBuffer(len );
utente.GetLine(i,pString , len);
strText.ReleaseBuffer();
strLine+=CString(_T("\n")+strText;
}
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Hi,
Sorry to have started a new thread for an old problem.But there was no reply for a long time so I thought I should restart.
If this a problem I won't do it again.
int *pValue = new int;GetParent->SendMessage(MY_MESSAGE, 0, (LPARAM) pValue);
delete pValue;
In the handler function for MY_MESSAGE:
LRESULT MyParent::OnMyMessage( WPARAM wParam, LPARAM lParam )
{
*(int *) lParam = 123; return 0;
}
The above code was given to sent a message to the parent window and allocate memory for a variable which belongs to the parent.
Thanks for the above code.It was really useful
But can I make Message map of the form MY_MESSAGE and have a handler function OnMyMessage ?
Since message maps are something that are provided by Windows API and they can be generated through Class Wizard where messages and their corresponding functions are already given. Ex WM_KEYDOWN with function OnKeyDown()
Prithaa
|
|
|
|
|
Hi,
Actualy i can't understand u r problem.
The steps for sending a message from one class to another is as follows,
1. define the message
ie #define MY_MSG WM_USER + 1
2. Add the handler in u r parent class
ie in messge map
ON_MESSAGE( MY_MSG, OnMyMessage ) and the message handler
void Parent::OnMyMessage( WPARAM wParam_i, LPARAM lParam_i )
{
}
3. Send the message ie
GetParent->PostMessage( MY_MSG, wParam, lParam ));
You can use either SendMessage() or PostMessage() to send message.
rgds
aneesh
|
|
|
|
|
Hi,
Thanks for your reply.I understood what you wrote
and tried but I get this error.
error C2440: 'type cast' : cannot convert from 'void (__thiscall CVer2scratchView::*)(unsigned int,long)' to 'long (__thiscall CWnd::*)(unsigned int,long)'
Pointers to members have different representations; cannot cast between them
This error is on line
ON_MESSAGE(MY_MESSAGE, ONMYMESSAGE)
Can you try what it must be?
Prithaa
|
|
|
|
|
prithaa wrote: error C2440: 'type cast' : cannot convert from 'void (__thiscall CVer2scratchView::*)(unsigned int,long)' to 'long (__thiscall CWnd::*)(unsigned int,long)'
Pointers to members have different representations; cannot cast between them
This error is meaningless without also showing the offending piece of code.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
|
prithaa wrote: Since message maps are something that are provided by Windows API and they can be generated through Class Wizard where messages and their corresponding functions are already given. Ex WM_KEYDOWN with function OnKeyDown()
just have a look at ON_MESSAGE macro in MSDN or if you know Win32 too try overlaoding DefWindowProc
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Hi,
i get a compile error, and i know the error
I have this situation
#include "B.h"
class A
{
B aBObject;
}
******************
#include "A.h"
class B
{
A *pointerToA;
}
During definition of A, B will be defined and uses A ( which is not already defined )
I have already used a #ifndef ... #define ...
Anyone a solution?
Thanks
|
|
|
|
|
In one of the .h-files, use forward declaration of the other class, i.e
class A; //Forward declaration
class B
{
A *pointerToA;
}
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Haupt.h
=======
#pragma once
#include "Einstellungen.h"
class Haupt
{
public:
Haupt(void);
~Haupt(void);
Einstellungen *Config;
void Applic();
};
Haupt.cpp
=========
#include "StdAfx.h"
#include ".\haupt.h"
Haupt::Haupt(void)
{
Config = new Einstellungen(this);
Config->Set();
}
Haupt::~Haupt(void)
{
}
void Haupt::Applic()
{
printf("APPLIC");
}
Einstellungen.h
===============
#pragma once
//#include "Haupt.h"
class Haupt;
class Einstellungen
{
public:
Einstellungen(Haupt *verb);
~Einstellungen(void);
void Set();
Haupt *Verbindung;
};
Einstellungen.cpp
=================
#include "StdAfx.h"
#include ".\einstellungen.h"
Einstellungen::Einstellungen(Haupt *Ver)
{
Verbindung = Ver;
}
Einstellungen::~Einstellungen(void)
{
}
void Einstellungen::Set()
{
Verbindung->Applic();
}
Your solution works only in an alone File, where all Definitions are togheter
But thanks !
|
|
|
|
|
|
i will read some sites
Big thanks
|
|
|
|
|
I'm sorry for not helping you out with your specific problem.
But I'm at work and have some other things to attend to...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
What error do you get?
Does adding #include "Haupt.h" to the top of Einstellungen.cpp fix it?
|
|
|
|