|
MyFathersSon wrote: Problem is, I can't get the data out from the edit control whenever I type anything in
Maybe these will help?
Three ways to get text from an edit control:
CEdit::GetWindowText()
EM_GETLINE message to edit control
WM_GETTEXT message to edit control
|
|
|
|
|
Cheers Mark, Unfortunately I feel that the code might be causing problems. I code the control as follows:
void CEditableCircleCtrl::DrawControl()//called by OnDraw method
{
CDC *pDC = GetDC();
if(pDC == NULL)
{
return;
}
CRect circlerect;
//draw the round rectangle
circlerect.top = 0;
circlerect.left = 0;
circlerect.bottom = 40;
circlerect.right = 40;
pDC->Ellipse(circlerect);
}
...
int CEditableCircleCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
//create the edit box
editrect.top = 13;
editrect.left = 6;
editrect.bottom = 28;
editrect.right = 36;
editctrl.Create(WS_VISIBLE|WS_CHILD|ES_CENTER,editrect, this, 0);
return 0;
}
How can I get hold of the text? Am I doing something wrong? WM_CHAR doesn't capture any text entered in the control. Where would I place any of your suggestions?
|
|
|
|
|
WM_CHAR would be sent to your editctrl object (which I assume is a CEdit(?)) so you'd need to
override CEdit and in your derived class handle WM_CHAR. That's if you really need to intercept
every char as it is entered by the user.
Anytime you want to extract the text from the edit control (after it is created, of course) you
can use something like
TCHAR szBuffer = new TCHAR[editctrl.GetWindowTextLength() + 1];
editctrl.GetWindowText(szBuffer, GetWindowTextLength() + 1); or
CString str;
editctrl.GetWindowText(str);
|
|
|
|
|
Cheers Mark, that was very helpful. Thanks for your time
|
|
|
|
|
Hie,
I have one function
void Log(const string& format="", ...)
{
va_list args;
va_start(args,format);
int len= vsprintf(buffer, format, args);
va_end(args);
cout<
|
|
|
|
|
vikrams wrote: vsprintf(buffer, format, args);
Maybe you are passing a invalid format string. If it's not a valid format string then the behavior is undefined.
Maybe you can modify the above function to look like this...
void __cdecl Log( const char* lpszString, ... )
{
va_list args;
va_start(args, lpszString );
int len = vsprintf(buffer, lpszString, args );
va_end(args);
}
And what is this buffer variable??
|
|
|
|
|
I tried using format.c_str().
but it's crashing.
|
|
|
|
|
please Vikrams you start to know CP well enough nowadays to know that you should post code samples within <pre></pre> html tags...
see my sig for a relevant link
|
|
|
|
|
To add to Nibu , uninitialized buffer could be causing crash.
Can you show , how it is declared ?
|
|
|
|
|
void Log(const string& format="", ...)
{
char buffer[1024]="";
va_list args;
va_start(args,format);
int len= vsprintf(buffer, format.c_str(), args);
va_end(args);
cout<<buffer;
}
This is not working !
|
|
|
|
|
This code runs without any crash.
|
|
|
|
|
vikrams wrote: This is not working !
With what input?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
vikrams wrote: This is not working !
When using a string type, va_start() adds 16 bytes to the starting address of format to get to the first optional argument. However, when using format.c_str() with vsprintf() , you are not 16 bytes from the start of format .
Try this instead:
void Log(const char *format, ...)
{
char buffer[1024] = "";
va_list args;
va_start(args, format);
int len= vsprintf(buffer, format, args);
va_end(args);
cout<<buffer<<endl;
}
...
Log(fmt.c_str(), "Hello World");
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'd use the Boost.Format[^] library to do this kind of thing.
Steve
|
|
|
|
|
I am programming with strings and i got this error when i am trying to upgrade my code from VC6.0 to VC7.1 . Its very urgent can anybody help me please.
regards,
venkat.
Uday kiran
|
|
|
|
|
|
Which identifier is not found ? Your post is lacking of relevant information.
Identifier not found probably means that you forgot to include a header file.
|
|
|
|
|
uday kiran janaswamy wrote: I am programming with strings
I think it's not _L but _T .
|
|
|
|
|
Hi all,
do we have some way by which we can have a function
with which we can do the cleanup job!!
like exit handler for threads.
i have created thread with CreateThread
Thanks
Harshal
|
|
|
|
|
You can call any function you have access to from your thread.
Write a cleanup function and call it?
Are you thinking along the lines of InitInstance/ExitInstance virtual initialization/cleanup
methods?
|
|
|
|
|
hello
can we have a toolbar on dialog ???
|
|
|
|
|
have you had a look here[^] ?
|
|
|
|
|
cancerion wrote: can we have a toolbar on dialog ???
Take a look at CWnd::RepositionBars . MSDN has a nice sample on this too.
For the sample you will have to search MSDN with the keyword as RepositionBars .
|
|
|
|
|
Yes and you can see examples on codeproject
|
|
|
|
|