Thread: repainting desktop window on refresh

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    7

    repainting desktop window on refresh

    Hi iv created a small program that allows me to scribble on the desktop window, kind of like I was holding a marking pen and scribbling on my monitors screen-the problem im having is that every time a window underneath the text is repainted or moved, it refreshes that part of the desktopwindow and obviously clears my scribbles. so what I want to know is how do I go about replacing the text when windows repaints itself, so that no matter what is going on beneath the text, and no matter how many times windows refreshes itself, my drawings dont disappear

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What about a transparent click-through window?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You could draw to a buffer and when you repaint Blit the buffer (ie a device context thingy).

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    7
    Elysia: that would be a good option, im however a bit limited beacause im using delphi 5 which I believe was created before windows supported transparent windows- but i must definitely check that option out, that would be the easiest, just like I said Iv got a sneaking suspicion that im not going to be able to

    zacs7: redrawing isnt a problem, that I can do easily, my problem is that I need to know when to redraw

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You can switch to a newer IDE if you want to. This is possible via Windows API. I don't know if any framework supports it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Jul 2008
    Posts
    7
    with transparent, click through windows, is it still possible to paint on them so that the window is transparent but the drawings aren't

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, the idea is that the background will be transparent.
    The click-through is so that every click made will be done on the window beneath it instead, so the window won't "absorb" those mouse clicks.
    Everything that exists on the window is normally not transparent.

    I used this technique once. Let me see if I still have the source.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Jul 2008
    Posts
    7
    that would be awesome if I could take a look at that- do the opaque regions also support click through

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The entire window is click-through.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by ave View Post
    that would be awesome if I could take a look at that- do the opaque regions also support click through
    They should - it's entirely up to you - basically, clickt hrough is pretty simple as far as I understand - you just say "Not for me" when the click message comes in, and Windows will automatically send it to the next window underneath.

    --
    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.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Unfortunately, I can't find the source for that.
    But there should be examples over at, say, codeprojects.com.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Registered User
    Join Date
    Jul 2008
    Posts
    7
    Matsp: any clues on how I could do that, i know the basics, so just a shove in the right direction

    Elysia: thanks anyway, I know in which direction to start looking now, so im sure if I just search around I will find what im looking for

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It's basically a windows flag or style that you set at the creation of the window, along with a transparent style.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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.

  15. #15
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Using transparent windows here is a hack since the correct method has already been suggested. The transparent window hack will lead you off into the weeds because it will lead to more z order problems later.

    Hi iv created a small program that allows me to scribble on the desktop window, kind of like I was holding a marking pen and scribbling on my monitors screen-the problem im having is that every time a window underneath the text is repainted or moved, it refreshes that part of the desktopwindow and obviously clears my scribbles.
    This leads me to believe you are not drawing the window when you receive the WM_PAINT.
    1. Your functions are probably just drawing directly to the DC
    2. When another window is moved over your window WM_PAINT is sent to your window telling you to repaint the window. Even further than that Windows will tell you what area needs repainting so you don't have to repaint the entire window.
    3. Since you are directly drawing to the DC and probably are not painting at all in response to WM_PAINT your 'drawings' get erased by the other window because the data only exists in the client DC. The data is not in memory which means you have no way to 're-present' or repaint the data from memory.

    In order to draw correctly you are going to have to track in memory what has been drawn. Then during a WM_PAINT you iterate the list of what has been drawn and re-draw it to the screen.

    Also what zacs7 said is correct. You should draw to an off-screen buffer or memory DC and then blit the memory DC to the window or client DC. This will eliminate any flicker. You will also have to tell windows that you want to handle the buffering which will turn off it's default buffering scheme. If you don't do this you will get some very odd results.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM