Hi,
Im looking for some ASM code that would draw some text in other window....
Like in a game, the window refresh it self in some interval...

Does anyone knows how to follow that refresh rate ..or somthing else ?
thx :lol:
Posted on 2004-10-17 15:06:30 by GR33d
i know but it don't control the refresh rate mayby :P
.386 

.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

.DATA
ClassName db "SimpleWinClass",0
AppName db "Text On Window",0
OurText db "Text On Window!",0

.DATA?
hInstance HINSTANCE ?
CommandLine LPSTR ?

.CODE
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW
mov eax,msg.wParam
ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hdc:HDC
LOCAL ps:PAINTSTRUCT
LOCAL rect:RECT
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
invoke GetClientRect,hWnd, ADDR rect
invoke DrawText, hdc,ADDR OurText,-1, ADDR rect, \
DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke EndPaint,hWnd, ADDR ps
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax, eax
ret
WndProc endp
end start

Posted on 2004-10-22 15:26:53 by |ShAdOw|
ok....
that algo writes on it owns screen...
i wanna write/draw on OTHER process window...
....
thx fur ur help
:)
Posted on 2004-10-22 22:49:43 by GR33d
Hi,

you can find out another window's DC by the GetDC-API. Attention: You have to release it with ReleaseDC.
But if you draw on it, it is destroyed the next time the program itself paints something above it.
Therefore, it might be the right thing to create your own window-class and attach it as a child.
Posted on 2004-10-23 16:27:25 by Claus von der Burchard
Hi!
Like This? 8)

.386
.model flat,stdcall
option casemap:none

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib

RGB macro red,green,blue
xor eax,eax
mov ah,blue
shl eax,8
mov ah,green
mov al,red
endm

.DATA
WinName db "XXX",0 ;The Window Title Name You Want Write
MsgBoxCaption db "HoHo",0
MsgFormat db '%d',0
szBuffer db 64 dup(?)
szSring db 'i love you',0

.DATA?
hWnd HINSTANCE ?
hdc HDC ?
rect RECT <>
rushnew HBRUSH ?

.CODE
start:
invoke FindWindow,NULL,addr WinName
mov hWnd,eax
invoke GetDC,hWnd
mov hdc,eax

RGB 255,0,0
invoke CreateSolidBrush,eax
mov rushnew,eax
invoke GetClientRect ,hWnd,addr rect

;invoke GetStockObject,GRAY_BRUSH
;invoke FillRect,hdc,addr rect,rushnew
invoke TextOut,hdc,0,0,addr szSring,SIZEOF szSring
invoke DeleteDC,hdc
invoke ExitProcess,eax

END start
Posted on 2004-10-25 04:11:41 by keyif
In the Windows GUI, which is what most applications use, a window is refreshed under the following conditions:
1. Another window that overlays the current window is moved or removed, revealing the current window
2. When resizing, minimizing or maximizing.
3. When the program itself tells Windows it wants to have its window refreshed.

The paint request is then handled normally by putting a paint request in the message queue. I think you also want to know when a paint request occurs in order to overwrite what you want to overwrite,

I'm not sure, but a "Windows Hook" *might* be available in order to peek at another window's message queue to determine if its screen is being painted. Note that hooking is not very recommendable because in my experience two hooking programs can conflict and crash your computer!

In the Windows DirectX (DirectDraw and Direct3D), which is what most games use, the "window" is always(?) refreshed at the monitor's frame rate (or an integer factor thereof, if the program can't keep up).
Posted on 2004-10-26 19:17:44 by AmkG