lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Hello there.

I am using dllimport v0.0001 alpha lua library by Jas Latrix


I have one small problem and I am asking for your help.

I am trying to execute this code:

---------------------------------------------------------------------------------------------------
require "dllimport"
GetDC = dllimport("USER32","GetDC","P=P")
TextOut = dllimport("GDI32", "TextOut", "I=PiiPi")

h = GetDC(0)
print("DC: ", h)

text = "some cool text"
h = TextOut( h, 0, 0, text, string.len(text) )
print("RES: ", h)
---------------------------------------------------------------------------------------------------

Used API functions:
BOOL TextOut(
HDC hdc, // handle to DC
int nXStart, // x-coordinate of starting position
int nYStart, // y-coordinate of starting position
LPCTSTR lpString, // character string
int cbString // number of characters
);
HDC GetDC(
HWND hWnd // Handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.
);

The problem here is that TextOut doesn't draw on the Desktop for some reason:.
I don't see why.

The similar script works in AutoHotKey automatition language:
h := DllCall("GetDC", "uint", 0)
text := "some cool text"
DllCall("TextOut", "uint", h, "int", 0, "int", 0, "str", text, "int", strlen(text))

What do I do wrong here ? All examples in help file do work without problems.
Moreover, while I was experimenting with different parameters, lua did draw once the screen, but I accidently closed editor without saving the script, so I lost it..... so it passed, but now I can't repeat that. Also, return value of the API is 1 meaning that it was succesiful, and when I provide errorneous parameters it returns 0 as expected.

I also tried to put s for a string instead P (I=Piisi) but I get error about illegal 4th parameter....


Maybe you can provide some insight what went wrong here.
PS: I don't know where I downloaded dllimport and I can't find it now, but if you need it I can upload somwhere.


Thx
Miodrag

--
www.r-moth.com
http://r-moth.deviantart.com