|
suresh_sathya wrote:
pXMLDoc=NULL;
pXMLDoc->Release();
This does not only produces a memory leak, it also does a very nice GPF! since you are using a null pointer to call Release().
So, first of all, pXMLDoc->Release() must be called before pXMLDoc=NULL;
Otherwise, it does not make much sense to use raw interfaces here, just use CComPtr<IXMLDOMDocument> pXMLDoc; instead. It will even release the object for you.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
I am just trying to parse xml and add some attribute names to my listbox.But when the program comes in for loop,it stops at third line and shows memory error.
Debug assertion failed
CComPtr<ixmldomdocument> pXMLDoc;
CComPtr <ixmldomnamednodemap> pXMLNamedNodeMap=NULL;
CComPtr <ixmldomnodelist> pXMLNodeList=NULL;
CComPtr <ixmldomnode> pXMLAttNode=NULL;
CComPtr <ixmldomnode> pXMLNode=NULL;
HRESULT hr;
CComBSTR bstrName;
CComVariant varValue;
CComVariant varNodeValue;
long lCount;
VARIANT_BOOL bIsSuccessful;
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&pXMLDoc);
if (FAILED(hr))
return(hr);
varValue="testing.xml";
hr=pXMLDoc->load(varValue,&bIsSuccessful);
pXMLDoc->selectNodes((_bstr_t)"DATABASE/TABLE[@Left]",&pXMLNodeList);
long Tablelen;
pXMLNodeList->get_length(&Tablelen);
HWND hListBox=GetDlgItem(hDlg,IDC_LIST);
CComVariant Tablename;
for(int ii=0;ii< Tablelen;ii++)
{
pXMLNodeList->get_item(ii,&pXMLNode);
pXMLNode->get_attributes(&pXMLNamedNodeMap);
pXMLNamedNodeMap->getNamedItem((_bstr_t)"Name",&pXMLNode);
pXMLNode->get_nodeValue(&Tablename);
//SendMessage(hListBox,LB_ADDSTRING,0,(LPARAM)(char *)(_bstr_t)Tablename);
}
|
|
|
|
|
There are many errors in this code. The best option is you get your hands on a working msxml sample first (download msxml 3 SDK, or msxml4 SDK, or platform SDK core services).
For instance, this article [^]on codeproject does such things.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
I wanted to display 10 bitmaps using CImageList
but why all the bitmaps were black
1.first ,I created a project "Cards",Imported 1,2,...,10
2.and I added variable in CCardsView
CImageList* m_pImageList
and the function
BOOL CCardsView::AddBitmap(UINT nResourceID)
{
CBitmap m_bmp;
if(m_bmp.LoadBitmap(nResourceID))
{
m_pImageList->Add(&m_bmp,RGB(256,256,256));
m_bmp.DeleteObject();
return TRUE;
}
return FALSE;
}
3.CCardsView::CCardsView()
{
// TODO: add construction code here
m_pImageList=new CImageList;
m_pImageList->Create(71,96,ILC_COLORDDB,256,1);
for(int i=1;i<11;i++)
{
AddBitmap(i);
}
}
4.CCardsView::~CCardsView()
{
if(m_pImageList!=NULL)
{
delete m_pImageList;
}
}
5.void CCardsView::OnDraw(CDC* pDC)
{
CCardsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPoint pos(0,0);
// m_pImageList->SetBkColor(CLR_NONE);
// m_pImageList->SetOverlayImage(0,1);
for(int i=0;i<10;i++)
{
m_pImageList->Draw(pDC,i,pos,ILD_NORMAL);
pos.x+=50;
}
}
Why?
--oly--
|
|
|
|
|
RGB(256,256,256) is like RGB(0,0,0). Max channel value is 255.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
hi,
this is the debug result:
f:\projects center\task history\mission 8_13\hydrosrv\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
and this is the source of warning:
enum RecordCreateOptionsEnum
{
adCreateCollection = 8192,
adCreateStructDoc = -2147483648,
adCreateNonCollection = 0,
adOpenIfExists = 33554432,
adCreateOverwrite = 67108864,
adFailIfNotExists = -1
};
tell me how to fix this problem.
Thanks in advance
Extreme programming. Do the No.1
|
|
|
|
|
adCreateStructDoc = 0x80000000
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
Hi
I have some dll set which I'm using in VC7. As long as it was compiled in VC7 everything was fine. Now, when I'm using the same dlls compiled in VC6, my program crashes when I'm trying to execute some code from this dlls. Is this a problem of using import libraries (lib files) from VC6 (I mean that maybe lib files from VC6 cannot be used in VC7), or maybe whole dlls are incompatible (this would be very stupid I think), or maybe this dlls are just buggy(and previous dlls compiled in VC7 are not buggy). If this is a problem of lib files is there a way to convert lib from VC6 to VC7 (I can't recompile this dlls). I know one "easy" solution to my problem: getting back to VC6, but of course it's not a good idea (probably I used some VC7 features and because program is quite big there would be a lot of work to do, additionally I just got used to VC7 and I like it ). Anyone have some hints? Thanks in advance
Mariusz Popiolek
|
|
|
|
|
Hi,
I've written a code which replaces characters in a string with their respective URLEncode (i.e a " " will be replaced by "+" etc..).
However the code crashes at execution.
Please help!!
Here's the code extract;
Code:
>-----------------------------------------------------------------------------
for(j=0;j
|
|
|
|
|
|
for(j=0;j<one.length();j++)
{
indxD = one.find_first_of ( " " , 0 );
one.replace(indxD,1,"%2B",3);
}
From the problem I see, you should escape % and replace it to %%2B, while the length is still 3. (Escaping escape code, weird that!).
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
In addition, your encode routine is completely wrong. Spaces should be replaced with +, while non alphabetical characters should be replaced with their hex ascii representation prefixed with a %.
That's not exactly what you are doing.
It's also questionable because whether you are using javascript (escapeurl), ASP (urlencode), C++ (InternetCanonicalizeUrl, UrlEscape), .NET (HttpUtility.UrlEncode), you've many SAFE ways to do it already. Why reinvent that f***ing squared wheel ?
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
i connect to a server (a game server), now i want to know the server's ip address (i.e. 123.222.111.222) and port the server used, do u think it is possible?
thanks for any info and help.
includeh10
|
|
|
|
|
includeh10 wrote:
i connect to a server (a game server), now i want to know the server's ip address (i.e. 123.222.111.222) and port the server used, do u think it is possible?
Well, to connect to the server you need the IP address of the server (or domain name) and the listening port. So if you do not know either of them, you wouldn't be in the server in the first place.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
try tracert in a dos console.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
or try netstat in a dos console to find a list of connections your computer currently has.
|
|
|
|
|
Hello everyone,
I am writing a application that has a notify icon in the status area. Now I get in trouble in preventing the icon disappearing after the 'explorer.exe' is terminated and restarted. Who can help me? Thanks.
Kerry Chou (STU)
Kerry Chou from STU
|
|
|
|
|
[already answered you in the newsgroup, but in this case you also get mail notification]
If your main window receives a message whose value is equal to RegisterWindowMessage(TEXT("TaskbarCreated")) then this means the taskbar is being recreated and you should re-add your tray icons. Remember that this message is NOT sent to your tray icon message handler, but it is sent to the application's top level window (usually your main frame window)
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Thank you Nish, I have resolved the problem.
But I can not find any information about the 'lpString' parameter of 'RegisterWindowMessage(LPCTSTR lpString)' function in MSDN, how can I identify the lpString parameter when I want to define a new window message?
Thanks!
Kerry Chou from STU
|
|
|
|
|
Kerry Chou wrote:
Thank you Nish, I have resolved the problem.
But I can not find any information about the 'lpString' parameter of 'RegisterWindowMessage(LPCTSTR lpString)' function in MSDN, how can I identify the lpString parameter when I want to define a new window message?
Thanks!
Kerry,
RegisterWindowMessage is used to register custom messages. Say you have 3 apps all wanting to communicate to each other. Now you can use RegisterWindowMessage to get a unique message ID. For example RegisterWindowMessage("Kerry's special message") will always return the same unique message ID for an entire session. Now you can broadcast this message to all top level windows and the other programs which are expecting this message can handle it.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
When i show my dialog box iam calling this code in WM_INITDIALOG.I am loading the xml parser whenever i show my dialog box.I think that might be the problem for memory increase.What is the exact error.
IXMLDOMDocument2 *pIXMLDOMDocument2=NULL;
IXMLDOMNodeList *pIXMLDOMNodeList=NULL,*pIXMLDOMNodeList1=NULL;
IXMLDOMNode *pIXMLDOMNode=NULL,*pIXMLDOMNode1=NULL,*nextItem=NULL;
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap1 = NULL;
IClassFactory *pIClassFactory=NULL;
char strpath[300];
GetModuleFileName(NULL,strpath,300);
int len=strlen(strpath);
while(strpath[len]!='\\')
{
len=len-1;
}
strpath[len]='\0';
int retval=PathFileExists(strcat(strpath,"\\testing.xml"));
if(retval)
{
try
{
HRESULT hr;
CoInitialize(NULL);
hr=CoGetClassObject(CLSID_DOMDocument,CLSCTX_SERVER,NULL,IID_IClassFactory, (LPVOID*)(&pIClassFactory));
pIClassFactory->CreateInstance(NULL,IID_IXMLDOMDocument, (LPVOID*)(&pIXMLDOMDocument2));
if(SUCCEEDED(hr))
{
HWND BrowserWindow=(HWND)GetCommandLine();
DestroyWindow(BrowserWindow);
VARIANT_BOOL boolvalue;
VARIANT myvar;
myvar.vt=VT_BSTR;
myvar.bstrVal=L"testing.xml";
VARIANT Fieldname;
Fieldname.vt=VT_BSTR;
pIXMLDOMDocument2->put_async(FALSE);
VARIANT Tablename;
Tablename.vt=VT_BSTR;
HRESULT hrload;
long Tablelen;
hrload=pIXMLDOMDocument2->load((_variant_t)myvar.bstrVal,&boolvalue);
pIXMLDOMDocument2->selectNodes((_bstr_t)"DATABASE/TABLE",&pIXMLDOMNodeList);
pIXMLDOMNodeList->get_length(&TotTablelen);
hrload=pIXMLDOMDocument2->load((_variant_t)myvar.bstrVal,&boolvalue);
pIXMLDOMDocument2->selectNodes((_bstr_t)"DATABASE/TABLE[@Left]",&pIXMLDOMNodeList);
pIXMLDOMNodeList->get_length(&Tablelen);
HWND hListBox=GetDlgItem(hDlg,IDC_LIST);
for(int i=0;i< Tablelen;i++)
{
pIXMLDOMNodeList->get_item(i,&pIXMLDOMNode);
pIXMLDOMNode->get_attributes(&pIXMLDOMNamedNodeMap1);
pIXMLDOMNamedNodeMap1->getNamedItem((_bstr_t)"Name",&pIXMLDOMNode);
pIXMLDOMNode->get_nodeValue(&Tablename);
SendMessage(hListBox,LB_ADDSTRING,0,(LPARAM)(char *)(_bstr_t)Tablename);
}
}
}
catch (_com_error &e)
{
MessageBox(NULL,(char*)e.Description(),NULL,MB_OK);
}
}
CHECK_AND_RELEASE(pIXMLDOMDocument2);
CHECK_AND_RELEASE(pIXMLDOMNodeList);
CHECK_AND_RELEASE(pIXMLDOMNodeList1);
CHECK_AND_RELEASE(pIXMLDOMNamedNodeMap1);
CHECK_AND_RELEASE(pIXMLDOMNode);
CHECK_AND_RELEASE(pIXMLDOMNode1);
CHECK_AND_RELEASE(nextItem);
CoUninitialize();
}
|
|
|
|
|
What are you asking about? What error is happening? Or are you wondering why your memory usage goes up?
The code has a lot of errors in it, such as:
Use PathRemoveFileName() and PathAppend() to make the XML name; your current code is not DBCS-safe.
Use CoCreateInstance() to create the XML parser object in one call.
CLSCTX_SERVER isn't a valid constant, should be CLSCTX_INPROC_SERVER.
You don't initialize your VARIANTs.
L"testing.xml" is not a BSTR
and so on.
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi,
We are using these with VC+ 6.0:
<br />
OnPrint()<br />
{<br />
CPrintDialog printDlg(FALSE);<br />
<br />
if (printDlg.DoModal() == IDCANCEL)
return;<br />
----------------<br />
}<br />
So if we choose OK then it will Print, Cancel then not (return)
What can we do to print immediately ... without having to select OK button ... any trick to skip this without confirm?
Thanks
|
|
|
|
|
Look at CView::OnPreparePrinting
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi,
Thanks for the tip, I will ry.
Regards,
|
|
|
|
|