Page 1 of 1

The GUI is missing mouse events

Posted: 31 Jul 2017, 03:56
by arcticir
If the GUI uses the "-Caption" parameter, its GDI control will not be able to respond to mouse events.

Code: Select all

img:="D:\2a96558f30074646a6e18da7cb46408c.(960_1200).jpg"

OnMessage(0x0200, func("WM_MOUSEMOVE"))
(gui:=GuiCreate("-Caption")).OnEvent("Close","ExitApp")
gui.BackColor:=0x3f627f
k:=GuiCreate("+E0x80000 0x10000000 +Parent" gui.hwnd)

GdiplusStartup(getvar(pToken:=0),(si:=Struct("UINT GdiplusVersion;PTR DebugEventCallback;BOOL SuppressBackgroundThread;BOOL SuppressExternalCodecs",{GdiplusVersion:1}))[])
GdipCreateBitmapFromFile(&img,getvar(pBitmap:=0))
GdipGetImageDimension(pBitmap, getvar(width:=0), getvar(height:=0))
width:=Cast("Uint",width,"Float")
height:=Cast("Uint",height,"Float")
_W:=width*0.5
_H:=height*0.5
BITMAPINFOHEADER:="DWORD biSize;LONG biWidth;LONG biHeight;WORD biPlanes;WORD biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant;"
bi:=Struct(BITMAPINFOHEADER,{biSize:sizeof(BITMAPINFOHEADER),biWidth:_W,biHeight:_H,biPlanes:1,biBitCount:32})
hbm := CreateDIBSection( hdc:=GetDC(), bi[]),ReleaseDC(0,hdc)
hdc := CreateCompatibleDC(),obm := SelectObject(hdc, hbm)
GdipCreateFromHDC(hdc,getvar(G:=0)),GdipSetInterpolationMode(G, 7)
GdipDrawImageRectRectI(G,pBitmap,0,0,_W,_H,0,0,width,height,2)
pt:=Struct("x,y")
pt.x:=0,pt.y:=0
UpdateLayeredWindow(k.hwnd,0,pt[],getvar(temp1:=_W|_H<<32),hdc, getvar(temp2:=0),0,getvar(temp3:=255<<16|1<<24),2)
gui.show("w" _W " h" _H+50)
Return

WM_MOUSEMOVE(w,l,m,h){
	static i:=1
	ct(i++ "`t" h "`n")
}

ct(s){
	static stdout
	Return WriteConsole(stdout?stdout:(AttachConsole(-1),AllocConsole(),stdout:=GetStdHandle(-11)),&s,StrLen(s),0)
}

Re: The GUI is missing mouse events

Posted: 31 Jul 2017, 17:28
by HotKeyIt
Looks fine for me when I add a ToolTip for example, not sure about WriteConsole code:

Code: Select all

WM_MOUSEMOVE(w,l,m,h){
	static i:=1
    ToolTip A_TickCount
	ct(i++ "`t" h "`n")
}

Re: The GUI is missing mouse events

Posted: 31 Jul 2017, 20:21
by arcticir
Will the picture trigger a prompt?

WIN8 64 AHK32/64

Image

Re: The GUI is missing mouse events

Posted: 01 Aug 2017, 00:20
by arcticir
Another problem, unable to create this WINAPI function:

Code: Select all

name_size := 1255
VarSetCapacity(name, name_size )
GetModuleFileNameExW(ProcessExist(),0, &name, name_size )
MsgBox name

Code: Select all

Error:  Call to nonexistent function.

Specifically: GetModuleFileNameExW(ProcessExist(),0, &name, name_size )

	Line#
	001: name_size := 1255
	002: VarSetCapacity(name, name_size )
--->	003: GetModuleFileNameExW(ProcessExist(),0, &name, name_size )
	004: MsgBox name
	005: Exit

Re: The GUI is missing mouse events

Posted: 06 Aug 2017, 16:02
by HotKeyIt
With regards to gui you need -Caption: k:=GuiCreate("+E0x80000 0x10000000 -Caption +Parent" gui.hwnd).

GetModuleFileNameExW is not included in winapi because it is in different modules depending on windows version and I had no code to determine whether it is in psapi or kernel32, there are a few of these functions.
Probably I can try to implement that it first tries to load from kernel32 and when it fails from psapi but I am not sure.

Re: The GUI is missing mouse events

Posted: 06 Aug 2017, 22:21
by arcticir
thank you very much.