|
You must be an expert on computer science. I very appreciate your help, thanks a lot.
I'm a beginner
|
|
|
|
|
I'm studying MSDN.net 2003 and see some words below.
"Subclassing the window does not work for messages set between processes."
These words occurred at the section "About Hooks" whereas I can't understand it.
Does it mean if we subclass a window and do something in the associated wndproc with many messages which would also be processed in the hook procedure will make the subclassing work un-regular?
Can you explain it for me?Thanks in advance.
////////////////////////////////////////
hello guys!
|
|
|
|
|
It means you can't subclass a windows from another process (a guess).
Steve
|
|
|
|
|
When you subclass a window, it means you are replacing that window's window procedure (the function that Windows calls when it has a message for the window) with a function of your own. Subclassing is used to modify the normal behavior of a message.
Hook procedures can be used to do the same kind of thing. In the hook procedure you can alter the message to change the behavior. Unfortunately, if a Windows message involves a pointer of any kind (for example, to a string), the pointer (an address in memory) only has meaning inside the process from which it originates.
Software Zen: delete this;
|
|
|
|
|
Hey,
So I'm throwing together a little program that will append another file with just one line of text. Everything seems to run smoothly, except that the program which I want to access the file (Firefox), doesn't recognize the changes.
If I open up notepad, the line has been added, and only once I save the file from inside notepad does Firefox regognize the change.
To write to the file, I'm just using a simple fopen, fwrite combonation. My code is as follows:
FILE *host;<br />
host = fopen("file", "a");<br />
fwrite(ipAdd, ipAdd.GetLength(), 1, host);<br />
fclose(host);
Like I said, everything executes properly, and I can that the line has been appended to the file, it's just that Firefox doesn't regognize it. (Even after restarting Firefox.)
Any suggestions would be greatly appreciated.
Nicky
|
|
|
|
|
|
Still doesn't regognize the change. I may be wrong, but I'm pretty confident Firefox isn't the problem.
Any other suggestions?
Thanks,
Nicky
|
|
|
|
|
I know nothing about Firefox, but if it is accessing the same file then the problem is with Firefox. Normaly I would shut down the program and restart it, to see if it reloads the new version, if that does not work, then I shut down my computer and see what happens when I try again. If it still does not recognise the chages, then you are acessing to different files.
INTP
Every thing is relative...
|
|
|
|
|
Like I said in my first post, even after restarting Firefox (closing and reopening), the file still isn't recognized. I haven't tried restarting the my computer, but that really wouldn't be practical, even if it worked.
I think the most important thing is that if I open the file in notepad, and simply save it again (not making any changes), the changes are regognized. Any thoughts on why this would be?
Nicky
|
|
|
|
|
hey,
i have a ulong and i need to convert it to uint. how can i do this? i'm guessing this is pretty simple. i've searched google but i just get a ton pages showing how to do conversions in c# and vb.
thanks in advance,
sam kline
-- modified at 19:21 Saturday 4th March, 2006
|
|
|
|
|
unsigend long x = 100;
unsigned int y = (unsigned int)x;
this will do. But why do you want to convert long to int. long is 64bits and int is 32 so it will get truncated.
|
|
|
|
|
Acutaly it depends on the compiler, in VC6 they are both 32bits. An int is supposed to be the size of a register word, but in reality it is up to the creators of the compiler.
INTP
Every thing is relative...
|
|
|
|
|
yea long is 32-bit in vc. I must have been sleeping when replying
|
|
|
|
|
I'd do it like this:
static_cast<uint>(your_ulong)
C style casts (a type in brackets) are a major haste and should be avoided - This is the reason C++ added the const_cast , dynamic_cast , static_cast and reinterpret_cast keywords.
I'm sure there will be people who disagree but I would wager they haven't had to spend weeks hunting down some obscure bug caused by a bad cast which is almost invisible in the source code.
Steve
|
|
|
|
|
That depends on the type of cast. Doing such things as uint casts, no I have never had problems with them.
However, when converting pointers, yeah, static_cast will save you MUCH pain.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I agree that with numeric types there is no difference - however it's a policy thing. If all the casts are one of the function style casts you can "grep" for every cast in the project. Casts generally represent a design problem (but not in all cases) and as such should be highly visible.
Steve
|
|
|
|
|
I have never worked for a big company, but after years of reading (and fixing) other peaples code I understand why a policy is needed. I am not talking about visability (good point though), I am talking about simple things like comparing floating point numbers.
I recieved a varification a few years ago (that I was not a geek) when a guy (which I was warned about) told a joke about comparing floating point values and I said that I had no problem doing so (he stopped laughing). It took me a couple of minutes to realise what he was talking about, I did not find it funny becuase I take such things for granted.
INTP
Every thing is relative...
|
|
|
|
|
Hi!
I have a question regarding file input and output.
If I use a getchar or a getline, how can I tell
my program to go get a certain character or line
like for instance the character or line
after the phrase "Get this line:" or line # 43?
How can I do such things and which other things
are possible?
I haven't found anything usefull on the net so you
guys are my last resort.
Thanks!
Peter
|
|
|
|
|
If you know all the lines in the file are the same length then it is simply a matter of using one of the seek functions (fseek, lseek, basic_filebuf::seekpos, etc) to set the file pointer to the proper position. If that is not possible then you have to start at the beginning of the file and start reading one line at a time until you get to the desired line.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Yes, that might work.
Can you give me an example of the latter?
I am quite new to file input and output and I have never written any code that seeks
a certain line or a certain character.
Thanks!
|
|
|
|
|
You already mentioned the method "getline", it reads one whole line at a time. You just need to count the number of lines you read.
The other part of finding a substring (part of the line), you just do on a line by line bases. Unless there is a newline in the substring, in which case you have to search the whole file piece by piece or a character at at time, your choice.
You could just load the whole file (if not to larg) into an STL string type and call find to search for a substring.
The is a ridiculously large number of ways to do what you want, just look at what your library offers (string and file i/o), and your imagination.
You can even use regular expressions.
INTP
Every thing is relative...
|
|
|
|
|
I once knew a Peter Charlesworth who worked for a UK company called Kerridge back in the late '80s - not you by any chance?
The Rob Blog Google Talk: robert.caldecott
|
|
|
|
|
I'm afraid I'm not.
I wasn't born yet in the '80s, although I have been to the UK once.
Sorry to disappoint you, but that name is a pseudonym I came up with
while browsing through my font-list (Charlesworth is a font's name)
and I liked that name so I went for it. It sounds rather confident
and worthy, don't you agree?
Well I hope for you you'll see your old friend back one of these days!
Regards,
Me
|
|
|
|
|
hello.
i've used this code to open a program:
STARTUPINFO si = { sizeof(STARTUPINFO) };
PROCESS_INFORMATION pi = {0};
BOOL bSuccess;
bSuccess = CreateProcess ( NULL, "\"C:\\Program Files\\dir\\program.exe\"",
NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi );
now i want to be able to minimize and restore the program. what code can i use to do this?
thanks in advance,
sam kline
-- modified at 12:59 Saturday 4th March, 2006
|
|
|
|
|
The PROCESS_INFORMATION structure will contain the thread handle of the newly opened program. You can use PostThreadMessage to post any windows messages to that thread.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|