|
is the event being created??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I think your best way of implementing this is to make new threads for each client connection.
Then, within the read thread, you can have a loop similar to this, which consumes negligible CPU time:-
WSAEVENT event;
WSANETWORKEVENTS netevents;
event = WSACreateEvent();
WSAEventSelect(s, event, FD_READ | FD_CLOSE);
DWORD result, lIdleTimeout;
lIdleTimeout=0
while (TRUE)
{
result = WSAWaitForMultipleEvents(1, &event, FALSE, 100, FALSE);
if (result == WSA_WAIT_TIMEOUT)
{
if (++lIdleTimeout > IDLE_CONNECTION_TIMEOUT)
{
closesocket(s);
return FALSE;
}
continue;
}
lIdleTimeout=0;
WSAEnumNetworkEvents(s, event, &netevents);
if (netevents.lNetworkEvents & FD_CLOSE) {
printf ("socket closed\n");
return TRUE;
}
if (netevents.lNetworkEvents & FD_READ) {
continue;
}
}
The key here is that WSAWaitForMultipleEvents() is very very lightweight. This example was for a connection thread for a server type socket, but implementing a similar theory in a client socket is simple.
Signature space for rent. Apply by email to....
|
|
|
|
|
Thanks.
The wait function (single) I use works well. I am just having a problem closing the handle of the event object.
Kuphryn
|
|
|
|
|
What is the message that a dialog receives when you bring another application on top of it?
|
|
|
|
|
There are most likely several; use Spy++ to find the ones you want. If the dialog was previously active, you'll most likely get WM_KILLFOCUS , WM_ACTIVATE , and possibly WM_ACTIVATEAPP .
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
Hello friends,
i would like to catch the WM_SET_TEXT message in an CEdit derived class.
My Function "OnSetText" is called (by Win/framework), but now is my problem: how can i set
the text of the control myself in my function?
When i use SetWindowText, i "call" my own function recursive..!
Thank you very much for your help!
Fiffi
|
|
|
|
|
um....set a flag when you start the recursion and if flag is set then don't recurse and clear the flag??? that's a guess
or on the OnSetText in your class, start a timer (perhaps using flag approach above) and then set the text on the timer call??
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Hello RedZenBird,
I don't would like to call the function recursive!
The command SetWindowText send the WM_SET_TEXT message to windowses to set her text. I would like to catch that message in my CEdit derived class/control (That part is done and OK).
But i would like to the the text in my WM_SET_TEXT-message-handler-function.
When i use SetWindowText my function calls recursive herself!
My question: How can i set the window text without SetWindowText/WM_SET_TEXT ?
(Sorry for my bad english!)
Fiffi
|
|
|
|
|
The point RedZenBird was trying to make is that you need to have a situation where OnSetText can do nothing if not appropriate:-
class CYourEditCtrl
{
protected:
BOOL bTextSet;
.....
}
void CYourEditCtrl::OnSetText( ... )
{
if (bTextSet) {
bTextSet = FALSE;
return;
}
bTextSet=TRUE;
SetText(....);
return;
}
Signature space for rent. Apply by email to....
|
|
|
|
|
Have you tried calling Default()?
Do you need to trap WM_SETTEXT, or would one of the EN_ messages do what you want?
Steve S
[This signature space available for rent]
|
|
|
|
|
You've subclassed an Edit control, and are receiving the WM_SETTEXT message. This message is sent to the control in order to change the text; it is the only (safe) way to accomplish this for an Edit control. So, you simply need to call the original window procedure.
If you are not modifying the text specified in the message, you can just call CEdit:OnSetText() or CWnd::Default() - both of these will call the origial Edit control procedure with the original message parameters.
If you *are* modifying the text, you will need to call CWnd::DefWindowProc() and pass in WM_SETTEXT for the message parameter, 0 for the second parameter (wparam), and a pointer to the string as the last parameter (lparam). Note that this method is not the same as ::DefWindowProc() , as it will call the original window procedure if the window was subclassed.
Have fun!
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
Hello friends,
Thank you very much for you help!
I begin with try/test...
Fiffi
|
|
|
|
|
I'm trying to change the value of a transfer var in a drop down list. The value that is selected is 10 off as my indexs start at 10 and go up instead of 0. So I have been trying to add 10 to this variable but it just won't take.
Help@!
|
|
|
|
|
First, you need to post some code. The following phrases in your description are a little hard to understand:
"indexs start and 10 and go up"
"it just won't take"
Item indices in a combo box control start at 0, and increase to the number of items in the list (minus 1). Period. If you need the selection index to be treated in some other way, you will have to apply that difference each time you retrieve the selection index from the combo box.
Since you are using a 'transfer var', I'll assume you are using MFC's DDX/DDV in a dialog box. Transfer variables are set from the dialog controls each time you call UpdateData(FALSE) . Every time you call UpdateData(FALSE) , your transfer variable is going to be set to the selection index of the combo box control, regardless of whatever was in the variable beforehand. So, if your transfer variable is m_xfer , and the 4th item in the combo box is selected, then:
m_xfer = 123456;
UpdateData(FALSE);
TRACE("m_xfer = %d\r\n",m_xfer); will display
m_xfer = 3 in the Output window.
Gary R. Wheeler
|
|
|
|
|
Is there a limit on the amount of timer's I can have running in an application, and how much overhead will there be in these timer events? I'm thinking about using up to 1000 timers in a window or even up to 2000 timers if two instances of the window are open.
I will set the timers to intervals of about 4 or 4.2 seconds and they will not all go off at the same time but that's about 250 (or 500) timer events per second in my worst case scenario.
Any thoughts? I could provide more details if needed.
|
|
|
|
|
Have you tried this? Something about having a thousand timers firing (even if it were possible) sounds a bit freakish to me....Can't you have a single timer fire and then use that timer event to 'fire other internal events' in your process?
For example, one app I've written uses an sorted array of "timed tasks" and then on every timer tick it increments the "array slot" for the tasks to be fired at that timer tick and fires each of them....I don't know if this concept works in your design....but I daresay you may wanna reconsider your timer strategy....
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Ok, here's the problem. I'm trying to make a simple radar type display, called a PPI. This one is different from most we've done previously, in that when you draw a target on the PPI, I do not want to see where the target's location was on the previous (radar) scan. Thus, I need to erase the target's location for the last scan before I draw the target's new location for the current scan. Also, keep in mind that some targets do not move but may disappear after several scans.
Now, in the past we just drew a target for say scan number n and then at scan number n+20, we would have a 20 target history onscreen since we did not erase the previous locations.
Now, I could probably do it with one timer but I was trying to make this simple. There are probably several approaches to doing this but tracking the targets, i.e. keeping track of their position from scan to scan and then correlating those targets from the current scan to the previous scan, is not simple. So, I thought if I made my target symbols intelligient with each one having its own timer, then it would erase itself (or make itself not visible) before being redrawn in the current scan being processed. The timer would go off just about the time when the next scan's data was being drawn in about the same location. Thus, the user would see targets from a previous scan for a select area disappear and then the updated (new) target being drawn within say .2 seconds.
As I said there are several ways of doing this, one approach would be to redraw all of the targets (XOR them so they erase) from the previous scan and then draw the new targets from the current scan but the problem with this is that radars take 4.6 seconds per scan (some are 10 and 12 second scans). Thus, I would have a blank display until the updated positions for these targets are drawn. Unacceptable.
If I want to make it smooth it requires some form of tracking. But, I want something simple. I hope this makes sense. The reason I thought the timers might work is because Direct3D or DirectDraw has something built into it that does something similar. e.g. U have a car or robot and you want it to move in some direction at some rate of speed.
|
|
|
|
|
Well, I think you are on the right track to have the targets be smart enough to erase/paint themselves.
Now, then, your question about having each object have a timer is still relevant. What I think we are trying to say to you is: instead of having each target have a timer that fires, consider:
1. Have a single timer ( 500 ms , 1 sec, whatever nyquist related rate you like )
2. Put all the target objects into some kind of prioritized collection.
3. Put a "timer_fired" method on each of the target objects.
4. When the single timer fires, have a smidge of logic that will determine where in the prioritized collection should be triggered by the timer event.
5. Inove the "timer_fired" method on each object stored at that location in the priority collecton.
Make sense?
Hope that helps.....
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Ok. I discussed this with another guy and we came up with a solution that only uses one timer. It's similar to what you are suggesting.
Basically, I will know the scan rate of the radar and create/set a timer that is 1/72th of the scan rate. This will allow me to categorize targets into 5 degree wedges. I will save what targets belong in what wedge and when the timer event fires, I will tell the targets in that wedge (container) to erase themselves.
Thanks for the suggestions. It's good to have somebody to talk to about stuff before you implement it.
|
|
|
|
|
As RedZenBird noted, 1000 timers is rather a lot. Given that normal timers are not particularly acurate or reliable, you may want to re-think this a bit; perhaps just keep a sorted queue of actions, and trigger them as their times come around (use one timer to periodically check the time).
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
Hi there,
I'm having problem displaying a dialogbox. Here's the scenario.
1. I've an asynchronous function. CAsyncSocket::OnReceive()
2. In OnReceive(), I'm receiving some data from in a buffer.
3. And I'm trying to display the contents of the buffer in the dialogbox. So, I'm calling the Dialogbox's class's DoModal() inside the OnReceive() fn. It fails when DoModal() is invoked.... gives me access violation 00005. I know it has to do with sending a notification message to my dialog to inform that's ready... but I'm unsure about doing it so. Any ideas, clues, suggestions, thougths?
MyClass::OnReceive() //asyn. function, invoked if the
//socket has some data in it.
{
ar.Read(buf, 4095); //ar is CArchive instance
MyDialog dlg;
dlg.DoModal(); //fails right here, I think I've to
// send teh parent dialog some
// message and set the input focus?
}
Very much appreciated
JJ
|
|
|
|
|
Hi all,
I have a win32 application which I run with two integer arguments.
I can see under debugging that these arguments are held in "lpCmdLine" parameter of "WinMain" routine as a string.
Now I want to change these two arguments to integer values so that I can use later in the rest of the program.
Is there anyone who have written code which do the above?
thanks in advance
regards
/rsasalm
|
|
|
|
|
look up strtok() and atoi() in msdn.
Signature space for rent. Apply by email to....
|
|
|
|
|
Stupid question, perhaps, but....
If I were to want to use #define to define a set of characters/string instead of a number, is there anything particular I have to go through it?
In other words, I'm going to be using a specific set of strings to begin and end a number of strings I am concatenating, and I figured that using #define would be the best way to go.
However, I've only used #define for numbers before, and I wasn't sure if #define could even use other types, or for that matter if typecasting was necessary.
I was starting to write:
#define xmlBeginStatement "<" //plus other stuff
and then wondered if I had to do either:
#define xmlBeginStatement char "<"
or something else like that. And my darned reference manuals say nothing about it.
Thanks!
James A Beggs
Microsoft MSN Mobile Component Test Team
|
|
|
|
|
#define is a preprocessor job, it simply defines text to replace in source code before it's passed to compiler. It does know nothing about types.
Pavel
Sonork 100.15206
|
|
|
|