|
ratprita wrote: i need a sample program, which satisfies these conditions.
What about writing one, as you are supposed to do ?
|
|
|
|
|
ratprita wrote: a.Should have classes like Manager, Engineer to exploit polymorphic features of C++.
Here ya go:
class Employee
{
};
class Manager : public Employee
{
};
class Engineer : public Employee
{
}; I'll let you fill in the blanks!
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I one of my sample applcaiton,I hav changed the combobox in to Listbox,
After that i got in piece of code.
CAlarmCombo *pSysBox = (CAlarmCombo *)((CMainFrame *)AfxGetMainWnd())->m_SysWnd.GetDlgItem(IDC_SYSALARM);
if(pSysBox)
{
pSysBox->EnableWindow(TRUE);
if( pSysBox->GetCount() < 5 )
pSysBox->AddString((LPCTSTR)RGB(255,0,0));
}
The code is working fine with CComboBox.
The error comes in that bolded line as some USER32.dll unhandled exception.
Anu
|
|
|
|
|
What is the string you're trying to add?
RGB(255, 0, 0) is not a valid string.
pSysBox->AddString(_T("RED")); would be the correct way to do this.
|
|
|
|
|
You are trying to type cast RGB(255, 0, 0) to a string. This casting is wrong. What are you trying to display on the list?
|
|
|
|
|
Anu_Bala wrote: pSysBox->AddString((LPCTSTR)RGB(255,0,0));
What do you want to do?
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]
|
|
|
|
|
Actually it displaying kind of test like
BT001 BTcomments LL
Like this it will print in the COmboBOx.
What i did is..I want ListBox,so replaced the combobox with ListBox,and i use the ID of Combobox in to Listbox.
But with the ComBoBOx it works fine.
The string gets added in function
void CAlarmCombo::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
.
.
.
CString sAlrm = _T("");
sAlrm.Format("%-16s %-25s %-4s",pTagBase->GetTagName(),pTagBase->GetDescription(),pAlrmDisp->sStatus);
pDC->TextOut(25,lpDIS->rcItem.top + 1,sAlrm)
}
Even i couldnot understand what that AddString() doing.
But how it works perfect in using COmboBox.
Anu
|
|
|
|
|
In the expression
pSysBox->AddString((LPCTSTR)RGB(255,0,0));
You're casting to a const TCHAR * a temporary DWORD value, that plainly makes no sense...
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]
|
|
|
|
|
Anu_Bala wrote: pSysBox->AddString((LPCTSTR)RGB(255,0,0));
The RGB[^] macro returns a COLORREF[^]. You're forcing the compiler away from complaining about this by cleverly casting the COLORREF value to an LPCTSTR .
If you want to add the string as it is, then try
pSysBox->AddString(_T("RGB(255,0,0)"));
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Anu_Bala wrote: CAlarmCombo *pSysBox = (CAlarmCombo *)((CMainFrame *)AfxGetMainWnd())->m_SysWnd.GetDlgItem(IDC_SYSALARM);
What a mess!
Anu_Bala wrote: pSysBox->AddString((LPCTSTR)RGB(255,0,0));
Do you know what an RGB value is? Hint: it can't be converted to a LPCTSTR by casting it.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
How can I create a virtual desktop, where I can show icons of desktop folder and also show a web page as active desktop.
Thanks,
Amit
|
|
|
|
|
What do you mean by a Virtual Desktop?
You can create another desktop using CreateDesktop[^].
|
|
|
|
|
Hi...
I am having the following code snap.
CString str = "this is a test program to broke cstring";
Now i need only upto "this is a te".
how to separate it?
G.Paulraj
|
|
|
|
|
CString str2 = str.Left(12);
Or
str.Delete(12, 0x7FFF);
|
|
|
|
|
|
In Visual C++ 6.0 I have two ActiveX control project. One ActiveX control is dependent on another ActiveX control. For that First Project is compiled succesfully and then in second project we used Project->Add To Project->Components and Controls-> then point to compiled first project ActiveX control.
Then It will insert .h and .cpp files to Second Project.
The same how to do in Visual Studio 2008. Please help regarding this
|
|
|
|
|
Hi,
Iam displaying child views as seperate window.When i maximize the view,it maximized up to top mainframe. But i want this: when i press the maximize button,the view should maximized up to the toolbar.Like the childwindow minimize,maximize button should appear below the toolbar.
How can i do this?Pls help me.
Anu
|
|
|
|
|
hi all...
iam a beginner in VC++
previously i have posted query regarding saving editbox contents and opening a text file...
it worked perfectly .. thanks for all support.. i have experienced a very fast response from this forum..
I have 4 editboxes.. i have added Cfontdialog to my application..
once i click ok it changes the font of the first editbox alone.. how can i change the font of other 3 editboxes indivitually... for that as per my understaning, i should find, in which editbox the cursor is... how can i achieve that...below code is for one edit box..
LOGFONT lf;
CFont *font = new CFont();
CFontDialog FontDlg(&lf);
if(FontDlg.DoModal() == IDOK)
{
font->CreateFontIndirect(&lf);
m_edit1.SetFont(font);
}
plz help me.. thanks in advance
|
|
|
|
|
|
hi..
thanks for the reply...
im facing a problem now..
the GetCaretPos() is always getting position of cursor in first edit box even if i keep the cursor in the second or third
Also GetCntrlID is returning me an integer value..
can u help me wid this...
|
|
|
|
|
heloo.. i solved the problem..
used CWnd *pwnd = CWnd::GetFocus();;
int wID = pwnd->GetDlgCtrlID();
thanks for the help 
|
|
|
|
|
sonualex wrote: CFont *font = new CFont();
This variable should have class scope, and should not be a pointer.
sonualex wrote: once i click ok it changes the font of the first editbox alone.. how can i change the font of other 3 editboxes indivitually
Unless I'm just not understanding, what about:
if (FontDlg.DoModal() == IDOK)
{
font->CreateFontIndirect(&lf);
m_edit1.SetFont(&font);
m_edit2.SetFont(&font);
m_edit3.SetFont(&font);
m_edit4.SetFont(&font);
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
hi David..
nice to c u...
thanks for the reply....
below is my code... it worked fine
i used the font pointer here.. dint understand y v cant use pointer...
CWnd *pwnd = CWnd::GetFocus();;
int wID = pwnd->GetDlgCtrlID();
LOGFONT lf1;
CFont *font1 = new CFont();
switch(wID)
{
case IDC_EDIT1:
{
CFontDialog FontDlg1(&lf1);
if(FontDlg1.DoModal() == IDOK)
{
font1->CreateFontIndirect(&lf1);
m_edit1.SetFont(font1);
}
}
break;
}
|
|
|
|
|
sonualex wrote: i used the font pointer here.. dint understand y v cant use pointer...
Because it's completely unnecessary.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
ok.. thanks for that too..
|
|
|
|