|
|
I strongly recommend these two books:
Effective C++
Scott Meyers
ISBN: 0-201-92488-9
More Effective C++
Scott Meyers
ISBN: 0-201-63371-X
(2b || !2b)
|
|
|
|
|
there's a lot of good stuff in STL (how to use it, the philosophy behind it, etc.) and templates in general are a good intermediate step.
and really, once you've mastered templates and STL, there's not much left, just more of the same.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
thanks all...I'll follow up on these..
as for the gent, who asked me what I have read thus far..I started off with Deittel & Deittel, then got into Windows and MFC, with Charles Petzold and Jeff Prosise books. So, I haven't really dealth with STL and some other areas of C++ that Windows programming really doesn't get involved in, too much.
thanks
|
|
|
|
|
and really, once you've mastered templates and STL, there's not much left
There's much left. "Modern C++ Design" by Alexandrescu has a lot of advanced-level metaprogramming/generic programming stuff.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
For improving your C++, I'd recommend Bjarne Stroustrup's "C++ Programming Language". The author is the C++ creator, so you'll get first-hand information. After this, read two Scott Meyers' books listed in previous posts. You may also have a look at http://www.gotw.ca/ - this is C++ Guru of The Week website.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
|
|
I'm building a TabCtrl extension class that allows the tab pages to be created from a dialog resource.
Inside the tab control it normally creates a new instance (using new ) and keeps that pointer in a list. However, if you want to do anything complicated on the tab then you need to inherit from the default tab page class (CTabPage) to provide the handling of events, etc. Therefore there is an AddPage override which accepts a pointer to a CTabPage and just adds it to the internal list.
The destruction code for the tab control just iterates through the list calling delete. However, if the pointer passed in wasn't created with new then it will crash. I wanted to avoid having to create objects with new outside of the tab control class and allow them to be deleted by the tab control class.
So, if in the destruction routine I could determine if the pointer was a valid heap pointer then I could delete it, otherwise I would just leave it and let it's destructor do the work.
Am I making sense?
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
Item 27 in Meyers' "More Effective C++" deals with related issues. He presents some methods of determining if object is on the heap or not, however, there's no simple solution to this problem.
Here's what I would do in this case:
Assume that clients are responsible for deleting pages if it's necessary (many of them will simply create their pages as data members in dialog class or as local stack-allocated objects). Clearly document client code responsibility and everything should be OK.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
many of them will simply create their pages as data members in dialog class or as local stack-allocated objects
That's most of the problem. The default approach is for the tab control to do all of the new'ing and deleting of the objects required for the tab pages. If a client creates a local stack-allocated object and passes a pointer to it for the tab control, then the tab control tries to call delete on it.
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
So there are two overloads of AddPage, right?
void AddPage(UINT nResID);
void AddPage(CTabPage *page);
You need to keep not only the page pointer, but a boolean value meaning 'tab control created this page'. To avoid code duplication, create new private method that adds the page to internal list. Note the second parameter.
private:
void RealAddPage(CTabPage *page, bool bOwnedByMe);
AddPage methods should call ReadAddPage passing true or false respectively:
void CYourTab::AddPage(CTabPage *page)
{
RealAddPage(page, false);
}
void CYourTab::AddPage(UINT nResID)
{
CTabPage *page = new CTabPage(nResID);
RealAddPage(page, true);
}
In destructor, you'll iterate through list of pages and call delete only on those created with a call to AddPage accepting resource ID.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
|
Hi Everybody...
I am having a problem in resizing the CFileDialog. I have derived a class from CFileDialog and then i placed a button on that dialog now what i want to do is that i want to resize that dialog with this button. I have made it but unfortunately when i ran this application on Win2000. what is happening the list control that shows the contents of the current folderis resizing instead dialog....
I am using this code:
CFileDialog* pFileDlg = (CFileDialog*)CWnd::FromHandle(hwnd)
COptionsFileDialog *pFileDialogEx = (COptionsFileDialog *)pFileDlg ;
pFileDialogEx->SetWindowPos(0, 0, 0, 590, size , SWP_NOZORDER);
Is any one has an idea what is happening yar....
Rose
|
|
|
|
|
On Win2000 the File dialog is resizable. So it has to handle WM_SIZE in order to properly move/size child controls, including the listview showing folder contents. Calling SetWindowPos causes WM_SIZE to be sent to your dialog and controls are repositioned.
You can't just place a button on File dialog, if you want to extend/customize its functionality, you'll have to read "Explorer-Style Custom Templates" topic in MSDN. It's somewhere under User Input/Common Dialog Box Library/Open and Save as dialog boxes.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sir,
Thanks for the reply...
I have used this flag while at the DoModal Time but its behaviour is same..
Also I have got some thing new as
CListCtrl* pLCtrl;
BOOL bWin2k = FALSE;
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(osvi);
::GetVersionEx(&osvi);
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 5)
bWin2k = TRUE;
if (bWin2k)
{
CWnd *pWnd = GetParent()->GetDlgItem(lst2);
pLCtrl = (CListCtrl*)pWnd->GetDlgItem(1);
}
else
pLCtrl = (CListCtrl*)GetParent()->GetDlgItem(lst1);
return pLCtrl;
can u tell me sir why
pLCtrl = (CListCtrl*)pWnd->GetDlgItem(1);
is used..........
|
|
|
|
|
I have used this flag while at the DoModal Time
What are you talking about? Which flag? If you want your dialog to behave correctly under W2K, read the MSDN article I've pointed you at.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sir,
I have read this article and it is about Hook procedures as i am new to VC programming tell me what are these.........
|
|
|
|
|
Check the KB article Q195034: "HOWTO: OfnKing Demonstrates CFileDialog Customization"
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
maybe look at this server's dialog section
t!
|
|
|
|
|
maybe look at this server's dialog section
Sorry I can't Understand Please Explain..?
|
|
|
|
|
there are some articles about file dialog at
http://www.codeproject.com/dialog/
Windows Common dialogs and others sections
i thought it will help you
t!
|
|
|
|
|
yes
I have seen all these but all these are using resource dialog but i want to use the windows standard dialog by deriving a class from the CFileDialog......
|
|
|
|
|
minimaly example you giving in another thread not thinks about w98
t!
|
|
|
|
|
Why don't you just use Paolo Mesina's CResizableDialog class (article posted here on Code Project. It's very comprehensive.
|
|
|
|