|
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.
|
|
|
|
|
Geez - he's using common File Open dialog, and is having problems with resizability introduced in W2K. How do you think CResizableDialog fits into this picture?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am using MSComm OCX in my VC++ project. Basically, I want to transmit & receive a Data from PC ( Com port1) to an embedded device also designed by me.
The problem is that, '0' is not being transmitted or received by VC++, while it is possible in VB.
Can anybody help me?
Thanking you in advance.
Sr. Engineer
R & D,
Hi-rel Electronics LTd.
INDIA.
|
|
|
|
|
Hello,
I would like to know how to integrate an excel sheet in an VC++6.0 application.
Can you help me? or tell me where can i find such an information.
Thanks.
|
|
|
|
|
|
I have a bunch of printers installed and I want to choose which to print to at run time (using code only - no user interface).
I know the names of the printers (as they appear in control panel printers folder) and i know the name of the one i want to use.
So what i need is, something like a SetCurrentPrinter(strMyPrinterName) func.
Any ideas?
|
|
|
|
|
If you're using Win32 API only, pass the name of the printer as 2nd parameter to CreateDC. With MFC, you can also use CWinApp::SelectPrinter and CWinApp::CreatePrinterDC.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks, i am using MFC, so i'll try SelectPrinter. I cant use the DC oriented methods since i am using a library to do all the printing legwork (i just need to select a printer in advance...)
|
|
|
|
|
Depending on what your library does, you may check the docs for SetDefaultPrinter API function. It's available only on Win2000, but documentation contains code that performs the same thing on earlier systems with GetProfileString, WriteProfileString and SendNotifyMessage.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi all,
I'm writing ActiveX ...
I have simple question, How can i get size of my ActiveX ? (I mean RECT)
Thanks for all helps ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi all,
I wrote some functions in my header file,
I wanna create .LIB file of my header file, How can i do that ?
Thanks for all helps ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|