|
I'm converting a multi project, multi threaded application from VC6 to .Net. After solving all the obvious problems due to the forgiveful VC6 compiler I stumbled across some harder problems.
First of all I got a ziljon of warnings (4251 and 4275). I chose to pragma ignore them. After that I got it all to compile and ran the application.
Then I got an Assertion Failed when the application greated the first CFrameWnd:
<br />
BOOL InterfaceThread::InitInstance()<br />
{<br />
iThreadHasExited = NULL;<br />
<br />
iDummyWindow=new DummyWindow();<br />
<br />
iDummyWindow->Create(NULL,"InterfaceThreadDummy");<br />
iDummyWindow is a CFrameWnd and InterfaceThread inherits from CWinthread. This is the first function called from _AfxThreadEntry.
In CFrameWnd::CreateEx AfxGetInstanceHandle Fails Assertion.
After this a lot of assertion fails and finally I get an unrecoverable crash in AfxNewHandler. The error occurs here (in operator new):
<br />
#ifdef _AFXDLL<br />
if (pfnNewHandler == _pfnUninitialized)<br />
{<br />
AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();<br />
pfnNewHandler = pState->m_pfnNewHandler;<br />
}<br />
if (pfnNewHandler == NULL || (*pfnNewHandler)(nSize) == 0)<br />
break;<br />
#else<br />
->>>>>>>>if (_afxNewHandler == NULL || (*_afxNewHandler)(nSize) == 0)<br />
break;<br />
#endif<br />
Seems like _AFXDLL isn't defined even though it is defined in the preprocessor definitions.
Anybody got a hint???
|
|
|
|
|
After a little debugging I just realized that new returned NULL. How can that be possible, now extraordinary amout of memory has been used and the size of the block alloced is just 400 bytes.
A new just before this had functioned perfectly.
Is there something that need to be done i .Net?
|
|
|
|
|
Just a suggestion - have you tried reading through all the warnings you're getting, rather than just ignoring them? - You might be overlooking something really important
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Of course I read through them. I also seached the web for similar problems, and most places indicated that you should ignore them.
The warnings were the following:
URLParameters.h(167) : warning C4251: 'URLParameters::iAttributes' : class 'CMapStringToString' needs to have dll-interface to be used by clients of class 'URLParameters'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\include\afxcoll.h(1410) : see declaration of 'CMapStringToString'
BackgroundImage.h(26) : warning C4275: non dll-interface class 'CWnd' used as base for dll-interface class 'BackgroundImage'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\include\afxwin.h(1913) : see declaration of 'CWnd'
BackgroundImage.h(25) : see declaration of 'BackgroundImage'
On top of this I've tried to find what's wrong with the memory handling.
I added a dummy loop that allocates an int in each iteration. If I put it in the top of InitInstance it can allocate int forever and ever, but if I move it down a bit (below a couple of window creations) it fails really quickly, after a 9 ints
We have now problem what so ever with memory when we're using VC 6, but now it crashes really early (not more than 14Mb of memory usage).
|
|
|
|
|
I have a program in visual C++ which is used to plot rainfall rate graphs against time. Now i am looking for a suitable interpolation method that can improved my rainfall rate graphs especially near the maximum turning points.
Anyone out there that i can tap on his or her expertise????Thank youu
God bless;)
|
|
|
|
|
|
Now i have one serial com port, and i want it been shared by 2 threads. Now i am using the binary semaphore to control it. I want to ask is it good? or is it good to use the critical section?
Can any body help me compare these method to let me see which one is better?
Thanks
|
|
|
|
|
Microsoft's own documentation makes the claim that the critical section is faster. Critical section can be used for synchronization among many threads within the same process. The critical section can not synchronize separate threads from different processes. It is difficult to make reader/writer type objects with critical sections.
|
|
|
|
|
Please if any of you can help me in these 2 cases :
Case 1:
I want to know something about Thread Termination . Generally I do it by exiting from the thread function by a return statement and posting a message to the main thread that the thread has ended . I have never used Terminate thread or Exit Thread API calls . But I have seen articles telling you call call Exit Thread from "Inside a thread" and not from "Outside a thread".Can you please explain me or put some of your thoughts in this matter ?
Case 2 :
Can you please send me a sample project which contains any program such as this :
There is a main thread which monitors two different Worker threads . Any sample application will do . So far I have done by creating a single thread within my the main thread .
Any help will be great . Thanks in Advance . Please mail me at aveek_99@yahoo.com .
Regards,
Aveek
|
|
|
|
|
sudiptam wrote:
But I have seen articles telling you call call Exit Thread from "Inside a thread" and not from "Outside a thread".Can you please explain me or put some of your thoughts in this matter ?
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Please if any of you can help me in these 2 cases :
Case 1:
I want to know something about Thread Termination . Generally I do it by exiting from the thread function by a return statement and posting a message to the main thread that the thread has ended . I have never used Terminate thread or Exit Thread API calls . But I have seen articles telling you call call Exit Thread from "Inside a thread" and not from "Outside a thread".Can you please explain me or put some of your thoughts in this matter ?
Case 2 :
Can you please send me a sample project which contains any program such as this :
There is a main thread which monitors two different Worker threads . Any sample application will do . So far I have done by creating a single thread within my the main thread .
Any help will be great . Thanks in Advance . Please mail me at aveek_99@yahoo.com .
Regards,
Aveek
|
|
|
|
|
|
Hello Friends,
I want to migrate from VC++6.0 to .Net, Please suggest me the correct path and what are the different technologies are present in it.
Thanks you in advance only.
Neelesh K J Jain.
|
|
|
|
|
Hi , I'am copying some text content into the Clipboard. But I'm getting error at the SetClipboardData(CF_TEXT, h_glbl); function call. This is the code I'm using
CString str; <br />
HGLOBAL h_glbl;<br />
char * buff_data ;<br />
EmptyClipboard();<br />
m_ctrl_edit_cliptextdata.GetWindowText(str);<br />
if ( OpenClipboard() != 0 )<br />
{<br />
h_glbl = GlobalAlloc(GMEM_DDESHARE, str.GetLength() );<br />
buff_data = (char * ) GlobalLock(h_glbl);<br />
strcpy(buff_data, (LPCSTR) str) ;<br />
GlobalUnlock(h_glbl);<br />
SetClipboardData(CF_TEXT, h_glbl);<br />
CloseClipboard();<br />
}
Thanks in Advance.
|
|
|
|
|
is this why if not what error type!
Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
to CF_TEXT
|
|
|
|
|
SivaramanDhamodharan wrote:
But I'm getting error...
Would you mind telling us what this error is?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
Would you mind telling us what this error is?
This is error message i am getting :
"Unhandled Exception at 0x77f767 in Clipboard.exe : User breakpoint"
I am using vc++.net.
Also, I tried to copy the Error dialog and failed because it is opened state by this application.
Thanks ,
DavidCrow and annonymous
|
|
|
|
|
compiler = vs.net2003 pro
anti software norton internet security 2005
i can not run forms.net but am able to compile com based apps.
i have disabled all antivirus and all others including scripts indicated
by severall help sites either internally or on net
the problem is still there can any one come up with a soloution besides un
installing NAV internet security 2005
email pgelliott@iprimus.com.au
|
|
|
|
|
yyin = fopen( yytext, "r" );
yy_switch_to_buffer(
yy_create_buffer( yyin, YY_BUF_SIZE ) );
these can only associate the input buffer with a file. However, creating new file is prohibited under my envirment.
Are there any good ways to solve this problem?
Best Regards,
|
|
|
|
|
I have a main app dialog with out the title bar style. So when i minisize the main app dialog and right click the samll icon in the work bar, there won't be a content menu jump out. Could any one teach me which message i should process to show the content menu when a app is minisized?
Please, help me.
Thanks a lot
|
|
|
|
|
For That you have make changes System Menu
here are some codes
#1 Get system Menu
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString("about box");
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
for handling Menu Message you have to overide
WM_SYSCOMAND message. i.e. this way
void CSockDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
this code is wizard generated but help very much
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Thank you ThatsAlok.
But i still got problem...
When i minisize the main dialog, then right click the small icon in the work bar, i can catch SC_RESTORE and SC_MINIMIZE, but i cann't catch the SC_MOUSEMENU! The left mouse click message could got, but the right mouse click couldn't catch?!
Thank you very much.
|
|
|
|
|
Hi!
nId contain value SC_MOUSEMENE.Ar eyou getting that or not pls Clarify
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Thank you for your such quickly reply.
Yes, I use the nID to get the message. I set one breakpoint at the first of the function OnSysCommand(..) and could get the mouse left click when minisize the main window, but if i use the right click, nothing happen, i got none message and my breakpoint even can not be called!
it seems no message pass in when i use the right mouse click?!
Thanks again for your help!
|
|
|
|
|
I have a program that all driverd from CDialog, and all have a member function - CString GetFuncName(),and use it like following
void ShowFunctionName(int functionid,CObject* functionobj)
{
CString msg;
switch(functionid)
{
case 1:
msg.Format("Function is %s",((CFunction1*)functionibj)->GetFuncName());
break;
case 2:
msg.Format("Function is %s",((CFunction2*)functionibj)->GetFuncName());
break;
......
}
MessageBox(msg);
}
I want to simplify code as following
void ShowFunctionName(int functionid,CObject* functionobj)
{
CString msg;
msg.Format("Function is %s",((CDialogEx*)functionibj)->GetFuncName());
MessageBox(msg);
}
So I create CDialogEx as following
class CDialogEx : public CDialog
{
public:
CDialogEx(){CDialog::CDialog();};
~CDialogEx(){CDialog::~CDialog();};
CDialogEx(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL){CDialog::CDialog(lpszTemplateName,pParentWnd);};
CDialogEx(UINT nIDTemplate, CWnd* pParentWnd = NULL)
{
CDialog::CDialog(nIDTemplate, pParentWnd);
};
public:
virtual CString GetFuncNameg() {CString rtn; return rtn;};
};
and all the functions CFunction1~CFunctionn all chage inherit from CDialog to CDialogEx,And Change the constructor ( :CDialog( .. to CDialogEx(...)
CFunction1::CFunction(CWnd* pParent /*=NULL*/)
: CDialogEx(CFunction::IDD, pParent)
But when the progame run at
CFunction1 dlg;
dlg.DoMoal();
It Will cause the "Debug Assertion Error" and terminate program
Can anybody give me a sample source like abuout "How to create and use an Extened Dialog Class?"
or hint me where has the sample.
My tool is Visull C++ 6.0
|
|
|
|