|
I need to display more than 5000 chars in a edit box.
It seems like MFC edit bos has a limit of 5000 chars.
any suggestions to get around this would be helpful.
thanks
Sanjay
|
|
|
|
|
Sanjay R. Zore wrote:
It seems like MFC edit bos has a limit of 5000 chars.
No such limit exists. What makes you think that an edit control is limited to 5000 characters?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
see CEdit::LimitText
unless you're on 16-bit Windows or Win 95, the only limit on edit control data size is the size of an unsigned 32 bit integer, which is somewhat larger than 5000...
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
i'm trying to run two separate threads. its working when i use an Integer to be passed as an argument to the thread. for example, if i send '1' one thread will keep on telling 1,1,1,1,1,1,1.
[tested using msgbox]
mean while, i send '2'. then another instance of the thread will start saying 2,2,2,2,2,2,
so u will get like 1,2,1,2,1,2,2,1,2,1,1.. like that.. its woking fine.
But if i pass a char[] parameter, its not working
ie,
if i pass "TEST",
it says , "TEST","TEST","TEST".......
meanwhile if i start another to say "CODE",
its destroys "TEST" and so two instance of "CODE" is displayed.
like instead of "TEST","CODE","TEST","CODE",... am getting like "CODE","CODE","CODE"...
plz tell me how to go..
thanks in advance
Thanks in advnace
V
|
|
|
|
|
Vivekuniq wrote:
plz tell me how to go.
You need thread synchronization for this to work. Place a critical section or mutex around your display routine so that only one thread can print at one time.
John
|
|
|
|
|
but how is it working for Integers?
V
|
|
|
|
|
Without the code I can only guess... So here is my best guess: Because the code to output the integers takes so fast that there is no context switch between the call.
John
|
|
|
|
|
if there is no context switch , it should print the same value right?.. sorry if i misunderstand, anyway plz view the code here.. plz try to help me . everytime i'm struggling with the threads .
char[4] agIndv;
UINT CQACDDlg::DevMonitoring(LPVOID p)
{
CQACDDlg * me = (CQACDDlg *)p;
me->DevMonitoring(agIndv);
return 0;
}
void CQACDDlg::DevMonitoring(char[] ageID)
{
while(1)
{
AfxMessageBox(ageID);
//Sleep here for a while
}
}
void CQACDDlg::OnSetSplit() // onclick for new Threads
{
m_SplitID.GetWindowText(agIndv,5); //agIndv is global taken from a CEdit box
AfxBeginThread(DevMonitoring,this);
}
in the header file,
i declare
static UINT DevMonitoring(LPVOID lp);
V
|
|
|
|
|
The objects passed to the threads should probably be allocated on the heap rather than the stack, and then destroyed by the secondary thread. Something like (in MFC):
CString *strName = new CString("David");
AfxBeginThread(ThreadProc, strName);
...
UINT ThreadProc( LPVOID lpVoid )
{
CString *str = (CString *) lpVoid;
...
delete *str;
return 0;
} The same concept can be used with non-MFC code.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
can you tell me in context with the below code?
char[4] agIndv;
UINT CQACDDlg::DevMonitoring(LPVOID p)
{
CQACDDlg * me = (CQACDDlg *)p;
me->DevMonitoring(agIndv);
return 0;
}
void CQACDDlg::DevMonitoring(char ageID[])
{
while(1)
{
AfxMessageBox(ageID);
}
}
void CQACDDlg::OnSetSplit() // OnClick for new Threads
{
m_SplitID.GetWindowText(agIndv,5); //agIndv is global taken from a CEdit box
AfxBeginThread(DevMonitoring,this);
}
Thanks
V
|
|
|
|
|
Hello,
If I see correct, you have a global instance of a char array. I guess that you use that array to write "TEST" and "CODE" to, that are passed to the thread.
Your problem is that you overwrite the contents of the array. So both threads are printing the same array!
To solve this problem, allocate a char array on the heap and pass that to the threads:
UINT CQACDDlg::DevMonitoring(LPVOID p)
{
CQACDDlg * me = (CQACDDlg *)p;
char* psAg = new char[];
me->DevMonitoring(psAg);
return 0;
}
void CQACDDlg::DevMonitoring(char* pszAgeID)
{
while(1)
AfxMessageBox(ageID);
delete[] pszAgeID;
}
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
Behind every great black man...
... is the police. - Conspiracy brother
Behind every great piece of code in this application is
......BOB and David- VivekUniq
EXCELLENT. thank u so much.
V
|
|
|
|
|
Vivekuniq wrote:
EXCELLENT. thank u so much.
You're welcome
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I'll try.
struct info
{
CQACDDlg *pThis;
char *string;
};
void CQACDDlg::DevMonitoring( LPSTR lp )
{
while (1)
AfxMessageBox(lp);
delete [] lp;
}
UINT DevMonitoring( LPVOID lpVoid )
{
struct info *me = (struct info *) lpVoid;
me->pThis->DevMonitoring(me->string);
delete me;
return 0;
}
void CQACDDlg::OnSetSplit()
{
struct info *s1 = new struct info;
s1->pThis = this;
s1->string = new char[5];
lstrcpy(s1->string, "CODE");
AfxBeginThread(::DevMonitoring, s1);
struct info *s2 = new struct info;
s2->pThis = this;
s2->string = new char[5];
lstrcpy(s2->string, "TEST");
AfxBeginThread(::DevMonitoring, s2);
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thank u so much man.. .. i'm so happy
V
|
|
|
|
|
Morning, all
Is it necessary to set the pointer to NULL after delete everytime in C++?
It would cause memory leak by just delete and NOT set to NULL, right?
Thank you!
|
|
|
|
|
valerie99 wrote:
Is it necessary to set the pointer to NULL after delete everytime in C++?
if you're about using the pointer variable again and want to be sure not to use an invalid memory block, yes, set to null.
valerie99 wrote:
it would cause memory leak by just delete and NOT set to NULL, right?
how ????
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
valerie99 wrote:
Is it necessary to set the pointer to NULL after delete everytime in C++?
It's not required, but it is recommended.
valerie99 wrote:
It would cause memory leak by just delete and NOT set to NULL, right?
No, not at all. The memory is freed within the delete operator. Setting the pointer to NULL afterwards is just a precautionary measure.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
valerie99 wrote:
Is it necessary to set the pointer to NULL after delete everytime in C++?
No, but it is considered "a good programming practice".
valerie99 wrote:
It would cause memory leak by just delete and NOT set to NULL, right?
No. It would not.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
valerie99 wrote:
It would cause memory leak by just delete and NOT set to NULL, right?
Out of curiosity, did you happen to program in a garbage collected environment?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
I'm using the COleDateTime control to allow the user to set the date.
My question is : How can i get the selected date by the user?
I know i should handle the MCN_SELECT message'but i don't know how to get the
selected date.
Anyone?
Regards,
Eli
|
|
|
|
|
eli15021979 wrote:
How can i get the selected date by the user?
By using any number of the Getxxx() methods:
GetMonth()
GetDay()
GetYear()
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi David,
First,Thanks for your prompt reply.
I tried the Getxxx() method but the give me the current system time and not the selected date.
Regards,
Eli
|
|
|
|
|
This makes no sense. A COleDateTime object represents whatever date you set it to, be it some past date, the current date, or some future date The concept of 'selecting' a date, much like you would with a UI component, does not exist. You can 'set' the date, however.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi David,
Thanks again for your answers.
It's my mistake - I've set the control class member to COleDateTime instead of CMonthCalCtrl.
with CMonthCalCtrl I can use the GetCurSel() to get the selected date.
With besr regards,
Eli
|
|
|
|