Make your own free website on Tripod.com
| Home | Ruff-In | MTutor | GradientFill | FB code | FBLoan | TW-Form | JaxGUI | Other DownLoads | PBCC Code | GW Code | Fix 2000/ XP | Text Screen Shots | QB code
Code for Screen Shot

ConASCII

Some of the routines in this example doesn't work in 98 or 95.
 
Makefontex rountine doesn't work compiled with freebasic 13csv in XP, it does work compiled with ver12.
 
You can Copy this Code and Give it a try, before you DownLoad. You'll have to add you own Very Small bitmaps though or you can leave them out.
 
 

 

  #DEFINE EM_SETOPTIONS WM_USER + 77 
  #DEFINE ES_DISABLENOSCROLL &H00002000
  #DEFINE ES_SAVESEL &H00008000        
  #DEFINE ECOOP_OR &H0002              
  #DEFINE ECO_SELECTIONBAR &H01000000  
            
  OPTION EXPLICIT
 ' $INCLUDE: 'win\kernel32.bi'
 ' $INCLUDE: 'win\user32.bi'
 ' $INCLUDE: 'win\GDI32.bi'
 ' $INCLUDE :'win\COMMCTRL32.bi'

  TYPE LV_ITEM   
     mask       AS uinteger
     iItem      AS LONG     
     iSubItem   AS LONG     
     STATE      AS uinteger 
     stateMask  AS uinteger 
     pszText    AS string ptr
     cchTextMax AS LONG      
     iImage     AS LONG      
     lParam     AS LONG      
     iIndent    AS LONG      
 END TYPE
 
 TYPE LV_COLUMN              
     mask AS uinteger        
     fmt AS LONG             
     cx AS LONG              
     pszText AS string ptr   
     cchTextMax AS LONG      
     iSubItem AS LONG        
     iImage AS LONG          
     iOrder AS LONG          
   END TYPE                  
 
 TYPE NEWTEXTMETRIC       
  tmHeight AS LONG       
  tmAscent AS LONG        
  tmDescent AS LONG       
  tmInternalLeading AS LONG
  tmExternalLeading AS LONG
  tmAveCharWidth AS LONG 
  tmMaxCharWidth AS LONG 
  tmWeight AS LONG 
  tmOverhang AS LONG
  tmDigitizedAspectX AS LONG
  tmDigitizedAspectY AS LONG
  tmFirstChar AS BYTE
  tmLastChar AS BYTE 
  tmDefaultChar AS BYTE
  tmBreakChar AS BYTE
  tmItalic AS BYTE   
  tmUnderlined AS BYTE
  tmStruckOut AS BYTE  
  tmPitchAndFamily AS BYTE
  tmCharSet AS BYTE   
  ntmFlags AS UINTEGER 
  ntmSizeEM AS UINTEGER 
  ntmCellHeight AS UINTEGER
  ntmAveWidth AS UINTEGER 
 END TYPE
 
 TYPE ENUMLOGFONT
  elfLogFont AS LOGFONT
  elfFullName AS STRING * LF_FULLFACESIZE 
  elfStyle AS STRING * LF_FACESIZE         
 END TYPE

 DECLARE FUNCTION  WinMain (byval hInstance as long, _ 
                       byval hPrevInstance as long, _  
                       szCmdLine as string, _          
                       byval iCmdShow as long) as long 
 'entry point
 END WinMain(GetModuleHandle(null), null, Command$, SW_NORMAL)
                       
 
  SUB RoundRectangle (BYVAL hDC AS uinteger, _
                BYVAL x AS LONG, BYVAL y AS LONG, _
                BYVAL x2 AS LONG, BYVAL y2 AS LONG, _
                BYVAL rw AS LONG, BYVAL rh AS LONG, _
                BYVAL BrushPattern AS LONG, BYVAL BrushClr AS LONG, _
                BYVAL PenType AS LONG, BYVAL PenWidth AS LONG, BYVAL PenClr AS LONG)
    DIM hBrush AS uinteger, hPen AS uinteger
    hPen   = CreatePen(PenType, PenWidth, PenClr) ' create pen with given color
    hPen   = SelectObject(hDC, hPen)         ' select it into given dc
    IF BrushPattern = 0 THEN
        hBrush = CreateSolidBrush(BrushClr)  ' create solid brush with given color
    ELSE
        hBrush = CreateHatchBrush(BrushPattern, BrushClr)  ' create hatched brush with given color
    END IF
    hBrush = SelectObject(hDC, hBrush)       ' select it into given dc
    RoundRect hDC, x, y, x2, y2, rw, rh      ' draw the actual rectangle
    DeleteObject SelectObject(hDC, hBrush)       ' delete what we created
    DeleteObject SelectObject(hDC, hPen)         ' to avoid memory leaks
  END SUB
 
 
  FUNCTION EnumCharSet(elf AS ENUMLOGFONT,ntm AS NEWTEXTMETRIC, _
             BYVAL FontType AS LONG,CharSet AS LONG) AS LONG
      CharSet = elf.elfLogFont.lfCharSet
  END FUNCTION

  FUNCTION MakeFontEx(sFont AS STRING, BYVAL PointSize AS LONG, _
         BYVAL fBold AS LONG, BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG, _
         BYVAL StrikeThru AS LONG) AS LONG
     DIM hDC AS LONG, CharSet AS LONG, CyPixels AS LONG
    hDC = GetDC(HWND_DESKTOP)
        CyPixels  = GetDeviceCaps(hDC, LOGPIXELSY)
        EnumFontFamilies hDC, BYVAL sFont, @EnumCharSet , BYVAL CharSet
     ReleaseDC HWND_DESKTOP, hDC
     PointSize = 0 - (PointSize * CyPixels) \ 72
     MakeFontEx = CreateFont(PointSize,0,0,0, fBold, _
                           fItalic,fUnderline,StrikeThru,CharSet, _
                           OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS, _
                           DEFAULT_QUALITY,FF_DONTCARE, _
                           sFont)
  END FUNCTION

 DATA "Rec. Nr.", 80, "Last Name", 120, "First Name", 120," Phone", 120, "Email", 120
 DATA "101", "Boggs", "Jimmy", "(532) 223-3034","jboggs@aol.com"
 DATA "102", "Smith", "Granny", "(244) 545-8970","gsmith@msn.com"
 DATA "103", "Washington"," Roy","(434) 677-1432","rwash@pldi.net"
 DATA "104", "James", "Frank","(439) 879-5468","james@excite.com"
 

 FUNCTION ProcessWindow (BYVAL hDlg AS Uinteger, BYVAL wMsg AS Uinteger, BYVAL wParam _
                  AS Uinteger, BYVAL lParam AS LONG) AS LONG
   STATIC hLBbrush1 AS LONG
   STATIC hEDbrush1 AS LONG
   DIM ps AS PAINTSTRUCT
   DIM itm AS STRING, Length AS LONG, Index AS LONG, x AS LONG
   DIM CbText1 AS STRING
   DIM LBgColor1 AS LONG
   DIM LFgColor1 AS LONG
   DIM wmID AS LONG, wmEvent AS LONG
   DIM LbText1 AS STRING
   STATIC hBmp1 AS LONG
   DIM MemDC1 AS LONG, rc1 AS RECT, bm1 AS BITMAP
   DIM Lt1 AS STRING
   STATIC hBmp3 AS LONG
   DIM MemDC3 AS LONG, rc3 AS RECT, bm3 AS BITMAP
   DIM Lt2 AS STRING
   STATIC hBmp4 AS LONG
   DIM MemDC4 AS LONG, rc4 AS RECT, bm4 AS BITMAP
   STATIC hBmp5 AS LONG
   DIM MemDC5 AS LONG, rc5 AS RECT, bm5 AS BITMAP
   DIM Buff1 AS string *  14
   DIM ff AS LONG
   DIM row AS SINGLE, xl AS LONG, yl AS LONG, xx AS LONG, lStyle AS LONG
   STATIC hLv1 AS LONG
   DIM LvItm1 AS LV_ITEM , LVcol1 AS LV_COLUMN
   DIM Buf1 AS string *  14
   STATIC hLv2 AS LONG
   DIM LvItm2 AS LV_ITEM , LVcol2 AS LV_COLUMN
   DIM Buf2 AS string *  16
   STATIC hLv3 AS LONG
   DIM LvItm3 AS LV_ITEM , LVcol3 AS LV_COLUMN
   DIM Buf3 AS string *  16
   STATIC hLv4 AS LONG
   DIM LvItm4 AS LV_ITEM , LVcol4 AS LV_COLUMN
   DIM Buf4 AS string *  80
   DIM eFgColor1 AS LONG
   DIM eBgColor1 AS LONG
   DIM MSBtx AS STRING
   DIM EdTxt1 AS STRING * 40
   DIM RichTxt1 AS STRING
   DIM Et3 AS STRING
   DIM Lt4 AS STRING
   DIM hCtrl AS LONG
   InitCommonControls
   DIM hRich1 AS LONG
   DIM hfont AS LONG
   DIM hHand AS LONG
   DIM check AS LONG
  
    LBgColor1 = &HB8E989     ' Selected background color for ListBox1
    LFgColor1 = &H400080     ' Selected foreground color for ListBox
    eFgColor1 = &HECFFCE    ' Selected foreground color for Edit
    eBgColor1 = &H301983    ' Selected background color for Edit
  IF wMsg = WM_CREATE THEN        'Messages that Initializes Controls and 
                                       'tasks that affects the Appearance of Dialogs
     hLBbrush1  =  CreateSolidBrush(LBgColor1)  ' Creates a logical brush with specified color for ListBox1
     hEDbrush1  =  CreateSolidBrush(eBgColor1)  ' Creates a brush with the specified color
     hBmp1 = LoadImage(0, "\bin\Sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE) 
     hBmp3 = LoadImage(0, "\bin\sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
     GetObject hBmp3, LEN(bm3), bm3       'get bitmap's size
     hBmp4 = LoadImage(0, "\bin\sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
     hBmp5 = LoadImage(0, "\bin\sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
     GetObject hBmp5, LEN(bm5), bm5       'get bitmap's size

   DIM ARay3(5,5) AS STRING
     Aray3(0,0)="101" : ARay3(0,1)="Boggs" : ARay3(0,2)="Jimmy"
     Aray3(0,3)="(532) 223-3034" : ARay3(0,4)="jimmyb@aol.com"
     Aray3(1,0)="102" : ARay3(1,1)="Bullard" : ARay3(1,2)="Lester"
     Aray3(1,3)="(361) 893-5792" : ARay3(1,4)="lbull@msn.com"
     Aray3(2,0)="103" : Aray3(2,1)="Sprite": ARay3(2,2)="Jack"
     ARay3(2,3)="(580) 935-7242" : Aray3(2,4)="Jsprit@pldi.net"
     Aray3(3,0)="104" : ARay3(3,1)="Williams" : Aray3(3,2)="Sandy"
     ARay3(3,3)="(303) 453-9087" : ARay3(3,4)="swil@excite.com"

     hCtrl  = CreateWindowEx(WS_EX_ClientEdge, "Button", "Check 1", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTOCHECKBOX OR BS_CENTER, _ 
           670,  154,  100,  19, _  
          hdlg,  120, 0, BYVAL NULL)
     hCtrl  = CreateWindowEx(WS_EX_ClientEdge, "Button", "Check 2", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTOCHECKBOX OR BS_CENTER, _ 
           670,  198,  100,  19, _  
          hdlg,  121, 0, BYVAL NULL)
     hCtrl  = CreateWindowEx(WS_EX_ClientEdge, "Button", "Check 3", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTOCHECKBOX OR BS_CENTER, _ 
           670,  242,  100,  19, _  
          hdlg,  122, 0, BYVAL NULL)
     hCtrl  = CreateWindowEx(WS_EX_ClientEdge, "Button", "Check 4", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTOCHECKBOX OR BS_CENTER OR BS_PUSHLIKE, _ 
           670,  286,  100,  19, _  
          hdlg,  123, 0, BYVAL NULL)
     hCtrl  = CreateWindowEx(0, "Button", "Check 5", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTOCHECKBOX OR BS_CENTER OR BS_FLAT OR BS_PUSHLIKE, _ 
           670,  330,  100,  19, _  
          hdlg,  124, 0, BYVAL NULL)
      hCtrl = CreateWindowEx(WS_EX_ClientEdge, "Button", "Option 1", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTORADIOBUTTON OR BS_CENTER, _ 
           10,  154,  100,  19, _  
          hdlg,  125, 0, BYVAL NULL)
      hCtrl = CreateWindowEx(WS_EX_ClientEdge, "Button", "Option 2", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTORADIOBUTTON OR BS_CENTER, _ 
           10,  198,  100,  19, _  
          hdlg,  126, 0, BYVAL NULL)
      hCtrl = CreateWindowEx(WS_EX_ClientEdge, "Button", "Option 3", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTORADIOBUTTON OR BS_CENTER OR BS_PUSHLIKE, _ 
           10,  242,  100,  19, _  
          hdlg,  127, 0, BYVAL NULL)
      hCtrl = CreateWindowEx(WS_EX_ClientEdge, "Button", "Option 4", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTORADIOBUTTON OR BS_CENTER OR BS_PUSHLIKE, _ 
           10,  286,  100,  19, _  
          hdlg,  128, 0, BYVAL NULL)
      hCtrl = CreateWindowEx(0, "Button", "Option 5", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  BS_AUTORADIOBUTTON OR BS_CENTER OR BS_FLAT OR BS_PUSHLIKE, _ 
           10,  330,  100,  19, _  
          hdlg,  129, 0, BYVAL NULL)
             ' Change font in Control using its handle and Font handle
 
       Lt1=Lt1 + ""
      hCtrl = CreateWindowEx(0, "static", BYVAL STRPTR( LT1 ), _
            SS_BITMAP   OR  WS_CHILD OR WS_VISIBLE, _
                  240,  1,  100,  129, _  
                  hdlg,  103, 0, BYVAL NULL)   
       Lt2=Lt2 + ""
      hCtrl = CreateWindowEx(0, "static", BYVAL STRPTR( LT2 ), _
            SS_BITMAP   OR  WS_CHILD OR WS_VISIBLE, _
                  430,  1,  100,  129, _  
                  hdlg,  104, 0, BYVAL NULL)   
       Lt4=Lt4 + "This is the Label control, unless you change the "
       Lt4=Lt4 + "background color, it will be window color. Text can be "
       Lt4=Lt4 + "changed also, plus bitmap can be added."
      hCtrl = CreateWindowEx(0, "static", BYVAL STRPTR( LT4 ), _
            WS_CHILD OR WS_VISIBLE, _
                  544,  418,  220,  107, _  
                  hdlg,  114, 0, BYVAL NULL)   
     hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "Button", "&Retry", _
           WS_CHILD OR WS_VISIBLE OR  BS_OWNERDRAW  , _
                 240,  418,  100,  131, _  
                 hdlg,  105, 0, BYVAL NULL)   
     hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "Button", "", _
           WS_CHILD OR WS_VISIBLE OR  BS_BITMAP     , _
                 430,  418, bm5.bmWidth, bm5.bmHeight, _  
                 hdlg,  106, 0, BYVAL NULL)   
     hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "Button", "&Ok", _
           WS_CHILD OR WS_VISIBLE OR  BS_PUSHBUTTON, _
                 370,  528,  45,  21, _  
                 hdlg,  115, 0, BYVAL NULL)   
     hCtrl  = CreateWindowEx(WS_EX_ClientEdge, "Edit", "", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  ES_LEFT OR ES_MULTILINE OR ES_WANTRETURN, _ 
           10,  22,  210,  107, _  
          hdlg,  111, 0, BYVAL NULL)
       Et3=Et3 + "This is the Read Only Edit control, You can't type in this "
     hCtrl  = CreateWindowEx(WS_EX_ClientEdge, "Edit",  Et3, _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  ES_LEFT OR ES_MULTILINE OR ES_WANTRETURN OR ES_READONLY, _ 
           10,  418,  210,  107, _  
          hdlg,  113, 0, BYVAL NULL)
      hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "ComboBox", "", _
            WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR  CBS_DROPDOWN OR CBS_AUTOHSCROLL OR CBS_HASSTRINGS, _
                  350,  1,  70,  503, _  
                  hdlg,  101, 0, BYVAL NULL)   
      hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "", _
                  WS_CHILD OR WS_VISIBLE OR WS_TABSTOP OR WS_BORDER OR WS_VSCROLL OR  LBS_NOTIFY OR LBS_HASSTRINGS , _
                  350,  44,  60,  440, _  
                  hdlg,  102, 0, BYVAL NULL)   
      hLv1 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _
         WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ 
         LVS_SHOWSELALWAYS OR  LVS_NOSORTHEADER OR LVS_REPORT OR LVS_SINGLESEL, _
         150,  154,  170,  92, _  
         hdlg,  107, 0, BYVAL NULL)   
      hLv2 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _
         WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ 
         LVS_SHOWSELALWAYS OR  LVS_NOSORTHEADER OR LVS_REPORT OR LVS_SINGLESEL, _
         150,  286,  170,  92, _  
         hdlg,  108, 0, BYVAL NULL)   
      hLv3 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _
         WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ 
         LVS_SHOWSELALWAYS OR  LVS_NOSORTHEADER OR LVS_REPORT OR LVS_SINGLESEL, _
         450,  154,  190,  92, _  
         hdlg,  109, 0, BYVAL NULL)   
      hLv4 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _
         WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ 
         LVS_SHOWSELALWAYS OR  LVS_NOSORTHEADER OR LVS_REPORT OR LVS_SINGLESEL, _
         450,  286,  190,  92, _  
         hdlg,  110, 0, BYVAL NULL)   
     LoadLibrary("RICHED32.DLL")
     hRich1 = CreateWindowEx(WS_EX_CLIENTEDGE, "RichEdit", "RichEdit", WS_CHILD OR WS_VISIBLE OR _ 
     WS_CHILD OR WS_VISIBLE OR WS_TABSTOP OR WS_VSCROLL OR ES_WANTRETURN OR ES_AUTOVSCROLL OR _ 
     ES_MULTILINE OR ES_NOHIDESEL OR ES_SAVESEL OR ES_DISABLENOSCROLL, _   
     540,  22,  230,  110, hDlg,  112, 0, BYVAL NULL)
    
     SendMessage hRich1, EM_SETSEL, 1, 1       ' to reset pos/selection in text
     SendMessage hRich1, EM_SCROLLCARET, 0, 0  ' Make caret  scroll into view..
     SendMessage hRich1, EM_SETOPTIONS, ECOOP_OR, ECO_SELECTIONBAR
     SendMessage hRich1, EM_SETMARGINS, EC_LEFTMARGIN, 5     'Set Left Margin
     SetWindowText hRich1, "Text set in RichEdit Control"
     SendMessage GetDlgItem(hDlg, 104), STM_SETIMAGE, IMAGE_BITMAP, BYVAL hBmp3
     SendMessage GetDlgItem(hDlg, 106),BM_SETIMAGE,IMAGE_BITMAP, BYVAL hBmp5
       hCtrl = GetDlgItem(hDlg,  101)                       ' Get Handle of Control, using handle of Dialog
       FOR x = 0 TO  22                                        ' Load ComboBox with Items to select
          itm = "Item" + STR$(x)                            ' Create an Item using that string
          SendMessage hCtrl, CB_ADDSTRING, 0, BYVAL itm     ' Put the Item in the ComboBox for display
       NEXT X
       hCtrl = GetDlgItem(hDlg,  102)
       FOR x = 1 TO  20                                      ' Load ListBox with Items to select
          itm = "Item" + STR$(x)                          '  Create an Item using that string
          SendMessage hCtrl, LB_ADDSTRING, 0, BYVAL itm   '  Put the Item in the ListBox for display
       NEXT X
      
    hFont = MakeFontEx("Microsoft Sans Serif", -10,  700,  1,  0,  0)   ' Get a Handle for this Font
    hHand = GetDlgItem(hDlg,  110)                                      ' Get Handle for a Control using its ID nr and its Parent Handle
    CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE)      
      
    hFont = MakeFontEx("Times New Roman", -13,  700,  0,  0,  0)   ' Get a Handle for this Font
    hHand = GetDlgItem(hDlg,  101)                                      ' Get Handle for a Control using its ID nr and its Parent Handle
    CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE)             ' Change font in Control using its handle and Font handle

    hFont = MakeFontEx("Cooper BlkIt BT", -13,  400,  0,  0,  0)   ' Get a Handle for this Font
    hHand = GetDlgItem(hDlg,  102)                                      ' Get Handle for a Control using its ID nr and its Parent Handle
    CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE)             ' Change font in Control using its handle and Font handle
  
    hFont = MakeFontEx("Microsoft Sans Serif", -11,  700,  0,  0,  0)   ' Get a Handle for this Font
    hHand = GetDlgItem(hDlg,  111)                                      ' Get Handle for a Control using its ID nr and its Parent Handle
    CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE)             ' Change font in Control using its handle and Font handle
  
    SetWindowPos hDlg, HWND_TOP, 0, 0, 0, 0, SWP_NoSize OR SWP_NoMove

   lStyle = SendMessage(hLv1, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
   lStyle = lStyle  OR  LVS_EX_GRIDLINES  OR LVS_EX_FULLROWSELECT
   SendMessage hLv1, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle
   LVcol1.psztext=VARPTR(Buf1)
   LVcol1.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM
   FOR xl = 1 TO  5                 ' For/Next to create header
     Buf1 = "Column " + STR$(xl)    ' assign column name  
     LVcol1.cx= 72                  ' assign GUI column width 
     LVcol1.isubitem=xl             ' column number  
     SendMessage hLv1, LVM_INSERTCOLUMN, xl, LVcol1 ' Send it to LV
   NEXT xl  
   xl = 1 : ff = FREEFILE                ' filenumber for creating & saving filler Data to file
   OPEN "\FREEBASIC\LLLVVVX1.ZZZ" FOR BINARY AS #ff 
     FOR yl=1 TO  20
       buff1="Item Nr" + STR$(xl)        ' Create Item filler Data for buffer
       PUT #ff,seek(ff), buff1                    ' Write column 1 filler DATA to file
       FOR xx = 1 TO  4
         buff1="Item Nr"+STR$(xx*100+xl)
         PUT #ff, SEEK(ff), buff1                  ' Write the rest to file
       NEXT xx   
       xl=xl+1   
     NEXT yl   
   CLOSE ff  
   LvItm1.mask=LVIF_TEXT             ' flag that specifies text
   LvItm1.psztext=VARPTR(Buf1)        ' Pointer to buffer
  xl = 0 : ff = FREEFILE              ' for filler DATA from file to LV
  OPEN "\FREEBASIC\LLLVVVX1.ZZZ" FOR BINARY AS #ff
   FOR yl=1 TO  20
      GET #ff, SEEK(ff), buf1             ' get first column item from file
      LvItm1.iitem=xl                 ' line number
      LvItm1.isubitem=0               ' number for column 1 subitem
      SendMessage hLv1, LVM_INSERTITEM, 0, LvItm1
      FOR xx = 1 TO  4
         LvItm1.isubitem=xx           ' number for rest of items
         GET #ff, SEEK(ff), buf1          ' get the rest of the items
         SendMessage hLv1, LVM_SETITEMTEXT, xl, LvItm1' send items to LV
      NEXT xx
      xl=xl+1
   NEXT yl
  CLOSE #FF

   lStyle = SendMessage(hLv2, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
   lStyle = lStyle  OR  LVS_EX_GRIDLINES  OR LVS_EX_FULLROWSELECT
   SendMessage hLv2, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle
   LVcol2.psztext=VARPTR(Buf2)
   LVcol2.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM
   RESTORE
   FOR xl = 0 TO 8             ' Setup to read Data for columns
      READ Buf2            ' read column name
      READ LVcol2.cx            ' read column GUI width
      LVcol2.isubitem=xl/2        ' Setup for sending to LV
      SendMessage hLv2, LVM_INSERTCOLUMN, xl/2, LVcol2 ' Send to LV
      xl=xl+1  
   NEXT xl
   xl=0  
   LvItm2.mask=LVIF_TEXT 
   LvItm2.psztext=VARPTR(Buf2) 
   FOR row=11 TO 30 STEP 5            ' Setup to Read from DATA
      LvItm2.iitem=xl                 ' line number 
      LvItm2.isubitem=0               ' number for column 1 subitem
      READ buf2
      SendMessage hLv2, LVM_INSERTITEM, xl, LvItm2
      FOR yl = 1 TO 4  
         LvItm2.isubitem = yl         ' number for rest of items
         READ buf2                    ' Read the rest of the items and
         SendMessage hLv2, LVM_SETITEMTEXT, xl, LvItm2 ' Send them to LV
      NEXT yl
      xl=xl+1
   NEXT 

   lStyle = SendMessage(hLv3, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
   lStyle = lStyle  OR  LVS_EX_GRIDLINES  OR LVS_EX_FULLROWSELECT
   SendMessage hLv3, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle
   LVcol3.psztext=VARPTR(Buf3)
   LVcol3.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM
   RESTORE
   FOR xl = 0 TO 8             ' Setup to read Data for columns
      READ Buf3            ' read column name
      READ LVcol3.cx            ' read column GUI width
      LVcol3.isubitem=xl/2        ' Setup for sending to LV
      SendMessage hLv3, LVM_INSERTCOLUMN, xl/2, LVcol3 ' Send to LV
      xl=xl+1  
   NEXT xl
   xl=0  
   LvItm3.mask=LVIF_TEXT 
   LvItm3.psztext=VARPTR(Buf3) 
    FOR row=0 TO 3
       LvItm3.iitem=xl                  ' line number
       LvItm3.isubitem=0                ' number for column 1 subitem
       buf3 = Aray3(row, 0)             ' Fill buffer with item from array
       SendMessage hLv3, LVM_INSERTITEM, xl, LvItm3 'Send it to LV
       FOR yl = 1 TO 4                  ' Do rest of the items
          LvItm3.isubitem = yl
          buf3 = Aray3(row,yl)
          SendMessage hLv3, LVM_SETITEMTEXT, xl, LvItm3
       NEXT yl
       xl=xl+1
    NEXT     
   lStyle = SendMessage(hLv4, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
   lStyle = lStyle  OR  LVS_EX_GRIDLINES  OR LVS_EX_FULLROWSELECT
   SendMessage hLv4, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle
   LVcol4.psztext=VARPTR(Buf4)
   LVcol4.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM
   Buf4 = "This is the header text for the listview"
   LVcol4.cx= 380              ' gui column width
   LVcol4.isubitem= 1          ' Column number
   SendMessage hLv4, LVM_INSERTCOLUMN, xl, LVcol4
   xl=1
   LvItm4.mask=LVIF_TEXT      ' flag that specifies text
   LvItm4.psztext=VARPTR(Buf4) ' Point to buffer
   FOR yl = 1 TO  20           ' number of lines to display
     buf4="Record Nr" + STR$(yl)+" " + STRING$(50,"X")' Create text for LV
     LvItm4.iitem=yl           ' get Line number
     SendMessage hLv4, LVM_INSERTITEM, 0, LvItm4' Send it to LV
   NEXT yl

  ELSEIF wMsg = WM_CTLCOLORSTATIC THEN
     IF LPARAM = GetDlgItem(hDlg,  103) AND hBmp1 THEN
        GetClientRect LPARAM, rc1               'label's size 
        GetObject hBmp1, LEN(bm1), bm1           'get bitmap's size 
        MemDC1 = CreateCompatibleDC(WPARAM)    'create DC for bitmap 
        SelectObject MemDC1, hBmp1  'select bitmap into DC, then paint it to label's dc
        StretchBlt WPARAM, 0, 0, rc1.nRight, rc1.nBottom, _ 
            MemDC1, 0, 0, bm1.bmWidth, bm1.bmHeight, SRCCOPY  'stretched to control 
        DeleteDC MemDC1                          'clean up temporary DC     
        ProcessWindow = GetStockObject(HOLLOW_BRUSH) 'return a hollow brush     
     END IF
  ELSEIF wMsg = WM_CTLCOLORBTN THEN
     IF LPARAM = GetDlgItem(hDlg,  105) AND hBmp4 THEN
        GetClientRect LPARAM, rc4               'label's size 
        GetObject hBmp4, LEN(bm4), bm4           'get bitmap's size 
        MemDC4 = CreateCompatibleDC(WPARAM)    'create DC for bitmap 
        SelectObject MemDC4, hBmp4  'select bitmap into DC, then paint it to label's dc
        StretchBlt WPARAM, 0, 0, rc4.nRight, rc4.nBottom, _ 
            MemDC4, 0, 0, bm4.bmWidth, bm4.bmHeight, SRCCOPY  'stretched to control 
        DeleteDC MemDC4                          'clean up temporary DC     
        ProcessWindow = GetStockObject(HOLLOW_BRUSH) 'return a hollow brush     
     END IF
  ELSEIF wMsg = WM_CTLColorEdit THEN      ' Message to color an Edit Control
     IF GetDlgCtrlId(lParam) =  111 THEN   '  Check its ID number
        SetTextColor Wparam, eFgColor1     '  Set the Forground Color
        SetBkColor Wparam, eBgColor1       '  Set the BackGround Color
        ProcessWindow = hEDbrush1 : EXIT FUNCTION
     END IF
  ELSEIF wMsg = WM_CTLColorListBox THEN   ' Message to color a ListBox 
     IF GetDlgCtrlId(lParam) =  102 THEN   '  Check its ID number
        SetTextColor Wparam, LFgColor1     '  Set the Forground to selected Color
        SetBkColor Wparam, LBgColor1       '  Set the BackGround to selected Color
        ProcessWindow = hLBbrush1 : EXIT FUNCTION
     END IF
  ELSEIF wMsg = WM_DESTROY THEN           ' Message sent when a Window is being destroyed
     DeleteObject hLBbrush1                '  Frees all system resources associated with this brush 
     DeleteObject hBmp1
     DeleteObject hBmp3
     DeleteObject hBmp4
     DeleteObject hBmp5
     DeleteObject hEDbrush1                '  Frees all system resources associated with this brush
  ELSEIF wMsg = WM_COMMAND THEN       ' Messages sent for Command Items
     wmID = wParam and &hFFFF         'Control ID  
     wmEvent = wParam shr 16          'Window Event 
                                       ' a control sends notification messages to its Parent
    IF wmEvent = BN_CLICKED THEN        ' Intercept a Mouse click
        IF wmID =  105 THEN        ' Retry Button
          MessageBox GetActiveWindow(), " Retry Button"," ", 0 OR MB_TASKMODAL
        ELSEIF wmID =  106 THEN
          MessageBox GetActiveWindow(), " Retry Button"," ", 0 OR MB_TASKMODAL
        ELSEIF wmID =  115 THEN
          GetWindowText GetDlgItem(hDlg,  111), EdTxt1, LEN( EdTxt1)    ' Put Edit Controls Text in a String
          MsbTx = msbTx + EdTxt1 + CHR$(13)+CHR$(10)
          GetWindowText GetDlgItem(hDlg,  112), RichTxt1, LEN( RichTxt1)    ' Put Edit Controls Text in a String
       
          hCtrl = GetDlgItem( hDlg,  120)                        ' Get CheckBox Handle using its ID number and Parent Handle
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Check if this Checkbox is checked
          IF check THEN MSBtx=MSBtx + " CheckBox nr1 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem( hDlg,  121)                        ' Get CheckBox Handle using its ID number and Parent Handle
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Check if this Checkbox is checked
          IF check THEN MSBtx=MSBtx + " CheckBox nr2 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem( hDlg,  122)                        ' Get CheckBox Handle using its ID number and Parent Handle
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Check if this Checkbox is checked
          IF check THEN MSBtx=MSBtx + " CheckBox nr3 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem( hDlg,  123)                        ' Get CheckBox Handle using its ID number and Parent Handle
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Check if this Checkbox is checked
          IF check THEN MSBtx=MSBtx + " CheckBox nr4 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem( hDlg,  124)                        ' Get CheckBox Handle using its ID number and Parent Handle
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Check if this Checkbox is checked
          IF check THEN MSBtx=MSBtx + " CheckBox nr5 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem(hDlg,  125)                ' Get Control Handle using dialog handle and Control ID
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Use handle to see if RadioButton is checked
          IF check THEN MSBtx=MSBtx + " RadioButton nr 1 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem(hDlg,  126)                ' Get Control Handle using dialog handle and Control ID
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Use handle to see if RadioButton is checked
          IF check THEN MSBtx=MSBtx + " RadioButton nr 2 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem(hDlg,  127)                ' Get Control Handle using dialog handle and Control ID
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Use handle to see if RadioButton is checked
          IF check THEN MSBtx=MSBtx + " RadioButton nr 3 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem(hDlg,  128)                ' Get Control Handle using dialog handle and Control ID
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Use handle to see if RadioButton is checked
          IF check THEN MSBtx=MSBtx + " RadioButton nr 4 was checked" + CHR$(13)+CHR$(10)
          hCtrl = GetDlgItem(hDlg,  129)                ' Get Control Handle using dialog handle and Control ID
          check = SendMessage(hCtrl, BM_GetCheck, 0, 0)  ' Use handle to see if RadioButton is checked
          IF check THEN MSBtx=MSBtx + " RadioButton nr 5 was checked" + CHR$(13)+CHR$(10)
          MessageBox GetActiveWindow(), BYVAL STRPTR(msbTX), "", MB_OK
          PostQuitMessage 0     'off switch
       END IF
    END IF
   
    IF wmID =  101 AND wmEvent = CBN_SELCHANGE THEN      ' Message sent to Parent thru WM_COMMAND when ComboBox Item is clicked
       hCtrl = GetDlgItem( hDlg,  101 )                                  ' Get Handle of Control, using handle of Dialog
       Index = SendMessage( hCtrl, CB_GETCURSEL, 0, 0 )                 ' Get Index of the currently selected Item
       Length = SendMessage( hCtrl,  CB_GETLBTEXTLEN, Index, 0 )        ' Get text length of selected Item
       IF Length < 1 THEN EXIT FUNCTION
       CbText1 = STRING$( Length, 0 )                                    ' Create Buffer in string that will hold the text
       SendMessage hCtrl, CB_GETLBTEXT, Index, BYVAL STRPTR( CbText1 )  ' Put selected text in the string
       CbText1 = "ComboBox  Nr1"+ CHR$(32) + CbText1                     ' String used in Example PBMAIN displaying item selected
       MessageBox GetActiveWindow(),BYVAL STRPTR( CbText1 ),"You Clicked on", MB_OK  ' MessageBox showing which Item selected
    END IF
   
    IF wmID =  102 AND wmEvent = LBN_SELCHANGE THEN      ' Message sent to Parent thru WM_COMMAND when ListBox Item is clicked
       hCtrl = GetDlgItem( hDlg,  102 )                                  ' Get Handle of Control, using handle of Dialog
       Index = SendMessage( hCtrl, LB_GETCURSEL, 0, 0 )  
       Length = SendMessage( hCtrl, LB_GETTEXTLEN, Index, 0 )           ' Get text length of selected Item
       IF Length < 1 THEN EXIT FUNCTION
       LbText1 = STRING$( Length, 0 )                                    ' Create Buffer in string that will hold the text
       SendMessage hCtrl, LB_GETTEXT, Index, BYVAL STRPTR( LbText1 )    ' Put selected text in the string
       LbText1 =  "ListBox  Nr1"+ CHR$(32) + LbText1                     ' String used in Example PBMAIN displaying item selected
       MessageBox GetActiveWindow(),BYVAL STRPTR( LbText1 ),"You Clicked on", MB_OK  ' MessageBox showing which Item selected
    END IF
   
  ELSEIF wMsg = WM_PAINT THEN   ' dialog is to be redrawn
    BeginPaint hDlg, ps  ' get device context to draw in
    RoundRectangle ps.hDC, 20,  22,  751,  525,  731,  503, _
    HS_DIAGCROSS , &HC0C0C0, PS_NULL , 1, 0
    RoundRectangle ps.hDC, 130,  132,  331,  415, 20, 20, _
    HS_BDIAGONAL , &H808080, PS_SOLID, 3, &HC0C0C0
    RoundRectangle ps.hDC, 430,  132,  651,  415, 20, 20, _
    HS_FDIAGONAL , &H808080, PS_SOLID, 1, 0
    EndPaint hDlg, ps            ' end painting
  ELSEIF wMsg = WM_CLOSE  THEN   ' Message from Clicking on system close Icon
    PostQuitMessage 0
  END IF
  ProcessWindow = DefWindowProc(hdlg, wMsg, wParam, lParam) 
 END FUNCTION

  FUNCTION WINMAIN (BYVAL hInstance     AS LONG, _
                    BYVAL hPrevInstance AS LONG, _         
                    szCmdLine           AS STRING, _   
                    BYVAL iCmdShow      AS LONG) AS LONG   
    DIM wMsg        AS Msg     
    DIM wcls        AS wndclass 
    DIM hWnd        AS unsigned LONG       
    DIM szpgmname   AS STRING, style as long
               
     szpgmname = "FreeBasic GUI Samples"
     WITH wcls
         .style         = CS_HREDRAW OR CS_VREDRAW OR CS_DBLCLKS
         .lpfnWndProc   = @ProcessWindow  'point to callback code 
         .cbClsExtra    = 0 
         .cbWndExtra    = 0 
         .hInstance     = hInstance 
         .hIcon         = LoadIcon( hInstance, "MAINICON" )
         .hCursor       = LoadCursor( NULL, BYVAL IDC_ARROW )
         .hbrBackground = GetStockObject(WHITE_BRUSH )
         .lpszMenuName  = NULL
         .lpszClassName = STRPTR(szpgmname)
     END WITH
     RegisterClass wcls
          style =   WS_VISIBLE OR WS_OVERLAPPEDWINDOW OR  DS_MODALFRAME
          hWnd = CreateWindowEx(0, szpgmname, "Regular SDK Example", _
                                Style,  10,  45,  780,  573, _
                                HWND_DESKTOP, NULL, hInstance, BYVAL NULL)
     WHILE (GetMessage(wMsg, NULL, 0, 0) <> false )   
         TranslateMessage wMsg
         DispatchMessage  wMsg
     WEND
     WinMain = wMsg.wParam
 END FUNCTION