Page 1 of 1

Commandlinks (Windows Vista and above)

Posted: Wed Sep 15, 2021 3:43 am
by jacdelad
Make a button a command link:

Code: Select all

#BS_COMMANDLINK = $E
#BCM_SETNOTE = $1609
OpenWindow(0, 100, 100, 150, 60, "Commandlink-Demo")
ButtonGadget(0, 10, 10, 125, 40, "Commandlink",#BS_COMMANDLINK)
SendMessage_(GadgetID(0),#BCM_SETNOTE,0,"Subline(s)")
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
Behaves like a normal button.

Additionally the image can be changed with:

Code: Select all

SendMessage_(GadgetID(0),#BM_SETIMAGE,#IMAGE_ICON,ImageID(LoadImage(#PB_Any,my_icon_with_path)))
Use #IMAGE_CURSOR or #IMAGE_BITMAP for cursors/bitmaps.

Re: Commandlinks (Windows Vista and above)

Posted: Wed Sep 15, 2021 8:39 am
by BarryG
Thanks for this. I'm trying to use a PNG icon (encoded to BMP) but it doesn't work. Any ideas?

Code: Select all

UsePNGImageDecoder()
i=LoadImage(#PB_Any,"Path\To\Icon.png")
i2=EncodeImage(i)
#BS_COMMANDLINK = $E
#BCM_SETNOTE = $1609
OpenWindow(0, 100, 100, 250, 100, "Commandlink-Demo")
ButtonGadget(0, 10, 10, 225, 60, "Commandlink",#BS_COMMANDLINK)
SendMessage_(GadgetID(0),#BCM_SETNOTE,0,"Subline(s)")
SendMessage_(GadgetID(0),#BM_SETIMAGE,#IMAGE_ICON,i2)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver

Re: Commandlinks (Windows Vista and above)

Posted: Wed Sep 15, 2021 10:54 am
by Axolotl
Hi BarryG,

you have to change the #IMAGE_ICON to #IMAGE_BITMAP

Code: Select all

;SendMessage_(GadgetID(0), #BM_SETIMAGE, #IMAGE_ICON, ImageID(0)) 
SendMessage_(GadgetID(0), #BM_SETIMAGE, #IMAGE_BITMAP, ImageID(0)) 


and this is an running example (with a self made image!) ... I changed the window size to see the entire stuff!

Code: Select all


#BS_COMMANDLINK = $E
#BCM_SETNOTE = $1609

Procedure MakeTestImage(ImgID) 
  Protected k 

  If CreateImage(ImgID, 32, 32)
    If StartDrawing(ImageOutput(ImgID))
      DrawingMode(#PB_2DDrawing_Transparent)
      Box(2,2,28,28, #Green) 
      Circle(4, 4,10, #Blue) 
      StopDrawing()
    EndIf
  EndIf 
  ProcedureReturn ImageID(ImgID) 
EndProcedure 

MakeTestImage(0) 

OpenWindow(0, 100, 100, 250, 160, "Commandlink-Demo")
ButtonGadget(0, 10, 10, 225, 140, "Commandlink", #BS_COMMANDLINK) 
SendMessage_(GadgetID(0), #BCM_SETNOTE, 0, "Subline(s)") 

;SendMessage_(GadgetID(0), #BM_SETIMAGE, #IMAGE_ICON, ImageID(0)) 
SendMessage_(GadgetID(0), #BM_SETIMAGE, #IMAGE_BITMAP, ImageID(0)) 

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget                          :Debug "EventGadget: " + EventGadget()  
  EndSelect
ForEver 

Re: Commandlinks (Windows Vista and above)

Posted: Sun Sep 19, 2021 7:40 pm
by Kwai chang caine
Not works without "visual themes XP" else works good with it actived
Thanks for sharing 8)

Re: Commandlinks (Windows Vista and above)

Posted: Mon Sep 20, 2021 4:52 pm
by jacdelad
Yes, yes, you need the themes. I forgot to mention it.