|
Well, you don't show how you do the re-drawing of the area in your WM_PAINT processing. Where did you place the call to ValidateRect()? Immediately on entry or just before the EndPaint()? Is it possible that you are calling some other functions that cause the invalidate to happen (explicitly or implicitly) before the call to ValidateRect()?
|
|
|
|
|
It's too much code to simply paste here. You'll have to take my word for it that there is no way for the rect to be invalidated other than when I explicitly call for it.
My code works like this. bitmap A is updated from a thread. Thread calls InvalidateRect when done updating a frame. bitmap B contains the window background and doesn't change. bitmap C is a double buffer. When WM_PAINT arrives, call BeginPaint, alpha blend bitmap A with B onto C and BitBlt bitmap C to the screen. When done call EndPaint.
Like I said this is GDI 101, and I have never had a problem like this with previous versions of windows or Visual Studio.
As it stands now, calling ValidateRect from anywhere in the WM_PAINT handler solves the problem. I currently have it after the call to EndPaint. Without this call, WM_PAINT is being sent from window creation and always with the full client area. Even though at that time my drawing routines have not yet begun. And yes I do call Begin End on EVERY WM_PAINT.
On another note, passing the message onto DefWindowProc, after those two calls, also results in undesired behaviour. rectangles are being validated but not those that are in the paint struct.
I'm really beginning to think this is a bug.
Waldermort
|
|
|
|
|
Of course, if this were a newly introduced bug in Windows (not saying that it isn't) then we'd expect to see a lot more programs going into high cpu usage processing WM_PAINT messages.
Theory goes that the EndPaint() call will take care of the ValidateRect() on the .rcPaint member of the PAINTSTRUCT you received in BeginPaint(). Is that the same thing you are using in your manual ValidateRect() call? Is there a possibility that it is being clobbered during your paint processing? If .rcPaint changed between Begin and End that would explain what you see. You say you use that member to do your re-drawing, read-only?
|
|
|
|
|
Chuck O'Toole wrote: Theory goes that the EndPaint() call will take care of the ValidateRect() on the .rcPaint member of the PAINTSTRUCT you received in BeginPaint(). Is that the same thing you are using in your manual ValidateRect() call? Is there a possibility that it is being clobbered during your paint processing? If .rcPaint changed between Begin and End that would explain what you see. You say you use that member to do your re-drawing, read-only?
BeginPaint() actually.
Like you said though, if it were a bug... which makes me think there must be a problem in my code somewhere.
Anyway, found it! Deep in there was a legacy debug routine to update the entire screen. Now to find out who made it and then...
Thanks for the suggestions though.
Waldermort
|
|
|
|
|
Hi Friends,
My software server listens on a particular port using dedicated "listener thread" . We accept the connections from client and serve this request on different threads.
Under high input requests from client (12000 approx/sec), the "listener thread" dies. Any suggestion for this kind of problem?
Currently it looks to me that the select or accept call is possibly the reason behind. Should we use pselect or simialr to this?
~ Vikram S
|
|
|
|
|
vikrams wrote: the "listener thread" dies.
Please clarify "dies." Is there an error?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Well, the first place I would look for is running out of memory. Depending on how you create the thread (_beginthreadex / CWinThread class / whatever) if you are creating a thread for each of the 12000/second arrivals, you might run out of some resource. You might check for stack size too, if I remember correctly, each thread gets a stack and that's taken off the end of your stack so, eventually, there'll be some overlap. I'm a bit foggy on that but it caused me problems in the past and I had to build the app with a larger stack size.
|
|
|
|
|
I still working on my SQL Server Scanning Program. I can enumerate all the server names on the LAN, but I need something to store the names in. I'm using a collection, because the number of names is different every time.
I can add names, edit and remove names in the collection, but I can't figure out how to populate the collection in another class, and return it back for more processing. When I try to pass the collection, I get the missing list of arguments message.
The link to the collection I made.
Creating a Collection Class in C++[^]
|
|
|
|
|
jkirkerx wrote: When I try to pass the collection, I get the missing list of arguments message.
What are you trying to pass it to?
|
|
|
|
|
I thought it was an object, that I could pass down to a function, down to another function, like a HWND object. But it was not the case, because after more research, You can't pass a template collection according to my limited reading. So I pasted my class SQL Enumerator function up 1 level, and condensed it.
I'll keep my ears open for a better way of storing values while I work with them.
|
|
|
|
|
Guys,
I have to maintain a number of legacy products which are DOS applications, developed using MSVC 1.52. I have just splashed out on a new laptop only to find that MSVC1.52 refuses to install undr Windows 7, even in XP (and Win 98) compatibility mode.
Anyone managed to do this, or does anyone know of a C compiler which will produce 16 bit DOS apps but will run under Windows 7?
The code is C and not C++ and does not us MFC.
Thanks
Tony
|
|
|
|
|
I believe XP (and before) used to have an emulator that would allow it to run 16bit applications... that's probably gone in the newer OS's... try to search for a 16bit emulator that you can run under...
|
|
|
|
|
|
Thanks,
You are right of course, the problem is not so much related to Windows 7 but to the 64 bit platform. That makes the problem all the more difficult because its not just a case of replacing the OS.
I saw that Windows 7 Pro has an XP mode but I guess it will be XP/64 so the problem will still be the same.
Things are never easy (sigh!)
|
|
|
|
|
Have you considered simply using a virtual machine? I've got win7 (home premium, so no XP emulation mode) I simply installed Virtual Box before installing XP, linux Mint, etc inside it.
You'll have no problem installing XP, 2000 or 98 in it, and from there any version of visual studio you please. Of course there's always the MS Virtual PC, or the ubiquitous VMWare.
|
|
|
|
|
I have a 64-bit Windows 7 system, running 32 bit XP in the virtual machine, so that may be an answer. You can get the VM from Microsoft[^].
|
|
|
|
|
As pointed out by others, 64-bit Windows does not support 16-bit programs even though Intel x64 and AMD64 do support 16-bit programs.
However there is a program called DOSBox (http://www.dosbox.com/download.php?main=1[^]) that can be used to run 16-bit programs.
I use this program to run the old classic DOS games.
|
|
|
|
|
Thanks,
I saw DOSBox but I dont actually run the DOS apps on the development PC as they are embedded. The real problem is getting Microsoft Visual C++ V1.52 to install and run so I am looking for a Windows on Windows solution.
|
|
|
|
|
|
Thanks a lot for the suggestion. I have installed Virtual PC and XP (32 bit) and my MSVC 1.52 is installing nicely.
Great solution (and free).
|
|
|
|
|
(Using VS 2008 C++)
Is it safe to use a size specifier in enum declaration ?
typedef enum MyEnum : int
{
e1,
e2,
e3
} MyEnum;
This will generate a warning :
C4480 : nonstandard extension used: specifying underlying type for enum 'enum'.
Is this just an informative warning that it will not do what it is supposed to do or will it really type my enum values as int values ?
For what I can read it looks kosher and when/if we switch to VS2010/2011
Thanks.
Watched code never compiles.
|
|
|
|
|
Yes it is safe, unless you switch to a compiler that doesn't support it. In pre-VC11 compilers, I believe it has no meaning and is essentially ignored.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
what is ignored ? I assume the warning.
I tested with different size specifier and it returns the appropriate size; so I assume it's safe.
Thanks.
Watched code never compiles.
|
|
|
|
|
Sorry about the long post but its a bit of complex subject matter.
I'm trying to do a data-binding system in C++ similar to that found in WPF.
WPF uses the built-in C# reflection mechanism to map an XML data binding tag to a method or field in a object. It can also binding collection classes to list controls.
I want to do the same but in C++. I'm writing the back-end system so I need to provide a data-binding/reflection type system for other programmers to use.
Requirements:
Here is an example usage for the system.
The programmers will define their own classes and somehow expose their classes functions and member variables to the the data binding system. They could then create a collection class, containing instances of those classes.
They specify the UI elements in a XML format, and include the data binding reference for certain widget types.
They would then expose the collection class to the widget, probably using data-binding, which will bind the collection class a list widget. The list widget would then iterate through the list and for each element would invoke a function call, by mapping the binding name to a class function or reading the data directly out of the object structure.
What I have so far:
I've created an interface class (IReflection) which provides a number of pure virtual methods. A programmer wanting to expose their classes methods/member variables would inherit for the interface.
I've managed to expose the member variables by using a static class which takes a static function pointer that belongs to the class. This then creates a temporary instance of the class, which is then used to build a table of byte offsets for each member variable. This static array belongs to the class. One of the IReflection methods, takes a string lookup name, finds it in the array, gets the byte offset back and reads the data at that point. The lookup table also contains the size of the type of data to prevent buffer overruns.
This works OK, except its pretty nasty and feels like a bit of hack. Also it gets around private access
as the code is just reading a piece of memory.
I have a slightly harder problem when it comes to executing member functions. I want to be able to create function pointers to call the methods that are exposed. However I don't want to create member function pointers as I would need to create them for every instance and I think that would be a waste of memory. Therefore I need to provide static functions which as essentially proxy functions that take a pointer to the instance and then call the member function on it.
This is making the code look messy and unmanageable and I'm not happy with any of the solutions I have.
I have found lots of information on-line for providing reflection in C++, but none of them provide the ability to invoke methods or read/write properties, which is essential for a UI to display and change values.
I am starting to think I should provide a method in the IReflection interface that takes a string and returns the type of data required. It would then be up to the programmer to define this function. They could simply just write 'if-else if' code and do the necessary string compares and execute the correct code.
That feels like the easy option for me, but I'm concerned how much work I'm generating for others by taking the easy option.
It would be nice to be able to expose the data binding using a set of macros, similar to RTTI to make it easier for the programmer to define the code. However I'm not a fan of macro code as it is impossible to debug.
I should say this is a UI system for a game engine, so I can't go around allocating lots of memory, I don't want lots of small allocations as this is bad for memory fragmentation and the data cache. It also needs to work quickly. I'll probably eventual turn the strings into hashes and do hash table lookup but that is a implementation detail for performance reasons and doesn't have to be done straight away.
Does anyone know how this could be done or know of any examples of this type of system. Not sure if you would call this problem 'dynamic data-binding' or 'reflection'.
Any advice would be appreciated.
Thanks
|
|
|
|
|
For dynamically invoking methods, you could take an approach similar to the COM dual interfaces: take a look at
IDispatch[^].
Basically, there's a method called GetTypeInfo, which describes your current object. Then there is GetIDsOfNames, which maps a method to an ID, and finally, Invoke, which -tadaaaah- invokes que method, passing the ID as parameter.
This is how languages such as VB6 used to work with COM interfaces. Not sure, however, on whether you should use good ol' IDispatch or implement your own interfaces, suited to your needs. But I think the approach could help you: by knowing how many methods are available, and being able to invoke them through an ID or index.
Cheers!
|
|
|
|