|
okay... i did that... except I apparently missed just how to link the control to the bitmap I want... sorry to ask for a walk through, but its late and I'm not entirely clear headed at this point
Thanks and Thanks
-Mel
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
|
|
|
|
|
Mel Feik wrote:
I apparently missed just how to link the control to the bitmap I want
Add your bitmap as a resource to your project and give it an ID like IDB_LOGO or whatever you like. Then in the properties dialog for the static control that you added, you will be able to select the IDB_LOGO resource, and that will link your bitmap to the static control.
Good Luck
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!
|
|
|
|
|
thanks
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
|
|
|
|
|
I'm somewhat embarrassed to ask this, but as I said I've not done this before. I goofed this up somehow and ended up with a hex file instead of my bitmap.
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
|
|
|
|
|
On the control's properties there is a Type combo (set it to Bitmap) and an Image combo (set it to the resource ID of the bitmap to show). You can also set the bitmap at runtime with the STM_SETIMAGE message.
--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
|
|
|
|
|
thanks again
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
|
|
|
|
|
If the bitmap doesn't use the 16 standard colors, I'd recommend CWndImage[^] (if you use MFC)
deals with pixel-vs-dialog units size and palette issues.
Auch den Schatten will ich lieben weil ich manchmal lieber frier' Rosenstolz [sighist]
|
|
|
|
|
Thanks to all replies. I must have just been over tired last night. Didn't have any problems with it today and I appreciate the help.
-Mel
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
|
|
|
|
|
Are there any other good C++ forums that you know about. I mean the Forums like Sun has for java. This one is good but still there may be others........
|
|
|
|
|
I think that programmers heaven is decent (at times) so you might want to check that out.. has seperate forums for C/C++ w/ and w/o MFC.
http://programmersheaven.com/zone3/index.htm[^]
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
|
|
|
|
|
Programmer's heaven is ok but i could have been better. I was using the Java Forum hosted by Sun http://forum.java.sun.com/, it's real great
|
|
|
|
|
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
|
|
|
|