Page 1 of 1

About Boxes

Posted: Wed Feb 15, 2017 6:13 pm
by blueb
marcoagpinto posted a picture of a sample of About Boxes that he uses.

http://www.purebasic.fr/english/viewtop ... 50#p502650

I thought it looked like a good idea and thought I might try to do the same. :)

The image used is at: DropBox https://www.dropbox.com/s/cm6hgr774qqpa ... B.png?dl=0

I used a Marquee code sample from Arctic Fox (2006) to make it easy.

Here are the results:

Code: Select all

;==================================================================
;
; Author:    blueb    
; Date:       February  15, 2017
; Explain:  Create a general use 'About Box' that displays the PB compiler version used.       
;==================================================================

;Constants
#AboutBox = 3
#Width = 300
#Height = 200
#MarqFG = $2E2EA8 ; color
#MarqBG = $F0F0F0 ; color

;Declares
Declare MarqueeText(GadgetNumber, x, y, w, h, Text$, Direction = 0, Reverse = 0, TextColor = 0, BackColor = #White, Font$ = "Arial", FontSize = 12)

;Begin
;--------------------------------------------------------------------------

If #PB_Compiler_Processor =  #PB_Processor_x86
     model.s = "  x86 (32 bit)... Note: PB x64 (64 bit) is available. "
ElseIf #PB_Compiler_Processor =  #PB_Processor_x64
     model.s = "  x64 (64 bit)... Note: PB x86 (32 bit) is available. "
EndIf 

ans.s = "Compiled with PureBasic  " + StrD(#PB_Compiler_Version/100, 2)+ model + "@ www.PureBasic.com "

UsePNGImageDecoder()  
If OpenWindow(#AboutBox,0,0,#Width, #Height,"About",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
     
     CanvasGadget(0, 60, 10, 185, 125)
     StartDrawing(CanvasOutput(0))
          Box(0,0,280,220,GetSysColor_(#COLOR_BACKGROUND)) 
          DrawAlphaImage(ImageID(LoadImage(#PB_Any, "DevelopedWithPB.png")), 0, 0)
     StopDrawing()
     MarqueeText(1, 5, 140, 290, 50, ans, 0, 0, #MarqFG,#MarqBG , "Arial Rounded MT Bold", 20) 
EndIf

Repeat 
     Event = WaitWindowEvent() 
Until Event = #PB_Event_CloseWindow 
; -------------------------------------------------------
; End of program

Procedure MarqueeText(GadgetNumber, x, y, w, h, Text$, Direction = 0, Reverse = 0, TextColor = 0, BackColor = #White, Font$ = "Arial", FontSize = 12) 
     ; Arctic Fox  - June 26, 2009 Forum 
     ; ----------------------------------------------
     Protected ret, BgCo$, TxCo$, Dir$, html$ 
     
     ret = WebGadget(GadgetNumber, x, y, w, h, "") 
     HideGadget(GadgetNumber, 1) 
     
     BgCo$ = RSet(Hex(Red(BackColor)), 2, "0") + RSet(Hex(Green(BackColor)), 2, "0") + RSet(Hex(Blue(BackColor)), 2, "0") 
     TxCo$ = RSet(Hex(Red(TextColor)), 2, "0") + RSet(Hex(Green(TextColor)), 2, "0") + RSet(Hex(Blue(TextColor)), 2, "0") 
     
     Select Direction 
          Case 1 
               Dir$ = "right" 
               
          Case 2 
               Dir$ = "up" 
               
          Case 3 
               Dir$ = "down" 
               
          Default 
               Dir$ = "left" 
     EndSelect 
     
     html$ = "<html><head>" + #CRLF$ 
     html$ + "<style type=" + #DQUOTE$ + "text/css" + #DQUOTE$ + ">" + #CRLF$ 
     html$ + "body {background-color: #" + BgCo$ + ";}" + #CRLF$ 
     html$ + "body,td,th {" + #CRLF$ 
     html$ + "font-family: " + Font$ + ";" + #CRLF$ 
     html$ + "font-size: " + Str(FontSize) + "px;" + #CRLF$ 
     html$ + "color:#" + TxCo$ + ";" + #CRLF$ 
     html$ + "}" + #CRLF$ 
     html$ + "</style></head>" + #CRLF$ 
     html$ + "<body scroll=" + #DQUOTE$ + "no" + #DQUOTE$ + " style=" + #DQUOTE$ + "vertical-align:text-top" + #DQUOTE$ + ">" 
     html$ + "<marquee direction=" + #DQUOTE$ + Dir$ + #DQUOTE$ 
     If Reverse : html$ + " behavior=" + #DQUOTE$ + "alternate" + #DQUOTE$ : EndIf 
     html$ + ">" + Text$ + "</marquee></body></html>" 
     
     SetGadgetItemText(GadgetNumber, #PB_Web_HtmlCode, html$) 
     While WindowEvent() : Wend 
     
     SetGadgetAttribute(GadgetNumber, #PB_Web_ScrollY, 0.7 * h) 
     DisableGadget(GadgetNumber, 1) 
     HideGadget(GadgetNumber, 0) 
     ProcedureReturn ret 
EndProcedure