|
|
nyquisttt wrote: you are write sorry.
What does it mean?
Best,
Jun
|
|
|
|
|
That's a spelling mistake. I think he ment You are right. Sorry.
Fortitudine Vinsinues!
|
|
|
|
|
Hi All
working on a dialog based application, where the entire registry is scaneed for errors, For Registry using SDK functions ( RegOpenKey(), RegEnumKey( ) etc.)
Now what my problem is:
while scanning is going on ( there is a button "STOP" on the dialog)
if user press or click on the STOP button then the the scanning of Registry should be stopped and a messagebox should appear for resume or exit operation.
I think problem would be clear...
So please suggest me the scenario to implement this and better if provide some code snippet for the same.
Thanks
|
|
|
|
|
Start the scanning of the resgistry in a separate thread that runs an "infinite loop". This loop can be finished either when the scan is complete or when a variable is set to false. Something like that (pseudo-code):
while (bContinue)
{
if (LastKey == true)
bContinue = false;
}
This variable can be set through the main thread but you have to make it thread safe (for example use a critical section). If you are new to thread, I suggest you read some documentation about that because it can be difficult for a beginner.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
First, I would like to recommend instead a message box, two buttons "Pause" and "Stop" in your main dialog.
Perform the registry scanning in a worker thread. When press "Pause", call SuspendThread dunction in order to suspend registry scanning and change the button caption from "Pause" to "Resume". When the user press "Resume", call ResumeThread to start scanning again.
When the user press "Stop" you can call TerminateThread.
Ovidiu
Microsoft MVP - Visual C++
@to Cédric: Why "infinite loop"?
-- modified at 10:09 Friday 23rd June, 2006
|
|
|
|
|
ovidiucucu wrote: Why "infinite loop"?
I prefer using a loop that you can fully control instead of killing the thread with terminate thread. The reason is if you want to make some 'clean-up' after the loop (ok, maybe infinite loop was not the right word but I meant a loop that finishes when one of the condition is met).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
You are double-right.
First when say "maybe infinite loop was not the right" because registry is a finite stuff and sooner or later its scanning have to finish, regardless the user pushes "Stop" or not.
Second, indeed for the sake of good recommendations we have to avoid TerminateThread, which in our case can let a registry key open for reading which can lead in unpredictable, catastrophic effects.
Ovidiu
Microsoft MVP
-- modified at 10:25 Friday 23rd June, 2006
|
|
|
|
|
Using SuspendThread() and TerminateThread() is very risky, and not nearly as simple as you've described here. Before a thread suspends itself, it needs to ensure that by being suspended, the calling thread is not affected. If a synchronization object is being held by the thread, it would need to be released. Suspending a thread from another, without taking all of the precautions, is not a good idea because the thread being suspended might be in the middle of something important (e.g., memory allocation). This could result in your application entering a "hung" state. If a thread calls TerminateThread() on itself, there is no chance for cleanup. The thread goes away right then and there.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
So, instead of SuspendThread/ResumeThread the right solution is...
Ovidiu
Microsoft MVP
|
|
|
|
|
I didn't indicate they couldn't be used. You have to be very careful when using them, however.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Avoid TerminateThread(). A thread synchronization should be implemented to allow the thread function to complete/end gracefully.
Best,
Jun
|
|
|
|
|
Thanks u all
Infact I am new to threading programming. Though have some theortical basics of the concept.
So u r requested to tell me the link to begin with so that things could be more clear.
Thanks
|
|
|
|
|
i am a new programer in mfc.now i met a problem.I want to draw objects such as line ,rectagle,stroke etc. and need these objects can be resize,move,rotate in interactive mode which means using track handles of interation with mouse.I can realize resize and move with CRectTacker and it works well.But the CRectTracker do not support rotate.Now i want to rotated these objcets. i can draw rotated objects in "GDI+" ,but not in the realtime mode.if someone have realize it , i will thanks for your helping in advance.Please give me some advice.i could not find some topics about this.
|
|
|
|
|
See here[^] and here.[^]
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
i have realize it,but i want to realize the rotation of objects like lines ,curves in microsoft office .
i want to realize the rotated the objects not only resize and move.
|
|
|
|
|
I assume MFC.
Setup a timer in the OnInitDialog() updated each second (or more or less accurate, depending on how accurate the current time must be).
SetTimer(100,1000,NULL);
In the timer handler, Update the editbox with the current time:
void CBuilderDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent==100)
{
CTime t1;
t1=CTime::GetCurrentTime();
m_Editbox.SetWindowText(t1.Format("%H:%M:%S"));
}
else if (nIDEvent==1)
{
m_SplDlg.CloseIt();
KillTimer(1);
}
CDialog::OnTimer(nIDEvent);
}
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
|
Hi,
How do I get the serialnumber of the attached monitor ?
I use WMI to do some inventory management stuff and WMI will tell several things about the monitor, but apparentlig not the serial number.
Any ideas ?
jh
|
|
|
|
|
dt-jh wrote: How do I get the serialnumber of the attached monitor ?
Where is this serial number displayed?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'll try to be a little more precise. The serialnumber isn't as such displayed on the monitor screen ( if thats what You mean ). It's more a question to get the monitor to tell its serial number. I have perviously seen a program, that could do that. So some interaction between the monitor an the CPU unit may be possible. At least - it seems - some monitors are capable of doing that. Perhaps in conjunction with "non standard" videoports. For instance the new digital porttypes.
Anyway, thanks for taking the time to answer.
Regards.
jh
|
|
|
|
|
dt-jh wrote: The serialnumber isn't as such displayed on the monitor screen ( if thats what You mean ).
No. What I was getting at was if you know the monitor to have a serial number (i.e., have actually seen it displayed somewhere), then we can surely find a way of retrieving it.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Oh - now i get it. ( I hope )
Yes, we run a "professional" inventory management tool in the company. That's the program, that can do the job. I'll try to get som more information for You/us.
Regards
jh
|
|
|
|
|
Does this inventory program work on all of your monitors or just a select few?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I think the monitor device only receives signals from the computer but is not able to send data back. Therefore I am afraid you will not be able to determine monitor’s information programmatically.
However you can get some information about video controller using Win32_VideoController WMI class.
|
|
|
|