DIALOG NEW or Dialog_New

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > UI (User Interface) > DIALOGS > Dialog Creation >

DIALOG NEW or Dialog_New

 

Description

 

Creates a new dialog window.

 

Syntax

 

' Syntax for complete design of dialog from code

[hwnd =] DIALOG NEW [{PIXELS, | UNITS},] [Name sDialogName,] hwParent, Title, xPos, yPos, Width, Height [, [Style] [, [ExtendedStyle] ] ] [TO hwnd]

 

' This syntax is used to load a full dialog with all its controls from a .RC resource file previously referenced via #RESOURCE

' sDialogName name will be searched inside .RC file identifier and if found, dialog will be created with all child controls as well.

' This syntax will also create all objects for each control present into the dialog.

[hwnd =] DIALOG NEW [{PIXELS, | UNITS},] Name sDialogName, hwParent

 

' Alternative syntax with brackets

hwnd = Dialog_New([{PIXELS, | UNITS},] hwParent, Title, xPos, yPos, Width, Height [, [Style] [, [ExtendedStyle]]] )

 

Returns

 

Handle to the created window.

Zero means error.

 

Parameters

 

Name

Type

Optional

Meaning

PIXELS | UNITS


Yes

If the PIXELS is specified, all size and position are specified in pixels.

If UNITS is specified, all size and position are specified in units.

UNITS is the default one if this parameter is not specified.

sDialogName

String

Yes

Optional dialog name string - same name restrictions as for variable names apply.

 
If specified, sDialogName is used to create dialog pseudo-object, which can be used to call various methods and properties, and define events as well.

hwParent

Number

No

Handle of the parent window

Title

String

No

String expression used to set window title.
Title can be UTF-8 string

xPos

Number

No

Upper x position

yPos

Number

No

Upper y position

Width

Number

No

Width of the new window

Height

Number

No

Height of the new window

Style

Number

Yes

An optional bitmask describing how the dialog should be displayed. See Dialog Style equates.

ExtendedStyle

Number

Yes

An optional extended style bitmask describing how the dialog should be displayed. See Dialog ExtendedStyle equates.

hwnd

Variable

No

A numeric single variable name that will receive the handle of the new window.

 

Remarks

 

All size and position parameters passed to functions working with dialogs and controls will be sensible to PIXELS | UNITS option specified when the dialog is creates.

 

Restrictions

 

See also

 

#resource

 

Dialog Pseudo-object Methods and Properties

Dialog Pseudo-object Events

 

Dialog Commands

Dialog Low Level Event Handling

 

Controls

 

Examples

 

' HIGH LEVEL APPROACH, loading dialog from resource file created via thinAir / Tools / User Tools / Resource Editor

 

uses "ui"

 

#resource "frmMain.rc" ' Resource file containing dialog named frmMain and button named btnClose

 

function TBMain()

  

  dialog new units, name frmMain, %HWND_DESKTOP ' Style and controls loaded from RC file,

                                                ' dialog and control have now automatic frmMain and btnClose pseudo-objects

 

  dialog show modal frmMain.Handle              ' Dialog displayed as modal

 

end function

 

' Event handler for OnDestroy event of named dialog

callback function frmMain.OnDestroy()

  msgBox frmMain.Handle"Window is to be destroyed."

end function

 

' Event handler for OnClick event of named button

callback function btnClose.OnClick()

  frmMain.End

end function

 

' LOW LEVEL APPROACH, complete from code, including callback event handling

 

USES "UI"

 

'---Define a button ID

%ButtonClose = 1001

 

Dim hDlg As DWORD

 

DIALOG New 0, "APPTITLE",-1,-1, 330, 203, %WS_POPUP | %WS_VISIBLE | %WS_CLIPCHILDREN | %WS_CAPTION | %WS_SYSMENU %WS_MINIMIZEBOX To hDlg

 

CONTROL ADD BUTTON, hDlg, %ButtonClose, "Click to kill", 90, 50, 150, 100

 

DIALOG SHOW MODAL hDlg Call cbDialog

 

'------------------------------------------------

' Callback function used to handle dialog events

'------------------------------------------------

CALLBACK Function cbDialog() As Long

 

  Select Case CBMSG

    Case %WM_Command

      If CBWPARAM = %ButtonClose Then DIALOG End CBHNDL

 

    Case %WM_DESTROY

      MSGBOX 0, "Window is to be destroyed."

      

  End Select 

 

End Function