Click here to Skip to main content
15,888,521 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to retrofit C++ app to support B/S? Pin
Richard Andrew x6428-Dec-08 23:47
professionalRichard Andrew x6428-Dec-08 23:47 
QuestionUnable to Load Image Other than .bmp by LoadImage Function? [modified] Pin
Le@rner28-Dec-08 18:09
Le@rner28-Dec-08 18:09 
AnswerRe: Unable to Load Image Other than .bmp by LoadImage Function? Pin
Hamid_RT28-Dec-08 19:22
Hamid_RT28-Dec-08 19:22 
GeneralRe: Unable to Load Image Other than .bmp by LoadImage Function? Pin
Le@rner28-Dec-08 19:26
Le@rner28-Dec-08 19:26 
GeneralRe: Unable to Load Image Other than .bmp by LoadImage Function? Pin
Hamid_RT28-Dec-08 19:33
Hamid_RT28-Dec-08 19:33 
GeneralRe: Unable to Load Image Other than .bmp by LoadImage Function? [modified] Pin
Le@rner28-Dec-08 19:50
Le@rner28-Dec-08 19:50 
GeneralRe: Unable to Load Image Other than .bmp by LoadImage Function? Pin
Hamid_RT28-Dec-08 20:01
Hamid_RT28-Dec-08 20:01 
GeneralRe: Unable to Load Image Other than .bmp by LoadImage Function? Pin
Le@rner28-Dec-08 20:25
Le@rner28-Dec-08 20:25 
GeneralRe: Unable to Load Image Other than .bmp by LoadImage Function? Pin
Hamid_RT28-Dec-08 20:50
Hamid_RT28-Dec-08 20:50 
Questioncrash with vectors in Release Pin
VC++Maniac28-Dec-08 17:25
VC++Maniac28-Dec-08 17:25 
AnswerRe: crash with vectors in Release Pin
_AnsHUMAN_ 28-Dec-08 17:38
_AnsHUMAN_ 28-Dec-08 17:38 
GeneralRe: crash with vectors in Release Pin
VC++Maniac28-Dec-08 23:32
VC++Maniac28-Dec-08 23:32 
This code is used for holding the text selection made by the user.
CCursorPos is used for holding the cursor position.

class CCursorPos
{
public:

	CCursorPos()
	{
		invalidate();
	}

	CCursorPos(const CCursorPos& pos)
	{
		*this = pos;
	}

	BOOL isValid() const
	{
		return (m_posItem!=NULL && m_textPos.x > -1 && m_textPos.y > -1);
	}

	CCursorPos& operator=(const CCursorPos& pos)
	{
		ASSERT(pos.isValid());
		setCursor(pos.getItem(),pos.getTextPoint());
		return *this;
	}

	BOOL operator==(const CCursorPos& pos) const
	{
		ASSERT(isValid());
		ASSERT(pos.isValid());

		return (getItem() == pos.getItem() && 
			getTextPoint() == pos.getTextPoint());
	}

	BOOL operator!=(const CCursorPos& pos) const
	{
		return !(*this == pos);
	}

	POSITION getItem() const
	{
		ASSERT(isValid());
		return m_posItem;
	}

	const CPoint& getTextPoint() const
	{
		ASSERT(isValid());
		return m_textPos;
	}

	void invalidate()
	{
		m_textPos.x = m_textPos.y = -1;
		m_posItem = NULL;
	}

	void setCursor(const POSITION& pos, const CPoint& ptText)
	{
		m_textPos = ptText;
		m_posItem = pos;
		ASSERT(isValid());
	}

protected:

	CPoint m_textPos;		// in view coordinates
	POSITION m_posItem;
};

........

class COutlineTextView
{
.....
CCursorPos m_selStart, m_selEnd;
std::vector<POSITION> m_selection;

....
};

void COutlineTextView::prepareSelBounds()
{
      if (m_selection.size() > 0){
		m_selection.clear();
	}

       .....

	POSITION pos = m_selStart.getItem();
	while(pos != NULL && pos != m_selEnd.getItem())
	{
		m_selection.push_back(pos);                 //CRASH HERE  !!!!!!
		pos = getOutline()->getNext(pos);
	}

	ASSERT(pos);
	m_selection.push_back(m_selEnd.getItem());
       ...
}


