示例#1
0
BOOL CMDIChildWnd::Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
                           const RECT &rect, CMDIFrameWnd *pParentWnd,
                           CCreateContext *pContext )
/***************************************************/
{
    if( pParentWnd == NULL ) {
        pParentWnd = (CMDIFrameWnd *)AfxGetMainWnd();
    }
    ASSERT( pParentWnd != NULL );
    ASSERT( pParentWnd->IsKindOf( RUNTIME_CLASS( CMDIFrameWnd ) ) );
    
    CREATESTRUCT cs;
    cs.dwExStyle = 0L;
    cs.lpszClass = lpszClassName;
    cs.lpszName = lpszWindowName;
    cs.style = dwStyle;
    cs.x = rect.left;
    cs.y = rect.top;
    cs.cx = rect.right - rect.left;
    cs.cy = rect.bottom - rect.top;
    cs.hwndParent = pParentWnd->m_hWnd;
    cs.hMenu = NULL;
    cs.hInstance = AfxGetInstanceHandle();
    cs.lpCreateParams = pContext;
    if( !PreCreateWindow( cs ) ) {
        PostNcDestroy();
        return( FALSE );
    }

    MDICREATESTRUCT mcs;
    mcs.szClass = cs.lpszClass;
    mcs.szTitle = cs.lpszName;
    mcs.hOwner = cs.hInstance;
    mcs.x = cs.x;
    mcs.y = cs.y;
    mcs.cx = cs.cx;
    mcs.cy = cs.cy;
    mcs.style = cs.style;
    mcs.lParam = (LPARAM)cs.lpCreateParams;
    AfxHookWindowCreate( this );
    HWND hWnd = (HWND)::SendMessage( pParentWnd->m_hWndMDIClient, WM_MDICREATE, 0,
                                     (LPARAM)&mcs );
    if( !AfxUnhookWindowCreate() ) {
        PostNcDestroy();
        return( FALSE );
    }
    if( hWnd == NULL ) {
        PostNcDestroy();
        return( FALSE );
    }
    ASSERT( m_hWnd == hWnd );

    return( TRUE );
}
示例#2
0
BOOL CFindDialog::Create(LPCTSTR lpszFindWhat, DWORD dwFlags, WhereType where, CWnd* pParentWnd)
{
    m_nFindPos=where;
	m_nIDHelp = AFX_IDD_FIND;
	m_fr.Flags |= dwFlags;

	ASSERT_VALID(pParentWnd);
	m_fr.hwndOwner = pParentWnd->m_hWnd;
	ASSERT(m_fr.hwndOwner != NULL); // must have a parent for modeless dialog

	m_fr.wFindWhatLen = sizeof(m_szFindWhat);

    int n=min(sizeof(m_szFindWhat)-1,_tcslen(lpszFindWhat));
	_tcsncpy(m_szFindWhat, lpszFindWhat, n);
    m_szFindWhat[n]=_TCHAR('\0');

	AfxHookWindowCreate(this);
    HWND hWnd = ::FindText(&m_fr);
    if (!AfxUnhookWindowCreate()){
		PostNcDestroy();
    }

	ASSERT(hWnd == NULL || hWnd == m_hWnd);
	return hWnd != NULL;
}
示例#3
0
LRESULT CSubclassWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    ASSERT(m_hWnd);
    ASSERT(m_hWndAfter);
    ASSERT(m_oldWndProc);
#if 0
    if(uMsg == WM_CLOSE) /*有时侯窗口处理完WM_CLOSE就没有WM_NCDESTROY了*/
    {
        WNDPROC hOld = Unsubclass();
        LRESULT lr = ::CallWindowProc(hOld, m_hWndAfter, uMsg, wParam, lParam);
        return lr;
    }
