Edit control in Property sheets
Steven Youngs -- steve@ncgraphics.co.uk Sunday, April 14, 1996 Environment: Win NT v3.51 and v4.0, VC++ v4.0 I'm trying to dynamically add an edit control to a CPropertySheet derived class, but I cannot seem to get the sunken 3D border effect ala Windows 95 The snippet of code I have is as follows BOOL CGLDiagnosticsSheet::OnInitDialog() { BOOL bStatus = CPropertySheet::OnInitDialog(); m_pwndFormatNumber = new CEdit; CRect rcEdit; // rcEdit is filled in with some sensible numbers... m_pwndFormatNumber->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER, rcEdit, this, 0); return (bStatus); } Using Spy++, this edit control has a style of 0x50012000. Now if I add an edit control to one of the property pages, it also has a style of 0x50012000 but, it *has* the sunken 3D border ;-) So, the effect is presumably unrelated to the window style. Anyone got any ideas how I can get the 3D border effect for my edit control?? Steve. _____________ Steven Youngs NC Graphics (Cambridge) Ltd.
Don.Irvine@net-tel.co.uk Wednesday, April 17, 1996 [Mini-digest: 3 responses] > I'm trying to dynamically add an edit control to a CPropertySheet derived > class, but I cannot seem to get the sunken 3D border effect ala Windows 95 If memory serves me right [it's been a while], it is an extended style WS_EX_CLIENTEDGE which adds the 3D border to the window. Don -----From: Paul JakoubekSteve, I've used the CreatEx method to have access to the extended style WS_EX_CLIENTEDGE: BOOL createEditReturn = CreateEx( WS_EX_CLIENTEDGE, // DWORD dwExStyle "EDIT", // LPCTSTR lpszClassName (LPCTSTR) NULL, // LPCTSTR lpszWindowName WS_BORDER | WS_TABSTOP | WS_VISIBLE | WS_CHILD, // DWORD dwStyle x, y, nWidth, nHeight, // int x, int y, int nWidth, int nHeight pWnd->GetSafeHwnd(), // HWND hwndParent (HMENU) nID, // HMENU nIDorHMenu NULL); // LPVOID lpParam = NULL This seems to do the trick -----From: Steven Youngs Thanks to you both for your suggestion. You both came up with = WS_EX_CLIENTEDGE. I had in fact already tried this, but with no success. = Anyway I tried again and have the solution which you may (or may not !!) = be interested in. The problem is that I was calling pEdit->Create(...) = but in fact you need to call CreateEx(....) in order to specify extended = window styles. (CWnd::Create() passes in 0 as the extended window style) Anyway, I changed=20 pEdit->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP |=20 WS_EX_OVERLAPPEDWINDOW | ES_NUMBER,=20 rcEdit, this, IDC_FORMATNUMBER); to=20 pEdit->CreateEx(WS_EX_OVERLAPPEDWINDOW, _T("EDIT"),=20 NULL,=20 WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_NUMBER, rcEdit.left, rcEdit.top, rcEdit.Width(), rcEdit.Height(), this->GetSafeHwnd(),=20 HMENU(IDC_FORMATNUMBER)); and it all works fine :-) Scott: If there is nothing similar to this in the MFC FAQ, perhaps you = could add it to save others the problem. Thanks. Steve.
| Вернуться в корень Архива |