January 28, 2020, 02:51:18 PM

Author Topic: [bb] Buttons with multiple lines of text by Cold Harbour [ 1+ years ago ]  (Read 806 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Buttons with multiple lines of text
Author : Cold Harbour
Posted : 1+ years ago

Description : Allows you to have button text on multiple lines.

Code :
Code: BlitzBasic
  1. ;       .lib "User32.dll"
  2. ;       GetWindowLong% (hwnd%, nIndex%) : "GetWindowLongA"
  3. ;       SetWindowLong% (hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA"
  4.  
  5. Const BM_SETSTYLE       =       244
  6. Const GWL_STYLE         =       -16
  7. Const BS_MULTILINE      =       8192
  8.  
  9. win=CreateWindow ("Win",10,10,600,600,main,15)
  10.  
  11. b1=Createmultibutton("A quite long bit of text to show multlineness",10,10,80,70,win,1)
  12. b2=Createmultibutton("A quite long bit of text to show multlineness",10,100,90,70,win,2)
  13. b3=Createmultibutton("A quite long bit of text to show multlineness",10,200,80,70,win,3)
  14.  
  15. While WaitEvent(10)<>$803
  16. Wend
  17. End
  18.  
  19.  
  20. Function Createmultibutton(name$, x, y, w, h, p,style)
  21.  
  22.         button = CreateButton(name, x, y, w, h, p,style)
  23.  
  24.         hwnd = QueryObject(button, 1)
  25.  
  26.         SetWindowLong (hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) Or BS_MULTILINE)
  27.  
  28.         ;force button redraw kludge
  29.         SetGadgetShape button,GadgetX(button),GadgetY(button),GadgetWidth (button)+1,GadgetHeight (button)
  30.         SetGadgetShape button,GadgetX(button),GadgetY(button),GadgetWidth (button)-1,GadgetHeight (button)
  31.  
  32.         Return button
  33.  
  34. End Function


Comments : none...