The call stack:

> Desktop.exe!_crt_debugger_hook(int _Reserved=3144168) Line 65 C
Desktop.exe!_invalid_parameter(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0) Line 112 + 0x7 bytes C++
Desktop.exe!_invalid_parameter_noinfo() Line 125 + 0xc bytes C++
Desktop.exe!std::_Vector_const_iterator<unsigned long,std::allocator<unsigned long> >::operator+=(int _Off=0) Line 160 + 0x14 bytes C++
Desktop.exe!std::_Vector_iterator<unsigned long,std::allocator<unsigned long> >::operator+=(int _Off=0) Line 376 C++
Desktop.exe!std::_Vector_iterator<int,std::allocator<int> >::operator+(int _Off=0) Line 382 + 0xc bytes C++
Desktop.exe!std::vector<CTreeData *,std::allocator<CTreeData *> >::insert(std::_Vector_const_iterator<CTreeData *,std::allocator<CTreeData *> > _Where=..., CTreeData * const & _Val=0x017d6b20) Line 878 + 0x1b bytes C++
Desktop.exe!std::vector<CTreeData *,std::allocator<CTreeData *> >::push_back(CTreeData * const & _Val=0x017d6b20) Line 824 C++
Desktop.exe!COutlineTextView::prepareSelBounds() Line 4817 C++
Desktop.exe!COutlineTextView::setSelection(const CCursorPos & selStart={...}, const CCursorPos & selEnd={...}) Line 4857 C++
Desktop.exe!COutlineTextView::OnMouseMove(unsigned int nFlags=1, CPoint point={...}) Line 168 C++
Desktop.exe!COutlineEditView::OnMouseMove(unsigned int nFlags=1, CPoint pointMove={...}) Line 2935 C++
Desktop.exe!CWnd::OnWndMsg(unsigned int message=512, unsigned int wParam=1, long lParam=13254392, long * pResult=0x002ffcd0) Line 2062 C++


I replaced vector with CArray. But caused a crash after OnMouseMove() function was fully executed.
GeneralRe: crash with vectors in Release Pin
David Schumaker17-Feb-09 7:35
David Schumaker17-Feb-09 7:35 
GeneralRe: crash with vectors in Release Pin
Maximilien30-Jun-09 8:41
Maximilien30-Jun-09 8:41 
AnswerRe: crash with vectors in Release Pin
semitae11-Feb-10 1:26
semitae11-Feb-10 1:26 
QuestionHANDLE? Pin
dec8228-Dec-08 16:30
dec8228-Dec-08 16:30 
AnswerRe: HANDLE? Pin
Subrat 470826628-Dec-08 16:58
Subrat 470826628-Dec-08 16:58 
AnswerRe: HANDLE? Pin
Hamid_RT28-Dec-08 18:04
Hamid_RT28-Dec-08 18:04 
QuestionEvent driven, blocking Pipe for MFC? Pin
nobaq28-Dec-08 11:54
nobaq28-Dec-08 11:54 
AnswerRe: Event driven, blocking Pipe for MFC? Pin
Richard Andrew x6428-Dec-08 11:57
professionalRichard Andrew x6428-Dec-08 11:57 
GeneralRe: Event driven, blocking Pipe for MFC? Pin
nobaq28-Dec-08 12:26
nobaq28-Dec-08 12:26 
GeneralRe: Event driven, blocking Pipe for MFC? Pin
Richard Andrew x6428-Dec-08 12:30
professionalRichard Andrew x6428-Dec-08 12:30 
GeneralRe: Event driven, blocking Pipe for MFC? Pin
nobaq28-Dec-08 12:45
nobaq28-Dec-08 12:45 
GeneralRe: Event driven, blocking Pipe for MFC? Pin
Richard Andrew x6428-Dec-08 18:50
professionalRichard Andrew x6428-Dec-08 18:50 
GeneralRe: Event driven, blocking Pipe for MFC? Pin
nobaq29-Dec-08 1:50
nobaq29-Dec-08 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.