BOOL CCoolDialogBar::Create(CWnd* pParentWnd, CDialog *pDialog, CString &pTitle, UINT nID, DWORD dwStyle) { ASSERT_VALID(pParentWnd); // must have a parent ASSERT (!((dwStyle & CBRS_SIZE_FIXED) && (dwStyle & CBRS_SIZE_DYNAMIC))); // save the style -- AMENDED by Holger Thiele - Thankyou m_dwStyle = dwStyle & CBRS_ALL; // create the base window CString wndclass = AfxRegisterWndClass(CS_DBLCLKS, LoadCursor(NULL, IDC_ARROW), m_brushBkgd, 0); // JC: changed the nId from 0 to 1234, to fix some problems if (!CWnd::Create(wndclass, pTitle, dwStyle, CRect(0,0,0,0), pParentWnd, 1234/*0*/)) return FALSE; // create the child dialog m_cDialog = pDialog; m_cDialog->Create(nID, this); // JC: added patch to fix the problem with LoadBarState SetDlgCtrlID(nID); // use the dialog dimensions as default base dimensions CRect rc; m_cDialog->GetWindowRect(rc); m_sizeHorz = m_sizeVert = m_sizeFloat = rc.Size(); m_sizeHorz.cy += m_cxEdge + m_cxBorder; m_sizeVert.cx += m_cxEdge + m_cxBorder; return TRUE; }
BOOL CTDLFilterBar::Create(CWnd* pParentWnd, UINT nID, BOOL bVisible) { if (CDialog::Create(IDD_FILTER_BAR, pParentWnd)) { SetDlgCtrlID(nID); ShowWindow(bVisible ? SW_SHOW : SW_HIDE); return TRUE; } return FALSE; }
bool MFCDataEditorTScale::CreateTScale( CRect &r, CWnd *w, UINT id, MFCSequenceEditor *ed) { editor = ed; if (!Create(_T("STATIC"), "timeline", WS_CHILD|WS_VISIBLE /*|WS_CLIPSIBLINGS*/ /*|TBS_TOOLTIPS*/, r, w, id)) { return false; } ed->xscale = this; SetDlgCtrlID(id); // CToolTipCtrl *t=GetToolTips(); return true; }
bool ViewerToolBar::Create(CWnd* parent, UINT id) { // rebar_band_id_ = rebar_band_id; small_icons_ = AfxGetApp()->GetProfileInt(REGISTRY_SECTION_TOOLBAR, REG_ICONS, 0) == 0; int bmp_id= small_icons_ ? IDB_VIEWER_TOOLBAR : IDB_VIEWER_TOOLBAR_BIG; Derived::Params p; if (small_icons_) p.arrow_down_img_id = IDR_ARROW_DOWN_IMG; else p.arrow_down_img_id = IDR_ARROW_DOWN_IMG; if (!Derived::Create(parent, tb_buttons, commands, bmp_id, &p)) return false; SetOnIdleUpdateState(true); CSize s= Derived::Size(); SetWindowPos(0, 0, 0, s.cx, s.cy, SWP_NOZORDER | SWP_NOACTIVATE); SetDlgCtrlID(id); //SetPadding(4, 4); //if (IsWhistlerLookAvailable()) // SetPadding(0, -2); // btn with down arrow section inflates total buttons height //if (!Derived::Create(tb_buttons, commands, bmp_id, 0, parent, id)) // return false; //// img list for disabled images //CreateDisabledImageList(bmp_id, saturation, lightness); //ModifyStyle(0, CCS_ADJUSTABLE); RestoreState(REGISTRY_SECTION_TOOLBAR, REG_STATE); CRect rect; GetWindowRect(rect); SetWindowPos(0, 0, 0, rect.Width() + 8, rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); return true; }
BOOL CRuntimeDlg::Create(LPCTSTR szCaption, DWORD dwStyle, DWORD dwExStyle, const CRect& rect, CWnd* pParentWnd, UINT nID) { // cache and remove visibility BOOL bVisible = (dwStyle & WS_VISIBLE); dwStyle &= ~WS_VISIBLE; // remove DS_SETFONT (not supported) dwStyle &= ~DS_SETFONT; if (dwStyle & WS_CHILD) { dwStyle |= DS_CONTROL; dwExStyle |= WS_EX_CONTROLPARENT; } // create modeless dialog AfxHookWindowCreate(this); if (CreateDlgIndirect(RTDLGTEMPLATE(dwStyle, dwExStyle, rect), pParentWnd, NULL) != NULL) { // notify parent if we're a child window if (pParentWnd && (dwStyle & WS_CHILD) && !(dwExStyle & WS_EX_NOPARENTNOTIFY)) pParentWnd->SendMessage(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, nID), (LPARAM)GetSafeHwnd()); SetInitialPos(rect, dwStyle); // set window text SetWindowText(szCaption); // set control id SetDlgCtrlID(nID); PostCreate(); // for derived classes // reshow? if (bVisible) ShowWindow(SW_SHOW); return TRUE; } return FALSE; }
HRESULT CTRiASToolBar::SetBarID (int iCtrlID, BOOL fAdjustWnd) { #if !defined(_USE_SEC_CLASSES) UINT uiOldID = m_uiID; if (fAdjustWnd) { uiOldID = SetDlgCtrlID (iCtrlID); ASSERT(uiOldID == m_uiID); } if ((int)m_uiID != iCtrlID) { m_uiID = (UINT)iCtrlID; return m_pMainFrm -> RemapBarID (m_pIBar, uiOldID, m_uiID); } return S_OK; #else // nicht mehr einstellbar, da intern vorgegeben return S_OK; #endif // !_USE_SEC_CLASSES }
bool MFCQuaRotor::CreateRotor(char *lbl, CRect &r, CWnd *w, UINT id, float ini, float fmin, float fmid, float fmax, int angmi, int angmx, int lw) { if (!CreateEx(NULL, WS_CHILD|WS_VISIBLE|TBS_TOOLTIPS, r, w, id)) { return false; } SetDlgCtrlID(id); CToolTipCtrl *t=GetToolTips(); if (t) { t->SetDelayTime(0); } label = lbl; bounds = r; bounds.MoveToXY(0,0); SetFloatRange(fmin, fmid, fmax); SetAngleRange(angmi, angmx); SetPixelScaleLength(200); // causes a messy z-order redrawing issue!!!! // ModifyStyleEx(NULL, WS_EX_TRANSPARENT, NULL); if (!SetKnobResource(IDB_ROT_SM_K)) { return false; } if (lw >= 0) { labelWidth = lw; } else { labelWidth = bounds.right-knobBitmap.GetWidth(); if (labelWidth < 0) { labelWidth = 0; } } bgColor = rgb_orange; SetKnobParams(); SetFloatValue(ini); return true; }
// 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; }
//**************************************************************************************** BOOL CBCGDialogBar::Create(LPCTSTR lpszWindowName, CWnd* pParentWnd, BOOL bHasGripper, LPCTSTR lpszTemplateName, UINT nStyle, UINT nID) { ASSERT(pParentWnd != NULL); ASSERT(lpszTemplateName != NULL); //------------------------------------------------------ // cannot be both fixed and dynamic // (CBRS_SIZE_DYNAMIC is used for resizng when floating) //------------------------------------------------------ ASSERT (!((nStyle & CBRS_SIZE_FIXED) && (nStyle & CBRS_SIZE_DYNAMIC))); if (bHasGripper) { m_cyGripper = max (12, globalData.GetTextHeight ()); } else { m_cyGripper = 0; } m_bAllowSizing = nStyle & CBRS_SIZE_DYNAMIC ? TRUE : FALSE; //------------------------------ // allow chance to modify styles //------------------------------ m_dwStyle = (nStyle & CBRS_ALL); CREATESTRUCT cs; memset(&cs, 0, sizeof(cs)); cs.lpszClass = AFX_WNDCONTROLBAR; cs.lpszName = lpszWindowName; cs.style = (DWORD)nStyle | WS_CHILD; cs.hMenu = (HMENU)(UINT_PTR) nID; cs.hInstance = AfxGetInstanceHandle(); cs.hwndParent = pParentWnd->GetSafeHwnd(); if (!PreCreateWindow(cs)) { return FALSE; } #ifndef _AFX_NO_OCC_SUPPORT m_lpszTemplateName = lpszTemplateName; #endif //---------------------------- // initialize common controls //---------------------------- VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG)); AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG); //-------------------------- // create a modeless dialog //-------------------------- if (!CreateDlg (lpszTemplateName, pParentWnd)) { TRACE(_T("Can't create dialog: %s\n"), lpszTemplateName); return FALSE; } #ifndef _AFX_NO_OCC_SUPPORT m_lpszTemplateName = NULL; #endif #pragma warning (disable : 4311) SetClassLongPtr (m_hWnd, GCLP_HBRBACKGROUND, (long)::GetSysColorBrush(COLOR_BTNFACE)); #pragma warning (default : 4311) //---------------------------------------------- // 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 m_szHorz = m_sizeDefault; // set the size members m_szVert = m_sizeDefault; m_szFloat = m_sizeDefault; //----------------------- // 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); if (lpszWindowName != NULL) { SetWindowText (lpszWindowName); } return TRUE; }
BOOL CPadView::SetWordWrap(BOOL bWordWrap) { bWordWrap = !!bWordWrap; // make sure ==TRUE || ==FALSE if (IsWordWrap() == bWordWrap) return FALSE; // preserve original control's state. CFont* pFont = GetFont(); int nLen = GetBufferLength(); TCHAR* pSaveText = new TCHAR[GetBufferLength()+1]; GetWindowText(pSaveText, nLen+1); // create new edit control with appropriate style and size. DWORD dwStyle = dwStyleDefault & ~(ES_AUTOHSCROLL|WS_HSCROLL|WS_VISIBLE); if (!bWordWrap) dwStyle |= ES_AUTOHSCROLL|WS_HSCROLL; CWnd* pParent = GetParent(); CRect rect; GetWindowRect(rect); pParent->ScreenToClient(rect); CWnd* pFocus = GetFocus(); UINT_PTR nID = GetDlgCtrlID(); HWND hWnd = ::CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), NULL, dwStyle, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, pParent->m_hWnd, (HMENU)nID, AfxGetInstanceHandle(), NULL); if (hWnd == NULL) { delete[] pSaveText; return FALSE; } // set the window text to nothing to make sure following set doesn't fail SetWindowText(NULL); // restore visual state ::SetWindowText(hWnd, pSaveText); delete[] pSaveText; if (pFont != NULL) { ASSERT(pFont->m_hObject != NULL); ::SendMessage(hWnd, WM_SETFONT, (WPARAM)pFont->m_hObject, 0); } // detach old window, attach new SetDlgCtrlID((UINT)nID+1); HWND hWndOld = Detach(); ::SetWindowLongPtr(hWndOld, GWLP_WNDPROC, (LONG_PTR)*GetSuperWndProcAddr()); ASSERT(m_hWnd == NULL); SubclassWindow(hWnd); ASSERT(m_hWnd == hWnd); GetParentFrame()->SendMessage(WM_RECALCPARENT); UINT nTabStops = m_nTabStops; GetEditCtrl().SetTabStops(nTabStops); GetClientRect(&rect); SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW); SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_DRAWFRAME); SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); UpdateWindow(); // destroy old ::SetWindowPos(hWndOld, NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE| SWP_NOZORDER); ::DestroyWindow(hWndOld); // restore rest of state... GetEditCtrl().LimitText(nMaxSize); if (pFocus == this) SetFocus(); // notify container that doc changed GetDocument()->UpdateAllItems(NULL); ASSERT_VALID(this); return TRUE; }
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; }
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; }