Click here to Skip to main content
15,905,073 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Guarding delete Pin
Joe Moldovan1-Mar-02 11:56
Joe Moldovan1-Mar-02 11:56 
GeneralRe: Guarding delete Pin
Mukkie1-Mar-02 12:06
Mukkie1-Mar-02 12:06 
GeneralTimers are as threads? (newbie) Pin
Joan M28-Feb-02 22:18
professionalJoan M28-Feb-02 22:18 
GeneralRe: Timers are as threads? (newbie) Pin
Joaquín M López Muñoz28-Feb-02 23:41
Joaquín M López Muñoz28-Feb-02 23:41 
GeneralRe: Timers are as threads? (newbie) Pin
Steen Krogsgaard1-Mar-02 3:34
Steen Krogsgaard1-Mar-02 3:34 
GeneralRe: Timers are as threads? (newbie) Pin
Joan M1-Mar-02 4:54
professionalJoan M1-Mar-02 4:54 
GeneralRe: Timers are as threads? (newbie) Pin
Bill Wilson1-Mar-02 6:09
Bill Wilson1-Mar-02 6:09 
GeneralRe: Timers are as threads? (newbie) Pin
Steen Krogsgaard3-Mar-02 21:30
Steen Krogsgaard3-Mar-02 21:30 
I'm not quite sure I fully understand your program design. What are you Send/PostMessaging to? Windows in your app, other apps on the same PC, other apps on different PCs? If the targets of the message is in another process I'd go for your current design, using PostMessage. However, if the targets are in-process I'd let each target be represented by class. On creation each of these classes registeres itself to your OnTimer-handling class (you could keep an array of CTargetClass pointers). On each WM_TIMER I would simply call a method on each class. A simple example could look like this:

class CTargetClass : public CObject_derivative
{
public:
   CTargetClass (CHandlingClass* pHandler)
....
public:
   void ReturnInfo (CInfo* pInfo);
}

CTargetClass::CTargetClass (CHandlingClass* pHandler)
{
   pHandler->RegisterTarget(this);
}

class CHandlingClass : public CSomeBaseClass
{
....
public: 
   void RegisterTarget (CTargetClass* pTarget);
   afx_msg void OnTimer(UINT nIDEvent);
protected:
   int m_iMaxTargets;
   CTargetClass* m_pTargets; // this will point to an array of m_iMaxTargets 
}

void CHandlingClass::CRegisterTarget (CTargerClass* pTarget)
{
   // for simplicity it's assumed that the m_pTargets array is always big enough
   // It would be much better to use STL containers or even MFC containers.
   m_pTargets[m_iMaxTargets] = pTarget;
   m_iMaxTargets++;
}

void CHandlingClass::OnTimer (UINT nIDEvent)
{
   if (nIDEvent == ID_OF_YOUR_TIMER) {
      int i;
      CInfo info;
      for (i=0; i<m_iMaxTargets; i++) {
         m_pTargets[i].ReturnInfo(&info);
         DoWhateverYouNeedWithTheInfo(info);
      }
   }
}

Lots of stuff omitted, but I hope you get the idea.

Cheers
Steen.

"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
QuestionHow to access network shared resource from a service? Pin
28-Feb-02 21:21
suss28-Feb-02 21:21 
AnswerRe: How to access network shared resource from a service? Pin
Bill Wilson1-Mar-02 6:20
Bill Wilson1-Mar-02 6:20 
GeneralStandard Conversions about char Pin
28-Feb-02 19:38
suss28-Feb-02 19:38 
GeneralRe: Standard Conversions about char Pin
Joaquín M López Muñoz28-Feb-02 20:12
Joaquín M López Muñoz28-Feb-02 20:12 
GeneralRe: Standard Conversions about char Pin
Bill Wilson1-Mar-02 8:43
Bill Wilson1-Mar-02 8:43 
GeneralRe: Standard Conversions about char Pin
Tim Smith1-Mar-02 5:27
Tim Smith1-Mar-02 5:27 
GeneralPreventing a Non-resizable form from maximizing when run from a shortcut Pin
outlaw-torn28-Feb-02 19:05
outlaw-torn28-Feb-02 19:05 
GeneralRe: Preventing a Non-resizable form from maximizing when run from a shortcut Pin
Paul M Watt28-Feb-02 19:07
mentorPaul M Watt28-Feb-02 19:07 
GeneralRe: Preventing a Non-resizable form from maximizing when run from a shortcut Pin
Steen Krogsgaard1-Mar-02 3:37
Steen Krogsgaard1-Mar-02 3:37 
GeneralCustom message handling Pin
alex.barylski28-Feb-02 18:40
alex.barylski28-Feb-02 18:40 
GeneralRe: Custom message handling Pin
Mazdak28-Feb-02 18:47
Mazdak28-Feb-02 18:47 
GeneralRe: Custom message handling Pin
Nish Nishant28-Feb-02 19:25
sitebuilderNish Nishant28-Feb-02 19:25 
GeneralRe: Custom message handling Pin
alex.barylski28-Feb-02 19:55
alex.barylski28-Feb-02 19:55 
GeneralRe: Custom message handling Pin
Michael Dunn28-Feb-02 20:52
sitebuilderMichael Dunn28-Feb-02 20:52 
GeneralRe: Custom message handling Pin
alex.barylski1-Mar-02 6:02
alex.barylski1-Mar-02 6:02 
GeneralRe: Custom message handling Pin
alex.barylski1-Mar-02 6:15
alex.barylski1-Mar-02 6:15 
GeneralRe: Custom message handling Pin
Nish Nishant28-Feb-02 21:25
sitebuilderNish Nishant28-Feb-02 21:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.