#endif
    if(uMsg == WM_NCDESTROY)//
    {
        LRESULT lr;
        if(m_hWnd != NULL)
        {
            WNDPROC hOld = Unsubclass();
            lr = ::CallWindowProc(hOld, m_hWndAfter, uMsg, wParam, lParam);
        }
        else
        {
            lr = ::DefWindowProc(m_hWndAfter, uMsg, wParam, lParam);
        }
        PostNcDestroy();
        return lr;
    }

    return ::CallWindowProc(m_oldWndProc, m_hWnd, uMsg, wParam, lParam);
}
示例#4
0
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;
}
示例#5
0
/**
 * 指定されたウィンドウを作成し、それを CWndProc オブジェクトにアタッチします
 * @param[in] dwExStyle 拡張ウィンドウ スタイル
 * @param[in] lpszClassName 登録されているシステム ウィンドウ クラスの名前
 * @param[in] lpszWindowName ウィンドウの表示名
 * @param[in] dwStyle ウィンドウ スタイル
 * @param[in] x 画面または親ウィンドウの左端からウィンドウの初期位置までの水平方向の距離
 * @param[in] y 画面または親ウィンドウの上端からウィンドウの初期位置までの垂直方向の距離
 * @param[in] nWidth ウィンドウの幅 (ピクセル単位)
 * @param[in] nHeight ウィンドウの高さ (ピクセル単位)
 * @param[in] hwndParent 親ウィンドウへのハンドル
 * @param[in] nIDorHMenu ウィンドウ ID
 * @param[in] lpParam ユーザー データ
 * @retval TRUE 成功
 * @retval FALSE 失敗
 */
BOOL CWndProc::CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hwndParent, HMENU nIDorHMenu, LPVOID lpParam)
{
	// 同じスレッドのみ許す
	if (sm_dwThreadId != ::GetCurrentThreadId())
	{
		PostNcDestroy();
		return FALSE;
	}

	CREATESTRUCT cs;
	cs.dwExStyle = dwExStyle;
	cs.lpszClass = lpszClassName;
	cs.lpszName = lpszWindowName;
	cs.style = dwStyle;
	cs.x = x;
	cs.y = y;
	cs.cx = nWidth;
	cs.cy = nHeight;
	cs.hwndParent = hwndParent;
	cs.hMenu = nIDorHMenu;
	cs.hInstance = sm_hInstance;
	cs.lpCreateParams = lpParam;

	if (!PreCreateWindow(cs))
	{
		PostNcDestroy();
		return FALSE;
	}

	sm_pWndInit = this;
	HWND hWnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszClass, cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy, cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);
	if (sm_pWndInit != NULL)
	{
		sm_pWndInit = NULL;
		PostNcDestroy();
	}

	return (hWnd != NULL) ? TRUE : FALSE;
}
示例#6
0
BOOL CFormView::Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
                        const RECT &rect, CWnd *pParentWnd, UINT nID,
                        CCreateContext *pContext )
