|
|
One way is to use a memory device context (search codeproject for CMemDC), which is essentially a bitmap in memory. Instead of drawing directly to the screen, you draw everything to the memory DC, and then as the last step in the drawing process, you BitBlt the memory DC onto the real DC. This means that if the same part of the DC is drawn multiple times during the drawing process, you won't see any flicker.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
hehe... yes I know you can use doublebuffering, but I wanto know if it possible to have a flicker-free graphic without it. Thanks anyway
Aidman » over and out
|
|
|
|
|
|
But shouldn't it be possible to use ValidateRect or some other function to prevent an graphic area from updating to the screen? So that you can draw stuff on that area and update it when your done, sort of like when you use BeginPaint and EndPaint?
Aidman » over and out
|
|
|
|
|
Not if you're drawing directly to the screen.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Aidman wrote:
But shouldn't it be possible to use ValidateRect or some other function to prevent an graphic area from updating to the screen?
Yes, but the part you don't validate will still flicker if you draw over the same part multiple times or if you don't handle WM_ERASEBKGND to prevent the background being erased.
It's almost always better to use a memory DC, combined with selective invalidating like you suggested.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
if you don't handle WM_ERASEBKGND to prevent the background being erased.
YES! This is very important to avoid filcker even if you use a memory dc.
John
|
|
|
|
|
John M. Drescher wrote:
YES! This is very important to avoid filcker even if you use a memory dc.
Absolutely! I probably didn't make that clear enough did I
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi All,
I need to play a video file in .avi file format I am writing a DirectX win32 program so I do not want to use the control that ships with VC++ as I need full control.
also the AVI file is compressed using a custom codec.how can I extract the frames although it is compressed.
Thanks in advance
|
|
|
|
|
Hi. Recently due to my newbie design, I got stuck with all my windows as dialogs. Now I want to create a modal help dialog that has CHTMLView in it. I successfully did this with WebBrowser ActiveX object, but it requires external file (which I dont like), since it doesnt have LoadFromResource interface. Now most of the examples shown have Doc/View architecture which makes it simple to replace CChildView with CHTMLView. But almost none is inside a CDialog. The hints like creating CFrameWnd inside a CDialog sounds good but I couldn't make it work. Can anyone help / post an article on this? Any solutions will do. Thanks!!!
Desperate...
|
|
|
|
|
|
Thanks much! I was able to get the original Paul DiLascia HTMLCtrl and works awesome.
http://www.microsoft.com/msj/0100/c/c0100.aspx
|
|
|
|
|
Hi,
I'm looking for what I should use for a collection class which holds small objects of my own creation (all of the one class type.) Trouble is that the collection is expected to have up to 500000 objects in it.
What would be recommended for a collection class that minimizes the searching and retrieval time for so many objects in the collection?
Thanks,
Dave
|
|
|
|
|
It depends on how you want to access them. If you need to do lookups based on some key value, and the values do not need to be sorted, then you can use a hashmap, as it has constant time insertion, deletion, and retrieval.
If you need them sorted, then you could use a balanced tree, as that will have logN insertion/deletion/retrieval, and allows traversing the tree in order (keeping them sorted).
If you don't care how they are sorted, and don't need to do lookups, then you could use a simple linked list, or even an array if you know at the start how many items there will be.
If you can provide some more details with how you plan to use it, then it will be easier to recommend a specific collection to use.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Can anyone tell me why this code
#include <map>
std::map<std::string, int> foo;
int test_stl(std::string key)
{
return foo.find(key)->second;
} Gives me about a page of STL compilation errors in Visual Studio .NET?
Can anyone give me an example of working code that uses a hash_map or a map with an std::string key type?
Why couldn't Science, in the long run, serve
As well as one's uncleared lunch-table or
Mme X en Culottes de Matador? James Merrill
|
|
|
|
|
If you actually include the compile errors (or at least the first few), then it will make it a lot easier to determine what the problem is.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Looks like you just need to #include <string> :
#include <map>
#include <string>
std::map<std::string, int> foo;
int test_stl(std::string key){
return foo.find(key)->second;
}
- Mike
|
|
|
|
|
Duh! Thanks for setting me straight.
|
|
|
|
|
Hello everybody,
Here is my problem.
I wrote a program that does a statistical analysis, allocating large quantities of memories (3-400 MB) dynamically, and then performs cycles of calculations on the data.
At the end of each cycle, the program opens 2 files in sequence and writes the results to the disk.
With the first file there is no problem, with the second everything goes well for 20-30 cycles (on average, but the figure varies), when the fopen() that should open the file fails, returning a null pointer. If I try to make it open the same file (which is always the same file that it opened without problems for the first 20-30 cycles) passing to the fopen the name in “” instead of passing a variable, it still doesn’t open it.
If I give it a wayout letting it open another file somewhere else, it succeeds and goes on.
At the next cycle, it reopens the old file without problems.
It is as the write permission on that file were temporarily altered in a cycle, to be brought back to their original values in the next cycle.
The problem occurs with 3 different compilers (borland, Visual C++, mingw) and on 2 operating systems (windows NT e windows ME) , running on 2 different machines (both pentium)
I tried to launch the program from the Visual C++ debugger with all the cheks activated, putting also checks on the heap (functions _CrtMemCheckpoint, _ASSERTE( _CrtCheckMemory( ) )), but apparently there is no memory corruption problem.
Here is the function savememory where the error occurs.
void Sieve::savememo(void)
{
int lr,nd,i,j,b,var1,* fp2;
Node * ndp;
fp = fopen(MEMORYFILE,"w");
fprintf(fp,"\n%d",cyc);
for (lr=1; lr<LAYERS; lr++) {
fprintf(fp,"\n\nLR %d",lr);
for (nd=0; nd<nn[lr]->dimlr; nd++) {
ndp = nn[lr]->nodes[nd];
fprintf(fp,"\n%3d) ; %.3f ;",nd,ndp->score);
for (i=0; i<MAXIPNDS; i++) {
fprintf(fp," [%3d", ndp->memo.inar[i].ndnr);
fprintf(fp," %5.2f", ndp->memo.inar[i].wht);
fprintf(fp," (%3d", ndp->memo.inar[i].spc.x1);
fprintf(fp," %3d)", ndp->memo.inar[i].spc.x2);
var1 = (int)ndp->memo.inar[i].spon;
fprintf(fp," %d] ;", var1);
}
fprintf(fp," [%5.2f -1] ;", ndp->memo.bias);
fprintf(fp," (%2d %2d)", ndp->memo.a.x1,ndp->memo.a.x2);
fprintf(fp," (%2d %2d)", ndp->memo.b.x1,ndp->memo.b.x2);
}
}
if (fclose(fp))
printf("Error closing file\n");
#ifdef DEBUG2
printf("AFTER WRITE MEMORYFILE I AM! \n");
printf("\n%s %d\n", DNAMEMFILE, cyc);
#endif
fp = fopen(DNAMEMFILE,"w");
#ifdef DEBUG2
printf("\nfp: %p\n", fp);
if (fp == NULL)
fp = fopen("C:\\ZEUG\\ZOS\\MPXVC\\IOX\\MPXDNA0.TXT","w");
if (fp == NULL) fp = fopen("C:\\ZEUG\\ZOS\\MPXVC\\IOX\\MPXDNA2.TXT","w");
if (fp == NULL) fp = fopen("C:\\ZEUG\\ZOS\\MPX\\IOX\\MPXDNA3.TXT","w");
if (fp == NULL) fp = fopen("C:\\ZEUG\\ZOS\\FILE01.txt","wt");
printf("AFTER fopen(DNAMEMFILE) I AM! \n");
#endif
for (lr=1; lr<LAYERS; lr++)
for (nd=0; nd<nn[lr]->dimlr; nd++) {
fprintf(fp,"\n\nlr %d nd %d dimpop %d\n",lr,nd,
nn[lr]->nodes[nd]->popp->dimpop);
for (j=0; j<DIMPOP; j++) {
fprintf(fp,"\n%5.3f %5.3f",nn[lr]->nodes[nd]->popp->guys[j].score,
nn[lr]->nodes[nd]->popp->guys[j].dd);
for (b=0; b<DIMDNA; b++) {
var1 = (int)nn[lr]->nodes[nd]->popp->guys[j].dna[b];
fprintf(fp," %d",var1);
}
}
}
fclose(fp);
#ifdef DEBUG2
printf("AFTER WRITE DNAMEMFILE I AM! \n");
#endif
}
Help, I’m getting crazy!
Thank you
Alex
|
|
|
|
|
Hi Alex,
You aren't testing whether the second fclose() succeeds. It may be that the value of fp has been trashed by your for loops. You could printf fp after the close or better still inspect it in the debugger.
Your code hasn't displayed correctly because < and/or > signs are missing. You need to use the Formatting bar to add these.
I'd try remove the code between the fopen/fclose and repeat the test and see what happens. Also inspect why the fopen is failing more closely. perror() might be of use here and the CRT global errno.
Hope that helps.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville,
That's what I did: I placed a GetLastError right after the test on the pointer of the fopen() and the result is error code = 32, which on my system means: "impossible to access the file, file is used by another process."
In additon, I noticed that, if I wait for a while (in the deubugger), the file (the same file, with the name unchanged) becomes available again and the fopen succeeds. So this would be an easy wayout I only coud be sure that no major problem (like dangling pointers or the like) is threatening the correctenss of the application results.
Anyway, I am trying to figure out some possibilities:
1. Is it possible that some system processes or not-system processes (I am thinking at the Kazaa stuff which I once downloaded - now I deleted it but I notice that, when I connect to the internet, an icon "connected" in the Kazza style appears at the bottom of the screen).
2. The file was not closed properly at the last cycle and so it is still marked as "used". In this case should be seen as used bu the same process, not by another one.
Now I am going to check out the result of the second fclose() as you already suggested.
What do you think?
Alex
|
|
|
|
|
Help...
I'm writing a "simple" DLL that should be capable of accepting a varaible as a dosptr (dos pointer) which would point to some text, modify it and return the modified text.
It seems that the pointer is being interpreted ok but I cant seem to return a revised variable to the calling app, well not without crashing it anyway.
Has anybody go any ideas ???
Cheerz
Juglugs
|
|
|
|
|
A dos pointer (as you put it) is just a standard C string pointer (char*) and these are passed to DLLs all the time.
The question are:
What is the DLL doing with the string?
Are you telling the DLL how much space it has to work with?
Are you sure the DLL is not over-running the buffer?
Are you passing a static or const string?
Is the DLL written using C or C++?
You could pass the string along with a seperate buffer (+size of buffer) to store the resulting string in, but that should not be needed.
In general calling a function/method in DLL is just like calling a function in your own code or one of the standard C/C++ libraries.
Trust in the code Luke. Yea right!
|
|
|
|
|
The DLL Should be just concatenating it with another string.
No im not telling the DLL how much space it has to work with.
shouldnt be overrunning the buffer.
static or const dunno the base app cannot pass strings as such just
a dosptr using somet like dll_call whichdll stack "P" var.
C++
|
|
|
|
|