By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,464 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,464 IT Pros & Developers. It's quick & easy.

Console Hooks

P: n/a
Is it possible to attach Windows WndProc hooks into a Console application
window?

Thanks,
Mythran

Apr 4 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Mythran,
Is it possible to attach Windows WndProc hooks into a Console application
window?


If I understood your question correctly, you would like to somehow modify
the workings of the Windows console window. Am I correct?

If yes, I don't think creating custom window hooks would be a very good
solution because you would be modifying operating system functionality. What
exactly would you like to achieve? With some more information, it would be
easier to suggest alternative ways to get what you want.

Thanks!

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Apr 4 '06 #2

P: n/a

"Jani Järvinen [MVP]" <ja***@removethis.dystopia.fi> wrote in message
news:u4**************@TK2MSFTNGP11.phx.gbl...
Mythran,
Is it possible to attach Windows WndProc hooks into a Console application
window?


If I understood your question correctly, you would like to somehow modify
the workings of the Windows console window. Am I correct?

If yes, I don't think creating custom window hooks would be a very good
solution because you would be modifying operating system functionality.
What exactly would you like to achieve? With some more information, it
would be easier to suggest alternative ways to get what you want.

Thanks!

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/


Alternative?? Hmm..

I have a console window. I can draw to the console window where I would
like a string displayed (lower-left hand side, in a different font than the
console font). It's all good until the console window gets repainted (by
moving the area I paint off the screen, or scrolling the console window).
At this point, I would like to redraw the string (when it gets re-updated).
So, I can do this by listening for the correct message to WndProc and then
draw the string...which is why I want to do it this way. So yeah, I would
like to attach a WndProc hook to a console application :) And even if there
is another way, I would like to learn how to attach the WndProc hook to a
console app, simply because it has me stumped ...

Mythran

Apr 4 '06 #3

P: n/a
Hello!
I can draw to the console window where I would like a string displayed
(lower-left hand side, in a different font than the console font). It's
all good until the console window gets repainted (by moving the area I
paint off the screen, or scrolling the console window).


It sounds like you were trying to draw a status bar to the console window.
In that case, are you sure a console application would be what you want in
the first place? To me it sounds like you would be better off with a normal
GUI application. As you know, there you have maximum control over the
appearance of your application.

If you still need to use a console application, you can mimic a status bar
in your console application by drawing text with a different color and
background. Assuming you use .NET 2.0, you can use the System.Console class
to change colors, and then write to the bottom of the screen.

http://msdn2.microsoft.com/en-us/lib...le(VS.80).aspx

Trying to hook the console window is in my opinion a recipe for disaster. If
not with the current operating systems, then with the next ones.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Apr 4 '06 #4

P: n/a

"Jani Järvinen [MVP]" <ja***@removethis.dystopia.fi> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
Hello!
I can draw to the console window where I would like a string displayed
(lower-left hand side, in a different font than the console font). It's
all good until the console window gets repainted (by moving the area I
paint off the screen, or scrolling the console window).


It sounds like you were trying to draw a status bar to the console window.
In that case, are you sure a console application would be what you want in
the first place? To me it sounds like you would be better off with a
normal GUI application. As you know, there you have maximum control over
the appearance of your application.

If you still need to use a console application, you can mimic a status bar
in your console application by drawing text with a different color and
background. Assuming you use .NET 2.0, you can use the System.Console
class to change colors, and then write to the bottom of the screen.

http://msdn2.microsoft.com/en-us/lib...le(VS.80).aspx

Trying to hook the console window is in my opinion a recipe for disaster.
If not with the current operating systems, then with the next ones.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/


Grr, I do appreciate the replies, but I keep getting the same responses "do
it a different way". I'm sure there are other ways, and in most cases, I
would do it other ways, but I'm trying to do it this way just so I can do it
:) Just, because that's what I want heh...this isn't a production
application, just a test application I'm working on to see if I can do
things that normally aren't done. I am not trying to cause trouble, I just
want what I want and how I want it....just because I want it that way lol...

Anywho, if it's possible, I would like to know how and do it.

Thanks,
Mythran

Apr 4 '06 #5

P: n/a
Simple answer, NO it's not possible. The Console application has no window
attached to it, so it has no massege queue and as such can't have a windows
procedure 5wndProc).

