flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
upsurt
How can I draw a rectangle directly on the screen without a window?
|
|||
![]() |
|
upsurt
Thank you very much, cod3b453!
Here my first try Code: include "win32ax.inc" .data cnt dd 1000 .code start: @@: dec [cnt] jz @f invoke GetDesktopWindow invoke GetWindowDC,eax invoke BitBlt,eax,100,100,250,100,0,0,0,BLACKNESS invoke Sleep,10 jmp @b @@: finish: invoke ExitProcess,0 .end start |
|||
![]() |
|
upsurt
How can I remove the rectangle and how can I define the color? *confused*
If I move the rectangle to a new position, the old rectangle still exists for some time. Code: include "win32ax.inc" .data cnt dd 1000 .code start: @@: dec [cnt] jz @f invoke GetDesktopWindow invoke GetWindowDC,eax invoke BitBlt,eax,[cnt],[cnt],250,100,0,0,0,BLACKNESS invoke Sleep,10 jmp @b @@: finish: invoke ExitProcess,0 .end start |
|||
![]() |
|
cod3b453
The problem here is you are effectively hijacking the screen and overwriting the display area; if you really want to do this without creating a proper window you'll either need to enumerate all the open windows using EnumWindows* or save a copy of the screen under the region you're colouring in and put it back when you move it (though this is less reliable).
*You can get their regions using GetWindowRect. For every window that is under your box, you'll probably need to trap drawing using SetWindowLong to subclass the WM_PAINT or similar messages to redraw over the top or use SendMessage WM_PAINT or similar to force a redraw when you want to move it and restore the proper drawing. |
|||
![]() |
|
revolution
You could also force all other windows to redraw the portion under the rectangle by sending an InvalidateRect message. That way you don't need to manage the pixels yourself, each window will handle its own drawing in the usual fashion.
|
|||
![]() |
|
cod3b453
revolution wrote: ...InvalidateRect... ![]() |
|||
![]() |
|
upsurt
Thank you, guys! You're awesome!
|
|||
![]() |
|
upsurt
AndreyT wrote:
Source: http://stackoverflow.com/questions/2325894/difference-between-invalidaterect-and-redrawwindow |
|||
![]() |
|
badc0de02
you have to make a screen shot and copy from the image the rect and set it in like a puzzle to remove it --
|
|||
![]() |
|
revolution
A screen shot is not a good option IMO because the applications running can be dynamic and have different data to display. If you simply overwrite it with some previous capture then you get old pixels mixed with new pixels and the user says "WTF is this mess?".
|
|||
![]() |
|
badc0de02
so just simply use window hook to update every windows SIMPLY?
|
|||
![]() |
|
badc0de02
or just simply get A new Screenshot to every drawing cycle and REPLACE IT SIMPLY?
|
|||
![]() |
|
badc0de02
we have now to opinions Revolution wich is the simplest wich no?
|
|||
![]() |
|
revolution
badc0de02 wrote: or just simply get A new Screenshot to every drawing cycle and REPLACE IT SIMPLY? |
|||
![]() |
|
badc0de02
whats with the next OPINION?
|
|||
![]() |
|
upsurt
I thought also about screenshots ... but wasn't sure about the overhead/data while making a mass of screenshots.
And by the way, how would I paint the rectangle part of the image to the screen? The code I've right now draws only a black rectangle. And I don't know how to change the color. I guess it should also be able to draw a circle ... without painting every single by my self. |
|||
![]() |
|
revolution
upsurt wrote: And by the way, how would I paint the rectangle part of the image to the screen? BTW: I can't image why you want to avoid using a window. Things become much simpler when you use the OS tools for their intended purpose. The OS can also use the GPU to accelerate various functions. If you bypass all that stuff then you probably only end up creating a headache for yourself by duplicating all the OS code. |
|||
![]() |
|
upsurt
upsurt wrote:
by the way, these to options work, but only around 80% invoke InvalidateRect,rc,TRUE invoke UpdateWindow,[hwnd] and invoke RedrawWindow,[hwnd],NULL,NULL,RDW_FRAME+RDW_INVALIDATE+RDW_UPDATENOW+RDW_ALLCHILDREN But they don't clean the whole rectangle, only a part. So they will be a black part left. ![]() WHY?? |
|||
![]() |
|
revolution
upsurt wrote: <snip> BTW: If you used a formal window then you won't have this problem. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.