|
I'm actually "drawing them a bit at a time", as you put it.
The picture displayed consists of "tiles", and there are 3 to 5 layers of them, overlapping each other. Any of the layers can be turned on and off anytime by the user. I have separate functions for drawing different layers. They take a pointer to CDC, and uses it to draw it on the fly, directly onto the client view. Scroll bars are used to move the client view within this massive "field" of tiles and layers.
I've tried to use a "backbuffer" of a sort in the past, but all failed miserably. I've even tried to store a memDC pointer and always use it to draw all the active layers, then copy it onto the actual DC. But it seems DC is only temporary and can't be reliably used loop after loop. I've also tried to use CBitmap as a "backbuffer", but I couldn't quite figure what was going wrong with it, I think it was something to do with the fact that in windows the client size is variable and the size of the buffer has to change constantly depending on the client size (as opposed to the concept of "backbuffer" like it was in DOS/DirectX, where the size of the backbuffer was always constant, just as the primary buffer was of constant size).
When new tiles are plotted in one of the layers, only the affected tile area is redrawn. So it's usable... I know it's a major work-around, something one should avoid. I just can't seem to find an appropriate way to do this properly (and no, I'm nowhere close to being a MFC guru)
When the layers are turned on, OnErase isn't clearing window. It doesn't need to, so I've overriden it. On a side note, I'm using OnDraw. I'm not catching OnPaint message directly.
Anything to enlighten this situation would really help... it's close to a nightmare trying to solve it, so up until now I haven't bothered (the app is perfectly usable... while it has all the flaws). I really do want to solve it though, given the chance.
|
|
|
|
|
instead of ondraw, draw to the dc in onpreparedc.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Hi,
How do you obtain the width of a vertical bar?
thanks
|
|
|
|
|
use GetSystemMetrics(SM_CXVSCROLL);
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
|
Need help! How can I remove the program button from the taskbar?
|
|
|
|
|
Need help! How can I remove the program button from the taskbar?
|
|
|
|
|
Explain: "The program button"
--Bar Cochva--
|
|
|
|
|
With Program Button I mean the button in the taskbar.. where the start button is... in the buttom of the screen
but I have a solusion.... I replaced _EX_APPWINDOW with _EX_TOOLWINDOW
|
|
|
|
|
With Program Button I mean the button in the taskbar.. where the start button is... in the buttom of the screen
but I have a solusion.... I replaced _EX_APPWINDOW with _EX_TOOLWINDOW
|
|
|
|
|
Paul DiLascia addresses this question in the May 2000 issue of MSDN magazine. Search MSDN for May 2000.
Frank
|
|
|
|
|
How can I get back to my previous position in VS? Lets say I hit ctrl-home on accident and I want to get back to the previous line I was on. Is there a keyboard bind I can set for this?
|
|
|
|
|
Tools -> Options -> Combatibility
Select "Include caret positioning in undo buffer"
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
I wish I had asked this question a looooooooong time ago. Thank you!
|
|
|
|
|
I know that VC++ doesn't have export keyword . However, is there some way around, so that I can separate declarations and definitions of template functions?
I vote pro drink
|
|
|
|
|
Separate them like you would a regular class (.h/.cpp respectively) but instead of compiling the .cpp file directly, just include it in your header file -- you can also add the .cpp file to you project, just make sure it does not get compiled ( Settings... > General > Exclude file from build ( or just give it a different file extension ) )
functionTest.cpp
#include <iostream>
#include <vector>
#include <string>
#include "function.h"
using std::cout;
using std::endl;
using std::vector;
using std::string;
typedef vector<string> STRINGVECTOR;
int main ( int argc, char * argv [] ) {
STRINGVECTOR myBooks;
myBooks.push_back ( "Cryptonomicon" );
myBooks.push_back ( "Elemental Mind" );
myBooks.push_back ( "My Brain is Open" );
myBooks.push_back ( "Principia Mathematica" );
myBooks.push_back ( "The C Programming Language" );
STRINGVECTOR::iterator stolen = get_n (
myBooks.begin (), myBooks.end (), 4 );
cout << "My copy of \'" << *stolen << "\' was stolen!!" << endl;
return 0;
}
function.h
template <class _Iterator, class _Size >
_Iterator get_n ( _Iterator first, _Iterator last, _Size index );
#include "function.cpp"
function.cpp
template <class _Iterator, class _Size >
inline _Iterator get_n ( _Iterator first, _Iterator last, _Size index ) {
while ( first != last && 0 != index ) {
++first;
--index;
}
return ( first );
}
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Hi all,
I need some helps with ObjectARX for AutoCAD 2000i.
Working anybody with ObjectARX ??
ObjectARX is API for Autodesk AutoCAD.
Libor Matejka
|
|
|
|
|
Arx come with help files, afaik.
What do You need?
|
|
|
|
|
Hi,
I need use SaveAs() function, but I don'n know how.
If I use this code :
AcDbDatabase *pDb = new AcDbDatabase();
pDb->saveAs("d:\\test1.dwg");
delete pDb;
then test1.dwg is empty file without etities (line, circles ....)
What is wrong ?
What I must do for using SavaAs();
Libor Matejka
|
|
|
|
|
Try tu use AcDbDatabase::insert method.
And maybe calling save as command from autocad will be solution. As I remember that is ADS_COMMAND
|
|
|
|
|
Hi,
you must use this code :
AcDbDatabase* pDb=NULL;
pDb=acdbHostApplicationServices ()->workingDatabase ();
pDb->saveAs("d:\\pokus.dwg");
Libor Matejka
|
|
|
|
|
Hi,
In my OnMouseMove(...) I'm loading a bitmap like so:
<ccode>
CSize sizeOfBmp = m_dibMask.GetSize();
CBitmap *pOldBm = pDibMask->MakeBitmap(&m_dib, &dc, sizeOfBmp);
//This is to fix Dundas bug
delete dc.SelectObject(pOldBm);
dc.SelectObject(pOldBm);
Since my masked image (I'm using a masked image to create "hotspots") get's loaded everytime the mouse moves in the view, I was wondering if it's possible to do the above code but somehow persist the dc so I can make a call to dc.GetPixel(...) without actually having to load it all over again. My masked image is about 800k so I'm thinking that if I can persist the dc I can gain some performance.
Also, in my UI, the user can change the image/mask pair by selecting a different image, will this cause any problem?
Thanks for any help you can provide,
Craig
|
|
|
|
|
You could make it static or make it a member variable and set it up in your initialisation.
I just reread your post - I'd make it a member variable and then delete/recreate when the user changes what it is.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Thanks for the info Christian. Just so I'm clear on what you mean.
1. Create member variable in my .h file
CDC dc;
2. In my loadFile function (when the user selects a new imgage.)
if(dc != NULL)
delete dc;
dc.CreateCompatibleDC(NULL);
CSize sizeOfBmp = m_dibMask.GetSize();
CBitmap *pOldBmp = m_dibMask.MakeBitmap(&m_dibMask, &dc, sizeOfBmp);
//Fix Dundas bug
delete dc.SelectObject(pOldBm);
3. In my destructor
if(dc != NULL)
delete dc;
I'm kind of questioning the deletion of the dc, how do I do that correctly without creating memory leaks?
Thanks again for all your help,
Craig
|
|
|
|
|
No, this is dodgy - it won't compile. You are treating the variable DC as a pointer when you check for NULL and call delete, but it isn't one.
You can get the same effect without using a pointer by using dc.DeleteDC(); which will get rid of anything that was there before, but not crash if it was empty.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|