WinBatch® Technical Support Forum

Archived Boards => WinBatch Dynamic Dialogs => Topic started by: mcvpjd3 on June 01, 2016, 09:20:40 AM

Title: Multiple lines of text on a Button
Post by: mcvpjd3 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
Title: Re: Multiple lines of text on a Button
Post by: td 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.
Title: Re: Multiple lines of text on a Button
Post by: td 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) Select
#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")
Title: Re: Multiple lines of text on a Button
Post by: kdmoyers on June 01, 2016, 12:38:38 PM
Nice Tony! I actually have an immediate use for that!
-Kirby