Click here to Skip to main content
15,918,404 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Detours Simple sample applications dll export problem Pin
«_Superman_»29-Jan-09 1:49
professional«_Superman_»29-Jan-09 1:49 
GeneralRe: Detours Simple sample applications dll export problem Pin
keret29-Jan-09 3:41
keret29-Jan-09 3:41 
GeneralRe: Detours Simple sample applications dll export problem Pin
«_Superman_»29-Jan-09 19:49
professional«_Superman_»29-Jan-09 19:49 
GeneralRe: Detours Simple sample applications dll export problem Pin
keret30-Jan-09 0:35
keret30-Jan-09 0:35 
Questionhow to get file name to input to 'IWMMetadataEditor' in C++ ? Pin
Supriya Tonape29-Jan-09 1:22
Supriya Tonape29-Jan-09 1:22 
QuestionThread Question Pin
Dennis L29-Jan-09 0:54
Dennis L29-Jan-09 0:54 
AnswerRe: Thread Question Pin
Code-o-mat29-Jan-09 0:59
Code-o-mat29-Jan-09 0:59 
GeneralRe: Thread Question [modified] Pin
Dennis L29-Jan-09 1:36
Dennis L29-Jan-09 1:36 
The code is:

// When user presses the start button
void DataCryptMain ::ProcessCrypt()
{
...
cryptthread.Start(_staticThreadProc, this)
...
}

// Crypt procedures
DWORD WINAPI _staticThreadProc(LPVOID lpData)
{
DataCryptMain *dcr = reinterpret_cast<datacryptmain>(lpData);
return dcr->CryptThreadProc(NULL);
}

DWORD WINAPI DataCryptMain::CryptThreadProc(LPVOID lpData)
{
int iErrorOrInfo = INFO_PROCESS_DONE;

// Ciphering stuff
iErrorOrInfo = CryptoRijnDaelProcess();

Notify_Progress_GUI(NOTIFY_PROGRESS_END, NULL, iErrorOrInfo);

return 0;
}

// Notify GUI
void DataCryptMain::Notify_Progress_GUI(int iNotificationType, WPARAM wParam, LPARAM lParam)
{

if (iNotificationType == NOTIFY_PROGRESS_RUNNING)
{
PostMessage(hWnd, WM_PROGRESS_RUNNING, wParam, lParam);
}
else
{
PostMessage(hWnd, WM_PROGRESS_END, wParam, lParam);
}

}

// Call back procedure from inside Encrypt()
bool _ProgressBarProc(PRBDATA *prbdata)
{
DataCryptMain *dcr = reinterpret_cast<datacryptmain>(prbdata->lpOtherData);
return dcr->ProgressBarProc(prbdata);
}


bool DataCryptMain::ProgressBarProc(PRBDATA *prbdata)
{
if (cryptthread.WaitToExit()) return TRUE;

PRBDATA *_prbdata = new PRBDATA;

memcpy(_prbdata, prbdata, sizeof(PRBDATA));

Notify_Progress_GUI(NOTIFY_PROGRESS_RUNNING, NULL, (LPARAM)_prbdata);

return FALSE;
}

// Rijndael processing
int DataCryptMain::CryptoRijnDaelProcess()
{
int iErrorOrInfo = OK;

RijnDaelCrypto *rdc = new RijnDaelCrypto;
	
...
...
	
// Set progress bar function
SetProgressFunc(_ProgressBarProc, (LPVOID)this);

------------------- Here this function loops through the file encryption
if (rdc->Encrypt(wcgFileNameIn, wcgFileNameOut, cryptParams.iCipherMode) < 0)
iErrorOrInfo = ERR_PROCESS_STOPPED_BY_USER;

_DELETE(rdc);

return iErrorOrInfo;
}

