Gui Builder

Windows specific questions.
VANYA
Posts: 1374
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Gui Builder

Postby VANYA » Aug 29, 2012 11:52

1) is not completely visible main window:

Image

2) Here is the generated source code:

Code: Select all

' GuiCodgen translates a Graphical control into FB
'  Email: aloberr@yahoo.fr
'***************************************************************
#INCLUDE ONCE "windows.bi"
#INCLUDE ONCE "win\commctrl.bi"
#INCLUDE ONCE "win\commdlg.bi"
#INCLUDE ONCE "win\wingdi.bi"
#INCLUDE ONCE "win\richedit.bi"
#INCLUDE ONCE "win\tlhelp32.bi"
#INCLUDE ONCE "file.bi"

#define SET_CONTROL_FONT(H,B,C)      SendMessage(H,WM_SETFONT,Cast(WPARAM,Set_Font(B,C)),1)
#define Show(Window) RedrawWindow(Window,0,0,0):ShowWindow(Window,SW_SHOW)
#Define _RGB(r,g,b) ((cint(r) shl 16) or (cint(g) shl 8) or cint(b))
#DEFINE   SubclassWindow(h,f)   (CAST(WNDPROC, SetWindowLong(h,GWL_WNDPROC,CAST(DWORD, @f))))

 DIM SHARED g_hinstance as HINSTANCE

'***************************************************************
' Now define our control ID constants
'***************************************************************

#DEFINE   ID_Form1      100
#DEFINE   ID_BUTTON1      101
#DEFINE   ID_RichEdit1      102
#DEFINE   ID_ListView1      103

'***************************************************************
' Reserve memory space for each control that we'll create
'***************************************************************

DIM SHARED    Form1    AS    HWND
DIM SHARED    BUTTON1    AS    HWND
DIM SHARED    RichEdit1    AS    HWND
DIM SHARED    ListView1    AS    HWND

'**************************************************************
' Other variables & constants used by the program go here
'**************************************************************