/************************************************/
{
    UNUSED_ALWAYS( lpszClassName );
    UNUSED_ALWAYS( lpszWindowName );

    CREATESTRUCT cs;
    memset( &cs, 0, sizeof( CREATESTRUCT ) );
    cs.style = dwStyle;
    if( !PreCreateWindow( cs ) ) {
        PostNcDestroy();
        return( FALSE );
    }

    m_pCreateContext = pContext;
    AfxHookWindowCreate( this );
    HWND hWnd = ::CreateDialogParam( AfxGetInstanceHandle(), m_lpszTemplateName,
                                     pParentWnd->GetSafeHwnd(), AfxDlgProc, 0L );
    AfxUnhookWindowCreate();
    m_pCreateContext = NULL;
    
    if( hWnd == NULL ) {
        PostNcDestroy();
        return( FALSE );
    }
    ASSERT( m_hWnd == hWnd );

    CRect rectDialog;
    ::GetWindowRect( hWnd, &rectDialog );
    SetScrollSizes( MM_TEXT, rectDialog.Size() );

    ::SetWindowLong( hWnd, GWL_ID, nID );
    ::SetWindowPos( hWnd, NULL, rect.left, rect.top, rect.right - rect.left,
                    rect.bottom - rect.top,
                    SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
    return( TRUE );
}
示例#7
0
BOOL CDialogBar::Create( CWnd *pParentWnd, LPCTSTR lpszTemplateName, UINT nStyle,
                         UINT nID )
/*******************************************************************************/
{
    m_dwStyle = nStyle & CBRS_ALL;
    
    CREATESTRUCT cs;
    memset( &cs, 0, sizeof( CREATESTRUCT ) );
    cs.lpszClass = _T("AfxControlBar");
    cs.style = nStyle | WS_CHILD;
    cs.hwndParent = pParentWnd->GetSafeHwnd();
    cs.hMenu = (HMENU)nID;
    cs.hInstance = AfxGetInstanceHandle();
    if( !PreCreateWindow( cs ) ) {
        PostNcDestroy();
        return( FALSE );
    }

    AfxHookWindowCreate( this );
    HWND hWnd = ::CreateDialogParam( AfxGetInstanceHandle(), lpszTemplateName,
                                     pParentWnd->GetSafeHwnd(), AfxDlgProc, 0L );
    AfxUnhookWindowCreate();

    if( hWnd == NULL ) {
        PostNcDestroy();
        return( FALSE );
    }
    ASSERT( m_hWnd == hWnd );

    CRect rect;
    ::GetWindowRect( hWnd, &rect );
    m_sizeDefault = rect.Size();

    ::SetWindowLong( hWnd, GWL_ID, nID );
    ::SetWindowPos( hWnd, NULL, 0, 0, 0, 0,
                    SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
    return( TRUE );
}
示例#8
0
BOOL BaseDialog::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd, HINSTANCE hInst)
{
  if(!hInst)
    hInst = AfxGetResourceHandle();

  HGLOBAL hTemplate = NULL;
  HWND hWnd = NULL;

  TRY
  {
    CDialogTemplate dlgTemp(lpDialogTemplate);
    SetFont(dlgTemp);
    hTemplate = dlgTemp.Detach();
    lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate);

    m_nModalResult = -1;
    m_nFlags |= WF_CONTINUEMODAL;

    AfxHookWindowCreate(this);
    hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
      pParentWnd->GetSafeHwnd(), AfxDlgProc);
  }
  CATCH_ALL(e)
  {
    e->Delete();
    m_nModalResult = -1;
  }
  END_CATCH_ALL

  if (!AfxUnhookWindowCreate())
    PostNcDestroy();

  if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
  {
    ::DestroyWindow(hWnd);
    hWnd = NULL;
  }

  if (hTemplate != NULL)
  {
    GlobalUnlock(hTemplate);
    GlobalFree(hTemplate);
  }

  if (hWnd == NULL)
    return FALSE;
  return TRUE;
}
示例#9
0
/**
 * Windows のウィンドウが破棄されるときに非クライアント領域が破棄されると、最後に呼び出されたメンバー関数は、フレームワークによって呼び出されます
 * @param[in] wParam パラメタ
 * @param[in] lParam パラメタ
 */