//WM_PROGRESS_RUNNING
bool DataCryptMain::OnProgressRunning(WPARAM wParam, LPARAM lParam)
{
	float fPercent[3];
	char sTemp[64];

	PRBDATA *prbdata = reinterpret_cast<prbdata>(lParam);

	// Percent % read file
	fPercent[0] = ((float)prbdata->iReadBytesIncByFuncRead / (float)prbdata->dwSize) * 100.0f;
	// Percent % block/s processed
	fPercent[1] = ((float)prbdata->iBlocksIncrement / (float)prbdata->iBlocksNum) * 100.0f;
	// Average percent
	fPercent[2] = (fPercent[0] + fPercent[1]) / 2;

	SendDlgItemMessage(hWnd, IDC_PROGRESSSTATUS, PBM_SETPOS, (WPARAM)fPercent[2], 0);

	// Display progress bar's percent value
	sprintf_s(sTemp, "%0.1f %%", fPercent[2]);
	SetDlgItemText(hWnd, IDC_PERCENT1, sTemp);

	// Display info
	sprintf_s(sTemp, "%d bytes", prbdata->dwSize);
	SetDlgItemText(hWnd, IDC_FILESIZE, sTemp);
	sprintf_s(sTemp, "%d bytes", prbdata->iReadBytesIncByFuncRead);
	SetDlgItemText(hWnd, IDC_READBYTES, sTemp);
	sprintf_s(sTemp, "%d block/s", (int)prbdata->iBlocksIncrement);
	SetDlgItemText(hWnd, IDC_BLOCKSPROCESSED, sTemp);

	_DELETE(prbdata);

	return FALSE;
} </prbdata></datacryptmain></datacryptmain>


modified on Thursday, January 29, 2009 9:03 AM

GeneralRe: Thread Question Pin
Code-o-mat29-Jan-09 1:56
Code-o-mat29-Jan-09 1:56 
GeneralRe: Thread Question Pin
Dennis L29-Jan-09 2:17
Dennis L29-Jan-09 2:17 
GeneralRe: Thread Question Pin
Code-o-mat29-Jan-09 2:32
Code-o-mat29-Jan-09 2:32 
GeneralRe: Thread Question Pin
Dennis L29-Jan-09 3:03
Dennis L29-Jan-09 3:03 
GeneralRe: Thread Question Pin
Stephen Hewitt29-Jan-09 2:27
Stephen Hewitt29-Jan-09 2:27 
AnswerRe: Thread Question Pin
SandipG 29-Jan-09 1:02
SandipG 29-Jan-09 1:02 
QuestionHooking into mouse messages in a Command/MSDOS window Pin
goop0029-Jan-09 0:46
goop0029-Jan-09 0:46 
AnswerRe: Hooking into mouse messages in a Command/MSDOS window Pin
ATM@CodeProject29-Jan-09 0:49
ATM@CodeProject29-Jan-09 0:49 
GeneralRe: Hooking into mouse messages in a Command/MSDOS window Pin
goop0029-Jan-09 0:53
goop0029-Jan-09 0:53 
AnswerRe: Hooking into mouse messages in a Command/MSDOS window Pin
«_Superman_»29-Jan-09 1:35
professional«_Superman_»29-Jan-09 1:35 
GeneralRe: Hooking into mouse messages in a Command/MSDOS window Pin
goop0029-Jan-09 3:21
goop0029-Jan-09 3:21 
QuestionHow to add a control at the Runtime in VC++? Pin
Pre1234529-Jan-09 0:27
Pre1234529-Jan-09 0:27 
AnswerRe: How to add a control at the Runtime in VC++? Pin
SandipG 29-Jan-09 0:31
SandipG 29-Jan-09 0:31 
QuestionRe: How to add a control at the Runtime in VC++? Pin
David Crow29-Jan-09 2:54
David Crow29-Jan-09 2:54 
QuestionUnicode issue, show chinese letters etc.!? Pin
bosfan29-Jan-09 0:18
bosfan29-Jan-09 0:18 
AnswerRe: Unicode issue, show chinese letters etc.!? Pin
Iain Clarke, Warrior Programmer29-Jan-09 0:37
Iain Clarke, Warrior Programmer29-Jan-09 0:37 
GeneralRe: Unicode issue, show chinese letters etc.!? Pin
bosfan29-Jan-09 0:54
bosfan29-Jan-09 0:54 

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.