Alaska Software Inc. - ConfirmBox font
Username: Password:
AuthorTopic: ConfirmBox font
Itai Ben-ArtziConfirmBox font
on Tue, 11 Jan 2022 00:08:00 -0800
Is there a way to set the font for the ConfirmBox? How?
Matej JuracRe: ConfirmBox font
on Tue, 11 Jan 2022 12:43:02 +0100
Afaik no as it is system dialog and  its apperance is controlled by OS.

If different font (I presume bigger font) is needed the only option is 
to write a substitute function.



Itai Ben-Artzi je 11.1.2022 ob 9:08 napisal:
> Is there a way to set the font for the ConfirmBox? How?
Itai Ben-ArtziRe: ConfirmBox font
on Tue, 11 Jan 2022 22:35:55 -0800
Sad but Thanks!
Matej JuracRe: ConfirmBox font
on Wed, 12 Jan 2022 12:43:03 +0100
If you have Donnay's express++ license there is great sample in 
Express\Samples\Static and can be quickly modified for better "ConfirmBox".


Itai Ben-Artzi je 12.1.2022 ob 7:35 napisal:
> Sad but Thanks!
James LoughnerRe: ConfirmBox font
on Tue, 18 Jan 2022 14:30:25 -0500
On 1/12/22 1:35 AM, Itai Ben-Artzi wrote:
> Sad but Thanks!
> 
I wrote my own here is a start


PROCEDURE MPMMSGBOX(cMSG,cTitle,lDesktop)
LOCAL 
oDlg,aMsg:={},I,J,oBut,oMsg,X:=0,Y:=50,H,W,oDummy,DA,xerr,yerr:=1,zerr:="",nWait,nHndl,cStack
    IF EMPTY(lDeskTop)
       lDeskTop := .F.
    ENDIF
    IF cTitle = NIL
       cTitle := ''
    ENDIF
    IF VAL(cTitle) > 0
       nWait := VAL(cTitle)
    ELSE
       nWait := 10
    ENDIF
    IF Valtype(cMSG) = "C"
       AADD(aMsg,"")
       J := 1
       FOR I = 1 TO LEN(cMsg)
          IF cMsg[I] = CHR(13)
             AADD(aMsg,"")
             ++J
             LOOP
          ENDIF
          aMsg[J] += cMsg[I]
       NEXT I
    ELSEIF Valtype(cMSG)= "A"
       aMsg := cMSG
    ELSE
       MPMMsgbox("Program error incorrect value in MPMCONFIRMBOX Call")
       xerr:=Yerr+Zerr   force error
       RETURN
    ENDIF
    IF oMainWindow = AppDeskTop() .OR. lDeskTop .OR. EMPTY(oMainWindow)
       DA := AppDeskTop()
    ELSE
       DA := oMainWindow:DrawingArea
    ENDIF
    oDlg := MSGDialog():New(DA,SetAppWindow())
   oDlg := MSGDialog():New(AppDeskTop(),SetAppWindow())
    oDlg:AlwaysOnTop := .T.
    oDlg:Border := XBPDLG_NO_BORDER
    IF VALTYPE(cTitle) = "C"
       IF cTitle='WAIT' .OR. VAL(cTitle)>0  See ModalLoop below
          oDlg:Title := ''
       ELSE
          oDlg:Title := cTitle
       ENDIF
    ENDIF
    oDlg:Close := {||oDlg:Destroy(),SetAppFocus(SetAppWindow())}
    oDlg:Create()
    IF "ERROR" $ UPPER(oDlg:Title)
       oDlg:DrawingArea:SetColorFG(GRA_CLR_WHITE)
       oDlg:DrawingArea:SetColorBG(GRA_CLR_RED)
    ELSE
       oDlg:DrawingArea:SetColorBG(GRA_CLR_WHITE)
       oDlg:DrawingArea:SetColorFG(GRA_CLR_RED)
    ENDIF
     calc size
    FOR I = LEN(aMsg) TO 1 Step -1
       oMsg := XbpStatic():New(oDlg:DrawingArea,,{10,Y})
       oMsg:AutoSize := .T.
       oMsg:Type := XBPSTATIC_TYPE_TEXT
       oMsg:Options := XBPSTATIC_TEXT_CENTER+XBPSTATIC_TEXT_VCENTER
       oMsg:Caption  := aMsg[I]
       oMsg:Create()
       X := MAX(oMsg:CurrentSize()[1]+10,X) //Added width, TEV 04/07/14
       Y += oMsg:CurrentSize()[2]+3
    NEXT I
    X := MAX(X,250)
    Y := MAX(Y,80)
 