void CWndProc::OnNcDestroy(WPARAM wParam, LPARAM lParam)
{
	LONG_PTR pfnWndProc = ::GetWindowLongPtr(m_hWnd, GWLP_WNDPROC);
	DefWindowProc(WM_NCDESTROY, wParam, lParam);
	if (::GetWindowLong(m_hWnd, GWLP_WNDPROC) == pfnWndProc)
	{
		if (m_pfnSuper != NULL)
		{
			::SetWindowLongPtr(m_hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(m_pfnSuper));
			m_pfnSuper = NULL;
		}
	}
	Detach();

	// call special post-cleanup routine
	PostNcDestroy();
}
示例#10
0
// WM_NCDESTROY handler
//  cleansup the data and unsubclasses the window
//  calls PostNcDestroy
BOOL cef_window::HandleNcDestroy()
{
    WNDPROC superWndProc = WNDPROC(GetWindowLongPtr(GWLP_WNDPROC));

    RemoveProp(::gCefClientWindowPropName);

    DefaultWindowProc(WM_NCDESTROY, 0, 0);

    if ((WNDPROC(GetWindowLongPtr(GWLP_WNDPROC)) == superWndProc) && (mSuperWndProc != NULL))
        SetWindowLongPtr(GWLP_WNDPROC, reinterpret_cast<INT_PTR>(mSuperWndProc));

    mSuperWndProc = NULL;

    PostNcDestroy();

    return TRUE;
}
示例#11
0
// Window Message Dispatching
LRESULT cef_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
    case WM_NCDESTROY:
        if (HandleNcDestroy())
            return 0L;
        break;
    }

    LRESULT lr = DefaultWindowProc(message, wParam, lParam);

    if (message == WM_NCDESTROY)
    {
        PostNcDestroy();
    }

    return lr;
}
示例#12
0
文件: dlgfr.cpp 项目: Rupan/winscp
BOOL CFindReplaceDialog::Create(BOOL bFindDialogOnly,
	LPCTSTR lpszFindWhat, LPCTSTR lpszReplaceWith,
	DWORD dwFlags, CWnd* pParentWnd)
{
	ASSERT_VALID(this);
	ASSERT(m_fr.Flags & FR_ENABLEHOOK);
	ASSERT(m_fr.lpfnHook != NULL);

	m_nIDHelp = bFindDialogOnly ? AFX_IDD_FIND : AFX_IDD_REPLACE;

	m_fr.wFindWhatLen = _countof(m_szFindWhat);
	m_fr.lpstrReplaceWith = (LPTSTR)m_szReplaceWith;
	m_fr.wReplaceWithLen = _countof(m_szReplaceWith);
	m_fr.Flags |= dwFlags;

	if (pParentWnd == NULL)
		m_fr.hwndOwner = AfxGetMainWnd()->GetSafeHwnd();
	else
	{
		ASSERT_VALID(pParentWnd);
		m_fr.hwndOwner = pParentWnd->m_hWnd;
	}
	ASSERT(m_fr.hwndOwner != NULL); // must have a parent for modeless dialog

	if (lpszFindWhat != NULL)
		lstrcpyn(m_szFindWhat, lpszFindWhat, _countof(m_szFindWhat));

	if (lpszReplaceWith != NULL)
		lstrcpyn(m_szReplaceWith, lpszReplaceWith, _countof(m_szReplaceWith));

	HWND hWnd;

	AfxHookWindowCreate(this);
	if (bFindDialogOnly)
		hWnd = ::FindText(&m_fr);
	else
		hWnd = ::ReplaceText(&m_fr);
	if (!AfxUnhookWindowCreate())
		PostNcDestroy();

	ASSERT(hWnd == NULL || hWnd == m_hWnd);
	return hWnd != NULL;
}
示例#13
0
BOOL CMDIChildWnd::Create(LPCTSTR lpszClassName,
	LPCTSTR lpszWindowName, DWORD dwStyle,
	const RECT& rect, CMDIFrameWnd* pParentWnd,
	CCreateContext* pContext)
{
	if (pParentWnd == NULL)
	{
		CWinThread *pThread = AfxGetThread();
		ENSURE_VALID(pThread);
		CWnd* pMainWnd = pThread->m_pMainWnd;
		ENSURE_VALID(pMainWnd);
		ASSERT_KINDOF(CMDIFrameWnd, pMainWnd);
		pParentWnd = (CMDIFrameWnd*)pMainWnd;
	}
	ASSERT(::IsWindow(pParentWnd->m_hWndMDIClient));

	// insure correct window positioning
	pParentWnd->RecalcLayout();

	// first copy into a CREATESTRUCT for PreCreate
	CREATESTRUCT cs;
	cs.dwExStyle = 0L;
	cs.lpszClass = lpszClassName;
	cs.lpszName = lpszWindowName;
	cs.style = dwStyle;
	cs.x = rect.left;
	cs.y = rect.top;
	cs.cx = rect.right - rect.left;
	cs.cy = rect.bottom - rect.top;
	cs.hwndParent = pParentWnd->m_hWnd;
	cs.hMenu = NULL;
	cs.hInstance = AfxGetInstanceHandle();
	cs.lpCreateParams = (LPVOID)pContext;

	if (!PreCreateWindow(cs))
	{
		PostNcDestroy();
		return FALSE;
	}
	// extended style must be zero for MDI Children (except under Win4)
	ASSERT(cs.hwndParent == pParentWnd->m_hWnd);    // must not change

	// now copy into a MDICREATESTRUCT for real create
	MDICREATESTRUCT mcs;
	mcs.szClass = cs.lpszClass;
	mcs.szTitle = cs.lpszName;
	mcs.hOwner = cs.hInstance;
	mcs.x = cs.x;
	mcs.y = cs.y;
	mcs.cx = cs.cx;
	mcs.cy = cs.cy;
	mcs.style = cs.style & ~(WS_MAXIMIZE | WS_VISIBLE);
	mcs.lParam = (LPARAM)cs.lpCreateParams;

	// create the window through the MDICLIENT window
	AfxHookWindowCreate(this);
	HWND hWnd = (HWND)::SendMessage(pParentWnd->m_hWndMDIClient,
		WM_MDICREATE, 0, (LPARAM)&mcs);
	if (!AfxUnhookWindowCreate())
		PostNcDestroy();        // cleanup if MDICREATE fails too soon

	if (hWnd == NULL)
		return FALSE;

	// special handling of visibility (always created invisible)
	if (cs.style & WS_VISIBLE)
	{
		// place the window on top in z-order before showing it
		::BringWindowToTop(hWnd);

		// show it as specified
		if (cs.style & WS_MINIMIZE)
			ShowWindow(SW_SHOWMINIMIZED);
		else if (cs.style & WS_MAXIMIZE)
			ShowWindow(SW_SHOWMAXIMIZED);
		else
			ShowWindow(SW_SHOWNORMAL);

		// make sure it is active (visibility == activation)
		pParentWnd->MDIActivate(this);

		// refresh MDI Window menu
		::SendMessage(pParentWnd->m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0);
	}

	ASSERT(hWnd == m_hWnd);
	return TRUE;
}
示例#14
0
BOOL CWnd::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate,
	CWnd* pParentWnd, HINSTANCE hInst)
{
	ASSERT(lpDialogTemplate != NULL);
	if (pParentWnd != NULL)
		ASSERT_VALID(pParentWnd);

	if (hInst == NULL)
		hInst = AfxGetInstanceHandle();

#ifndef _AFX_NO_OCC_SUPPORT
	_AFX_OCC_DIALOG_INFO occDialogInfo;
	COccManager* pOccManager = afxOccManager;
#endif

	HGLOBAL hTemplate = NULL;

	HWND hWnd = NULL;
#ifdef _DEBUG
	DWORD dwError = 0;
#endif

	TRY
	{
		VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
		AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);

#ifndef _AFX_NO_OCC_SUPPORT
		// separately create OLE controls in the dialog template
		if (pOccManager != NULL)
		{
			if (!SetOccDialogInfo(&occDialogInfo))
				return FALSE;

			lpDialogTemplate = pOccManager->PreCreateDialog(&occDialogInfo,
				lpDialogTemplate);
		}

		if (lpDialogTemplate == NULL)
			return FALSE;
#endif //!_AFX_NO_OCC_SUPPORT

		// If no font specified, set the system font.
		CString strFace;
		WORD wSize = 0;
		BOOL bSetSysFont = !CDialogTemplate::GetFont(lpDialogTemplate, strFace,
			wSize);

		// On DBCS systems, also change "MS Sans Serif" or "Helv" to system font.
		if ((!bSetSysFont) && GetSystemMetrics(SM_DBCSENABLED))
		{
			bSetSysFont = (strFace == _T("MS Shell Dlg") ||
				strFace == _T("MS Sans Serif") || strFace == _T("Helv"));
			if (bSetSysFont && (wSize == 8))
				wSize = 0;
		}

		if (bSetSysFont)
		{
			CDialogTemplate dlgTemp(lpDialogTemplate);
			dlgTemp.SetSystemFont(wSize);
			hTemplate = dlgTemp.Detach();
		}

		if (hTemplate != NULL)
			lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate);

		// setup for modal loop and creation
		m_nModalResult = -1;
		m_nFlags |= WF_CONTINUEMODAL;

		// create modeless dialog
		AfxHookWindowCreate(this);
		hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
			pParentWnd->GetSafeHwnd(), AfxDlgProc);
