|
The initial dialog does not paint when there is
a modal dialog in focus, because i run the app in full screen.
But if there are no functions that i can use that deals
with "OnFocus", WM_PAINT works, i just need to be carefull with it.
Thanks
Fredrick
|
|
|
|
|
You could use the WM_ACTIVATE[^] message. Use a handler which looks something like this:
void CDialogAppDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
if (nState==WA_ACTIVE || nState==WA_CLICKACTIVE)
{
}
}
Steve
|
|
|
|
|
Perfect, just what i needed.
Thanks!
|
|
|
|
|
Hello everyone,
I think in built-in C/C++ functions, there is no direct function call to trim heading and trailing space characters, right? So, we have to implement it manually by iterating the string to check character one by one.
Support not using MFC.
thanks in advance,
George
|
|
|
|
|
|
Hi Christian,
It is implemented by find_first_not_of and find_last_not_of of STL string,
no built-in functions.
regards,
George
|
|
|
|
|
G'day George,
dBaseIII had a popular function for this purpose, alltrim. In the mid nineties i needed that function in C and wrote the following implementation, plain C code.
<br />
char *alltrim( char *t)<br />
{<br />
unsigned char *t_, *tc_;<br />
int i=0, l;<br />
<br />
l = strlen(t);<br />
tc_ = (unsigned char*) t;<br />
<br />
<br />
while (*(tc_+i) <= ' ' && i < l)<br />
i++;<br />
<br />
if (i==l) <br />
{<br />
*t = (char) 0; <br />
return t;<br />
}<br />
else<br />
t_ = ( unsigned char* ) (t+i); <br />
<br />
<br />
<br />
i=l-1;<br />
while (*(tc_+i) <= ' ')<br />
i--;<br />
i++; <br />
*(t+i) = ( char ) 0; <br />
l = strlen((char*) t_) + 1; <br />
memmove(t, t_, l); <br />
return t;<br />
}<br />
Unfortunatedly the preview of the code looks awfull, like it has been handled by alltrim itself.
Regards,
Henk
21cm: the universal wavelength of neutral hydrogen
|
|
|
|
|
Thanks Henk,
I think you mean there is no built-in function.
regards,
George
|
|
|
|
|
I have written a CString Object into Text file by using :
f.Write (&FileName,FileName.GetLength());//FileName is CString Object
Now I want to Read CString object back How this could be done?I am using code :
LPTSTR p = CurrentLanguageName.GetBuffer(11);
void *g=(void *)p;
f.Read (g,CurrentLanguageFileLen);
CurrentLanguageName.ReleaseBuffer( );
//But this method don't work.
Regards,
priyank
|
|
|
|
|
you better use CStdioFile class which is derived from CFile.
It has a ReadString and a WriteString method.
|
|
|
|
|
Try the following to write:
CString StringToWrite;
StringToWrite="ABC";//e.g.
f.Write (StringToWrite.GetBuffer(20),StringToWrite.GetLength()+1);
Try the following to read:
CString str;
char B;
for(i=0;i<1000;i++){
f.Read(&B,sizeof(B));
str+=B;
if(B=='\0')break;
}
Not the best way to do it, but if it work U R OK!
kostas KEL
|
|
|
|
|
KEL3 wrote: f.Write (StringToWrite.GetBuffer(20),StringToWrite.GetLength()+1);
Why are you unnecessarily calling GetBuffer() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
pri_skit wrote: f.Write (&FileName,FileName.GetLength());//FileName is CString Object
You might want to check the contents of the file you are writing to, as you are writing the address of the CString object to the file.
pri_skit wrote: //But this method don't work.
Why are you bothering with a void pointer?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote:
Why are you unnecessarily calling GetBuffer()?
If you write:
f.Write (&FileName,FileName.GetLength());
you are about to write the whole object into the file
(including private variables etc...) and that is generally
BAD.
In fact the correct code for that would be:
f.Write (&FileName,sizeof(FileName));
since the previous code would probably crash your app
if the string buffer (allocated on the heap) is longer
than the size of the object.
===============================================
A little correction:
Try the following to read:
CString str;
char B;
for(i=0;i<1000;i++){
f.Read(&B,sizeof(B));
if(B=='\0')break; // Before "str+=B;" to avoid adding two '\0' at the end.
str+=B;
}
kostas KEL
|
|
|
|
|
KEL3 wrote: In fact the correct code for that would be:
f.Write (&FileName,sizeof(FileName));
Wrong. This would still write the address of FileName to the file. Why is it so hard to code something like:
f.Write(FileName, FileName.GetLength());
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, sorry.
I meant that,
f.Write (&FileName,sizeof(FileName));
would be the correct code to save the
object in the file, not the string that
it has allocated. I would be more clear
in future!
But the code I posted above:
f.Write(FileName.GetBuffer(20), FileName.GetLength()+1);
works. I have done it before (that's why
I decided to answer, despite the fact
I'm not an expert). Your piece of code
does the same with less code! I just
didn't have in mind that CString could
be so easily type-casted into LPCSTR
and then to void* .
But you must also use the +1 , so
that the '\0' character be written.
This is needed if you don't know the size
of the string from the beginning.
No mean to argue, you are right.
Thanks for helping me in the past too. Remember this:
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=2117813&df=100&fr=15724.5#xx2117813xx[^]
kostas KEL
|
|
|
|
|
I have a question to calculate gcd of two numbers.I have tried a lot but cant do it. I am very new to Visual C++. How can I do it. I have to do it without using functions. And Please i want it very urgent. Got only few hours to submit.
|
|
|
|
|
Read up on the Euclidean algorithm
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
shabbi89 wrote: ...but cant do it.
Even on paper?
shabbi89 wrote: And Please i want it very urgent. Got only few hours to submit.
Don't let your emergencies become someone else's problem.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Using visual c++ .NET, is there a simple way to isolate functions from
user input during runtime? (This is done with a command-line program)
AIM: So functions can be calculated upon
EXAMPLE FUNCTION: Sin(x+y(Cos(y))
Thanks for any help!
-- modified at 22:04 Saturday 20th October, 2007
J ker
HA! HA! HA!
|
|
|
|
|
no, you have to write your own string parser.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
G'day,
Is there an easy trick to make a dll re-entrant, e.g. each time the dll is called, the caller gets its own data area? The functions in the dll are written in plain C, no classes are involved.
Regards,
Henk
|
|
|
|
|
DLLs can be written without any class, only in C. This is done easily with VC++.
|
|
|
|
|
henk21cm wrote: each time the dll is called, the caller gets its own data area?
I'm not sure what you mean here.
Each process that is linked to DLL gets its own instances of all the
DLLs data, except that data that's explicitly shared somehow.
Except for special shared data, you manage your data in the DLL
just like you do in an EXE. How would each "caller gets its own data area"
in an EXE? Automatic/stack-based variables, some kind of passed data struct,
etc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|