DECLARE FUNCTION Form1_Proc ( byval hWnd as HWND, byval Msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
DECLARE FUNCTION MakeFontEx(sFont As String, PointSize AS LONG, fBold AS LONG=0, _
                 fItalic AS LONG=0, fUnderline AS LONG=0, StrikeThru AS LONG=0,CharSet as LONG=0) AS HFONT

Declare sub setRichEdit(hwnd as HWND,Forecolor as Integer,backColor as Integer,style as integer=0)

sub SetFormColor (hWnd As HWND ,Kolor As COLORREF )
   Dim As HBRUSH hbr=CreateSolidBrush(Kolor)
  DeleteObject(Cast(HBRUSH,SetClassLong(hWnd,GCL_HBRBACKGROUND,cast(DWORD,hbr))))
  InvalidateRect (hWnd,NULL,TRUE)
End Sub


Function Set_Color (TxtColr As Integer ,BkColr As Integer ,wParam As WPARAM ,lParam As LPARAM )As LRESULT
  static As HBRUSH  ReUsableBrush
  SetTextColor(cast(HDC,wParam),TxtColr)
  if(BkColr=-1) Then
     BkColr=CInt(cUINT(CULng(GetClassLongPtr(GetParent(cast(HWND,lParam)),GCL_HBRBACKGROUND))))
     if(Cast(UINT,BkColr)>31)Then
       SetBkMode(cast(HDC,wParam),TRANSPARENT): return BkColr
     else
        BkColr=GetSysColor(BkColr-1)
     End If
  End If
  DeleteObject(ReUsableBrush)
  ReUsableBrush=CreateSolidBrush(BkColr)
  SetBkColor(cast(HDC,wParam),BkColr)
  return cast(LRESULT,ReUsableBrush)
End Function


DECLARE SUB FORMLOAD()
' ========================================================================================
' Main
' ========================================================================================
Declare FUNCTION WINMAIN (BYVAL hInstance AS HINSTANCE, BYVAL hPrevInstance AS HINSTANCE, BYVAL lpszCmdLine AS ZString PTR, BYVAL nCmdShow AS LONG) AS LONG
 
End WinMain(GetModuleHandle(NULL),NULL,Command,SW_SHOW)

FUNCTION WINMAIN (BYVAL hInstance AS HINSTANCE, BYVAL hPrevInstance AS HINSTANCE, BYVAL lpszCmdLine AS ZString PTR, BYVAL nCmdShow AS LONG) AS LONG

   DIM hwndMain AS HWND
   Dim hCtl AS HWND
   Dim hFont AS HFONT
   Dim wcex AS WNDCLASSEX
   Dim szClassName AS ZString * 80

   hFont = GetStockObject(ANSI_VAR_FONT)

   ' Register the window class
   szClassName        ="Form1"
   g_hinstance       = hInstance
   wcex.cbSize        = SIZEOF(WNDCLASSEX)
   wcex.style         = CS_HREDRAW OR CS_VREDRAW
   wcex.lpfnWndProc   = @Form1_Proc
   wcex.cbClsExtra    = 0
   wcex.cbWndExtra    = 0
   wcex.hInstance     = hInstance
   wcex.hCursor       = LoadCursor (NULL, BYVAL IDC_ARROW)
   wcex.hbrBackground = cast(HBRUSH,COLOR_3DFACE+1)
   wcex.lpszMenuName  = NULL
   wcex.lpszClassName = STRPTR(szClassName)
   wcex.hIcon         = LoadIcon (NULL, BYVAL IDI_APPLICATION) ' Sample, if resource icon: LoadIcon(hInst, "APPICON")
   wcex.hIconSm       = LoadIcon (NULL, BYVAL IDI_APPLICATION) ' Remember to set small icon too..
   RegisterClassEx @wcex


 FORMLOAD()

   ' Message handler loop
   Dim uMsg AS MSG
   While GetMessage(@uMsg, NULL, 0, 0)
      IF IsDialogMessage(hwndMain, @uMsg)=0 THEN
            TranslateMessage @uMsg
            DispatchMessage @uMsg
      END IF
   WEND

   FUNCTION = uMsg.wParam

END FUNCTION

'***************************************************************
' Now let's create and load the form and all of its controls
'***************************************************************

SUB FORMLOAD()
     DIM iccex   AS INITCOMMONCONTROLSEX
     iccex.dwSize    = SIZEOF(iccex)
     iccex.dwICC     = ICC_TREEVIEW_CLASSES Or ICC_BAR_CLASSES  Or ICC_TAB_CLASSES  Or ICC_UPDOWN_CLASS  Or                      ICC_PROGRESS_CLASS Or  ICC_ANIMATE_CLASS Or ICC_WIN95_CLASSES  Or ICC_DATE_CLASSES  Or                       ICC_USEREX_CLASSES Or  ICC_COOL_CLASSES Or  ICC_INTERNET_CLASSES  Or ICC_PAGESCROLLER_CLASS
     InitCommonControlsEx(@iccex)
'Load up the Richedit DLL
If LoadLibrary("RICHED32.DLL") = 0 Then
      MessageBox(NULL,"Unable to load RICHED32.DLL","Error",0)
End If
 Form1 = CreateWindowEx(0, _
                                        "Form1", _
                                        "Form1", _
                                         WS_MINIMIZEBOX or  WS_SIZEBOX or  WS_CAPTION or  WS_MAXIMIZEBOX or  WS_POPUP or  WS_SYSMENU, _
                                        176, _
                                        219, _
                                        640, _
                                        512, _
                                        HWND_DESKTOP, _
                                        NULL , _
                                        GetmoduleHandle(0),NULL)
 BUTTON1 = CreateWindowEx(0, _
                                        "button", _
                                        "&Button", _
                                         WS_CHILD OR WS_VISIBLE OR WS_CLIPSIBLINGS OR BS_PUSHBUTTON , _
                                        64, _
                                        88, _
                                        112, _
                                        32, _
                                        Form1, _
                                        Cast(HMENU,ID_BUTTON1), _
                                        GetmoduleHandle(0),NULL)
 RichEdit1 = CreateWindowEx( WS_EX_CLIENTEDGE, _
                                        RICHEDIT_CLASS, _
                                        "", _
                                          WS_CHILD OR WS_CLIPSIBLINGS OR WS_VISIBLE OR WS_VSCROLL OR WS_HSCROLL or ES_MULTILINE Or ES_WANTRETURN , _
                                        240, _
                                        112, _
                                        280, _
                                        152, _
                                        Form1, _
                                        Cast(HMENU,ID_RichEdit1), _
                                        GetmoduleHandle(0),NULL)
 setRichEdit(RichEdit1, _RGB(255,255,0),_RGB(255,0,128),  WS_CHILD OR WS_CLIPSIBLINGS OR WS_VISIBLE OR WS_VSCROLL OR WS_HSCROLL or ES_MULTILINE Or ES_WANTRETURN )
 ListView1 = CreateWindowEx( 0 , _
                                        "SysListView32", _
                                        "", _
                                         WS_BORDER OR WS_CHILD OR WS_VISIBLE OR WS_CLIPSIBLINGS Or LVS_REPORT OR LVS_SINGLESEL OR LVS_SHOWSELALWAYS , _
                                        40, _
                                        200, _
                                        160, _
                                        160, _
                                        Form1, _
                                        Cast(HMENU,ID_ListView1), _
                                        GetmoduleHandle(0),NULL)
 Dim As HFONT hFont = MakeFontEx("MS Sans Serif", 10, FALSE, FALSE, FALSE, FALSE)
 SendMessage(ListView1,WM_SETFONT, Cast(WPARAM,hFont),cast(LPARAM,MAKELPARAM(FALSE,0)))
 ListView_SetExtendedListViewStyle(ListView1, LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES)

Dim lvc AS LVCOLUMN
DIM lvi AS LVITEM
lvc.mask      = LVCF_FMT  Or LVCF_WIDTH  Or LVCF_TEXT Or LVCF_SUBITEM
lvc.fmt       = LVCFMT_LEFT
lvc.cx        = 100
lvc.pszText   = StrPtr("LvColumn1")
lvc.iSubItem  = 0
 ListView_InsertColumn(ListView1, 0, @lvc)
lvc.cx        = 200
lvc.pszText   = StrPtr("LvColumn2")
lvc.iSubItem  = 1
 ListView_InsertColumn(ListView1, 0, @lvc)
 lvi.mask     = LVIF_TEXT
 lvi.pszText  = StrPtr(Str(4))
 lvi.iSubItem = 0
 ListView_InsertItem(ListView1, @lvi)
 ListView_SetBkColor(ListView1, _RGB(255,0,128))
 ListView_SetTextColor(ListView1, _RGB(255,255,0))
 ListView_SetTextBkColor(ListView1, _RGB(255,0,128))
 Dim As HFONT hFont = MakeFontEx("MS Sans Serif", 10, FALSE, FALSE, FALSE, FALSE)
 SendMessage(ListView1,WM_SETFONT, Cast(WPARAM,hFont),Cast(LPARAM,MAKELPARAM(FALSE,0)))
 ListView_SetExtendedListViewStyle(ListView1, LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES)
 ShowWindow(Form1,SW_SHOW)
 UpdateWindow(Form1)
END SUB

'***************************************************************
' Now that the form and its controls are loaded and on the
' screen, we go into the event loop and wait for the user
' to do something!
'***************************************************************

FUNCTION Form1_Proc ( byval hWnd as HWND, byval Msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
 Dim RetC AS RECT
 Dim pToolTip AS TOOLTIPTEXT PTR
 Dim ptnmhdr AS NMHDR PTR         'information about a notification message
 Dim pRebar AS NMREBAR PTR
 Dim mminfo AS MINMAXINFO PTR
 
 
 SELECT CASE Msg

    CASE WM_CREATE
      EXIT FUNCTION
    CASE WM_CTLCOLORSTATIC, WM_CTLCOLORBTN, WM_CTLCOLOREDIT,WM_CTLCOLORLISTBOX, WM_CTLCOLORSCROLLBAR
           If Cast(HWND,lparam)=BUTTON1 Then
             SetTextColor(Cast(HDC,wParam),_RGB(255,255,0))
             SetBkColor(Cast(HDC,wParam), _RGB(255,0,128))
             Return cast(LRESULT,createsolidbrush(_RGB(255,0,128)))
           End If
   CASE WM_SIZE
   IF  wparam  <>  SIZE_MINIMIZED THEN
       GetClientRect hwnd, @RetC    'dlg client rect
       'MoveWindow PicMain, 2, retC.Top + rebar_height, RetC.Right - 4, RetC.Bottom - rebar_height  - Statusbar_height,  TRUE
   END IF
          return 0

   CASE WM_PAINT
       DIM ps as PAINTSTRUCT
       DIM hdc as HDC
      'Dim rc AS RECT: GetClientRect(hwnd,@rc)
         hdc=BeginPaint(hwnd,@ps)
            ' FillRect(ps.hdc,@rc,CreateSolidBrush(YELLOW))
                   ' Put your Code heare
         Delete(hdc)
         EndPaint(hwnd,@ps)
          EXIT FUNCTION

   CASE WM_TIMER
       InvalidateRect(hwnd,0,1)
          EXIT FUNCTION

  CASE WM_COMMAND
  SELECT CASE LOWORD(wParam)   'Which control triggered this event?
   CASE ID_BUTTON1   'CommandButton
   CASE ID_RichEdit1   'RichTextBox
     ' Add code here to handle this control: RichEdit1
   CASE ID_ListView1   'ListView
     ' Add code here to handle this control: ListView1
  END SELECT
  Return 0
 
  CASE WM_CLOSE
 
 if IDYES = MessageBox(hWnd,"Quit?","Form1", MB_YESNO or MB_ICONQUESTION) Then
    DestroyWindow(Form1)
 end If
    Return 0
 
  CASE WM_DESTROY
     PostQuitMessage(0)
     Return 0
 
 END SELECT
   Return DefWindowProc( hWnd, Msg, wParam, lParam )
END FUNCTION

'***********************************************************************************
' Add any other supporting routines here
'***********************************************************************************

sub setRichEdit(hwnd as HWND,Forecolor as Integer,backColor as Integer,style as integer=0)
  SendMessage(hwnd , EM_SETEVENTMASK, 0, ENM_SELCHANGE Or ENM_CHANGE Or ENM_UPDATE)
SendMessage(hwnd , EM_SETBKGNDCOLOR, 0, CAST(LPARAM,CreateSolidBrush(backColor)))
DIM   cf AS CHARFORMAT2
cf.cbSize = sizeof(CHARFORMAT2)
cf.dwMask = CFM_COLOR
cf.crTextColor = GetSysColor(Forecolor)
SetFocus(hwnd)
SendMessage( hwnd , EM_SETSEL, 0, GetWindowTextLength(hwnd))
SendMessage( hwnd , EM_SETCHARFORMAT, 0,cast(LPARAM,@cf))
DIM   pf AS PARAFORMAT2
 pf.cbSize = sizeof(PARAFORMAT2)
 pf.dwMask = PFM_ALIGNMENT
'The EditStyles are only dummies to give the right Arguments here
'CTD Files need not to be changed for this
 IF (Style And not ES_CENTER) AND (Style And not ES_RIGHT) THEN pf.wAlignment = PFA_LEFT
 IF (Style And ES_CENTER) THEN pf.wAlignment = PFA_CENTER
 IF (Style And ES_RIGHT) THEN pf.wAlignment = PFA_RIGHT
 SendMessage(hwnd , EM_SETSEL, 0, GetWindowTextLength(hwnd ))
 SendMessage(hwnd , EM_SETPARAFORMAT,0, cast(LPARAM,@pf))
End sub

'***********************************************************************************
' End of program
'***********************************************************************************



Errors: FbTemp.bas(204) error 4: Duplicated definition, hFont in 'Dim As HFONT hFont = MakeFontEx("MS Sans Serif", 10, FALSE, FALSE, FALSE, FALSE)'

If you remove the duplicate ad hFont, where to take the function MakeFontEx?
aloberoger
Posts: 495
Joined: Jan 13, 2009 19:23

Re: Gui Builder

Postby aloberoger » Aug 29, 2012 15:21

I don't know why the window is not completly showed
perhaps it is a matter of resolution screen?
I implemented the source code like this:

'**Create the Header Window using the registered class
ghWndHDMain = CreateWindowEx(WS_EX_APPWINDOW OR WS_EX_WINDOWEDGE, _
"GFB.1", _
"Gui Forms Builder", _
WS_POPUP OR WS_STYLE _
OR WS_CLIPSIBLINGS OR WS_CLIPCHILDREN, _
40,40, _
740,108, _
hWnd, _ 'ghWndOwner
ghHDMenu, _
ghInst, _
BYVAL NULL)

I thing my screen resolution is 1084*780

For MakeFontEx Thinks you
I have already corrected this in the source code, you have to wait until I upload the new file.


I notice that without implementation of MakeFontEx the compilation was curuously successfull on my machine.

If you are interrested by the source code,you can send me your email address.
VANYA
Posts: 1374
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Gui Builder

Postby VANYA » Aug 29, 2012 15:50

aloberoger wrote:I don't know why the window is not completly showed
perhaps it is a matter of resolution screen?
I implemented the source code like this:

'**Create the Header Window using the registered class
ghWndHDMain = CreateWindowEx(WS_EX_APPWINDOW OR WS_EX_WINDOWEDGE, _
"GFB.1", _
"Gui Forms Builder", _
WS_POPUP OR WS_STYLE _
OR WS_CLIPSIBLINGS OR WS_CLIPCHILDREN, _
40,40, _
740,108, _
hWnd, _ 'ghWndOwner
ghHDMenu, _
ghInst, _
BYVAL NULL)

I thing my screen resolution is 1084*780


Just please, increase the size of 10-15 pixels

For MakeFontEx Thinks you
I have already corrected this in the source code, you have to wait until I upload the new file.


I notice that without implementation of MakeFontEx the compilation was curuously successfull on my machine.

If you are interrested by the source code,you can send me your email address.


No, no. I just tried your program.

How will I have time ,I am test more to identify errors.
Coolman
Posts: 228
Joined: Nov 05, 2010 15:09

Re: Gui Builder

Postby Coolman » Aug 29, 2012 17:24

This time. antivirus has not reacted. is would it be possible for information purposes posting section of source code that caused this reaction ...

thanks.
aloberoger
Posts: 495
Joined: Jan 13, 2009 19:23

Re: Gui Builder

Postby aloberoger » May 23, 2014 21:17

aloberoger
Posts: 495
Joined: Jan 13, 2009 19:23

Re: Gui Builder

Postby aloberoger » May 30, 2014 20:04

the project was updated in the same link
remember that the form have to be MainForm=true to be able to compile the output bas file for now only api code is generated via toolbar Save-Enregistrer .api bas
St_W
Posts: 1504
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Gui Builder

Postby St_W » Jun 07, 2014 23:09

The link above seems to be invalid as of now.
aloberoger
Posts: 495
Joined: Jan 13, 2009 19:23

Re: Gui Builder

Postby aloberoger » Jun 08, 2014 20:16

MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: Gui Builder

Postby MOD » Jun 09, 2014 16:53

You could ask Sebastian for some users space instead of using these **** filehoster. :\

See: http://users.freebasic-portal.de/
aloberoger
Posts: 495
Joined: Jan 13, 2009 19:23

Re: Gui Builder

Postby aloberoger » Jun 10, 2014 8:03

You could ask Sebastian for some users space instead of using these **** filehoster. :\



I need some explanation about how to do.
MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: Gui Builder

Postby MOD » Jun 10, 2014 8:06

Click on the link above and write a mail to Sebastian.
TJF
Posts: 3600
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Gui Builder

Postby TJF » Jun 10, 2014 13:58

aloberoger wrote:I need some explanation about how to do.

Find the Email adress in the Impressum.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests