Click here to Skip to main content
15,896,118 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMenu class derived from CMenu Pin
prithaa7-Apr-09 23:30
prithaa7-Apr-09 23:30 
AnswerRe: Menu class derived from CMenu Pin
Iain Clarke, Warrior Programmer8-Apr-09 0:03
Iain Clarke, Warrior Programmer8-Apr-09 0:03 
QuestionMenu and document Pin
gopalan.kaliyamoorthy7-Apr-09 23:11
gopalan.kaliyamoorthy7-Apr-09 23:11 
AnswerRe: Menu and document Pin
«_Superman_»7-Apr-09 23:22
professional«_Superman_»7-Apr-09 23:22 
GeneralRe: Menu and document Pin
gopalan.kaliyamoorthy8-Apr-09 18:40
gopalan.kaliyamoorthy8-Apr-09 18:40 
GeneralRe: Menu and document Pin
«_Superman_»8-Apr-09 19:07
professional«_Superman_»8-Apr-09 19:07 
Questionprint in splitted window Pin
susanne17-Apr-09 22:35
susanne17-Apr-09 22:35 
Questionhow to set a class member function as parameter of an other class in its constructor ? Pin
pedefetoll7-Apr-09 22:22
pedefetoll7-Apr-09 22:22 
Here the code of a "pulsar" in Qt context. QMTPulsar is an abstract class used for execution of periodic switches, and execute a function at the end of each period. The compilation message is given.
Best regards.

> QMThreadOneAction is used to run asynchronously a function;

La création des QMThreadOneAction est incorrecte.

//-------------------------------------
/** QMTPulsar.h
> Pulse component
- mechanism of periodic (or not) raise and fall call
*/

#ifndef __TESTUTILS_H__
#define __TESTUTILS_H__

#ifdef DEVICELOADER_EXPORTS
#define DEVICELOADER_API __declspec(dllexport)
#else
#define DEVICELOADER_API __declspec(dllimport)
#endif

#include "QtCore/QtGlobal"
#include "QtCore/QThread"
#include "MTDevicePrv.h"


//-------------------------------------
/** QMTPulsar
> process up and down switches, and function execution at each switch.
*/
class DEVICELOADER_API QMTPulsar :
public QThread
{
//-------------------------------------
/** QMThreadOneAction
> execute asynchronously a function
*/
class QMThreadOneAction :
public QThread
{
private:
MTDevicePrv *_device;
void (__cdecl* QMTPulsar::_fonc)(MTDevicePrv *dev);
bool _running;

//! execute function once
void run(void)
{
if (_fonc) {
if (!_running) {
_running = true;

try {
_fonc( _device);
}
catch(...){}

_running = false;
}
}
}
public:
//! constructeur
QMThreadOneAction (
MTDevicePrv *dev,
void (__cdecl* QMTPulsar::fonc)(MTDevicePrv *)
)
{
_running = false;
_device = dev;
_fonc = fonc;
}

//! execute asynchronously function
void go( void) {
run();
}
};

private:

MTDevicePrv *_device;

//! start with action or not
/**
_startWithAction = false

F1 F2
_______________
D1 | D2 |
__________

_startWithAction = true

F1 D1 F2
_______________
| | D2
__________

*/
bool _startWithAction;
//! D1 (microsecond)
qint64 _firstDurationMUS;
//! D2 (microsecond)
qint64 _secondDurationMUS;
//! repeat mechanism
bool _periodic;
//! is operating
bool _active;

QMThreadOneAction *_thFirst;
QMThreadOneAction *_thSecond;

//! processing
void run() {
do {
if (!_active) {
QThread::yieldCurrentThread();
}
else {
if (!_startWithAction) {
QThread::usleep( _firstDurationMUS);
_firstAction();
QThread::usleep( _secondDurationMUS);
_secondAction();
}
else {
_firstAction();
QThread::usleep( _firstDurationMUS);
_secondAction();
QThread::usleep( _secondDurationMUS);
}
}
} while( _periodic);
};

//! first action call to implement
void _firstAction( void) {
_thFirst->go();
}

//! second action call to implement
virtual void _secondAction( void) {
_thSecond->go();
}

public:

//! first action call to implement
virtual void fnFirstAction( MTDevicePrv *dev) = 0;

//! second action call to implement
virtual void fnSecondAction( MTDevicePrv *dev) = 0;

/** create pulsar
@param startWithAction start immediately firstAction or not
@param firstDurationMUS first delay in micro sec
@param secondDurationMUS second delay in micro sec
@param periodic periodic or not
@param startActive start activity immediately
*/
QMTPulsar(
MTDevicePrv *dev,
bool startWithAction,
qint64 firstDurationMUS,
qint64 secondDurationMUS,
bool periodic,
bool startActive)
{
_device = dev;
_startWithAction = startWithAction;
_periodic = periodic;
_firstDurationMUS = firstDurationMUS;
_secondDurationMUS = secondDurationMUS;
_active = startActive;

/* error #171)*/ _thFirst = new QMThreadOneAction( _device, fnFirstAction);
/* error #172)*/ _thSecond = new QMThreadOneAction( _device, fnSecondAction);
/*
Compilation en cours...
QMTPulsar.cpp
c:\_projets-cpp2008\deviceframework\deviceframework\devicemanager\qmtpulsar.h(171) : error C3867: &'QMTPulsar::fnFirstAction' : liste d'arguments manquante dans l'appel de fonction ; utilisez 'QMTPulsar::fnFirstAction' pour créer un pointeur vers membre
c:\_projets-cpp2008\deviceframework\deviceframework\devicemanager\qmtpulsar.h(172) : error C3867: &'QMTPulsar::fnSecondAction' : liste d'arguments manquante dans l'appel de fonction ; utilisez 'QMTPulsar::fnSecondAction' pour créer un pointeur vers membre
Le journal de génération a été enregistré à l'emplacement "file://c:\_Projets-CPP2008\DeviceFramework\DeviceFramework\DeviceManager\src\Debug\BuildLog.htm"
DeviceManager - 2 erreur(s), 0 avertissement(s)
*/
run();
};

~QMTPulsar();

//! return owner device
MTDevice* getDevice() const {
return _device ;
}

//! activate (if true) mechanism
virtual void activate(
bool active) {
_active = active;
if (!QThread::isRunning())
run();
};
};

