Click here to Skip to main content
16,012,759 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Easy way to convert webpage to txt file? Pin
Selevercin15-Jun-04 13:42
Selevercin15-Jun-04 13:42 
GeneralRe: Easy way to convert webpage to txt file? Pin
georgiek5015-Jun-04 14:32
georgiek5015-Jun-04 14:32 
AnswerRe: Easy way to convert webpage to txt file? Pin
palbano15-Jun-04 12:37
palbano15-Jun-04 12:37 
AnswerRe: Easy way to convert webpage to txt file? Pin
Ravi Bhavnani15-Jun-04 18:34
professionalRavi Bhavnani15-Jun-04 18:34 
GeneralCALLBACK aka __stdcall Pin
Igor Mihailov15-Jun-04 10:04
Igor Mihailov15-Jun-04 10:04 
GeneralRe: CALLBACK aka __stdcall Pin
palbano15-Jun-04 10:24
palbano15-Jun-04 10:24 
GeneralRe: CALLBACK aka __stdcall Pin
15-Jun-04 10:28
suss15-Jun-04 10:28 
GeneralRe: CALLBACK aka __stdcall Pin
palbano15-Jun-04 10:42
palbano15-Jun-04 10:42 
/** Win32 CreateThread class wrapper */
class base_w32thread{
protected:
	HANDLE	_handle;
	DWORD	_dwTID;
	base_w32thread():_handle(0), _dwTID(0L){}
	virtual ~base_w32thread()=0;

public:
	bool start(LPSECURITY_ATTRIBUTES psecattrs = NULL, DWORD dwCreateFlags = 0L);
	operator HANDLE(){ return _handle; }
protected:
	virtual void run()=0;
	virtual void onEndThread(){}
	static long WINAPI threadfnc( LPARAM lp);
};

threadfnc is the callback that is sent as the argument to CreateThread() below
/** start the thread */
bool base_w32thread::start(LPSECURITY_ATTRIBUTES psecattrs, DWORD dwCreateFlags){

	assert( !_handle);
	if( _handle)
		return false;

	_handle = ::CreateThread( psecattrs, 0, 
		(LPTHREAD_START_ROUTINE)threadfnc, this, dwCreateFlags, &_dwTID);
	return (_handle)?true:false;
}

Then in the callback function there is no "this" pointer so we have sent the object pointer as the User Parameter to CreateThread and we cast it to the correct type
/** Thread function */
long WINAPI base_w32thread::threadfnc( LPARAM lp){

	assert( lp);
	base_w32thread* pThis = (base_w32thread*)lp;
	if( pThis)
		pThis->run();

	pThis->_handle = 0L;		// thread exited
	pThis->onEndThread();
	return 0L;
}

Hope that helps

"No matter where you go, there your are." - Buckaroo Banzai
-pete

GeneralRe: CALLBACK aka __stdcall Pin
Igor Mihailov15-Jun-04 10:46
Igor Mihailov15-Jun-04 10:46 
GeneralRe: CALLBACK aka __stdcall Pin
Michael Dunn15-Jun-04 10:41
sitebuilderMichael Dunn15-Jun-04 10:41 
GeneralRe: CALLBACK aka __stdcall Pin
Indrawati15-Jun-04 14:31
Indrawati15-Jun-04 14:31 
GeneralRe: CALLBACK aka __stdcall Pin
Archer28215-Jun-04 20:46
Archer28215-Jun-04 20:46 
Generalpointer to class as arguement in a function Pin
georgiek5015-Jun-04 10:03
georgiek5015-Jun-04 10:03 
GeneralRe: pointer to class as arguement in a function Pin
palbano15-Jun-04 10:32
palbano15-Jun-04 10:32 
GeneralRe: pointer to class as argument in a function Pin
Nynaeve15-Jun-04 10:39
Nynaeve15-Jun-04 10:39 
GeneralRe: pointer to class as argument in a function Pin
georgiek5015-Jun-04 11:29
georgiek5015-Jun-04 11:29 
GeneralRe: pointer to class as argument in a function Pin
toxcct15-Jun-04 11:57
toxcct15-Jun-04 11:57 
GeneralRe: pointer to class as argument in a function Pin
Anonymous15-Jun-04 12:00
Anonymous15-Jun-04 12:00 
GeneralRe: pointer to class as argument in a function Pin
toxcct15-Jun-04 12:04
toxcct15-Jun-04 12:04 
GeneralRe: pointer to class as argument in a function Pin
georgiek5015-Jun-04 13:57
georgiek5015-Jun-04 13:57 
GeneralRe: pointer to class as argument in a function Pin
Nynaeve16-Jun-04 7:26
Nynaeve16-Jun-04 7:26 
GeneralRe: pointer to class as argument in a function Pin
georgiek5016-Jun-04 12:36
georgiek5016-Jun-04 12:36 
GeneralWrite a DDE Server program for Excel using VC++ Pin
swerajan15-Jun-04 8:36
swerajan15-Jun-04 8:36 
Generaldll resource Pin
Spiritofamerica15-Jun-04 7:31
Spiritofamerica15-Jun-04 7:31 
GeneralRe: dll resource Pin
User 665815-Jun-04 7:39
User 665815-Jun-04 7:39 

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.