|
I am not sure but I don't think so. I am only using the standard console handle and I am only referring to this handle and I am using the WriteConsole() function for output.
/ms
|
|
|
|
|
I need help with something that I think is simple I just don't know how to do or how to implement it. I want to create a global variable that can be used by all of my dialog boxes. When I say used I don't just mean viewed, I would also like to be able to write to it. Thanx for all your help
P.S. If by chance anyone has the time or knows how to make a edit box appear or dissapear that would be helpful too. I figured out how to do this with buttons but when I try it the same way with edit boxes it gives me a error and I dont' know where to go from there.
Sincerely
David Berg
email: quake3b@yahoo.com
AIM: CaNorDBerG
|
|
|
|
|
Question 1: Global variables in C/C++ work like the following. Suppose you have three source files, Src1.cpp, Src2.cpp, and Src3.cpp, and you want a variable to be global between all three. Variables have to be declared exactly once, so we'll do that in Src1.cpp:
int TheGlobalVariable; The other two sources will define the global as extern like this:
extern int TheGlobalVariable; The extern keyword lets the compiler and the linker know that this variable is declared elsewhere (which means that it's storage is in another place).
Question 2: All windows (buttons, edit controls, anything) can be made to 'appear' and 'disappear' the same way, using the ShowWindow() function. The basic Win32 API function is like this:
ShowWindows(HWND window,int show_cmd); where window is the handle to the window, and show_cmd is the operation you want to perform. The two values for show_cmd you are interested in are SW_SHOW and SW_HIDE which 'show' and 'hide' the window, respectively.
If you are using MFC, all windows ultimately have CWnd as a base class, which has the method
ShowWindows(int show_cmd); where show_cmd takes the same values as the Win32 API function.
Software Zen: delete this;
|
|
|
|
|
Minor typo: ShowWindows(...) -> ShowWindow(...) . (I know that's what you meant).
On a different note, many thanks for your excellent CP article Using the WebBrowser control, simplified[^]. I rated it 5 only because CP won't let me rate in any higher!
And now for a shameless grovel: any pointers on how to implement enum/get/set methods that would allow the user to enumerate all the identified (i.e. id=mumble ) HTML elements in the current document, and peek and poke them? In other words, I'd like to be able to programatically select/clear/populate GUI elements (check boxes, radio buttons, text fields, etc.). I'm guessing I'd have to diddle with IHTMLDocument2 but I'm so COM disadvantaged it's pathetic.
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
CP won't let me rate in any higher
Glad you liked it.
Ravi Bhavnani wrote:
any pointers on how to implement enum/get/set methods that would allow the user to enumerate all the identified (i.e. id=mumble) HTML elements in the current document
You've hit on the right approach. IHTMLDocument2 is the place to start. It lets you enumerate the contents of the document. Each piece in the document will be represented as an interface pointer to an object (like IHTMLElement ). You use those interface pointers to set/get properties of the element.
Software Zen: delete this;
|
|
|
|
|
I am writing a file system monitoring thread in c++ for win32 and it is critical to keep the thread running no matter what! is there any way to restart a thread if and when it exits (say due to an error). I found out that I can use the Wait functions to find out if a thread has exited using it's handle, but this requires another thread or process to monitor the monitoring thread. Is there a way of automatically restarting a thread?
|
|
|
|
|
This doesn't make sense. Simply ensure the thread never exits unless you want it to. You just need to handle all errors as req'd. Anything else is plain wrong AFAIC.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Neville, that sounds good, but in a mission critical environment it would be a poor practice. In mission critical software development you must plan for ALL events. The idea of creating a piece of software that is 100% bullet proof is just as silly as producing software that is 100% bug free. It just can't be done. Anyway, in some instances I would rather have the thread or the process crash and restart than to continue trying to limp on after an unexpected exception (such as an access violation). Anyway, since he is talking about a thread which might be running in a foreign process space, his own address space is always suspect and could have been damaged by another thread in the process.
Bottom line, he must plan for total thread failure.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi Tim,
I basically agree with you but I was left with the distinct impression that he wasn't really trying to handle errors, hence my reply. I mean if he is ok to let the thread crash then why not the app.
I run a number of worker threads in ED and untill now I never thought about the possibility of one crashing and having to be restarted. Mind you I put a loy of effort into trying to ensure everything is as robust as I can and then handling errors as best can be. This is an app that is used by a lot of people, but it certainly isn't mission critical.
I don't know where you picked up on the thread running in a foreign process space. That would indeed warrant a much more stringent implementation.
But as I said to start I basically agree with you.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Infact I am running the thread in a foreign process space. So I don't have an option of monitoring the thread status and creating a new thread if there is a termination. Inspite of handling errors extensively, I am worried that an abnormal termination is possible.
Neville, I did a bit of reading on win32 thread implementation and I do agree that the idea of a thread restarting itself doesn't make sense May be I have to rely on effective error handling
Thanks,
Aralguppe.
|
|
|
|
|
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
|
|
|
|