flat assembler
Message board for the users of flat assembler.
Index
> Windows > Problem with GdipDrawString 32 bit |
Author |
|
Mikl___ 31 Jul 2018, 13:10
Hi, Roman!
Code: format PE64 GUI 6.0 entry WinMain include 'win64a.inc' IMAGE_BASE equ 0x400000 struct RectF x rd 1 ;REAL = REAL4 y rd 1 awidth rd 1 height rd 1 ends struct GdiplusStartupInput GdiplusVersion rd 1 DebugEventCallback rd 1 SuppressBackgroundThread rd 1 SuppressExternalCodecs rd 1 ends section '.code' code readable executable writeable proc WinMain local msg:MSG frame xor r8,r8;NULL mov edx,gdiplusStartupInput mov ecx,GdiplusToken invoke GdiplusStartup xor ebx,ebx mov ecx,FileName invoke LoadCursorFromFile mov esi,IMAGE_BASE mov edi,ClassName push rax ;hIconSm push rdi ;lpszClassName push rbx ;lpszMenuName push COLOR_WINDOWTEXT;hbrBackground=black push 10003h ;hCursor push rax ;hIcon push rsi ;hInstance push rbx ;cbClsExtra & cbWndExtra push WndSDI push sizeof.WNDCLASSEX;cbSize & style invoke RegisterClassEx,esp;addr WNDCLASSEX push rbx push rsi ;rsi=400000h shl esi,9 ;rsi=CW_USEDEFAULT push rbx push rbx push 90 push 270 push rsi ;rsi=CW_USEDEFAULT push rsi ;rsi=CW_USEDEFAULT sub rsp,20h xor ecx,ecx mov r9d,WS_OVERLAPPEDWINDOW or WS_VISIBLE invoke CreateWindowEx,,edi,edi lea edi,[msg] @@: xor r9,r9 xor r8,r8 xor edx,edx invoke GetMessage,edi invoke DispatchMessage,edi jmp @b endf endp ;---------------------------------------- proc WndSDI hwnd,uMsg,wParam,lParam local Ps:PAINTSTRUCT local hdc:QWORD local graphics:QWORD mov [hwnd],rcx frame cmp edx,WM_DESTROY je wmDESTROY cmp edx,WM_CREATE je wmCREATE cmp edx,WM_PAINT je wmPAINT leave jmp [NtdllDefWindowProc] wmDESTROY:invoke DeleteObject,[hCompatibleDC] invoke DestroyWindow, [hwnd] invoke GdiplusShutdown,[GdiplusToken] invoke DeleteObject,[hFont] xor ecx,ecx invoke RtlExitUserProcess wmCREATE:mov ecx,logfont invoke CreateFontIndirect mov [hFont],rax mov edx,WM_SETFONT xor r9,r9;FALSE invoke SendMessage,[hwnd],,rax ;---------- prepare all can be possible for drawing here (WM_PAINT is faster as this) xor ecx,ecx;NULL xor edx,edx;LANG_NEUTRAL mov r8d,nativeFormat invoke GdipCreateStringFormat mov ecx,0FF00C832h mov edx,nativebrush invoke GdipCreateSolidFill jmp wmBYE wmPAINT:lea edx,[Ps] invoke BeginPaint mov [hdc],rax lea edx,[graphics] invoke GdipCreateFromHDC,[hdc] lea edx,[graphics] invoke GdipCreateFromHWND,[hwnd] mov edx,logfont mov r8d,gpFont invoke GdipCreateFontFromLogfont,[hdc] mov edx,wPhrase or r8,-1 invoke GdipDrawString,[graphics],,,[gpFont],RectText,[nativeFormat],[nativebrush] invoke GdipDeleteFont,[gpFont] lea edx,[Ps] invoke EndPaint,[hwnd] wmBYE: endf leave retn endp ;----------------------------------------- ;section '.data' data readable writeable ClassName db "GDI+ рисование текста",0 FileName db "br_Rabbit3.cur",0 gdiplusStartupInput GdiplusStartupInput 1,NULL,FALSE,FALSE nativeFormat rq 1 hCompatibleDC rq 1 wPhrase du "hello, World!",0 nativebrush rq 1 gpFont rq 1 hFont rq 1 logfont LOGFONT 36,12,0,0,400,0,0,0,0,0,0,0,DEFAULT_PITCH or FF_SCRIPT,"Times New Roman" RectText RectF 0.0,0.0,270.0,90.0 GdiplusToken rq 1 ;----------------------------------------------- section '.idata' import data readable writeable library ntdll,'ntdll.dll',\ user,'USER32.DLL',\ gdiplus,'gdiplus.dll',\ gdi,'GDI32.DLL' import gdiplus,\ GdipCreateFontFromLogfont,'GdipCreateFontFromLogfontA',\ GdipCreateStringFormat,'GdipCreateStringFormat',\ GdipCreateSolidFill,'GdipCreateSolidFill',\ GdipCreateFromHWND,'GdipCreateFromHWND',\ GdipCreateFromHDC,'GdipCreateFromHDC',\ GdiplusShutdown,'GdiplusShutdown',\ GdipDeleteFont,'GdipDeleteFont',\ GdipDrawString,'GdipDrawString',\ GdiplusStartup,'GdiplusStartup' import user,\ LoadCursorFromFile,'LoadCursorFromFileA',\ RegisterClassEx,'RegisterClassExA',\ DispatchMessage,'DispatchMessageA',\ CreateWindowEx,'CreateWindowExA',\ DestroyWindow,'DestroyWindow',\ SendMessage,'SendMessageA',\ GetMessage,'GetMessageA',\ BeginPaint,'BeginPaint',\ EndPaint,'EndPaint' import gdi,\ CreateFontIndirect,'CreateFontIndirectA',\ DeleteObject,'DeleteObject' import ntdll,\ NtdllDefWindowProc,'NtdllDefWindowProc_A',\ RtlExitUserProcess,'RtlExitUserProcess'
|
||||||||||||||||||||
31 Jul 2018, 13:10 |
|
Roman 31 Jul 2018, 13:19
I found in my example bug.
invoke GdipCreateFont,[pFontFamily],24,0,UnitPixel(EQU 2),pFont Fix to(font size must be float !): invoke GdipCreateFont,[pFontFamily],24.0,0,UnitPixel(EQU 2),pFont And now i see my text in my window ! I'm sorry to trouble you. |
|||
31 Jul 2018, 13:19 |
|
Roman 31 Jul 2018, 13:55
How draw russian text GdipDrawString ?
Instead of letters i see abracadabra where there should be Russian letters. I try, but not help: Code: invoke GdipCreateStringFormat,0 , LANG_NEUTRAL+SUBLANG_DEFAULT, GdiPlusStringFormat |
|||
31 Jul 2018, 13:55 |
|
Mikl___ 31 Jul 2018, 14:33
Roman
макрос du неправильно обрабатывает буквы кириллицы, должно быть вот так (синтаксис masm) Code: du macro string local bslash bslash = 0 irpc c,<string> if bslash eq 0 if '&c' eq "/" bslash = 1 elseif '&c'gt 127 db ('&c'- 0B0h),4 else dw '&c' endif else bslash = 0 if '&c' eq "n" DW 0Dh,0Ah elseif '&c' eq "/" dw '/' elseif '&c' eq "r" dw 0Dh elseif '&c' eq "l" dw 0Ah elseif '&c' eq "s" dw 20h elseif '&c' eq "c" dw 3Bh elseif '&c' eq "t" dw 9 endif endif endm dw 0 endm
|
||||||||||
31 Jul 2018, 14:33 |
|
Roman 31 Jul 2018, 14:51
Aha ! Thanks Mikl___
I fixed this ! Just write in fasm: Code:
include "c:\fasm\include\encoding\win1251.inc"
|
|||
31 Jul 2018, 14:51 |
|
Roman 31 Jul 2018, 14:53
Mikl___ а нет ли у Вас masm примера GDI plus outline text ?
Что бы текст был с обводкой. Как вот этот текст https://i.stack.imgur.com/WCAit.png |
|||
31 Jul 2018, 14:53 |
|
Mikl___ 31 Jul 2018, 15:18
Roman,
нет, теста с обводкой нет... |
|||
31 Jul 2018, 15:18 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.