oDlg:SetPosAndSize({(DA:CurrentSize()[1]-X-20)/2,(DA:CurrentSize()[2]-Y-20)/2},{X+20,Y+35})
    oDummy := XbpSLE():New(oDlg:drawingArea,,{-30,-30},{1,1}):Create()
    oBut := 
XbpPushButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]-75)/2,3},{75,25})
    IF VAL(cTitle) = 0
       oBut:Caption := "OK"
       oBut:Activate := {||oDlg:Destroy()}
       oBut:Create()
       oBut:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut)}
    ENDIF
    IF VAL(cTitle) = 0
       oDlg:KEY1 := {xbeK_ALT_O,oBut:Activate}
       SetAppFocus(oBut)
    ENDIF
    IF "ERROR" $ UPPER(oDlg:Title)
       IF FILE("MSGBOXSOUND.WAV")
 
DllCall("WINMM.DLL",DLL_STDCALL,"PlaySoundA","MSGBOXSOUND.WAV",0, 
SND_FILENAME + SND_ASYNC)
       ENDIF
    ELSE
       IF FILE("CONFIRMBOXSOUND.WAV")
 
DllCall("WINMM.DLL",DLL_STDCALL,"PlaySoundA","CONFIRMBOXSOUND.WAV",0, 
SND_FILENAME + SND_ASYNC)
       ENDIF
    ENDIF
    oDlg:DrawingArea:InvalidateRect()
    IF oMainWindow != SetAppWindow()
       oDlg:SetModalState(XBP_DISP_APPMODAL)
    ENDIF
    CLEAR TYPEAHEAD
    IF "SYSTEM" $ Upper(oDlg:Title)
       altd()
       cStack := GetCallStack()
       IF !FILE("MPMERROR.LOG")
          nHndl := FCREATE("MPMERROR.LOG")
       ELSE
          nHndl := FOPEN("MPMERROR.LOG",FO_READWRITE)
          Fseek(nHndl,0,FS_END)   postion to end
       ENDIF
       cStack := CHR(13)+CHR(10)+alltrim(xw32_GetComputerName())
       cStack += CHR(13)+CHR(10)+DTOS(DATE())+ " 
"+Time()+CHR(13)+CHR(10)+cMsg+CHR(13)+CHR(10)+cStack
       FWRITE(nHndl,cStack)
       FCLOSE(nHndl)
    ENDIF
    IF "ERROR" $ UPPER(oDlg:Title) .OR. UPPER(cTitle)="WAIT"  Need 
another way to hold the box open until we get a response
        IF SYS_ERRDELAY
           SLEEP(300)
        ENDIF
        ModalLoop(oDlg)
    ELSE
        ModalLoop(oDlg,nWait)
    ENDIF
   WindowsLoop(oDlg)
    SetAppFocus(SetAppWindow())

RETURN


