|
Hi,
You are correct the x value is the root cause of the problem but i can't avoid this value. Is there any way to avoid overflow by doing some changes.
|
|
|
|
|
Simple mathematics would suggest that the only way to improve this situation is to find a way of ensuring that the x-value is within a reasonable range. The rules are the rules I am afraid.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi,
I am trying to enter some messages in the static text box.
But the messages are coming continously.
How can i display the messages to the newline.
Thanks
Raj
|
|
|
|
|
you can use newline '\n' constant in your string where you want to break the string.
Regards,
Srinivas
|
|
|
|
|
I want to use class CMFCPropertyGridProperty to add a button,and when i click the button,it can pop a dialog which
i defined it by myself.
it trobuled me a long time.
when i see the information online,it told me that i can use CMFCPropertyGridProperty::hasbutton method,but it's a protect member,and i am new do this,i really don't know how to do it.
help me...
thanks a lot
|
|
|
|
|
As a minimum you create a new class that inherits from the base class. Then you can override the HasButton method and get it to return true.
Now you will get a small … button when you use this new class for your property. If you look at the MFC source code you will see that you can also override OnButtonClick to detect when the button is clicked.
This is as much as I have found out so far.
|
|
|
|
|
Hello,
this is a bit of a strange question: I have a CTabCtrlEx class
that was passed to me for doing tabbed dialog forms: in substance
it is a class that allows dialogs to be inscribed inside a
tabbed control. It is probably a well known class but I cannot find
the origin of it (maybe Jeff Prosise's, but I don't know for certain).
Hence the question is, do you know any reference to this class in
the literature ?
I attach here the class itself
---- header ----
#if !defined(AFX_TABCTRLEX_H__INCLUDED_)
#define AFX_TABCTRLEX_H__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define TBC_NO_IMAGE -1
class CTabCtrlEx : public CTabCtrl
{
private:
BOOL m_bDeleteItemDlg;
BOOL m_itemRectIsValid;
CRect m_itemDlgRect;
CDialog* m_pLastSelDlg;
public:
CTabCtrlEx(BOOL bDeleteItemDlg = FALSE);
~CTabCtrlEx();
BOOL InitItem(UINT nIDTemplate, CDialog* pDlg, CDialog* pParent);
int AddItem(LPTSTR lpczText, CDialog* pDlg, int nImage = TBC_NO_IMAGE);
int GetItem(CDialog* pDlg);
int GetItem(LPCTSTR lpczText);
CDialog* GetNextItem(int nItem);
BOOL RemoveItem(CDialog* pDlg);
BOOL RemoveItem(LPCTSTR lpczText);
void RemoveAllItems(BOOL bDeleteDlg);
CDialog* GetSelectedItemDlg();
BOOL SetSelectedItemDlg(CDialog* pDlg);
void SetItemDlgRect(LPRECT lprect);
BOOL GetItemDlgRect(LPRECT lprect);
BOOL ShowSelectedItemDlg();
virtual BOOL DestroyWindow();
protected:
afx_msg void OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_TABCTRLEX_H__INCLUDED_)
---- header ----
---- body ----
#include "stdafx.h"
#include "TabCtrlEx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CTabCtrlEx::CTabCtrlEx(BOOL bDeleteItemDlg )
{
m_bDeleteItemDlg = bDeleteItemDlg;
m_itemRectIsValid = FALSE;
m_pLastSelDlg = NULL;
}
CTabCtrlEx::~CTabCtrlEx()
{
}
BEGIN_MESSAGE_MAP(CTabCtrlEx, CTabCtrl)
ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnTcnSelchange)
END_MESSAGE_MAP()
BOOL CTabCtrlEx::DestroyWindow()
{
if(m_bDeleteItemDlg)
RemoveAllItems(m_bDeleteItemDlg);
return CTabCtrl::DestroyWindow();
}
int CTabCtrlEx::AddItem(LPTSTR lpczText, CDialog* pDlg, int nImage )
{
int nItem = GetItemCount();
TCITEM item;
item.mask = TCIF_TEXT|TCIF_PARAM;
item.pszText = lpczText;
item.lParam = (DWORD) pDlg;
if(nImage != TBC_NO_IMAGE)
{
item.mask |= TCIF_IMAGE;
item.iImage = nImage;
}
return InsertItem(nItem, &item);
}
BOOL CTabCtrlEx::InitItem(UINT nIDTemplate, CDialog* pDlg, CDialog* pParent)
{
if(!pDlg->m_hWnd && !pDlg->Create(nIDTemplate, pParent))
return FALSE;
if(m_itemRectIsValid)
pDlg->SetWindowPos(NULL, m_itemDlgRect.left, m_itemDlgRect.top, m_itemDlgRect.Width(), m_itemDlgRect.Height(),
SWP_NOZORDER|SWP_HIDEWINDOW);
return TRUE;
}
int CTabCtrlEx::GetItem(CDialog* pDlg)
{
TCITEM item;
item.mask = TCIF_PARAM;
int nCount = GetItemCount();
for(int i = 0; i < nCount; i++)
if(CTabCtrl::GetItem(i, &item) && item.lParam == (DWORD) pDlg)
return i;
return -1;
}
int CTabCtrlEx::GetItem(LPCTSTR lpczText)
{
TCHAR czText[MAX_PATH];
TCITEM item;
item.mask = TCIF_TEXT;
item.pszText = czText;
item.cchTextMax = MAX_PATH - 1;
int nCount = GetItemCount();
for(int i = 0; i < nCount; i++)
if(CTabCtrl::GetItem(i, &item) && _tcscmp(item.pszText, lpczText) == 0)
return i;
return -1;
}
CDialog* CTabCtrlEx::GetNextItem(int nItem)
{
int nCount = GetItemCount();
if(nItem >= nCount)
return NULL;
TCITEM item;
item.mask = TCIF_PARAM;
if(!CTabCtrl::GetItem(nItem, &item))
return NULL;
return (CDialog*) item.lParam;
}
BOOL CTabCtrlEx::RemoveItem(CDialog* pDlg)
{
int nItem = GetItem(pDlg);
return nItem >=0 ? CTabCtrl::DeleteItem(nItem) : FALSE;
}
BOOL CTabCtrlEx::RemoveItem(LPCTSTR lpczText)
{
int nItem = GetItem(lpczText);
return nItem >=0 ? CTabCtrl::DeleteItem(nItem) : FALSE;
}
void CTabCtrlEx::RemoveAllItems(BOOL bDeleteDlg)
{
int nItem = 0;
CDialog* pDlg = GetNextItem(nItem);
while(pDlg)
{
CTabCtrl::DeleteItem(nItem);
if(bDeleteDlg)
{
if(m_pLastSelDlg == pDlg)
m_pLastSelDlg = NULL;
pDlg->DestroyWindow();
delete pDlg;
}
pDlg = GetNextItem(nItem);
}
}
CDialog* CTabCtrlEx::GetSelectedItemDlg()
{
int nSel = GetCurSel();
if(nSel == -1)
return NULL;
TCITEM item;
item.mask = TCIF_PARAM;
if(!CTabCtrl::GetItem(nSel, &item))
return NULL;
return (CDialog*) item.lParam;
}
BOOL CTabCtrlEx::SetSelectedItemDlg(CDialog* pDlg)
{
int nItem = GetItem(pDlg);
nItem = SetCurSel(nItem);
return nItem >= 0 ? TRUE : FALSE;
}
BOOL CTabCtrlEx::ShowSelectedItemDlg()
{
CDialog* pCurSelDlg = GetSelectedItemDlg();
if(m_pLastSelDlg == pCurSelDlg)
return TRUE;
if(m_pLastSelDlg)
m_pLastSelDlg->ShowWindow(FALSE);
m_pLastSelDlg = pCurSelDlg;
if(m_pLastSelDlg)
m_pLastSelDlg->ShowWindow(TRUE);
return m_pLastSelDlg != NULL;
}
void CTabCtrlEx::SetItemDlgRect(LPRECT lprect)
{
m_itemDlgRect = lprect;
m_itemRectIsValid = TRUE;
}
BOOL CTabCtrlEx::GetItemDlgRect(LPRECT lprect)
{
if(!lprect || !m_itemRectIsValid)
return FALSE;
lprect->top = m_itemDlgRect.top;
lprect->left = m_itemDlgRect.left;
lprect->bottom = m_itemDlgRect.bottom;
lprect->right = m_itemDlgRect.right;
return TRUE;
};
void CTabCtrlEx::OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult)
{
ShowSelectedItemDlg();
*pResult = 0;
}
---- body ----
|
|
|
|
|
federico.strati wrote: do you know any reference to this class in the literature ?
What information are you after? You have the full source, so in one sense it is fully documented. Are you concerned about using copyrighted code?
|
|
|
|
|
Hi all,
How can get Domain name in given URL?
thanks in advance.
|
|
|
|
|
|
Am not sure exactly what you mean but you might be looking for UrlGetParh[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
hello, i want to use finesse with C++, and i have installed fitnesse, but i don't know how to
install fitcpp in linux. can you help? thanks.
|
|
|
|
|
fitnesse ? finesse ?
what is that ? link ?
Watched code never compiles.
|
|
|
|
|
|
Well you have the link to the best place for an answer to your question. Use the documentation, tutorials, user group etc.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
in fact, the fitnesse is for java. so the information about c++ is little. i will look again.
thank you
|
|
|
|
|
No idea who's been throwing the 1 votes around here so have a 5 in consolation - I'd personally love to be able to try fitnesse with C++ development but being a lazy sod I've never given it a go as the docs for fitcpp were pretty dire 5 years ago. If you do find out how to install it please drop a link or describe the process here. Even if you can't get it going then the likes of me would still be interested in what's gone wrong.
Cheers,
Ash
PS: You've probably seen this already, but Alan Griffiths wrote an article on fitcpp back in 2004 for the ACCU[^]. It's crap at what you need to do to install fitcpp but goes into some detail about how to write tests and fixtures afterwards.
|
|
|
|
|
|
|
thanks, I'll have a look when I get a moment.
Cheers,
Ash
|
|
|
|
|
Hi,
I am using SelectObject() in my code but confused with the MSDN description.
CFont font;
font.CreateFont(-12, 0, 0, 0, 400, FALSE, TRUE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, _T("Courier New"));
CFont* oldFont = pdc->SelectObject(font);
pdc->TextOut(0, 0, str);
pdc->SelectObject(oldFont);
font.DeleteObject();
As per MSDN we should not use the object return by SelectObject because it is a temporary one.
But if we are restoring the old GDI object in the above way will it cause any problem
because the same dc can be used in some other place.
|
|
|
|
|
MSDN says:
This function may return a pointer to a temporary object. This temporary object is only valid during the processing of one Windows message.
So, it is ok to replace the selected object by the previous object like you did in your case.
|
|
|
|
|
Thanks for the reply. But if i want to use the same DC after this call wiil it be ok.
|
|
|
|
|
You can reuse the device-context how many times you want. The only thing you should be aware of is that:
- each time you select a GDI object (font, pen, brush, etc.) into a device-context you should restore the one that it held originally
- you should not save the pointers returned by
SelectObject to restore them later, because they could be temporary. To be more specific, the objects pointed could be destroyed during the idle-time of your application (i.e. inside the CWinApp::OnIdle ). This means that you should restore these objects before returning from the message handler on which you have called SelectObject
|
|
|
|
|
But if we restore the temporary pointer returned from SelectObject in the DC immediately, the DC may be having some dangling references after the current call. Means if we store the current DC for some other call there are chances of using incorrect memory.
|
|
|
|