|
Hi!
I've created an XML file in VS.NET.
I've created a Schema with "Create Shema" on the XML-menu.
My XML-file then look like this:
?xml version="1.0" encoding="utf-8"?<br />
ROOT xmlns="http://tempuri.org/XMLFile1.xsd"<br />
ELEM<br />
/ELEM<br />
/ROOT
(Taken away the > and < signs)
The Schema-file (XMLFile1.xsd) now exists in the current dir.
How do I now validate my XML against that Schema?
When I press: "Validate XML Data" on the on the XML-menu I got the following error:
Visual Studio could not locate a schema for this document. Validation can only ensure this is a well formed XML document and cannot validate the data against a schema.
_____________________________
...and justice for all
APe
|
|
|
|
|
I have a string that's about 450 bytes that I want to assign to a CString, but the string is getting cut off.
CString rawData(i_pszRawData);
int buffLen = rawData.GetLength ();
buffLen is always 230 and not 450 bytes!
If these an embedded zero or null character or binary zero in the string, is there a way around it so that the full 450 is assigned to the CString?
Thanks.
-C
|
|
|
|
|
Wheatbread wrote:
If these an embedded zero or null character or binary zero in the string, is there a way around it so that the full 450 is assigned to the CString?
CStrings are designed to hold zero-terminated strings. if you need to hold arrays with zeros in them, you'll need to use something else, like an array of BYTEs.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
Hi, I have encountered a problem with a very basic operation. does anybody have any idea about this?
Please see sample code below:
//////////////////////////////////////////
double a, b;
a = 99.99
b = 99.99
if (a <= b){
::MessageBox(NULL, L"TRUE", L"", MB_OK);
}
else{
::MessageBox(NULL, L"FALSE", L"", MB_OK);
}
//////////////////////////////////////////
somehow, it always display FALSE. Anybody knows how to handle this situation?
SDE
|
|
|
|
|
Doubles are NOT precise numbers. They are approximate representations. Whenever you need to compare doubles (or check if zero), you need to do approximate math, using an acceptable number of precision digits to your app. An example is below:
BOOL IsDoubleZero(double dVal)
{
if (dVal < 0.000001 && dVal > -0.000001)
return TRUE;
return FALSE;
}
BOOL AreDoublesEqual(double dVal1, double dVal2)
{
doubld dDiff = dVal1 - dVal2;
if (dDiff < 0.000001 && dDiff > -0.000001)
return TRUE;
return FALSE;
}
onwards and upwards...
|
|
|
|
|
Wow - never knew that. What about floats? Same thing? Hope so else I just screwed up an interview question!
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Angel1058 wrote:
What about floats? Same thing?
Yes.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I find that absolutely astonishing - you can't compare two doubles or floats for equality? So all these financial and scientific calculations using massive numbers with loads of decimal places aren't accurate - they are approximations?!?
It's not that I am doubting anything written here but I still find that amazing. 99.99 isn't guaranteed to equal 99.99.
Are there any precise types then?
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Angel1058 wrote:
So all these financial and scientific calculations ... they are approximations?!?
Correct.
Most scientific and financial applications (including my hack TakeStock[^] (forgive the shameless plug - but after all, it is freeware) will instead store floating point numbers as an aggregation of integers (which can be accurately compared).
So a bank balance of $12,345,678.90123 will instead be stored as the integer value 1,234,567,890,123 "milli cents". Since the number of mCents could be extremely large, you need store this value in a collection of int s. In the 70's and early 80's, many programmers used PL/1 which included a DECIMAL data structure for exactly this kind of thing.
Microsoft provides the CURRENCY [^] type that suffices for most financial calculations.
Hope this helps!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks guys. These have been a great help. I've been thinking about this for quite some time now.
|
|
|
|
|
Is this your actual code? What cmpiler, what settings do you use?
While it is true what was said - floats and doubles are not accurate representations - a simple assignment like yours typically is ok.
(And your ode with default debug/release settings outputs "TRUE" for me).
float and double both use a limited number of digits, certain numbers e.g 1/3, cannot berepresented accurately this way. Also, during calculations, final digits simply get lost. So comparing *results* as replied is a must.
However, you should also consider the alternative:
bool IsEqualRel(double a, double b, double eps = 1e-5)
{
_ASSERTE(a!= 0 && b != 0);
if (a==b) return true;
if (a<0 != b<0) return false;
return fabs((a-b)/a+b)) < eps;
}
bool IsZero(double a, double eps = 1e-5)
{
return a==0 || fabs(a) < eps;
}
which works for all magnitudes except comparison to zero (that's why the separate IsZero function).
With the absolute posted by the other guy, 1e-27 == 100e-27 and 10000000000000 != 10000000000001 which is often not what you need when working with numbers in this range.
I never really know a killer from a savior boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Hello All Great programmers!!
i am facing some exporting symbol from Win32 static Library.
i have declared function like this
extern const char * cl_strerror(int);
and when i call it from my mfc dialog based application( iam including required library file and header file in MFC app),it's give following error
testlibststaticDlg.obj : error LNK2001: unresolved external symbol "char const * __cdecl cl_strerror(int)" (?cl_strerror@@YAPBDH@Z)
Please somebody give some useful pointer
Ashutosh Tripathi
|
|
|
|
|
Hi
Use;
extern "C" const char * cl_strerror(int);
or
extern "C"
{
const char * cl_strerror(int);
}
to group more than one external reference.
Martin
|
|
|
|
|
when i declare char * cl_strerror(int); as
extern "C" const char * cl_strerror(int);
i got following error compiling the Library file
error C2059: syntax error : 'string'
Could you resolve the error please
Ashutosh Tripathi
|
|
|
|
|
Hi
Try changing it to this;
extern const char * __stdcall cl_strerror(int);
HTH
Martin
|
|
|
|
|
I know there are articles galore on double buffering but I can't get it to work!! I've copied below a very simple OnPaint method and nothing gets drawn. If I draw direct onto the CPaintDC it works. CGraphicStatic is derived from CStatic and the ON_WM_PAINT message map is used.
void CGraphicStatic::OnPaint()
{
CPaintDC actualDC(this);
CDC memDC;
memDC.CreateCompatibleDC(&actualDC);
CRect cr;
GetClientRect(&cr);
memDC.Rectangle(cr);
actualDC.BitBlt(0,0,cr.Width(),cr.Height(),&memDC , 0 , 0 , SRCCOPY);
}
but the following does..
void CGraphicStatic::OnPaint()
{
CPaintDC actualDC(this);
CRect cr;
GetClientRect(&cr);
actualDC.Rectangle(cr);
}
Hopefully, like my other posts, this is something stupid!
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
You need to create a bitmap and select it into the memory device context before you can draw on it.
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"
|
|
|
|
|
For a compatible DC, you have to give it a backing buffer - a bitmap object - to paint onto. A newly-created compatible DC has a 1-pixel monochrome bitmap selected into it. Any painting outside this area is simply discarded.
You need to create a new bitmap compatible with the original DC (using CreateCompatibleBitmap ) and select that into memDC using SelectObject before you start painting. If you make it compatible with the memory DC you get a monochrome bitmap, rather than one with the colour depth of the original.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Superb - worked a treat. Many thanks
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
I'm writing an add-in for IE and i would like to know if the document has been loaded entirely or it just resulted in a fragment (it happens oftenly when you hit the Stop button).
Do you know how could i accomplish this? I didn't find anything valuable from IHTMLDocument2 ...
"though nothing
will keep us together
we can beat them
for ever and ever"
rechi
|
|
|
|
|
Hi.
I have a program that reads a database and displays its graphics into a CScrollView Instance. To do that it reads records from the database and creates a small metafile for each of it. Finaly, when all those metafiles are created it replays them over the view and displays those that are part of the visible (on screen) window.
I want to create that view invisible (not on the screen) and using the same functions I would like to create all those metafiles. Then rather than replaying them on the display I would like to save them in the disk as EMF.
So far I manage to create the EMF and to replay over it the metafiles. However, I am always getting a part of my image in the saved file and not the whole image (wich be larger than the screen). I do not display the view on the screen thus the CGetClientBox CGetClipBox functions return a zero size rectangle. I 've tried to use functions to manipulate the window extend and the viewport but I am not sure that I understand them.
Can some explain to me what are window origin/extend versus viewport ones? And how can I affect the size of a disk saved MetaFiles?
Thanks a lot
Dimitris
|
|
|
|
|
As already stated, I have isolated a code generation problem with VC6 that I believe is a bug.
(a) If you have VC6 SP 1..4, please download the project and try it (it's a single-file project)
http://www.cherea.de/ReleaseBuildProblem.zip[^]
Make a debug build, and run it. Same for a Release Build. I expect no response in debug (succeeds), and a message box "Error" in the release build (fail)
If the release build fails, please send me the disassembly (from the release/ folder).
(b) See the next reply for the code in question. Have a look at it, I still hope I've made a mistake on the C++ side. The download mentioned above also contains much more information (detailed description, isassembly, etc.)
Thanks
I never really know a killer from a savior boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
#include <comdef.h>
inline GUID GetSomeID()
{
static const GUID someid_ =
{ 0x11112222, 0x3333, 0x4444, { 0x55, 0x55, 0x66, 0x66, 0x77, 0x77, 0x88, 0x88 } };
return someid_;
}
IUnknownPtr GetSomeUnknown()
{
try
{
static IUnknownPtr unk;
struct __declspec(uuid("{CFC399AF-D876-11d0-9C10-00C04FC99C8E}")) idMSXML;
if (unk==NULL)
unk.CreateInstance(__uuidof(idMSXML));
if (unk != NULL)
return unk;
}
catch(...) {}
DebugBreak();
return NULL;
}
struct CPtrWrap : IUnknownPtr
{
CPtrWrap(IUnknownPtr unk) : IUnknownPtr(unk) {}
};
struct CFinalPtr : public CPtrWrap
{
CFinalPtr(CPtrWrap psw) : CPtrWrap(psw) {}
};
static IUnknownPtr GetItem(GUID id, long l0, long l1)
{
return (id == GetSomeID()) ? GetSomeUnknown() : NULL;
}
struct CEnableMe
{
virtual void Enable(BOOL bOn = TRUE) {}
};
struct CMyOneApp
{
int m_mainFrame;
CMyOneApp() : m_mainFrame(1) {}
void UpdateEditDuplicate(CEnableMe * pCmdUI);
};
void CMyOneApp::UpdateEditDuplicate(CEnableMe * pCmdUI)
{
try {
bool enable = false;
{
rand();
GUID ParentID = GetSomeID();
CFinalPtr itParent = GetItem(ParentID, 0, 0);
if (itParent == NULL) _com_issue_error(E_POINTER);
enable = m_mainFrame != NULL;
}
pCmdUI->Enable( enable );
return;
} catch(_com_error ce)
{
OutputDebugString(" *********** FAILED ***********\n");
}
}
int APIENTRY WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
CEnableMe cmdUI;
CoInitialize(0);
CMyOneApp app;
app.UpdateEditDuplicate(&cmdUI);
return 0;
CoUninitialize();
}
I never really know a killer from a savior boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
It is coming as you expected on my machine. I mean there is a Message Box saying "error" in Releasewithdebug configuration and its ok on debug config.
Now, how do I send u the file
Found on Bash.org
I'm going to become rich and famous after i invent a device that allows you to stab people in the face over the internet
My Articles
|
|
|
|
|
thanks!
no need for the file in this case, but which VC6 Service Pack is installed?
(You can look in the registry HKEY_LOCAL_MACHINE\Software\Microsoft\Visual Studio\6.0\Service Packs\, the "latest" value)
I never really know a killer from a savior boost your code || Fold With Us! || sighist | doxygen
|
|
|
|