flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
upsurt 26 Jul 2014, 19:44
How can I draw a rectangle directly on the screen without a window?
|
|||
![]() |
|
upsurt 26 Jul 2014, 21:17
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 26 Jul 2014, 21:25
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 26 Jul 2014, 21:42
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 26 Jul 2014, 21:59
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 26 Jul 2014, 22:05
revolution wrote: ...InvalidateRect... ![]() |
|||
![]() |
|
upsurt 27 Jul 2014, 08:46
Thank you, guys! You're awesome!
|
|||
![]() |
|
upsurt 28 Jul 2014, 14:06
AndreyT wrote:
Source: http://stackoverflow.com/questions/2325894/difference-between-invalidaterect-and-redrawwindow |
|||
![]() |
|
badc0de02 28 Jul 2014, 16:04
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 28 Jul 2014, 16:39
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 28 Jul 2014, 17:20
so just simply use window hook to update every windows SIMPLY?
|
|||
![]() |
|
badc0de02 28 Jul 2014, 17:22
or just simply get A new Screenshot to every drawing cycle and REPLACE IT SIMPLY?
|
|||
![]() |
|
badc0de02 28 Jul 2014, 17:25
we have now to opinions Revolution wich is the simplest wich no?
|
|||
![]() |
|
revolution 28 Jul 2014, 17:46
badc0de02 wrote: or just simply get A new Screenshot to every drawing cycle and REPLACE IT SIMPLY? |
|||
![]() |
|
badc0de02 28 Jul 2014, 17:55
whats with the next OPINION?
|
|||
![]() |
|
upsurt 28 Jul 2014, 18:47
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 28 Jul 2014, 18:55
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 28 Jul 2014, 18:55
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 28 Jul 2014, 18:58
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.