|
|
Actually I meant the same that CFrameWnd do.
void CFrameWnd::PostNcDestroy()
{
delete this;
}
- NS -
|
|
|
|
|
But you told him to check the CWnd::PostNcDestroy()
|
|
|
|
|
Ofcourse. MSDN clearly says "Derived classes can use this function for custom cleanup such as the deletion of the this pointer." in Remarks section. Please have a look.
- NS -
|
|
|
|
|
Thats ok. After checking that function in MSDN, he will understand that he can delete this pointer from the postncdestroy() function. But his question was whether its safe to delete a CWnd pointer and the above explanation doesnt answer it. Like if it is not safe, why?
|
|
|
|
|
His question is a little bit different. He asked whether it can be done from DestroyWindow. But PostNCDestroy is called from void CWnd::OnNcDestroy() which is called when WM_NCDESTROY is sent to that window. WM_NCDESTROY is the last message received by the window in destruction. So I think it is safe to use, if it is safely handled. I mentioned that CFrameWnd is using this technique safely.
- NS -
|
|
|
|
|
One thing I find inside the Destroy -- is a call to Detach -- which seperates the HWND from the CWnd. It seems safe to delete at that time.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
assumption:
char c[4]={1,2,3,4};
char* addr=c;
then addr is the address of c[0], the address c is the address c[0];then i want to know, what is the mean and value of &c? what is the mean of (int*)&c ?
thanks
|
|
|
|
|
It is pointer to pointer i.e. int**
|
|
|
|
|
Lao Wang wrote: what is the mean and value of &c?
It is the address of c array. It will be same as &c[0].
Lao Wang wrote: what is the mean of (int*)&c ?
It is only a conversion of pointer from (char*) to (int*)
- NS -
|
|
|
|
|
NS17 wrote: It is only a conversion of pointer from (char*) to (int*)
char* ? or char** ?
|
|
|
|
|
Yes char** is correct.
I mentioned only about the memory adresss.
- NS -
|
|
|
|
|
you already got some good answers, but i'll sum it up.
c is defined as an array of char , so, basically, it can be seen as a char* .
& used as an unary operator means to return the address of the variable attached, so &c is the address of c.
but as c is a char* , its address is a char** .
in front of it, you have a cast operator, which casts the address returned into an int* address
|
|
|
|
|
thanks
as your mean, &c=char** , but the equation char ** c=&c, has compile wrong message with "can not convert from char (*)[4] to char **"
so i think &c != &c[0];
|
|
|
|
|
Lao Wang wrote: so i think &c != &c[0];
how do you test this ?
BTW, c == &(c[0])
but the first element of the array is at the address of the beginning of the array
|
|
|
|
|
Hi all,
I create a database on SQL 2005 Express edition and link it to a C++/MFC application as follows. It wont gives any compile time errors. But at run time, it gives an error. Here are details.
Link the database in OnInitDialog()
here is the code
<br />
BOOL CSRFDBDlg::OnInitDialog()<br />
{<br />
CDatabase srfDB ;<br />
CString srfNAME ;<br />
<br />
srfNAME = "ODBC; DSN=.SQLEXPRESS; UID=sa; PWD=sa123; DATABASE=srfdb.mdf" ;<br />
srfDB.Open(srfNAME) ;<br />
if(srfDB.IsOpen())<br />
{<br />
AfxMessageBox("ok") ;<br />
}<br />
<br />
srfDB.Close() ;<br />
}<br />
Gives the following runtime error
Data source name not found and no default driver specified
Can you guys tell me where I'm going wrong....
I appreciate your help all the time...
Eranga
|
|
|
|
|
have you defined the DSN in control panel>administrative settings>odbc..?
hope you have not.
gud luck.
---------------------------------------------
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Hey, I've done it correctly
I found a nice book there in the library, and according to that book I think it is easy to use SQLOLEDB.1, simply OLEDB connection.
What you think of it. Actually I'm on the right way now. Open the SQL database and write some values to it.
I appreciate your help all the time...
Eranga
|
|
|
|
|
nice that you got your problem solved.
i have practically not used sql with vc++.
so i cannot suggest you any thing in that area.
gud luck.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Thank you. Let see what can I do for it.....
I appreciate your help all the time...
Eranga
|
|
|
|
|
How do I open a file with spaces (ex. read me.txt). I know this can be done using getline(Input_File, File_Name), I've tried doing that, but with no luck.
Here's my function:
<br />
void TextInfo(void)<br />
{<br />
ifstream Input_File;<br />
string File_Name;<br />
do<br />
{<br />
Input_File.open( GetString( "Enter name of file to read: " ).c_str() );<br />
if ( Input_File )<br />
break;<br />
cout << "Bad file name, try again." << endl;<br />
Input_File.clear();<br />
} while ( true );<br />
<br />
HoldScreen();<br />
}
|
|
|
|
|
It sounds like your issue is really with your GetString() function...
What does it do and how does it work? What does it do with leading and trailing spaces? Or the carriage-return?
Filenames are allowed to have spaces in them.
Are you sure you're in correct directory when attempting to open the file?
What if you put the file in your root folder, and then attempt to open: C:\read me.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
This is my GetString function, I open from root, but it will say: Bad file name, try again. But when I open a file without spaces, its okay.
<br />
string GetString( string Prompt )<br />
{<br />
bool Done = false;<br />
string InputValue;<br />
do<br />
{<br />
cout << Prompt;<br />
cin >> InputValue;<br />
if ( cin )<br />
{<br />
Done = true;<br />
}<br />
else<br />
{<br />
cout << "Bad Input!" << endl;<br />
cin.clear();<br />
cin.ignore(99,'\n');<br />
}<br />
} while ( !Done );<br />
<br />
cin.ignore(99,'\n');<br />
<br />
return InputValue;<br />
}<br />
|
|
|
|
|
VistaXP wrote: cin >> InputValue;
This will stop at the first whitespace character. Use getline() instead.
"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
|
|
|
|
|
I think this is the perfect time for you to learn to use the debugger.
You would have found this problem yourself...
And you would have felt very smart to do so.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|