|
|
Sorry, just trying to show someone how to sign up. Thought I could delete this, but cannot.
|
|
|
|
|
I would like to create a CBitmap object from a DC, then draw the bitmap on each successive repaint rather than doing all the drawing stuff again (there is quite a lot, which is why I want to use this approach).
So, I know how to blit the CBitmap back to the DC each time the window is repainted, but I don’t know how to copy the stuff I’ve drawn to the DC into the CBitmap. How would I do this?
Thanks in advance for any help you can give me.
Yours,
James Millson
|
|
|
|
|
Once I've create a function CopyBitmap(..) to copy a bitmap form one to another. Note that it does not work on all kind of bitmaps (eg 32-bits not ). You should be able to find the way to copy the image from your DC to a CBitmap. Hint: iso SourceDC use your own pointer to DC in the function BitBlt(..). Have fun!
Kit
BOOL
CBetterBitmap::CopyBitmap
(
CBitmap* pbmpSource, // IN: Source bitmap
CBitmap* pbmpDest // OUT: Target bitmap
)
{
BOOL bResult = FALSE;
// Invalid source bitmap
ASSERT(pbmpSource != NULL);
// pbmpDest must point to an existing CBitmap instance
ASSERT(pbmpDest != NULL);
ASSERT(pbmpDest->GetSafeHandle() == NULL);
// Quick pointer verification
if ( (pbmpSource != NULL) &&
(pbmpDest != NULL) )
{
BITMAP bmp;
pbmpSource->GetBitmap(&bmp);
// First copy the bitmap information
if (pbmpDest->CreateBitmapIndirect(&bmp))
{
CDC SourceDC;
CDC DestDC;
// Now copy the bitmap via display compatible DC's
if ( (SourceDC.CreateCompatibleDC(NULL) != FALSE) &&
(DestDC.CreateCompatibleDC(NULL) != FALSE) )
{
CBitmap* pbmpPrevSrc = SourceDC.SelectObject(pbmpSource);
CBitmap* pbmpPrevDest = DestDC.SelectObject(pbmpDest);
bResult = DestDC.BitBlt(0, // Source Left
0, // Source Top
bmp.bmWidth, // Source Width
bmp.bmHeight, // Source Height
&SourceDC, // Source DC
0, // Target Left
0, // Target Top
SRCCOPY); // Raster Operation
DestDC.SelectObject(pbmpPrevSrc);
SourceDC.SelectObject(pbmpPrevDest);
}
}
}
// Return result
return bResult;
}
|
|
|
|
|
If you've got a DC and you want to copy it to a CBitmap, just select the CBitmap into another DC and Blt across.
Jonathon
|
|
|
|
|
Hi all,
Hopefully this is a trivial problem for you people, I'm a well seasoned C/C++ programmer, but I'm new to MFC (I used to develop for Unix with any expeditions into the Windows world being handled by the venerable Borland C++ Builder series). Anyway, my problem is this; I've created a dialog based application (C++ Builder showing through already ) that performs some very extended processing when a button is clicked (it does a lot of low-level I/O with a CD), however, I need to provide the user with a way of stopping the processing, such as a cancel button.
I've added all of the necessary code for a cancel button, but the problem is that whilst my extended processing loop is running, my application is not processing any other events that occur (such as the cancel button being pressed). Under Builder there is a function called "ProcessMessages()" that would cycle the Windows message loop and allow other controls to respond to messages. Is there a similar function for MFC? Or will I have to use some other nasty method for my extended processing (such as starting a seperate thread for it)?
Thanks in advance
|
|
|
|
|
First off, if you still have the option of moving your UI processing to another thread you should really consider doing so.
If on the other hand, if the above is not an option you can add the following code and call it from your processing loop, it will allow your cancel messages to get through.
void PeekAndPump () {
MSG Msg;
CWinApp * pApp = AfxGetApp ();
while ( ::PeekMessage ( &Msg, NULL, 0, 0, PM_NOREMOVE ) ) {
pApp->PumpMessage ();
}
}
Have a good one,
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
There's nice article in Feb'97 issue of MSJ - "Wicked Code" by Jeff Prosise. He presents the CWaitDialog class that looks like solution for your problem. The article should be in the 'Periodicals' section of your VC++ help. If it's not there, search msdn.microsoft.com
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi all,
I want to create ActiveX that have EditBox in base ... it mean i want to write ActiveX about new EditBox with my metoths and events ...
So:
1- I adding EditBox to my ActiveX dialog
2- I create my events and metoths in wizard ...
But when i compile my ActiveX, i can't see my EditBox !!! why ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I need urgently function that gets string (for example: "101")
And returns int (101).
Please help me !!!
|
|
|
|
|
|
|
I have a textBox and spin
I dont success to connect both so that when the user will press on the spin up or down it will change the textBox accordingly.
Who can to explain me step by step what I have to do ????
thanks;)
|
|
|
|
|
To get your spin control to update the edit-box set it as its Z-order to the next number after the edit-box(Specify Z order by setting the tab order). After you have done that, you should enable the 'Auto buddy' option, and if you also want the spin control to fill the edit-box with numbers you set the 'Set buddy integer' option(these can be found on the control property pages -- Alt+Enter).
Hope this helps.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
OK ! You are right.
But now I have another problem.
if I set the range of spin with big numbers(as 10000)
In run time I gets a MessageBox of error that impossible to return int
|
|
|
|
|
When you set the range, are you using SetRange32? If not, you should. SetRange only allows you to set 16 bit ranges (I know 10000 can fit it a 16 bit variable, but when in Rome...).
Also, you should make sure the spin control’s data member is initialized to a valid index within the range that you specified.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Whenever I start my VCPP, before it displays the window it gets a fatal error. When I say details it syays this:
MSDEV caused a divide error in module DEVSHL.DLL at 015f:50024d84.
Registers:
EAX=00000000 CS=015f EIP=50024d84 EFLGS=00010246
EBX=00000000 SS=0167 ESP=0067ef7c EBP=0067f1dc
ECX=00000001 DS=0167 ESI=007dd440 FS=4377
EDX=00000000 ES=0167 EDI=007deca8 GS=0000
Bytes at CS:EIP:
f7 7d f0 8b c8 eb 82 8b 4d c8 eb 9b 8b 45 e8 2b
Stack dump:
00000000 007dd440 007deca0 00000018 00000001 00000007 0067f030 0000809e 0067f07a 00000928 00000047 00000000 0067f3de 00000000 00000000 00000000
How can I fix this? I tried reinstalling it, running defrag, scandisk, virus scan, I don't know what to do, please help, I can't program till this is fixed.
|
|
|
|
|
Please, someone help me. I'm going crazy not being able to program.
|
|
|
|
|
Have you tried installing the latest SP? are you using any third-party addin's, if you are disable them.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
No, I don't use addins and my VC++ was working for like a year with SP 3. And now it just suddenly keeps giving me that error. What can I do about?
|
|
|
|
|
Hmmm... Aside from installing SP5, I'm not sure what the best approach would be. HAve you by any chance just installed some new fangled software package? Have you considered wiping your system completely clean, and starting from scratch?? – I know it’s a little drastic, but this would be my best advice to you at this point.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Is there a way to add extra control such as a datagrid or a chart control to VC. I used to use these controls (are they OCX's?) in visual basic all the time, its not something whcih seems to be used often in vc, why is this??
ben
|
|
|
|
|
If you go Project/Add to project/Components and COntrols you'll find that you can add Registered ActiveX controls on your machine. I don't know if this list is dynamic or set by VC on install, because you're right - I don't use them. I prefer the control I get by building my own or getting them from places like this. An overridden MFC control has all the source, so I can do what I want with it. I remember the hell I went through wading through VB documentation on MSDN trying to figure out FlexGrid. Not for me, thanks.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
is there a technique to understand stl errors?? the syntax is so odd, eg:
'class std::_Tree<int,struct std::pair<int="" const="" ,char="" *="">,struct std::map<int,char *,struct="" std::less<int="">,class std::allocator<char *=""> >::_Kfn,struct std::less<int>,class std::allocator
<char *=""> >::iterator __thiscall std::map<int,char *,struct="" std::less<int="">,class std::allocator<char *=""> >::find(const int &)' : cannot convert parameter 1 from 'char [3]' to 'const int &'
This particulr problem was easy to solve but the error messages are worse than useless...!
|
|
|
|
|
There is a VC add in kicking around that strips the extraneous template errors so you can quickly get to the meat of STL error messages. I think it's here, but I could be wrong. Either way, it's about if you search for it ( I don't *think* I have it myself )
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|