|
Thnaks for the info --- my refernce books are a few years old. This is Microsoft's way of keeping the revenue stream coming in, I guess )
John P.
|
|
|
|
|
It's not happening in C++/Microsoft technologies, but also happens with popular languages like and Java and all.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
(1) You can use WM_CTLCOLOR or WM_PAINT
(2) Hope I understood your question See CWnd::DoModal()
(3)for set position from a window see SetWindowPos(..) or MoveWindow(...)
I hope its helful for you
|
|
|
|
|
I need to send a CString into a parameter that is of LPVOID type. I've tried:
CString stuff = _T("...");
LPVOID info = stuff.GetBuffer();
foo ( info );
stuff.ReleaseBuffer();
but the data is lost. How should I go about doing this?
|
|
|
|
|
Try:
foo((LPVOID) ((LPCTSTR) stuff));
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I tried that too, same thing. What I am trying to do is send form data to the wininet SendRequest(LPCTSTR, DWORD, LPVOID, DWORD) function. the LPVOID parameter is the POST data that you send with a HTTP Post header.
|
|
|
|
|
epicyeti wrote: ...same thing.
How are you confirming this?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
what does work is something like this:
CString header = _T("Content-Type: application/x-www-form-urlencoded");
CString m_data = _T("target=wininet");
char data[] = "target=wininet";
LPVOID postdata=data;
pFile->SendRequest(header, header.GetLength(), stuff, mdata.GetLength)
basically i'm sending to the URL www.codeproject.com the data to the search form on the main page. The code above will return an html file with the search results.
The calls to SendRequest() with the double cast and the call to GetBuffer() both return html files that have no search results. I'm inferring from this that no post data got sent.
|
|
|
|
|
epicyeti wrote: what does work is something like this:
So what's the problem then (if you have a working solution)?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The problem is that I can't set the char data[] in the last example. I have a CString variable that has the POST data in it, however I can't get the data in CString because it returns a const char*, and I can't set that to the char data[]. I also have no idea what the post data will be, and thus can't hard code it as I did in the working example.
That was me hard coding my test. In the release it can't be hard coded.
Is there a way I could effectively do this:
CString m_data = _T("...");
char data[];
data = m_data.GetBuffer();
|
|
|
|
|
epicyeti wrote: Is there a way I could effectively do this:
CString m_data = _T("...");
char data[];
data = m_data.GetBuffer();
If data actually had a size associated with it:
char data[100];
strcpy(data, m_data); Or:
const char *data = m_data;
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I finally got it to work.
So the CString::GetBuffer() returns a const wchar_t* not a const char*, I was mistaken. Howerver I could still use the method you suggested:
const wchar_t* data= m_data.GetBuffer();
If I send that into the SendRequest function the wide char data is lost or not converted or something. So I had to convert it to a char*:
const wchar_t* data= m_data.GetBuffer();
m_data.ReleaseBuffer();
char* Cdata;
Cdata = new char[m_data.GetLength()+1];
size_t num=m_data.GetLength();
wcstombs_s(&num, Cdata, num+1, data, num);
LPVOID postdata=Cdata;
This seems sloppy to me, but it gives the correct output when I use postdata in the SendRequest function. Thanks for all your help!
-- modified at 15:42 Tuesday 1st August, 2006
|
|
|
|
|
epicyeti wrote: Is there a way I could effectively do this:
CString m_data = _T("...");
char data[];
data = m_data.GetBuffer();
Did you read the response from 2 hours ago?
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
|
|
|
|
|
Yeah, I'm sorry I didn't respond.
the strcpy doesn't take a CString varriable. I could have used GetBuffer on it, but I would probably would have had to conver the returned wchar_t to a char like I ended up doing. My real issue evidently was with sending the SendRequest function a wchar_t* instead of a char*.
Thanks for your input, and again I am sorry I didn't respond.
|
|
|
|
|
epicyeti wrote: the strcpy doesn't take a CString varriable
It does because CString has an explicit LPCTSTR operator to do the casting. The problem is actually that you have UNICODE enabled (apparently), in which case you need to convert it from wchar_t to char* first. Alternatively, you could pass the data in UNICODE format, but you would need to pass the size as double the length of the string and specify that you are using UTF-16 as your text format in your HTTP headers.
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
|
|
|
|
|
Your signature is true to life. I'll be sure to know if I am using UNICODE from now on, and I'll be more careful with my headers. Thanks again for your input.
|
|
|
|
|
epicyeti wrote: SendRequest(LPCTSTR, DWORD, LPVOID, DWORD) function. the LPVOID parameter is the POST data that you send with a HTTP Post header.
You will probably need to do this:
CString strPostData = _T("Some POST Data");<br />
char buffer[100] = {0};<br />
strcpy(buffer, strPostData);<br />
pHttpFile->SendRequest("POST", dwSomeDword, (LPVOID)buffer, strlen(buffer) + 1);
LPVOID is defined as void* . Using the LPCTSTR operator for CString will return you a const char* (when UNICODE is not defined). The const keyword is the main thing you should be worried about there. The fact that SendRequest does not ask for a const void* indicates that it may try to write to that buffer, which would cause problems if you tried to pass in the CString object itself.
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
|
|
|
|
|
Are you trying to pass this to another function in the same thread or to another thread?
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
|
|
|
|
|
|
Hey guys,
I was wondering if we use iostream.h in visual studio 2005.
I tried including iostream.h but it says file cannot be found.
It's strange how iostream.h is not used in Visual Studio 2005
Are we suppose to have iostream.h in visual studio 2005
or do we use iostream.... using namespace std;
thanks
-- modified at 11:28 Tuesday 1st August, 2006
|
|
|
|
|
iostream.h is the old implementation (from before the standard was formalized). It was left in the old versions of the IDE for backwards compatibility only. You should be using iostream (the same goes for vector, list, map, string, etc.)
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
|
|
|
|
|
|
|
Hi,
I've written an own FindDlg. It's derived from CDialog and just provides an own SelectionList. It crashes anywhere between CFindDlg::EndDialog(IDOK) and the calling Method. - Ain't nice but happens.
But the prog crashes only while executing release-build. Running debug-release don't crash. (Memory-Exeption during read...)
So how can I fix my prog, that it runs also within release-build. Or how can I find my bug? - I don't have any Idea?
Thanks && Greets,
Horst
Calling Method ==>
CFindDlg dlgFind;<br />
<br />
dlgFind.SetTreeRef(m_pobjCurrentTree);<br />
dlgFind.DoModal();<br />
MessageBox("You won't see me....");<br />
<br />
if ( ! dlgFind.GetFoundItem().IsEmpty() ) { <br />
LVFINDINFO SearchPattern;<br />
<br />
SelectTreeItem(dlgFind.GetFoundItem());<br />
<br />
SearchPattern.flags = LVFI_STRING;<br />
SearchPattern.psz = dlgFind.GetFoundItem();<br />
<br />
m_ctrlElement.SetItemState(m_ctrlElement.FindItem(&SearchPattern), LVIS_SELECTED, LVIS_SELECTED);<br />
m_ctrlElement.SetFocus();<br />
}<br /> <== Calling Method
OnOK ==>
void CFindDlg::OnOK() {<br />
int iSelectedSOC;<br />
POSITION pListSelection = m_ctrlFoundItem.GetFirstSelectedItemPosition();<br />
<br />
iSelectedSOC = pListSelection == NULL ? -1 : m_ctrlFoundItem.GetNextSelectedItem(pListSelection);<br />
m_sFoundItem = iSelectedSOC == -1 ? "" : m_ctrlFoundItem.GetItemText(iSelectedSOC, 0);<br />
<br />
MessageBox("This will be the last you will see before abort...");<br />
EndDialog(IDOK);<br />
}<br /> <== OnOK
|
|
|
|
|