ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Dialog Box functions
  • Features of the dialog box
  • Displaying the dialog box
  • Line break in the dialog box
  • Miscellaneous
  • Emulation
  • Background application: Specific to Android 10 and higher
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Displays a message in a standard dialog box that proposes "OK" and "Cancel" and returns the user's choice.
OK / Cancel dialog
Remarks:
  • This is a blocking dialog box. To continue running the application, the user must validate one of the buttons.
    WINDEVAndroidiPhone/iPad To avoid blocking the application, use OKCancelAsynchronous.
  • WINDEV WINDEV allows you to apply the skin template of your project to this dialog box. For more details, see Customizing dialog boxes.
Example
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadJavaUser code (UMC)
// Suppression d'une ligne avec confirmation (oui par défaut)
IF OKCancel("Supprimer cet enregistrement?") THEN
	HDelete(CLIENT)
END
WINDEVReports and QueriesAndroidiPhone/iPadJavaUser code (UMC)
// Choix pour la sortie du programme
IF OKCancel("Voulez-vous quitter le programme?") = Yes THEN
	Close()
END
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadJavaUser code (UMC)
// Demande de confirmation de la suppression du fichier dont 
// le nom est contenu dans la variable NOM_FIC, avec 
// positionnement sur le bouton "Non" de la fenêtre OKAnnuler
IF OKCancel(No, "Supprimer le fichier?") THEN
	fDelete(NOM_FIC)
END
Syntax
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadJavaUser code (UMC)

Displaying an OK/Cancel dialog box Hide the details

<Result> = OKCancel([<Selected button>, ] <Text> [, <Line 2> [... [, <Line N>]]])
<Result>: Boolean
Identifies the button selected by the user:
FalseThe "Cancel" button was chosen by the user.
TrueThe "OK" button was chosen by the user.
<Selected button>: Optional boolean
Button selected by default in the dialog box:
No"Cancel" button selected by default.
True
(by default)
"OK" button selected by default.
<Text>: Character string
Text to display.
<Line 2>: Optional character string
Text displayed in the following lines.
<Line N>: Optional character string
Text displayed in the following lines.
WEBDEV - Browser code

Displaying an OK/Cancel dialog box on the browser Hide the details

OKCancel([<Selected button>, ] <Code for OK> , <Code for cancel> , <Text> [, <Line 2> [... [, <Line N>]]])
<Selected button>: Optional boolean
Button selected by default in the dialog box:
No"Cancel" button selected by default.
True
(by default)
"OK" button selected by default.
<Code for OK>: Character string
Code to run if the OK button is chosen by the Web user. This parameter can correspond to:
  • the name of a button. If the OK button is selected, the click code of this button will be run.
  • the name of a browser function or procedure. If the OK button is selected, this procedure will be run.
  • a string or another value. If the OK button is selected, the value will be run as being a JavaScript code.
<Code for cancel>: Character string
Code to run if the Cancel button is chosen by the Web user. This parameter can correspond to:
  • the name of a button. If the Cancel button is selected, the click code of this button will be run.
  • the name of a browser function or procedure. If the Cancel button is selected, this procedure will be run.
  • a string or another value. If the Cancel button is selected, the value will be run as being a JavaScript code.
<Text>: Character string
Text to display.
<Line 2>: Optional character string
Text displayed in the following lines.
<Line N>: Optional character string
Text displayed in the following lines.
Remarks

Features of the dialog box

  • The title of the dialog box corresponds to the title of the current window (or page).
    AndroidiPhone/iPad To comply with the system specifications, the title of dialog box is empty by default. To define this title, use NextTitle.
  • To modify or define the title of dialog box, use NextTitle.
  • The message is aligned to the left.
  • The captions of buttons depend on the runtime language of Windows.
  • The maximum number of characters cannot exceed 4096. If a larger string is passed as parameter, it will be truncated.
  • The icon displayed (exclamation mark) cannot be modified.
WINDEV To customize this dialog box (and all the system dialog boxes in your application), check "Customize system windows (Info, YesNo, Confirm, Dialog)" in the "Style" tab of the project description. For more details, see Customizing dialog boxes.
WEBDEV - Server code To customize this dialog box (and all the system dialog boxes in your site), check "Apply the skin to the dialog boxes (YesNo and OKCancel)" in the "Skin" tab of the project description window.
WEBDEV - Browser code

Displaying the dialog box

The dialog box does not lock other processes. The dialog box is displayed in the center of the page, with a DDW effect (Dim Disabled Windows).
OKCancel uses the internal page named "WEBDEVOKCancel". To include this page in your project:
  1. Click in the quick access buttons.
  2. The window for creating a new element is displayed: click "Page" then "Page".
  3. Click "Internal page" in the wizard and select the internal page named "OK/Cancel".
  4. Validate. The "WEBDEVOKCancel" page is displayed in the editor.
  5. Save the page by keeping its default name.

Line break in the dialog box

The CR string (Carriage Return) can be used to force a break to the next line. For example:
IF OKCancel("Attention: vous allez supprimer cet enregistrement" + CR + ...
	"Voulez-vous continuer?") THEN
	HDelete(CLIENT)
END
is equivalent to:
IF OKCancel("Attention: vous allez supprimer cet enregistrement", ...
	"Voulez-vous continuer?") THEN
	HDelete(CLIENT)
END
You also have the ability to use the syntax of multiline strings. For example:
OKCancel(
[
Attention: vous allez supprimer cet enregistrement.

Voulez-vous continuer?
])
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadJavaUser code (UMC)

Miscellaneous

  • Timers (TimerSys) are not stopped when this function is called.
  • WINDEV Windows events are not stopped when this function is called.
  • WINDEVJava DelayBeforeClosing limits how long the message is displayed. The dialog box is automatically closed. For question or confirmation dialog boxes, the default button corresponds to the expected answer.
  • The text of the buttons is displayed in the system language.
  • WEBDEV - Server code If your project uses pre-launched sessions, this function must not be used in the project initialization event. This function must be used in the "Initialization in pre-launched session mode" event.
  • iPhone/iPad This function must not be used:
    • in the "Resize" event of the window. Otherwise, the application will be locked.
    • in the "Change the orientation" event of the window.
    • in the "Move to the foreground" event associated with the project.
      Note: The function can also be used in the "Bring to foreground" event of a window..
    • in a thread.
WINDEV

Emulation

To emulate an OKCancel message, use EmulateOKCancel.
Android

Background application: Specific to Android 10 and higher

Starting with Android 10, it is no longer possible to open a window when the application is in the background.
OKCancel can open a window. If this function is used while the application is in the background, a fatal error will occur.
Tips:
  • It is possible to determine if the application is in the background using InBackgroundMode.
  • If an application needs to interact with the user while it is in the background, the solution is to display a notification (via the Notification type). The application will be brought back to the foreground when the notification is clicked, if the ActivateApplication property is set to True. You can also open a window from the procedure passed to the ActionClick property.
Business / UI classification: UI Code
Component: wd300obj.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo OkCancel
Exemplo OkCancel

IF OKCancel("Vamos Gravar") THEN
//Comandos
Info("Comandos")
END

//Blog com Video e exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/07/curso-windev-funcoes-dialogo-2-okcancel.html
https://www.youtube.com/watch?v=ECbkPsdEoIY
De matos AMARILDO
10 Jul. 2016

Last update: 09/24/2024

Send a report | Local help