|
As Zac mentioned, show only the relevant code. All that extraneous code just gets in the way. Formatting your code with <pre> tags goes a long way, too.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
RTI::AttributeHandleValuePairSet* Ball::createNVPSet()
{
RTI::AttributeHandleValuePairSet* pBallAttributes = NULL;
if ( ms_rtiAmb )
{
pBallAttributes = RTI::AttributeSetFactory::create( 4 );
pBallAttributes->add( Ball::ms_ballLocationXId,
(char*)&this->m_currentState.x,
sizeof(double) );
pBallAttributes->add( Ball::ms_ballLocationYId,
(char*)&this->m_currentState.y,
sizeof(double) );
pBallAttributes->add( Ball::ms_ballVelocityXId,
(char*)&this->m_currentState.vx,
sizeof(double) );
pBallAttributes->add( Ball::ms_ballVelocityYId,
(char*)&this->m_currentState.vy,
sizeof(double) );
}
return pBallAttributes;
}
void Ball::sendUpdate()
{
if ( m_nextStateCalculated == RTI::RTI_TRUE )
{
m_currentState = m_nextState;
m_nextStateCalculated = RTI::RTI_FALSE;
try
{
RTI::AttributeHandleValuePairSet* pNvpSet = createNVPSet();
(void) ms_rtiAmb->updateAttributeValues( getInstanceId(),
*pNvpSet,
NULL );
pNvpSet->empty();
delete pNvpSet;
}
catch ( RTI::Exception& e )
{
cerr << "BALL: Error:" << &e << endl;
}
}
}
void Ball::update(
RTI::InteractionClassHandle theInteraction,
const RTI::ParameterHandleValuePairSet& theParameters )
{
if (ms_rtiAmb)
{
if ( theInteraction == Ball::ms_clockTickId )
{
RTI::ParameterHandle paramHandle;
RTI::ULong valueLength;
for ( unsigned int i = 0; i < theParameters.size(); i++ )
{
paramHandle = theParameters.getHandle( i );
if ( paramHandle == Ball::ms_clockTickIntervalId )
{
double timeInterval = 1 / 60.0;
theParameters.getValue( i, (char*)&timeInterval, valueLength );
for ( unsigned int j = 0; j < ms_numInstances; j++ )
{
( *( (Ball*)(ms_instances[j]) ) ).m_stateTimeInterval = timeInterval;
}
}
else if ( paramHandle == Ball::ms_clockTickNumId )
{
}
else if ( paramHandle == Ball::ms_clockTickTimeId )
{
}
else
{
cerr << "BALL: Error: I seem to have received a parameter for "
<< "interaction class ClockTick that I don't "
<< "know about." << endl;
}
}
Ball* pBall;
for ( unsigned int k = 0; k < ms_numInstances; k++ )
{
cout << "BALL: Iterating through all Balls." << endl;
pBall = (Ball*)ms_instances[ k ];
if ( pBall->m_nextStateCalculated == RTI::RTI_TRUE )
{
pBall->m_currentState = pBall->m_nextState;
pBall->m_nextStateCalculated = RTI::RTI_FALSE;
try
{
cout << "BALL: Creating NVP set." << endl;
RTI::AttributeHandleValuePairSet* pNvpSet = pBall->createNVPSet();
cout << "BALL: Sending new ball state out into the world." << endl;
(void) ms_rtiAmb->updateAttributeValues( pBall->getInstanceId(),
*pNvpSet,
NULL );
pNvpSet->empty();
delete pNvpSet;
}
catch ( RTI::Exception& e )
{
cerr << "BALL: Error:" << &e << endl;
}
}
else
{
cerr << "BALL: Next state not ready." << endl;
}
}
}
else
{
cerr << "BALL: Recieved an interaction class I don't know about." << endl;
}
}
}
|
|
|
|
|
|
it does actually...... does
take away the preprocessor statements
|
|
|
|
|
The call in the sendUpdate method is operating on only the current Ball object.
The call in the update method is operating on a Ball object that was contained in the array it is iterating through.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hey I need some help with trying to get a feature working.
What I have and what I'm trying to do:
I have a IE Toolbar derived from CCommandBarCtrlImpl (CCommandBarCtrlBase), this toolbar of course has several buttons and several of those buttons are of the dropdown type. On TBN_DROPDOWN the appropriate popupmenu is created as such
[code]
CMenu menuPopup;
menuPopup.CreatePopupMenu();
int items = 0;
for(unsigned int j=0;j<m_menu.m_items.size();j++)
{
="" if(m_menu.m_items[j]-="">shouldShow())
{
m_menu.m_items[j]->appendMenu(ctrl,(CMenuHandle)menuPopup,items,m_id);
items++;
}
}
m_globalReadyState=false;
DWORD dwThread=GetCurrentThreadId();
hSelectHook=SetWindowsHookEx(WH_CALLWNDPROC,SelectHook,NULL,dwThread);
hClickHook=SetWindowsHookEx(WH_MSGFILTER,ClickHook,NULL,dwThread);
ctrl->cur_btn=m_id;
::TrackPopupMenu(menuPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, 0, wnd, NULL);
UnhookWindowsHookEx(hSelectHook);
UnhookWindowsHookEx(hClickHook);
m_globalReadyState=true;
ctrl->m_popup.clear();
for(j=0;j<m_menu.m_items.size();j++)
{
="" if(m_menu.m_items[j]-="">shouldShow())
{
m_menu.m_items[j]->FreeMenu();
}
}
menuPopup.DestroyMenu();
[/code]
This works fine, but something I noticed is that whenever a popupmenu is open (weather it's one I make or just some random one in IE) then the toolbarbuttons won't receive any mouseinput (eg their mouseover effects stop functioning).
Right now Im handling mouseover so that whenever a user moves the mouse over a button with a dropdown button the Menu is forcefully shown (by emulating a send to TBN_DROPDOWN (OnDropDown)). What I want is for the toolbar to still receive mouseinput whilst a popupmenu is open so that you can for example move the mouse over a button with a popupmenu the popupmenu pops up, if you move the mouse to the next button whilst the popupmenu is open that next button still receives the mouseover aka "Hot" effect and it should also close the open popupmenu, this is especially important if the next button has a popupmenu to, then the old should close, and the one corresponding to the next button should open!
I'm really stressed about this because it's the only thing left to fix and I am a tad unknowledgable about MFC since this source was bought in from someone else and just handed to me to modify i feel like a fish on land. Hopefully someone might be able to swiftly rescue me =)
Thanks in advance! =)
|
|
|
|
|
How do I change the height of a programatically? I also want to change the size of the resizable frame of a Window. How do I go about doing it?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
Do you need to customize titlebar from your application?
|
|
|
|
|
WhiteSky wrote: Do you need to customize titlebar from your application?
Yes!
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
See here[^] maybe it is some helpful to you and Im not sure but i think an example in codeguru
|
|
|
|
|
Hi everybody, i'm trying to get an answer to my question: How to display a dialog in SDI app that has a class derrived from CRecordView?
But no one seems willing to tell me, or i'm trying smt impossible?
|
|
|
|
|
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
ivanris wrote: But no one seems willing to tell me, or i'm trying smt impossible?
Perhaps you are asking in the wrong place.
|
|
|
|
|
ivanris wrote: But no one seems willing to tell me, or i'm trying smt impossible?
This is very easy to do but I am not allowed to answer it here.
[EDIT]
Wait a minute wasn't this question in the lounge? If not I appologize.
[/EDIT]
John Last modified: Mon Aug 28 09:54:58 2006 --
|
|
|
|
|
you know john, some people can move threads around here... sorry, it was not a UFO
|
|
|
|
|
You've been answered more than once, with the most recent being a mere three minutes ago. See here and here. What exactly do you not understand?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How to display a dialog in SDI app that has a class derrived from CRecordView?
|
|
|
|
|
ivanris wrote: How to display a dialog in SDI app that has a class derrived from CRecordView?
The same way you would any other dialog (e.g., DoModal() ). Having a CRecordView -derived view has no bearing on that.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How do i can shell a program hidden and i want my program to wait until the shelled program ends.
thanks.
|
|
|
|
|
that's a "hard-to-undeerstand" english...
what do you mean by "to shell a program" ?
also, please rephrase your question in a more lexical speaking...
|
|
|
|
|
Can you be more specific,Do you need to ShellExecute
|
|
|
|
|
Sina Parastgary wrote: shell a program hidden and i want my program to wait until the shelled program ends
I think that you are starting a process from your application that should run hidden in the background and also not show itself in the System Process list.
Am I right?
Sina Parastgary wrote: wait until the shelled program ends
Are you trying to achieve this in two different process?. If yes you can use a shared variable. When the value of that shared variable changes post a message from your application and ask the parent application to quit.
I think I am on the right track in understanding your statement...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
From what I understand you want to start a program using ShellExecute and wait for that 'shelled' program to end. If this is true, you can use the following -
1. Use FindExecutable() API to find the associated EXE
2. Use CreateProcess() API to create the process for the EXE got from step#1
3. Use WaitForSingleObject() API to wait on the process created in step#2
If you can state your problem more clearly, people here will be able to help you in a better way
S o h a i l K a d i w a l a
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Use ShellExecuteEx() instead, followed by WaitForSingleObject() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi there,
I've now encountered a hard problem.
As we know, in a dialog-based program, when we press a
button, the windows wait for the corresponding procedures
to be executed. During executing those procedures, the other
windows message won't be taken care.
I've ever used a library, it provides two functions.
One is Go(), and the other is Stop().
I created two corresponding buttons ButtonGO, and ButtonStop
to do Go() and Stop().
I don't have to use AfxCreateThread in OnBottonGO. When I press
ButtonGo, the ButtonStop button is still pressable!
When I press ButtonStop, the OnButtonGo() function shall return.
How this can be done?
Any suggestion will be appreciated.
|
|
|
|