コード例 #1
0
ファイル: dlgcore.cpp プロジェクト: anyue100/winscp
BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
	ASSERT(HIWORD(lpszTemplateName) == 0 ||
		AfxIsValidString(lpszTemplateName));

	m_lpszTemplateName = lpszTemplateName;  // used for help
	if (HIWORD(m_lpszTemplateName) == 0 && m_nIDHelp == 0)
		m_nIDHelp = LOWORD((DWORD)m_lpszTemplateName);

#ifdef _DEBUG
	if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))
	{
		ASSERT(FALSE);          // invalid dialog template name
		PostNcDestroy();        // cleanup if Create fails too soon
		return FALSE;
	}
#endif //_DEBUG

	HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
	HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
	HGLOBAL hTemplate = LoadResource(hInst, hResource);
	BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);
	FreeResource(hTemplate);

	return bResult;
}
コード例 #2
0
ファイル: CBaseDlg.cpp プロジェクト: HGRun/MFC_UI_REPO
BOOL CBaseDlg::CreateModeDlg(CString strCaption, CRect rect, BOOL bMode /*= TRUE*/, CWnd* pParent /*= NULL*/)
{
	m_bMode = bMode;
	BOOL bResult = FALSE;
	DLGTEMPLATE* pTemp = NULL;

	// 先获得dpi
	HDC	hdc = ::GetDC(0);
	int		nDpiX = GetDeviceCaps(hdc, LOGPIXELSX);
	int		nDpiY = GetDeviceCaps(hdc, LOGPIXELSY);
	::ReleaseDC(0, hdc);
	ASSERT(nDpiX = nDpiY);
	double fScaleData = 64.0 / nDpiX;
#ifdef		WINCE
	fScaleData = fScaleData * 0.859;
#endif
	rect.left = (int)(rect.left*fScaleData);
	rect.top = (int)(rect.top*fScaleData);
	rect.right = (int)(rect.right*fScaleData);
	rect.bottom = (int)(rect.bottom*fScaleData);

	pTemp = m_dlgTemp.CreateTemplate(WS_POPUPWINDOW | DS_MODALFRAME | WS_CAPTION, rect, strCaption);
	if (bMode)
	{
		bResult = InitModalIndirect(pTemp, pParent);
	}
	else
	{
		bResult = CreateIndirect(pTemp, pParent);
	}
	return bResult;
}
コード例 #3
0
ファイル: WndSettingsPage.cpp プロジェクト: GetEnvy/Envy
BOOL CSettingsPage::Create(const CRect& rcPage, CWnd* pSheetWnd)
{
	ASSERT_VALID(this);
	ASSERT( m_lpszTemplateName != NULL );

	CDialogTemplate pTemplate;
	LPDLGTEMPLATE pData;

	if ( ! pTemplate.Load( m_lpszTemplateName ) ) return FALSE;
	pData = (LPDLGTEMPLATE)GlobalLock( pTemplate.m_hTemplate );
	if ( ! pData ) return FALSE;

	DWORD dwExStyle = Settings.General.LanguageRTL ? WS_EX_RTLREADING|WS_EX_RIGHT|WS_EX_LEFTSCROLLBAR|WS_EX_LAYOUTRTL :
		WS_EX_LTRREADING|WS_EX_LEFT|WS_EX_RIGHTSCROLLBAR;

	if ( ((DLGTEMPLATEEX*)pData)->signature == 0xFFFF )
	{
		DLGTEMPLATEEX* pEx = (DLGTEMPLATEEX*)pData;
		pEx->style		= WS_CHILDWINDOW|WS_OVERLAPPED|DS_3DLOOK|DS_SETFONT|DS_CONTROL;
		pEx->exStyle	= dwExStyle|WS_EX_WINDOWEDGE|WS_EX_CONTROLPARENT;
	}
	else
	{
		pData->style			= WS_CHILDWINDOW|WS_OVERLAPPED|DS_3DLOOK|DS_SETFONT|DS_CONTROL;
		pData->dwExtendedStyle	= dwExStyle|WS_EX_WINDOWEDGE|WS_EX_CONTROLPARENT;
	}

	GlobalUnlock( pTemplate.m_hTemplate );
	CreateIndirect( pTemplate.m_hTemplate, pSheetWnd );
	SetFont( &theApp.m_gdiFont );

	MoveWindow( rcPage );

	return ( m_hWnd != NULL );
}
コード例 #4
0
ファイル: IECtrlEx.cpp プロジェクト: ximenpo/simple-cpp-win32
void WebBrowserCtrlEx_ContainerWnd::Create(CWnd* pParentWnd, int nWidth, int nHeight, DWORD dwStyle, DWORD dwStyleEx) {
    RECT	rc	= {0, 0, nWidth, nHeight};

    DlgTemplate	m_DlgBuilder;
    m_DlgBuilder.Begin(dwStyle, rc, "", dwStyleEx);

    CreateIndirect(m_DlgBuilder.GetTemplate(), pParentWnd);
}
コード例 #5
0
bool CSTATUS_DIALOG::create_dialog()
{
	//Load DLGTEMPLATE
	DLGTEMPLATE* pTemplate;

	HINSTANCE hInst= AfxFindResourceHandle(
		MAKEINTRESOURCE(IDD_DIALOG_STATUS),RT_DIALOG);

	if (hInst == NULL)
	{ 
		TRACE("Cound not find resource in resource chain");
		ASSERT(FALSE);
		return true;
	}

	HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(IDD_DIALOG_STATUS),
		RT_DIALOG);
	ASSERT(hRsrc != NULL);

	HGLOBAL hTemplate = ::LoadResource(hInst, hRsrc);
	ASSERT(hTemplate != NULL);

	pTemplate = (DLGTEMPLATE*)::LockResource(hTemplate);

	//Load coresponding DLGINIT resource
	void* lpDlgInit = NULL;
	HGLOBAL hDlgInit = NULL;

	HRSRC hsDlgInit = ::FindResource(hInst, MAKEINTRESOURCE(IDD_DIALOG_STATUS),
		RT_DLGINIT);
	if (hsDlgInit != NULL)
	{
		// load it
		hDlgInit = ::LoadResource(hInst, hsDlgInit);
		ASSERT(hDlgInit != NULL);

		// lock it
		lpDlgInit = ::LockResource(hDlgInit);
		ASSERT(lpDlgInit != NULL);
	}

	//ToDo: Modify DLGTEMPLATE in memory if desired

	CreateIndirect(hTemplate, NULL, hInst);

	::UnlockResource(hTemplate);
	::FreeResource(hTemplate);
	if (hDlgInit) 
	{
		::UnlockResource(hDlgInit);   
		::FreeResource(hDlgInit);
	}	
	
	return true;
}
コード例 #6
0
ファイル: dlgcore.cpp プロジェクト: anyue100/winscp
BOOL CDialog::CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd,
	HINSTANCE hInst)
{
	ASSERT(hDialogTemplate != NULL);

	LPCDLGTEMPLATE lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
	BOOL bResult = CreateIndirect(lpDialogTemplate, pParentWnd, NULL, hInst);
	UnlockResource(hDialogTemplate);

	return bResult;
}
コード例 #7
0
BOOL CMessageBox::Create(CWnd *pWnd,UINT msg,WORD wParamHigh)
{
	m_bModeless=true;
	if(0!=msg){
		ASSERT(NULL!=pWnd);
		m_pParentNotify=pWnd;
		m_nParentNotifcationMessage=msg;
		m_nParentNotifcationwParamHigh=wParamHigh;
	}
	return CreateIndirect (&DlgData.tmpl,pWnd); 
}
コード例 #8
0
BOOL CXTPTaskDialogFrame::Create(CWnd* pParentWnd)
{
    if (m_lpDlgTemplate == NULL)
    {
        const int nDlgTemplateSize = sizeof(DLGTEMPLATE) + sizeof(DWORD) * 8;
        m_lpDlgTemplate =  (DLGTEMPLATE*)malloc(nDlgTemplateSize);
        ZeroMemory(m_lpDlgTemplate, nDlgTemplateSize);
    }

    if (!m_lpDlgTemplate)
        return FALSE;

    m_lpDlgTemplate->style = GetFrameStyle() | WS_VISIBLE;

    m_lpDlgTemplate->dwExtendedStyle = m_pConfig->dwFlags & TDF_RTL_LAYOUT ? WS_EX_LAYOUTRTL : 0;

    return CreateIndirect(m_lpDlgTemplate, pParentWnd ? pParentWnd : m_pParentWnd, NULL);
}
コード例 #9
0
ファイル: dlgcore.cpp プロジェクト: anyue100/winscp
// for backward compatibility
BOOL CDialog::CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
	void* lpDialogInit)
{
	return CreateIndirect(lpDialogTemplate, pParentWnd, lpDialogInit, NULL);
}
コード例 #10
0
ファイル: dlgcore.cpp プロジェクト: anyue100/winscp
// for backward compatibility
BOOL CDialog::CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd)
{
	return CreateIndirect(hDialogTemplate, pParentWnd, NULL);
}
コード例 #11
0
ファイル: DynDialogEx.cpp プロジェクト: zphseu/cuiyan
int CDynDialogEx::DoModal() 
{
	//Do we need OK and Cancel buttons??
	if (m_bAddSystemButtons) {
		AddSystemButtons();
	}

	//
	// Get font info from mainwindow of the application
	//
	CFont* pParentFont = m_pFont;
	if (pParentFont == NULL && m_pParentWnd != NULL) {
		pParentFont = m_pParentWnd->GetFont();
	}
	if (pParentFont == NULL && AfxGetApp()->m_pActiveWnd != NULL) {
		pParentFont = AfxGetApp()->m_pActiveWnd->GetFont();
	}
	LOGFONT LogFont;
	memset(&LogFont, 0x00, sizeof(LogFont));
	if (pParentFont != NULL) {
		pParentFont->GetLogFont(&LogFont);
	}
	else {
		// Can do better???
		strcpy(LogFont.lfFaceName, _T("MS Sans Serif"));
		LogFont.lfHeight = 8;
	}

	//Prework for setting font in dialog...
	int cWC = MultiByteToWideChar(CP_ACP, 0, LogFont.lfFaceName, -1, NULL, 0);
	int nFontNameLen = cWC + 1;
	WCHAR *szFontName = new WCHAR[nFontNameLen];
	// Copy the string
	MultiByteToWideChar(CP_ACP, 0, LogFont.lfFaceName, -1, (LPWSTR) szFontName, cWC);
	szFontName[cWC] = 0;
	nFontNameLen = (cWC) * sizeof(WCHAR);

	if (m_wFontSize == 0) {
		m_wFontSize = (unsigned short)LogFont.lfHeight;
	}

	//Prework for setting caption in dialog...
	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 iRet = -1;
	//Here 's the stuff to build the dialog template in memory
	//without the controls being in the template
	//(Our first try, was this same template with some additional code
	//for each control placed on it, that's why this class is cold Ex :)
	//This gave some problems on WIN9x systems, where EDIT boxes
	//were not shown with 3D-look, but as flat controls)
	int nBufferSize =  sizeof(DLGTEMPLATE) + (2 * sizeof(WORD)) /*menu and class*/ + szBoxLen /*size of caption*/
		+ sizeof(WORD) /*fontsize*/ + nFontNameLen /*size of fontname*/;

	//Are there any subclassed controls...
	if (m_DialogTemplate.cdit > 0) {
		nBufferSize = (nBufferSize + 3) & ~3;  // adjust size to make first control DWORD aligned

		CDynDialogItemEx *pDynDialogItemEx = NULL;
		for (int i = 0; i < m_arrDlgItemPtr.GetSize(); i++) {
			pDynDialogItemEx = m_arrDlgItemPtr[i];
			if (pDynDialogItemEx != NULL) {
				if (pDynDialogItemEx->IsDlgItemSubclassed()) {
					int nItemLength = sizeof(DLGITEMTEMPLATE) + 3 * sizeof(WORD);
					nItemLength += (pDynDialogItemEx->GetCaptionLength() + 1) * sizeof(WCHAR);

					if (i != m_DialogTemplate.cdit - 1) {   // the last control does not need extra bytes
						nItemLength = (nItemLength + 3) & ~3;  // take into account gap so next control is DWORD aligned
					}
					nBufferSize += nItemLength;
				}
			}
		}
	}

	HLOCAL hLocal = LocalAlloc(LHND, nBufferSize);
	if (hLocal != NULL) {
		BYTE*	pBuffer = (BYTE*)LocalLock(hLocal);
		if (pBuffer == NULL) {
			LocalFree(hLocal);
			AfxMessageBox(_T("CDynDialogEx::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;

		*(WORD*)pdest = m_wFontSize;						// font size
		pdest += sizeof(WORD);
		memcpy(pdest, szFontName, nFontNameLen);		// font name
		pdest += nFontNameLen;

		// will now transfer the information for each one of subclassed controls...
		if (m_DialogTemplate.cdit > 0) {
			CDynDialogItemEx *pDynDialogItemEx = NULL;
			for (int i = 0; i < m_arrDlgItemPtr.GetSize(); i++) {
				pDynDialogItemEx = m_arrDlgItemPtr[i];
				if (pDynDialogItemEx != NULL) {
					if (pDynDialogItemEx->IsDlgItemSubclassed()) {
						pdest = pDynDialogItemEx->FillBufferWithItemTemplate(pdest);
					}
				}
			}
		}
		ASSERT(pdest - pBuffer == nBufferSize); // just make sure we did not overrun the heap

		//Next lines to make sure that MFC makes no ASSERTION when PREVIOUS/NEXT is pressed:)
		if (m_lpDialogTemplate != NULL) {
			m_lpDialogTemplate = NULL;
		}

		//These are the MFC functions, which do the job...
		if (m_bModelessDlg) {
			iRet = CreateIndirect((LPDLGTEMPLATE)pBuffer, m_pParentWnd);		
		}
		else {
			InitModalIndirect((LPDLGTEMPLATE)pBuffer, m_pParentWnd);
			iRet = CDialog::DoModal();
		}

		LocalUnlock(hLocal);
		LocalFree(hLocal);

		delete [] szBoxCaption;
		delete [] szFontName;
		return iRet;
	}
	else {
		AfxMessageBox(_T("CDynDialogEx::DoModal() : LocalAllock Failed"));
		return -1;
	}
}
コード例 #12
0
void CMemoryInfoEdit::Create( CWnd* pParentWnd )
{
    CreateIndirect( initDialog(hInstance,MAKEINTRESOURCE(CMemoryInfoEdit::IDD)), pParentWnd );

	//CDialog::Create( MAKEINTRESOURCE(CMemoryInfoEdit::IDD), wnd );
}
コード例 #13
0
ファイル: SearchDlg.cpp プロジェクト: BlueSpells/MapGen
bool CSearchDlg::Init()
{
    return CreateIndirect((LPCDLGTEMPLATE)SearchDialog, m_pParent) != 0;
}