BCX_FORM function

Purpose: BCX_FORM creates a window.

Note well: When using BCX_FORM without


 GUI "Classname"

a ClassName must be provided by using


 BCX_CLASSNAME$ = "SomeClassName"

prior to initialization.


 Syntax:

 hWnd = BCX_FORM([Caption$] _
                     [,Xpos%] _
                     [,Ypos%] _
                    [,Width%] _
                   [,Height%] _
                 [,WinStyle%] _
               [,ExWinStyle%])

 Parameters:

  • hWnd The return value is a handle to the new Form if the function succeeds. If the function fails, the return value is NULL.
  • Caption$ [OPTIONAL] Default string to be placed as Title on Form.
  • Xpos% [OPTIONAL] Specifies the initial horizontal position of the Form being created. X% is the x-coordinate of the upper-left corner of the Form being created relative to the upper-left corner of the parent window's client area.
  • Ypos% [OPTIONAL] Specifies the initial vertical position of the Form being created. Y% is the initial y-coordinate of the upper-left corner of the Form being created relative to the upper-left corner of the parent window's client area.
  • Width% [OPTIONAL] Specifies the width, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels , of the Form being created. The default width is 250.
  • Height% [OPTIONAL] Specifies the height, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels , of the Form being created. The default height is 150
  • WinStyle% [OPTIONAL] If the WinStyle% parameter is used, the default Window Style for a BCX_FORM control, WS_MINIMIZEBOX | WS_SIZEBOX | WS_CAPTION | WS_MAXIMIZEBOX | WS_POPUP | WS_SYSMENU, is replaced with the value in WinStyle%. See the CreateWindowEx Function dwStyle parameter in your Win32 SDK or PSDK Reference help for more information about valid Window Styles.
  • ExWinStyle% [OPTIONAL] The default Extended Window Style for a BCX_FORM is 0. See the CreateWindowEx Function dwExStyle parameter in your Win32 SDK or PSDK Reference help for more information about valid Extended Window Styles.

Example 1 :


 Form1 = BCX_FORM()

Example 2 :


 Form1 = BCX_FORM("My Form")

Example 3 :


 Form1 = BCX_FORM("My Form", 0, 0, 310, 250)

Example 4 :


 Form1 = BCX_FORM("My Form", 0, 0, 100, 100, WS_CAPTION | WS_SYSMENU)

Remarks: In Examples 1, 2 and 3 the default style used is


 WS_MINIMIZEBOX | WS_SIZEBOX | WS_CAPTION | WS_MAXIMIZEBOX | WS_POPUP | WS_SYSMENU.

The default window Style for a BCX_FORM control also can be changed by using the MODSTYLE function.

Example 5 : This example shows how to use GUI NOMAIN with BCX_FORM


 BCX_RESOURCE 123 ICON "bcx.ico"
 
 GUI NOMAIN, ICON, 123
 
 DIM FooBloo AS HACCEL
 
 FUNCTION WINMAIN
   GLOBAL Form1 AS HWND
   BCX_SETMETRIC("DialogUnits")
   BCX_REGWND("MAINFORM", form1Proc)
   Form1 = BCX_FORM("BCX_TEMPLATE", 0, 0, 110, 110)
   BCX_SET_FORM_COLOR(Form1,QBCOLOR(31))
   CENTER(Form1)
   SHOW(Form1)
   FUNCTION = BCX_MSGPUMP(FooBloo)
 END FUNCTION
 
 BEGIN EVENTS form1Proc
   SELECT CASE CBMSG
   CASE WM_KEYDOWN
     SELECT CASE wParam
     CASE VK_HOME
       MSGBOX "VK_HOME"
     CASE VK_END
       MSGBOX "VK_END"
     CASE VK_NEXT
       MSGBOX "VK_NEXT"
     CASE VK_PRIOR
       MSGBOX "VK_PRIOR"
     CASE VK_DOWN
       MSGBOX "VK_DOWN"
     CASE VK_UP
       MSGBOX "VK_UP"
     CASE VK_LEFT
       MSGBOX "VK_LEFT"
     CASE VK_RIGHT
       MSGBOX "VK_RIGHT"
     CASE VK_RETURN
       MSGBOX "VK_RETURN"
     END SELECT
   CASE WM_CLOSE
     DestroyWindow(Form1)
   END SELECT
 END EVENTS MAIN
  

Example 6 : This example shows how to set up two forms in SUB FORMLOAD. The trick involves:


 GUI "Two_Forms_Demo"
 
 GLOBAL Form1 AS HWND
 GLOBAL Form2 AS HWND
 
 GLOBAL Form1_Button1 AS HWND
 GLOBAL Form2_Button1 AS HWND
 
 GLOBAL lpForm2_Proc AS WNDPROC
 
 CONST  IDC_FORM1_BUTTON1 = 201
 CONST  IDC_FORM2_BUTTON1 = 202
 
 SUB FormLoad
 
   Form1 = BCX_FORM("Form 1", 0, 0, 160, 100)
   Form1_Button1 = BCX_BUTTON("Show", Form1, IDC_FORM1_BUTTON1, 64, 40, 40, 14)
 
   Form2 = BCX_FORM("Form 2", 0, 0, 200, 140)
   Form2_Button1 = BCX_BUTTON("Hide",Form2, IDC_FORM2_BUTTON1,  80, 70, 40, 14)
 
   lpForm2_Proc = SubclassWindow(Form2, Form2_Proc)
 
   CENTER (Form1)
   SHOW   (Form1)
 END SUB
 
 BEGIN EVENTS
   SELECT CASE CBMSG
 
     '**********************
   CASE WM_COMMAND
     '**********************
     IF CBCTL = IDC_FORM1_BUTTON1 THEN
       CENTER (Form2)
       SHOW (Form2)
     END IF
     EXIT FUNCTION
 
     '**********************
   CASE WM_CLOSE
     '**********************
     DIM RAW id
     id = MSGBOX("Are you sure?","Close Window!",MB_YESNO OR MB_ICONQUESTION)
     IF id THEN PostQuitMessage(0)
     EXIT FUNCTION
 
     '**********************
   CASE WM_DESTROY
     '**********************
     PostQuitMessage(0)
     EXIT FUNCTION
   END SELECT
 END EVENTS
 
 
 CALLBACK FUNCTION Form2_Proc
   SELECT CASE CBMSG
     '**********************
   CASE WM_COMMAND
     '**********************
     IF CBCTL = IDC_FORM2_BUTTON1 THEN HIDE (CBHWND)
     EXIT FUNCTION
 
     '**********************
   CASE WM_CLOSE
     '**********************
     HIDE (CBHWND)   'Don't CLOSE it, HIDE it
     EXIT FUNCTION
 
     '**********************
   CASE WM_DESTROY  'Don't DESTROY it, HIDE it
     '**********************
     HIDE (CBHWND)
   END SELECT
 END FUNCTION

For another example of the BCX_FORM function see Demo.bas in the BCX\Gui_Demo\EZ_Gui folder.