|
code snippet
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
Johannes,
Calling Sleep() in your UI thread prohibits the Windows messages
required (WM_PAINT) to update the control from being processed.
Try this:
on click:
set box "3"
box.Invalidate()
box.UpdateWindow()
sleep 1000
set box "2"
box.Invalidate()
box.UpdateWindow()
sleep 1000
set box "2"
box.Invalidate()
box.UpdateWindow()
sleep 1000
Keep in mind, calling Sleep() like this effectively freezes your
user interface for 3 seconds...not always the desired effect
Hope this helps,
Mark
|
|
|
|
|
Yea it kinda frezes but thats OK,
Im not exactly sure how thoes functions are to be used, the dlg box is called status, and the variable to it (add member variable) is m_status, so normaly i use:
m_status = "Two!";
UpdateData(FALSE);
To set it to "Two!". But how would i use th ones you said?
ive got loads to learn..
thanks!!
/Johannes
|
|
|
|
|
m_status = "Two!";
UpdateData(FALSE);
That's fine. UpdateData() will set the text of the control.
But still, if you are going to sleep, you need to make sure the
text is redrawn on the screen beforehand, otherwise it won't be repainted
until after the Sleep()s.
Mark
|
|
|
|
|
How do i make it repaint?
thanks!
/Johannes
|
|
|
|
|
Force it to repaint immediately (after setting the new text)
by using these two functions:
Invalidate();
UpdateWindow();
Mark
|
|
|
|
|
Works perfectly!
thanks a million!
/Johannes
|
|
|
|
|
The thread that is doing the sleeping is also the thread that would be 'painting' the new text. When your method is complete, there will be four paint messages that are handled one right after the other in to quick a fashion so that you see only the final result.
As to how to 'fix' this, you can implement a timer instead of sleeping and repond to the timer messages.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
It sounds like you need a separate thread to do the work so that the main thread can respond to the UI messages. Without more details, however, I can't say for sure.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Problem is resolved using:
Invalidate();
UpdateWindow();
thanks to MSalsbery and the rest whom replied
thanks all!
/Johannes
|
|
|
|
|
I just installed VC8 and am in the process of integrating my projects. There are many errors I have never seen before, also the layout of VC8 is somewhat confusing.
Two errors are my main concern right now:
1. error C2058: constant expression is not integral
Comes from an enum declared within a class
enum Keys
{
classesRoot = HKEY_CLASSES_ROOT,
};
and:
2. cannot convert parameter 1 from '_single_tile *' to 'std::_Vector_iterator<_Ty,_Alloc>'
tiles.erase(&tiles[p2]);
where tiles is a vector of structs. This works well in VC6, I can't understand why VC8 throws an error.
|
|
|
|
|
With the first one, locate the definition of HKEY_CLASSES_ROOT. As the error message indicates, it must be integral, so wherever you have it defined, it is likely not integral. As to your second one, I'm guessing that the changes implemented to the STL that ships with VC8 are considerable when comparing it to the STL that shipped with VC6. There is likely a standards conformance reason for some change that is causing your code to now produce that error. Someone with more STL knowledge might provide better insight though.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
I don't mean to sound stupid, but what does integral mean?
|
|
|
|
|
Integral means that the type must be int or at the least convertable to int.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
Well this fixed the first error, though I am still unsure what the error means.
enum Keys
{
classesRoot = 0x80000000,
currentUser ,
localMachine ,
users ,
performanceData ,
currentConfig ,
dynData
};
As for the second error, I still don't know how to fix. I could typecast it (bad programming) but I would prefer to fix it the correct way.
|
|
|
|
|
(2) That should never have compiled anyway. The standard way to use erase is to pass an iterator (vector.begin() + index).
|
|
|
|
|
And for (1), use the following to get rid of the error :-
enum Keys
{
classesRoot = (LONG)(ULONG_PTR)HKEY_CLASSES_ROOT
};
|
|
|
|
|
Nish, I want to give you a big wet kiss )
Now to get rid of those 'deprecated' warnings.
|
|
|
|
|
waldermort wrote: There are many errors I have never seen before...
Because VC++ is now more compliant.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
VC6 let you treat an iterator as a pointer. That's what you're trying to do here, in reverse, grab a pointer and pass it through as if it were an iterator. The change is to make it more standards conformant, and it happened in VC2002.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Guess you learn something new every day. I always thought an iterator was a pointer, except for the fact that when increasing it it instead increases by the size of what it's pointing at.
As for this VS8, it's already making my eyes ache
|
|
|
|
|
A pointer has behaviour that makes it a valid random access iterator, they basically behave the same.
Yeah, it was a big change ( and a change to being more VB like IMO ). The absence of the class wizard is a pain, the new system doesn't work as well IMO, I tend to hand wire events ( but then, I always did ). But, once you're used to it, it is a lot better, although VC2005 C++ support in things like intellisense is not so great.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
My first impression was not all that great. I have had to find and change so many setting/options/toolbars.. just to have an environment similar to what I am used to.
I have never used the class wizard so I'm not missing anything there. I do like the extra memory validation that goes on the background though. It found a few stack corruptions that I would have otherwise missed (partly due to converting to the 'safe' CRT).
I'm not sure if it's my configuration or just the IDE, but the compile times have almost doubled. It can be a pain when trying to debug. Also, I have not figured out yet how to position the watch window. It's currently tabbed, I want to be able to see the watch and the local/auto variables at the same time.
Gonna take some time to get used used to.
|
|
|
|
|
waldermort wrote: enum Keys
{
classesRoot = HKEY_CLASSES_ROOT,
};
If you don't really need an enum type, it might be better to turn those into static const members, which you can init in the header file:
class CFoo
{
public:
static const HKEY classesRoot = HKEY_CLASSES_ROOT;
}; That also has the advantage of preserving the type-safety of classesRoot .
|
|
|
|
|
RE: Problem #2.
Your old code worked because previous versions of the stl implemented iterators as C++ pointers.
In the latest implementation you can no longer assume that iterators and pointers are equivalent.
tiles.erase( ( tiles.begin() + p2 ) ) shoule work fine assuming that p2 is the index of the element you want to remove.
|
|
|
|