BCX_WND function

Purpose: BCX_WND creates a window and, as well, automatically creates and registers a new class using the ProcedureName parameter.


 Syntax:

  hWnd = BCX_WND(ClassName$, _
              ProcedureName, _
                   Caption$  _
                 [, hParent] _
                   [, Xpos%] _
                   [, Ypos%] _
                  [, Width%] _ 
                 [, Height%] _ 
               [, WinStyle%] _
             [, ExWinStyle%] _
                     [, nID)
 

 Parameters:

  • hWnd The return value is a handle to a new window if the function succeeds. If the function fails, the return value is NULL.
  • "ClassName" A unique string literal name for the program. Every Windows MDIGUI program requires a ClassName. Windows uses the ClassName to distinguish one running program from another.
  • ProcedureName specifies a WNDPROC name for this instance of a windows procedure. This name is used both for the WNDPROC structure of the window and for the BEGIN EVENTS loop.
  • Caption$ [OPTIONAL] to be placed as title on the window.
  • hParent [OPTIONAL] specifies the handle to the parent window.
  • Xpos% [OPTIONAL] specifies, in screen coordinates, the initial horizontal x-coordinate of the upper-left corner of the window being created. The default argument for this parameter is CW_USEDEFAULT. See the CreateWindowEx Function x parameter description in your Win32 SDK or PSDK Reference help for more information.
  • Ypos% [OPTIONAL] specifies, in screen coordinates, the initial vertical y-coordinate of the upper-left corner of the window being created. The default argument for this parameter is CW_USEDEFAULT. See the CreateWindowEx Function y parameter description in your Win32 SDK or PSDK Reference help for more information.
  • Width% [OPTIONAL] specifies, in PIXELS, the width of the window being created. The default argument for this parameter is CW_USEDEFAULT. See the CreateWindowEx Function nWidth parameter description in your Win32 SDK or PSDK Reference help for more information.
  • Height% [OPTIONAL] specifies, in PIXELS, the height of the window being created. The default argument for this parameter is CW_USEDEFAULT. See the CreateWindowEx Function nHeight parameter description in your Win32 SDK or PSDK Reference help for more information.
  • WinStyle% [OPTIONAL] If the WinStyle% parameter is used, the default Window Style for a BCX_WND control, WS_OVERLAPPEDWINDOW, is replaced with the value in WinStyle%. See the CreateWindowEx Function dwStyle parameter description 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_WND is 0. See the CreateWindowEx Function dwExStyle parameter description in your Win32 SDK or PSDK Reference help for more information about valid Extended Window Styles.
  • nID specifies the handle(HMENU) of the menu to be used with the window; nID can be NULL if the window uses the class menu.

Remarks : Using BCX_Wnd sets pixels on as default.

Example :


 GUI NOMAIN
 
 FUNCTION WINMAIN()
   LOCAL Form1
   Form1 = BCX_WND("MAINFORM", Form1Proc, "GUI NOMAIN TEST")
   SHOW(Form1)
   FUNCTION = BCX_MSGPUMP()
 END FUNCTION
 
 BEGIN EVENTS Form1Proc
 END EVENTS MAIN
 

SHOWMODAL ... ENDMODAL macro statements

Purpose: The SHOWMODAL ... ENDMODAL macros are used together to make modal a BCX_WND window. The SHOWMODAL ... ENDMODAL macros can be used only with a BCX_WND window which has another window as its parent. These macros are used in place of SHOW and cause the parent window to be disabled when the BCX_WND child form is opened and to be enabled when the BCX_WND child form is closed.


 Syntax:

 ' Placed at the point in the program where the BCX_WND
 ' is to be changed to a modal condition.
 SHOWMODAL(hwnd)

 ' Placed at the point in the program where the BCX_WND
 ' is to be reverted to a modeless condition.
 ENDMODAL(hwnd)

 Parameters:

  • hwnd is the HWND handle of the BCX_WND created window.

Example : This example shows usage of the SHOWMODAL and ENDMODAL macros


 GUI NOMAIN, PIXELS
 
 FUNCTION WINMAIN()
   GLOBAL Form1 AS CONTROL
   GLOBAL Button1 AS CONTROL
 
   Form1 = BCX_WND("MAINFORM", form1Proc, "Multi-Form GUI NoMain / Dialog Test",0,0,0,800,600)
   BCX_SET_FORM_COLOR(Form1,QBCOLOR(31))
   BCX_SETICON(Form1, 123)
   Button1 = BCX_BUTTON("Modal", Form1,  98, 690,  20, 96, 24)
   BCX_BUTTON("Modeless",        Form1,  99, 690,  50, 96, 24)
   BCX_BUTTON("Modal Form",      Form1, 100, 690,  80, 96, 24)
   BCX_BUTTON("Non-Modal Form",  Form1, 105, 690, 110, 96, 24)
   BCX_BUTTON("Close",           Form1, 104, 690, 140, 96, 24)
   CENTER(Form1)
   SHOW(Form1)
   SetFocus(Button1)
 
   FUNCTION = BCX_MSGPUMP()
 END FUNCTION
 
 BEGIN EVENTS form1Proc
   SELECT CASE Msg
     HANDLE_MSG(WM_COMMAND, form1_command)
     HANDLE_MSG(WM_CLOSE, form1_close)
   END SELECT
 END EVENTS MAIN
 
 MSGHANDLER form1_command
 IF CBCTLMSG = BN_CLICKED THEN
   IF CBCTL = 98 THEN
     BCX_MDIALOG(DialogOne,"BCX Modal Dialog",Form1,110,110,110,110)
   END IF
   IF CBCTL = 99 THEN
     BCX_DIALOG(DialogTwo,"BCX Modeless Dialog",Form1,110,110,110,110)
   END IF
   IF CBCTL = 100 THEN
     LoadForm2()
   END IF
   IF CBCTL = 105 THEN
     LoadForm3()
   END IF
   IF CBCTL = 104 THEN
     SendMessage(Form1, WM_CLOSE, 0, 0)
   END IF
 END IF
 END HANDLER
 
 MSGHANDLER form1_close
 LReturn = DestroyWindow(hWnd)
 END HANDLER
 
 '----------------------------------------------------
 
 BEGIN MODAL DIALOG AS DialogOne
 
   SELECT CASE CBMSG
   CASE WM_INITDIALOG
     CENTER(hWnd)
     SHOW(hWnd)
   END SELECT
 
 END DIALOG
 
 '----------------------------------------------------
 
 BEGIN DIALOG AS DialogTwo
 
   SELECT CASE CBMSG
   CASE WM_INITDIALOG
     CENTER(hWnd)
     SHOW(hWnd)
   END SELECT
 
 END DIALOG
 
 FUNCTION LoadForm2()
   LOCAL nStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_BORDER
   LOCAL form AS HWND
   'EnableWindow(Form1, FALSE)
   form = BCX_WND("CHILD1FORM", form2Proc, "Modal Form", Form1,10,10, 640,400, nStyle, 0)
   BCX_SETICON(form, 123)
   BCX_BUTTON("Modal",     form, 101,560, 20, 72, 24)
   BCX_BUTTON("Modeless",  form, 102,560, 50, 72, 24)
   BCX_BUTTON("Close",     form, 103,560, 80, 72, 24)
   CENTER(form)
   SHOWMODAL(form)
 
   FUNCTION = 0
 END FUNCTION
 
 FUNCTION LoadForm3()
   LOCAL nStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_BORDER
   LOCAL form AS HWND
   form = BCX_WND("CHILD2FORM", form3Proc, "Non-Modal Form", Form1,10,10, 640,400, nStyle, 0)
   BCX_SETICON(form, 123)
   BCX_BUTTON("Modal",     form, 201,560, 20, 72, 24)
   BCX_BUTTON("Modeless",  form, 202,560, 50, 72, 24)
   BCX_BUTTON("Close",     form, 203,560, 80, 72, 24)
   CENTER(form)
   SHOW(form)
 
   FUNCTION = 0
 END FUNCTION
 
 BEGIN EVENTS form3Proc
   SELECT CASE CBMSG
   CASE WM_CREATE
     STATIC nWndNo = 0
     SetWindowText(hWnd, "Window No. " + TRIM$(STR$(++nWndNo)))
   CASE WM_COMMAND
     IF CBCTLMSG = BN_CLICKED THEN
       IF CBCTL = 201 THEN
         BCX_MDIALOG(DialogOne,"BCX Modal Dialog",hWnd,110,110,110,110)
       END IF
       IF CBCTL = 202 THEN
         BCX_DIALOG(DialogTwo,"BCX Modeless Dialog",hWnd,110,110,110,110)
       END IF
       IF CBCTL = 203 THEN
         SendMessage(hWnd, WM_CLOSE, 0, 0)
       END IF
     END IF
   CASE WM_CLOSE
     DestroyWindow(hWnd)
   END SELECT
 END EVENTS
 
 BEGIN EVENTS form2Proc
   SELECT CASE CBMSG
   CASE WM_COMMAND
     IF CBCTLMSG = BN_CLICKED THEN
       IF CBCTL = 101 THEN
         BCX_MDIALOG(DialogOne,"BCX Modal Dialog",hWnd,110,110,110,110)
       END IF
       IF CBCTL = 102 THEN
         BCX_DIALOG(DialogTwo,"BCX Modeless Dialog",hWnd,110,110,110,110)
       END IF
       IF CBCTL = 103 THEN
         SendMessage(hWnd, WM_CLOSE, 0, 0)
       END IF
     END IF
   CASE WM_CLOSE
     ENDMODAL(hWnd)
     SetFocus(Form1)
   END SELECT
 END EVENTS