|
You mentioned you tried sending a message...did you try posting instead? e.g., in the double-click handler for your control, use PostMessage to post a message to your view class. In the PostMessage handler you can raise the C++ event function you mention.
|
|
|
|
|
Hi all,
I have a modeless property sheet with three pages.
The pages are deleted in PostNCDestroy.
However, when a page has not been opened when the sheet is closed, PostNCDestroy for that page is not called, causing memory leaks.
How do I solve this?
Ronald
|
|
|
|
|
rwilmink wrote:
...causing memory leaks.
Where? If the page has not been created, it will not have allocated any memory. Is the leak in the property sheet?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
The pages are first created on the heap and then added to the sheet (sheet->AddPage(pPage)).
I delete the sheet and the pages with 'delete this' in PostNCDestroy.
When a page has not been openened (by clicking the tab) PostNCDestroy is not called so the page is not deleted from the heap.
|
|
|
|
|
rwilmink wrote:
The pages are first created on the heap...
Why? Can you not just use something like:
class MySheet : CPropertySheet
{
CMyPage page1;
CMyPage page2;
CMyPage page3;
};
MySheet::MySheet()
{
AddPage(&page1);
AddPage(&page1);
AddPage(&page1);
} No heap and no memory allocation/cleanup to mess with.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
No, I can't, all kinds of problems with cyclic includes.
|
|
|
|
|
Ok, then if the property sheet is allocating memory for the pages, it should also free up that memory. Something like:
class MySheet : public CPropertySheet
{
MyPage *page1;
MyPage *page2;
MyPage *page3;
};
MySheet::MySheet()
{
page1 = new MyPage;
AddPage(page1);
page2 = new MyPage;
AddPage(page2);
page3 = new MyPage;
AddPage(page3);
}
MySheet::~MySheet()
{
delete page1;
delete page2;
delete page3;
}
BOOL MySheet::OnCommand( WPARAM wParam, LPARAM lParam )
{
WORD wNotifyCode,
wId;
wId = LOWORD(wParam);
wNotifyCode = HIWORD(wParam);
if (BN_CLICKED == wNotifyCode)
{
if (IDOK == wId)
{
if (! ProcOk())
return TRUE;
}
}
return CPropertySheet::OnCommand(wParam, lParam);
}
BOOL MySheet::ProcOk( void )
{
if (::IsWindow(page1->m_hWnd))
{
if (! page1->OnKillActive())
return FALSE;
}
if (::IsWindow(page1->m_hWnd))
page1->OnOK();
return TRUE;
}
void MyPage::OnOK()
{
CPropertyPage::OnOK();
}
BOOL MyPage::OnKillActive()
{
return CPropertyPage::OnKillActive();
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
does setcretiontime in c++, .net frames work works in mfc ?
ditty grail
|
|
|
|
|
|
I don't see why not. What reservations are you having about it?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi!
I'm trying to add a menu to my dialog based program.
In one of the submenus and submenuitem can be checked/unchecked.
I don't know what I'm doing wrong but I can't make it to do this.
No sign of it being checked appears.
Here's the part where I think should do this but I don't know what to add.
void CTestProgramForTestWATH2cppDlg::OnUpdateHelpCheckthis(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
CWnd* pBar;
if ((pBar = GetDlgItem(pCmdUI->m_nID)) == NULL)
{
pCmdUI->ContinueRouting();
return; // not for us
}
pCmdUI->m_pSubMenu->CheckMenuItem(ID_HELP_CHECKTHIS, MF_CHECKED);
}
BOOL CTestProgramForTestWATH2cppDlg::OnHelpCheckthis(UINT nID)
{
// TODO: Add your command handler code here
return TRUE;
}
Does the function CheckMenuItem do what I request??
|
|
|
|
|
Hachaso wrote:
pCmdUI->m_pSubMenu->CheckMenuItem(ID_HELP_CHECKTHIS, MF_CHECKED);
What value does this return ?
~RaGE();
|
|
|
|
|
use pCmdUI->SetCheck(); instead of pCmdUI->m_pSubMenu->CheckMenuItem(ID_HELP_CHECKTHIS, MF_CHECKED);
|
|
|
|
|
How to find the selected date from Month Calendar Control
in vc++
Praveen Chowdam Kumar
|
|
|
|
|
parims wrote:
selected date from Month Calendar Control
Use CMonthCalCtrl::GetCurSel
TO Set date in month ctrl use:-
Use CMonthCalCtrl::SetCurSel
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I am new to MFC.
I added CMonthCalCtrl and set the variable ,,
m_month -- to CMonthCalCtrl
and write the below code in MCM_SELCHANGE in message handler.
void CTabOne::OnSelchangeMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult)
{
CString m_strDate;
CTime ct;
m_month.GetCurSel(ct);
m_strDate.Format("%2d-%2d-%2d",ct.GetDay(),ct.GetMonth(),ct.GetYear());
MessageBox(m_strDate);
UpdateData(FALSE);
*pResult = 0;
}
=============
Plz Help me ., I am getting Date field error.
Aelected date is coming with 12 adding to real date.
Praveen Chowdam Kumar
|
|
|
|
|
I tested your code. But I don't get any error.
Can you specify any other symptoms?
Or did i failed to understand your problem?
parims wrote:
and write the below code in MCM_SELCHANGE in message handler.
I think MCM_SELCHANGE is actually MCN_SELCHANGE!
|
|
|
|
|
parims wrote:
UpdateData(FALSE);
This is unnecessary and will likely cause you grief in the future. Interacting with the control using m_month is all that's necessary.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi,
I'm trying to link a Visual C++ project after successfully compiling it.
The project is a PC-side application for PC-DSP communication. Thus, I use a provided library that I received
with the hardware.The project is a win32 application (not a console application)
When I try to link, I get these errors:
Linking...
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/PC_LVC.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
PC_LVC.dll - 4 error(s), 1 warning(s)
Any suggestions?
Thanks,
Idan.
|
|
|
|
|
are you sure you inserted conditional inclusions ?
#ii !defined(__MY_HEADER_H_INCLUDED__)
#define __MY_HEADER_H_INCLUDED__
#endif //__MY_HEADER_H_INCLUDED__
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Hi Idan,
It is really good to have a problem.
The possible reason could be, your hardware library might use different code generator(Multi threaded). To resolve this open your Project Setting, C/C++ Tab, check "Use run-time library" combobox. Try to change the threading model selected. I think, by default it could be a single threaded.. Change it to multithreaded..
If it doesn't workout let me know..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
I need to keep the first column of my view hidden. so I created the column with size zero & used OnNotify to disable tracking. But now when I press “ctrl , + “ keys together the hidden column is shown. How to solve this problem?
Thanks..
sourabh
|
|
|
|
|
study.sourabh wrote:
I need to keep the first column of my view hidden
No offense, but this seems a weird design.
study.sourabh wrote:
How to solve this problem?
I think you will have to derive a class from the CListCtrl and handle the keyboardinputs in the ::PreTranslateMsg function (not call the base class if the key combination is ctrl, +
~RaGE();
|
|
|
|
|
It sounds like you need this column to store some values in it, and you don't want the user to see these values. It would probably be a better design to use the item data for each entry in the list view to store these information.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|