|
Great brain.. Constantin.
Thanks a lot.
|
|
|
|
|
Hi,
I think just with a casting could be enough ?
CString Mystring;
myfunc((LPCSTR) Mystring);
If not, try this:
CString MyString;
myfunc(MyString.GetBuffer(0));
MyString.ReleaseBuffer();
HTH
Braulio
|
|
|
|
|
try using the Cstring::operator LPCSTR();
i.e.
yourfunc(str.operator LPCSTR());
yourfunc(LPCSTR str)
{
...
...
}
|
|
|
|
|
It would be nice if your explanation could describe whether this error was a syntax or semantic error. From your description, most people with a good english understanding would have thought that "does not work", implies a syntax compiler error, however, from constantin's solution I can see you actually meant "does not work" in a semantic sense where the function does not operate how you expect it to. It would be great if people could do this in their questions to stop nutters like me barking up the wrong tree, racking my brains for a solution that doesn't exist .
Alan.
|
|
|
|
|
Dear Alan,
Will definately take care from now onwards,
Rohit
|
|
|
|
|
hello all
When user click on a link, then how to get information of that link (eg : IP address) and how to block that IP (user can't go to that site).
sorry all, i'm not good in English.
|
|
|
|
|
Are you sure you want the C++ forum for this?
Sounds more like a web question.
Jason Henderson "I can picture in my mind a world without war, a world without hate. And I can picture us attacking that world, because they'd never expect it."
- Jack Handey
|
|
|
|
|
Can some one help me write this in c++;
I am using csharp but i want this in native code;
public static bool Contains( ref string[][] lookupTable, string value, bool ignoreCase )
{
int i = value.Length;
if ( i <= 0 || i - 1 >= (int)lookupTable.Length )
{
return false;
}
string[] strs = lookupTable[i - 1];
if ( strs == null )
{
return false;
}
else
{
return Contains( ref strs, value, ignoreCase );
}
}
Thank You
Bo Hunter
|
|
|
|
|
This function does not compile in C# (bad parameter in recursive call), and as far as I can see it doesn't do anything useful (it always return false).
If you fix that, I might be able to help you.
|
|
|
|
|
Well this probaly want compile by it self but I just need some help writing this in C++.
if you would look closely at this you would see that this is not a recursive call.
The other Contians method takes a single deminsion array of strings this one takes two deminsion array of strings.
I just thought if I could get help with this one I could do the rest myself.
I dont like to see people to throw up a bunch of code and ask someone to translate it for them. I would like to learn to do it myself.
Thank You
Bo Hunter
|
|
|
|
|
Assuming you have a function called Contains that takes an array of strings, you could write it like this: (note: I havent compiled or tested it)
typedef std::vector<std::string> string_row;
typedef std::vector<string_row> string_matrix;
bool Contains (const string_row& lookupTable, const std::string& value, bool ignoreCase);
bool Contains (const string_matrix& lookupTable, const std::string& value, bool ignoreCase)
{
int i = value.length();
if ( i <= 0 || i-1 >= lookupTable.size() )
return false;
const string_row& strs = lookupTable[i-1];
if (strs.size() == 0)
return false;
else
return Contains(strs, value, ignoreCase);
}
“Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002
|
|
|
|
|
This looks like a homework assignment for a CS course.
|
|
|
|
|
How can I get the process's ID when I have got the process's HANDLE?
Thanks
|
|
|
|
|
in Windows XP sp1 and Windows server 2003 you can call GetProcessId.
But for the other, I dont think there is a documented way of doing that. You might be able to doing with some kernel call, but Im not sure. If there is a way, search Google under microsoft.public.win32.programmer.kernel
Magnus
|
|
|
|
|
|
|
ei how do u make an installation of an application.. I have coded a DLL using ATL COM Appwizard with MFC support..... Now, my dll is used in another VB Application.. now i want to make the VB application installable to other computers.. so how do i know which dlls will be added to my installation file aside from my own dll?... and since its using MFC support what MFC dlls will i include?
|
|
|
|
|
hi! i'm making a dll from ATL COM appwizard...
and then one of the properties there is of type BSTR....
now the BSTR type is stored internally by class with LPWSTR member...
now when i'm setting that BSTR i just equate it... i.e.
STDMETHODIMP CBluetooth::put_ServiceName(BSTR newVal)<br />
{<br />
m_sLPWSTRString = newVal;<br />
<br />
return S_OK;<br />
}<br />
assuming that newVal = "The String"...
when this function exits it seems m_sLPWString is now pointing to a garbage string.. (not the string "The String"..as seen in a debugger).... the address is the same but the contents of the address seems to be altered so whats the problem here...?
I can't use the CString functions since i'm avoiding the use of MFC....
actually when i used the COM from a program in Visual Basic it seems to work fine.. but when i used it from VB .NET thats were the problem comes in....
|
|
|
|
|
It is because the BSTR that is being passed to you is not owned by you, that is the memory for it was not allocated by you. That's what I mean by you don't own it.
The caller is passing you a BSTR and then freeing it which is why your LPWSTR is now pointing at garbage.
To fix this, you need to allocate some memory that is pointed at by your LPWSTR then copy the contents of the BSTR to your new memory.
Since you appear to be using ATL, why not just use a CComBSTR instead of the LPWSTR? The overhead is minimal and it will take care of the memory allocation and freeing.
Here are both examples:
// don't forget to free this mem in FinalRelease or something
DWORD ccb = ::SysStringByteLen(newVal);
m_sLPWSTRString = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, ccb);
CopyMemory(m_sLPWSTRString, newVal, ccb);
OR
// in you .h file
CComBSTR m_bsServiceName;
// in your .cpp file
STDMETHODIMP CBluetooth::put_ServiceName(BSTR newVal)
{
// CComBSTR takes care of both allocation and
// memory copy and will also free itself on destruction
m_bsServiceName = newVal;
return S_OK;
}
|
|
|
|
|
Hi,
BSTR's are a real nightmare, I think what could work is:
<br />
m_sLPWSTRString = newVal.Copy();<br />
( or something ilke that), just forget about handling BSTR, just use "_bstr_t" or "CComBSTR", but take care with that as well..., personally I preffer _bstr_t since it allows you to convert from char * to BSTR, a good working code couldbe
<br />
_bstr_t m_sLPWSTRString;<br />
m_sLPWSTRString = newVal;
Good luck
Braulio
|
|
|
|
|
Hello
I have one dilaog bar in my CFormView.
I have embbeded some buttons on my dilog bar.
I have to change the views based on the button selection
from the user.
For example if the user presses button1 from the dialog bar..
I want to diaply another formview with different dialog bar,
for button1...
CFormView1+CDialogBar1
for button 2 ..
CFormView2 + CDialogBar2 ..
for button3...
CFormView3+CDialogBar3
etc...
how to do this?
any idea or code snippets please!!!
"They can because they think they can" - Voltaire
|
|
|
|
|
HI THERE
Where can I find a Program, which include source code, or any information for converting TTF to DXF?
Thanks
|
|
|
|
|
There is information on this site (and elsewhere) about the DXF format.
You can use ::GetGlyphOutline to retrieve the line segments of a particular character.
Putting the two bits of information and some hard work, you'll have your answer.
You never know, there might just be an article in it somewhere!
Iain.
|
|
|
|
|
Hi,
does anyone know the proper way to pass data from one independent class to a view within SDI?
thanks...
|
|
|
|
|
Hi,
In my SDI application I have two Formviews separated by a splitter window. I want users to use the MainMenu (File->Save As etc) to display data etc which depends on both the Views.
For the two views do I need to write the same menu handlers in both the view classes, or, there is better place to put the menu handlers? I can't put it in the document class, as I'll show some popup dialog etc, which are not supported by document class.
Please advise
|
|
|
|