|
Use a CALLBACK function. When you set up a CALLBACK function, you are setting up an Event function which gets called whenever the specified event happens, in your case 100ms has passed.
<br />
void SetTestTimer() { _TimerID = timeSetEvent(_TimerRate, 0, &Run, (DWORD)this, TIME_PERIODIC); };<br />
then define your Callback in the header (and as appropriate in the .cpp) as :
<br />
static void CALLBACK Run(UINT wTimerID, UINT msg, UINT dwUser, DWORD dw1, DWORD dw2);<br />
The CALLBACK must be static and have those parameters to run from SetTimer because they act as a function signature, otherwise the function will never get called . Have a nice day.
Alan.
"Once I was but the Learner, now I am the Master" [Darth Vader]
|
|
|
|
|
Hi all, I'm almost there with my array template class, I just have one horrid problem before success . OK, I'm reserving a raw memory chunk using malloc/realloc. If T is an object I am then using the placement new operator (default) to construct the objects inside this reserved block, otherwise I am doing a block initialise on the data. Here's the problem, when I have an array of chars, everything is fine (the placement new path is not necessary), however if I have an array of
<br />
class MyClass<br />
{<br />
public:<br />
MyClass(void);<br />
~MyClass(void);<br />
<br />
array<char> string1;<br />
array<char> string2;<br />
};<br />
<br />
HRESULT Allocate(unsigned int alloc)<br />
{<br />
unsigned int size = sizeof(T);<br />
if(size > 4)<br />
{<br />
m_pItem = malloc(alloc*size);<br />
<br />
new(m_pItem) T[alloc];<br />
}else...<br />
}<br />
Malloc reserves enough space for say 10 of these objects and returns a pointer to the data which is stored. The placement new operator then gets passed this pointer, but fatally constructs the object 4 bits on from m_pItem. Its strange because my debug window says new[] returned 0x00322c50 yet if I use T* p = new(m_pItem) T[alloc]; instead, p = 0x00322c54 but the debug window still claims 0x00322c50 was returned??? Also m_pItem shows complete garbage in the debug window (so it ain't there), but looking at the mem address 0x00322c54, I can see the object has been nicely constructed there. What the hell is going on?
|
|
|
|
|
OK, just managed to find out that when you use new(m_pItem) T[alloc] - the array form of placement new, it may, depending on the object, add some extra overhead to the allocation. Urrrggghhh. Apparently its safer to just loop through the number of objects and use the non-array placement of new - new(m_pItem) T;, which doesn't add any overhead, and everything is hunky dory. What a crock of sh*t. Now all I need to do is figure out how to destroy objects without making a fuss or memory leak .
Alan.
|
|
|
|
|
Hi !
I'm developping using the Visual C++ environnement, but I'm not using the MFC nor the Win32 API directly. Thus, I'm thinking about using another editor for my C++ sources.
Any suggestions, or is the Microsoft's editor the best ?
Thanks !
Jerome
|
|
|
|
|
I couldn't live without CodeWright.
Bernd
|
|
|
|
|
I couldn't live without ED.;) See sig.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
If the default editor does not work for you, can can change it by right clicking on any file icon in the Solution explorer (View->Solution Explorer) and then choose 'Open With....' to enter the location of your favourite editor.
Hope this helps
|
|
|
|
|
I love the original VS editor, its neat, tidy, clear, concise and has all the tools you need for debugging, what more could you possibly want?
|
|
|
|
|
Hi,
I am using CFormView and there is a situation where 2 ActiveX controls overlap
one on the other.
My problem is the first ActiveX control which is below the other is refreshed
every 1 second, due to this the second control which is on top gets hidden.
As I have used CRectTracker on the second control, the tracker gets erased.
What do I need to do so that the first control which is below the second control, gets clipped by the second control.
Thanks,
Sansky
John 3:16
For God so loved the world,
that he gave his only begotten Son ( Jesus Christ ) ,
that whosoever believeth in him should not perish, but have everlasting life.
|
|
|
|
|
Hi,
I have to read from very large files (> GBytes) and parse it (MPEG data, trick modes: FFW/FRw)in "real time" (about 10 MByte/S) on Windows XP system. In some cases I have to read and parse it forwards and in other cases i have to read it starting at the enf of the file and parse it backwarts. I did it in C++ and MFC. I have used the CFile class. In both cases I read small portions (about 64k) from the file, move it into a ringbuffer for later parsing.In the case of forward this works fine.
Backwards I jump back a specific length and read/move that portion of data into the ringbuffer. Repeating this steps i walk backwarts the file in 64k steps.
In the case of small files or for some seconds (dependante on system memory) this works also fine.
But in opposite to forward the system cache seems to increase dramaticaly. At a certain time the sytem starts pageing all other applications in the memory, what causes the system reaction time to become very slow and the reading stream from the file is interrupted.
It seems to me that the cache manager is not optimized to read from a file in backward direction.
Are there any ideas or experiences out there how i can handle reading backwards in a file in "real time" ??
Is there anything i can do, that the cache manager understands that i am walking backwarts ..
Thanks a lot for your help.
Eddie
|
|
|
|
|
I'd try doing this using a Memory Mapped File, which theoretically should give much better results, and far simpiler code.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Memory Mapped File, definitely the way to go, its just like a portion of memory then, you can read forward, back even jump through hoops and its still fast .
Alan.
|
|
|
|
|
There are two basic 'hints' you can specify to CreateFile to tell Windows how you intend to manipulate the file.
Specifying no hint indicates to Windows that you mostly intend to read the file forwards. This is what you have at the moment. It will perform some asynchronous read-ahead from the file, and drop the cache mappings fairly quickly after each read. When it does drop them, it adds the physical memory pages to the tail of the list of free pages, so if it needs to reload them again, it doesn't need to reload from disk unless the pages have actually been reused.
Windows actually tries to interpret your read pattern and guess where the next read might occur.
If you use the FILE_FLAG_RANDOM_ACCESS flag, read-ahead is inhibited, and the cache manager is less aggressive about unmapping recently used sections.
Finally, I'll quickly mention FILE_FLAG_SEQUENTIAL_SCAN where the cache manager assumes that you're reading the file from end to end, never going back, and so adds unmapped cache data to the head, not the tail, of the free list so it gets reused quickly.
In order to be able to pass the FILE_FLAG_RANDOM_ACCESS flag, you'll need to subclass CFile .
More complete information in Inside Windows 2000 from MS Press (Solomon & Russinovich).
|
|
|
|
|
Thanks for your hints,
I tried FILE_FLAG_RANDOM_ACCESS from CFile. There was the possibility to use that flag at the CFile constructor.
(CFile::osRandomAccess See FILE_FLAG_RANDOM_ACCESS in CreateFile in the Platform SDK)
But this was not enougth, the memory consumtion still increase.
So I use the FILE_FLAG_NO_BUFFERING flag to bypass the Cache Manager at all.
(CFile::osNoBuffer See FILE_FLAG_NO_BUFFERING in CreateFile in the Platform SDK). After I did some additional tuning on my rinbuffers this seems to be the solution. Memory usage keeps nearly constant and the transfe-rate is enough to do real time parsing on the mpeg stream.
Thanks for all your comments,
Eddie
|
|
|
|
|
I kept a CListCtrl in my application and inserting columns by picking up column captions
by parsing from a flat file . The problem is InsertColumn method is inserting a cloumn but not displaying column caption ?? Rest of the columns are fine and no pronlem with Inserting items.
How to get the first coulmn name displayed??
thanks in advance
Warm Regards,
KKRam
|
|
|
|
|
Use the LVCFMT_LEFT attribute while inserting headings, and also give the correct width required for the column to display the heading.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Thanks Jagadeesh,
I am done with that CListCtrl using that Attribute.,
Warm Regards,
KKR
|
|
|
|
|
I've looked thru as many articles as I could find on the subject of bitmaps and I still cannot find how to make a composite bitmap from a few individual ones. I want to do this in a memory dc then when finished adding each bitmap, bitblt the single one to the screen dc. My goal is to reduce or eliminate flickering and ,yes, I know about double buffering but everthing I read was blitting 1 single bitmap not multiple ones.
Basically, I have one large (400x550 pixels) background bitmap and about 38 smaller (30x150) bitmaps that I am layering over the background one. I have lots of flickering. So I thought that if I could combine all bitmaps into one single memory dc then blit to screen dc I would greatly reduce flicker.
Am I or dreaming??
Manufacturing Software Developer
|
|
|
|
|
You can create a new DC which is compatible with your application DC using CreateCompatibleDC( ... ). Then you can do all your layering operations in this newly created DC, and when your are finished, you can BitBlt the newly created DC to your application DC. This can certainly avoid the flickering you are talking about.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Yes, that was it exactly. I feel like an idiot because of how simple the solution was. Actually, just after I sent off this question I experimenting with the method that you ended up suggesting. I created a new memory DC, bitblt'd with SCRCOPY each bitmap into that same memory space. Then, finally, bitblt SCRCOPY the memory DC to the screen DC. It worked fine. There was no flickering.
I tend to exhaust all other means of possible solution paths before using common sense!
Thanks!
Manufacturing Software Developer
Hewlett-Packard Company
|
|
|
|
|
Where in VC++.NET do I change the name of the exe file? Thanks.
Matt (Padawan Learner)
|
|
|
|
|
Its in the project settings, in the Link section.. isn't it ?
Just trying to remember off the top of my tiny head.
|
|
|
|
|
Got it. Thanks.
Matt (Padawan Learner)
|
|
|
|
|
Please Tell me How to search and operate a device,such as USB device?
Use the functions such as "SetupDiClassDev() etc.," need GUID,and How can I Get GUID use windows'API functions?
I Use Windows XP OS.
Thanks.
ST!!
Njbull
Sep.12/2003,Beijing
|
|
|
|
|
I need to draw a selection box in a real time video. This box is created when i pressed the left mouse button and drag the outline of the box. However since my codes are not in MFC, i do not know of any way to draw this box.. Can anyone help??
|
|
|
|
|