AlertMsg("Here you go", "Yes;No;Anything", "Title")So, my simple question: when I click on one of the command buttons, why doesn't the form close? It only closes when I click on the X in the upper right hand corner.
* Replacement for MESSAGEBOX? PARAMETERS gcPrompt, gcCaptions, gcTitleCaption, gcPromptFontSize, gcButtonFontSize RELEASE _AlertMsgForm PUBLIC _AlertMsgForm _AlertMsgForm = CREATEOBJECT("TempForm") LOCAL lcPrompt, lnBtn, laCaptions(1) LOCAL lcHeight, lcLeft, lnButtons, lcName, lnI, lcFocus PRIVATE gcReturnValue gcReturnValue = 0 lcPrompt = CHRTRAN(gcPrompt,'|',CHR(13)) lcPrompt = STRTRAN(lcPrompt,CHR(13),CHR(13)+CHR(10)) WITH _AlertMsgForm .WINDOWTYPE = 1 .HEIGHT = 36 .WIDTH = 134 && apparently, the minimum! .CAPTION = "" .NAME = "AlertMsg" .TITLEBAR = 1 .CAPTION = EVL(gcTitleCaption, "FYI") .MINBUTTON = .F. .MAXBUTTON = .F. .FONTSIZE = EVL(gcPromptFontSize, 11) .ADDOBJECT('lblPrompt','Label') WITH .lblPrompt .FONTSIZE = 9 .LEFT = 20 .TOP = 10 .WIDTH = 20 .BACKSTYLE = 0 .CAPTION = lcPrompt .WORDWRAP = .T. .HEIGHT = .PARENT.TEXTHEIGHT(lcPrompt) .WIDTH = .PARENT.TEXTWIDTH(lcPrompt) .FONTSIZE = EVL(gcPromptFontSize, 11) .VISIBLE = .T. ENDWITH lcHeight = .lblPrompt.TOP + .lblPrompt.HEIGHT + 16 lcLeft = 20 lnButtons = ALINES(laCaptions, EVL(gcCaptions, 'OK'), ';') lcFocus = .F. FOR lnI = 1 TO lnButtons lcName = 'Btn'+TRANSFORM(lnI) .ADDOBJECT(lcName, "TempButton") WITH .&lcName lcCaption = laCaptions(lnI) IF '|' # LEFT(lcCaption,1) .CAPTION = '\<'+lcCaption ELSE .CAPTION = '\<'+SUBSTR(lcCaption,2) lcFocus = lcName ENDIF .FONTSIZE = EVL(gcButtonFontSize, 10) .ButtonNumber = lnI .TOP = lcHeight .LEFT = lcLeft .VISIBLE = .T. lcLeft = lcLeft + .WIDTH + 12 ENDWITH ENDFOR .HEIGHT = lcHeight + .Btn1.HEIGHT + 10 .WIDTH = .lblPrompt.WIDTH+40 .WIDTH = MAX(.WIDTH, lcLeft + 8) .lblPrompt.LEFT = (.WIDTH - .lblPrompt.WIDTH)/2 IF NOT EMPTY(lcFocus) .&lcFocus..SETFOCUS ENDIF .AUTOCENTER = .T. .SHOW ENDWITH RETURN gcReturnValue DEFINE CLASS TempForm AS FORM SHOWWINDOW = 1 ENDDEFINE DEFINE CLASS TempButton AS COMMANDBUTTON AUTOSIZE = .T. ButtonNumber = 0 PROCEDURE CLICK gcReturnValue = THIS.ButtonNumber THISFORM.RELEASE ENDPROC ENDDEFINE