can u explain me the code for including bitmaps.. line by the line comments help me understand.. i would love some...
and please instruct how to include... more bitmaps... any helpful links to dllcall, hmodule, getmodulehandle stuff?
hModule := DllCall( "GetModuleHandle", Str, A_ScriptFullPath ) ; what does this do :oops: A_ScriptFullpath
is the executing file and is already loaded in memory. We need a handle to it so that we can refer the resources stored in it.
In case we need to refer a Bitmap stored in a Dll, we can get a handle to it with a DllCall to LoadLibrary. ( example will follow )
hBitmap1 := DllCall( "LoadImageA", UInt,hModule, UInt,007, UInt,(IMAGE_BITMAP:=0x0), Int,250, Int,250, UInt, (LR_SHARED := 0x8000) ) ; same again and image dimensions have to be hardcoded ??
If you specify 0 & 0 for X & Y, the original size would be loaded. Most of the time the user would be knowing the dimensions already unless he is writing a Resource Hacker
in AHK ( which is possible! )
Gui, Add,Text, x0 y0 w0 h0 hwndPic1 +0xE ; text or image?? why hwndPic1 ? which style number is this?
Text and Picture both are Static controls except a AHK picture control has the SS_Bitmap ( 0xE )
style. If we wanted to call a picture control we have to specify the picture file name as the third parameter or else the STM_SETIMAGE would not work. Therefore you either provide a dummy picture file as the third parameter or use SS_Bitmap
in options of the picture control. I chose to use Text control with SS_Bitmap so that it is prominent enough to be noticed by the users. ( This means you may choose to add an empty picture control with SS_Bitmap in options. )
SendMessage, (STM_SETIMAGE:=0x172), (IMAGE_BITMAP:=0x0), hBitmap1,, ahk_id %Pic1% ; mumbo jumbo.. :oops:??
Every standard windows control can be controlled with SendMessages and this is one example.
From AHK when you call something like GuiControl,, MyPic, C:\MyPic.BMP
to change the contents of a picture control, AHK will be internally using such messages to achieve the task.
These are the message that can be used on a Static Control
.. and here is an example code that calls a bitmap resource from Shell32.dll
:arrow: No need to compile it :
Gui, -Caption +AlwaysOnTop +Border +ToolWindow
Gui, Margin, 0, 0
Gui, Add, Picture, x0 y0 w0 h0 +0xE vMyPic1 hWndPic1 ; +0xE is SS_BITMAP
hModule := DllCall( "LoadLibrary", Str,"Shell32.dll" )
hBitmap1 := DllCall( "LoadImageA", UInt,hModule, UInt,14351, UInt,(IMAGE_BITMAP:=0x0)
, Int,0, Int,0, UInt, (LR_SHARED := 0x8000) )
SendMessage, (STM_SETIMAGE:=0x172), (IMAGE_BITMAP:=0x0), hBitmap1,, ahk_id %Pic1%
GuiControlGet, MyPic1, Pos
Gui, Show, w%MyPic1W% h%MyPic1H%
Shell32.dll loads into the memory when Windows boots-up and yet I call LoadLibrary()
only for the sake of a module handle.
I have not hardcoded the dimensions but have to ascertain the picture control's size to fit the GUI.