PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Custom Control  (Read 530 times)

Andre Smit

  • Guest
Custom Control
« on: March 04, 2006, 05:42:52 PM »


Just started evaluating Firefly. I'm impressed.

Having problems getting a custom control to show. It is DLL based and has an associated inc header file. I have included the inc file in the project and added a custom control to the form and provided class name etc.

This is my INIT function:
Code: [Select]

Function FRMFILE_GRID_INIT (ClassName As Asciiz, Caption As Asciiz, hWndParent As Dword, _
                                    ExStyles As Dword, Styles As Dword, nLeft As Dword, nTop As Dword, _
                                    nWidth As Dword, nHeight As Dword) As Long                          
Control Add ClassName, HWND_FRMFILE, IDC_FRMFILE_GRID, Caption, nLeft, nTop, nWidth, nHeight, Styles, ExStyles

End Function

I need to run  LoadLibrary("bgrid.dll") to register the classname which I do on my Main Form calling the dialog on which the custom control is placed. Any suggestions?




  • Guest
Custom Control
« Reply #1 on: March 04, 2006, 05:59:31 PM »

Control Add is used for DDT dialogs in PowerBASIC. You should try using CreateWindowEx instead to see if it works. I would not mix DDT with FireFly. This is the default code that is generated by FireFly in the code editor. You should use it as a guideline.
Code: [Select]

                                   ClassName   As Asciiz, _  ' windows class
                                   Caption     As Asciiz, _  ' window caption
                                   hWndParent  As Dword,  _  ' handle of parent window
                                   ExStyles    As Dword,  _  ' extended window styles
                                   Styles      As Dword,  _  ' standard window styles
                                   nLeft       As Dword,  _  ' left position of control
                                   nTop        As Dword,  _  ' top position of control
                                   nWidth      As Dword,  _  ' width of control
                                   nHeight     As Dword   _  ' height of control
                                   ) As Long

   'If your custom control uses CreateWindowEx then use the template below, otherwise
   'follow the instructions provided by the Custom Control's author. The Custom Control
   'INIT function is called during the %WM_CREATE message for the Form on which the
   'Custom Control is created.

   Local hWndControl As Dword

   hWndControl = CreateWindowEx(ExStyles, _
                                ClassName, _
                                Caption, _
                                Styles, _
                                nLeft, nTop, nWidth, nHeight, _
                                hWndParent, IDC_FORM1_CUSTOMCONTROL1, _
                                GetModuleHandle(ByVal %Null), _
                                ByVal %Null)

   'It is important that this function return the Windows Handle to the newly created Control *** Do not delete this ***.
   Function = hWndControl

End Function

Notice that the handle of the newly created control is returned from the function. i.e.  Function = hWndControl