|
waxie wrote: I was looking for an event handler every time the dialog is activated
Ok. then it's the overridable OnActivate() . It will get called when the window is activated or deactivated. Don't forget to put it in the message map as well. If you add it with ClassWizard this will be done automagically for you.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
For clarification reasons, here's how to do it manually:
Add the message handler declaration for OnActivate() in you header file:
afx_msg void OnActivate( UINT nState, CWnd* pwndOther, BOOL bMinimized );
In your .cpp file, add the message handler to the message map...
ON_WM_ACTIVATE()
END_MESSAGE_MAP()
...and add the message handler implementation...
void <YourDialogClass>::OnActivate( UINT nState, CWnd* pwndOther, BOOL bMinimized )
{
TRACE( "OnActivate called.\n" );
}
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Just to be sure,what I did is I went to the dialog resource and looked for the message handlers in its properties and added a message handler for WM_ACTIVATE. Still no good though. The dialog (my dialog) is one of the tabs of a parent dialog. Would it matter?
|
|
|
|
|
Is your dialog a property page? If yes then try CPropertyPage::OnSetActive() .
cheers,
mykel
OMM: "Let us be thankful we have commerce. Buy more. Buy more now. Buy. And be happy."
|
|
|
|
|
Nope, it's not a property page. It's a tab page in a tabcontrol.
|
|
|
|
|
'ait... according to MSDN i recommend the following:
TCN_SELCHANGE Notification
Notifies a tab control's parent window that the currently selected tab has changed.
This message is sent in the form of a WM_NOTIFY message. check MSDN for further details, e.g. the handle to the tab control is passed with the notification. then i guess you can call CTabCtrl::GetCurSel() to get the currently selected tab.
cheers,
mykel
OMM: "Let us be thankful we have commerce. Buy more. Buy more now. Buy. And be happy."
|
|
|
|
|
waxie wrote: The dialog (my dialog) is one of the tabs of a parent dialog. Would it matter?
It depends on what you're trying to do.
My guess is that you want to know when the user selects another tab in the control.
If I guessed correctly and you're using CTabCtrl you have to write a message handler for the WM_NOTIFY message sent from the tab control with the TCN_SELCHANGE control code.
Use ClassWizard to add a message handler for this. Afterwards you message map should have an entry looking something like this:
ON_NOTIFY( TCN_SELCHANGE, IDC_TAB, OnTabChanged ) ...and a message handler looking similar to this:
void <YourDialogClass>::OnTabSelchange( NMHDR* pNMHDR, LRESULT* pResult )
Have a look att the MSDN sample FIRE[^] to see how it's done.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
These are just guesses but maybe it helps: Check WM_NCACTIVATE and also the Frame Window of the dialog (i hope CDialog has one)
CChildFrame::OnNcActivate(...) worked for me with CView based class in a MDI environment.
|
|
|
|
|
I also tried the above suggestions already, still no good.
Thanks for the replies though. I really appreciate them.
|
|
|
|
|
May be you are looking for OnShowWindow(BOOL ) or something like this will be called everytime the window is sabout to be shown or hidden.
|
|
|
|
|
OnShowWindow still doesnt work. Thanks for the reply though.
|
|
|
|
|
Hi All
i want hook folder as well as file movement so downloaded(from www.codeproject.com/atl/CopyHook.asp) one sample which helps us to hook folder movement but i need even for File so can anyone help me out..
Thanks in advance
R e h a n
|
|
|
|
|
VC_RYK wrote: i want hook folder as well as file movement
ReadDirectoryChangesW . There is a sample in MSDN called FWatch.
|
|
|
|
|
How can i Sum Rows in column 3 i have selected ?
ok,this code sum all rows in all columns :
int nSum = 0;
for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)
{
for( int nColumn = 0; nColumn < 3;nColumn++)
{
csText = m_list1.GetItemText(nRow ,nColumn );
nSum += atoi( csText);
}
}
csText.Format("%d", nSum);
m_sum.SetWindowText(csText);
I have added Checkboxes to CListCtrl to select witch rows to Sum,ALL I WANT IS TO SUM ROWS IN COLUMN 3 THAT I HAVE SELECTED !!!
HOW ?
Bravoone
|
|
|
|
|
Bravoone_2006 wrote: int nSum = 0;
for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)
{
for( int nColumn = 0; nColumn < 3;nColumn++)
{
csText = m_list1.GetItemText(nRow ,nColumn );
nSum += atoi( csText);
}
}
int nSum = 0;
for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)
{
csText = m_list1.GetItemText( nRow, 2 );
nSum += atoi( csText);
}
|
|
|
|
|
And how would your code know which item is checked
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
OK, but it works for col 2 but I WANT to select witch rows to sum
HOW? i have try this but it sum all rows in column 2!
:
CString csText;
for(int i=0; i<m_list1.getitemcount();i++)
{
="" if(m_list1.getcheck(i))
="" {
int="" nsum="0;
for(" int="" nrow="0;" <="" m_list1.getitemcount();nrow++)
{=""
cstext="m_list1.GetItemText(" nrow,="" 2="" );=""
nsum="" +="atoi(" cstext);
}
cstext.format("%d",="" nsum);=""
m_sum.setwindowtext(cstext);=""
="" }
="" }
how="" can="" i="" sum="" only="" that="" rows="" have="" select="" ?=""
<div="" class="ForumSig">Bravoone
|
|
|
|
|
Hi Bravoone,
Try pasting this code in the first for loop
int nSum = 0;
for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)
{
for( int nColumn = 0; nColumn < 3;nColumn++)
{
if(m_list1.GetCheck(/*index of item*/nRow))
{
csText = m_list1.GetItemText(nRow ,nColumn );
nSum += atoi( csText);
}
}
// Rest of the code.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
ok but :
error C2065: 'nColumn' : undeclared identifier
its not right !something is wrong !
what ?
Bravoone
|
|
|
|
|
Bravoone_2006 wrote: error C2065: 'nColumn' : undeclared identifier
its not right !something is wrong !
what ?
Are you kidding ? I think the erro message is pretty clear no ? You are using nColumn in your code and it has not been declared anywhere. BTW, when somebody gives you code snippet, it is always better to try to understand what it does so that next time you can do it yourself, instead of blindly copy/pasting into your own code.
If you tried to do that, maybe with all the answer you got you would probably have had a working solution. Don't expect people to do everything for you.
|
|
|
|
|
THANKS GUYS !
EVERYTING IS OK !
THANKS !
Bravoone
|
|
|
|
|
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
hi all,
how can i replace a string in file with my own string. for example, i open a file and search string %Pankaj% and replace with them c:\windows\system.i'm new to VC++.
thanks in advance......
Pankaj Jain
|
|
|
|
|
|
Is there a way to build a static library that could be used on both Windows & linux OS?
|
|
|
|