|
Hi All,
In my project I want to get the string value set in text box. So I write
following code as
CEdit *pOpenEdit = (CEdit *) GetDlgItem(IDC_FOLDER_PATH);
if( NULL != pOpenEdit->GetSafeHwnd())
{
pOpenEdit->GetWindowText(buff,256);
}
In the above code I did not get handle of edit box. What is wrong in this code.
Please send me solution if anybody have.
Thanks
Om
|
|
|
|
|
What happens if you run this code?
CWnd *pwnd=GetDlgItem(IDC_FOLDER_PATH);
pwnd->GetWindowText(buff,256);
Or if you declare a variable for editbox
m_Edit.GetWindowText(buff,256);
or if you use of WM_GETTEXT message ?
|
|
|
|
|
When I run above code I get null handle. so the code on next line is not execute.
I use same code in other function of same class for Setting string value to editbox,the code is executed in that function. So why i did not get the handle od edit box in above code.
Plz reply me.
OM
|
|
|
|
|
Are you sure id of editbox is correct and what happens if you declare a variable for it did you can values of edit control.
|
|
|
|
|
Hi Hamid,
ID of Edit box is correct, because by using same ID i get the pointer for setting value to the window.
CEdit *pOpenEdit = (CEdit *) GetDlgItem(IDC_FOLDER_PATH);
if( NULL != pOpenEdit->GetSafeHwnd() )
{
if( strOpenPath != "" )
pOpenEdit->SetWindowText(strOpenPath);
}
This code is execute well but in following code i did not get the
handle.
CEdit *pOpenEdit = (CEdit *)GetDlgItem(IDC_FOLDER_PATH);
if( NULL != pOpenEdit->GetSafeHwnd() )
{
char buff[500];
pOpenEdit->GetWindowText(buff,256);
strOpenLocation = buff;
}
In this code I did not get handle so it is not entered in if block. Let me know what is wrong in this code.
Thanks in Advance
Om
|
|
|
|
|
I have a question why you didnt declare a variable for edit control instead handle to it?
|
|
|
|
|
/*
I'm not sure what your having trouble with. However, I am confused what your using the handle for? Do you realize that your trying to use a pointer before you've even checked that it is valid?
*/
void CTest712Dlg::ShowEditText()
{
if (::IsWindow(m_hWnd)) {
CEdit* pOpenEdit=(CEdit*)GetDlgItem(IDC_FOLDER_PATH);
if (pOpenEdit) {
CString sText("");
pOpenEdit->GetWindowText(sText);
TRACE("%s\n",sText);
}
}
}
void CTest712Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
ShowEditText();
}
|
|
|
|
|
Use ClassWizard (Ctrl+W) to associate a CEdit variable with the IDC_FOLDER_PATH control. Then use its GetWindowText() method.
"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
|
|
|
|
|
how to change the text color of button when the button is created at runtime using controlbar?
dghdghdghdgh
|
|
|
|
|
Will this[^] helpful ?
Regards,
Paresh.
|
|
|
|
|
I want to get data about
-Processor kind
-OS Name and Version
-Total Physical Memory
-VGA Name
-Main board Name
what the function can support this issue
|
|
|
|
|
|
Hi ALL,
I want to create new dir on specified path of remote server. How to use CreateDir() function of CFtpConnection class.
Thanks in Advance
atul
|
|
|
|
|
Atul23 wrote: How to use CreateDir() function of CFtpConnection class.
CFtpConnection::CreateDirectory just takes a path string.
What exactly are you having trouble with?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
how i can check whether the argument lpStr in FillStr function is initialized or not?
class myClass
{
public :
myClass()
{
}
~myClass()
{
}
LPSTR lpStr ;
};
int FillStr( <code>LPSTR lpStr</code> )
{
if( lpStr )
{
strcpy( lpStr , "myData" ) ;
return 1 ;
}
return 0 ;
}
void main()
{
myClass obj ;
if( FillStr( obj.lpStr ) )
{
printf( "%s" , obj.lpStr ) ;
}
}
Thanks & Regards
|
|
|
|
|
strcpy( lpStr , "myData" ) ;
This is a disaster waiting to happen based upon the way lpStr was passed in to your function. There is no indication to your method how big the buffer that lpstr points to so for all it knows, it might overwrite the buffer with the strcpy().
You never allocate memory for the buffer in your code. You should put that member pointer to the string in your initialization list for the class and set it to null or zero to ensure it has a known state before the class constructor is run.
If you know the buffer size, you can (reliably) check for the null terminator without worrying about overwriting the buffer. If the null terminator is at index zero, then it's empty. However, that does not necessarily mean that it wasn't initialized since "\0" is a valid string to initialize it with.
You might want to consider using an already existing string class written by someone who has thought all the possibilities out already.
|
|
|
|
|
hi my code is:
char* test;<br />
<br />
test = (char *)malloc(strlen("Clerk")*sizeof(char));<br />
strcpy(test,"Clerk");<br />
if(test == "Clerk")<br />
printf("ok");<br />
if(strcmp(test,"Clerk"))<br />
printf("ok2");<br />
system("pause");
how ever as you can see both if statement doesnt work f this is so? how am i supposs to compare the strings?
please help i am rather urgent thx
|
|
|
|
|
neodeaths wrote: if(strcmp(test,"Clerk"))
strcmp return 0 if both strings are equal,try
if(strcmp(test,"Clerk")==0)
Thanks & Regards
|
|
|
|
|
neodeaths wrote: test = (char *)malloc(strlen("Clerk")*sizeof(char));
strcpy(test,"Clerk");
The first line does not allocate enough space to contain the trailing \0, so that your next statement overruns the buffer. <understatement>This is not good.</understatement>
neodeaths wrote: if(test == "Clerk")
This is not the right way to compared strings that are accessed by a char * . Use strncmp or one of its cousins. The == only works on things like CString, which contain a comparison operator within their definition.
neodeaths wrote: if(strcmp(test,"Clerk"))
Read the documentation for the return type of the strcmp functions and that will tell you what is wrong with this statement.
Judy
|
|
|
|
|
Hi all,
Using code given on this link "http://www.codeproject.com/file/self_extractor.asp" i am preparing a exe file. But when i run this exe on another computer which is not having vc++ 6.0 installed in it. It gives an error of MFC42D.dll missing. What should i change its setting so that application should run properly....
Thanks in advance
|
|
|
|
|
The debug version needs not only MFC42D.dll, but also other debug versions of dlls, like MSVCRTD.DLL.
Try to build a release version instead, good luck.
|
|
|
|
|
|
neha.agarwal27 wrote: i am preparing a exe file. But when i run this exe on another computer which is not having vc++ 6.0 installed in it. It gives an error of MFC42D.dll missing. What should i change its setting so that application should run properly....
please build that executable in release mode
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Please refer here[^] for more information.
Regards,
Paresh.
|
|
|
|
|
Hi,
I have found very good information from this blog.
http://blogs.msdn.com/vcblog/archive/2007/10/12/how-to-redistribute-the-visual-c-libraries-with-your-application.aspx?CommentPosted=true#commentmessage[^]
But I have one quetion and also problem which is related to this blog topic redistributing the library.
I have created Visual Studio’s setup project in which I have added Activex (.ocx) control in it and also I have included appropriate .MSM file and its accompanying policy .MSM to distribute the library.
My package is created successfully(in VS 2005).
And I try to install it on the different machine(without VS 2005) but ask for the installing .Net Framework 2.0 but I did not install it and try to install other setup file(which also created with our main setup file) and it perfactly installed.
And now What I have to do to use that Activex (.ocx) control directly in other application.
May I directly register it using REGSVR32.exe or any other setting I have to do?
Please suggest me if you can. It will be very helpful to me.
Thanks.
Ashish Bhatt
|
|
|
|