|
www.codeguru.com is another good one. It has java forum maybe you are interested.
David
|
|
|
|
|
Check out
Experts Exchange
http://www.experts-exchange.com
|
|
|
|
|
For core C++, you can't go past comp.lang.c++ on usenet.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
hi, i've written a simple application that display a sequence of bitmap in the VIEw of a MFC/SDI application.
There're four components to the implementation:
(1) timer itselg
(2) View_Class::OnTimer(..)
{
Invalidate(); //Trigger View_Class::OnDraw()
(3) View_Class::OnDraw(..) is responsible for rendering the bitmaps to screen.
(4) Document class - handles all bitmap loading
(4a) Constructor:
STEP 1: Pre-load a few frames
STEP 2: launch a thread - LoadFrames( ) - that load the rest of the bitmap sequence.
hThread = CreateThread( NULL, 10000000, (LPTHREAD_START_ROUTINE) LoadFrames, this, 0, &nThreadID);
As you can see, I did allocated 10MB worth of memory here!
STEP 3: set timer
(4b) LoadFrames( ) //This method loads a bunch of frames to document class
{
//ERROR!!
hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), sPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
if( hBitmap != NULL)
{
pDoc->GetBitmapSeq(i).Attach(hBitmap);
}
else
{
//Out of memory?!?! NOTE: dwError==8 implies "ERROR_NOT_ENOUGH_MEMORY"
//System monitor shows that the thread never had more than 2.5MB!??! How can it run out of memory??
DWORD dwError = GetLastError();
}
}
Thanks
norm
|
|
|
|
|
Three problems that I can see:- A thread that uses MFC must be created by
AfxBeginThread() . - The stack size parameter has no effect in this situation, as you're not creating bitmaps on the stack.
- The
HINSTANCE param to LoadImage() must be NULL when using LR_LOADFROMFILE Good luck
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
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
|
|
|
|
|
thankyou... i tried using CAnimateCtrl but doesnt seems like it helps..
MCI control is a lot better, especially with memory requirement. But seems like it's a little jerky. QuickTime is the best thus far - which makes me wonder why we need avi in the first place.
norm
|
|
|
|
|
Hi, I launched a thread that's responsible for loading a sequence of bitmap into memory, so, I need a lot of memory for this thread. Here's the code fragment:
unsigned long nThreadID;
HANDLE hThread;
hThread = CreateThread( NULL, 5000000, (LPTHREAD_START_ROUTINE) LoadFrames, this, 0, &nThreadID);
So, as you see, I've allocated 5MB of memory to this thread. However, I keep getting memory allocation error from my thread function:
long WINAPI LoadFrames(LPARAM lparam)
{ //*
...
...
hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), sPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
if( hBitmap != NULL)
{
pDoc->GetBitmapSeq(i).Attach(hBitmap);
}
else
{
//Out of memory!! dwError==8 implies "ERROR_NOT_ENOUGH_MEMORY"!!?! I really dont understand, I was monitoring the system monitor and the thread has less than 3MB allocated to it.
DWORD dwError = GetLastError();
... more exception handling code...
}
return 1;
} //*
Thanks!
norm
|
|
|
|
|
You are allocating a 5M Stack for the worker thread. Is that what you really want? Where does LoadImage() get its memory from. I doubt that its the stack.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Thanks for the feedback first of all. LoadImage return a BITMAP hBitmap which is stored in a variable (of type BITMAP of course) in the "thread function". The images sequence is stored in a CBitmap array in the document class, which is separate from the thread... so, all I need is just enuf memory for ONE bitmap (700kB), and yes 10MB is an overkill, but I really dont understand why LoadImage results in memory error:
long WINAPI LoadFrames(LPARAM lparam)
{ //*
CString sPath;
HBITMAP hBitmap = NULL;
CAutoPlayMFCDoc * pDoc = NULL;
pDoc = (CAutoPlayMFCDoc*) lparam;
//Load the rest of the frames!
for(int i=NUM_PRELOAD; i<num_bitmap; i++)
="" {="" **
="" spath="pDoc-">GetPath();
if( sPath.GetLength() > 0 )
{ //***
hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), sPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
if( hBitmap != NULL)
{
pDoc->GetBitmapSeq(i).Attach(hBitmap);
}
else
{
//That's the problem: dwError==8 implies "ERROR_NOT_ENOUGH_MEMORY"
DWORD dwError = GetLastError();
pDoc->SetLoadState(1);
i = i -1; //reload the frame
break;
}
//Increment m_nTargetDocFrame:
pDoc->SetTargetDocFrame(i);
} //***
} //**
return 1;
} //*
norm
|
|
|
|
|
The "dwError==8 implies "ERROR_NOT_ENOUGH_MEMORY"" may be a red herring. If you move this code into the main app thread does it work?
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Yes, after I adjust the number of frames to be preloaded in the document class' constructor, i got the same error (from LoadImage() in document class constructor)...
How can I adjust the memory for the mainthread? or the application thread?
norm
|
|
|
|
|
I don't think it is a memory problem. Maybe there is a problem with the bitmap you are loading. Why don't you try some others, including some smaller ones.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
what do u mean problem with bitmaps? anyway, your suggestion "try smaller bitmap" is probably pointing to the right direction, it seems that the application consistently returns error (dwError = 8) around the time when it finishes loading the 32nd frame.
But u're right, it's got nothing to do with memory allocated to the thread.
norm
|
|
|
|
|
Hello -
I'm building a product that requires an html wysiwyg editor - I upgraded to Visual C++ .NET (7) to get MFC 7 - with the CHtmlEditView / CHtmlEditDoc classes, only to find that there is no IDM_TABLE command.
I also tried inserting using IHTMLDocument2:
BSTR str = SysAllocString(L"<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#CCCCCC\" bgcolor=\"#E6E6E6\"><tr><td width=\"11%\"> </td></tr></table>");<br />
<br />
IHTMLDocument2 *pDoc;<br />
long col=0;<br />
IDispatch * pDocDisp = NULL; <br />
<br />
pDocDisp = GetHtmlDocument();<br />
HRESULT h = pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );<br />
if( h == S_OK )<br />
{<br />
IMarkupServices *pMS = NULL;<br />
IMarkupPointer *pMkStart = NULL;<br />
IMarkupPointer *pMkFinish = NULL;<br />
<br />
<br />
CComPtr<IHTMLElement> pElement; <br />
HRESULT hr = pDoc->createElement(L"TABLE", &pElement);<br />
pElement->put_outerHTML(str);<br />
<br />
pDoc->QueryInterface(IID_IMarkupServices, (LPVOID *) &pMS);<br />
pMS->InsertElement(pElement, pMkStart, pMkFinish);
and also tried IHTMLTable / QueryInterface. None worked.
If anyone has a solution to my problem I'd be greateful.
Thanks.
Art Cote
Art Cote
|
|
|
|
|
IHTMLElement has a function called InsertAdjacentHTML.
BTW: I would recommend you to use smart pointers which make life a lot easier, and they also help avoiding memory leaks.
Just us it as follows:
IDispatchPtr pDisp = ...
IHTMLDocument2Ptr pDoc(pDisp);
IHTMLElementCollectionPtr pCollection;
pDoc->get_all(&pCollection);
IHTMLElementCollection pAllTables(pCollection->tags(CComVariant("table")));
...
|
|
|
|
|
As someone said, insertAdjacentHTML is a fine stuff :
CComQIPtr<IHTMLDocument2> pHtmlDoc( GetHtmlDocument() );
CComBSTR bstrWhere = "BeforeEnd";
CComBSTR bstrText = ...;
CComPtr<IHTMLElement> pBody;
pHtmlDoc->get_body( &pBody );
pBody->insertAdjacentHTML( (BSTR)bstrWhere, (BSTR)bstrText);
How low can you go ? (MS rant)
|
|
|
|
|
Thanks for the responses. One question - is insertAdjacentHTML feasible for drag drop operation, i.e.,
a la IDM_TEXTBOX message - simply drops edit box on
CHtmlEditView.
What I'd ultimately want to do is to be able to insert
a table based on parameters entered in dialog, then
drop table onto CHtmlEditView. Similar to the DHTMLedit component using IDM_TRIED_INSERTTABLE.
Thanks a bunch for responding so quickly.
|
|
|
|
|
Art Cote wrote:
One question - is insertAdjacentHTML feasible for drag drop operation, i.e.,
These are separate things. Handling drag&drop events is a different matter, which should not interfere with adding html code to an existing page.
How low can you go ? (MS rant)
|
|
|
|
|
The solution:
BSTR bstrText = SysAllocString(L"<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#CCCCCC\" bgcolor=\"#E6E6E6\"><tr><td width=\"11%\"> </td><td width=\"11%\"> </td><td width=\"11%\"> </td></tr><tr><td width=\"11%\"> </td><td width=\"11%\"> </td><td width=\"11%\"> </td></tr></table>");<br />
<br />
IHTMLDocument2 *pDoc; <br />
IDispatch * pDocDisp = NULL; <br />
pDocDisp = GetHtmlDocument();<br />
HRESULT h = pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );<br />
BSTR bstrWhere = SysAllocString(L"BeforeEnd"); <br />
IHTMLElement *pBody;<br />
IHTMLLocation *pLocation;<br />
pDoc->get_body( &pBody );<br />
<br />
pBody->insertAdjacentHTML( (BSTR)bstrWhere, (BSTR)bstrText);<br />
<br />
SysFreeString(bstrText);<br />
SysFreeString(bstrWhere);<br />
pDoc->Release();<br />
pDocDisp->Release();
works fine - putting a table into CHtmlEditView. However how does one access
the IHTMLTable interface - when I to get_activeElement I get the body,
not the selected table.
Thanks.
Art
|
|
|
|
|
Art Cote wrote:
I to get_activeElement I get the body,
not the selected table.
What selected table ? You haven't selected anything here.
I guess you mean you are willing to get a IHTMLTable pointer from the table you have just inserted. That's easy, change your html tags so that you add a <table ...> with a name="mytable" attribute.
Then from the document.all collection, you can ask the DOM to retrieve the IHTMLElement whose name is "mytable" :
IHTMLElementCollection::item Method
HRESULT item( VARIANT name /*VT_BSTR*/, <-- "mytable"
VARIANT index,
IDispatch** pdisp
);
Finally, cast it to IHTMLTable
How low can you go ? (MS rant)
|
|
|
|
|
Oops - I meant to get the only table element on the page-
eventually i will setup element selection.
The code works - does one need to update the document somehow ?? so the changes to the table are shown?
(fragment)
<br />
pDoc->get_all(&pCollect); <br />
pCollect->item(varID,varIdx, &pDocDisp );<br />
pDocDisp->QueryInterface(IID_IHTMLTable, (void**) &pElem);<br />
<br />
pElem->put_cols(cols);<br />
<br />
.
.
.
Thanks again...
art
|
|
|
|
|
|
I know this may sound like a dumb question, however I'm stumped. Can someone tell me what a Dword is used for?
Thanks,
John
|
|
|
|
|
a DWORD is the same as an unsigned int .
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
it's used wherever you need 32 bits of unsigned storage. there's no rule that says what you should do with it.
-c
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|