Good day,
I've been using GDI in my applications but would like to give GDI+ a try. I've been through some of the examples from the forum and have written a small app to test the code. It doesn't however work. In one of the posts, the GDIPLUS.DLL is mentioned. Is this what I'm missing? Kindly point me in the right direction.
comment *
- GDI+ test application
*
.386
.model flat, stdcall
option casemap:none
wordlow MACRO xParam
mov eax,xParam
and eax,0FFFFh
EndM
wordhigh MACRO xParam
mov eax,xParam
shr eax,16
EndM
ARGB MACRO alpha, red, green, blue
EXITM % alpha SHL 24 OR red SHL 16 OR green SHL 8 OR blue
ENDM
GdiplusStartupInput STRUCT
GdiplusVersion DWORD ?
DebugEventCallback DWORD ?
SuppressBackgroundThread DWORD ?
SuppressExternalCodecs DWORD ?
GdiplusStartupInput ENDS
; include files
include windows.inc
include user32.inc
include kernel32.inc
include gdiplus.inc
; lib files
includelib user32.lib
includelib kernel32.lib
includelib gdiplus.lib
; protos declared
WinMain proto :DWORD, :DWORD, :DWORD, :DWORD
WndMain proto :DWORD, :DWORD, :DWORD, :DWORD
.const
UNITPIXEL equ 2
.data
; windows specific
ClassName db "WinClass",0
szAppName db "GDI+",0
; gdi+ stuff
gdipsi GdiplusStartupInput <1,NULL,FALSE,FALSE>
pensize REAL4 3.0
.data?
; application specific
hInstance HINSTANCE ?
CommandLine LPSTR ?
hWin HWND ?
; gdi+ stuff
graphics dword ?
token dword ?
pen dword ?
.code
main:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke GdiplusStartup,addr token,addr gdipsi,NULL
invoke WinMain, hInstance, NULL, CommandLine, SW_MAXIMIZE
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 hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName, NULL ;offset szMenu
mov wc.lpszClassName, OFFSET ClassName
invoke LoadIcon, hInst, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_CROSS
mov wc.hCursor, eax
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx, WS_EX_WINDOWEDGE, ADDR ClassName, ADDR szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,700,400, NULL, NULL, hInst, NULL
mov hWnd, eax
invoke ShowWindow, hWnd, CmdShow
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 lPaint:PAINTSTRUCT
local hDC:HDC
.if uMsg == WM_DESTROY
invoke PostQuitMessage, NULL
.elseif uMsg == WM_CLOSE
invoke GdipDeleteGraphics, graphics
invoke GdiplusShutdown, token
invoke DestroyWindow,hWnd
.elseif uMsg == WM_CREATE
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWnd,addr lPaint
mov hDC,eax
invoke GdipCreateFromHDC,hDC,addr graphics
invoke GdipCreateFromHWND,hWnd,addr graphics ; why both of these?
invoke GdipCreatePen1,ARGB(0, 50, 50, 80),pensize,UNITPIXEL,addr pen
invoke GdipDrawEllipse,graphics,pen,10,10,50,50
invoke GdipDeletePen, pen
invoke EndPaint,hWnd,addr lPaint
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif
xor eax, eax
Ret
WndProc EndP
end main
you are passing integer values where floats are expected -> GdipDrawEllipseI
In the attachment an example with needed includes.
qWord, thank you!
I have stored on my pc a perfect example of gdi+ usage just by carefully crafting that program. It's called Fire GDI+, and it shows a little fire on its window. For more information you may get in this topic below, and do some diggin' if you like :)
Here it is: http://www.masm32.com/board/index.php?topic=155.0