#ifdef _DEBUG
		dwError = ::GetLastError();
#endif
	}
	CATCH_ALL(e)
	{
		DELETE_EXCEPTION(e);
		m_nModalResult = -1;
	}
	END_CATCH_ALL

#ifndef _AFX_NO_OCC_SUPPORT
	if (pOccManager != NULL)
	{
		pOccManager->PostCreateDialog(&occDialogInfo);
		if (hWnd != NULL)
			SetOccDialogInfo(NULL);
	}
#endif //!_AFX_NO_OCC_SUPPORT

	if (!AfxUnhookWindowCreate())
		PostNcDestroy();        // cleanup if Create fails too soon

	// handle EndDialog calls during OnInitDialog
	if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
	{
		::DestroyWindow(hWnd);
		hWnd = NULL;
	}

	if (hTemplate != NULL)
	{
		GlobalUnlock(hTemplate);
		GlobalFree(hTemplate);
	}

	// help with error diagnosis (only if WM_INITDIALOG didn't EndDialog())
	if (hWnd == NULL && (m_nFlags & WF_CONTINUEMODAL))
	{
#ifdef _DEBUG
#ifndef _AFX_NO_OCC_SUPPORT
		if (afxOccManager == NULL)
		{
			TRACE0(">>> If this dialog has OLE controls:\n");
			TRACE0(">>> AfxEnableControlContainer has not been called yet.\n");
			TRACE0(">>> You should call it in your app's InitInstance function.\n");
		}
		else if (dwError != 0)
		{
			TRACE1("Warning: Dialog creation failed!  GetLastError returns 0x%8.8X\n", dwError);
		}
#endif //!_AFX_NO_OCC_SUPPORT
#endif //_DEBUG
		return FALSE;
	}

	ASSERT(hWnd == m_hWnd);
	return TRUE;
}
示例#15
0
BOOL CDialogBar::Create(CWnd* pParentWnd, LPCTSTR lpszTemplateName,
	UINT nStyle, UINT nID)
{
	ASSERT(pParentWnd != NULL);
	ASSERT(lpszTemplateName != NULL);

#ifdef _DEBUG
	// dialog template must exist and be invisible with WS_CHILD set
	if (!_AfxCheckDialogTemplate(lpszTemplateName, TRUE))
	{
		ASSERT(FALSE);          // invalid dialog template name
		PostNcDestroy();        // cleanup if Create fails too soon
		return FALSE;
	}
#endif //_DEBUG

	// allow chance to modify styles
	m_dwStyle = (nStyle & CBRS_ALL);
	CREATESTRUCT cs;
	memset(&cs, 0, sizeof(cs));
	cs.lpszClass = _afxWndControlBar;
	cs.style = (DWORD)nStyle | WS_CHILD;
	cs.hMenu = (HMENU)nID;
	cs.hInstance = AfxGetInstanceHandle();
	cs.hwndParent = pParentWnd->GetSafeHwnd();
	if (!PreCreateWindow(cs))
		return FALSE;

	// create a modeless dialog

#ifndef _AFX_NO_OCC_SUPPORT
	m_lpszTemplateName = lpszTemplateName;
#endif

	// initialize common controls
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
	AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);

	BOOL bSuccess = CreateDlg(lpszTemplateName, pParentWnd);

