Purebasic timer
SendMessage_(GadgetID(#Message), #EM_SETTARGETDEVICE, 0, 0) ResizeWindow(#MsgBox, boxLeft, boxTop, boxWidth, boxHeight)īuttonLeft2 = buttonLeft + (buttonWidth / 2) + (multiButtonSpace / 2)īuttonLeft - ((buttonWidth / 2) + (multiButtonSpace / 2))īuttonLeft3 = buttonLeft + buttonWidth + multiButtonSpaceīuttonLeft - (buttonWidth + multiButtonSpace)īuttonGadget(#CancelButton, buttonLeft3, buttonTop, buttonWidth, buttonHeight, "Cancel")īuttonGadget(#NoButton, buttonLeft2, buttonTop, buttonWidth, buttonHeight, "No")īuttonGadget(#OKButton, buttonLeft, buttonTop, buttonWidth, buttonHeight, OKYes)ĮditorGadget(#Message, messageLeft, messageTop, txtWidth, txtHeight * msgLines, #PB_Editor_ReadOnly) MsgLines = (boxHeight - (messageTop + messageButtonSpace + buttonHeight + buttonBottomSpace)) / txtHeightīoxTop = (DesktopHeight(0) - boxHeight) / 2īoxLeft = (DesktopWidth(0) - boxWidth) / 2īuttonTop = messageTop + messageButtonSpace + (txtHeight * msgLines)īuttonLeft = (boxWidth - buttonWidth) / 2 If txtWidth DesktopHeight(0) - boxVMarginsīoxHeight = DesktopHeight(0) - boxVMargins If TextWidth(Mid(message, parseStart, parsePos - parseStart)) > (boxWidth - messageHMargins) ParsePos = FindString(message, Space(1), parsePos) MultiButtonWidth = ((buttonWidth * buttons) + (multiButtonSpace * (buttons + 1))) If buttonWidth + messageHMargins => boxWidthMinīuttonWidth = boxWidthMin - messageHMarginsīuttons = 3 #PB_MessageRequester_YesNoCancel
OpenWindow(#MsgBox, 0, 0, boxWidthMin, boxHeight, title, wFlags) WFlags = #PB_Window_ScreenCentered | #PB_Window_TitleBar | #PB_Window_Invisible Protected.i buttons = 1, multiButtonSpace = 15, multiButtonWidth, buttonLeft2, buttonLeft3 Protected.i txtWidth, txtHeight, messageButtonSpace = 15, buttonBottomSpace = 15 Protected.i messageTop = 15, messageLeft = 20, messageHMargins, msgLines = 1 Protected.i buttonTop, buttonLeft, buttonWidth = 80, buttonHeight = 25 Protected.i boxWidthMin = 120, boxWidthMax = 300, boxVMargins = 200 Protected.i boxWidth, boxHeight, boxLeft, boxTop Protected.i wFlags, mbQuit, useEditor, timerInc, response Protected.i parsePos, parseStart, lastSpace, controlledTabOrder = 1 Protected.s OKYes = "OK", defaultButtonTxt, fontName = "Arial", fontSize.i = 8 Procedure.i TimerMsgBox(message.s, title.s = "", mbFlag.i = 0, timeOut.i = 0, defaultButton.i = 1)
it will also display the active timeout countdown in seconds) this button will receive the focus and be the timeout response default button (set with #PB_MessageRequester_Yes /_No /_Cancel auto-close timer (in seconds, not milliseconds) button config (#PB_MessageRequester_Yes /_YesNo /_YesNoCancel) (parameters 2, 3, 4, & 5 are optional, with default values) this message box takes a total of five (05) parameters: within the procedure in the variable definitions section text fonts, sizes & offsets are fully customisable and can be set message box minimum & maximum sizes, button sizes & offsets, and desktop will be displayed in a scrollable read-only EditorGadget extremely long texts that exceed the allowable height of the long message texts will be wrapped and displayed multi-lined
all text & buttons are automatically sized for the message box possible return values: #PB_MessageRequester_Yes /_No /_Cancel TimerMsgBox() is a fully self-contained procedure, ready-to-use MULTI-LINE, MULTI-BUTTON, TIMER-ENABLED, STAY-ON-TOP MESSAGE BOX