AutoHotkey Community

It is currently May 27th, 2012, 4:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 111 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next
Author Message
 Post subject:
PostPosted: September 10th, 2005, 2:24 pm 
Convecerning Grapic Buttons I've found s.th about a toolbar control at MSDN. Maybe it's of any help.

http://msdn.microsoft.com/library/defau ... _using.asp


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2006, 2:11 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
thank you for the script corrupt
here just defined which button was clicked:
Code:
Gui, Add, Button, h30 w140 gMyButton1 vB1 +%BS_BITMAP%
Gui, Add, Button, h30 w40 gMyButton2 vI1 +%BS_ICON%
Gui, Add, Button, h30 w60 gMyButton3 vB2 +%BS_BITMAP%
....

MyButton1:
MsgBox, Graphic button1 clicked :)
return
MyButton2:
MsgBox, Graphic button2 clicked :)
return
MyButton3:
MsgBox, Graphic button3 clicked :)
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2006, 7:26 am 
Offline

Joined: December 7th, 2005, 8:29 am
Posts: 345
Hi,

thanks for the script :)

is there a way to add text and graphic to the button?

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2006, 6:39 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
At the moment... the easiest way would be to create a custom bitmap with the desired text.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2006, 10:14 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
easy example, create a record button , save with irfanview
Code:
;part 1  save this as record.bmp (AltGr/ print screen, save with irfanview)
#NoTrayIcon
;C=000000 ;black
;C=008000 ;green
;C=C0C0C0 ;silver
;C=00FF00 ;lime
;C=808080 ;grey
;C=808000 ;olive
;C=FFFFFF ;white
;C=FFFF00 ;yellow
;C=800000 ;maroon
;C=000080 ;navy
C=FF0000 ;red
;C=0000FF ;blue
;C=800080 ;purple
;C=008080 ;teal
;C=FF00FF ;fuchsia
;C=00FFFF ;aqua
Gui,-Border
Gui,Color,%C%
Gui,Font, S16 Cdefault bold,Lucida Console
Gui,Add,TEXT,cWHITE   x10  y10 ,RECORD
Gui,Show,x0 y0 w110 h40,COLOR TEST
return
esc::exitapp
Code:
;Example, click 2 Picture-Buttons
Gui, Add, Picture, gEx1 x10  y10 w80 h30,record.bmp
Gui, Add, Picture, gEx2 x220 y10 w180 h130,C:\test2.jpg
Gui, Show, x255 y146 h200 w477,TEST
Return

Ex1:
MsgBox,Clicked record
return

Ex2:
MsgBox,Clicked Picture2
return

GuiClose:
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 19th, 2006, 10:32 pm 
Ok so this script was awesome, my only question is how/what would someone need to change to make it so you could get the images from a Icon Library file such as an ICL or a DLL???

My concern is that by the time I am finished with my niffty little script I will have roughly around 20 image-buttons (using .ico files btw) and I don't want to have them all just randomly placed in a subfolder within my script's directory. It just seems much more "professional" to have fewer needed items, and it would make the files a little more secure in terms of someone messing with the images.

If someone can help me out with this soon it would greatly be appreciated. Thanks in advance

- Steven Michael


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2006, 10:48 am 
Offline

Joined: August 8th, 2006, 3:55 pm
Posts: 49
@garry: Your example, Tue Apr 04, 2006 10:14 pm, was very helpful for me, thank you very much.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2006, 10:46 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear robiandi, :)

You wrote:
@garry: Your example, Tue Apr 04, 2006 10:14 pm, was very helpful for me, thank you very much.


Actually the date and time will differ for people accessing this forum from different timezones.

Please refer the snapshot:
Image

You may right-click & copy the shortcut of that post (red arrow pointing to a tiny icon)
and paste it instead - like this:
http://www.autohotkey.com/forum/viewtop ... 5555#55555

Just a suggestion.

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2006, 11:38 am 
Offline

Joined: August 8th, 2006, 3:55 pm
Posts: 49
Dear Goyyah, many thanks for the information.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 5th, 2006, 9:27 pm 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
I know this is a very old post but the content is very important so I thought I would give it a bump so that it won't go unnoticed! :!:

Clear throat. Cough twice...

OK, I'll break. My motivation is a bit more selfish...

I noticed that buttons created using this technique appear to be using the Window Classic style (at least for me). Here's what it looks like on my computer. The 2nd and 3rd buttons are the best examples.

Image

Is there any way to get the program to use the default button style?

Thanks in advance for your feedback.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 5th, 2006, 11:20 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Probably not. Themed buttons are drawn using bitmaps, I suppose they don't merge well with graphic buttons. Classic buttons are drawn with brushes (or pens), they are actually just a border. So they mix well with other graphics.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2006, 12:09 am 
Maybe you can workaround the problem with one of Goyyahs Tricks. ;)
http://www.autohotkey.com/forum/viewtop ... 9899#59899

