|
run it trough the debugger...?
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
put a breakpoint in each thread and press F8 to step through the execution context will toggle between threads... If you pressF5 then you may loose the control of debugging the threades.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Debugging threads is always difficult. If at all possible try to debug with the minimum number of threads at any one time.
As has already been mensioned context switching will occur while debugging threads.
Ant.
|
|
|
|
|
I think you can use the ordinary "TRACE" inside each threads, and then use F5 to debug.
This will only show you the sequence of operations that really happen. But the advantage is that you will know what is happened on when
But don't use too many TRACE, on each thread, cause doing so will make the debug report is too long and hard to TRACE
does it help?
Programming or Die?
----C++ 4 ever-----
|
|
|
|
|
Guys,
I developed a simple console appliation using Visual C++ 6.0 for the purpose of exception handling. I developed a simple program:
#include <stdio.h>
class CFoo
{
public:
CFoo()
{
throw;
}
};
int main(int argc, char* argv[])
{
try
{
CFoo foo;
}
catch(...)
{
printf("Exception Occured");
}
return 0;
}
i.e i throw exception from the constructor of CFoo class and wants to catch this exception in the main().
But this is not happening, instead my program crashes when i encounters throw and show dialog box of Visual C++ debug library that "Abnormal Program Termination". Can any one tell me why program is unable to enter the catch(..) block ??
Imtiaz
|
|
|
|
|
You can't throw an exception in constructor of statically allocated object. For details, search 'exceptions in constructors' in MSDN.
Robert-Antonio
"Czech Railways discovered, that in case of disaster the most damaged wagons
were the first and the last. So they decided to create trains without them."
|
|
|
|
|
You've got to throw something. The statement
throw; does a rethrow, i.e. it throws again the exception that triggered a catch handler:
try{
...
}
catch(...){
printf("oops!");
throw;
} Try for instance throw "hello"; in CFoo ctor. The problem should go away.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Does anyone know of a decent HTTP framework for C++? I want to include a simple HTTP server interface into a program, and would rather not code it by hand and so am looking for a suitable library. I've done a search but cannot find anything appropriate, and dont really want to start ripping code from Apache.
Note that it must be platform independant!
|
|
|
|
|
I dunno, have you tried searching in google?
Programming or Die?
----C++ 4 ever-----
|
|
|
|
|
Yes, thanks for that, who would have thought to use google.
|
|
|
|
|
Hi,
I have recently started working with a company that wants me to move an application from MAC to PC. They want to incorporate the MAC application into their newly created VB.NET application.
Is there an easy way to move the MAC C++ code to Visual C++.Net? The C++ code on the MAC should be mostly MAC independent (or so I have been told)!
Best regards
Pål Eilertsen
|
|
|
|
|
palei wrote:
Is there an easy way to move the MAC C++ code to Visual C++.Net? The C++ code on the MAC should be mostly MAC independent (or so I have been told)!
It all depends on what the code is made up of.
Obviously you'll have to scrap any GUI code, as the Mac API's are totally different to the Win32 API's.
If the other code uses standard C++, it shouldn't be too much trouble to recompile it on Windows. I've not taken code from MAC to PC, but I have taken PC code to MAC.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Hi,
My problem :
In my MFC-Dialog the funktion CMyProgDlg::OnInitDialog() starts a static Funktion in a thread (AfxBeginThread).
How is it possible to access a non-static member-variable (etc. m_txt) out of the static function?
The error: error C2597: illegal reference to non-static member 'CMyProgDlg::m_Txt'
Thanks!!!
|
|
|
|
|
you must pass the dialog as a parameter to the
static funtion.
in the static function you can cast the UserDefined
LPVOID parameter back to your CMyProgDlg and use
the m_Text member.
|
|
|
|
|
this[^] might help
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Pass a pointer to CMyProgDlg instance as a parameter to the thread function:
void CMyProgDlg::ThreadFunc(LPVOID pParam)
{
CMyProgDlg* pDlg = (CMyProgDlg*)pParam;
}
void CMyProgDlg::OnInitDialog()
{
AfxBeginThread(CMyProgDlg::ThreadFunc, this);
}
Robert-Antonio
"A flower walked around a meadow. She saw a beatiful human and plucked off his head."
|
|
|
|
|
Hi
I'm trying to work with dialog boxes and I need to know if my needs are implementable.
As we all know when we want to register a window class (to create a window of it later), we set a value of "WNDCLASS" structure named "cbWndExtra", this value specifies number of the bytes to reserve for each window instance. These bytes can be accessed through "SetWindowLong" and "GetWindowLong" calls.
Since we don't register a "WNDCLASS" for a dialog box, I need to know if I can use these facilities while I'm working with dialog boxes!! Is it possible? How?
Thanks in advance
Mehran Ziadloo
|
|
|
|
|
You can, but cbWndExtra must be at least DLGWINDOWEXTRA . You can specify your own window class to be used for a dialog by using the CLASS parameter of the DIALOG resource.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Is there any way to store user-defined data in a CWnd class without deriving a new class from it? Similar to the Tag property that many controls in .NET have. Thanks.
- Aaron
|
|
|
|
|
how about
SetWindowLong(hWnd,GWL_USERDATA,user_data)
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
That looks like it will work beautifully. Thanks!
- Aaron
|
|
|
|
|
Hi all,
I have written an application with a third party dll but get a
assertion fail from the third party dll,
The assertion fail on :
dbgheap.c and expression _CrtlsValidHeapPointer(pUserData)
it seems a memory conflict error
But the memory conflict error only occur on Window 2000, but on Window XP
Home it works fine, why ?
|
|
|
|
|
Because the memory layout for XP and 2000 are slightly different. Someone has a bug in their program. They are deallocating an invalid pointer.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks Tim,
What does the "invalid" of invalid pointer mean ?
1. a pointer which has already been deallocated
2. a pointer that has not been allocating memory yet
3. or something else ?
Patrick
|
|
|
|
|
Hi,
I am merging 5 bmp's and displaying them as a single bmp in the OnDraw(). The bmp does not get scrolled when i move the
scrollbar.Instead if i draw a rectangle it gets scrolled when i move the scrollbars, why does not the bmp get scrolled?
Thanks and regards,
Salil.
void CAprsView::OnDraw(CDC* pDC)
{
CAprsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString szFilename("d:\\vc\\mfc\\2001.bmp");
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,szFilename,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp;
bmp.Attach(hBmp);
CClientDC dc(this);
CDC bmDC;
bmDC.CreateCompatibleDC(&dc);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
BITMAP bi;
bmp.GetBitmap(&bi);
dc.StretchBlt (0,0,len_in_pix,ht_in_pix,&bmDC,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC.SelectObject(pOldbmp);
CString szFilename1("d:\\vc\\mfc\\2002.bmp");
HBITMAP hBmp1 = (HBITMAP)::LoadImage(NULL,szFilename1,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp1;
bmp1.Attach(hBmp1);
CClientDC dc1(this);
CDC bmDC1;
bmDC1.CreateCompatibleDC(&dc1);
CBitmap *pOldbmp1 = bmDC1.SelectObject(&bmp1);
BITMAP bi1;
bmp1.GetBitmap(&bi1);
dc1.StretchBlt (0,br_in_pix,len_in_pix,ht_in_pix,&bmDC1,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC1.SelectObject(pOldbmp1);
CString szFilename2("d:\\vc\\mfc\\2003.bmp");
HBITMAP hBmp2 = (HBITMAP)::LoadImage(NULL,szFilename2,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp2;
bmp2.Attach(hBmp2);
CClientDC dc2(this);
CDC bmDC2;
bmDC2.CreateCompatibleDC(&dc2);
CBitmap *pOldbmp2 = bmDC2.SelectObject(&bmp2);
BITMAP bi2;
bmp2.GetBitmap(&bi2);
dc2.StretchBlt (0,br_in_pix+ht_in_pix,len_in_pix,br_in_pix,&bmDC2,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC2.SelectObject(pOldbmp2);
CString szFilename3("d:\\vc\\mfc\\2004.bmp");
HBITMAP hBmp3 = (HBITMAP)::LoadImage(NULL,szFilename3,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp3;
bmp3.Attach(hBmp3);
CClientDC dc3(this);
CDC bmDC3;
bmDC3.CreateCompatibleDC(&dc3);
CBitmap *pOldbmp3 = bmDC3.SelectObject(&bmp3);
BITMAP bi3;
bmp3.GetBitmap(&bi3);
dc3.StretchBlt (0,2*br_in_pix+ht_in_pix,len_in_pix,ht_in_pix,&bmDC3
,0,0,bi.bmWidth,bi.bmHeight,SRCCOPY);
bmDC3.SelectObject(pOldbmp3);
CString szFilename4("d:\\vc\\mfc\\2005.bmp");
HBITMAP hBmp4 = (HBITMAP)::LoadImage(NULL,szFilename4,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp4;
bmp4.Attach(hBmp4);
CClientDC dc4(this);
CDC bmDC4;
bmDC4.CreateCompatibleDC(&dc4);
CBitmap *pOldbmp4 = bmDC4.SelectObject(&bmp4);
BITMAP bi4;
bmp4.GetBitmap(&bi4);
dc4.StretchBlt (0,2*br_in_pix+2*ht_in_pix,len_in_pix,20,&bmDC4
,0,0,bi.bmWidth,20,SRCCOPY);
bmDC4.SelectObject(pOldbmp4);
}
void CAprsView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: calculate the total size of this view
CSize sizeTotal(2000,3000);
CSize sizePage(sizeTotal.cx/2,sizeTotal.cy /2);
CSize sizeLine(sizeTotal.cx/2,sizeTotal.cy /2);
// TODO: calculate the total size of this view
//sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal,sizePage,sizeLine);
}
|
|
|
|
|