|
No, I'm reporting the progress of a lengthy process and I'm doing it withing a for loop:
for (int i=0; i<2342323346; i++)
{
DoLengthThing();
wndStaticText->SetWindowText(progress_str);
}
How can I make the static control not to flicker like crazy?
/T
|
|
|
|
|
store a copy of what you are setting the control to and only update the control if the string has changed....
|
|
|
|
|
I have an exe that I have embedded two binary files through the Resource editor in Visual C++ - How do I use those files from within the exe just like I do with Bitmaps, Icons, Cursors, Menus etc? Is there some sort of LoadResource that works for extracting custom data?
Cheers,
Clint
|
|
|
|
|
HINSTANCE hInstance = AfxGetInstanceHandle();
HRSRC hRsrc = FindResource(hInstance, pResourceIDName, "MyResourceTypeName");
if (hRsrc)
{
HGLOBAL hGlobal = LoadResource(hInstance, hRsrc);
if (hGlobal)
{
BYTE *pData = (BYTE *)LockResource(hGlobal);
DWORD dwSize = SizeofResource(hInstance, hRsrc);
..........whatever
}
UnlockResource(hGlobal);
FreeResource(hGlobal);
}
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Hi all, I got a stupid problem regards flipping a DirectDraw surface. I have initialised DirectDraw (through CreateEx), set cooperative level and set the display mode, no probs. I can load in a graphic and blit it to the back buffer and display it by calling the flip() routine. Now heres the interesting part, if I now get the so called back buffer pointer again and draw to it, when I call flip() the page is blank. Doesn't matter what I do, its blank. I got a timer going which flips the page every 1sec, what you should see is a very small, crappy animation, but instead I get one picture and one blackness screen. great. I have looked in the DD7 SDK help and the code is very similar to mine. I get the back buffer by calling this (roughly):
LPDIRECTDRAWSURFACE7 GetBackBuffer()
{
if (NumBuffers >0)
{
LPDIRECTDRAWSURFACE7 Buffer;
DDSCAPS2 ddscaps = {DDSC_BACKBUFFER, 0, 0, 0};
PrimarySurface->GetAttachedSurface(&ddscaps, &Buffer)
return Buffer;
}
return NULL;
}
I flip the code using PrimarySurface->Flip(NULL, DDFLIP_WAIT) and have included the necessary caps (PRIMARYSURFACE, COMPLEX, FLIP, DIRECT3D, VIDEOMEMORY) and flags (BACKBUFFER etc.) in the right places (As you can see cos I can write to the back buffer and flip it, but not to the back buffer after that. Again the one after that is ok, but not the one after that etc.). Don't know what the hell it is. I have DirectX 8.1 as my runtime and 7.0 as the SDK but even still, the 7.0 sample programs work! I would be eternally greatful if someone could have a go at answering my plea for help, thanks to all those who give it a go. Also I have some trouble using high resolution 32-bit display modes (the primary surface or back buffer - I forget which - comes out as multicoloured junk when I flip it???????), the other is ok - strange eh?. Might have some connection with the other problem, maybe a memory pointer is not reallocated or something, don't know but surely someone out there has the answer...
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
From my limited understanding of how page flipping works:
When you flip buffers you are actually just swapping pointers. So the back buffer becomes the primary and the primary becomes the back. If you are not re-filling the back buffer in between flippings you will get a blank page.
Alan Chambers wrote:
Also I have some trouble using high resolution 32-bit display modes (the primary surface or back buffer - I forget which - comes out as multicoloured junk when I flip it???????)
Did you convert the bitmap to 32 bit before copying it to the back buffer? Also, did you set the surface to be 32 bit? It could also be a memory thing like you said.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
Thanks for your reply Jason. You're right about the pointer swapping stuff, the back buffer SHOULD become the primary and the primary SHOULD become the back buffer. But when trying to refill the back buffer here (so between flippings) it comes out blank, doesn't do it, f***s up. stupid. As for the trouble I'm having using a high resolution 32bit display (1280x1024x32), I don't even have to draw ANYTHING, just flip the back buffer and the page is full of multicoloured junk. I'm pretty sure these problems are interwined, and it looks like it may be a memory thing (not a lack of it, but the pointer system isn't doing its job properly). Should I be clearing the buffer before using it maybe? Any more ideas on how I could go about resolving it would be great, or even links to web sites that may contain the answer.
Cheers,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote:
As for the trouble I'm having using a high resolution 32bit display (1280x1024x32), I don't even have to draw ANYTHING, just flip the back buffer and the page is full of multicoloured junk
Be sure you use True Color in the Display settings. I had the same problems, and I changed the resolution, now it works perfectly. Also make sure, if you try to use graphs, that the correct palette was loaded, and the colorkey initialised.
Alan Chambers wrote:
But when trying to refill the back buffer here (so between flippings) it comes out blank
Once you´ve done your flip, you have to blit all the objects on the back buffer.
I´ll send you a good example, maybe it will help. Anyway, if it does not work, feel free to send me your code, i´ll throw an eye on it.
~RaGE();
|
|
|
|
|
"Send you a good example" that would be brilliant. Thanks for the advice too. I do have some added info which completes this, officially, as THE strangest problem ever. If I write the code
MessageBox(GetActiveWindow(), "Whatever", "Whatever", MB_OK) before I do any page flipping, the code works and I see this beautifully changing but crappy animation. Take it out and I get picture, blank, picture, blank etc. How stupid and strange is that! I mean what has messagebox got to do with anything? Also I notice that the primary surface always gets refreshed at application startup(made blank), whilst the back buffer retains the image that was in memory last (even if the application NEVER draws to it/clear it or anything). I take it this is normal? Many Thanks anyway Rage,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote:
I mean what has messagebox got to do with anything
Well, if you are running DDraw windowed, you have to define clipping regions. Anyway, mixing GDI (i.e. messageBoxes) with DDraw is not trivial, so I suppose it is not anormal that sometimes strange things come out
~RaGE();
|
|
|
|
|
I have a set of classes all derived from a single abstract base class (not CObject-based). Each of these classes can serialize itself, and does so by first calling Serialize on the base class, to serialize the common stuff.
Now, i'm adding clipboard support for these objects. I used the "clipboard assistant", which is uses CArchive to store the objects. Storing them on the clipboard is easy, just serialize out. So far so good. But going the other way, creating an object based on data from the clipboard, is where I'm stuck. I can't just serialize to my derived objects because I don't know which one to use - all I know is that I have a chunk of serialized data that came from one of my derived classes. I can't serialize to the base class because it's abstract.
Part of what the base class serializes is a tag that identifies the derived class type. But, I can't read into that CArchive to find the tag, then rewind, because CArchive doesn't have any "rewind" functionality (though its CFile member probably does).
Any ideas?
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Not like you to be posting questions Chris, you normally answer mine. I'm a little shakey answering this cos I'm not really sure if its what your after, but it may at least give you an idea. Have you tried using fstream to read in the first struct/value of your file and based on that use a case statement to process the correct CArchive and serialize routine? I'm not that clued up about MFC but I think your in a bit of a catch 22. If I'm on the right lines, I'd be happy to help a bt further.
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote:
Not like you to be posting questions Chris,
yeah, there are some things i just never do much of - this is one of them.
looks like i'll end up doing something like what you're describing. i was hoping for a cleaner way. oh well.
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Chris, see my 3rd serialization article, specifically the section "Serializing a heterogenous collection class". I have sample code that uses the factory pattern to implement this. Send me mail if you'd like me to send it to you (virtual NDA assumed ).
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I am writing a simple program which makes calls of a DLL. My program crashes shortly after making a call to any function of the DLL, even when the function doesnt do anything and returns void. My memory manager gives me a message about operator delete, suggesting that some memory has been messed up somewhere. Initially, the function call appears to be succesful, it just crashes as i step through amongst some dissasembly code.
Thanks in advance
James
|
|
|
|
|
Sounds like a mismatched calling convention. For example, the DLL routines are using __stdcall while the caller thinks the routines are all _cdecl. This causes all sorts of nasty stack thrashing.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Think I found a Bug in the API Function TabbedTextOut. When Parameter nCount is 1 and nTabOrigin is 80 and lpnTabStopPositions is 67 (pointer to int with value 67) the Function behaves like nTabOrigin is 0. nTabOrigin can be only 13 greater than the int-value lpnTabStopPositions points to. With an array with more than one value the Origin parameter works well.
Can someone report this bug to MS?
|
|
|
|
|
Hello,
I need to know how to create a new child MDI window. I have a program that opens bitmap images, but it doesn't put them on a new window. I want to know how to write my own OnFileNew command basically. Mayeb my problem is with my fileOpen, since it doesn't open new windows?
If anyone has any advice on how do this, or even better, KNOWS how to do this, I would be very happy.
thanks a lot
NickOne
|
|
|
|
|
Look at the code in the OnFileNew handler. It does what you want,just copy the relevant bits.
|
|
|
|
|
Hi people,
I've just set up some scrollbars with the guidance of a nice cp article, but there's a small thing I'd like to change:
The code makes the scrollbar disappear when it's no longer needed.
However, some apps (like Notepad) always show the scrollbar and just hide the thumb instead.
Anyone know how to do that?
Thanks,
Ren
|
|
|
|
|
EnableScrollBar(SomeHwnd, SB_VERT, ESB_DISABLE_BOTH);
does the trick with the vertical scrollbar...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi,
Thanks for the help. Your code solved the problem, but I found another approach as well.
Here's my OnSize handler:
void COverviewWnd::OnSize(UINT nType, int cx, int cy)
{
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE|SIF_RANGE|SIF_DISABLENOSCROLL;
si.nPage = cy;
si.nMax = rctTotal.Height();
si.nMin = 0;
SetScrollInfo(SB_VERT, &si);
CWnd::OnSize(nType, cx, cy);
}
Apparently SetScrollInfo automatically calculates whether the scrollbar is necessary or not by comparing nPage (the available space) and nMax (the total space the document occupies).
It's default behavior is to hide the scrollbar when it's no longer needed, but you can set the SIF_DISABLENOSCROLL flag to have it disabled instead.
You probably knew this, but I wrote it down anyway for those who don't.
Greetings,
Ren
|
|
|
|
|
I know this is a really stupid question, but I'm use to programming on Unix systems.
I wrote a program using MS Visual C++, and I want to pass in a value into the argsv.
so I can run it at the command prompt something like: "whatever.exe filename.txt"
of course this doesn't work. Any ideas?
ICXC
NIKA
|
|
|
|
|
Why doesn't it work, I have done that lots of times...
Starting a program with "whatever.exe filename.txt" from the command promt I mean, and it works just fine.
What exactly are you trying to do that don't work?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
It works when I use the ms-dos command prompt. when I just go to start and run, then browse, then try to do it, it's a no go.
ICXC
NIKA
|
|
|
|
|