|
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
|
|
|
|
|
Yeah! He's right. This code:
#define XXX void function(int r)
static XXX
{
}
will be seen by the comiler as:
static void function(int r)
{
}
You can write anything after #define
Ñ There is only one MP Ð
|
|
|
|
|
why not consider:
const char xmlBeginStatement[] = "<";
some would consider it be be 'better form'.......
Just trying to keep the forces of entropy at bay
|
|
|
|
|
I did. I had decided on using defines at the time. I'm certainly not married to it, however.
|
|
|
|
|
Meyer's will argue that using const definitions over #define is the way to go...I agree with him....
Just trying to keep the forces of entropy at bay
|
|
|
|
|
|
how about INT_MAX? It's defined in limits.h
|
|
|
|
|
if you do a search for LARGE_INTEGER in the index of MSDN, you will find its entry. Here's the brief:
The LARGE_INTEGER structure is used to represent a 64-bit signed integer value.
Header: Declared in Winnt.h; include Windows.h.
|
|
|
|
|
It's defined in winnt.h
#if defined(MIDL_PASS)
typedef struct _LARGE_INTEGER {
#else // MIDL_PASS
typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
};
struct {
DWORD LowPart;
LONG HighPart;
} u;
#endif //MIDL_PASS
LONGLONG QuadPart;
} LARGE_INTEGER;
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
|
I have looked through all the postings on this website and no one seems to have a reasonable answer to the question of using a container and microsoft word. And I am going to post the question, hopefully someone will have a useful idea. I am using VC++ 6.0 and I am trying to create a COM exe or dll. This is what I am doing: I am creating a frame window and automatically opening an ms word document so basically, it is a container window for microsoft word. This part I can get to work but there are some problems. Why are there several toolbar buttons disabled? How can I enabled them? Why does the print/print preview not work? I am not using ATL (and I prefer not too). Also, if I add a menu option of my own, how do I know when the user has selected my menu option? I have researched this through this website and MSDN and I am doing everything that was suggested. But it still isn't working. I have seen similar posting but all the answers have been things like "have you tried to record a macro through VB." and such, things that really don't help. CAN ANYONE OUT THERE HELP ME??????? IS THIS AN INFINITE PROBLEM THAT ONLY MICROSOFT CAN SOLVE??????? IS IT HOPELESS????
|
|
|
|
|
I wouldn't think print preview would work when word in embeded. That should be up to the main application.
Todd Smith
|
|
|
|
|
Actually, MSDN and a few posting suggest doing this:
BOOL CXOfficeView::OnPreparePrinting(CPrintInfo* pInfo)
{
if (!CView::DoPreparePrinting(pInfo))
return FALSE;
if (!COleDocObjectItem::OnPreparePrinting(this, pInfo))
return FALSE;
return TRUE;
}
According to most of the documentation, this should work because print preview would call the print. This doesn't work.
Also, what about the standard print, it doesn't work. And the toolbar buttons!
|
|
|
|