|
The casting is unneeded here, since:
typedef wchar_t *LPCWSTR;
typedef wchar_t *BSTR;
There is no need for casting, unless bstr is not a pure BSTR.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Correct. It does however make it clear what constructor we are using - but then again we might not care
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
It is a gratuitious cast and has the potential to break the code in the future. NEVER use an explicit cast unless you have to.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
CString str = bstr;
Regards,
Alvaro
There is much pleasure to be gained from useless knowledge. - Bertrand Russell
|
|
|
|
|
Hello,
How to I know if a pidl or a path is a shortcut? I know how to resolve
the path by using IShellLink but I would like to detect if it's a shortcut
before resolve it.
Thanks!
|
|
|
|
|
I press F1 in the editor window. However, it displayed very often "The page cannot be displayed" or "Cannot find server". It makes the help system not usable. Isn't it the help is in my harddisk after installation of VS.NET ?? How can i solve this problem ?
|
|
|
|
|
I use Visual C++ 6.0 and I want to display thai font on dialog box. So I open resource and write thai font on dialog box. When I compile program the dialog box can not show thai font. It display _________ . Do you know how to solve my problem?
Thank you.
|
|
|
|
|
Try set properties of that dialog. In dialog properties page you should set language to 'Neutral' and recompile it.
|
|
|
|
|
Hi,
how can I make my own CEdit context menu with the default options?
Normaly, it has Undo, Cut, Copy, Delete, Paste, Select All.... disabled depending on input. I like to have it + my own menu entry. How do I create the default options. Thanks for help!
|
|
|
|
|
PJ Arends (spelling) has an article under the edit section of this site that shows exactly how this is accomplished...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hockey wrote:
PJ Arends (spelling) has an article under the edit section of this site that shows exactly how this is accomplished...
thx! exactly what i searched
|
|
|
|
|
Hi virtual friends,
my requirement is to display all the exposed properties
and its values of a activex control.
currently am using a function GetIDsofNames shown below
pDispatch->GetIDsOfNames(IID_NULL, names, 1, LOCALE_USER_DEFAULT, &dispid))
where pDispatch is the Dispatch pointer of the activeX control, to access
the properties.The problem am facing currently is that whenever i access a
runtime property it pop-ups a message box telling that this property is
runtime property.
Now how do i avoid this messagebox.Is there anyway that i could know if its
a runtime property and hence bypass GetIDsofNames?
Regards
Pradeep
|
|
|
|
|
I have a question about DLLs and esp MFC extension DLLs. If I make the MFC extension DLL and put in it many exported classes and also have other defines etc, are these defines then ONLY used internally to the DLL? How would you make some "defines" exported or would you not do this? THose classes not exported in the DLL are then assumed to be used only WITHIN the DLL, is that right?
Thanks.
|
|
|
|
|
I forgot to add this. If I several classes in the DLL to export, I need to include the header file for all the classes?
|
|
|
|
|
First of all, I am not sure what you mean by "defines". Is it #define, or is it any variable, method or class ?
In short, I recommend to just use the __declspec(dllexport) / __declspec(dllimport) modifiers.
#ifdef MFC_DLL
#define EXPORTEDSTUFF __declspec(dllexport)
#else
#define EXPORTEDSTUFF __declspec(dllimport)
#endif
You can use EXPORTEDSTUFF in front of a variable, C method, C++ method, class.
Now you can compile your MFC dll with the MFC_DLL symbol.
In the client application, you just include the appropriate headers (because of course the compiler needs to solve the type declarations), without the MFC_DLL symbol.
That's all about it.
How low can you go ? (MS rant)
|
|
|
|
|
Can anyone see why this block, which is reading from the serial port, allows szBuffer to filled with more than 10 bytes? I just dont see how its being allocated more. When I run in the program it will allow an unlimited number of characters to be placed into szBuffer (so long as the '>' isnt sent to it (ASCII 62))
Any help would be appreciated
-Mel
ps. I left the last while statement there to lend clarity to what fContinue is doing but the code above is just error handling of error events and I was tryign to keep the post small so I left it out
-Mel
<br />
if (eEvent & CSerial::EEventRecv)<br />
{<br />
DWORD dwBytesRead = 0;<br />
char szBuffer[10];<br />
do<br />
{<br />
lLastError = serial.Read(szBuffer,sizeof(szBuffer)- 1,&dwBytesRead);<br />
if(lLastError != ERROR_SUCCESS)<br />
return ShowError(serial.GetLastError(), _T("Unable to read from COM-Port"));<br />
<br />
if(dwBytesRead >0)<br />
{<br />
if (szBuffer[dwBytesRead-1] == 62)<br />
fContinue = false;<br />
}<br />
}while (dwBytesRead == sizeof(szBuffer)-1);<br />
}
}while (fContinue);<br />
<br />
---------------------------------------------
Be good! But if you can't be good, at least be good at it and try not to get any on ya!
-mjf
|
|
|
|
|
How come there are two while loops?
Kuphryn
|
|
|
|
|
I left the last while statement there to lend clarity to what fContinue is doing but the code above is just error handling of error events and I was tryign to keep the post small...
-Mel
---------------------------------------------
Be good! But if you can't be good, at least be good at it and try not to get any on ya!
-mjf
|
|
|
|
|
As an experiment, use "10" instead of sizeof().
Kuphryn
|
|
|
|
|
out put was the same... I typed "the quick red fox jumped over the lazy brown dog" and it all went into szBuffer. Maybe its not as obvious as I thought, I just figured I was getting a bit fuzzy in the head as I've been in at it since 9am with just a two hour dinner break.
---------------------------------------------
Be good! But if you can't be good, at least be good at it and try not to get any on ya!
-mjf
|
|
|
|
|
Something is definitely looping and reading the data. Otherwise, maybe the COM part of the implementation dynamically expands szBuffer to accommodate the data.
Kuphryn
|
|
|
|
|
This code makes me shiver. Should you be checking each character of szBuffer for >? Does Read ever set dwBytesRead to the required buffer size that's available in the queue? Try adding ASSERT() after read to be sure.
do
{
if (eEvent & CSerial::EEventRecv)
{
DWORD dwBytesRead = 0;
char szBuffer[10];
do
{
lLastError = serial.Read(szBuffer, sizeof(szBuffer)-1, &dwBytesRead);
ASSERT(dwBytesRead < 10);
if(lLastError != ERROR_SUCCESS)
return ShowError(serial.GetLastError(), _T("Unable to read from COM-Port"));
if(dwBytesRead > 0)
{
if (szBuffer[dwBytesRead-1] == '>')
fContinue = false;
}
} while (dwBytesRead == sizeof(szBuffer)-1);
}
} while (fContinue);
Todd Smith
|
|
|
|
|
nope.. the ASSERT didn't catch it either - ggrrrr! AT this stage I'm just using 10 as an arbitrary value that doesn't take a long time for me type out from the sending machine. In practice, I will have no idea of the sizeof the incoming data persay. Actually, I will be testing the first few characters and then know the size (there are several different formatted messages coming in of different but known sizes and I want to make sure it breaks not only on the '>' but on a full szBuffer (for any case where the '>' didn't get sent)
---------------------------------------------
Be good! But if you can't be good, at least be good at it and try not to get any on ya!
-mjf
|
|
|
|
|
Oh. How are you determining that szBuffer has more than 10 bytes in it? Try this
change
DWORD dwReadBytes;
char szBuffer[10];
do
{
Read();
}
to
do
{
DWORD dwReadBytes;
char szBuffer[10] = {0};
Read();
}
Todd Smith
|
|
|
|
|
well.. your question regarding how i'm checking szBuffer got me thinking and I've determined that dwBytesRead is always 1 so I'm gonna have to take a good look at that. As to how I am actually checking- good question- had a line in there that was concat-ing szBuffer[dwBytesRead-1]to another string that was being displayed else where in code. You can see the problem with that knowing dwBytesRead is always one - so it wasn't szBuffer that was gettign the extra memory after all. Writing the code at you have it here required the do/while condition to be redone as well... thinking it might be a good idea to approach this with a more alert mind so I'm packing in the VC for the night - but thanks for the input and if you happen to think of anything else send it over - it cant hurt.
Thanks
-Mel
---------------------------------------------
Be good! But if you can't be good, at least be good at it and try not to get any on ya!
-mjf
|
|
|
|