|
Hi Guy's
I have a couple of problems with Visual C++ 6. (with Service Pack 5)
1) Is there a way of not stepping into functions such as CString during a debug session.
I'm sure I read on CP how to do this, but I cannot find that article again.
2) When running Visual C++ on a Win2K machine, sometimes when pressing F5 to build and run, VC will cause my machine to reboot. Any ideas on how to fix this?
Paresh Solanki
A Completly Random Ordering Never Yields Meaning
|
|
|
|
|
Hmm... do not use F11 and you won't step in, lol..
As for second question, I'm running VC6 on Win2k too, and have no problems with it.. So it is not Win2k, but something installed on your machine
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
Hmmm.., helpful, never woulda thought of that
If you have something like
<br />
CString bar = "Hello Philip";<br />
foo(bar.mid(3, 7));<br />
Pressing F10 will step over foo() , but F11 will step into CString::Mid() , before stepping into foo() .
What I would like is to be able to step over CString::Mid()() but into foo() .
Paresh Solanki
A Completly Random Ordering Never Yields Meaning
|
|
|
|
|
I'm not sure u can disable this... But who knows?
Anyways I don't see big deal by pressing F11 - Shift+F11 - F11... and u are inside your function
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
That's fine until you get
foo(fn1(), fn2(), fn3(), fn4()...)
causes some frantic F11-shift+F11 keystrokes.
Paresh Solanki
A Completly Random Ordering Never Yields Meaning
|
|
|
|
|
The VC debugger and UI is pretty intelligent. But if it was as intelligent as you want it to be, it'd do you out of a job!
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
|
Just what I needed Thanks!!
Paresh Solanki
A Completly Random Ordering Never Yields Meaning
|
|
|
|
|
What do you think is the better way to implement a object-oriented worker-th?
passing "this" as a LPVOID-param to a static member-function, which uses "this" to access member-data/functions dedicated to thread-operation and call the static member-function with AfxBeginThread, or subclass CWinThread
like that:
BOOL CWinThreadDerived::InitInstance()
{
while(WaitForSingleObject(m_hEventKill, 0) == WAIT_TIMEOUT)
{
WorkToBeDone();
}
return FALSE;
}
I prefer the CWinThread-derived way, because it's comfortable to implement, but a programming-professional told me THAT I shouldn't do so, but not WHY. What do you think?
|
|
|
|
|
If want to have an OO solution, you should definitely use CWinThread-derived way.
I am also using CWinThread-derived way in my applications and I have not heard any problems from my customers yet. But some multi-thread related classes in MFC have really serious bugs. For example, using CEvent class is not advised. As I have heard, it causes the application crash in some situations. I also saw this warning in a book from Microsoft Press(I could not remember the name right now).
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
Could you explain how you use it?
Remember: I want a Message-loop-LESS worker-thread. I poll for a shutdown-event in InitInstance() and while it's unsignaled a Work()-function is executed. Is it the way to go?
Yeah I heard about those troubles with MFC-syncs, so I use API-calls to sync my threads, Thanx for your Re, Flo!
|
|
|
|
|
AFAIK, a worker thread is always message-loopless. Otherwise it is called user interface threads.
In InitInstance() method, you can do the initializations. You should have a method called int Run() which will be called automatically when the thread is initialized. The thread should do its job in this method.
CMyThread *pThread = new CMyThread ();
pThread->CreateThread ();
This creates the thread, and starts running it. If you want it to be started later, CreateThread takes a parameter for this (CREATE_SUSPENDED or something like this. I could not remember it right now )
Have a look at the following pages
http://www.codeproject.com/threads/cthread.asp -> This really a very good example!
http://www.codeproject.com/threads/usingworkerthreads.asp
Hope this helps.
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
Aaaah! I see!
when I override Run and don't care THERE for the Messages, it already has no message-loop, am I right?
Is Run called once or continuosly?
thx Flo
|
|
|
|
|
|
Thank you very very much for your answers. I rely on them and forward any customers-complain to you OK?
mfg HintiFlo@gmx.at
|
|
|
|
|
OK! I will. But I am sure that there will be none! There are no problems with CWinThread. The problems occur generally because of bad design
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
Bah, I bet that "programmer-professional" was another Microsoft's hater lol.
Use CWinThread as long as u are using MFC... why to make life harder?
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
Oh no! He was an MFC-programmer with a very good reputation.
Two beer or not two beer -> 2B-r || !2B-r
mfg Flo
|
|
|
|
|
So tell him to explain what he meant, maybe I will agree too. I never had problems with CWinThread .
And a good programmer never tell you "don't use it" without saying why and pointing to another way.
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
I have a timer message in my CMainFrame (CFrameWnd) class which I need to call the OnPaint() function in CChildView (CWnd) every second.
I have the timer set up properly, now I just can't seem to run the OnPaint() function from CMainFrame.
I got a pointer to my Child view class (or so I thought) using
CWnd *tmp = GetActiveWindow();
but this appears to be a pointer to only CWnd, not my CChildView class which inherits it's properties. Odd thing is, far as I know, the only instance of CWnd running should be my CChildView object... so why am I not getting a pointer to it instead of, what appears to be, a temporary CWnd one?
I tried making the timer message in the CChildView class, but classwizard doesn't even seem to have the option, when I tried to do it manually I got some strange errors (also, I wasn't sure where to put my SetTimer function call?).
Any help would be appreciated as I have to have this done for tomorrow.
Thanks
|
|
|
|
|
How are you doing this ? Are you trying to call OnPaint, or are you invalidating the window ?
To force OnPaint you should do this
tmp->Invalidate();
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
ah, well invalidate seemed to work fine since I just needed the window to update every second.
But for future reference, do you know how I would go about accessing a function of my CChildView class from CMainFrame?
|
|
|
|
|
GetActiveView ?
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Anti_dentite wrote:
but this appears to be a pointer to only CWnd, not my CChildView class
You need to cast the CWnd* to a CChildView*
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
What about sending a WM_PAINT?
I think it calls OnPaint for you (or did I confuse sth.?)
mfg HintiFlo
|
|
|
|