#ifndef _AFX_NO_OCC_SUPPORT
	m_lpszTemplateName = NULL;
#endif

	if (!bSuccess)
		return FALSE;

	// dialog template MUST specify that the dialog
	//  is an invisible child window
	SetDlgCtrlID(nID);
	CRect rect;
	GetWindowRect(&rect);
	m_sizeDefault = rect.Size();    // set fixed size

	// force WS_CLIPSIBLINGS
	ModifyStyle(0, WS_CLIPSIBLINGS);

	if (!ExecuteDlgInit(lpszTemplateName))
		return FALSE;

	// force the size to zero - resizing bar will occur later
	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);

	return TRUE;
}
示例#16
0
BOOL COXSizeDialogBar::Create(CWnd* pParentWnd, LPCTSTR lpszTemplateName,
							  UINT nStyle, UINT nID)
{
	ASSERT(pParentWnd != NULL);
	ASSERT(lpszTemplateName != NULL);
	ASSERT((nStyle & WS_THICKFRAME)==NULL);
	
// Alas, MFC doesn't export many of the debugg-only functions, but I've added
// the code for this safety net as it helps track down errors faster, and
// only has an overhead in debug code
#ifdef _DEBUG
// dialog template must exist and be invisible with WS_CHILD set
	if (!CheckDialogTemplate(lpszTemplateName, TRUE))
	{
		ASSERT(FALSE);          // invalid dialog template name
		PostNcDestroy();        // cleanup if Create fails too soon
		return FALSE;
	}
#endif //_DEBUG

	// allow chance to modify styles
#if _MFC_VER <= 0x0421
	m_dwStyle = nStyle;
#else
    m_dwStyle = nStyle&CBRS_ALL;
#endif
	CREATESTRUCT cs;
	memset(&cs, 0, sizeof(cs));
	cs.lpszClass = _afxWndControlBar;
	cs.style = (DWORD)nStyle | WS_CHILD;
	cs.hMenu = (HMENU)(UINT_PTR)nID;
	cs.hInstance = AfxGetInstanceHandle();
	cs.hwndParent = pParentWnd->GetSafeHwnd();
	if (!PreCreateWindow(cs))
		return FALSE;
	
	// create a modeless dialog
#ifndef _AFX_NO_OCC_SUPPORT
	m_lpszTemplateName = lpszTemplateName;
#endif

	// initialize common controls
	//VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));

	BOOL bSuccess = CreateDlg(lpszTemplateName, pParentWnd);

#ifndef _AFX_NO_OCC_SUPPORT
	m_lpszTemplateName = NULL;
#endif

	if (!bSuccess)
		return FALSE;
	
	// dialog template MUST specify that the dialog
	//  is an invisible child window
	SetDlgCtrlID(nID);
	CRect rect;
	
	
	// force WS_CLIPSIBLINGS
	// I also remove the titlebar. This means the resource can include a caption, which
	// will be used when the frame is floating.
	ModifyStyle(WS_CAPTION, WS_CLIPSIBLINGS);		
	if (!ExecuteDlgInit(lpszTemplateName))
		return FALSE;
	
	// m_sizeDefault isn't actually used by the COXSizeDialogBar, but since it's public, it
	// seemed sensible to keep it available. Otherwise it might be difficult to get hold
	// of the original size of the dialog (as specified in the resource file). 
	
	//GetWindowRect(&rect);
	GetClientRect(&rect);
	m_sizeDefault = rect.Size();    // set fixed size
	
	// Move to position 0,0
	// NB: size not forced to zero, as this can affect resizing if bar is 
	// immediately docked
	SetWindowPos(NULL, 0, 0, 0, 0, 
		SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_FRAMECHANGED);
	
	// set all the sizes to be the default after the positioning done above
	m_VertDockSize 	= m_sizeDefault;
	m_HorzDockSize  = m_sizeDefault;
	m_FloatSize 	= m_sizeDefault;
	
	
	// if auto-sizing, store the rectangles of all the child windows.
	if(m_Style & SZBARF_DLGAUTOSIZE)	
	{
		m_GadgetResizeHandle = CreateGadgetResizeHandle(this);
	}

	return TRUE;
}
示例#17
0
// virtual override of CWnd::Create
BOOL CFormView::Create(LPCTSTR /*lpszClassName*/, LPCTSTR /*lpszWindowName*/,
                       DWORD dwRequestedStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,
                       CCreateContext* pContext)
{
    ASSERT(pParentWnd != NULL);
    ASSERT(m_lpszTemplateName != NULL);

    m_pCreateContext = pContext;    // save state for later OnCreate

#ifdef _DEBUG
    // dialog template must exist and be invisible with WS_CHILD set
    if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE))
    {
        ASSERT(FALSE);          // invalid dialog template name
        PostNcDestroy();        // cleanup if Create fails too soon
        return FALSE;
    }
