AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

graphic buuton from axc_extracttomem

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
WankaUSR



Joined: 14 Aug 2007
Posts: 86

PostPosted: Wed Oct 07, 2009 5:47 pm    Post subject: graphic buuton from axc_extracttomem Reply with quote

Also posted In Scripts and Functions on http://www.autohotkey.com/forum/viewtopic.php?t=29593&postdays=0&postorder=asc&start=15 but with no reply so if this means double post let me know
I'm trying to use the AddGraphicButton() function to create a button witj an image extracted from an AXC cab but so far with no luck. After searching the forum this is the what I came up with but it doesn't work. Also tried AGB_LoadImage() but doesn't work and the scripts here http://www.autohotkey.com/forum/viewtopic.php?t=26421&postdays=0&postorder=asc&highlight=addgraphicbutton&start=45 but still doesn't create the image required for the AddGraphicButton(). Any ideas?

Code:
; start GDI+ -----------------------------------------------------------------------------
DllCall( "LoadLibrary", Str,"gdiplus" )
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall( "gdiplus\GdiplusStartup", UIntP,pToken, UInt,&si, UInt,0 )
; ----------------------------------------------------------------------------------------   

axc_extracttomem("pack.axc","test.bmp",test)
hBitmap := gdiBitmap( test, 32016, wxh )
AddGraphicButton("btnx", hBitmap, "x116 y107 w280 h130", 20, 90)
Gui, Show, x131 y91 h377 w477, Test
Return

GuiClose:
ExitApp

gdiBitmap( byref buffer, nsize, byref wxh ) {
; Sean : http://www.autohotkey.com/forum/viewtopic.php?p=147029#147029
  hData := DllCall("GlobalAlloc", UInt,2, UInt, nSize )
  pData := DllCall("GlobalLock",  UInt,hData )
  DllCall( "RtlMoveMemory", UInt,pData, UInt,&Buffer, UInt,nSize )
  DllCall( "GlobalUnlock", UInt,hData )
  DllCall( "ole32\CreateStreamOnHGlobal", UInt,hData, Int,True, UIntP,pStream )

  DllCall( "gdiplus\GdipCreateBitmapFromStream", UInt,pStream, UIntP,pBitmap )
  DllCall( "gdiplus\GdipCreateHBITMAPFromBitmap", UInt,pBitmap, UIntP,hBitmap, UInt,8 )
  DllCall("gdiplus\GdipGetImageWidth" , "Uint", pBitmap, "UintP", nW)
  DllCall("gdiplus\GdipGetImageHeight", "Uint", pBitmap, "UintP", nH), wxh := nW "x" nH
  DllCall( "gdiplus\GdipDisposeImage", UInt,pBitmap )
return hbitmap
}

AddGraphicButton(VariableName, ImgPath, Options="", bHeight=32, bWidth=32){
Global
Local ImgType, ImgType1, ImgPath0, ImgPath1, ImgPath2, hwndmode
; BS_BITMAP := 128, IMAGE_BITMAP := 0, BS_ICON := 64, IMAGE_ICON := 1
Static LR_LOADFROMFILE := 16
Static BM_SETIMAGE := 247
Static NULL
SplitPath, ImgPath,,, ImgType1
If ImgPath is float
{
  ImgType1 := (SubStr(ImgPath, 1, 1)  = "0") ? "bmp" : "ico"
  StringSplit, ImgPath, ImgPath,`.
  %VariableName%_img := ImgPath2
  hwndmode := true
}
ImgTYpe := (ImgType1 = "bmp") ? 128 : 64
If (%VariableName%_img != "") AND !(hwndmode)
  DllCall("DeleteObject", "UInt", %VariableName%_img)
If (%VariableName%_hwnd = "")
  Gui, Add, Button,  v%VariableName% hwnd%VariableName%_hwnd +%ImgTYpe% %Options%
ImgType := (ImgType1 = "bmp") ? 0 : 1
If !(hwndmode)
  %VariableName%_img := DllCall("LoadImage", "UInt", NULL, "Str", ImgPath, "UInt", ImgType, "Int", bWidth, "Int", bHeight, "UInt", LR_LOADFROMFILE, "UInt")
DllCall("SendMessage", "UInt", %VariableName%_hwnd, "UInt", BM_SETIMAGE, "UInt", ImgType,  "UInt", %VariableName%_img)
Return %VariableName%_img ; Return the handle to the image
}



axc_unpacktomem(packfile,fil,byref bin) {
  ls:="_llseek",lr:="_lread",lo:="_lopen",lc:="_lclose",u:="uint",i:="int",s:="str"
  lt:="_lcreat",lw:="_lwrite",h:=dllcall(lo,s,packfile,i,0),varsetcapacity(x,4,0)
  varsetcapacity(hdr,16),dllcall(lr,u,h,s,hdr,i,16),fls=numget(hdr,8)
  if (h<1||(numget(hdr)<>0x20437841)||(numget(hdr,4)<>0x3f666666)||fls<1)+(axc:=0)
{ dllcall(lc,u,h)
  return -1
} dllcall(lr,u,h,s,hdr,i,1),z:=asc(hdr),varsetcapacity(crc,z),dllcall(lr,u,h,s,crc,i,z)
  dllcall(ls,u,h,u,-0,i,2),dllcall(ls,u,h,u,-0,i,2),dllcall(ls,u,h,i,0,i,1)
  dllcall(ls,u,h,i,-4,i,2),dllcall(lr,u,h,s,x,i,4),z:=numget(x),dllcall(ls,u,h,i,-z-4,i,2)
  varsetcapacity(csv,z),dllcall(lr,u,h,s,csv,i,z)
  loop,parse,csv,`n
{ if ( subStr(a_loopfield,2,instr(a_loopfield,"""",0,2)-2)=fil)
{ loop,parse,a_loopfield,csv
  f%a_index%:=a_loopfield 
  dllcall(ls,u,h,i,f2,i,0),varsetcapacity(bin,f3),dllcall(lr,u,h,s,bin,i,f3)
  if ((e:=dllcall(&CRC,s,bin,u,f3,i,-1,u,0x04C11DB7,"cdecl uint")+0)<>f4)
{ msgbox,16,Checksum Error!,CRC32 failed on %f1% %e%
  varsetcapacity(bin,0),dllcall(lc,u,h)
  return -3
} dllcall(lc,u,h)
   return f3
}} return -2
} ;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Back to top
View user's profile Send private message Visit poster's website
WankaUSR



Joined: 14 Aug 2007
Posts: 86

PostPosted: Fri Feb 05, 2010 12:13 pm    Post subject: Reply with quote

so no one knows how to do this?
I've been searching for a way to use image from skan's axc cab to graphic buttons but with no luck since the original post! Please help me
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group