Hello,all
I want to rotate a char at every second. but the char can't be rotated. That's why?
regards
;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.MODEL FLAT,STDCALL
option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Gdi32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\Gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ID_TIMER1 equ 1999
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain PROTO :DWORD, :DWORD, :DWORD, :SDWORD
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
ClassName db "SimpleWinClass",0
AppName db "Font Demo",0
format db "Angle ( %d )",0
szArial db "Arial",0
szhString db "Arial TrueType Font",0
szCourierNew db "Courier New",0
szaString db "Courier New TrueType Font",0
szTimesNR db "Times New Roman",0
szvString db "Times New Roman TrueType Font",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
dwAngle dword ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:SDWORD
LOCAL wc:WNDCLASSEX, msg:MSG, 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 hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,hInstance,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,0
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, ps:PAINTSTRUCT, hNFont:DWORD, hOFont:DWORD
LOCAL CharBuf:dword
.if uMsg == WM_CREATE
invoke SetTimer,hWnd,ID_TIMER1,1000,NULL ;500ms timer update ICO
mov dwAngle,0
.elseif uMsg == WM_TIMER
mov eax,wParam
.if eax == ID_TIMER1
; Print in TrueType text at 45 degrees using "Courier New" bold font
; ------------------------------------------------------------------
;invoke BeginPaint,hWnd, ADDR ps
;mov hdc,eax
invoke GlobalAlloc,GPTR,16
mov CharBuf,eax
.if dwAngle < 3600
;invoke CreateFont, 20,10,dwAngle,450, FW_BOLD, FALSE,FALSE,FALSE, \
; ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
; DEFAULT_QUALITY, 18, ADDR szCourierNew
;mov hNFont, eax
;invoke SelectObject, hdc, hNFont
;mov hOFont, eax
;invoke lstrlen, ADDR szaString
;invoke TextOut, hdc, 270,270, ADDR szaString, eax
;invoke DeleteObject, hOFont
add dwAngle,100
.else
mov dwAngle,0
.endif
invoke wsprintf,CharBuf,offset format,dwAngle
invoke SetWindowText,hWnd,CharBuf
invoke GlobalFree,CharBuf
;invoke EndPaint,hWnd, ADDR ps
.endif
.elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
invoke CreateFont, 20,10,450,450, FW_BOLD, FALSE,FALSE,FALSE, \
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
DEFAULT_QUALITY, 18, ADDR szCourierNew
mov hNFont, eax
invoke SelectObject, hdc, hNFont
mov hOFont, eax
invoke lstrlen, ADDR szaString
invoke TextOut, hdc, 270,270, ADDR szaString, eax
invoke DeleteObject, hOFont
.ELSEIF uMsg==WM_DESTROY
invoke KillTimer,hWnd,ID_TIMER1 ;cancel the 400ms timer for updating ICO.
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=cf_2
\masm32\bin\ml /c /coff %name%.bat
\masm32\bin\Link /subsystem:windows %name%.obj
if exist *.bak del *.bak
if exist *.obj del *.obj
echo.
I want to rotate a char at every second. but the char can't be rotated. That's why?
regards
;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.MODEL FLAT,STDCALL
option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Gdi32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\Gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ID_TIMER1 equ 1999
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain PROTO :DWORD, :DWORD, :DWORD, :SDWORD
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
ClassName db "SimpleWinClass",0
AppName db "Font Demo",0
format db "Angle ( %d )",0
szArial db "Arial",0
szhString db "Arial TrueType Font",0
szCourierNew db "Courier New",0
szaString db "Courier New TrueType Font",0
szTimesNR db "Times New Roman",0
szvString db "Times New Roman TrueType Font",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
dwAngle dword ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:SDWORD
LOCAL wc:WNDCLASSEX, msg:MSG, 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 hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,hInstance,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,0
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, ps:PAINTSTRUCT, hNFont:DWORD, hOFont:DWORD
LOCAL CharBuf:dword
.if uMsg == WM_CREATE
invoke SetTimer,hWnd,ID_TIMER1,1000,NULL ;500ms timer update ICO
mov dwAngle,0
.elseif uMsg == WM_TIMER
mov eax,wParam
.if eax == ID_TIMER1
; Print in TrueType text at 45 degrees using "Courier New" bold font
; ------------------------------------------------------------------
;invoke BeginPaint,hWnd, ADDR ps
;mov hdc,eax
invoke GlobalAlloc,GPTR,16
mov CharBuf,eax
.if dwAngle < 3600
;invoke CreateFont, 20,10,dwAngle,450, FW_BOLD, FALSE,FALSE,FALSE, \
; ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
; DEFAULT_QUALITY, 18, ADDR szCourierNew
;mov hNFont, eax
;invoke SelectObject, hdc, hNFont
;mov hOFont, eax
;invoke lstrlen, ADDR szaString
;invoke TextOut, hdc, 270,270, ADDR szaString, eax
;invoke DeleteObject, hOFont
add dwAngle,100
.else
mov dwAngle,0
.endif
invoke wsprintf,CharBuf,offset format,dwAngle
invoke SetWindowText,hWnd,CharBuf
invoke GlobalFree,CharBuf
;invoke EndPaint,hWnd, ADDR ps
.endif
.elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
invoke CreateFont, 20,10,450,450, FW_BOLD, FALSE,FALSE,FALSE, \
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
DEFAULT_QUALITY, 18, ADDR szCourierNew
mov hNFont, eax
invoke SelectObject, hdc, hNFont
mov hOFont, eax
invoke lstrlen, ADDR szaString
invoke TextOut, hdc, 270,270, ADDR szaString, eax
invoke DeleteObject, hOFont
.ELSEIF uMsg==WM_DESTROY
invoke KillTimer,hWnd,ID_TIMER1 ;cancel the 400ms timer for updating ICO.
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=cf_2
\masm32\bin\ml /c /coff %name%.bat
\masm32\bin\Link /subsystem:windows %name%.obj
if exist *.bak del *.bak
if exist *.obj del *.obj
echo.
dcskm4200,
The rest of your code looks OK, A timer, TextOut() etc ... but I am not sure what you want to do in terms of rotation. If its characters in the string that TextOut() displays its string manipulation before the TextOut call ?
Tell us a bit more and someone may be able to help you.
Regards,
hutch at movsd dot com
The rest of your code looks OK, A timer, TextOut() etc ... but I am not sure what you want to do in terms of rotation. If its characters in the string that TextOut() displays its string manipulation before the TextOut call ?
Tell us a bit more and someone may be able to help you.
Regards,
hutch at movsd dot com
hello,Hutch--
someone told me That is impossible to do it with win32asm. I don't believe that. so i'm trying.
regards
someone told me That is impossible to do it with win32asm. I don't believe that. so i'm trying.
regards
Its a great effect but it will be no joy to do in binary. I would be looking at a back buffer placing the characters individually at their required location then blitting the result onto the part of a wndow you require. The leading and trailing effects of mouse movement are particularly complicated.
You could have a look at one of the GDI API functions PolyTextOut() as it may do the task you have in mind.
You could have a look at one of the GDI API functions PolyTextOut() as it may do the task you have in mind.
hi, dcskm4200
nice to meet you ;)
well, why do you want to rotate text while in the script text is not rotated? you just complicate your work. draw arrows with dots as in the script, or even better - just with lines (with different colours/weights).
regards!
nice to meet you ;)
well, why do you want to rotate text while in the script text is not rotated? you just complicate your work. draw arrows with dots as in the script, or even better - just with lines (with different colours/weights).
regards!
hello,Hutch--
thanks you for guiding me.
tonight, I'll try to use the method that you taught me.
it has been finished.
;=================================
hello,Shoo.
I'm very glad to meet you here. the world is becoming smaller and smaller. as an our proverb said, if I did not see you on looking up, then i'll see you on looking down.
i'v never forgotten the method how found a error. That is it which you taught me.
until now, I'v not found the best effect how moving a char. i think your method is better. But I don't know how to complete. give me a example.
;=================================
regards
thanks you for guiding me.
tonight, I'll try to use the method that you taught me.
"The leading and trailing effects of mouse movement are particularly complicated".
it has been finished.
;=================================
hello,Shoo.
I'm very glad to meet you here. the world is becoming smaller and smaller. as an our proverb said, if I did not see you on looking up, then i'll see you on looking down.
i'v never forgotten the method how found a error. That is it which you taught me.
until now, I'v not found the best effect how moving a char. i think your method is better. But I don't know how to complete. give me a example.
;=================================
regards
ok, i'll try to find time to this... but you forgot to post the proverb in original look also ;)
regards!
regards!
hello,Hutch--
;========================
invoke lstrlen, ADDR szaString
mov polytext.n,eax
m2m polytext.x,dwAngle
mov polytext.y,40
mov polytext.lpStr,offset szaString
mov polytext.uiFlags,ETO_OPAQUE
mov polytext.pdx,12
mov polytext.icl.right,120
mov polytext.icl.left,30
mov polytext.icl.bottom,130
mov polytext.icl.top,40
invoke PolyTextOut,hdc,addr polytext,SIZEOF polytext
;invoke TextOut, hdc, 270,270, ADDR szaString, eax
invoke DeleteObject, hOFont
add dwAngle,100
;========================
Nothing did happen.
give me a example about how to use PolyTextOut.
regards
;========================
invoke lstrlen, ADDR szaString
mov polytext.n,eax
m2m polytext.x,dwAngle
mov polytext.y,40
mov polytext.lpStr,offset szaString
mov polytext.uiFlags,ETO_OPAQUE
mov polytext.pdx,12
mov polytext.icl.right,120
mov polytext.icl.left,30
mov polytext.icl.bottom,130
mov polytext.icl.top,40
invoke PolyTextOut,hdc,addr polytext,SIZEOF polytext
;invoke TextOut, hdc, 270,270, ADDR szaString, eax
invoke DeleteObject, hOFont
add dwAngle,100
;========================
Nothing did happen.
give me a example about how to use PolyTextOut.
regards
hello,all who are interesting the topic.
why the piece of code can't execute?
;=====================
.if eax <= 0
mov yAddFlag,FALSE
.endif
;=====================
regards.
;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.Model Flat, StdCall
Option Casemap :None
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
m2m macro p1, p2
push p2
pop p1
endm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
WindowsName db "char moving...",0
MainClassName db "WinASM_Class",0
FontName db "Times New Roman",0
format db "Source(x=%d,y=%d)-->Destination(x=%d,y=%d)",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hwnd dd ?
hInstance dd ?
msg MSG <?>
MyFont dd ?
xStep dd ?
yStep dd ?
BitWidth dd ?
ByBkBrush dd ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
TestText db "This is a Moving String.",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain proc
local @rect1:RECT,@rect2:RECT
local @wc:WNDCLASSEX
invoke RtlZeroMemory,addr @wc,sizeof @wc
mov @wc.cbSize,sizeof WNDCLASSEX
mov @wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov @wc.lpfnWndProc,offset WndProc
push hInstance
pop @wc.hInstance
mov @wc.hbrBackground,COLOR_BTNFACE+1
mov @wc.lpszMenuName,NULL
mov @wc.lpszClassName,offset MainClassName
invoke LoadIcon,hInstance,IDI_APPLICATION
mov @wc.hIcon,eax
invoke LoadCursor,NULL,IDC_ARROW
mov @wc.hCursor,eax
invoke RegisterClassEx,addr @wc
invoke CreateWindowEx,NULL,addr MainClassName,addr WindowsName,\
WS_CAPTION OR WS_SYSMENU OR WS_MINIMIZEBOX or WS_VISIBLE,\
CW_USEDEFAULT,CW_USEDEFAULT,500,300,NULL,NULL,hInstance,NULL
mov hwnd,eax
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 uses ecx edx hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
local @rect:RECT
local @hDc,@hBmp
local @ps:PAINTSTRUCT
LOCAL CharBuf,x10,y10:dword
LOCAL xAddFlag,yAddFlag:BOOL
.if uMsg == WM_CREATE
mov xStep,0
mov yStep,0
mov xAddFlag,0
mov yAddFlag,0
invoke GetSysColorBrush,COLOR_BTNFACE
;function retrieves a handle identifying a logical
;brush that corresponds to the specified color index.
mov ByBkBrush,eax
invoke SetTimer,hWnd,1000,30,NULL
.elseif uMsg==WM_PAINT
invoke GlobalAlloc,GPTR,128
mov CharBuf,eax
invoke CreateFont,24,0,0,0,0,0,0,0,ANSI_CHARSET,\
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,\
DEFAULT_PITCH or FF_SCRIPT,offset FontName
;function creates a logical font that has specific characteristics.
mov MyFont,eax
invoke BeginPaint,hWnd,addr @ps
invoke GetClientRect,hWnd,addr @rect
m2m x10,@rect.right
m2m y10,@rect.bottom
;function retrieves the coordinates of a window's client area.
invoke CreateCompatibleDC,@ps.hdc
;function creates a memory device context (DC) compatible with the specified device.
mov @hDc,eax
invoke CreateCompatibleBitmap,@ps.hdc,@rect.right,@rect.bottom
;function creates a bitmap compatible with the device that is
;associated with the specified device context.
mov @hBmp,eax
invoke SelectObject,@hDc,eax
invoke FillRect,@hDc,addr @rect,ByBkBrush
;function fills a rectangle by using the specified brush.
invoke SelectObject,@hDc,MyFont
invoke SetBkMode,@hDc,TRANSPARENT
invoke GetTabbedTextExtent,@hDc,addr TestText,sizeof TestText - 1,NULL,0
;function computes the width and height of a character string.
mov eax,xStep
.if eax >= x10
mov xStep,0
.endif
mov eax,yStep
.if eax >= y10
mov yAddFlag,TRUE
.endif
.if eax <= 0
mov yAddFlag,FALSE
.endif
m2m @rect.left,xStep
m2m @rect.top,yStep
invoke DrawText,@hDc,addr TestText,-1,addr @rect,DT_SINGLELINE
;function draws formatted text in the specified rectangle.
invoke wsprintf,CharBuf,offset format,@rect.left,@rect.top,@rect.right,@rect.bottom
invoke SetWindowText,hWnd,CharBuf
invoke GlobalFree,CharBuf
invoke BitBlt,@ps.hdc,0,0,@rect.right,@rect.bottom,@hDc,0,0,SRCCOPY
; function performs a bit-block transfer of the color data corresponding
; to a rectangle of pixels from the specified source device context into
; a destination device context.
invoke DeleteDC,@hDc
invoke DeleteObject,@hBmp
invoke EndPaint,hWnd,addr @ps
.elseif uMsg == WM_TIMER
inc xStep
;inc yStep
.if yAddFlag == FALSE
inc yStep
.else
dec yStep
.endif
invoke InvalidateRect,hWnd,0,0
;function adds a rectangle to the specified window's update region. The update
;region represents the portion of the window's client area that must be redrawn.
.ELSEIF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke WinMain
invoke ExitProcess,eax
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=charmov_4
\masm32\bin\ml /c /coff %name%.bat
\masm32\bin\Link /subsystem:windows %name%.obj
if exist *.bak del *.bak
if exist *.obj del *.obj
echo.
why the piece of code can't execute?
;=====================
.if eax <= 0
mov yAddFlag,FALSE
.endif
;=====================
regards.
;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.Model Flat, StdCall
Option Casemap :None
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
m2m macro p1, p2
push p2
pop p1
endm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
WindowsName db "char moving...",0
MainClassName db "WinASM_Class",0
FontName db "Times New Roman",0
format db "Source(x=%d,y=%d)-->Destination(x=%d,y=%d)",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hwnd dd ?
hInstance dd ?
msg MSG <?>
MyFont dd ?
xStep dd ?
yStep dd ?
BitWidth dd ?
ByBkBrush dd ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
TestText db "This is a Moving String.",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain proc
local @rect1:RECT,@rect2:RECT
local @wc:WNDCLASSEX
invoke RtlZeroMemory,addr @wc,sizeof @wc
mov @wc.cbSize,sizeof WNDCLASSEX
mov @wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov @wc.lpfnWndProc,offset WndProc
push hInstance
pop @wc.hInstance
mov @wc.hbrBackground,COLOR_BTNFACE+1
mov @wc.lpszMenuName,NULL
mov @wc.lpszClassName,offset MainClassName
invoke LoadIcon,hInstance,IDI_APPLICATION
mov @wc.hIcon,eax
invoke LoadCursor,NULL,IDC_ARROW
mov @wc.hCursor,eax
invoke RegisterClassEx,addr @wc
invoke CreateWindowEx,NULL,addr MainClassName,addr WindowsName,\
WS_CAPTION OR WS_SYSMENU OR WS_MINIMIZEBOX or WS_VISIBLE,\
CW_USEDEFAULT,CW_USEDEFAULT,500,300,NULL,NULL,hInstance,NULL
mov hwnd,eax
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 uses ecx edx hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
local @rect:RECT
local @hDc,@hBmp
local @ps:PAINTSTRUCT
LOCAL CharBuf,x10,y10:dword
LOCAL xAddFlag,yAddFlag:BOOL
.if uMsg == WM_CREATE
mov xStep,0
mov yStep,0
mov xAddFlag,0
mov yAddFlag,0
invoke GetSysColorBrush,COLOR_BTNFACE
;function retrieves a handle identifying a logical
;brush that corresponds to the specified color index.
mov ByBkBrush,eax
invoke SetTimer,hWnd,1000,30,NULL
.elseif uMsg==WM_PAINT
invoke GlobalAlloc,GPTR,128
mov CharBuf,eax
invoke CreateFont,24,0,0,0,0,0,0,0,ANSI_CHARSET,\
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,\
DEFAULT_PITCH or FF_SCRIPT,offset FontName
;function creates a logical font that has specific characteristics.
mov MyFont,eax
invoke BeginPaint,hWnd,addr @ps
invoke GetClientRect,hWnd,addr @rect
m2m x10,@rect.right
m2m y10,@rect.bottom
;function retrieves the coordinates of a window's client area.
invoke CreateCompatibleDC,@ps.hdc
;function creates a memory device context (DC) compatible with the specified device.
mov @hDc,eax
invoke CreateCompatibleBitmap,@ps.hdc,@rect.right,@rect.bottom
;function creates a bitmap compatible with the device that is
;associated with the specified device context.
mov @hBmp,eax
invoke SelectObject,@hDc,eax
invoke FillRect,@hDc,addr @rect,ByBkBrush
;function fills a rectangle by using the specified brush.
invoke SelectObject,@hDc,MyFont
invoke SetBkMode,@hDc,TRANSPARENT
invoke GetTabbedTextExtent,@hDc,addr TestText,sizeof TestText - 1,NULL,0
;function computes the width and height of a character string.
mov eax,xStep
.if eax >= x10
mov xStep,0
.endif
mov eax,yStep
.if eax >= y10
mov yAddFlag,TRUE
.endif
.if eax <= 0
mov yAddFlag,FALSE
.endif
m2m @rect.left,xStep
m2m @rect.top,yStep
invoke DrawText,@hDc,addr TestText,-1,addr @rect,DT_SINGLELINE
;function draws formatted text in the specified rectangle.
invoke wsprintf,CharBuf,offset format,@rect.left,@rect.top,@rect.right,@rect.bottom
invoke SetWindowText,hWnd,CharBuf
invoke GlobalFree,CharBuf
invoke BitBlt,@ps.hdc,0,0,@rect.right,@rect.bottom,@hDc,0,0,SRCCOPY
; function performs a bit-block transfer of the color data corresponding
; to a rectangle of pixels from the specified source device context into
; a destination device context.
invoke DeleteDC,@hDc
invoke DeleteObject,@hBmp
invoke EndPaint,hWnd,addr @ps
.elseif uMsg == WM_TIMER
inc xStep
;inc yStep
.if yAddFlag == FALSE
inc yStep
.else
dec yStep
.endif
invoke InvalidateRect,hWnd,0,0
;function adds a rectangle to the specified window's update region. The update
;region represents the portion of the window's client area that must be redrawn.
.ELSEIF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke WinMain
invoke ExitProcess,eax
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=charmov_4
\masm32\bin\ml /c /coff %name%.bat
\masm32\bin\Link /subsystem:windows %name%.obj
if exist *.bak del *.bak
if exist *.obj del *.obj
echo.
hi!
1.there unsigned comparison used: in this there is no any number less then zero. you can use this:
2.also look for x!
3.you should not make your flags xAddFlag and yAddFlag as local vars: you see them in one procedure, they are created uninitialized each call of window proc: one time to wm_paint and absolutely another time for wm_timer... if you will make these changes into your source, your text string will float and jump out from borders.
regards!
1.there unsigned comparison used: in this there is no any number less then zero. you can use this:
cmp eax,0
jg @F
mov yAddFlag,FALSE
@@:
2.also look for x!
3.you should not make your flags xAddFlag and yAddFlag as local vars: you see them in one procedure, they are created uninitialized each call of window proc: one time to wm_paint and absolutely another time for wm_timer... if you will make these changes into your source, your text string will float and jump out from borders.
regards!
Hello,Shoo.
That's all.
Thanks you very much.
That's all.
Thanks you very much.
since i'm here, a question:
you said you wish draw your clock using desktop, not separate window. in this i think just draw letters is not a good idea, because desktop is not one-coloured usually, and separate letters will not look good on it. it would be better to have table of ready bitmap circles with letters/numbers inside and jongle with them - it will be and simler, and look much better. of cause, differtnt colours may be used with them. regards!
you said you wish draw your clock using desktop, not separate window. in this i think just draw letters is not a good idea, because desktop is not one-coloured usually, and separate letters will not look good on it. it would be better to have table of ready bitmap circles with letters/numbers inside and jongle with them - it will be and simler, and look much better. of cause, differtnt colours may be used with them. regards!
hello,shoo
I agree up to your point. if I want to use the desktop, it is hardly and big work.
if some chars with flying as some screwworms are been showed in a window, it is not a better effect. I'll try. this is an opporunity I'm learning win32asm.
;================================================================
another question.
invoke CreateFont,24,0,x,y,0,0,0,0,ANSI_CHARSET,\
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,\
DEFAULT_PITCH or FF_SCRIPT,offset FontName
why the position which x,y is exist can't be used a VAR.
regards.
I agree up to your point. if I want to use the desktop, it is hardly and big work.
if some chars with flying as some screwworms are been showed in a window, it is not a better effect. I'll try. this is an opporunity I'm learning win32asm.
;================================================================
another question.
invoke CreateFont,24,0,x,y,0,0,0,0,ANSI_CHARSET,\
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,\
DEFAULT_PITCH or FF_SCRIPT,offset FontName
why the position which x,y is exist can't be used a VAR.
regards.
Please try to attach large sources of code as a file instead of pasting as a quote, believe me... you will get better responses from people ;)
Hi! i'm not sure i got what exactly do you mean with your question :( as calling convention they are just two dwords, pushed into the stack, and function does not care where from you got them... also i had look into msdn - it has to be equal to tenths of degrees, thus i do not know, is there valid to use intermediate values and values above 350, but you can control this easy, and try at least. and, finally, there are two modes: GM_COMPATIBLE and GM_ADVANCED. in case of GM_COMPATIBLE or win98 these values have to be equal. is it enough?
regards!
regards!
hello,shoo
Thanks you.
some problems:
1. can't rotate with a point.
2. can't del the finished chars.
regards.
Thanks you.
some problems:
1. can't rotate with a point.
2. can't del the finished chars.
regards.
1.what point do you mean?
2.you should to or update underlied window(s), either store altered area before placing text and then restore it by your code. second is faster but harder to do. it is a main problem why i had reccomend you to use ready not rotated bitmaps for letters - let they will be something like a bubbles with chars/numbers inside. in the script it was done with layers (i did not investigate it too much) i did not ever such manupulation before so can not even figure how it is better to do, but you are making great steps forward! i'll look into the source better and will let you know i i'll find there anything.
regards!
2.you should to or update underlied window(s), either store altered area before placing text and then restore it by your code. second is faster but harder to do. it is a main problem why i had reccomend you to use ready not rotated bitmaps for letters - let they will be something like a bubbles with chars/numbers inside. in the script it was done with layers (i did not investigate it too much) i did not ever such manupulation before so can not even figure how it is better to do, but you are making great steps forward! i'll look into the source better and will let you know i i'll find there anything.
regards!
hello,shoo
Thanks you for help.
" point " is the center of circle.
How set a char's color is an another problem.
Look at the exe. I need to set a char's coordinates as floating point values.
regards.
Thanks you for help.
" point " is the center of circle.
How set a char's color is an another problem.
Look at the exe. I need to set a char's coordinates as floating point values.
regards.
1.
2.why do you need to represent coordinates as float? load them directly from memory into fpu registers and make your calculations... are you free with fpu? it is not too complex in real.
regards!
The SetTextColor function sets the text color for the specified device context to the specified color.
COLORREF SetTextColor(
HDC hdc, // handle to DC
COLORREF crColor // text color
);
COLORREF SetTextColor(
HDC hdc, // handle to DC
COLORREF crColor // text color
);
2.why do you need to represent coordinates as float? load them directly from memory into fpu registers and make your calculations... are you free with fpu? it is not too complex in real.
regards!
hello,shoo
Thanks you for help.
set char's color is OK now.
rotating char's has improved some, almost finished. the source code is mess-up, after i'll tidy up. share it. here is a exe.
problem:
1. charmov_7.exe can't rotate with a point(.), the center of circle is rotating around a smaller circle.
regards.
Thanks you for help.
set char's color is OK now.
why do you need to represent coordinates as float?
I want to make the track of moving a char as real a circle.rotating char's has improved some, almost finished. the source code is mess-up, after i'll tidy up. share it. here is a exe.
problem:
1. charmov_7.exe can't rotate with a point(.), the center of circle is rotating around a smaller circle.
regards.