|
thanks,how can i cenert fitted this image in rect.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You can refer to Print Bitmaps without Doc/View Framework[^] for calculate image on the paper.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
my application crashes while I push_back a value of type POSITION.
I checked the call stack. The parameter to the insert function(push_back calls insert) was something else other than POSITION type.
How?
What could be the problem?
Please help!!
|
|
|
|
|
Can you post some code? Its hard to dig in to unseen
BTW did you read Survive The Release Version[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
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;
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);
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.
|
|
|
|
|
I see exactly the same problem in my code.
This problem occurred when I migrated to visual studio 2008 and attempted to execute the code using a release build.
The same code does not crash in debug build in VS 2008.
Has anyone been able to figure out the cause of the problem?
Thanks
David Schumaker
|
|
|
|
|
Good day,
Were you able to fix your problem ? I'm having the same kind of problem when porting to VS2008.
Thanks.
Max.
This signature was proudly tested on animals.
|
|
|
|
|
I had the same problem when porting from VS2005 to VS2008.
I avoided it using dynamic allocation something like this:
std::vector *v;
v = new ???;
v->push_back(***)
This works in both debug and release mode ^^
|
|
|
|
|
typedef void *HANDLE;
is there a type "HANDLE" in Visual c++?
i could not find any information about this type?
Thanks
|
|
|
|
|
yes.Already there in winnt.h
|
|
|
|
|
MSDN:
HANDLE Handle to an object.
This type is declared in WinNT.h as follows:
typedef PVOID HANDLE;
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi,
Is there a possibility to create a named pipe server within an (SDI) MFC app without using threads, maybe even with MFC classes?
It would be great if I could just create a named pipe object and receive a message/notification (to my SDI client window) when a client connects.
Connecting from other clients should be blocked until the first request is finished. (So no threads and critical sections are needed).
Is there anything that can solve this?
Thank you,
Niki
|
|
|
|
|
It might be simpler to use a mailslot than a named pipe.
You can send an alert to the client with a window message - like WM_COPYDATA, then the client responds by sending the data through the mailslot.
This is about as simple as it gets in Win32.
If you want hand holding, use .NET instead.
|
|
|
|
|
Thank you, I thought about Mailslots already. But the problem is the size: I need to request data up to a 1 MB.
|
|
|
|
|
I don't see anything in the docs that say that you can't send 1 MB messages to a mailslot.
You just specify zero for the intended message size when you create the mailslot, and it then allows messages of any size.
|
|
|
|
|
|
|
|
On second thought, the absolute easiest way for you to do this is what you already mentioned:
Use the WM_COPYDATA window message.
Yes it requires you to create and manage a window for purposes of receiving the message, but it just doesn't get any easier.
|
|
|
|
|
WM_COPYDATA...hmm, the first problem is within my (ATL) DLL where I hav no MFC. I created a window and a handling routine with plain Win32. First problem: I have a completely different scope and control flow inside my WndProc. I can't get an easy way to access my (ATL) object within my WndProc. Global variables are very ugly too.
Second problem: I tried it but it does not work. This is what I've done:
In my IInternetProtocol Start routine, I create a WindowClass and create a dummy window with CreateWindow. After that, there is the normal event loop.
Inside my WndProc, I use WM_CREATE to find the window of my MFC app and send WM_COPYDATA as a request.
This request is processed successfully by my MFC app; and now I immideatly send back an answer to the dummy window with WM_COPYDATA again.
But now I have a strange endless loop: There are tons of requests to my MFC app now. When I do not send back a WM_COPYDATA to the DLLs dummy window I get only one request.
But anyway, I think this technique is very slow (too slow) and not very robust, isn't it?
A third thought: What about sockets? Is there an MFC abstraction that works as mentioned?
Regards,
Niki
|
|
|
|
|
nobaq wrote: What about sockets? Is there an MFC abstraction that works as mentioned?
CAsyncSocket uses window messages for socket notifications by default, so I'd say yes.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
nobaq wrote: Second problem: I tried it but it does not work.
If it doesn't work, then there is something wrong in your implementation. Post the code and we can take a look.
|
|
|
|
|
|
I am trying to create a C++ dll using Visual Studio 2008 and am running into many dead ends. I've created a project using the template for a dll and can't figure out where to put my code. It's all giberish. I've also searched the net and the Code Project for an example and can't find one. Can anyone direct me to an example project which creates a simple dll?
|
|
|
|
|
Actually the template does a good job, showing how to export some symbols. What are your doubts about?
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]
|
|
|
|