|
I want to do something like this, however wsprintf throws a compiler error. Is there another format function that I should use instead to do this?
BSTR path = NULL;
int num = 1;
path = SysAllocString(L"//errors/error[@id='%i']");
wsprintf(path, num);
- Nick Parker My Blog | My Articles
|
|
|
|
|
int wsprintf( LPTSTR lpOut,
LPCTSTR lpFmt,
...
);
Nick Parker wrote:
BSTR path = NULL;
BSTR != LPCTSTR (wrong type)
int num = 1;
wsprintf(_T("//errors/error[@id='%i']");, num);
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
palbano wrote:
BSTR != LPCTSTR (wrong type)
I realize that. I need to use a BSTR for the rest of what I am working on. Any other suggestions?
- Nick Parker My Blog | My Articles
|
|
|
|
|
Do all formatting using LPTSTRs, then use the T2BSTR conversion macro to get your BSTR type.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Ummm, there is a problem ...
Aside from the BSTR != wchar_t*, what do you expect wsprintf to do ?
I mean it's used to take a format string (path) and create a result - you haven't specified a result string. Are you expecting it to modify path in place (it won't even with correct types) ?
From MSDN :
typedef OLECHAR * BSTR;
These strings are zero-terminated, and in most cases they can be treated just like OLECHAR* strings. However, you can query a BSTR for its length rather than scan it, so it can contain embedded null characters. The length is stored as a 32-bit integer at the memory location preceding the data in the string.
The 32-bit is placed before the BSTR value so you don't need to worry about it, just cast the BSTR to a wchar_t*.
e.g. (without error checking)
wchar_t res[500];
BSTR path = NULL;
int num = 1;
path = SysAllocString(L"//errors/error[@id='%i']");
wsprintf(res, (wchar_t*)path, num);
...cmk
Save the whales - collect the whole set
|
|
|
|
|
You're misusing the BSTR . wsprintf() prints into a TCHAR array, but a BSTR is not an array.
BSTR path = NULL;
CString s;
int num = 1;
s.Format ( _T("//errors/error[@id='%i']"), num );
path = s.AllocSysString(); If you can't/don't want to use CString , alloc a TCHAR buffer instead and make sure it's big enough, then use the T2BSTR conversion macro to convert it to a BSTR .
Check out this article[^] if you need more details on converting between string types.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
I am working on a SDI project that calls a function SetModifiedFlag(), in my document file, if any value in my document file changes. That function is not part of my projects document file but seems to be a call to a function that exists in CDocument...(CDocument::SetModifiedFlag()). Can someone tell me what this function is? The function contains a boolean value, bModified. How can I access this value for reading, and resettng. Is this a typical way to test to see if any of your doc values have changed, etc. I am just not familiar with this and someone else developed this piece of code.
Thank You.
Jerry
|
|
|
|
|
jerry1211a wrote:
How can I access this value for reading, and resettng.
CDocument::IsModified()
CDocument::SetModifiedFlag()
jerry1211a wrote:
Is this a typical
Yes
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
In a straighforward MFC implementation, you can call SetModified() and the variable you mention is set to a 'true' value indicating data has changed. The framework would use that, or you would, when the user 'closes' your application and you would ordinarily pop up a warning that the document has changed, and ask user if he wants to save it before exiting your program. In an SDI instance, I think you would do the same thing on File|New or File|Open if the data had changed, so user does not lose data changes prior to loading a new document. When the document is saved, then the modified flag is reset to a 'false' value.
|
|
|
|
|
Hey Guys
Last Week i sat up a new system. Unfortunatly I've lost my the serial. But i've still installed it on the old PC. Any idea how i can get it from there ?
Please Help
|
|
|
|
|
Help->About
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi All,
Now that MS VCToolkit (compiler and libraries from VC++ 7.x) is available as a free download from Microsoft, a natural question would be - is it possible at all to use it with DevStudio 6? It would be nice to be able to use the build environment... How about debug info compatibility and command line options compatibility? Did anybody try?
thanks!
|
|
|
|
|
yurig wrote:
is it possible at all to use it with DevStudio 6?
Yes. Just set the paths to the new compiler before the paths to the VC6 compiler in the Executables section of the Directories tab in the Options.
yurig wrote:
How about debug info compatibility and command line options compatibility?
The command line is compatible, so no problems there. Unfortunately, the VC6 debugger can't understand the VC7 debugging information, so you won't be able to debug any apps generated with it under VC6 - you'll need to use the new debugging tools.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks Ryan! I was able to compile my project, and this is basically all I need at this point - just make sure it will compile.
Yuri
|
|
|
|
|
MFC.
I do a skinning for a winapp written in mfc.
I have to change totally the bkcolor
apearence for all ui in a custom color.
I superclassed all controls and works fine except:
Tab controls 3d borders shadwows,
Toolbar separators,
Static frames and 3D edit controls shadows which are still
system color.
ANy Ideea.
P.S
Just Dont tell me I have to handle them on WM_PAINT
and redraw on top another rect.
|
|
|
|
|
Handle WM_NCPAINT
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hello,
I downloaded JBSocketServer1.zip and tried to compile it, however I got the following errors coming from mswsock.h and winsock2.h
Would you know why?
Thanks in advance.
Eugene
C:\MSDev\VC98\INCLUDE\mswsock.h(69) : error C2065: 'SOCKET' : undeclared identifier
C:\MSDev\VC98\INCLUDE\mswsock.h(69) : error C2146: syntax error : missing ')' before identifier 's'
C:\MSDev\VC98\INCLUDE\mswsock.h(69) : warning C4229: anachronism used : modifiers on data are ignored
C:\MSDev\VC98\INCLUDE\mswsock.h(73) : error C2059: syntax error : ')'
C:\MSDev\VC98\INCLUDE\mswsock.h(89) : error C2146: syntax error : missing ')' before identifier 'hSocket'
C:\MSDev\VC98\INCLUDE\mswsock.h(89) : warning C4229: anachronism used : modifiers on data are ignored
C:\MSDev\VC98\INCLUDE\mswsock.h(96) : error C2059: syntax error : ')'
C:\MSDev\VC98\INCLUDE\mswsock.h(101) : error C2146: syntax error : missing ')' before identifier 'sListenSocket'
C:\MSDev\VC98\INCLUDE\mswsock.h(101) : warning C4229: anachronism used : modifiers on data are ignored
C:\MSDev\VC98\INCLUDE\mswsock.h(109) : error C2059: syntax error : ')'
C:\MSDev\VC98\INCLUDE\mswsock.h(131) : error C2146: syntax error : missing ')' before identifier 'hSocket'
C:\MSDev\VC98\INCLUDE\mswsock.h(131) : error C2165: 'left-side modifier' : cannot modify pointers to data
C:\MSDev\VC98\INCLUDE\mswsock.h(131) : error C2071: 'LPFN_TRANSMITFILE' : illegal storage class
C:\MSDev\VC98\INCLUDE\mswsock.h(138) : error C2059: syntax error : ')'
C:\MSDev\VC98\INCLUDE\mswsock.h(146) : error C2146: syntax error : missing ')' before identifier 'sListenSocket'
C:\MSDev\VC98\INCLUDE\mswsock.h(146) : error C2165: 'left-side modifier' : cannot modify pointers to data
C:\MSDev\VC98\INCLUDE\mswsock.h(146) : error C2071: 'LPFN_ACCEPTEX' : illegal storage class
C:\MSDev\VC98\INCLUDE\mswsock.h(154) : error C2059: syntax error : ')'
C:\MSDev\VC98\INCLUDE\winsock2.h(95) : error C2378: 'SOCKET' : redefinition; symbol cannot be overloaded with a typedef
C:\MSDev\VC98\INCLUDE\winsock2.h(112) : error C2146: syntax error : missing ';' before identifier 'fd_array'
C:\MSDev\VC98\INCLUDE\winsock2.h(112) : error C2501: 'SOCKET' : missing storage-class or type specifiers
C:\MSDev\VC98\INCLUDE\winsock2.h(112) : error C2501: 'fd_array' : missing storage-class or type specifiers
C:\MSDev\VC98\INCLUDE\winsock2.h(115) : error C2059: syntax error : ')'
|
|
|
|
|
Try including winsock2 before mswsock
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
No including winsock2 before mswsock did not help...
Eugene
|
|
|
|
|
Hi
I created a Dialog box class within a MFC share Regular DLL. I use the Resource Wizard to create the Dialog and Class Wizard to define the derived class. I'm exporting the class with the _declspec(dllexport) storage class type specifier.
When I try to create an object of that derived Dialog box class in the client application... the object pointer is NULL. I get no errors. The DLL is loaded at load-time, the DLL Library is included in the linker. Do you know what step(s) I might be leaving out ??
One person suggested adding the AFX_MANAGE_STATE macro... but, none of the CDialog base functions are being re-defined. So, I'm exporting the Dialog Box functions indirectly... adding the AFX_MANAGE_STATE macro at the begain of the exported functions is not feasible. Besides, I create a Regular MFC DLL function that used a device context pointer and CBrush class... and I did not include the AFX_MANAGE_STATE macro.
Thx,
King
|
|
|
|
|
try this
hRes= LoadLibrary("dllwheredlgis.dll");
if(hRes)
AfxSetResourceHandle(hRes);
|
|
|
|
|
Hi
I try adding that code to the client app and hRes is a NULL HINSTANCE pointer.
also, I'm not sure where the problem lies, in the DLL or the Client ??
|
|
|
|
|
Hi!
Somebody that have programmed an UDP-protocol in C or C++? I need to do so but I am not sure how to. I have been reading a lot about how UDP works and how it looks like, but still to make C-code is little bit complicate..
Anyone that can help me? Is there any open-source that I can look at? I can´t use win-sockets because I use a laborationsboard that don´t have any common OS. So I need to write it in C?
|
|
|
|
|
see at:
http://enet.cubik.org/Features.html
|
|
|
|
|
I need to do some sorting in a C-Scripting environment.
I have an array of string; e.g. "Fread2", "RobertThree", so just need a routine that will determine if string1 > string2.
I know I could write my own, but I bet it would be slow and I am sure that it has been done many times before.
Sweep.
PS The scripting environment has no Sort routines!
|
|
|
|