FUNCTION MPMCONFIRMBOX(oOwner,cMSG,cTitle,nButtons,nStyle,nStartBtn,nTimout)
LOCAL 
oDlg,aMsg:={},I,J,oBut1,oBut2,oBut3,oMsg,X:=0,Y:=40,H,W,XOffset:=0,Icon,nRtn 
:= 0,oFocus,oDummy,DA,xerr,yerr:=1,zerr:=""

    IF oOwner = NIL
       oOwner := SetAppWindow()
    ENDIF
    IF nStartBtn = NIL
       nStartBtn := XBPMB_DEFBUTTON1
    ENDIF
    IF nButtons = NIL
       nButtons := XBPMB_OKCANCEL
    ENDIF
    IF nStyle = NIL
       nStyle := XBPMB_NOICON
    ENDIF
    IF Valtype(cMSG) = "C"
       AADD(aMsg,"")
       J := 1
       FOR I = 1 TO LEN(cMsg)
          IF cMsg[I] = CHR(13)
             AADD(aMsg,"")
             ++J
             LOOP
          ENDIF
          aMsg[J] += cMsg[I]
       NEXT I
    ELSEIF Valtype(cMSG)= "A"
       aMsg := cMSG
    ELSE
       MPMMsgbox("Program error incorrect value in MPMCONFIRMBOX Call")
       xerr:=Yerr+Zerr   force error
       RETURN nRtn
    ENDIF
     icon selection nstyle
    DO CASE
       CASE BAnd(nStyle,XBPMB_QUESTION)!=0
          Icon := XBPSTATIC_SYSICON_ICONQUESTION
          XOffset := 35
       CASE BAnd(nStyle,XBPMB_WARNING)!=0
          Icon := XBPSTATIC_SYSICON_ICONWARNING
          XOffset := 35
       CASE BAnd(nStyle,XBPMB_INFORMATION)!=0
          Icon := XBPSTATIC_SYSICON_ICONINFORMATION
          XOffset := 35
       CASE BAnd(nStyle,XBPMB_CRITICAL)!=0
          Icon := XBPSTATIC_SYSICON_ICONERROR
          XOffset := 35
       OTHERWISE   no icon
          Icon :=NIL
          XOffset := 15
    ENDCASE
    IF oMainWindow = AppDeskTop()
       DA := AppDeskTop()
    ELSE
       DA := oMainWindow:DrawingArea
    ENDIF
    oDlg := MSGDialog():New(DA,oOwner)
   oDlg := MSGDialog():New(AppDeskTop(),oOwner)
    oDlg:AlwaysOnTop := .T.
    oDlg:Border := XBPDLG_NO_BORDER
    IF VALTYPE(cTitle) = "C"
       oDlg:Title := cTitle
    ENDIF
    oDlg:Create()
    oDlg:DrawingArea:SetColorBG(GRA_CLR_WHITE)
    oDlg:DrawingArea:SetColorFG(GRA_CLR_DARKGREEN)
     calc size
    FOR I = LEN(aMsg) TO 1 Step -1
       oMsg := XbpStatic():New(oDlg:DrawingArea,,{10+Xoffset,Y})
       oMsg:AutoSize := .T.
       oMsg:Type := XBPSTATIC_TYPE_TEXT
       oMsg:Options := XBPSTATIC_TEXT_CENTER+XBPSTATIC_TEXT_VCENTER
       oMsg:Caption  := aMsg[I]
       oMsg:Create()
       X := MAX(oMsg:CurrentSize()[1]+10,X) //Added width, TEV 04/01/14
       Y += oMsg:CurrentSize()[2]+3
    NEXT I
    DO CASE
       CASE nButtons = XBPMB_OK
          X := MAX(X,150)
       CASE nButtons = XBPMB_OKCANCEL .OR. nButtons = XBPMB_RETRYCANCEL 
.OR. nButtons = XBPMB_YESNO    two butons
          X := MAX(X,250)
       CASE nButtons = XBPMB_ABORTRETRYIGNORE .OR. nButtons = 
XBPMB_YESNOCANCEL     three butons
          X := MAX(X,300)
       OTHERWISE
          X := MAX(X,250)
          nButtons := XBPMB_OKCANCEL     default
    ENDCASE
    Y := MAX(Y,80)
    IF Icon != NIL
       oStat := XbpStatic():New(oDlg:drawingArea,,{2,(Y+20)/2},{30,30})
       oStat:Type := XBPSTATIC_TYPE_SYSICON
       oStat:Caption := Icon
       oStat:Create()
    ENDIF

 
