Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

WDialog:Create() Method
Create a dialog
------------------------------------------------------------------------------

Syntax
<oWnd>:Create( [ <cnId_aDlg> ] , [ <hDLL> ] )   -->   self

Arguments
<cnId_aDlg> optionally specifies a resource id (numeric or
string) or a dynamic dialog structure (as returned e.g. by the
CreateDialog() / AppendDialog() functions).

<hDLL> optionally specifies the instance handle of a DLL
containing the resources.

Returns
SELF.

Description
This method can be used to create a dialog, whose window
handle is then stored in the hWnd instance variable.  In
practice, this method is not often used directly, as the
Init() methods in most descendant classes call Create()
by default.  However, if you need to do some extra
initialisation, for example, it can be useful to stop the sub-
class Init() calling this method (by specifying <lCreate> as
.F.), carrying out further work, and finally calling Create().

Example
// This shows a single method which can be used with a resource dialog or
// without, in which case it builds it dynamically.
// From SOURCE\OO\ODBCBROW.PRG:
METHOD Init(oParent, cnId_aDlg, lCreate) CLASS BrowseDialog
local     aCols :=                                     ;
{                                                      ;
     {"CourseID",    {|| ::oTable:FieldGet(1) } },     ;
     {"CourseTitle", {|| ::oTable:FieldGet(2) } }      ;
}

default lCreate to .t.

super:Init(oParent, cnId_aDlg, .f., .f.)

// Like this:  ::oTable = WODBC{self}
//        ::oTable:Select("select * from course")
// or in one statement:
::oTable = WODBC{self, "select * from course"}
::oTable:GoTop()

if cnId_aDlg == nil

     INIT DIALOG self                             ;
          Title "Browse In Dialog"  Style ::WndStyle  At 20,20 Size 250,200

     @ Id IDD_BROWSE  Obj ::oB  BListBox                       ;
          Columns aCols                                        ;
          GoBottomBlock {| | ::oTable:GoBottom() }            ;
          GoTopBlock    {| | ::oTable:GoTop() }               ;
          SkipBlock     {|oB, n| DoSkip(oB, ::oTable, n) }     ;
          At 10,10  Size 180,180

     @ Id IDCANCEL    Button    Title "&Cancel" At 200,10 Size 40,12

else
     @ Id IDD_BROWSE  Obj ::oB  BListBox                    ;
          Columns aCols                                     ;
          GoBottomBlock {| | ::oTable:GoBottom() }         ;
          GoTopBlock    {| | ::oTable:GoTop() }            ;
          SkipBlock     {|oB, n| DoSkip(oB, ::oTable, n) }

//   @ Id IDCANCEL    Button       // defaults to this, add it if you like
endif

if lCreate
     ::Create(cnId_aDlg)
endif

return self


See Also: WDialog:Init() CreateDialog() DialogBox()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson