Author Topic: Multiple lines of text on a Button  (Read 1067 times)

mcvpjd3

  • Newbie
  • *
  • Posts: 41
Multiple lines of text on a Button
« on: June 01, 2016, 09:20:40 am »
Can you put multiple lines of text on a pushbutton in a dialog? If so, how?

Thanks

td

  • Tech Support
  • *****
  • Posts: 2114
    • WinBatch
Re: Multiple lines of text on a Button
« Reply #1 on: June 01, 2016, 09:58:48 am »
It is not directly supported.  One way to accomplish it, however,  is to create a bitmap image with your text and display that in a PICTUREBUTTON.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


td

  • Tech Support
  • *****
  • Posts: 2114
    • WinBatch
Re: Multiple lines of text on a Button
« Reply #2 on: June 01, 2016, 12:14:22 pm »
Another approach would be to give a button the multiline button style in the initialization section of the a dialog callback:

Code: Winbatch
 #DefineSubroutine MLButtonProc(MLButton_Handle,MLButton_Event,MLButton_Name,MLButton_EventInfo,MLButton_ChangeInfo)
   switch MLButton_Event                                    ; Switch based on Dialog Message type
      case @deInit  ; Standard Initialization message
         BS_MULTILINE = 8192
         BS_CHECKBOX = 2

         hControl = DialogControlGet(MLButton_Handle, "PushButton_OK",  @dchWnd)
         hUser32 = DllLoad("User32.dll")
         CtrlStyle = DllCall(hUser32, long:"GetWindowLongW", long:hControl, long:-16)
         DllCall(hUser32, long:"SetWindowLongW", long:hControl, long:-16, long:(CtrlStyle&(~BS_CHECKBOX))^BS_MULTILINE)
         DllFree(hUser32)
         DialogControlSet(MLButton_Handle, "PushButton_OK", @dcTitle, "Line one":@CRLF:"Line Two")
         return(@retDefault)
   endswitch                                              
   return(@retDefault)
#EndSubroutine                                              ; End of Dialog Callback MLButtonCallbackProc

MLButtonFormat=`WWWDLGED,6.2`

MLButtonCaption=`Multiline Button Example`
MLButtonX=081
MLButtonY=099
MLButtonWidth=408
MLButtonHeight=166
MLButtonNumControls=002
MLButtonProcedure=`MLButtonProc`
MLButtonFont=`DEFAULT`
MLButtonTextColor=`DEFAULT`
MLButtonBackground=`DEFAULT,DEFAULT`
MLButtonConfig=0

MLButton001=`111,111,068,048,CHECKBOX,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
MLButton002=`261,147,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MLButton")
 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


kdmoyers

  • Full Member
  • ***
  • Posts: 179
Re: Multiple lines of text on a Button
« Reply #3 on: June 01, 2016, 12:38:38 pm »
Nice Tony! I actually have an immediate use for that!
-Kirby
The mind is everything; What you think, you become.