oDlg:SetPosAndSize({(DA:CurrentSize()[1]-X-20)/2,(DA:CurrentSize()[2]-Y-20)/2},{X+20+XOffset,Y+35})
    oDummy := XbpSLE():New(oDlg:drawingArea,,{-30,-30},{1,1}):Create()
    DO CASE
       CASE nButtons = XBPMB_OK
          oBut1 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]-75)/2,3},{75,25})
          oBut1:Caption := "OK"
          oBut1:Activate := {||nRtn := XBPMB_RET_OK,oDlg:Destroy()}
          oBut1:TabStop  := .T.
          oBut1:Create()
          oBut1:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut1)}
          IF nStartBtn = XBPMB_DEFBUTTON1
             oFocus := oBut1
          ENDIF
          oDlg:KEY1 := {{xbeK_ALT_O,ASC("O"),ASC("o")},oBut1:Activate}

       CASE nButtons = XBPMB_OKCANCEL
          oBut1 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]/3-75/2),3},{75,25})
          oBut1:Caption := "OK"
          oBut1:Activate := {||nRtn := XBPMB_RET_OK,oDlg:Destroy()}
          oBut1:TabStop  := .T.
          oBut1:Create()
          oBut1:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut1)}
          IF nStartBtn = XBPMB_DEFBUTTON1
             oFocus := oBut1
          ENDIF
          oBut2 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]*2/3-75/2),3},{75,25})
          oBut2:Caption := "Cancel"
          oBut2:TabStop  := .T.
          oBut2:Activate := {||nRtn := XBPMB_RET_CANCEL,oDlg:Destroy()}
          oBut2:Create()
          oBut2:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut2)}
          IF nStartBtn = XBPMB_DEFBUTTON2
             oFocus := oBut2
          ENDIF
          oDlg:KEY1 := {{xbeK_ALT_O,ASC("O"),ASC("o")},oBut1:Activate}
          oDlg:KEY2 := {{xbeK_ALT_C,ASC("C"),ASC("c")},oBut2:Activate}
       CASE nButtons = XBPMB_YESNO
          oBut1 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]/3-75/2),3},{75,25})
          oBut1:Caption := "YES"
          oBut1:Activate := {||nRtn := XBPMB_RET_YES,oDlg:Destroy()}
          oBut1:TabStop  := .T.
          oBut1:Create()
          oBut1:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut1)}
          IF nStartBtn = XBPMB_DEFBUTTON1
             oFocus := oBut1
          ENDIF
          oBut2 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]*2/3-75/2),3},{75,25})
          oBut2:Caption := "No"
          oBut2:Activate := {||nRtn := XBPMB_RET_NO,oDlg:Destroy()}
          oBut2:TabStop  := .T.
          oBut2:Create()
          oBut2:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut2)}
          IF nStartBtn = XBPMB_DEFBUTTON2
             oFocus := oBut2
          ENDIF
          oDlg:KEY1 := {{xbeK_ALT_Y,ASC("Y"),ASC("y")},oBut1:Activate}
          oDlg:KEY2 := {{xbeK_ALT_N,ASC("N"),ASC("n")},oBut2:Activate}
       CASE nButtons = XBPMB_RETRYCANCEL
          oBut1 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]*2/3-75/2),3},{75,25})
          oBut1:Caption := "Retry"
          oBut1:Activate := {||nRtn := XBPMB_RET_RETRY,oDlg:Destroy()}
          oBut1:TabStop  := .T.
          oBut1:Create()
          oBut1:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut1)}
          IF nStartBtn = XBPMB_DEFBUTTON1
             oFocus := oBut1
          ENDIF
          oBut2 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]*2/3-75/2),3},{75,25})
          oBut2:Caption := "Cancel"
          oBut2:Activate := {||nRtn := XBPMB_RET_CANCEL,oDlg:Destroy()}
          oBut2:TabStop  := .T.
          oBut2:Create()
          oBut2:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut2)}
          IF nStartBtn = XBPMB_DEFBUTTON2
             oFocus := oBut2
          ENDIF
          oDlg:KEY1 := {{xbeK_ALT_R,ASC("R"),ASC("r")},oBut1:Activate}
          oDlg:KEY2 := {{xbeK_ALT_C,ASC("C"),ASC("c")},oBut2:Activate}
       CASE nButtons = XBPMB_ABORTRETRYIGNORE
          oBut1 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]/4-75/2),3},{75,25})
          oBut1:Caption := "Abort"
          oBut1:Activate := {||nRtn := XBPMB_RET_ABORT,oDlg:Destroy()}
          oBut1:TabStop  := .T.
          oBut1:Create()
          oBut1:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut1)}
          IF nStartBtn = XBPMB_DEFBUTTON1
             oFocus := oBut1
          ENDIF
          oBut2 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]-75)/2,3},{75,25})
          oBut2:Caption := "Retry"
          oBut2:Activate := {||nRtn := XBPMB_RET_RETRY,oDlg:Destroy()}
          oBut2:TabStop  := .T.
          oBut2:Create()
          oBut2:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut2)}
          IF nStartBtn = XBPMB_DEFBUTTON2
             oFocus := oBut2
          ENDIF
          oBut3 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]*3/4-75/2),3},{75,25})
          oBut3:Caption := "Ignore"
          oBut3:Activate := {||nRtn := XBPMB_RET_IGNORE,oDlg:Destroy()}
          oBut3:TabStop  := .T.
          oBut3:Create()
          oBut3:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut3)}
          IF nStartBtn = XBPMB_DEFBUTTON3
             oFocus := oBut3
          ENDIF
          oDlg:KEY1 := {{xbeK_ALT_A,ASC("A"),ASC("a")},oBut1:Activate}
          oDlg:KEY2 := {{xbeK_ALT_R,ASC("R"),ASC("r")},oBut2:Activate}
          oDlg:KEY3 := {{xbeK_ALT_I,ASC("I"),ASC("i")},oBut2:Activate}
       CASE nButtons = XBPMB_YESNOCANCEL
          oBut1 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]/4-75/2),3},{75,25})
          oBut1:Caption := "Yes"
          oBut1:Activate := {||nRtn := XBPMB_RET_YES,oDlg:Destroy()}
          oBut1:TabStop  := .T.
          oBut1:Create()
          oBut1:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut1)}
          IF nStartBtn = XBPMB_DEFBUTTON1
             oFocus := oBut1
          ENDIF
          oBut2 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]-75)/2,3},{75,25})
          oBut2:Caption := "No"
          oBut2:Activate := {||nRtn := XBPMB_RET_NO,oDlg:Destroy()}
          oBut2:TabStop  := .T.
          oBut2:Create()
          oBut2:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut2)}
          IF nStartBtn = XBPMB_DEFBUTTON2
             oFocus := oBut2
          ENDIF
          oBut3 := 
