Click here to Skip to main content
15,906,106 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSystem Hooking Pin
Fareed Rizkalla30-Sep-10 5:45
Fareed Rizkalla30-Sep-10 5:45 
AnswerRe: System Hooking Pin
«_Superman_»30-Sep-10 18:37
professional«_Superman_»30-Sep-10 18:37 
Questionvisual studio 2005 fails to debug c++ program, breakpoint will never be hint, program after debug always running in background, (be found in task manager->processes) Pin
blueroadside30-Sep-10 5:07
blueroadside30-Sep-10 5:07 
AnswerRe: visual studio 2005 fails to debug c++ program, breakpoint will never be hint, program after debug always running in background, (be found in task manager->processes) Pin
Luc Pattyn30-Sep-10 5:59
sitebuilderLuc Pattyn30-Sep-10 5:59 
GeneralRe: visual studio 2005 fails to debug c++ program, breakpoint will never be hint, program after debug always running in background, (be found in task manager->processes) Pin
blueroadside1-Oct-10 0:17
blueroadside1-Oct-10 0:17 
AnswerRe: visual studio 2005 fails to debug c++ program, breakpoint will never be hint, program after debug always running in background, (be found in task manager->processes) Pin
prasad_som30-Sep-10 23:56
prasad_som30-Sep-10 23:56 
GeneralRe: visual studio 2005 fails to debug c++ program, breakpoint will never be hint, program after debug always running in background, (be found in task manager->processes) Pin
blueroadside1-Oct-10 0:23
blueroadside1-Oct-10 0:23 
QuestionWhat is this error msg? [solved] Pin
AmbiguousName30-Sep-10 3:47
AmbiguousName30-Sep-10 3:47 
AnswerRe: What is this error msg? [solved] Pin
Member 437175630-Sep-10 7:16
Member 437175630-Sep-10 7:16 
AnswerRe: What is this error msg? [solved] Pin
David Crow30-Sep-10 8:51
David Crow30-Sep-10 8:51 
QuestionCDialog DoModal function [Moved] Pin
prithaa30-Sep-10 1:48
prithaa30-Sep-10 1:48 
AnswerRe: CDialog DoModal function Pin
Richard MacCutchan30-Sep-10 2:27
mveRichard MacCutchan30-Sep-10 2:27 
GeneralRe: CDialog DoModal function Pin
prithaa1-Oct-10 1:42
prithaa1-Oct-10 1:42 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan1-Oct-10 2:35
mveRichard MacCutchan1-Oct-10 2:35 
GeneralRe: CDialog DoModal function Pin
prithaa1-Oct-10 17:20
prithaa1-Oct-10 17:20 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan1-Oct-10 23:05
mveRichard MacCutchan1-Oct-10 23:05 
GeneralRe: CDialog DoModal function Pin
prithaa2-Oct-10 0:17
prithaa2-Oct-10 0:17 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan2-Oct-10 1:11
mveRichard MacCutchan2-Oct-10 1:11 
GeneralRe: CDialog DoModal function Pin
prithaa2-Oct-10 2:06
prithaa2-Oct-10 2:06 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan2-Oct-10 4:12
mveRichard MacCutchan2-Oct-10 4:12 
GeneralRe: CDialog DoModal function Pin
prithaa3-Oct-10 2:09
prithaa3-Oct-10 2:09 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan3-Oct-10 3:15
mveRichard MacCutchan3-Oct-10 3:15 
GeneralRe: CDialog DoModal function Pin
prithaa3-Oct-10 23:24
prithaa3-Oct-10 23:24 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan4-Oct-10 0:44
mveRichard MacCutchan4-Oct-10 0:44 
GeneralRe: CDialog DoModal function Pin
prithaa4-Oct-10 1:18
prithaa4-Oct-10 1:18 
int MFC::Dialog::DoModal()
{
int cWC = MultiByteToWideChar(CP_ACP, 0, m_strCaption, -1, NULL, 0);
int szBoxLen = cWC + 1;
WCHAR *szBoxCaption = new WCHAR[szBoxLen];
// Copy the string...
MultiByteToWideChar(CP_ACP, 0, m_strCaption, -1, (LPWSTR) szBoxCaption, cWC);
szBoxCaption[cWC] = 0;
szBoxLen = (cWC) * sizeof(WCHAR);

int nBufferSize = sizeof(DLGTEMPLATE) + (2 * sizeof(WORD)) /*menu and class + szBoxLen /*size of caption*/
+ sizeof(WORD) /*fontsize*/ ;//+ nFontNameLen /*size of fontname*/;

HLOCAL hLocal = LocalAlloc(LHND, nBufferSize);
if (hLocal != NULL) {
BYTE* pBuffer = (BYTE*)LocalLock(hLocal);
if (pBuffer == NULL) {
LocalFree(hLocal);
AfxMessageBox(_T("D::DoModal() : LocalLock Failed"));
}

BYTE *pdest = pBuffer;
// transfer DLGTEMPLATE structure to the buffer
memcpy(pdest, &m_DialogTemplate, sizeof(DLGTEMPLATE)); // DLGTemplate
pdest += sizeof(DLGTEMPLATE);
*(WORD*)pdest = 0;// no menu -- WORD to say it is 0 bytes
pdest += sizeof(WORD); // Increment
*(WORD*)(pdest + 1) = 0; // use default window class -- WORD to say it is 0 bytes
pdest += sizeof(WORD); // Increment
memcpy(pdest, szBoxCaption, szBoxLen); // Caption
pdest += szBoxLen;

//These are the MFC functions, which do the job...

InitModalIndirect((LPDLGTEMPLATE)pBuffer, m_pParentWnd);
int iRet =0;
iRet = CDialog::DoModal();

LocalUnlock(hLocal);
LocalFree(hLocal);
return 0;
}
else {
AfxMessageBox(_T("D::DoModal() : LocalAllock Failed"));
return -1;
}
}

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.