|
Hi Aralguppe,
I'm not saying it doesn't make sense to restart a thread, I'm just concerned about why it is stopping in the first place and would start by focusing my efforts on ensuring it keeps running whenever possible. If it has to be restared then it can PostMessage() back to the main thread to get it to create the thread from scratch.
If this is a file monitoring app why does the thread need to be in another process? Even if it is and this "other process" is your code then my comments still apply.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Like Neville said, the key is to ensure that your thread never exits in the first place. One simple way to do that is to encapsulate the body of the thread in a try/catch block:
UINT ThreadFunction(LPVOID parameter)
{
for ( ; ; ) {
try {
}
catch (...) {
}
}
return 0;
} The catch (...) block catches all exceptions. Putting the try/catch block inside the for( ; ; ) loop creates the 'automatic restart' effect you are looking for.
Note that the catch (...) is typically considered to be poor practice. Too many programmers use it rather than catching the exact exceptions that they are interested in, which means error handling stops at that spot. In your case it would be a valid usage, since the catch (...) occurs at the outer edge of the executable code for the thread.
Software Zen: delete this;
|
|
|
|
|
Gary, I have added try catch blocks with catch(...) like you have mentioned. But I have to take care of all possible scenarios even one where the thread is forcibly terminated! Probably am asking for too much
Thanks,
Aralguppe.
|
|
|
|
|
Aralguppe wrote:
even one where the thread is forcibly terminated
One way to do that is to write your program as a service. Services can be set to automatically restart in the event they are terminated, or they crash.
Software Zen: delete this;
|
|
|
|
|
Hi,
is there any rotate text function in MFC that I can call anywhere out site the onPaint. I found all examples that in order to rotate the text I have to do it in onPaint()
thanks in advance
|
|
|
|
|
Anywhere
OnMouseMove might make sense for you?
Why do you need to call it outside OnPaint()...that function is there to let you draw...
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
well,
I need to build a function with multi functionalities like this
SetFontF(fontPoint,FontName,bold,rotate,.)....like that so I can call in any other functions in my project. Do you think is it possible to do that? Sorry I am brandnew in MFC.
Thanks a lot for your replying.
|
|
|
|
|
anyone, please give me an idea please......................
|
|
|
|
|
Is there a way i could define my own keywords, so that they would be the same color as the other predefined keywords?
for example.
i have keywords set to be Green, and i have black background.
the uppercase versions of char, bool, void, etc. dont show up Green
while the lowecase ones do.
so is there a way i could define my own keywords so they would show up green?
|
|
|
|
|
Yes. Create a file called usertype.dat in the SharedIde/bin directory in which Visual Studio is installed. Put your keywords in that file, one per line.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
there is no SharedIde folder however,
could this be the right folder?
C:\Program Files\Microsoft Visual Studio\VC98\Bin
just a thought, i didnt speicify i have the Enterprise Edition, i dont think that would make a difference would it?
and what about other highlighting like operators? could i set some of those, i generally define and as && , or as || etc. in small programs no one else will see the source too
|
|
|
|
|
Try C:\Program Files\Microsoft Visual Studio\Common\IDE .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin
this one worked
ok is there a way i could make different ones a different color
like i have
BOOL
VOID
and
or
and i set user types to green
is there a way i could set
and
or
to show up another color instead of green?
like something i could add to the right of the line like
and COLOR #FF00FF
or something like that?
|
|
|
|
|
Tools | Options | Format
Category = Source Windows
Colors = User defined keywords
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
that changes all of them to one color, i want to know if there is a way i could set them to be different colors
for example i defined
VOID
BOOL
and
or
as user types,
is there a way i could make "VOID" and "BOOL" be green while "and" and "or" will be a different color like red
|
|
|
|
|
Sorry, I replied in haste. Don't know how you'd go about doing that.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
1. When I create a windows program and don't have it in focus it seems to end proccessing. This is where I place my code:
<br />
while (GetMessage(&msg, NULL, 0, 0)) <br />
{<br />
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) <br />
{<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
}<br />
Is there anyway I can make sure that my program is being run all the time, even if it's not in focus?
2. My second question is about simulating the keyboard, I know about PostMessage(). However, with this function I must post
a key press to a certain window, what I want to do is to simulate a keypress to windows.
//Ylis
|
|
|
|
|
The hidden application will receive system messages but not the windows messages... Key press are windows messages and u will get it only if that window is in focus.
I am sure, i guesss for your problem you need to implement a keyboard hook.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
oki, thx
|
|
|
|
|
To simulate keyboard messages, I guess SendInput() would be a more appropriate option.
- Nirav
* Don't wish it was easier, wish you were better! *
|
|
|
|
|
Hello, I have a problem with IDirectSound8::SetCooperativeLevel.
The DirectX SDK tells that you have to call IDirectSound8::SetCooperativeLevel immediatly after creating a IDirectSound8 object.
the prototype of IDirectSound8::SetCooperativeLevel is:
HRESULT SetCooperativeLevel(
HWND hwnd,
DWORD dwLevel
);
My app framework doesn't have any window at the moment this function has to be called.
When I set hwnd to NULL, the function fails(E_INVALIDARG).
What should I use as hwnd here?
Thx
Don't try it, just do it!
|
|
|
|
|
That means you really need to create a window before you call that function... I have see few DirectX samples and every one of them created a window before it is called. So i think its a compulsary option.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Hi again, my application doesn't close anymore after the execution of:
if( FAILED( DirectSoundCreate8( NULL, &gpDSP, NULL ) ) )
return FALSE;
before returning from main procedure i call gpDSP->Release(); , but after returning from main proc the app loops somehow through kernel32, ntdll and the kernel.
what is wrong with this?
Don't try it, just do it!
|
|
|
|
|
I am studying for software engineer, but I am not (yet) very skilled. A relative asked me if I could help him. He has an eyeproblem and has trouble locating the mousecursor in Windows. He works with Autocad where the position of the mousecurosr is shown by a big cross. So a horizontal line covering the whole width of the monitor at the y position of the cursor and a vertical line covering the whole height of the monitor at the x position of the mousecursor. So where the 2 lines intersect there is the mousecursor.
I want to make a program that runs on top of every other program in windows and shows that cross. I searched 'The code project' and found some interresting articles. Here http://www.codeproject.com/bitmap/DeskShoot.asp abhinaba describes a way to shoot hole at your windows desktop and all the running application. The trouble with this is that 1 time a copy of the desktop is taken and the holes are painted on that copy and shown on top of everything else, so the programs that are running can be accessed until you close the shooting program.
My program should show the cross and the mouseposition on top of everything, but other programs must be able to get focus.
I already tried something with getDC. I am able to get a copy of the desktop, can draw on ii and also show it, but than the problem is that when I get the desktop for the second time the old cross pointing at the old position of the mousecursor I also visible. So eventually the screen will be filled with multiple crosses.
Is it actually possible to draw dynamically over the whole desktop with keeping the functionality to acces all the running programs? Am I looking in the right direction and can somebody help me further?
Oh by the way using a bigger mousecursor is not an option. Or maybe somebody knows a program that give this functionality?
English ins't my native language, so sorry for that
|
|
|
|
|
Instead of doing that i Guess you can increase the size of the Mouse cursor by selecting appropriate cursor and enable trailing mouse , which will certainly improve the visiblity of the cursor.
Hope this solves ur problem.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|