Don't know if it's of any help.
______________________
Cheers
AGU


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2006, 4:26 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
AGU wrote:
Maybe you can workaround the problem with one of Goyyahs Tricks. ;)
http://www.autohotkey.com/forum/viewtop ... 9899#59899

Don't know if it's of any help.

Not a perfect solution but it might work out until graphical buttons are a built-in feature. Hint. Hint. :wink: I'll give it a try. Thanks.

Them be my thoughts....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2007, 8:53 am 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
example for color buttons
save a small color part (from second script) with IrfanView to red.bmp/green.bmp
or just add a picture=
Code:
Gui, Add, Picture, x10 y10 w220 h150,%A_ScriptDir%\haarlem.jpg


Code:
;------- COLOR BUTTONS -------------------------------------
Gui,1: +AlwaysOnTop
Gui,1:Font,S12,FixedSys
;-----------------------------------------------------------
Gui,1:Add,Picture,x0 y1  h20 w100 gCALC,red.bmp
Gui,1:Add,text,cWhite BackgroundTrans x25 y3 h20 gCALC,CALC1

Gui,1:Add,Picture,x120 y1  h20 w100 gSNDVOL,green.bmp
Gui,1:Add,text,cWhite BackgroundTrans x145 y3 h20,VOLUME
;-----------------------------------------------------------
Gui,1:Show,x1 y0 h30 w230 ,COLOR BUTTONS
return

CALC:
run,calc.exe
return

SNDVOL:
run,sndvol32
return

GuiClose:
ExitApp

show colors=
Code:
;-- part 1  --- SAVE COLOR with IRFANVIEW red.bmp -------------------
;ctrl+printscreen,Irfanview,ctrl+V,mark,cut=CTRL+Y,save as=red.bmp
#NoTrayIcon
;---------------------------------------
C1=000000 ;black
C2=008000 ;green
C3=C0C0C0 ;silver
C4=00FF00 ;lime
C5=808080 ;grey
C6=808000 ;olive
C7=FFFFFF ;white
C8=FFFF00 ;yellow
C9=800000 ;maroon
C10=000080 ;navy
C11=FF0000 ;red
C12=0000FF ;blue
C13=800080 ;purple
C14=008080 ;teal
C15=FF00FF ;fuchsia
C16=00FFFF ;aqua
;C=A2A25E
;C=3C1B17
;C=C8D0D4 ;grey2
;C=D2DBDF ;grey3
;---------------------------------------
;Gui,Font, S7 Cdefault ,Lucida Console
;Gui,Add,TEXT,cWHITE   x10  y10 ,RECORD
;----------------------------------------
Gui,1:-Border
Gui,1:Color,%C1%
Gui,1:Add,TEXT,cWHITE  x2  y2 ,BLACK
Gui,1:Show,x0 y0 w50 h50,

Gui,2:-Border
Gui,2:Color,%C2%
Gui,2:Add,TEXT,cWHITE  x2  y2 ,GREEN
Gui,2:Show,x0 y50 w50 h50,

Gui,3:-Border
Gui,3:Color,%C3%
Gui,3:Add,TEXT,cBLACK  x2  y2 ,SILVER
Gui,3:Show,x0 y100 w50 h50,

Gui,4:-Border
Gui,4:Color,%C4%
Gui,4:Add,TEXT,cWHITE  x2  y2 ,LIME
Gui,4:Show,x0 y150 w50 h50,

Gui,5:-Border
Gui,5:Color,%C5%
Gui,5:Add,TEXT,cBLACK  x2  y2 ,GREY
Gui,5:Show,x0 y200 w50 h50,

Gui,6:-Border
Gui,6:Color,%C6%
Gui,6:Add,TEXT,cWHITE  x2  y2 ,OLIVE
Gui,6:Show,x0 y250 w50 h50,

Gui,7:-Border
Gui,7:Color,%C7%
Gui,7:Add,TEXT,cBLACK  x2  y2 ,WHITE
Gui,7:Show,x0 y300 w50 h50,

Gui,8:-Border
Gui,8:Color,%C8%
Gui,8:Add,TEXT,cBLACK  x2  y2 ,YELLOW
Gui,8:Show,x0 y350 w50 h50,

Gui,9:-Border
Gui,9:Color,%C9%
Gui,9:Add,TEXT,cWHITE  x2  y2 ,MAROON
Gui,9:Show,x0 y400 w50 h50,

Gui,10:-Border
Gui,10:Color,%C10%
Gui,10:Add,TEXT,cWHITE  x2  y2 ,NAVY
Gui,10:Show,x0 y450 w50 h50,
;---------------------------

Gui,11:-Border
Gui,11:Color,%C11%
Gui,11:Add,TEXT,cWHITE  x2  y2 ,RED
Gui,11:Show,x50 y0 w50 h50,

Gui,12:-Border
Gui,12:Color,%C12%
Gui,12:Add,TEXT,cWHITE  x2  y2 ,BLUE
Gui,12:Show,x50 y50 w50 h50,

