How do I draw a certain pixel on the console?
Thanks (:
How do I draw a certain pixel on the console?
Thanks (:
gavra.
Without changing the mode (which is only available in DOS) to graphics mode, you can't (or at least, you ain't supposed to do that - I'm sure there is some sneaky way of getting the handle of the window and using PutPixel or some such - but that's the same as asking "How do I add my own drawing in Internet Explorer - you aren't supposed to do that".
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I don know what you are talking about but it doesn't matter right now - I got it. (SetPixel)
thanks anyway [:
gavra.
Wait something is wierd with this function.. it seems to putpixel into my screen not into my console O_o
Help XD
gavra.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
GetDesktopWindow() you mean... and I don't think there is a concept of security when it comes to writing to another window's DC (or various other things). There is usually just, 1. you can write to another processes' window (attribute wise) with this function or 2. you can't
You need a handle to the console window, ie the window in which the command prompt appears... which should be easy to get (try FindWindow()). And then you can get the child-window area -- if that's what it's called, haven't done windows programming for a while.
The only downside is, you have to have a good understanding of how Win32 all ties together. And note that the window will probably redraw itself, thus you'd have to re-draw your pixels -- double buffering can help here.
GetConsoleWindow(): http://msdn.microsoft.com/en-us/libr...75(VS.85).aspx
O:
I used SetPixel, GetConsoleWindow, GetDC, RGB.
but after I draw the pixel if I press another apllication or window the pixel will be "removed" from from the screen - why?!
gavra.
Because the redrawing of the window is done by a process that isn't aware that you have drawn on top of what it knows about - that is exactly the point I was trying to make earlier - you can draw in another window, but you won't be able to make the application know that the drawing is there and make the other application maintain it. So, now you also need to intercept the "WM_PAINT" messages for that process, and we get into a really big hairy mess of "hooking" things.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Ohh so what is the solution? (if there is..)
humm and one more thing - what is the difference between the coordinates of gotoxy (the struct CROOD) and the coordinates of SetPixel? - it seems that SetPixel related somehow with my screen resolution and gotoxy (normally) related to the console pixels only..
thank you (:
gavra.
What are you actually trying to do? I'm sure there is some solution, but perhaps it's not along the lines of what you are currently doing... You can't really draw within another applications windows and expect those applications to maintain the content - that's like putting your pot-plants in your neighbours garden, and when you come back from holiday, expect them to still be there, without asking your neighbour to look after them - except that if your neighbour is kind, it's likely to work to do this. Applications are NEVER kind in this sense.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
XD
All I'm trying to do is to create functions for the console for drawing lines, rectangles, circles and so on..
and as I said it's actually works but not as I expected.
now, any solution\alternative way for doing this?
gavra.
Yes, use the proper Windows API in a GUI application - that's the RIGHT way to solve this type of problem.
Of course, that already has primitives to draw lines, rectangles, etc. But if you want to just practice, then you can always use the SetPixel to draw a pixel at a time.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
You could use FindWindow() and use the console window name, but its really not worth it. Just learn Win32 basics if you wan't to get into graphics.
Well ok.. (any links?)
and talking about primitives - I tried to think how to draw a circle but I have nothing helpefull \:
any ideas?
thank you again (:
gavra.