|
ParagPatel wrote: Thanks Simmons,
ParagPatel wrote: Yes.. stopTH must be globle
Being global has nothing to do with it. If the compiler detects that nothing in the loop is changing that variable, it will optimize out the check. So even if the secondary thread changes that variable, it will go unseen.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Changing it through the class object = changing it from a different thread (the main thread of the app). Which means it will be optimized away.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Did you see bottom of CreateThread on the MSDN it explains it for you.
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 )
|
|
|
|
|
Suresh H wrote: for(int i=0;i<10000;i++)
You need to add another condition to this loop, something like:
CEvent m_event;
for (int i = 0; i < 10000; i++)
{
if (WaitForSingleObject(m_event.m_hObject, 0) == WAIT_OBJECT_0)
break;
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all,
I have to work on a small project in VC++ using "Visual Studio.net 2003".
I have to use data base in my project.
Do I need to install anything to use ODBC or is it built in.
If yes, please tell met the softwares that are to be installed to use database.
Regards,
Sunil Kumar
|
|
|
|
|
See ODBC[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi all,
I am trying to write a lightweight Windows utility with C & Win32 APIs only.
I have setup a timer and would like to display some information on the window title bar (not dialog box) at a set time interval.
I tried to use the SetWindowText function but it doesn't seem to work.
Any help or pointers would be appreciated! Thanks.
M.
|
|
|
|
|
Did you use of SetWindowText on WM_TIMER?
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 )
|
|
|
|
|
Thank you. That was the problem. It works now.
|
|
|
|
|
Hello,
I have a CMDIChildWnd which has CRichEditCtrl window over it.Now there are 4 windows of CRichEditCtrl on CMDIChildWnd.
When these CRichEditCrl windows appear on the CMDIChildWnd the background color of CMDIChildWNd changes or sometimes whatever is in the background of the window is seen on the window.
This problem is not on my PC but when i transfer my .exe on another PC then there is a problem
Prithaa
|
|
|
|
|
I'm not sure what your problem is, but in general you should not create windows directly on CMDIChildWnd. Try making your own view class inheriting from CRichEditView, and then put then in the CChildFrame using splitters. There are plenty of resources searchable on CSplitterWnd, including loads on CP.
If you do things in a standard way, it increases their chances of working. I break the rules too, but you need to do it with your eyes open, and only if you can't avoid it.
Good luck,
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Hello,
Thanks for your reply.
Your explanation was very useful.
Let me try to explain the problem.
I have a project without Doc-View Architecture and the child window is created typically with the CreateNewChild().
Now I have a CView derived class and the OnDraw of this CView class displays text on the child window.
Also the CRichEditCtrl is displayed on the screen. This works fine with my PC.
But when I transfer the application it doesnt work. On the other PC when the childwindow opens it opens properly but when the window is resized the childwindow displays the contents that are there on the background of the child window.
For now lets forget CRichEditCtrl.
When I resize the childwindow should special care be taken to redraw the background of the window and I have not done that.
Any ideas of the problem.
Thanks
Prithaa
|
|
|
|
|
There are user settings like redraw-window-when-dragging that may be different from pc-pc, and from user-user, so it's perfectly possible to see differing behaviour.
Are you handling WM_ERASEBKGND in your view?
Have you done anything strange in PreCreateWindow to change the WNDCLASS of the view to use a NULL brush?
Can you make a brand new project, and in the new view's OnDraw, do the following:
void CMyNewView::OnDraw (CDC *dc)
{
CRect rc;
GetClientRect (&rc);
dc->FillSolidRect (&rc, RGB(255,0,0));
dc->MoveTo (rc.TopLeft ());
dc->LineTo (rc.BottonRight ());
}
This is from memory, so you many need the odd change. But this should made a solid red view, with a line from one corner to the other.
If this works (and it had better!) on both PCs, then you are doing something "clever" that is breaking it in your application. Just comment out loads of code, see when things start working, and work your way forward again.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hello,
Thanks for this wonderful insight.I ll check all your points.
Prithaa
|
|
|
|
|
Hi,
I have created Button on my Dialog Box using following code.
CButton *m_myButton;
m_myButton = new CButton();
m_myButton->Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(800,y1,900,(y1+25)),this, 1);
How should I add Event handler to this button.
|
|
|
|
|
I think you can use CMyButton instead of CButton:
class CMyButton: public CButton{
};
you can add Event handler(massage handler) to this class.
|
|
|
|
|
Do I need to insert a class for an event?no.
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 )
|
|
|
|
|
one easy way is to create a button at design time, and double click on it to add the handler to know what all is needed..
Otherwise also, it is not a mammoth task. You have to declare a function, define it and add an entry for the button click to the message map.
Also you may be interested ON_CONTROL_RANGE
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Tuesday, April 14, 2009 4:02 AM
|
|
|
|
|
thanks for your reply.I have declared one function.I have added entry in message map.
It is working for me.
|
|
|
|
|
You can insert this code on your code and then if you want you can make your button.
#define IDC_DYNAMICBUTTON 3000
BEGIN_MESSAGE_MAP(CMFCDlg, CDialog)
ON_BN_CLICKED(IDC_DYNAMICBUTTON,&CMFCDlg::OnBnClickedbutton)
END_MESSAGE_MAP()
void CMFCDlg::OnBnClickedbutton()
{
}
//header file
public:
afx_msg void OnBnClickedbutton();
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 )
|
|
|
|
|
I need to catch the 0xC0000005 Exception in my code. I've tried try{}catch(CException *e){}, but it didn't work.
|
|
|
|
|
I think you are on the look out for First and Second chance exception[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Well, I've already searched Google, And I found using SEH could resolve this problem. But in my case, the code which throw the Exception is a dll. So the SEH didn't work for me.
|
|
|
|
|
normal C++ not handling "0xC0000005 Access Violation Error"" exception, you need to give more compiler option to handle it.
but you can try "__try __except", exception handling of C, it will help you. Usage[^]
Parag Patel
|
|
|
|
|
Thanks for your suggestion!
I tried it before, but it didn't work. Anyway, I found it is better to fix this problem in the dll file which throw the exception using __try__catch.
|
|
|
|