MSGButton():New(oDlg:DrawingArea,,{(oDlg:DrawingArea:CurrentSize()[1]*3/4-75/2),3},{75,25})
          oBut3:Caption := "Cancel"
          oBut3:Activate := {||nRtn := XBPMB_RET_CANCEL,oDlg:Destroy()}
          oBut3:TabStop  := .T.
          oBut3:Create()
          oBut3:KeyBoard := {|nKey,x,o| ButtonMove2(nKey,oBut3)}
          IF nStartBtn = XBPMB_DEFBUTTON3
             oFocus := oBut3
          ENDIF
          oDlg:KEY1 := {{xbeK_ALT_Y,ASC("Y"),ASC("y")},oBut1:Activate}
          oDlg:KEY2 := {{xbeK_ALT_N,ASC("N"),ASC("n")},oBut2:Activate}
          oDlg:KEY3 := {{xbeK_ALT_C,ASC("C"),ASC("c")},oBut3:Activate}
    ENDCASE

    IF oFocus != NIL
       SetAppFocus(oFocus)
    ELSE
       SetAppFocus(oBut)
    ENDIF
   IF oMainWindow != SetAppWindow()
       oDlg:SetModalState(XBP_DISP_APPMODAL)
   ENDIF
    IF FILE("CONFIRMBOXSOUND.WAV")
 
DllCall("WINMM.DLL",DLL_STDCALL,"PlaySoundA","CONFIRMBOXSOUND.WAV",0, 
SND_FILENAME + SND_ASYNC)
    ENDIF
    oDlg:DrawingArea:InvalidateRect()
   PostAppEvent(xbeP_Paint,{0,0,0,0},,oDlg:DrawingArea)
    ModalLoop(oDlg)               //,nTimout)
   WindowsLoop(oDlg)
    SetAppFocus(SetAppWindow())

RETURN nRtn

CLASS MSGDialog FROM XbpDialog   mange keypress for 
MPMMsgbox/confirmbox objects
EXPORTED:
    VAR KEY1,KEY2,KEY3
    INLINE METHOD KeyBoard(nKey)
       DO CASE
          CASE ::KEY1 != NIL .AND. nKey $ ::KEY1[1]
              Eval(::KEY1[2])
          CASE ::KEY2 != NIL .AND. nKey $ ::KEY2[1]
              Eval(::KEY2[2])
          CASE ::KEY3 != NIL .AND. nKey $ ::KEY3[1]
              Eval(::KEY3[2])
          OTHERWISE
              ::XbpDialog:KeyBoard(nKey)
       ENDCASE
    RETURN Self
ENDCLASS

CLASS MSGButton FROM XbpPushButton   mange keypress for 
MPMMsgbox/confirmbox objects
EXPORTED:
    VAR KEY1,KEY2,KEY3
    INLINE METHOD KeyBoard(nKey)
       DO CASE
          CASE ::SetParent():SetParent():KEY1 != NIL .AND. nKey $ 
::SetParent():SetParent():KEY1[1]
              Eval(::SetParent():SetParent():KEY1[2])
          CASE ::SetParent():SetParent():KEY2 != NIL .AND. nKey $ 
::SetParent():SetParent():KEY2[1]
              Eval(::SetParent():SetParent():KEY2[2])
          CASE ::SetParent():SetParent():KEY3 != NIL .AND. nKey $ 
::SetParent():SetParent():KEY3[1]
              Eval(::SetParent():SetParent():KEY3[2])
          OTHERWISE
              ::XbpPushButton:KeyBoard(nKey)
       ENDCASE
    RETURN Self
ENDCLASS

FUNCTION GetCallStack()
    LOCAL n := 0 ,ctext:=""

    DO WHILE ! Empty( ProcName(++n) )
       cText += ProcName(n)             + "(" +LTrim(Str(ProcLine(n))) + 
")" +CHR(13)+CHR(10)
    ENDDO
RETURN cText
Itai Ben-ArtziRe: ConfirmBox font
on Tue, 18 Jan 2022 16:42:35 -0800
Many thanks, James!
Good sample.
Instead of multiple XbpStatic I use a single XbpHTMLWindow for better
styling.

Again, thank you for sharing.