Gui,13:-Border
Gui,13:Color,%C13%
Gui,13:Add,TEXT,cWHITE  x2  y2 ,PURPLE
Gui,13:Show,x50 y100 w50 h50,

Gui,14:-Border
Gui,14:Color,%C14%
Gui,14:Add,TEXT,cWHITE  x2  y2 ,TEAL
Gui,14:Show,x50 y150 w50 h50,

Gui,15:-Border
Gui,15:Color,%C15%
Gui,15:Add,TEXT,cWHITE  x2  y2 ,FUCHSIA
Gui,15:Show,x50 y200 w50 h50,

Gui,16:-Border
Gui,16:Color,%C16%
Gui,16:Add,TEXT,cBlack  x2  y2 ,AQUA
Gui,16:Show,x50 y250 w50 h50,
return

esc::exitapp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2007, 10:55 pm 
Offline

Joined: October 5th, 2004, 5:03 pm
Posts: 121
Location: Brasília, Brazil
corrupt,

I've wrote a simplier function to include an GraphicButton automaticaly.


Code:
#SingleInstance force
   
;PROGRAM TITLE
   ProgramTitle = Gui_Add_GraphicButton_Function

;GUI SHOW + HIDE
   Gui, Show, w650 h200 +Hide, %ProgramTitle%

   
;SET BUTTONS
loop 15
   GuiAddGraphicButton("h30 w30 xp+30 GMyButton", "D:\_kirk\img_kirk\icone_vazio.bmp", ProgramTitle)

;GUI SHOW AGAIN
   Gui, Show, , %ProgramTitle%
   Return

   
MyButton:
MsgBox, Graphic button clicked :)
return


GuiClose:
ExitApp
Return


GuiAddGraphicButton(GuiAddButtonOptions, ImgPath, WindowTitle, ImgHeight=26, ImgWidth=26) {
   { ;DETAILS
      ; HWND = window handle
      ; CtrlInstance = Button Number (same as the # in ClassNN in Window Spy)
      ; ImgPath = Path to the image to be displayed
      ; ImgType = Either BS_BITMAP (default) or BS_ICON are supported (0 or 1)
      ; ImgHeight = Image height (default = 32)
      ; ImgWidth = Image width (default = 32)
   }
   { ; GLOBALS AND BUTTON
         DetectHiddenWindows, On
         HWND := WinExist(WindowTitle)
         BS_BITMAP := 128
         IMAGE_BITMAP := 0
         BS_ICON := 64
         IMAGE_ICON := 1
   }
   { ;CHOOSE .ICO OU .BMP
      If ImgPath contains .ico
         {
         bs_chosen = %BS_ICON%
         ImgType=1
         }
      Else If ImgPath contains .bmp
      {
         bs_chosen = %BS_BITMAP%
         ImgType = 0
      }
      Gui, Add, Button, %GuiAddButtonOptions% +%bs_chosen%
   }
   { ;SEARCH LAST BUTTON
      WinGet, ControlList, ControlList, %WindowTitle%
     StringSplit, qt, ControlList, `n
      ;MsgBox %qt0%`n%ControlList%
     ;CtrlInstance = %qt0%
      Loop, parse, ControlList, `n
      {
         If A_LoopField not contains Button
            Continue
         StringReplace, butt, A_LoopField, Button, , all
         ac_buttons = %ac_buttons%|%butt%
         ;MsgBox %A_LoopField%
      }
      StringTrimLeft, ac_buttons, ac_buttons, 1
      Sort, ac_buttons, D| R N
      Loop, parse, ac_buttons, |
      {
         last_button = %A_LoopField%
         Break
      }
      ;MsgBox %last_button%
      CtrlInstance = %last_button%
   }
   { ;DLL CALL
   ; Set Constants
      NULL=
      LR_LOADFROMFILE := 16
      BM_SETIMAGE := 247

   ; Find the handle to the Button based on the windle handle and button number
     ;msgbox %CtrlInstance%
      Loop, %CtrlInstance%
      {
        CtrlHandle := DllCall("FindWindowExA", "Uint", HWND, "Uint", CtrlHandle, "str", "Button", "str", NULL, "Uint")
        If CtrlHandle = 0
          Return
      }

   ; Load the image from the file and retrieve the image handle
      ImgHwnd%CtrlInstance% := DllCall("LoadImage", "UInt", NULL, "Str", ImgPath, "UInt", ImgType, "Int", ImgWidth, "Int", ImgHeight, "UInt", LR_LOADFROMFILE, "UInt")

   ; Assign the image to the button
      DllCall("SendMessage", "UInt", CtrlHandle, "UInt", BM_SETIMAGE, "UInt", ImgType,  "UInt", ImgHwnd%CtrlInstance%)

   ; Return the handle to the image
      retImg := ImgHwnd%CtrlInstance%
   }
   Return, %retImg%
}



The problem is that it does not work when a prior button or radio is included before this functions...


By the way, if the button inserted before the function has no text, the function will work properly.

Corrupt, do you know why it happens?

Thanks,
Lingoist


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 111 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 25 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group