#endif //_DEBUG

    // initialize common controls
    VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
    AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);

    // call PreCreateWindow to get prefered extended style
    CREATESTRUCT cs;
    memset(&cs, 0, sizeof(CREATESTRUCT));
    if (dwRequestedStyle == 0)
        dwRequestedStyle = AFX_WS_DEFAULT_VIEW;
    cs.style = dwRequestedStyle;
    if (!PreCreateWindow(cs))
        return FALSE;

    // create a modeless dialog
    if (!CreateDlg(m_lpszTemplateName, pParentWnd))
        return FALSE;

    m_pCreateContext = NULL;

    // we use the style from the template - but make sure that
    //  the WS_BORDER bit is correct
    // the WS_BORDER bit will be whatever is in dwRequestedStyle
    ModifyStyle(WS_BORDER|WS_CAPTION, cs.style & (WS_BORDER|WS_CAPTION));
    ModifyStyleEx(WS_EX_CLIENTEDGE, cs.dwExStyle & WS_EX_CLIENTEDGE);

    SetDlgCtrlID(nID);

    CRect rectTemplate;
    GetWindowRect(rectTemplate);
    SetScrollSizes(MM_TEXT, rectTemplate.Size());

    // initialize controls etc
    if (!ExecuteDlgInit(m_lpszTemplateName))
        return FALSE;

    // force the size requested
    SetWindowPos(NULL, rect.left, rect.top,
                 rect.right - rect.left, rect.bottom - rect.top,
                 SWP_NOZORDER|SWP_NOACTIVATE);

    // make visible if requested
    if (dwRequestedStyle & WS_VISIBLE)
        ShowWindow(SW_NORMAL);

    return TRUE;
}
示例#18
0
BOOL SourceEdit::Create(CWnd* parent, UINT id)
{
  CREATESTRUCT cs;
  ::ZeroMemory(&cs,sizeof cs);
  cs.lpszClass = "Scintilla";
  cs.style = WS_VISIBLE|WS_CHILD|WS_CLIPCHILDREN;
  cs.hwndParent = parent->GetSafeHwnd();
  cs.hMenu = (HMENU)(UINT_PTR)id;
  cs.hInstance = AfxGetInstanceHandle();

  if (!PreCreateWindow(cs))
  {
    PostNcDestroy();
    return FALSE;
  }
  HWND wnd = ::CreateWindowEx(cs.dwExStyle,cs.lpszClass,cs.lpszName,cs.style,
    cs.x,cs.y,cs.cx,cs.cy,cs.hwndParent,cs.hMenu,cs.hInstance,cs.lpCreateParams);
  if (wnd == NULL)
    return FALSE;

  // Get the Unicode state of the 'real' window procedure before subclassing
  BOOL isUnicode = ::IsWindowUnicode(wnd);
  if (!SubclassWindow(wnd))
    return FALSE;

  CSize fontSize = theApp.MeasureFont(theApp.GetFont(InformApp::FontDisplay));
  m_editPtr = (sptr_t)SendMessage(SCI_GETDIRECTPOINTER);

  CallEdit(SCI_SETKEYSUNICODE,isUnicode);
  CallEdit(SCI_SETCODEPAGE,SC_CP_UTF8);
  CallEdit(SCI_SETEOLMODE,SC_EOL_LF);
  CallEdit(SCI_SETPASTECONVERTENDINGS,1);
  CallEdit(SCI_SETWRAPMODE,1);
  CallEdit(SCI_SETMODEVENTMASK,SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT);
  for (int i = 0; i < 5; i++)
    CallEdit(SCI_SETMARGINWIDTHN,i,0);
  CallEdit(SCI_SETMARGINLEFT,0,fontSize.cx);
  CallEdit(SCI_SETMARGINRIGHT,0,fontSize.cx);
  CallEdit(SCI_SETSELFORE,TRUE,::GetSysColor(COLOR_HIGHLIGHTTEXT));
  CallEdit(SCI_SETSELBACK,TRUE,::GetSysColor(COLOR_HIGHLIGHT));
  CallEdit(SCI_MARKERDEFINE,m_marker,SC_MARK_BACKGROUND);
  CallEdit(SCI_SETLEXER,SCLEX_CONTAINER);
  CallEdit(SCI_INDICSETSTYLE,0,INDIC_SQUIGGLE);
  CallEdit(SCI_INDICSETFORE,0,theApp.GetColour(InformApp::ColourError));
  CallEdit(SCI_SETINDICATORCURRENT,0);
  SetStyles();

  // Change the bindings for the Home and End keys
  CallEdit(SCI_ASSIGNCMDKEY,SCK_HOME,SCI_HOMEDISPLAY);
  CallEdit(SCI_ASSIGNCMDKEY,SCK_HOME+(SCMOD_SHIFT<<16),SCI_HOMEDISPLAYEXTEND);
  CallEdit(SCI_ASSIGNCMDKEY,SCK_HOME+(SCMOD_ALT<<16),SCI_HOME);
  CallEdit(SCI_ASSIGNCMDKEY,SCK_HOME+((SCMOD_ALT|SCMOD_SHIFT)<<16),SCI_HOMEEXTEND);
  CallEdit(SCI_ASSIGNCMDKEY,SCK_END,SCI_LINEENDDISPLAY);
  CallEdit(SCI_ASSIGNCMDKEY,SCK_END+(SCMOD_SHIFT<<16),SCI_LINEENDDISPLAYEXTEND);
  CallEdit(SCI_ASSIGNCMDKEY,SCK_END+(SCMOD_ALT<<16),SCI_LINEEND);
  CallEdit(SCI_ASSIGNCMDKEY,SCK_END+((SCMOD_ALT|SCMOD_SHIFT)<<16),SCI_LINEENDEXTEND);

  // Remove unwanted key bindings
  CallEdit(SCI_CLEARCMDKEY,SCK_ADD+(SCMOD_CTRL<<16));
  CallEdit(SCI_CLEARCMDKEY,SCK_SUBTRACT+(SCMOD_CTRL<<16));
  CallEdit(SCI_CLEARCMDKEY,SCK_DIVIDE+(SCMOD_CTRL<<16));

  return TRUE;
}
示例#19
0
void CCalculator::OnOK() 
{
	CDialog::OnOK();
	PostNcDestroy();
}