|
It should be:
void showNumber( TreeItemType& iTreeNumber )
{
cout << iTreeNumber.getKey();
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
yeah.
Before posting this problem on the boards, I had tried attaching void as the function sig:
void showNumber( TreeItemType& iTreeNumber )
{
cout << iTreeNumber.getKey();
}
and this is error i get:
"cpp(74) : error C2664: 'BinarySearchTree::preorderTraverse' : cannot convert parameter 1 from 'void' to 'FunctionType'"
then i tried this.
FunctionType showNumber( TreeItemType& iTreeNumber )
{
return showNumber(iTreeNumber);
}
for no error, but not the correct solution.
|
|
|
|
|
Then the problem is with code you've not shown. I've taken each of your code snippets and it compiles fine.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Wow, I wonder what it is then.
So you were able to call the BST's preorder traversal in main?
like so:
cTree1.preorderTraverse(showNumber(iFromTree));
By the way, thanks for all your quick responses.
|
|
|
|
|
Member 3822532 wrote: So you were able to call the BST's preorder traversal in main?
Exactly like this.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
damn... that works
I see what I did wrong now.
Thanks a lot for your help.
|
|
|
|
|
hi i am tryingto build astatic library. and while i build i get this fatal error, kindly help me rectify this.
fatal error C1083: Cannot open include file: 'BasicHashTable.hh': No such file or directory
|
|
|
|
|
if this is a C# question, it's in the wrong forum.
if it's a C++ question, then you have to either tell the compiler where to find BasicHashTable.hh or, put BasicHashTable.hh in a place where the compiler is already looking.
|
|
|
|
|
i have created a 5 Buttons dynamically.
eg :
2) Button 1 contol id :5000
1) Button 2 contol id :5001
1) Button 3 contol id :5002
1) Button 4 contol id :5003
1) Button 5 contol id :5003,
i need to select caption name "Button 1" using its control id 5000;
i used RButtonup and i got control id. But i dont know how to get the caption of Button .Please help.
|
|
|
|
|
Assuming your controls are in a dialog box: If you are using Win32 then you may call SendDlgItemMessage (with WM_GETTEXT or WM_SETTEXT , depending on your needs).
In a similar way you may use MFC 's CWnd::SendDlgItemMessage .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CWnd::SendDlgItemMessage,
i have no idia if you give example, it is very helpful to me.
|
|
|
|
|
Inside a method of your window class (the parent window of your buttons) call, for instance:
SendDlgItemMessage(5000, WM_SETTEXT, 0 , (LPARAM) _T("BUTTON 0"));
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
no i am not getting, please is there any sample code.
|
|
|
|
|
If you post your (relevant) code may be I can tell you how to modify it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ON_COMMAND_RANGE(5000,5100,OnButtonRange)
void CTest::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
CButton* m_btDynamic;
CString csText;
int k=0;
for(int i=0;i<5;i++)
{
m_btDynamic = new CButton();
csText.Format(L"Button %d",i+1);
m_btDynamic->Create(csText, BS_FLAT|WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_ICON,
CRect(10+k ,10+k,60+k,60+k),this, 5000+i);
k=k+30;
}
}
void CTest::OnButtonRange(UINT nIDforControl)
{
int iSelectedControlID;
iSelectedControlID = nIDforControl;
// here i want button caption
}
Where i should use SendDlgItemMessage()
|
|
|
|
|
Well, you already set the caption for you button with known values, so what's your need now?
BTW I suggest you to maintain the CButton pointers in a member variable:
in class declaration:
CButton * m_btDynamic[5];
then, in you function you may do
void CTest::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
CString csText;
int k=0;
for(int i=0;i<5;i++)
{
m_btDynamic[i] = new CButton();
csText.Format(L"Button %d",i+1);
m_btDynamic[i]->Create(csText,BS_FLAT|WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_ICON,
CRect(10+k ,10+k,60+k,60+k),this, 5000+i);
k=k+30;
}
}
so that whenever you need to access the caption of, say, third button, you may call
m_btDynamic[2]->GetWindowText();
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks CPallini,
this is not exact code i have posted.
in my actual code i have created 100 buttons, same way as u told. but the problem is if user right click on any button i want that caption.
|
|
|
|
|
You may do this way (in your event handler):
CButton * pClickedButton = (CButton *) GetDlgItem( id );
CString sClickedCaption = pClickedButton->GetWindowText();
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Friday, March 26, 2010 10:26 AM
|
|
|
|
|
i am getting error
error C2039: 'GetText' : is not a member of 'CButton'
|
|
|
|
|
Sorry, I should have fixed it now.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It's GetWindowText, not GetText.
But if you look at the documentation for CWnd on msdn, you can see the details for yourself too.
Good luck!
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
|
Who do you think you are, God?
(I was worried that you missed a certain poster's rants.)
|
|
|
|
|
To your knees! (to hear the softly spoken magic spells)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi I'm making a simple drawing program I used offset to set up a specific drawing.
The picture drawn with offset moves on the screen when i draw another picture everything drawn with this function moves by one pixel permanently on the screen. Cant find source of this problem.
It is an MFC aplication.
CS2::CS2(CPoint Start, CPoint End, COLORREF aColor)
{
m_PunktP = Start;
m_PunktD = End;
m_Color = aColor;
m_Pen = 1;
m_EnclRect = CRect(Start, End);
m_EnclRect.NormalizeRect();
}
CS2::~CS2(void)
{
}
void CS2::Draw(CDC* pDC)
{
CPen aPen;
POINT pt;
if(!aPen.CreatePen(PS_SOLID, m_Pen, m_Color))
{
AfxMessageBox(_T("Pen creation failed"), MB_OK);
AfxAbort();
}
CPen* pOldPen = pDC->SelectObject(&aPen);
pDC->MoveTo(m_PunktP);
pt.x = 0;
pt.y = 63;
m_PunktP.Offset(pt);
pDC->LineTo(m_PunktP);
[...]
pt.x = 0;
pt.y = -13;
m_PunktP.Offset(pt);
pDC->LineTo(m_PunktP);
pt.x = -32;
pt.y = 13;
m_PunktP.Offset(pt);
pDC->LineTo(m_PunktP);
pDC->SelectObject(pOldPen);
}
modified on Friday, March 26, 2010 9:33 AM
|
|
|
|