Click here to Skip to main content
15,923,576 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan4-Oct-10 3:21
mveRichard MacCutchan4-Oct-10 3:21 
GeneralRe: CDialog DoModal function Pin
prithaa4-Oct-10 5:19
prithaa4-Oct-10 5:19 
GeneralRe: CDialog DoModal function Pin
Richard MacCutchan4-Oct-10 5:41
mveRichard MacCutchan4-Oct-10 5:41 
GeneralRe: CDialog DoModal function Pin
prithaa4-Oct-10 6:20
prithaa4-Oct-10 6:20 
sorry i m posting code for the first time
int MFC::Dialog::DoModal() 
{
	//For OK and Cancel buttons??
	m_DialogTemplate.cy+=(DlgControls.size()*4);

	AddOkCancel();

	int iRet=0;
	
	//presetting for caption in the dialog....
		
	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);
		iRet = CDialog::DoModal();
		
		LocalUnlock(hLocal);
		LocalFree(hLocal);
		return iRet;
	}
	else {
		AfxMessageBox(_T("D::DoModal() : LocalAllock Failed"));
		return -1;
	}
}

GeneralRe: CDialog DoModal function Pin
prithaa4-Oct-10 6:21
prithaa4-Oct-10 6:21 
QuestionAssign value to a variable after a delay Pin
manoharbalu29-Sep-10 19:32
manoharbalu29-Sep-10 19:32 
AnswerRe: Assign value to a variable after a delay Pin
Cedric Moonen29-Sep-10 20:13
Cedric Moonen29-Sep-10 20:13 
AnswerRe: Assign value to a variable after a delay [modified] Pin
Eugen Podsypalnikov29-Sep-10 20:48
Eugen Podsypalnikov29-Sep-10 20:48 
AnswerRe: Assign value to a variable after a delay Pin
Aescleal29-Sep-10 20:52
Aescleal29-Sep-10 20:52 
GeneralRe: Assign value to a variable after a delay Pin
Luc Pattyn30-Sep-10 0:43
sitebuilderLuc Pattyn30-Sep-10 0:43 
GeneralRe: Assign value to a variable after a delay Pin
Aescleal30-Sep-10 0:59
Aescleal30-Sep-10 0:59 
QuestionHow to call C# APIs from C++ Pin
pandit8429-Sep-10 17:36
pandit8429-Sep-10 17:36 
AnswerRe: How to call C# APIs from C++ Pin
Anand Todkar29-Sep-10 18:30
Anand Todkar29-Sep-10 18:30 
AnswerRe: How to call C# APIs from C++ Pin
Sauro Viti29-Sep-10 23:33
professionalSauro Viti29-Sep-10 23:33 
QuestionTab key doesn't work right Pin
garyflet29-Sep-10 6:32
garyflet29-Sep-10 6:32 
AnswerRe: Tab key doesn't work right Pin
josda100029-Sep-10 6:58
josda100029-Sep-10 6:58 
GeneralRe: Tab key doesn't work right Pin
garyflet29-Sep-10 8:00
garyflet29-Sep-10 8:00 
AnswerRe: Tab key doesn't work right [modified] Pin
Stephen Hewitt29-Sep-10 8:35
Stephen Hewitt29-Sep-10 8:35 
GeneralRe: Tab key doesn't work right Pin
garyflet29-Sep-10 10:16
garyflet29-Sep-10 10:16 
GeneralRe: Tab key doesn't work right Pin
Stephen Hewitt29-Sep-10 20:10
Stephen Hewitt29-Sep-10 20:10 
QuestionMCI playback ended Pin
MikeRWinter29-Sep-10 2:26
MikeRWinter29-Sep-10 2:26 

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.