|
Rajib Podder wrote: i am facing problem while trying to attach a colored(32x32) .ico file at title bar of a window.
As far as I know, the icons in the title bar are 16x16.
If you use file explorer to browse the directory with your exe, you will probably see the 32x32 icon if you select that kind of view in explorer.
Rajib Podder wrote: CAN SOMEBODY PLZ HELP ME WETHER I AM MISSING SOME STEPS.
OR IS THERE OTHER WAY?????
Please don't shout in the forums.
Read the guidelines[^], especially item #6.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
hi,
as i have already...informed that i have the .res file containing the .ico file.
Now my question is that how can i attach the icon inside my application.
I have already described about my application.
or
please let mr know..if there are any other way out???????????????
|
|
|
|
|
Rajib Podder wrote: i am facing problem while trying to attach a colored(32x32) .ico file at title bar of a window
...
the icon is missing
Roger Stoltz wrote: the icons in the title bar are 16x16
Rajib Podder wrote: how can i attach the icon inside my application
As I have already...informed you can't since your icon has the wrong format.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Is ther any other alternative.
Can i attach any image?
if so,Please let me know the procedure
|
|
|
|
|
Hallo,
i have the following code:
void CTest_MyDocumentDoc::Print_Output()
{
m_ptrOutput->Invalidate (true);// m_ptrOutput= (CRichEditView *) m_wndSplitter.GetPane(1,0);
m_ptrOutput->UpdateWindow();
UpdateAllViews(NULL);
}
i have splitted SDI-appliction and i need to call OnDraw() indirectly to print / draw my results in the second part of my splitted sdi App., this code does not work , the OnDraw() does NOT be called ??
|
|
|
|
|
Don't do it that way. Put your code to draw the window in a separate method and call that method from both OnDraw and Print_Output, passing a suitable DC in both cases.
So, if you call it "DrawView", OnDraw would call DrawView, as would Print_Output.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i tried to do it that way before, but i did not have any text drawen on the monitor, i am forced to do it that way, and how can i get a suitable DC ?
please explain in code . thanks
|
|
|
|
|
susanne1 wrote: a suitable DC
OnDraw[^] gives you a screen DC
CPrintDialog/CPrintDialogEx can be used to create printer DCs, if you aren't going to follow the standard MFC printing mechanisms.
So in each case, you have a way of calling your 'draw' code with a suitable DC.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
write now i got every folder mails like for outbox, I used "PR_IPM_OUTBOX_entryid". Like this I got mails from every folder except from junk mail. What is id for junk mail
plz reply, thanks in advance.
sampath-padamatinti
|
|
|
|
|
Hi All,
i am using xmlhttp to fetch data from the server, now i have issue that i am fetching multiple pages one by one for the session, but with some pages i am getting this "Sorry, there are no results for the adjustments that you have selected" in response but data is available in the live environment, i think that i have to use time delay among request but i am not sure what exactly i am missing....please provide some ideas.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
The reason you're not getting results back is probably more to do with the server-side software than with your use of XMLHTTP.
Very difficult to say when you've provided virtually no information.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Good morning ,
just a brief question.
I got a multi-threaded program. Now is it possible to ensure that a certain thread at a certain point won´t lose its 'working permission'.
Hm, don´t know if I expressed that correctly.
I have a thread going into a function where it has to wait for a previously defined time, then go on. The thing is, it waits and waits and at some point its time slot is taken away. When it is given the next slot, though, the time it has waited for has 'long' passed. And thus it´s always too late.
The code in question is:
int RTPEngine::SendRTPPacket( BYTE* data, int size )
{
if( data && size > 0 && m_pHeader )
{
m_pLogger->Out(Logger::DEBUG, "RTPEngine: Sending data package with size %d (excluding header).\n", size);
BYTE* packet = new BYTE[size+12];
BYTE* headerBytes = m_pHeader->GetInc();
for( int i = 0; i < 12; i++ )
{
packet[i] = headerBytes[i];
}
for( int i = 0; i < size; i++ )
{
packet[i+12] = data[i];
}
double now = 0.0;
if( m_dPacketSendTime != 0.0 )
{
now = ((double) clock() / CLK_TCK) * 1000;
int tmp = 0;
while( now <= m_dPacketSendTime )
{
if( tmp >= 20 )
{
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Time now = %f, send time = %f.\n", now, m_dPacketSendTime );
tmp = 0;
}
tmp++;
now = ((double) clock() / CLK_TCK) * 1000;
}
}
now = ((double) clock() / CLK_TCK) * 1000;
int rc=sendto(m_oUDPSocket,(char*)packet,size+12,0,(SOCKADDR*)&m_oUDPAddress,sizeof(SOCKADDR_IN));
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Packet sent at = %f.\n", now );
m_dPacketSendTime = ((double) clock() / CLK_TCK) * 1000;
m_dPacketSendTime += (m_dPacketLengthMillis*(1.0 - m_dRTPOverlap));
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Next send time = %f.\n", m_dPacketSendTime );
return size;
}
else
return 0;
}
And one more thing is, on my Vista machine it works fine. The logger prints this:
RTPEngine: Next send time = 53637.795918.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
.
.
.
RTPEngine: Time now = 53636.000000, send time = 53637.795918.
RTPEngine: Time now = 53636.000000, send time = 53637.795918.
RTPEngine: Time now = 53637.000000, send time = 53637.795918.
RTPEngine: Time now = 53637.000000, send time = 53637.795918.
RTPEngine: Time now = 53637.000000, send time = 53637.795918.
RTPEngine: Packet sent at = 53638.000000.
On our server (XP) where it has to actually run later, it gives me this:
RTPEngine: Next send time = 53637.795918.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
.
.
.
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
RTPEngine: Time now = 53628.000000, send time = 53637.795918.
RTPEngine: Packet sent at = 53644.000000.
As you can see ... too late .
Any ideas?
Souldrift
modified on Friday, July 3, 2009 6:20 AM
|
|
|
|
|
Let me get my traditional admonition about Windows + real-time behaviour out of the way first - Windows is not anywhere near being a real-time OS, there's too much stuff going on, it has high interrupt latency etc etc. Ha, that's better.
Now - the one thing that may improve your situation is to increase the priority of your sending thread. Alternatively, you could use a different strategy - use a waitable timer[^], with a completion routine that sends the packet. Put the thread into an alertable wait state when you set the timer and the completion routine should get called by the timer.
The advantage of doing this is that the more your code is running, the more Windows will give a dynamic priority boost to other, similarly prioritised threads. If your code sleeps, that won't happen, and also, your system as a whole will be slightly more responsive.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the idea. I tried it (very exitedly). But I´m running into the same problem.
My new code is:
int RTPEngine::SendRTPPacket( BYTE* data, int size )
{
if( data && size > 0 && m_pHeader )
{
m_pLogger->Out(Logger::DEBUG, "RTPEngine: Sending data package with size %d (excluding header).\n", size);
BYTE* packet = new BYTE[size+12];
BYTE* headerBytes = m_pHeader->GetInc();
for( int i = 0; i < 12; i++ )
{
packet[i] = headerBytes[i];
}
for( int i = 0; i < size; i++ )
{
packet[i+12] = data[i];
}
double now = 0.0;
if( m_dPacketSendTime != 0.0 )
{
now = ((double) clock() / CLK_TCK) * 1000;
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Time now = %f.\n", now );
double dueMS = m_dPacketSendTime-now;
if( dueMS > 0 )
{
HANDLE hTimer = 0;
LARGE_INTEGER liDueTime;
hTimer = ::CreateWaitableTimer(0, TRUE, L"WaitableTimer");
liDueTime.QuadPart = -((int)dueMS * 10000);
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, FALSE);
::WaitForSingleObject(hTimer, INFINITE);
}
}
now = ((double) clock() / CLK_TCK) * 1000;
int rc=sendto(m_oUDPSocket,(char*)packet,size+12,0,(SOCKADDR*)&m_oUDPAddress,sizeof(SOCKADDR_IN));
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Packet sent at = %f.\n", now );
m_dPacketSendTime = ((double) clock() / CLK_TCK) * 1000;
m_dPacketSendTime += (m_dPacketLengthMillis*(1.0 - m_dRTPOverlap));
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Next send time = %f.\n", m_dPacketSendTime );
return size;
}
else
return 0;
}
I´m at a loss ...
Souldrift
Edit:
Actually I just found that this doesn´t work as expected. The output is:
RTPEngine: Next send time = 3009.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 3000.
RTPEngine: Packet sent at = 3000.
RTPEngine: Next send time = 3009.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 3000.
RTPEngine: Packet sent at = 3000.
RTPEngine: Next send time = 3009.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 3000.
RTPEngine: Packet sent at = 3000.
It doesn´t wait at all ??
modified on Friday, July 3, 2009 7:34 AM
|
|
|
|
|
The documentation for WaitForSingleObject[^] says this:
To enter an alertable wait state, use the WaitForSingleObjectEx[^] function
As I said, you need to be in an alertable wait state for your APC to be called.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Unfortunately that changes nothing
|
|
|
|
|
I put together a wee program demonstrating waitable timer usage:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
void ReportTime(const char* message, LONGLONG const& when)
{
std::cout << message << double(when)/10000.0 << std::endl;
}
VOID CALLBACK DoSendHere(__in_opt LPVOID lpArgToCompletionRoutine,
__in DWORD dwTimerLowValue,
__in DWORD dwTimerHighValue)
{
LARGE_INTEGER const& ftSleepStart = *(LARGE_INTEGER*)lpArgToCompletionRoutine;
LARGE_INTEGER liTimer;
liTimer.LowPart = dwTimerLowValue;
liTimer.HighPart = dwTimerHighValue;
ReportTime("DoSendHere::Timer slept for ", liTimer.QuadPart-ftSleepStart.QuadPart);
delete lpArgToCompletionRoutine;
}
int SendLoop()
{
LARGE_INTEGER ftStart;
GetSystemTimeAsFileTime((FILETIME*)&ftStart);
HANDLE hTimer = 0;
hTimer = ::CreateWaitableTimer(0, TRUE, L"WaitableTimer");
LARGE_INTEGER ftNow;
LARGE_INTEGER ftWaitTill;
GetSystemTimeAsFileTime((FILETIME*)&ftNow);
while(1)
{
ReportTime("SendLoop::Now = ", ftNow.QuadPart-ftStart.QuadPart);
ftWaitTill.QuadPart = ftNow.QuadPart + 5000000I64;
SetWaitableTimer(hTimer, &ftWaitTill, 0, &DoSendHere, new LARGE_INTEGER(ftNow), FALSE);
ftNow = ftWaitTill;
::SleepEx(INFINITE, TRUE);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
SendLoop();
return 0;
}
This is intended to set a timer for 500ms in the future and sleep until the timer's triggered, at which point a) the completion routine is called, and b) the SleepEx call exits.
I get this output (on Windows XP SP 3):
SendLoop::Now = 0
DoSendHere::Timer slept for 499.978
SendLoop::Now = 500
DoSendHere::Timer slept for 499.955
SendLoop::Now = 1000
DoSendHere::Timer slept for 499.933
SendLoop::Now = 1500
DoSendHere::Timer slept for 499.91
SendLoop::Now = 2000
DoSendHere::Timer slept for 499.888
SendLoop::Now = 2500
DoSendHere::Timer slept for 499.866
SendLoop::Now = 3000
DoSendHere::Timer slept for 499.843
SendLoop::Now = 3500
DoSendHere::Timer slept for 499.821
SendLoop::Now = 4000
DoSendHere::Timer slept for 499.798
SendLoop::Now = 4500
DoSendHere::Timer slept for 499.776
SendLoop::Now = 5000
DoSendHere::Timer slept for 499.754
SendLoop::Now = 5500
DoSendHere::Timer slept for 499.731
SendLoop::Now = 6000
DoSendHere::Timer slept for 499.709
SendLoop::Now = 6500
DoSendHere::Timer slept for 499.686
SendLoop::Now = 7000
DoSendHere::Timer slept for 515.288
SendLoop::Now = 7500
DoSendHere::Timer slept for 499.642
You can see that the timer triggers approximately 40 microseconds before the due time. This is interrupted when the processor's busy (for example, when I rebuild the software), as shown by the sleep period of 515ms. This is because Windows will not interrupt an active thread when signalled - so your time could be delayed by as much as a time-slice quantum.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for that. I highly appreciate you getting into this so much.
I all but copied your code and it works on my machine. But as soon as I put it on our server machine, the ol´ troublemakers show up again. I set a sleep time of appx. 10ms and usually the thing sleeps the day away ... well, 15 ms .
The output in my case is
RTPEngine: Next send time = 12891106961478.547000.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 12891106961468.750000.
DoSendHere::Timer slept for 15.625000
RTPEngine: Packet sent at = 12891106961484.375000.
RTPEngine: Next send time = 12891106961494.172000.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 12891106961484.375000.
DoSendHere::Timer slept for 0.000000
RTPEngine: Packet sent at = 12891106961484.375000.
RTPEngine: Next send time = 12891106961494.172000.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 12891106961484.375000.
DoSendHere::Timer slept for 15.625000
RTPEngine: Packet sent at = 12891106961500.000000.
RTPEngine: Next send time = 12891106961509.797000.
JobManager: Job 0_0 processed packet with size 2048. Packets available: 67
RTPEngine: Preparing to send data bundle with size of 1520 bytes.
RTPEngine: Adding leftover (352 bytes).
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 12891106961500.000000.
DoSendHere::Timer slept for 15.625000
RTPEngine: Packet sent at = 12891106961515.625000.
RTPEngine: Next send time = 12891106961525.422000.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Time now = 12891106961515.625000.
DoSendHere::Timer slept for 15.625000
RTPEngine: Packet sent at = 12891106961531.250000.
What bugs me even more than that (as seen in the output) is that the Timer sometimes sleeps for 0 ms even though it should wait.
Looking into it ... might be something with threads and time-slices, after all.
Souldrift
|
|
|
|
|
As Stuart already stated - windows is not a real-time operating system.
You might find this article[^] on the subject interesting.
However, I'm curious about why you need to send data with such accuracy you seem to be aiming for. Since you're using UDP sockets there's always going to be some kind of network latency that you cannot do anything about and it may not be the same for each packet sent.
It seems to me as if this is about RTP, i.e. Real-time Transport Protocol, since the name of your class is RTPEngine .
If this is the case then you shouldn't have to worry about timing when sending the data. Every RTP-packet has a timestamp that the receiver should use in order to figure out when the media data in the packet should be played.
Read more about RTP here[^].
If you cannot make use of the timestamp in the RTP-packets, or if this is really not about RTP, I'd try the following:- Create a sending worker thread that reads data packets from a queue, e.g.
std::queue ; the packets are added to the queue by another thread, probably the main thread. - The sending thread waits on a semaphore, with e.g.
::WaitForMultipleObjects() , that is released once for each packet added to the queue. The trick here is that a thread waiting on a synchronization object, such as a semaphore, gets a temporary priority boost when the object is signalled which means that it will be scheduled to run ASAP. - Each data packet has a waitable timer created and set by the thread that adds the packets to the queue. The sending thread then waits on the timer and sends the data when that the timer is signalled.
I would create a class that represents a packet with a waitable timer as a member. I would also use reference counting smart pointers that reflects the data packets as elements of the queue; this way I don't have to worry about writing cleaning up code in my sending thread. When the object goes out of scope everything is released - heap and waitable timers.
For more information on worker threads - read this[^].
For more information on reference counting smart pointer - read this[^] and some examples here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
The reason is not so much the exact timing but the available memory on the other side.
The receiving end is not another computer but a phone. Its an audio stream from a tts-server.
And the phone has only limited capacity so we cannot simply flood it since the sending end works much much faster than the processing of the stream at the receiving end. Therefor we wanted to build in something like a brake. That´s what the variable RTPOverlap is for. At the moment at a value of 10% (0.1). So the sending time of each RTP packet only overlaps with the previous one by about 10%. And these 10 percent are calculated from the playback time that one packet actually needs. Which is about 10ms for an RTP packet of 480 bytes. Meaning we send one packet and then the next comes after 9ms and so on.
Only ... it doesn´t work.
And of course I already have a 'sending worker'. The synthesizer of the tts-server works very fast. So I store the synthesized packages in one class like a scheduler and send them piece by piece away.
By the way, I am familiar with (no specialist, but I´ll find my way around) worker threads and smart pointers and RTP. I´ll look into your links now, anyway .. thanks so far.
Souldrift
|
|
|
|
|
It could be the use of the clock() function; on your XP machine it seems to have a much coarser granularity as the time isn't changing at all in the loop. I always use GetTickCount() for millisecond timing - you can work with integers and don't have to bother doing any division. It's never going to be accurate to a millisecond though; I tried a similar loop on my system and only got a different value about every 15 ms even though I was continually calling the function.
|
|
|
|
|
I don´t think so anymore. I now work with FILETIME (see code from Stuart Dootson). And I still got the same trouble.
Souldrift
|
|
|
|
|
I just found something else. A little disturbing. On our server machine (WIN XP) the Timer ALWAYS sleeps for 15.625ms. If it goes to sleep at all, that is. So this seems to be some kind of minimum time-slice (or a multiplied version of it).
On my own developing computer (Vista) I don´t have theis kind of time-slices. The Timer sleeps for 9ms, then for 10ms and thereafter for 8ms.
Does anybody now if one can manually control these time-slices?
Souldrift
|
|
|
|
|
There's some references on the web to the minimum timer period being 10 ms for uniprocessor systems and 15 ms for multiprocessor. It could also be different depending on whether it's 32 or 64 bit Windows.
The minimum on my system seems to be 15 ms - that's on Vista 32-bit with a dual-core processor.
|
|
|
|
|
Yeah, this would make our efforts kind of hopeless.
But I just found out another little something. It doesn´t seem to be a Vista-XP-thing. But a network-thing. Whatever computer I use as a server, as long as the client comes in via network, the timer sleeps like 15.something millis. If server and client are on the same machine, there doesn´t seem to be a minimum time-slice (or it´s below what I saw so far). The timer sleeps as long (or brief) as I want.
Souldrift
|
|
|
|
|