Willy.

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:ug**************@TK2MSFTNGP15.phx.gbl...
|
| "Jani Järvinen [MVP]" <ja***@removethis.dystopia.fi> wrote in message
| news:O8**************@TK2MSFTNGP11.phx.gbl...
| > Hello!
| >
| >> I can draw to the console window where I would like a string displayed
| >> (lower-left hand side, in a different font than the console font).
It's
| >> all good until the console window gets repainted (by moving the area I
| >> paint off the screen, or scrolling the console window).
| >
| > It sounds like you were trying to draw a status bar to the console
window.
| > In that case, are you sure a console application would be what you want
in
| > the first place? To me it sounds like you would be better off with a
| > normal GUI application. As you know, there you have maximum control over
| > the appearance of your application.
| >
| > If you still need to use a console application, you can mimic a status
bar
| > in your console application by drawing text with a different color and
| > background. Assuming you use .NET 2.0, you can use the System.Console
| > class to change colors, and then write to the bottom of the screen.
| >
| > http://msdn2.microsoft.com/en-us/lib...le(VS.80).aspx
| >
| > Trying to hook the console window is in my opinion a recipe for
disaster.
| > If not with the current operating systems, then with the next ones.
| >
| > --
| > Regards,
| >
| > Mr. Jani Järvinen
| > C# MVP
| > Helsinki, Finland
| > ja***@removethis.dystopia.fi
| > http://www.saunalahti.fi/janij/
| >
| >
|
| Grr, I do appreciate the replies, but I keep getting the same responses
"do
| it a different way". I'm sure there are other ways, and in most cases, I
| would do it other ways, but I'm trying to do it this way just so I can do
it
| :) Just, because that's what I want heh...this isn't a production
| application, just a test application I'm working on to see if I can do
| things that normally aren't done. I am not trying to cause trouble, I
just
| want what I want and how I want it....just because I want it that way
lol...
|
| Anywho, if it's possible, I would like to know how and do it.
|
| Thanks,
| Mythran
|
Apr 4 '06 #6

P: n/a
Thanks ;)
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl...
Simple answer, NO it's not possible. The Console application has no window
attached to it, so it has no massege queue and as such can't have a
windows
procedure 5wndProc).

Willy.

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:ug**************@TK2MSFTNGP15.phx.gbl...
|
| "Jani Järvinen [MVP]" <ja***@removethis.dystopia.fi> wrote in message
| news:O8**************@TK2MSFTNGP11.phx.gbl...
| > Hello!
| >
| >> I can draw to the console window where I would like a string
displayed
| >> (lower-left hand side, in a different font than the console font).
It's
| >> all good until the console window gets repainted (by moving the area
I
| >> paint off the screen, or scrolling the console window).
| >
| > It sounds like you were trying to draw a status bar to the console
window.
| > In that case, are you sure a console application would be what you
want
in
| > the first place? To me it sounds like you would be better off with a
| > normal GUI application. As you know, there you have maximum control
over
| > the appearance of your application.
| >
| > If you still need to use a console application, you can mimic a status
bar
| > in your console application by drawing text with a different color and
| > background. Assuming you use .NET 2.0, you can use the System.Console
| > class to change colors, and then write to the bottom of the screen.
| >
| > http://msdn2.microsoft.com/en-us/lib...le(VS.80).aspx
| >
| > Trying to hook the console window is in my opinion a recipe for
disaster.
| > If not with the current operating systems, then with the next ones.
| >
| > --
| > Regards,
| >
| > Mr. Jani Järvinen
| > C# MVP
| > Helsinki, Finland
| > ja***@removethis.dystopia.fi
| > http://www.saunalahti.fi/janij/
| >
| >
|
| Grr, I do appreciate the replies, but I keep getting the same responses
"do
| it a different way". I'm sure there are other ways, and in most cases,
I
| would do it other ways, but I'm trying to do it this way just so I can
do
it
| :) Just, because that's what I want heh...this isn't a production
| application, just a test application I'm working on to see if I can do
| things that normally aren't done. I am not trying to cause trouble, I
just
| want what I want and how I want it....just because I want it that way
lol...
|
| Anywho, if it's possible, I would like to know how and do it.
|
| Thanks,
| Mythran
|


Apr 4 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.