#endif
AnswerRe: how to set a class member function as parameter of an other class in its constructor ? Pin
TinyDevices7-Apr-09 22:26
professionalTinyDevices7-Apr-09 22:26 
GeneralRe: how to set a class member function as parameter of an other class in its constructor ? Pin
pedefetoll7-Apr-09 22:40
pedefetoll7-Apr-09 22:40 
AnswerRe: how to set a class member function as parameter of an other class in its constructor ? Pin
Stuart Dootson7-Apr-09 22:34
professionalStuart Dootson7-Apr-09 22:34 
QuestionWriting a similar function as ComboBox SelectString Pin
beko7-Apr-09 21:16
beko7-Apr-09 21:16 
AnswerRe: Writing a similar function as ComboBox SelectString Pin
Stuart Dootson7-Apr-09 21:53
professionalStuart Dootson7-Apr-09 21:53 
GeneralRe: Writing a similar function as ComboBox SelectString Pin
beko7-Apr-09 22:09
beko7-Apr-09 22:09 
QuestionRe: Writing a similar function as ComboBox SelectString Pin
TinyDevices7-Apr-09 22:23
professionalTinyDevices7-Apr-09 22:23 
AnswerRe: Writing a similar function as ComboBox SelectString Pin
Stuart Dootson7-Apr-09 22:27
professionalStuart Dootson7-Apr-09 22:27 
GeneralRe: Writing a similar function as ComboBox SelectString Pin
TinyDevices7-Apr-09 22:33
professionalTinyDevices7-Apr-09 22:33 
QuestionDLL multy [modified] Pin
denisxfrom7-Apr-09 20:49
denisxfrom7-Apr-09 20:49 
AnswerRe: DLL multy Pin
Stuart Dootson7-Apr-09 21:20
professionalStuart Dootson7-Apr-09 21:20 
Questionhai Pin
roopa.n7-Apr-09 20:39
roopa.n7-Apr-09 20:39 
AnswerRe: hai Pin
TinyDevices7-Apr-09 22:26
professionalTinyDevices7-Apr-09 22:26 
JokeRe: hai Pin
Nelek8-Apr-09 0:30
protectorNelek8-Apr-09 0:30 
AnswerRe: hai Pin
0x3c08-Apr-09 1:32
0x3c08-Apr-09 1:32 
Questionhai Pin
roopa.n7-Apr-09 20:38
roopa.n7-Apr-09 20:38 
AnswerRe: hai Pin
Cedric Moonen7-Apr-09 21:01
Cedric Moonen7-Apr-09 21:01 

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.