Post Reply 
Social Buttons
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AurelEdit037
04-17-2018, 08:17 PM
Post: #1
AurelEdit037
lates version:

Code:
'*******************************************************************
' AurelEdit - v0.37, compiled with A043(progress) - win32
' Alternative code editor for Oxygen Basic - A043(progress)
' by Aurel 29.3.2018 ,sciLexer -> 1.6.7.0, awinh-037
'*******************************************************************
$ Filename "AurelEdit037.exe"
Include "RTL32.inc"
Include "awinh037.inc"
#LOOKAHEAD ' for procedures
Type NMHDR
      hwndFrom as INT
      idFrom   as INT
      code     as INT
  End Type

INT win,hsci,wabout,optWin,fWindow,theme
INT winstyle,aboutWindow,optWinOn,findWinOn,stFW1,stFW2,stfw1ID=600,stfw2ID=601
INT fb1,fb2,fb3,fb1ID=501,fb2ID=502,fb3ID=503,fwed1,fwed1ID=504,fwed2,fwed2ID=505
INT button0,button1,button2,button3,button4,button5,button6,button7,button8,bGoto
INT edit1,edit2,edit3,edit4,edit5,editOpt
INT Lbox,static1,static2,static3,static4,ststic6,static7,static8,static9
INT ed1ID,ed2ID,ed3ID,edoID
INT b0ID,b1ID,b2ID,b3ID,b4ID,b5ID,b6ID,b7ID,b8ID=0,b9ID,b10ID
INT bo1,bo2,bo3,bo4,bo5,bo5,bo6,bo7
INT bo1ID=151,bo2ID=152,bo3ID=153,bo4ID=154,bo5ID=155,bo6ID=156
INT LboxID = 300,LBhdc,LBhdcMEM,LBox2,Lbox2ID = 301,fnBox=1
INT st1ID,st2ID,st6ID,st7ID,st8ID
int x,y,w,h : string CRLF = chr(13)+chr(10)
INT reID
bGotoID = 120
b0ID=99
b1ID=100
b2ID=101
b3ID=102
b4ID=103
b5ID=104
b6ID=105
b7ID=106
b8ID=107
'print str(b8ID)
b9ID =108
b10ID=110
% SW_RESIZE = 2
'-----------------
ed1ID=200
ed2ID=201
ed3ID=202
ed4ID=203
ed5ID=204
edoID=205
'----------------
st1ID=350
st2ID=351
st3ID=352
st4ID=353
st6ID=356
st7ID=357
'##### SCINTILLA CONSTANTS ###################################
INT hlibsci,hsci 'scintilla handlers
INT bip

% SCE_O2_DEFAULT = 0
% SCE_O2_LINECOMMENT = 1
% SCE_O2_NUMBER = 2
% SCE_O2_KEYWORD0 = 3  
% SCE_O2_STRING = 4
% SCE_O2_PREPROCESSOR = 5
% SCE_O2_OPERATOR = 6
% SCE_O2_IDENTIFIER = 7
% SCE_O2_DATE = 8
% SCE_O2_STRINGEOL = 9
% SCE_O2_KEYWORD1 = 10
% SCE_O2_KEYWORD2 = 11
% SCE_O2_KEYWORD3 = 12

% SCLEX_O2BASIC = 40 'fb lexer used 75

% SCI_SETLEXER = 4001
% SCI_COLOURISE = 4003
% SCI_STYLESETFORE = 2051
% SCI_STYLESETBACK = 2052
% SCI_STYLECLEARALL = 2050
% SCI_SETKEYWORDS = 4005
% SCI_STYLESETFONT = 2056
% SCI_STYLESETSIZE = 2055
% SCI_STYLESETBOLD = 2053
% SCI_SETMARGINWIDTHN = 2242
% SCI_SETMARGINTYPEN = 2240
% SCI_SETMARGINSENSITIVEN = 2246
% SCI_SETSELBACK = 2068
% SCI_SetSelFore = 2067
% SCI_GOTOLINE = 2024
% SCI_LINELENGTH = 2350
% SCI_GETLINE = 2153
% SCI_GETLINECOUNT = 2154
% SCI_GETCURLINE= 2027
% SCI_SCROLLCARET=2169
% SCI_SETCURRENTPOS = 2141
% SCI_SETANCHOR=2026
% SCI_SEARCHANCHOR=2366
% SCI_GETSELECTIONSTART=2143
'--------------------------------
% SCFIND_REGEXP=0x00200000
% SCFIND_WHOLEWORD=2
% SCFIND_MATCHCASE=4
% SCI_SEARCHNEXT=2367
% SCI_SEARCHPREV=2368
% SCI_REPLACESEL = 2170
'--------------------------------
% SCI_GOTOPOS=2025
% SCI_GETTEXT = 2182
% SCI_SETTEXT = 2181
% SCI_GETTEXTLENGTH = 2183

% SCI_CLEAR=2180
% SCI_CLEARALL=2004
% SCI_BRACEBADLIGHT=2352
% SCI_BRACEHIGHLIGHT=2351
% SCI_BRACEMATCH=2353
% SCI_GETSELECTIONEND=2145
% SCI_SETSELECTIONEND=2144
% SCI_SETCARETLINEVISIBLE=2096
% SCI_SETCARETFORE = 2069
% SCI_SETCARETLINEBACK = 2098
% SCI_SCROLLCARET=2169
% SCI_UNDO = 2176
% SCI_CUT = 2177
% SCI_COPY = 2178
% SCI_PASTE = 2179
% SCI_SELECTALL = 2013
% SCI_SETSAVEPOINT = 2014
% SCI_EMPTYUNDOBUFFER = 2175

% SC_MARGIN_SYMBOL = 0
% SC_MARGIN_NUMBER = 1
% SCI_SETMARGINMASKN = 2244

% TCN_SELCHANGE = -551
% SS_LEFT = 0x0

'init color strings
bstring sciBlue,sciRed,sciBrown
'Gosub oxyKeywords 'load oxygen basic keywords
'- tree view -------------
INT htv
'--------------------
STRING cOption="-c " ' default copt - gui No console "-c " for oxygen
STRING fName
char tx[500000]
string gxName="\gxo2.exe"   ' for oxygen change path to \gxo2.exe
char cdPath[256]
'string cdPath
GetCurrentDir 256,strptr cdPath
'GetTempPath ( 256, strptr cdPath)
cdPath = cdPath + gxName
'MsgBox cdPath , "Compiler Path...OK!"
'-------------------------------------
'global file name
STRING fileName
INT tab
'--------------------------------------
'loadbmp
'##################################################
INT bmpB0,bmpB1,bmpB2,bmpB3,bmpB4,bmpB5,bmpB6,bmpB7,bmpB8
bmpB1 = LoadImage(0,"AELogo.bmp",0,400,300,16)
'......................................................

'##################################################
x=100:y=100:w=800:h=540
winstyle = WS_CLIPCHILDREN | WS_MINMAXSIZE
'create window **************************************************
win = SETWINDOW("AurelEdit:",x,y,w,h,0,winstyle)
'InitDrawing(win)
    'WindowColor( win, 220, 230, 250)
'****************************************************************
bGoto = SetButton(win,440,4,60,24,"GOTO-->",0x50000000,0x200,bGotoID)
edit2 = SetEditBox(win,504,5,48,22,"LINE",0x50004000,0x200,ed2ID)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'create single-line edit control
edit1 = SetEditBox(win,160,34,560,20,"path",0x50004000,0x200,ed1ID)
'tab item
'edit3 = SetEditBox(win,30,30,18,20,"64",0x50004000,0x200,ed3ID)
'tab name
edit4 = SetEditBox(win,8,34,134,20,"Functions",0x50004000,0x200,ed4ID)
'create listbox -> Functions/Subs  ================================
INT lbx,lby,lbw,lbh
lbx=6:lby=58:lbw=168:lbh=414
Lbox = SetListBox(win,lbx,lby,lbw,lbh,"",0x50000140|CTLISTNOTIFY|WS_VSCROLL,0x200,LboxID)
ControlFont(LBox, 15, 7, 300, "Courier New")
Dim LBitems[2000] as INT
Dim LBitem as INT
'create listbox -> ASCI Table  ===================================
Lbox2 = SetListBox(win,lbx,lby,lbw,lbh,"",0x50000140|CTLISTNOTIFY|WS_VSCROLL,0x200,Lbox2ID)
ControlFont(LBox2, 16, 8, 500, "Courier New")
ShowWindow LBox2,0  ' hide AsciTable Box -> 0 HIDE
CreateAsciTable()   ' build asci table
'=================================================================
'create static control
'static1 = SetStatic(win,6,32,24,13,"TAB:",0,0,st1ID)
'button  set compiler gxo2.exe path-------------------------------------------
static6 = SetButton(win,554,4,38,23,"GXO2",0,0x200,st6ID) ' gxo2 path button
ControlFont(static6, 16, 7, 500, "Courier New")
'option edit box
editOpt = SetEditBox(win,600,5,140,22,"add compiler Path",0x50004000,0x200,edoID)

'set sci dimensions
'INT rx,ry,rw,rh
'rx=160:ry=80:rw=466:rh=360

' TOOLBAR -----------------------------------------------------------
TBBUTTON tbb
TOOLINFO tti
Dim AddBmp as TBADDBITMAP
' setting common controls mode
Dim iccx as INITCOMMONCONTROLSEX_TYPE
  iccx.dwSize = sizeOf(icxx)
  iccx.dwICC  = 4
' initialize common controls 32
InitCommonControlsEx( iccx )

INT htbar
INT toolID = 99
'add handlers
INT  hImageList,hImage
'create toolbar
htbar = SetToolbar (win, 0,  0, toolID)
'def NMHDR header
NMHDR phdr
'set toolbar size
MoveWindow(htbar, 0, 0, 434, 32,0)
' Set the imagelist used with default images
  hImageList = ImageList_Create(24, 24, ILC_MASK OR ILC_COLOR8, 1, 0)
  hImage = LoadImage(0, "rCodetb24.bmp", 0, 336, 24, 24)
  ImageList_AddMasked (hImageList,hImage, RGB(231,223,231))
  DeleteObject hImage
'set image list  
SendMessage htbar, 1072,0, byval hImageList
'set button structure size
SendMessage htbar , 1054, sizeof(tbb), NULL

'TBUTTONS & TOOLTIPS -------------------------------------------------
INT tooltip
tooltip = SetToolTip(htbar)

AddTButton(htbar, 100, 0, "New File")
AddTButton(htbar, 101, 1, "Open File")
AddTButton(htbar, 102, 2, "Save As...")
AddTButton(htbar, 103, 3, "Save File")
AddTButton(htbar, 104, 4, "Close File")
AddTButton(htbar, 105, 5, "ASCI Table")
AddTButton(htbar, 106, 6, "Parser")
AddTButton(htbar, 107, 7, "Compile::")
AddTButton(htbar, 108, 8, "Run")
AddTButton(htbar, 109, 9, "Web Site")
AddTButton(htbar, 110, 10, "Info")
AddTButton(htbar, 111, 11, "Find")
AddTButton(htbar, 112, 12, "Options")
AddTButton(htbar, 113, 13, "Help")

'///// MENUS /////////////////////////////////////////////////////////
'Appendmenu hMenu , wFlags, wIDNewItem, lpNewItem
INT mainMenu,submenu1,submenu2
INT mImg1 = LoadImage(0, "iNew.bmp", 0, 16, 16, 24)
INT mImg2 = LoadImage(0, "iOpen.bmp", 0, 16, 16, 24)
INT mImg3 = LoadImage(0, "iSave.bmp", 0, 16, 16, 24)
INT mImg4 = LoadImage(0, "iQuit.bmp", 0, 16, 16, 24)
INT mImg5 = LoadImage(0, "iUndo.bmp", 0, 16, 16, 24)
INT mImg6 = LoadImage(0, "iCut.bmp", 0, 16, 16, 24)
INT mImg7 = LoadImage(0, "iCopy.bmp", 0, 16, 16, 24)
INT mImg8 = LoadImage(0, "iPaste.bmp", 0, 16, 16, 24)
INT mImg9 = LoadImage(0, "iSelectAll.bmp", 0, 16, 16, 24)
INT mImg10 = LoadImage(0, "iCompile.bmp", 0, 16, 16, 24)
INT mImg11 = LoadImage(0, "iBuild.bmp", 0, 16, 16, 24)
INT mImg12 = LoadImage(0, "iRun.bmp", 0, 16, 16, 24)
INT mImg13 = LoadImage(0, "iAsDLL.bmp", 0, 16, 16, 24)
INT mImg14 = LoadImage(0, "iAddGUI.bmp", 0, 16, 16, 24)


mainMenu = CreateMenu()
'...............................................
submenu1 = CreatePopupMenu ()
'addsub menu items with ID
    AppendMenu (submenu1, 0,120,strptr "New")
        SetMenuItemBitmaps(submenu1, 0,MF_BYPOSITION , mImg1, 0) 'add menu item bitmap
    AppendMenu (submenu1,0,121,strptr "Open")
        SetMenuItemBitmaps(submenu1, 1,MF_BYPOSITION , mImg2, 0)
    AppendMenu (submenu1,0,122,strptr "Save")
        SetMenuItemBitmaps(submenu1, 2,MF_BYPOSITION , mImg3, 0)
    AppendMenu (submenu1,0,123,strptr "Quit")
        SetMenuItemBitmaps(submenu1, 3,MF_BYPOSITION , mImg4, 0)
'set submwnu1 on main menu
AppendMenu (mainMenu,16,submenu1,strptr "File")
'...............................................
submenu2 = CreatePopupMenu ()
'addsub menu items with ID
    AppendMenu (submenu2,0,124,strptr "Undo")
        SetMenuItemBitmaps(submenu2, 0,MF_BYPOSITION , mImg5, 0)    
    AppendMenu (submenu2,0,125,strptr "Cut")
        SetMenuItemBitmaps(submenu2, 1,MF_BYPOSITION , mImg6, 0)
    AppendMenu (submenu2,0,126,strptr "Copy")
        SetMenuItemBitmaps(submenu2, 2,MF_BYPOSITION , mImg7, 0)
    AppendMenu (submenu2,0,127,strptr "Paste")
        SetMenuItemBitmaps(submenu2, 3,MF_BYPOSITION , mImg8, 0)
    AppendMenu (submenu2,0,128,strptr "Select All")
        SetMenuItemBitmaps(submenu2, 4,MF_BYPOSITION , mImg9, 0)

'set submwnu1 on main menu
AppendMenu (mainMenu,16,submenu2,strptr "Edit")
'...............................................
submenu3 = CreatePopupMenu ()
'addsub menu items with ID
    AppendMenu (submenu3,0,129,strptr "Compile")
        SetMenuItemBitmaps(submenu3, 0,MF_BYPOSITION , mImg10, 0)    
    AppendMenu (submenu3,0,130,strptr "Build")
        SetMenuItemBitmaps(submenu3, 1,MF_BYPOSITION , mImg11, 0)
    AppendMenu (submenu3,0,131,strptr "Run")
        SetMenuItemBitmaps(submenu3, 2,MF_BYPOSITION , mImg12, 0)
    AppendMenu (submenu3,0,132,strptr "As DLL")
        SetMenuItemBitmaps(submenu3, 3,MF_BYPOSITION , mImg13, 0)
    AppendMenu (submenu3,0,133,strptr "Add GUI")
        SetMenuItemBitmaps(submenu3, 4,MF_BYPOSITION , mImg14, 0)

'set submwnu1 on main menu
AppendMenu (mainMenu,16,submenu3,strptr "Compile")
'...............................................
SetMenu  win ,mainMenu



'TAB control ---------------------------------------------------------
INT tc,tcID=500
tc = SetTabControl(win,180,58,598,26,0,0,tcID)

indexbase 0
INT tbArr[64],tabIndex,ai
STRING tabName[64],tabValue[64]
'reset tab info array >>>>>
For ai = 0 To 63
tabName[ai]  = ""
tabValue[ai] = ""
Next ai
'<<<<<<<<<<<<<<<<<<<<<<<<<<
tabIndex = -1
'add first tab.. index 0
CreateNewTab()

'Status bar ---------------------------------
INT status
status = SetStatusBar ( win, "Status-Bar...",0,0)
'--------------------------------------------------------------------
'nt hdc = getdc(win)
'nt iBrush = CreateSolidBrush (0xff0000)
'SelectObject Hdc, iBrush
'Rectangle Hdc, 0, 0, w,h
'SetBkColor hdc,ibrush
'ReleaseDC win,hdc

'Create Scintilla control ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
INT hlibsci,hsci
hlibsci = LoadLibrary "SciLexer.dll"
'print str(hlibsci)
INT rx,ry,rw,rh,ext,sci_style,sciID = 400
rx=180: ry=84 : rw=598 : rh=390 : ext=0x200
'rx=180: ry=80 : rw=540 : rh=340
sci_style =  WS_CHILD | WS_VISIBLE | ES_SUNKEN
hsci = CreateWindowEx(ext,"Scintilla","",sci_style,rx,ry,rw,rh,win,sciID,0,0)
'UpdateWindow hsci
'basic setings...
'SCLEX_O2BASIC
SENDMESSAGE(hsci, SCI_SETLEXER, 75 , 0)
'add oxyWords
oxyKeywords()
'set sci backColor
SENDMESSAGE(hsci, SCI_STYLESETBACK, 0,rgb(255,255,255)) 'white
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)

SENDMESSAGE(hsci, SCI_SETKEYWORDS, 0, strptr sciBlue )  :  'blue
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 1, strptr sciRed  )   :  'red
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 2, strptr  sciBrown )
'set font
For i = 0 to 12
    SENDMESSAGE (hsci,SCI_STYLESETFONT, i,strptr "Courier New")
    SENDMESSAGE (hsci,SCI_STYLESETSIZE, i,  10)
Next i
'set keywords group colors
'SENDMESSAGE(hsci, SCI_SETKEYWORDS, 0, strptr sciBlue )  :  'blue
'SENDMESSAGE(hsci, SCI_SETKEYWORDS, 1, strptr sciRed  )   :  'red
'SENDMESSAGE(hsci, SCI_SETKEYWORDS, 2,strptr  sciBrown ) :  'brown

'////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
'set SELECTIONED LINES COLOR
SendMessage hsci,SCI_SetSelBack,1, RGB(49, 106, 197)
SendMessage hsci,SCI_SetSelFore,1, RGB(255, 235, 225)
'caret line
'SendMessage hsci,SCI_SETCARETFORE,0xFFFFFF,0 'white carret
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(235,235,255),0
'SENDMESSAGE hsci,SCI_SETCARETFORE,RGB(115,115,255),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0


'--------------------------------------------------------------------
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DEFAULT,RGB(200,0,0))              '0 default
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_LINECOMMENT,rgb(0,120,0))          '1 line comment
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_NUMBER, rgb(160,0,0))             '2 number
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD0,RGB(0,0,200))            '3 keyword0 - blue
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRING,RGB(150,0,150))            '4 string
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_PREPROCESSOR,RGB(0,0,250))        '5 preproc
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_OPERATOR,rgb(180,0,0))            '6 operator
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_IDENTIFIER,RGB(0,0,0))             '7 identifier/var names
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DATE,RGB(0,0,0))                  '8 date
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRINGEOL,rgb(0,100,0))            '9 string EOL
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD1,RGB(220,0,0) )            '10 keyword1 -work red
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD2,RGB(160,80,0))            '11 keyword2 - as brown
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD3,RGB(220,0,220))            '12 keyword3 - magenta    

'->->->->->->->->->->->->->->->->->->
SetFocus win
  '
  WHILE GetMessage (wm,0,0,0)<>0
    TranslateMessage wm
    DispatchMessage wm
WEND

'<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-

Function WndProc(byval hWnd as INT,byval wMsg as INT, byval wParam as INT,byval lparam as sys) as sys callback


SELECT hWnd
'-----------
CASE win
'----------
Select wMsg

CASE WM_CREATE
'------------------
'------------------
CASE WM_DESTROY
PostQuitMessage 0
'------------------
case WM_SIZE
GetSize(win,x,y,w,h)
MoveWindow(hsci,180,80,(w-rw/2)+114,(h-76)-32 ,1)

MoveWindow(edit1,180,34,(w-rw/2)+84,20 ,1)
MoveWindow(Lbox,6,58,lbw,(h-76)-6 ,1)
MoveWindow(Lbox2,6,58,lbw,(h-76)-6 ,1)
MoveWindow(tc,180,55,(w-rw/2)+116,24,1)
'fix statusbar position on botom of window
MoveWindow ( status,0,(h-32),w,h,1)

'-------------------------------------------------------------
CASE WM_NOTIFY
  NMHDR notify at lparam
  Select notify.code
    case -552  'tcn_selchanging
    'leaving tab
    'int p = SendMessage(tc,TCM_GETCURSEL,0,0)
    'print "LEAVING-TAB->" + str(p)
    autoSave()

    case -551  'tcn_selchange
    'selected tab
    'int i = SendMessage(tc,TCM_GETCURSEL,0,0)
    'print "TAB:" + str(i)
     FindTab()

End Select


CASE WM_CTLCOLORLISTBOX
LBhdc = getDC(LBox)
If theme = 3 ' default
    INT lbColor = CreateSolidBrush(RGB(255,255,255))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(255,255,255))
    SetTextColor( wparam,RGB(20,45,125))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

If theme = 1 ' light blue - clear sea
    INT lbColor = CreateSolidBrush(RGB(240,240,255))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(240,240,255))
    SetTextColor( wparam,RGB(0,5,0))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

If theme = 2 ' soft yellow - soft desert
    INT lbColor = CreateSolidBrush(RGB(243,242,214))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(243,242,214))
    SetTextColor( wparam,RGB(0,5,0))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

If theme = 4 ' soft yellow - soft desert
    INT lbColor = CreateSolidBrush(RGB(43,42,54))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(43,42,54))
    SetTextColor( wparam,RGB(240,240,254))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

'-------------------------------------------------------------
    CASE WM_COMMAND    
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message

    Select controlID
     CASE LBoxID
     'doubleClick listbox item -> jump to line
        IF notifycode = LBN_DBLCLICK
        'pos=GETSELECTED(w1,3)
         pos = SendMessage Lbox,LB_GETCURSEL,0,0
        
        For n=0 TO pos    
            IF pos = n
            fnpos=LBitems[pos]
            SetFocus hsci
            SendMessage hsci,SCI_GOTOLINE,fnpos,0
            END IF
        Next n
        pos=0
        END IF

     'get file from clicked tab
    'CASE tcID
    
    

       CASE b1ID
        'NEW
        If notifycode=0
            autoSave() 'save current content
            SendMessage hsci,SCI_SETTEXT,0,strptr ""   'clear scintila
              NewTab()  'create new tab      
        End If

       CASE b2ID
        'OPEN
        If notifycode=0  
            doOpen()
            fnParser()
        End If

       CASE b3ID
          'SAVE AS..
         If notifycode=0
        doSave()    
        End If

      CASE b4ID
        If notifycode=0
        autoSave()
         'Beep 1200,60
        End If

      CASE b5ID
        If notifycode=0
        doClose()
         'Beep 800,50: Beep 600,50: Beep 400,50
        End If

      CASE b6ID
        If notifycode=0
            If fnBox = 1
             SetText (edit4,"ASCI Table:")
              ShowWindow LBox,0 : fnBox = 0' hide function listbox
              ShowWindow LBox2,1           ' show Asictable listbox2
              return 0
            End if
           If fnBox = 0
             SetText (edit4,"Function List:")
              ShowWindow LBox2,0 : fnBox = 1  ' hide AsciTable list
              ShowWindow LBox,1               ' show function list
              return 0
            End if
        End If

      CASE b7ID ' *parser
        If notifycode=0
        MsgBox "Not Implemented Yet!" , "@Parser"
        End If

      CASE 107  'compile
        If notifycode=0
        doCompile()        
        End If

      CASE b9ID ' run
        If notifycode=0
        doRun()
        End If

      CASE 110 'about
        If notifycode=0
        'show About window
         AboutBox()
        End If

     CASE 109 ' web site
      If notifycode=0
        MsgBox "Not Implemented Yet!" , "@Web Site"
      End If

      CASE 111 ' open FindWindow
         If notifycode = 0
           FindWindow()
         End If

      CASE 112 ' Option Window
        If notifycode=0
        OptWindow()
        End If

      CASE 113 ' Help
        If notifycode=0
        print "Help"
        End If

     CASE st6ID ' set compiler path [ gxo2.exe ]
      If notifycode = 0
      cdPath = GetText(editOpt)
      MsgBox cdPath , "Compiler Path:"
      End If

    CASE bGotoID
     JumpToLine()
  
    
End Select

' [[[ SELECT ->  MENU  ID-s  / WPARAM  ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
   SELECT wParam
      
        Case 120  'new
            autoSave() 'save current content
            SendMessage hsci,SCI_SETTEXT,0,strptr ""   'clear scintila
            NewTab()  'create new tab      

        Case 121  'open
            doOpen()
            fnParser()

        Case 122 'save as
            doSave()  

        Case 123 'Quit
            SendMessage win,WM_CLOSE,0,0
          ExitProcess 0

      'menu EDIT
        Case 124 'undo
       SendMessage hsci,SCI_UNDO,0,0

        Case 125 'cut
       SendMessage hsci,SCI_CUT,0,0

        Case 126 'copy
       SendMessage hsci,SCI_COPY,0,0

        Case 127 'paste
       SendMessage hsci,SCI_PASTE,0,0

        Case 128 'select all
       SendMessage hsci,SCI_SELECTALL,0,0

       'menu COMPILE
        Case 129 'compile
            doCompile()

        Case 130
          'doBuild()  'build
         MsgBox "Not Implemented Yet!" , "@Build"

        Case 131 'run
            doRun()

        Case 132 ' as DLL
            'doAsDLL()

        Case 132 'addGUI
            'doAddGUI()

   END SELECT



END SELECT
'------------------------------


'-----------------------
CASE wabout
'----------------------
Select wMsg
CASE WM_CLOSE
  IF aboutWindow = 1
    CloseWindow(wabout)
     aboutWindow=0
  END IF

End Select
'---------------------
CASE optWin   'option window events
'..........................
Select wMsg
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CASE WM_COMMAND
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message

    Select controlID
    CASE bo1ID
        'theme Clear Sea
        If notifycode=0
        MsgBox "You select theme -> CLEAR SEA", "THEME"
         theme = 1 : SetTheme1(): ControlFont (LBox, 15,7, 0, "Courier New")
          ControlFont(LBox2, 18, 9, 0, "Courier New")    
        End If
     CASE bo2ID
         'theme Soft Desert
        If notifycode=0
        MsgBox "You select theme -> SOFT DESERT" , "THEME"
         theme = 2 : SetTheme2(): ControlFont (LBox, 16,8, 0, "Courier New")
         ControlFont(LBox2, 18, 9, 0, "Courier New")    
        End If

    CASE bo3ID
         'theme Default
        If notifycode=0
        MsgBox "You select theme -> DEFAULT" , "THEME"
         theme = 3 : SetTheme3(): ControlFont (LBox, 16,8, 0, "Courier New")
         ControlFont(LBox2, 18, 9, 0, "Courier New"):UpdateWindow LBox2
        End If

    CASE bo4ID
         'theme Dark Moon
        If notifycode=0
        MsgBox "You select theme -> DARK MOON" ,"THEME"
         theme = 4 : SetTheme4(): ControlFont (LBox, 16,8, 0,"Lucida Console")
         ControlFont (LBox2, 17,9, 0,"Lucida Console"):UpdateWindow Lbox2
        End If

    End Select
    
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CASE WM_CLOSE
  IF optWinOn = 1
    CloseWindow(optWin)
     optWinOn=0
  END IF
End Select
'////////////// FIND WINDOW  ///////////////////////////////////
CASE fWindow
'///////////
Select wMsg ' for Find/Replace toolwindow
'////////////////////////////////////////////////////////////
CASE WM_COMMAND
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message

    Select controlID

    CASE fb1ID
        'Find-next...
        If notifycode=0
        FindNext()        
        End If
     CASE fb2ID
         'ReplaceOnce
        If notifycode=0
        ReplaceOnce(0)          
        End If
    CASE fb3ID
        If notifycode=0
         ReplaceAll()
         End If


    End Select

'.............................
CASE WM_CLOSE
  IF findWinOn = 1
    CloseWindow(fWindow) ' close [Find/Replace] toolwindow
     findWinOn = 0
  END IF
End Select
'////////////////////////////////////////////////////////
'CASE Lbox
    'select  wMsg
        'case wm_paint
        'BitBlt(hDC, 0, 0, ww, hh, hdcMem, 0, 0, SRCCOPY)
        'InvalidateRect(Lbox, 1, 0)

    'end select

END SELECT


FUNCTION = DefWindowProc hwnd,wMsg,wParam,lParam


END FUNCTION


'----------------------------------------------------------
'>>>  OPEN FILE DIALOG   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub doOpen

INT hsize=0
'bstring tx="" ' use bstring for text on scintilla
string dir=""
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = "All files "+sep+"*.*"+sep+"o2 files "+sep+"*.o2bas"
title="Open File... "
hwnd=0
fName = FileDialog(dir,filter,title,0,0,"o2bas")
'print "FNAME:" + fName
fileName = fName
'IF fName = "" Then Return
SendMessage edit1,WM_SETTEXT, 0, byval strptr(fname)

SendMessage status,WM_SETTEXT,0, byval strptr(fName)
tx =  GetFile fName
SendMessage hsci,SCI_SETTEXT, 0, byval strptr(tx)
SendMessage hsci,SCI_SETSAVEPOINT, 0, 0
SendMessage hsci,SCI_EMPTYUNDOBUFFER,0,0

If fName <> ""
FindNewTab()
End If

End Sub

'************************************************************
'save file
'************************************************************
SUB doSave
INT hsize=0,found,c
string dir="",filePath
'char tx[32768]
'bstring tx
string ext=".o2bas"

filter= "OB Files (*.o2bas)"
title="Save File... "    'for Oxygen change to *.o2bas
hwnd=0
fName = FileDialog(dir,filter,title,0,1,"o2bas")

'print fname
If fName="" then Return
  IF RightS(fname,6) <> ".o2bas"  'for Oxygen set number to 6 , .o2bas
    fname = fname + ext
  END IF
'print fname
hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
'exit if empty
IF hsize = 0
print "ERROR: -> Document is Empty!"
Return    ' ->->->
END IF

'SendMessage hsci,SCI_GETTEXT,hsize+1,tx
'PutFile fName,tx
'SendMessage(hsci, SCI_SETSAVEPOINT, 0, 0)
'filePath = fName

found=0
INT tab = GetSelectedTab(tc)
string tName = GetTabText(tc,tab)
tName = Trim(tName)
'print "SAVE:tabname;" + tname
'if file exists ...............................................................
For c = 0 To 63
    IF tName <> "*New"
        IF tabName[c] = tName
           filePath = tabValue[c]
            'SetTabText(tc,tab,tName)  'update tab name
             'ReOpenFile()             'reOpen file from filePath
             fnParser()               'parse code
            found=1                  'confirm found    
             Exit For      
        END IF
   END IF
Next c
'if is tab *New ...............................................................
IF found = 0
print "is there tab NEW?"
For c = 0 To 63
        IF tabName[c] = "*New"
            filePath = Trim(fName)
           tabValue[c] = filePath
              tName = GetFileName(filePath)   'extract file name from file Path
            SetTabText(tc,tab,tName)        'update tab name
              tabName[c] = tName              'update tab name element
             'ReOpenFile()                    'reOpen file from filePath
             fnParser()                       'parse code
            found=1                          'confirm found    
             Exit For      
        END IF
Next c
END IF
'if filename not exists and there is no tab *New -> create NEW tab
'IF found = 0
'END IF

IF found = 1
    SendMessage hsci,SCI_GETTEXT,hsize+1,tx
    PutFile filePath,tx
    Return
ELSE
    Print "ERROR: SAVE! - File Not Found!" + chr(10) + "Create [*New] Document!"
    Return
END IF


END SUB
'*************************************************************
'>>  AUTO SAVE
SUB autoSave
INT hsize,tab,found,c
STRING tName,filePath
'print "AutoSave->FNAME:" + fName

hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
'exit if empty
IF hsize = 0 Then Return    ' ->->->
found=0
INT tab = GetSelectedTab(tc)
string tName = GetTabText(tc,tab)
tName = Trim(tName)
'search...
For c = 0 To 63
        IF tabName[c] = tName
           filePath = tabValue[c]
            'SetTabText(tc,tab,tName)  'update tab name
             'ReOpenFile()             'reOpen file from filePath
             'fnParser()               'parse code
            found=1                  'confirm found    
            
             Exit For      
        END IF
Next c

IF found = 1
    SendMessage hsci,SCI_GETTEXT,hsize+1,strptr tx
    PutFile filePath,tx
    Return
ELSE
    Print "ERROR: AUTOSAVE! - File Not Found!"
    Return
END IF

END SUB
'*************************************************************
'do Close
SUB doClose
INT tab,tabCount,c
STRING tName
'clear sci control
SendMessage hsci,SCI_SETTEXT,0,strptr ""
tabCount=GetTabCount(tc)
'print "TAB COUNT:" tabCount
IF tabCount > 0
    tab = GetSelectedTab(tc)
    'print "SELECTED TAB:" + str(tab)
        IF tab > -1 then
         tName = GetTabText(tc,tab)
         tName = Trim(tName) : DeleteTab(tc,tab)   ' delete selected tab        
             For c = 0 To 63
               IF  tabName[c] = tName         
                  tabName[c] = ""      ' clear
                    tabValue[c] = ""     ' clear            
                    Exit For
                 END IF
             Next c
        
             'print "TAB.INDEX:" + str(tabIndex)
             tabIndex = tabIndex -1
             SendMessage tc,TCM_SETCURSEL,tabIndex, 0
            Findtab()
        End if
END IF
IF tabCount = 0
CreateNewTab()
END IF

END SUB
'*************************************************************
'do Copy / paste
SUB doCopy
SendMessage hsci,SCI_COPY,0,0
END SUB
'-------------------------------------------------------------
SUB doPaste
SendMessage hsci,SCI_PASTE,0,0
END SUB
'----------------------------------------------------------

SUB doCompile
char ln[256]
string fn=""
SendMessage edit1,WM_GETTEXT,256,strptr ln
fn = Trim(ln)
'print "FN:" + fn
IF LEN(fn) < 1
MsgBox "File Not Open!","Error::File"
Return
End If
int sRet
autosave()
'(sys hwnd, string lpOperation, lpFile, lpParameters, lpDirectory, sys nShowCmd) as sys
sRet = ShellExecute(0,"open", cdPath,"-c" + fName,"" , 5) ' if work sRet = 42
If sRet = 2 then MsgBox "Compiler gxo2 Not Found!"+ crlf + "Enter new compiler path!" , "GXO2 Path"
'sRet = ShellExecute 0,"open","gxo2.exe","-c "+ fn,"",5
'sRet = ShellExecute 0,"open",cdPath,cOption & chr(34) & fName & chr(34),"",5 'fb

END SUB
'---------------------------------------------------------
' RUN >>>>>>>>>>>>>>>>
SUB doRun
STRING exepath=""
INT dotpos=0
dotpos=INSTR(fName,".")
exepath = Mid(fName,1,dotpos-1)
exepath=exepath + ".exe"
'MESSAGEBOX 0,"path:"+exepath,"OK"
ShellExecute(0,"open", exepath, "","" , 5)
END SUB

'--------------------------------------------------------
SUB GetFileName (src as string) as String

String fname,sign1,name
INT dotpos,bslashpos,nameLen
'print "ShowFName::TABCOUNT->:"+str(tabcount)
'C:\OxygenBasic\examples\GUI\SciEditor\WinControls.o2bas
src=Trim(src)
bslashpos = FieldCount(src,chr(92))
name = Mid(src,bslashpos+1,LEN(src))
dotpos = INSTR(name,".")
'print "DOTP:" + str(dotpos)
'nameLen = LEN(src)-(LEN(src)-dotpos)

name = Mid(name,1,dotpos-1)
'
'print "ShowName->:" + name

Return name
END SUB
'-----------------------------------------------------------
SUB JumpToLine
INT tmpLine : char ln[100]
SendMessage edit2,WM_GETTEXT,100,ln
tmpLine = VAL (ln)-1
SetFocus hsci
SendMessage hsci,SCI_GOTOLINE,tmpLine,0
END SUB
'-----------------------------------------------------------
SUB FieldCount(source As String,delimiter As String) as Int
    Dim delpos,nexpos,count As Int
    'delimiter=chr$(92)
    count=1
    delpos=1
    nexpos=InStr(source,delimiter)
    While nexpos
        delpos=nexpos
        nexpos=InStr(delpos+1,source,delimiter)
        count++
    Wend
    RETURN delpos
END SUB  

'-----------------------------------------------------------------

SUB FindNewTab
INT found,tempTab,c,pos
STRING tName,tempName,tabNum
pos = GetSelectedTab(tc)
found=0
'search for tab -> *New
For c = 0 To 63
    IF  tabName[c] = "*New"         
        tabValue[c] = filename
         tName = GetFileName(filename) ' extract file name from filePath/tab name/
         tabName[c] = tName             ' update tab name
         SetTabText(tc,pos,tName)       ' set updated as tab text
         fnParser()
         found=1
         Exit For            
    END IF
Next c
            
IF found=1
'print "tab *New found!->RETURN"
Return   'ret    
end if
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      


IF found=1
'print "tabname already exists!->RETURN"
Return   'ret
end if
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'print" ELSE -> create new tab ...."
'print "ELSE->CREATE NEW TAB"

tabIndex=tabIndex+1  ' increase tab count
AddTab( tc, tabIndex, "*New")
SendMessage tc,TCM_SETCURSEL,tabIndex,0  ' set newTab as SELECTED

IF found=0
INT epos = -1
'search for first empty tabName in tabName[]
        For c = 0 To 63
            IF  tabName[c] = ""         
                tabName[c] = "*New" ' set first empty place with *New
                  tabValue[c] = ""    ' reset
                  epos=c              
                  Exit For
              END IF
         Next c
'-------------------------------------------
IF epos = -1
print "ERROR: File List Out Of Range! -> 63"
RETURN
END IF
'------------------------------------------
'if is OK update new tab !
pos = GetSelectedTab(tc)
'print "GET SELECTED TAB:" + str(pos)
'search for tab -> *New
For c = 0 To 63
    IF  tabName[c] = "*New"         
        tabValue[c] = filename
         tName = GetFileName(filename) ' extract file name from filePath/tab name/
         tabName[c] = tName             ' update tab name
         SetTabText(tc,pos,tName)       ' set updated as tab text
         ReOpenFile()                   'reOpen file from filePath
         fnParser()    
         found=1
         Exit For            
    END IF
Next c

END IF
'~~~~~~~~~~~~~~~~~~~~~~
RETURN
END SUB
'----------------------------------------------------------
SUB FindTab
INT found,tempTab,c
STRING tName,tabItem

tempTab=GetSelectedTab(tc)
tabItem = str(tempTab)
SendMessage edit3,WM_SETTEXT,0,strptr(tabItem) ' show tab id /zero-based/
tName=GetTabText(tc,tempTab)
tName=Trim(tName)
'print "LEN:GETText:" + str(len(tname))
SendMessage edit4,WM_SETTEXT,0,strptr(tName)   'show tab name
'print "LEN_after_TRIM:" + str(len(tName))

IF tName="*New"
SendMessage hsci,SCI_CLEARALL,0,0
Return
END IF

found=0
'show filePath [EDIT 1]-> C:\folder\myfile.bas
SendMessage edit1,WM_SETTEXT,0,strptr(tabValue[tempTab])
'search tab name...
For c = 0 To 63
    IF  tabName[c] = tName
         'print "FOUND:" + tabName[c]         
        found=1:Exit For                
    END IF
Next c

IF found = 1
ReOpenFile()
fnParser()
Return                
END IF
'-------------------
IF found=0
'MESSAGEBOX 0,"New File!","Message..."
Return
END IF

END SUB

'----------------------------------------------------------
SUB ReOpenFile
SendMessage hsci,SCI_CLEARALL,0,0
INT tempTab,c
STRING name,filePath
tempTab=GetSelectedTab(tc)
name=GetTabText(tc,tempTab)
name=Trim(name)
'print "RE-OPEN:" + name

For c = 0 To 63
    IF  tabName[c] = name          
        filePath = tabValue[c]
         Exit For            
    END IF
Next c
SendMessage edit1,WM_SETTEXT,0,strptr(filePath)
'print "REOPEN-GetName:" + name
tx =  GetFile filePath
SendMessage hsci,SCI_SETTEXT,0,strptr(tx)
SendMessage hsci,SCI_SETSAVEPOINT, 0, 0
SendMessage hsci,SCI_EMPTYUNDOBUFFER,0,0


END SUB
'----------------------------------------------------------
SUB CreateNewTab
int tab,c=0 : string tabnum
tabIndex=tabIndex+1
'first stored info for tabArray AT pos->0
tabName[c]="*New"
tabValue[c] = ""
'create new tab
AddTab( tc, tabIndex,"*New")
SendMessage tc,TCM_SETCURSEL,tabIndex,0  'set selected new tab
Tab=GetSelectedTab(tc)                   'get selected tab
tabNum = str(tab)
SendMessage edit3,WM_SETTEXT,0,strptr(tabnum) 'show tab ID

Return
END SUB

'-----------------------------------------------------------
SUB NewTab
tabIndex=tabIndex+1  ' increase tab count
AddTab( tc, tabIndex, "*New")
SendMessage tc,TCM_SETCURSEL,tabIndex,0  ' set newTab as SELECTED
INT epos = -1
'search for first empty tabName in tabName[]
        For c = 0 To 63
            IF  tabName[c] = ""         
                tabName[c] = "*New" ' set first empty place with *New
                  tabValue[c] = ""    ' reset
                  epos=c              
                  Exit For
              END IF
         Next c
'-------------------------------------------
IF epos = -1
print "ERROR: File List Out Of Range! -> 63"
RETURN
END IF

END SUB
'-----------------------------------------------------------

SUB fnParser
'reset listbox content ***************************************
STRING o2script[100000] 'string array
SendMessage LBox,LB_RESETCONTENT,0,o2script[100000]
STRING i$,txt,d$=" "
STRING GW1,GW2
INT smax,start,lineNum,iLen,bo,ipos
start=0
smax = Sendmessage hsci,SCI_GETLINECOUNT, 0, 0

'parse line by line >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
FOR lineNum = 1 TO smax
    
int Pos=0
int EPos=0
int SPos=0
int WC=0

'get-line ........................................................

iLen = SendMessage hsci,SCI_LINELENGTH,lineNum,0    'get line length
o2script[lineNum] = String(iLen," ")                'set buffer space
Sendmessage hsci,SCI_GETLINE, lineNum, strPtr(o2script[lineNum])
'test ///////////////////////////////
'print "LINE:" + o2script[lineNum]
'///////////////////////////////////
o2script[lineNum] = Ltrim(o2script[lineNum])
'--------------------------------------------
WC = 1
    Pos = InStr(1,o2script[lineNum], d$)
    While Pos > 0
        WC = WC + 1
        Pos = InStr(pos+1,o2script[lineNum], d$)
    Wend
'test wc------------------------------------------
'print WC
IF wc>0      
    SPos = 1      
    EPos = InStr(SPos,o2script[lineNum], d$) - 1
    If EPos <= 0 Then EPos = LEN(o2script[lineNum])
    GW1 = RTrim(LTrim(Mid(o2script[lineNum], SPos, EPos - SPos + 1)))
'print "GW1:"+GW1
END IF
'--------------------------------------------------
IF wc>1      
    SPos=EPos+2      
    EPos = InStr(SPos,o2script[lineNum], d$) - 1
    If EPos <= 0 Then EPos = LEN(o2script[lineNum])
    GW2 = RTrim(LTrim(Mid(o2script[lineNum], SPos, EPos - SPos + 1)))
'print "GW2:"+GW2
END IF

'test string & add to listbox
'/// SUB ///
IF Ucase(GW1) = "SUB"
'remove bracket ((((((((((((((((
bo = Instr (GW2,"(")
'print str(Len(GW2))
'print "BO:"+str(bo)
IF bo<>0
   bo=bo-1
   GW2=Mid(GW2,1,bo)
   bo=0
END IF
i$ = "SUB:" + GW2

SendMessage Lbox,LB_ADDSTRING,0,strptr i$
LBitems[LBitem]=lineNum
LBitem=LBitem+1
END IF

'/// FUNCTION ///
IF (Ucase(GW1) = "FUNCTION") And (Left(GW2,1)<>"=") And (Mid(GW1,9)<>"=")
bo = Instr (GW2,"(")
IF bo<>0
   bo=bo-1
   GW2=Mid(GW2,1,bo)
   bo=0
END IF
i$ = "FN:" + GW2
SendMessage Lbox,LB_ADDSTRING,0,strptr i$
LBitems[LBitem]=lineNum
LBitem=LBitem+1
END IF
GW1="":GW2=""

NEXT
LBitem=0
END SUB

'///////////////////////////////////////////////
SUB CreateAsciTable
INT index : STRING symbol,item
'add symbol / asci value
For index = 0 to 255
item =  chr(index) + " : " + str(index)
SendMessage Lbox2,LB_ADDSTRING,0,strptr item
Next index
END SUB
'////////////////////////////////////////////////
SUB AddTButton (byval twnd as int,byval id as int,byval iNum as int,byval tip as string)
'TOOLINFO tti

tti.cbSize = Sizeof(tti)
tti.uFlags = 0   'TTF_SUBCLASS | TTF_IDISHWND
tti.hwnd   = twnd
tti.uId    = id
tti.hinst  = 0
tti.lpszText = strPtr tip

SendMessage(SendMessage( htbar, 1059,0,0),1028, 0, tti)

'add button
tbb.iBitmap = iNum
tbb.idCommand = id
tbb.fsState = 4
tbb.fsStyle = 0    
tbb.dwData = 0


SendMessage htbar , TB_ADDBUTTONS, iNum, tbb  'addbutton
'SendMessage (htbar, 1952, 0, 0) 'autosize

END SUB


'//////////////////////////////////////
SUB oxyKeywords
'blue
sciblue="$ enum operator dim const local static global declare function sub method end if then else elseif endif "
sciblue=sciblue+"endsel do while enddo endwhile wend exit continue operation operations select case for to step next "
sciblue=sciblue+"goto gosub methods return block scope indexbase lib library extern that this "
sciblue=sciblue+"readstate writestate deff type val ltrim rtrim lcase ucase space left mid instr "
sciblue=sciblue+"asc len chr str hex print ellipse rgb sendmessage  "
sciblue=sciblue+"with "
sciblue=sciblue+"noinit "
sciblue=sciblue+"byval "
sciblue=sciblue+"byref "
sciblue=sciblue+"economy "
sciblue=sciblue+"fpu "
sciblue=sciblue+"cpu "
sciblue=sciblue+"noprec "
sciblue=sciblue+"include "
sciblue=sciblue+"define "
sciblue=sciblue+"typedef "
sciblue=sciblue+"includepath "
sciblue=sciblue+"lookahead "
sciblue=sciblue+"view "
sciblue=sciblue+"endv "
sciblue=sciblue+"version "
sciblue=sciblue+"getmemory "
sciblue=sciblue+"freememory "
sciblue=sciblue+"getprocaddress "
sciblue=sciblue+"copy0 "
sciblue=sciblue+"copy00 "
sciblue=sciblue+"copyn "
sciblue=sciblue+"copy "
sciblue=sciblue+"mbox "
sciblue=sciblue+"comparestr "
'----------------------------
sciblue=sciblue+"alias macro as "
sciblue=sciblue+"incl "
sciblue=sciblue+"semicolon "
sciblue=sciblue+"indexers "
sciblue=sciblue+"retn "
sciblue=sciblue+"offset "
sciblue=sciblue+"skip "
sciblue=sciblue+"with "
sciblue=sciblue+"dataspace "
sciblue=sciblue+"data "
sciblue=sciblue+"o2 "
sciblue=sciblue+"bind "
sciblue=sciblue+"defs "
sciblue=sciblue+"def "
sciblue=sciblue+"struct "
sciblue=sciblue+"class "
sciblue=sciblue+"var "
sciblue=sciblue+"asm "
sciblue=sciblue+"o2h "
sciblue=sciblue+"librarypath "
sciblue=sciblue+"file "
sciblue=sciblue+"quote "
sciblue=sciblue+"union "
sciblue=sciblue+"leaf "
sciblue=sciblue+"autodim "
sciblue=sciblue+"minormajor "
sciblue=sciblue+"alert "
sciblue=sciblue+"pragma "
sciblue=sciblue+"unique "
sciblue=sciblue+"console "
sciblue=sciblue+"elif "
sciblue=sciblue+"fi "
sciblue=sciblue+"ifdef "
sciblue=sciblue+"ifndef "
sciblue=sciblue+"undef "
sciblue=sciblue+"undefine "
sciblue=sciblue+"blockdepth "
sciblue=sciblue+"new "
sciblue=sciblue+"del "
sciblue=sciblue+"terminate "
sciblue=sciblue+"freestrings "
sciblue=sciblue+"freelibs "
sciblue=sciblue+"inherits "
sciblue=sciblue+"of "
sciblue=sciblue+"from "
sciblue=sciblue+"has "
sciblue=sciblue+"export "
sciblue=sciblue+"external "
sciblue=sciblue+"com "
sciblue=sciblue+"virtual "
sciblue=sciblue+"endselect "
sciblue=sciblue+"load "
sciblue=sciblue+"and "
sciblue=sciblue+"or "
sciblue=sciblue+"xor "
sciblue=sciblue+"stdcall "
sciblue=sciblue+"cdecl "
sciblue=sciblue+"ms64 "
sciblue=sciblue+"at "
sciblue=sciblue+"not "
sciblue=sciblue+"once "
sciblue=sciblue+"public "
sciblue=sciblue+"private "
sciblue=sciblue+"strptr "
sciblue=sciblue+"getfile putfile loadlibrary getdc releasedc sizeof "
sciblue=sciblue+"createwindowex filedialog trim replace #lookahead "

'AWIH keywords in sciBrown  //////////////////////////////////////////////////////////////
sciBrown=sciBrown+"wndproc addtab getselectedtab settabtext gettabtext gettabcount setselectedtab deletetab controlfont setricheditbackcolor "
sciBrown=sciBrown+"setwindow seteditbox setrichedit setbutton setlistbox setcombobox setstatic settoolbar settabcontrol settooltip "
sciBrown=sciBrown+"gettext settext setstatusbar settrackbar gettruckpos settreeview tvinsertitem setprogressbar pbsetpos setradiobutton "
sciBrown=sciBrown+"setcheckbox initdrawing windowcolor msgbox default notifycode "

'sciRed - red - var types
sciRed=sciRed+"void "
sciRed=sciRed+"byte "
sciRed=sciRed+"astring "
sciRed=sciRed+"pstring "
sciRed=sciRed+"bstring "
sciRed=sciRed+"char "
sciRed=sciRed+"zstring "
sciRed=sciRed+"wstring "
sciRed=sciRed+"bstring2 "
sciRed=sciRed+"zstring2 "
sciRed=sciRed+"asciiz "
sciRed=sciRed+"short "
sciRed=sciRed+"int "
sciRed=sciRed+"integer "
sciRed=sciRed+"float "
sciRed=sciRed+"single "
sciRed=sciRed+"sys "
sciRed=sciRed+"double "
sciRed=sciRed+"quad "
sciRed=sciRed+"word "
sciRed=sciRed+"dword "
sciRed=sciRed+"qword "
sciRed=sciRed+"uint "
sciRed=sciRed+"__int8 "
sciRed=sciRed+"__int16 "
sciRed=sciRed+"__int32 "
sciRed=sciRed+"__int64 "
sciRed=sciRed+"int8_t "
sciRed=sciRed+"int16_t "
sciRed=sciRed+"int32_t "
sciRed=sciRed+"int64_t "
sciRed=sciRed+"uint8_t "
sciRed=sciRed+"uint16_t "
sciRed=sciRed+"uint32_t "
sciRed=sciRed+"uint64_t "
sciRed=sciRed+"any "
sciRed=sciRed+"sys"
sciRed=sciRed+"bool "
sciRed=sciRed+"signed "
sciRed=sciRed+"unsigned "
sciRed=sciRed+"string "
sciRed=sciRed+"long "

END SUB
'
'///// EDITOR  ABOUT WINDOW - AboutBox  ///////////////////////////////////////////
SUB AboutBox
String mbff=""
mbff=" Aurel Edit is alternative Code editor for Oxygen Basic" + crlf + " Written with pure WIN32 API and Scintilla editing control" + crlf
'mbff=mbff + "Code Editor written..................."+chr(13)
mbff=mbff + " Created by Aurel v037-2018"
'create  about window ***********************************************
wabout = SetWindow("About AurelEdit...",300,160,412,400,0, 524288)
'create static control
static3 = SetStatic(wabout,2,2,400,300,"",0x5000030E,0,st3ID)
SendMessage static3, 370, 0, bmpB1
static4 = SetStatic(wabout,4,310,398,50,mbff,0x50000100 | SS_LEFT,0x200,st4ID)

aboutWindow = 1
END SUB
    
'/////// EDITOR OPTION WINDOW  ////////////////////////////////////////////////////0x5000010B
SUB OptWindow
INT static5,st5ID=355
STRING bff,bf1
'create option window **************************
optWin = SetWindow("Editor Themes...",300,160,412,400,0, 524288)
bff="Set color theme by choosing one of options..."
static5 = SetStatic(optWin,4,4,398,14,bff,0x50000101,0,st5ID)
'height , width , flag
ControlFont ( static5, 16, 8, 400,"Courier New")  
'----------------------------------------------------------------------------------
INT st6ID=336,st7ID=338,st8ID=339,st9ID=340
INT static6b,st6bID=337,static7b,st7bID=337,st8bID=440,st9bID=441
'----------------------------------------------------------------------------------
static6 = SetStatic(optWin,8,30,126,14,"Theme : Clear Sea",0x50000100,0,st6ID)
static6b = SetStatic(optWin,330,24,26,26,"",0x5000030E,0,st6bID)
SendMessage static6b, 370, 0, bmpB2
bo1 = SetButton(optWin,160,25,100,24," CLEAR SEA  ",0x50000000,0x200,bo1ID)
'---------------------------------------------------------------------------------
static7 = SetStatic(optWin,8,60,126,14,"Theme : Soft Desert",0x50000100,0,st7ID)
bo2 = SetButton(optWin,160,55,100,24," SOFT DESERT  ",0x50000000,0x200,bo2ID)
static7b = SetStatic(optWin,330,55,26,26,"",0x5000030E,0,st7bID)
SendMessage static7b, 370, 0, bmpB3
'----------------------------------------------------------------------------------
static8 = SetStatic(optWin,8,90,126,14,"Theme : Default",0x50000100,0,st8ID)
bo3 = SetButton(optWin,160,85,100,24," DEFAULT  ",0x50000000,0x200,bo3ID)
static8b = SetStatic(optWin,330,55,26,26,"",0x5000030E,0,st8bID)
SendMessage static8b, 370, 0, bmpB4
'----------------------------------------------------------------------------------
static9 = SetStatic(optWin,8,120,126,14,"Theme : Dark Moon",0x50000100,0,st9ID)
bo4 = SetButton(optWin,160,115,100,24," DARK MOON ] ",0x50000000,0x200,bo4ID)
static9b = SetStatic(optWin,330,55,26,26,"",0x5000030E,0,st9bID)
SendMessage static9b, 370, 0, bmpB5

'----------------------------------------------------------------------------------
optWinOn = 1
END SUB
'===============================================================================​==
SUB FindWindow ' create Find/Replace window As TOOLWINDOW?
print "sub findwindow"
'INT fb1,fb2,fb3,fb1ID=501,fb2ID=502,fb3ID=503,fwed1,fwed1ID=504,fwed2,fwed2ID=505
'create ToolWindow require exetended window style to be set
INT hinst = GetModuleHandle 0
fWindow = CreateWindowEx ( WS_TOOLWINDOW|WS_EX_TOPMOST,"Oxygen","Find/Replace...", 524288 , 600, 160, 412, 300, 0, 0, null, 0)
print "FINDWINDOW" + str fWindow
ShowWindow fWindow,SW_SHOW : UpdateWindow fWindow
fb1=SetButton(fWindow,20,240,100,24,"[ Find ]",0x50000000,0x200,fb1ID)
fb2=SetButton(fWindow,150,240,100,24,"[ Replace ]",0x50000000,0x200,fb2ID)
fb3=SetButton(fWindow,280,240,100,24,"[ Replace All ]",0x50000000,0x200,fb3ID)
'create single-line edit control and static control
stFW1 = SetStatic(fWindow,20,30,100,26,"Search Word >>>",0x50000001,0,stfw1ID)
fwed1 = SetEditBox(fWindow,150,30,200,23,"",0x50004000,0x200,fwed1ID)
stFW2 = SetStatic(fWindow,20,80,100,26,"Replace With >>>",0x50000001,0,stfw2ID)
fwed2 = SetEditBox(fWindow,150,80,200,23,"",0x50004000,0x200,fwed2ID)
findWinOn = 1
END SUB
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub FindNext () as long
INT loc=1,temp
if loc
loc=SENDMESSAGE hsci,SCI_GETSELECTIONEND,0,0
'print "is selected-LOC: " + str(loc)
else
loc=SENDMESSAGE hsci,SCI_GETSELECTIONSTART,0,0
'print "selection start-LOC: " + str(loc)
end if

SENDMESSAGE hsci, SCI_SETANCHOR, loc ,0
SENDMESSAGE hsci, SCI_SETCURRENTPOS,loc,0
SENDMESSAGE hsci, SCI_SEARCHANCHOR,0,0

temp = SCFIND_WHOLEWORD
'print "TEMP: " + str(temp)
loc=SENDMESSAGE hsci,SCI_SEARCHNEXT,temp,GetText(fwed1)
'print "SEARCH-NEXT: " + str(loc)
'---------------------------------------------
IF loc > -1
      SENDMESSAGE hsci,SCI_SCROLLCARET,0,0
ELSE
    Msgbox "No matches found","Search"
Return 0
END IF
'-------------------------------------------
Return loc
End Sub
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function ReplaceOnce(RepeatS As Long) As Long
If FindNext() = 0    
    Return 0
End if
SENDMESSAGE hsci,SCI_REPLACESEL,0,GetText(fwed2)
Return 1
End Function
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub ReplaceAll
   dim iResult As Long
   'If FindNext() = 0 then
   ' Exit Function
   'End If
   iResult = ReplaceOnce(1)
If iResult = 0 then Exit Sub
   While iResult =1
      FindNext()
      iResult = ReplaceOnce(1)                  
   Wend
   MsgBox " All words Replaced!","Info"
End Sub
'/////////////////////////////////////////////////////////////////////
'//////////////////   theme  CLEAR SEA          //////////////////////
Sub SetTheme1

SENDMESSAGE(hsci, SCI_STYLESETBACK,32, RGB(240,240,255)) 'clear sea
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 12
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i, strptr "Consolas")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 11)
Next i
'Margins ////////////////////////////////////////////////////////
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
'caret line
SendMessage hsci,SCI_SETCARETFORE,RGB(0,0,0),0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(245,245,200),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
'SetFocus win
'--------------------------------------------------------------------
SetThemeColors()        
'SetFocus Lbox
End Sub

'//////////////////////////////////////////////////////////////////////
'////// theme  SOFT DESERT  ///////////////////////////////////////////

Sub SetTheme2
SENDMESSAGE(hsci, SCI_STYLESETBACK,32, rgb(243,242,214)) 'soft desert
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 24
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i,strptr "Courier New")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 12)
     'SENDMESSAGE hsci, SCI_STYLESETBOLD, i, 12 'uncomment if you wish bold text
Next i
'Margins ////////////////////////////////////////////////////////
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
'caret line
SendMessage hsci,SCI_SETCARETFORE,RGB(0,0,0),0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(220,220,245),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
'--------------------------------------------------------------------
SetThemeColors()
End Sub

'///////////////////////////////////////////////////////////////////////
'////// theme DEFAULT   /////////////////////////////////////////////////
Sub SetTheme3
SENDMESSAGE(hsci, SCI_STYLESETBACK,32, rgb(255,255,255)) 'default
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 24
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i,strptr "Lucida Console")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 10)
    'SENDMESSAGE hsci, SCI_STYLESETBOLD, i, 12 'uncomment if you wish bold text
Next i
'set keyword colors
'Margins ////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
'caret line
SendMessage hsci,SCI_SETCARETFORE,RGB(0,0,0),0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(245,245,200),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0

'--------------------------------------------------------------------
SetThemeColors()    

End Sub

'//////////////////////////////////////////////////////////////////////////
'///// theme DARK MOON   //////////////////////////////////////////////////
Sub SetTheme4
SENDMESSAGE(hsci, SCI_STYLESETBACK,32, RGB(40,40,65)) 'dark moon
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 31
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i, strptr "Lucida Console")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 12)
     'SENDMESSAGE hsci, SCI_STYLESETBOLD, i, 12 'uncomment if you wish bold text
Next
'set keyword colors
'Margins ////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
'caret line
SendMessage hsci,SCI_SETCARETFORE,0xFFFFFF,0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(65,60,100),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
'--------------------------------------------------------------------
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DEFAULT,RGB(191,193,198))          '0 default
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_LINECOMMENT,rgb(0,120,0))          '1 line comment
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_NUMBER, rgb(160,120,100))          '2 number
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD0,RGB(49, 106, 197) )         '3 keyword0 - blue
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRING,RGB(150,100,150))            '4 string
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_PREPROCESSOR,RGB(0,0,250)) :       '5 preproc
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_OPERATOR,rgb(220,180,120)):            '6 operator
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_IDENTIFIER,RGB(171,195,150))       '7 identifier/var names
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DATE,RGB(0,0,100))                  '8 date
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRINGEOL,rgb(0,100,0))            '9 string EOL
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD1,RGB(200,100,100) )            '10 keyword1 -work red
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD2,RGB(160,80,0))            '11 keyword2 - as brown
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD3,RGB(220,0,220))            '12 keyword3 - magenta    
'SetFocus Lbox
End Sub

'/////////////////////////////////////////////////////////////////////
'//  SET THEME COLORS
'////////////////////////////////////////////////////////////////////
Sub SetThemeColors
'------------------------------------------------------------------------------------------------------
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DEFAULT,0)                         '0 default
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_LINECOMMENT,rgb(0,120,0))          '1 line comment
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_NUMBER, rgb(160,0,0))             '2 number
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD0,RGB(0,0,200))            '3 keyword0 - blue
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRING,RGB(150,0,150))            '4 string
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_PREPROCESSOR,RGB(0,0,250)) :       '5 preproc
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_OPERATOR,rgb(250,,0)):            '6 operator
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_IDENTIFIER,RGB(0,0,0))             '7 identifier/var names
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DATE,RGB(0,0,0))                  '8 date
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRINGEOL,rgb(0,0,0))            '9 string EOL
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD1,RGB(250,0,0) )            '10 keyword1 -work red
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD2,RGB(160,80,0))            '11 keyword2 - as brown
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD3,RGB(220,0,220))            '12 keyword3 - magenta    
'-------------------------------------------------------------------------------------------------------
End Sub
Find all posts by this user
Quote this message in a reply
04-17-2018, 08:18 PM
Post: #2
RE: AurelEdit037
and awinh037.inc

Code:
'###########################################################
'####     awinh v037 include file for o2(043)- win32   #####
'####     by  Aurel 10.4.2018                          #####
'####     Use at your own risk!                        #####
'###########################################################

Type WNDCLASSEX
cbSize        as INT
Style         as INT
lpfnwndproc   as SYS
cbClsextra    as INT
cbWndExtra    as INT
hInstance     as INT
hIcon         as INT
hCursor       as INT
hbrBackground as INT
lpszMenuName  as INT
lpszClassName as INT
hIconSm       AS INT
End Type

Type LARGE_INTEGER
lowpart AS INT
highpart AS INT
End Type

Type POINTAPI
x as INT
y as INT
End Type

Type MSG
hwnd    as INT
message as INT
wParam  as INT
lParam  as INT
time    as INT
pt      as POINTAPI
End Type

Type RECT
Left   as INT
Top    as INT
Right  as INT
Bottom as INT
End Type

Type PAINTSTRUCT
    INT hDC
    bool fErase
    RECT rcPaint
    bool fRestore
    bool fIncUpdate
    byte rgbReserved[32]
End type

Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As INT
    lpstrCustomFilter As INT
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As INT
    nMaxFile As Long
    lpstrFileTitle As INT
    nMaxFileTitle As Long
    lpstrInitialDir As INT
    lpstrTitle As INT
    flags As Long
    nFileOffset As word
    nFileExtension As word
    lpstrDefExt As INT
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As INT
End Type

% OFN_EXPLORER = 0x00080000
% OFN_PATHMUSTEXIST = 0x00000800
% OFN_FILEMUSTEXIST = 0x00001000
% OFN_OVERWRITEPROMPT = 0x00000002
% OFN_HIDEREADONLY = 0x00000004

% BCM_FIRST = 0x1600
% BCM_SETIMAGELIST = (BCM_FIRST + 0x0002)

% SW_NORMAL      = 1
% SW_SHOWDEFAULT = 10
% SW_SHOW        = 5
% CS_VREDRAW     = 1
% CS_HREDRAW     = 2
% CS_DBLCLKS     = 0x8
% CS_OWNDC       = 32
% SM_CXSCREEN    = 0
% SM_CYSCREEN    = 1
% IDI_HAND       = 32513
% IDI_QUESTION   = 32514
% IDI_EXCLAMATION= 32515
% IDI_ASTERISK   = 32516
% IDI_WINLOGO    = 32517
% IDI_APPLICATION= 32512
% IDC_ARROW      = 32512
% IDC_WAIT       = 32514
% IDC_HAND       = 32649
% IDC_ICON       = 32641
% IDC_IBEAM      = 32513
% IDC_NO         = 32648

% WM_SETICON     = &H80
% WM_KILLFOCUS = 0x8  
% WM_CREATE      = 1
% WM_DESTROY     = 2
% WM_CLOSE       = 0x10
% WM_PAINT       = 15
% WM_QUIT        = 18
% WM_SIZE        = 5
% WM_MOVE        = 3
% WM_CHAR        = 258
% WM_KEYLAST     = &H108
% WM_KEYFIRST    = &H100
% WM_KEYDOWN     = 256
% WM_MOUSEMOVE   = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP   = 514
% WM_RBUTTONUP   = 517
% WM_MBUTTONUP   = 520
% WM_TIMER       = 275
% WM_WINDOWPOSCHANGED = &H47
% WM_NOTIFY      = 0x004E
% WM_SETFONT = &H30
% WM_COMMAND = 0x111
% BN_CLICKED = 0
% WM_PARENTNOTIFY = 0x210
% WM_SETTEXT  = 0x000C
% WM_GETTEXT = 0xD
% WM_USER = 0x400
% WM_HSCROLL = 276
'control color messages
% WM_CTLCOLORMSGBOX = 0x132
% WM_CTLCOLOREDIT = 0x133
% WM_CTLCOLORLISTBOX = 0x134
% WM_CTLCOLORBTN = 0x135
% WM_CTLCOLORDLG = 0x136
% WM_CTLCOLORSCROLLBAR = 0x137
% WM_CTLCOLORSTATIC = 0x138

' Edit Control Messages
% EM_GETSEL = 0xB0
% EM_SETSEL = 0xB1
% EM_HIDESEL = 19
% EM_GETRECT = 0xB2
% EM_SETRECT = 0xB3
% EM_SETRECTNP = 0xB4
% EM_SCROLL = 0xB5
% EM_LINESCROLL = 0xB6
% EM_SCROLLCARET = 0xB7
% EM_GETMODIFY = 0xB8
% EM_SETMODIFY = 0xB9
% EM_GETLINECOUNT = 0xBA
% EM_LINEINDEX = 0xBB
% EM_SETHANDLE = 0xBC
% EM_GETHANDLE = 0xBD
% EM_GETTHUMB = 0xBE
% EM_LINELENGTH = 0xC1
% EM_REPLACESEL = 0xC2
% EM_GETLINE = 0xC4
% EM_LIMITTEXT = 0xC5
% EM_CANUNDO = 0xC6
% EM_UNDO = 0xC7
% EM_FMTLINES = 0xC8
% EM_LINEFROMCHAR = 0xC9
% EM_SETTABSTOPS = 0xCB
% EM_SETPASSWORDCHAR = 0xCC
% EM_EMPTYUNDOBUFFER = 0xCD
% EM_GETFIRSTVISIBLELINE = 0xCE
% EM_SETREADONLY = 0xCF
% EM_SETWORDBREAKPROC = 0xD0
% EM_GETWORDBREAKPROC = 0xD1
% EM_GETPASSWORDCHAR = 0xD2
'stayle no hide selection -add to richedit style
% ES_NOHIDESEL = 256
'charformat structure...
TYPE CHARFORMAT
  INT     cbSize
  DWORD    dwMask
  DWORD    dwEffects
  LONG     yHeight
  LONG     yOffset
  INT crTextColor
  BYTE     bCharSet
  BYTE     bPitchAndFamily
  CHAR    szFaceName[LF_FACESIZE]
End TYPE

'bm bitmaps
% BM_SETIMAGE = 247
% MF_BYPOSITION   = &H400
% IMAGE_BITMAP = 0
% COLOR_BTNFACE = 15
% ILC_MASK = 1
% ILC_COLOR8 = 8
% ILC_COLOR16 = 16
% PS_SOLID = 0
% SRCCOPY = 0xCC0020

'progress constants
% PBM_SETPOS = 0x402
% PBM_SETRANGE32 = 0x406

'trackbar constants
% TB_TUMBTRACK = 5

% WS_CLIPSIBLINGS = 0x4000000
% WS_CLIPCHILDREN = 0x2000000
% WS_SYSMENU      = 524288
% WS_THICKFRAME   = 0x40000
% WS_CAPTION      = 0xC00000
% WS_OVERLAPPED   = 0x0  
% WS_TOOLWINDOW   = 0x00000080 '0x80
% WS_TOPMOST      = 0x8
% WS_EX_TOPMOST   = &H8
% WS_WINDOWEDGE   = 0x100
% WS_HIDDEN       = 2048
% WS_SIZED        = 262144
% WS_POPUP       = 0x80000000
% WS_DLGFRAME    = 0x400000
% WS_MAXIMIZE    = &H1000000
% WS_MINIMIZEBOX = &H20000
% WS_MAXIMIZEBOX = 0x10000
% WS_BORDER      = &H800000
% WS_CHILD       = 0x40000000
% WS_VISIBLE     = 0x10000000
% WS_VSCROLL     = 0x200000
% WS_HSCROLL     = 0x100000
% WS_OVERLAPPEDWINDOW = 0x00CF0000
'minmaxsize-> overlappedwindow
% WS_MINMAXSIZE =(WS_OVERLAPPED Or WS_VISIBLE Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)

% TRANSPARENT    = 1
% OPAQUE         = 2
% PM_REMOVE      = 1
% PM_NOREMOVE    = 0
% PM_NOYIELD     = 2
% NULL_BRUSH     = 5

% ES_SUNKEN = 0x4000
% ES_MULTILINE = 0x4
% ES_WANTRETURN = 0x1000
% ES_AUTOVSCROLL = 0x40
% ES_AUTOHSCROLL = 0x80

' Listbox messages
% LB_ADDSTRING = 0x180
% LB_INSERTSTRING = 0x181
% LB_DELETESTRING = 0x182
% LB_SELITEMRANGEEX = 0x183
% LB_RESETCONTENT = 0x184
% LB_SETSEL = 0x185
% LB_SETCURSEL = 0x186
% LB_GETSEL = 0x187
% LB_GETCURSEL = 0x188
% LB_GETTEXT = 0x189
% LB_GETTEXTLEN = 0x18A
% LB_GETCOUNT = 0x18B
% LB_SELECTSTRING = 0x18C
% LB_DIR = 0x18D
% LB_GETTOPINDEX = 0x18E
% LB_FINDSTRING = 0x18F
% LB_GETSELCOUNT = 0x190
% LB_GETSELITEMS = 0x191
% LB_SETTABSTOPS = 0x192
% LB_GETHORIZONTALEXTENT = 0x193
% LB_SETHORIZONTALEXTENT = 0x194
% LB_SETCOLUMNWIDTH = 0x195
% LB_ADDFILE = 0x196
% LB_SETTOPINDEX = 0x197
% LB_GETITEMRECT = 0x198
% LB_GETITEMDATA = 0x199
% LB_SETITEMDATA = 0x19A
% LB_SELITEMRANGE = 0x19B
% LB_SETANCHORINDEX = 0x19C
% LB_GETANCHORINDEX = 0x19D
% LB_SETCARETINDEX = 0x19E
% LB_GETCARETINDEX = 0x19F
% LB_SETITEMHEIGHT = 0x1A0
% LB_GETITEMHEIGHT = 0x1A1
% LB_FINDSTRINGEXACT = 0x1A2
% LB_SETLOCALE = 0x1A5
% LB_GETLOCALE = 0x1A6
% LB_SETCOUNT = 0x1A7
% LB_MSGMAX = 0x1A8
% LBN_DBLCLICK = 2
% CTLISTNOTIFY = 1

'combo constants------------------------------
% CB_INSERTSTRING = 0x14A
% CB_RESETCONTENT = 0x14B
% CB_FINDSTRING = 0x14C
% CB_SELECTSTRING = 0x14D
% CB_SETCURSEL = 0x14E
% CB_SHOWDROPDOWN = 0x14F
% CB_GETITEMDATA = 0x150
% CB_SETITEMDATA = 0x151

'treeview constants -------------------------
% TVS_LINESATROOT = 0x0004
% TVS_HASLINES = 2
% TVS_HASBUTTONS = 0x0001
% TV_FIRST = 0x1100

% TVS_CHECKBOXES = 0x100
% TVM_SETBKCOLOR = (TV_FIRST + 29)
% TVM_SETLINECOLOR = (TV_FIRST + 40)
% TVM_SETTEXTCOLOR = (TV_FIRST + 30)
% TVM_SETITEMA = (TV_FIRST + 13)
% TVM_INSERTITEMW = (TV_FIRST + 50)
% TVM_INSERTITEM = 4352
% TVI_ROOT = 0xFFFF0000
% TVI_LAST = 0xFFFF0002
'..................................
% TVIF_TEXT = 1
% TVIF_HANDLE = 16
% TVIF_IMAGE = 2
% TVIF_PARAM = 4
% TVIF_DI_SETITEM = 128
% TVSELECTEDIMAGE = 36
'.................................

TYPE TV_ITEM
      mask           as INT
      hItem          as INT
      state          as INT
      stateMask      as INT
      pszText        as INT
      cchTextMax     as INT
      iImage         as INT
      iSelectedImage as INT
      cChildren      as INT
      lParam         as INT
END TYPE

TYPE TV_INSERTSTRUCT
      hParent      as INT
      hInsertAfter as INT
      item         as TV_ITEM
END TYPE


'.................................
TYPE NMTREEVIEW
hwnd as int
idfrom as int
code as int
action as int
omask as int
ohitem as int
ostate as int
ostatemask as int
opszText as INT
occhTextMax as int
oiImage as int
oiSelectedImage as int
ocChildren as int
olparam as int
oIIntegral as int
nmask as int
nhitem as int
nstate as int
nstatemask as int
npszText as INT
ncchTextMax as int
niImage as int
niSelectedImage as int
ncChildren as int
nlparam as int
nIIntegral as int
End TYPE

Dim tvi As TV_ITEM
Dim MyNmTV As NMTREEVIEW

'ListViewControl ----------------------------
INT _lvleft,_lvinit,LV_ITEM
% LVM_INSERTCOLUMN  = 4123
% LVM_INSERTITEM    = 4103
% LVM_SETITEM       = 4102

TYPE ListviewColumn
    cmask as int
    cfmt as int
    ccx as int
    cpszText as int
    ccchTextMax as int
    ciSubItem as int
END TYPE

TYPE ListviewItem
    mask as int
    iItem as int
    iSubItem as int
    state as int
    stateMask as int
    pszText as int
    cchTextMax as int
    iImage as int
    lParam as int
END TYPE

DIM LV_COLUMN as ListviewColumn
DIM LV_ITEM as ListviewItem

'tabControl constants-------------------------
% TCM_FIRST = 0x1300
% TCM_SETITEM = (TCM_FIRST + 6)
% TCM_GETITEM = 4869
% TCM_GETITEMCOUNT = 4868
% TCM_DELETEITEM = (TCM_FIRST + 8)
% TCM_INSERTITEM = 0x1307
% TCM_SETCURFOCUS = 0x1330
% TCN_FIRST = -550
% TCN_SELCHANGE = -551
% TCN_SELCHANGING = -552
% TCM_GETCURSEL = 4875
% TCM_SETCURSEL = 0x130C
% TCIF_TEXT=1
% TCS_HOTTRACK = 0x40

TYPE TC_ITEM
mask as int
res1 as int
res2 as int
pszText as INT
cchTextMax as int
iImage as int
lParam as int
End TYPE

'toolbar constants / structures.....................................

TYPE INITCOMMONCONTROLSEX_TYPE
  DWORD dwSize
  DWORD dwICC
End TYPE

'tooltips constants .................................................
% TB_SETTOOLTIPS = 1060
% EBTOOLTIPS = 256
% TBSTYLE_TOOLTIPS = &H100
% TBSETTIP = 9
% TTS_ALWAYSTIP = &H1
% TTS_NOPREFIX = &H2
% TTS_BALLOON = &H40 ' comctl32.dll v5.8 require
% TTM_ACTIVATE = WM_USER+1

% TTM_ADDTOOL = (WM_USER + 4)
% TTM_DELTOOL = (WM_USER + 5)
% TTM_NEWTOOLRECT = (WM_USER + 6)
% TTM_GETTOOLINFO = (WM_USER + 8)
% TTM_SETTIPBKCOLOR = (WM_USER + 19)
% TTM_SETTIPTEXTCOLOR = (WM_USER + 20)
% TTM_SETMAXTIPWIDTH = (WM_USER + 24)
% TTM_UPDATETIPTEXT  = 1036
% TTDT_AUTOPOP = 2
% TTDT_INITIAL = 3

% TTF_IDISHWND = &H1
% TTF_CENTERTIP = &H2
% TTF_SUBCLASS = &H10

Type TOOLINFO
    cbSize      As int
    uFlags      As int
    hWnd        As int
    uId         As int
    cRect       As RECT
    hinst       As int
    lpszText    As INT
End Type

'trackbar constants'''''''''''''''''''''''''''''
% TBM_SETPAGESIZE = 1045
% TBM_SETRANGEMIN = 1031
% TBM_SETRANGEMAX = 1032
% TBM_SETPOS = 1029
% TRACKBARNORMAL = 1409351681

'..............................................
% CCS_ADJUSTABLE  = 32
% CCS_NODIVIDER   = 64
% TBSTYLE_FLAT    = &H800
% TB_ADDBUTTONS   = WM_USER + 21
% TB_SETIMAGELIST = 1072
% TB_ADDBITMAP    = 1043
% TB_AUTOSIZE     = 1057
'..............................................
TYPE TBBUTTON
    iBitmap        as int
    idCommand    as int
    fsState       as byte
    fsStyle       as byte
     bReserved[1]    as byte
     bReserved[1] as byte
    dwData        as dword
    iString       as int
End TYPE

'statusbar constants
% SBARS_SIZEGRIP = 0x100

'----------------------------------------------
Def FW_BOLD       700
Def FW_LIGHT      300
Def FW_HEAVY      900
Def FW_NORMAL     400
Def FW_DONTCARE   0
Def FW_EXTRABOLD  800
Def FW_EXTRALIGHT 200
Def FW_HEAVY      900
Def FW_LIGHT      300
Def FW_MEDIUM     500
Def FW_SEMIBOLD   600
Def FW_THIN       100

% WHITE_BRUSH    = 0
% BLACK_BRUSH    = 4
% LTGRAY_BRUSH = 0xC0C0C0
% LTGRBL_BRUSH = 0xDCDCCE

% vk_LBUTTON  = &H1    
% vk_RBUTTON  = &H2
% vk_MBUTTON  = &H4
% vk_BACK     = &H8
% vk_TAB      = &H9
% vk_CLEAR    = &HC
% vk_RETURN   = &HD
% vk_SHIFT    = &H10
% vk_CONTROL  = &H11
% vk_MENU     = &H12
% vk_PAUSE    = &H13
% vk_CAPITAL  = &H14
% vk_ESCAPE   = &H1B
% vk_SPACE    = &H20
% vk_PRIOR    = &H21
% vk_NEXT     = &H22
% vk_END      = &H23
% vk_HOME     = &H24
% vk_LEFT     = &H25
% vk_UP       = &H26
% vk_RIGHT    = &H27
% vk_DOWN     = &H28
% vk_PRINT    = &H2A
% vk_SNAPSHOT = &H2C    
% vk_INSERT   = &H2D
% vk_DELETE   = &H2E
% vk_HELP     = &H2F
% vk_0 = &H30
% vk_1 = &H31
% vk_2 = &H32
% vk_3 = &H33
% vk_4 = &H34
% vk_5 = &H35
% vk_6 = &H36
% vk_7 = &H37
% vk_8 = &H38
% vk_9 = &H39
% vk_@ = &H40
% vk_A = &H41
% vk_B = &H42
% vk_C = &H43
% vk_D = &H44
% vk_E = &H45
% vk_F = &H46
% vk_G = &H47
% vk_H = &H48
% vk_I = &H49
% vk_J = &H4A
% vk_K = &H4B
% vk_L = &H4C
% vk_M = &H4D
% vk_N = &H4E
% vk_O = &H4F
% vk_P = &H50
% vk_Q = &H51
% vk_R = &H52
% vk_S = &H53
% vk_T = &H54
% vk_U = &H55
% vk_V = &H56
% vk_W = &H57
% vk_X = &H58
% vk_Y = &H59
% vk_Z = &H5A
% vk_F1  = &H70
% vk_F2  = &H71
% vk_F3  = &H72
% vk_F4  = &H73
% vk_F5  = &H74
% vk_F6  = &H75
% vk_F7  = &H76
% vk_F8  = &H77
% vk_F9  = &H78
% vk_F10 = &H79
% vk_F11 = &H7A
% vk_F12 = &H7B
% vk_NUMLOCK    = &H90
% vk_OEM_SCROLL = &H91    
% vk_LSHIFT     = &HA0
% vk_RSHIFT     = &HA1
% vk_LCONTR     = &HA2    
% vk_RCONTROL   = &HA3
    


'kernel32 = LoadLibrary "kernel32.dll"
Dim user32   = LoadLibrary "user32.dll"
'gdi32    = LoadLibrary "gdi32.dll"
'riched32 =  LoadLibrary "riched32.dll"
'comctl32 = LoadLibrary "comctl32.dll"
'comdialog32 =  LoadLibrary "comdlg32.dll"

' I am forced to use bind user32 () because standard way of SendMessage declaration NOT work like in most compilers!
bind user32
(
SendMessage SendMessageA
)
'///  KERNEL32.DLL   /////////
Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Declare Function GetModuleHandle  Lib "kernel32.dll" Alias "GetModuleHandleA" (INT lpModuleName) as Long
Declare Function GetCurrentDir Lib "kernel32.dll" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
'same function as above with shorter name
Declare Function GetThisFolder Lib "kernel32.dll" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Declare Function ExitProcess Lib "kernel32.dll" Alias "ExitProcess" (ByVal uExitCode As Long)
Declare Function GetTickCount Lib "kernel32.dll" () As Long
Declare Sub Sleep Lib "kernel32.dll" Alias "Sleep" (ByVal dwMilliseconds As Long)

Declare Function GetCurrentDir Lib "kernel32.dll" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpPathName As Long) As Long
Declare Function GetTempPath Lib "kernel32.dll" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Declare Function lstrcmpi Lib "kernel32.dll" Alias "lstrcmpiA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Declare Function GetCommandLine Lib "kernel32.dll" Alias "GetCommandLineA" () as String
Declare Function QueryPerformanceCounter   Lib "kernel32.dll" (ByRef lpPerformanceCount As LARGE_INTEGER) As Long
Declare Function QueryPerformanceFrequency Lib "kernel32.dll" (ByRef lpFrequency As LARGE_INTEGER) As Long

'///  USER32.DLL  //////////////
Declare Function CreateWindowEx Lib "user32.dll" Alias "CreateWindowExA"(ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, ByRef lpParam As Long) As Long
Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" (byref pcWndClassEx As WNDCLASSEX) As Long
Declare Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function UpdateWindow  Lib "user32.dll" (ByVal hwnd AS Long) As Long
Declare Function DestroyWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hinstance As Long, ByVal lpCursorName As Long) As Long
Declare Function LoadIcon Lib "user32.dll" Alias "LoadIconA" (ByVal hinstance As Long, ByVal lpIconName As long) As Long
Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" (ByVal hWnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal dwType As Long) As Long
'sendMessage not work in include file properly!
'!SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As INT, ByVal dwMsg As INT, ByVal wParam As INT, lParam As Long) As INT

' GET Message
Declare Function GetMessage Lib "user32.dll" Alias "GetMessageA" ( lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function PeekMessage Lib "user32.dll" Alias "PeekMessageA" (lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As INT, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Declare Function TranslateMessage Lib "user32.dll" (byRef lpMsg As MSG) As Long

Declare Function DispatchMessage Lib "user32.dll" Alias "DispatchMessageA" (byRef lpMsg As MSG) As Long
Declare Sub PostQuitMessage Lib "user32.dll" (ByVal nExitCode As Long)
! PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Declare Function GetParent Lib "user32.dll" (ByVal hWnd As Long) As Long

Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, lpRect As RECT) As Long
Declare Function SetWindowPos Lib "user32.dll"(hwnd AS INT,hWndInsertAfter AS INT,x AS INT,y AS INT,cx AS INT,cy AS INT,wFlags AS INT) As INT
Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function GetFocus   Lib "user32.dll" () As Long
Declare Function SetFocus   Lib "user32.dll" (ByVal hwnd As INT) As INT
Declare Function GetSysColor Lib "user32.dll" (ByVal nIndex As INT) As INT
Declare Function LoadImage Lib "user32.dll" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal dwType As Long, ByVal dwWidth As Long, ByVal dwHeight As Long, ByVal dwFlags As Long) As Long
Declare Function FillRect Lib "user32.dll" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Declare Function GetClientRect Lib "user32.dll" (ByVal hwnd As INT, ByRef lpRect As RECT) As Long
! InvalidateRect Lib "user32.dll" (ByVal hWnd As Long,ByVal lpRect As Long, ByVal bErase As Long) As Long
Declare Sub ValidateRect Lib "user32.dll" (ByVal hwnd As Long, ByVal t As Long)
Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Long, ByVal hdc As Long) As Long
Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long
Declare Function BeginPaint Lib "user32.dll" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long
Declare Function EndPaint Lib "user32.dll" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long
Declare Function ShowCursor Lib "user32.dll" (ByVal bShow As Long) As Long
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer

'/// GDI32.DLL  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Declare Function GetPixel   Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function CreateHatchBrush Lib "gdi32.dll" (ByVal nIndex As Long, ByVal crColor As Long) As Long
Declare Function CreatePen Lib "gdi32.dll" Alias "CreatePen" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Declare Function MoveToEx Lib "gdi32.dll" (ByVal hdc As INT, ByVal x As Long, ByVal y As Long, ByRef lpPoint As POINTAPI) As Long
Declare Function LineTo   Lib "gdi32.dll" (ByVal hdc As INT, ByVal x As Long, ByVal y As Long) As Long
Declare Function Ellipse Lib "gdi32.dll" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function SetPixel   Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function SetPixelV  Lib "gdi32.dll" (ByVal hdc As INT, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function Rectangle  Lib "gdi32.dll" (ByVal hdc As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
Declare Function TextOut    Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Declare Function DeleteDC   Lib "gdi32.dll" (ByVal hdc As Long) As Long
Declare Function PatBlt     Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Declare Function SetBkColor Lib "gdi32.dll" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function SetBkMode Lib "gdi32.dll"  (ByVal hDC As Long, ByVal nBkMode As Long) As Long

Declare Function BitBlt     Lib "gdi32.dll" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Declare Function CreateFont Lib "gdi32.dll" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long
Declare Function GetObject  Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long
Declare Function SelectObject  Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
Declare Function DeleteObject  Lib "gdi32.dll" (ByVal hObject As Long) As Long
Declare Function SetTextColor  Lib "gdi32.dll" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function FloodFill Lib "gdi32.dll" Alias "FloodFill" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Integer) As Integer
Declare Function ExtFloodFill Lib "gdi32.dll" Alias "ExtFloodFill" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Integer, ByVal wFillType As Integer) As Integer
Declare Function CreateCompatibleBitmap    Lib "gdi32.dll" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function CreateCompatibleDC        Lib "gdi32.dll" (ByVal hdc As Long) As Long
Declare Function SetForegroundWindow       Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long
Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long

'-------------------------------------------------------------------------------------------------------------------------
'//// COMDLG.DLL  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Declare Function GetOpenFileName  Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Declare Function GetSaveFileName  Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long

'//// SHELL32.DLL  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
! ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'///  COMCTL32.DLL  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Declare Function InitCommonControlsEx Lib "comctl32.dll" (icc As INITCOMMONCONTROLSEX_TYPE) As int
Declare Function ImageList_Create Lib "comctl32.dll" (byval cx as int,byval cy as int,byval flags as int,byval cInitial as int,byval cGrow as int) as int
Declare Function ImageList_Add Lib "comctl32.dll" (ByVal cx As Int, ByVal cy As Int ByVal flags As uint, ByVal cInitial as Int, ByVal cGrow as Int) As int
Declare Function ImageList_AddMasked Lib "comctl32.dll" (byval hImageList as int,byval hBitmap as int,byval crMask as int) as int

'-----------------------------------------------------------------------------------------------------------------------------------------------
'/// WINMM.DLL ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Declare Function PlaySound  Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Declare Function timeGetTime  Lib "winmm.dll" () As Long
'------------------------------------------------------------------------------------------------------------------------------------------------
'Menu declarations
Declare Function CreatePopupMenu Lib "user32.dll" () As INT
Declare Function CreateMenu      Lib "user32.dll" () As INT
Declare Function GetMenu         Lib "user32.dll" (ByVal hwnd As INT) As INT
Declare Function SetMenu         Lib "user32.dll" (ByVal hwnd As INT, ByVal hMenu As INT) As INT
Declare Function AppendMenu      Lib "user32.dll" Alias "AppendMenuA" (ByVal hMenu As INT, ByVal wFlags As INT, ByVal wIDNewItem As INT, ByVal lpNewItem As Any) As INT
Declare Function DrawMenuBar     Lib "user32.dll" (ByVal hwnd As INT) As INT
Declare Function DeleteMenu      Lib "user32.dll" (ByVal hMenu As INT, ByVal nPosition As INT, ByVal wFlags As INT) As INT
Declare Function DestroyMenu     Lib "user32.dll" (ByVal hMenu As INT) As INT
Declare Function TrackPopupMenu  Lib "user32.dll" (ByVal hMenu As INT, ByVal wFlags As INT, ByVal x As INT, ByVal y As INT, ByVal nReserved As INT, ByVal hwnd As INT, lprc As RECT) As INT
! SetMenuItemBitmaps Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long

' AWIH declared function - to avoid #lookahed ================================================================================​================
! HiWord (byval hi as INT) as INT
! LoWord (byval lo as INT) as INT
! ControlFont (byval hwnd as INT,byval height As INT, byval width As INT, byval flag As INT,byval fontname As string)
! SetText (byval hwnd as int,byval stext as string)
! GetText (byval hwnd as int) as String
! SetRichEditBackColor(byval _Rhwnd as int, byval _backcolor as int)
! SetWindow (byval wcaption as string ,byval Wx as int,byval Wy as int, byval Ww as int, byval Wh as int, byval wparent as int, byval style as int) as int
! Wait()
! CloseWindow(byval wnd as INT) as INT
Declare Sub EndProgram()
Declare Sub GetSize(byval hnd as INT,byref hndx as INT,byref hndy as INT,byref hndw as INT,byref hndh as INT)
Declare Sub SetSize(byval hnd as INT,byval hndx as INT,byval hndy as INT,byval hndw as INT,byval hndh as INT)

! SetButton       (byval _bhwnd as int,byval _bx as int,byval _by as int,byval _bw as int,byval _bh as int, byval _btext as string,byval _bflag as int,byval _ext as int,byval _cID as INT) as int
! SetEditBox      (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
! SetListView     (byval lvhwnd as int,byval lvx as int,byval lvy as int,byval lvw as int ,byval lvh as int,byval lvstring as string,byval lvcwidth as int,byval lvflag as int,byval _ex as int,byval _cID as INT) As INT
! SetListBox      (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
! SetStatic       (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
! SetRichEdit     (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
! SetProgressBar  (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int,byval _emin as int,byval _emax as int,byval _epos as int,byval _eflag as int,byval _ext as int,byval cID as INT)
Declare Sub PBSetPos (byval _hpb as int,byval _pbpos as int)
! SetRadioButton  (byval _bhwnd as int,byval _bx as int,byval _by as int,byval _bw as int,byval _bh as int, byval _btext as string,byval _bflag as int,byval _ext as int,byval _cID as INT) as int
! SetCheckBox     (byval _bhwnd as int,byval _bx as int,byval _by as int,byval _bw as int,byval _bh as int, byval _btext as string,byval _bflag as int,byval _ext as int,byval _cID as INT) as int
! SetComboBox     (byval _cbhwnd as int,byval _cbx as int,byval _cby as int,byval _cbw as int,byval _cbh as int, byval _cbtext as string,byval _cbflag as int,byval _ext as int,byval _cID as INT) as int
! AddCBItem       (byval _cbh as INT,byval _cbpos as INT,byval _cbstring as string) as iNT
! SetTreeView     (byval _tvhwnd as INT,byval _tvx as INT,byval _tvy as INT,byval _tvw as INT,_tvh,byval tvflag as INT,byval _tvextend as INT,byval _cID as INT) as INT

! TVInsertItem    (byval hTree as INT ,byval tvPos as INT,byval itemText as string,byval hImg as INT,byval tvselect as INT ) as INT
! SetTabControl  (byval _tbhwnd as INT,byval _tx as INT,byval _ty as INT,byval _tw as INT,byval _th as INT,byval _tbflag as INT,byval _ex as INT,byval cID as INT) As INT
! AddTab         (byval hwnd as INT ,byval tbpos as INT,byval tbtext as String ) as INT
! SetTabText     (byval cntID as INT,byval tbIndex as INT,byval tabText as String)
declare SUB SetSelectedTab (byval cntID as INT,byval index as INT)
! GetSelectedTab (byval cntID as INT) as INT
! GetTabText    (byval cntID as INT,byval tbIndex as INT) as String
! GetTabCount   (byval cntID as INT) as INT
! DeleteTab     (byval cntID as INT,byval index as INT ) as INT
! SetToolbar    (byval _tbhwnd as INT,byval _tbflag as INT,byval _ex as INT,byval cID as INT) As INT
! SetToolTip    (byval _tthwnd as INT) As INT
! SetStatusBar  (byval shwnd as INT,byval stext as STRING,byval sflag as INT,byval ex as INT) as INT
! SetTrackBar   (byval thwnd as INT,byval tex as INT,byval tey as INT,byval tew as INT,byval teh as INT,byval temin INT,byval temax as INT,byval tepage as INT,byval tepos as INT,byval teflag as INT,byval text as INT,byval ttID as INT) as INT
! GetTrackPos   (byval wnd as INT) as INT
! Randomize()
! RGB(byval red as INT,byval green as INT,byval blue as INT) as INT
! Rand(byval z1 as INT, byval z2 as INT) as INT
! Key(byval cKey As INT) As INT
! EscKey() As INT
! MsgBox     (byval lpText AS STRING,byval lpCaption AS STRING) as INT
! Replace    (byref t as string,byref w as string,byref r as string) as string
! FileDialog(byval Dir As String,byval filter as String ,byval Title as String ,byval Hwnd as INT,byval Flags as INT,byref defext as INT) As String

DECLARE SUB InitDrawing(byval wnd as INT)
DECLARE SUB FillSolidRect(wID as INT, x As Long, Y As Long, cx As Long, cy As Long, bbColor as INT)
DECLARE SUB WindowColor(byval wID as INT,byval wr as INT,byval wg as INT,byval wb as INT)


' END of AWINH functions ================================================================================​=====================================
Def INT_Red   1
Def INT_Green 2
Def INT_Blue  4
Def INT_BLACK &h101010
Def INT_WHITE &hE0E0E0
Dim INT_Seed  As Long

TYPE TBADDBITMAP
     INT hInst
     INT nID
End TYPE

'define Msg,Class & ClassEx //////////////////////////////////
Dim wm as MSG
Dim rc as RECT
Dim wcx as WNDCLASSEX
INT INT_hwnd


'/////////////////////////////////////////////////////////////

INT bHnd,bHdc
INT hbrush

Dim controlID As INT
Dim notifyCode As INT
'Controls handler {{{{{{{{{{{{{{{{{{{{{{{
Dim hButton     As INT
Dim hEdit       As INT
Dim hRichEdit   As INT
Dim hScrollBar  As INT
Dim hListbox    As INT
Dim hCombobox   As INT
Dim hListView   As INT
Dim hStatic     As INT
Dim hProgress   As INT
Dim hTreeView   As INT
Dim hTabControl As INT
Dim hTBControl  As INT
Dim hTTControl  As INT
Dim hTrackBar   As INT
'}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
STRING ClassName = "Oxygen"
Dim AscKey as INT

'GLOBALS for drawing to DC ((((((((((((((((((((((((((((((((((((((((((((((((((((
INT hdc, hdcMem, hbmMem,   oldBmp, oldBrush, oldPen, oldFont, fColor,bColor
INT textX,textY,hBrush
INT ww,hh
')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))​

'--------------------------------------------
MACRO Default
DefWindowProc hwnd,wMsg,wParam,lParam
End MACRO
'---------------------------------------------
Macro RightS(s,i)
Mid(s,(-i))
End macro
'--------------------------------------------
Function HiWord (byval hi as long) as long
shr hi,16 : function=hi
End Function
'---------------------------------------------
Function LoWord (byval lo as long) as long
And lo,&hffff : function=lo
End Function
'----------------------------------------------------------------

'===============================================================================​==========================
Function ControlFont ( byval hwnd as long,byval height As Long, byval width As long, byval flag As Long,byval fontname As string)  
int hFont
hFont = CreateFont( height,width,0,0,flag,0,0,0,1,0,0,0,2,fontname)
'CreateFont(_fsize,0,0,0,_ff,_fi,_fu,_fs,1,0,0,0,2,_fname)
SendMessage hwnd,WM_SETFONT,hfont,1
End Function
'----------------------------------------------------------------------
Function SetText (byval hwnd as int,byval stext as string)
SendMessage hwnd,WM_SETTEXT,0,strptr(stext)
UpdateWindow hwnd
End Function
'-------------------------------------------------------------------
Function GetText (byval hwnd as int) as string
char display[255]=""
SendMessage hwnd,WM_GETTEXT,255, display
Return display
End Function
'===============================================================================​=====================
Function SetRichEditBackColor(byval _ehwnd as int, byval _ecolor as int)
  SendMessage(_ehwnd, 1091,0,_ecolor) 'EM_SETBKGNDCOLOR=1091
End Function
'===============================================================================​======================

Function SetWindow (byval caption as string ,byval Wx as int,byval Wy as int, byval Ww as int, byval Wh as int, byval wparent as int, byval style as int) as int
inst = GetModuleHandle 0
int reg
wcx.cbSize        = SizeOf(WNDCLASSEX)
wcx.style         = CS_DBLCLKS |CS_OWNDC
wcx.lpfnWndProc   = &WndProc
wcx.cbClsExtra    = 0
wcx.cbWndExtra    = 0
wcx.hInstance     = inst
wcx.hIcon         = LoadIcon 0,IDI_APPLICATION        
wcx.hCursor       = LoadCursor 0,IDC_ARROW      
wcx.hbrBackground = CreateSolidBrush(GetSysColor(15))
wcx.lpszMenuName  = strptr ""
wcx.lpszClassName = strptr ClassName
wcx.hIconSm       = LoadIcon 0,IDI_APPLICATION

reg = RegisterClassEx(wcx)
'print "REGISTRED:" + str reg

'create window -------------------------------------------------------------------------------------
INT_hwnd = CreateWindowEx 0, ClassName, caption, style, Wx, Wy, Ww, Wh, wparent, 0, inst, 0
'---------------------------------------------------------------------------------------------------
'IF style <> WS_HIDDEN
ShowWindow INT_hwnd, SW_SHOW
'END IF
UpdateWindow INT_hwnd
'INT_hdc = GetDC(INT_hwnd)
'bHnd = CreateCompatibleBitmap(INT_hdc,ww,wh)
'bHdc = CreateCompatibleDC(INT_hdc)
'SelectObject bHdc, bHnd
'Width = ww
'Height= wh
INT_Seed = timeGetTime
'QueryPerformanceFrequency INT_qf
'QueryPerformanceCounter   INT_qc1
'print "WINDOW:" + Str(INT_hwnd)
Function = INT_hwnd
End Function

'- Msg Loop -----------------------------------------------------------------------------------
Function Wait()

  'INT _message
  While GetMessage(wm,0,0,0) <> 0
'   _message = wm
     Translatemessage wm
     DispatchMessage wm  
  Wend
  
End Function

'----------------------------------------------------------------------------------------------
Function CloseWindow(wnd as INT) as INT
DestroyWindow wnd
'PostQuitMessage 0
Return wnd=0
End Function

'----------------------------------------------------------------------------------------------
Sub EndProgram
PostQuitMessage 0
End Sub

'GetClientsize --------------------------------------------------------------------------------
SUB GetSize(byval hnd as INT,byref hndx as INT,byref hndy as INT,byref hndw as INT,byref hndh as INT)
GetClientRect(hnd,rc)
'hndx=0:hndy=0:hndw=0:hndh=0
hndx = rc.left
hndy = rc.top
hndw = rc.right
hndh = rc.bottom

End SUB

'SetSize() --------------------------------------------------------------------------------------
SUB SetSize(byval hnd as INT,byval hndx as INT,byval hndy as INT,byval hndw as INT,byval hndh as INT)
INT sdata[4]
sdata[0]=hndx
sdata[1]=hndy
sdata[2]=hndw
sdata[3]=hndh
'SetWindowPos(hnd,0,sdata[0],sdata[1],sdata[2],sdata[3],0)
MoveWindow(hnd,sdata[0],sdata[1],sdata[2],sdata[3],1)

End SUB
'===============================================================================​================
'syn : SetButton (hwnd,x,y,w,h,caption$,style,ext,controlID)
Function SetButton(byval _bhwnd as int,byval _bx as int,byval _by as int,byval _bw as int,byval _bh as int, byval _btext as string,byval _bflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
If _bflag=0
    _bflag = 0x50000000
EndIf
_ext = 0
hButton = CreateWindowEx(_ext,"BUTTON",_btext,_bflag,_bx,_by,_bw,_bh,_bhwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hButton,WM_SETFONT,_hfont,0
UpdateWindow _bhwnd
Function = hButton
End Function
'===============================================================================​================
'syn : SetEditBox (hwnd,x,y,w,h,caption$,style,ext)
Function SetEditBox(byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
If _eflag=0
    _eflag = 0x50800000
EndIf
hEdit = CreateWindowEx(_ext,"EDIT",_etext,_eflag,_ex,_ey,_ew,_eh,_ehwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hEdit,WM_SETFONT,_hfont,0
UpdateWindow _ehwnd
Function = hEdit
End Function

'===============================================================================​================
Function SetListBox (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
If _eflag=0
    _eflag = 0x50A00140 Or CTLISTNOTIFY
EndIf
hListbox = CreateWindowEx(_ext,"LISTBOX",_etext,_eflag,_ex,_ey,_ew,_eh,_ehwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hListbox,WM_SETFONT,_hfont,0
UpdateWindow _ehwnd
Function = hListbox
End Function

'create ListView ==============================================================================
Function SetListView (byval lvhwnd as int,byval _lvx as int,byval _lvy as int,byval _lvw as int ,byval _lvh as int,byval lvstring as string,byval lvcwidth as int,byval _lvflag as int,byval _ex as int,byval _cID as INT) As INT
'
  If _lvflag=0
   _lvflag = 1409351681 | 8
  End If
  hListView = CreateWindowEx(_ex,"SysListView32","",_lvflag,_lvx,_lvy,_lvw,_lvh,lvhwnd,_cID,0,0)
  LV_COLUMN.cmask       = 7 'LVCF_FMT|LVCF_TEXT|LVCF_WIDTH
  LV_COLUMN.cfmt        = 0 '  LVCFMT_LEFT
  LV_COLUMN.ccx         = lvcwidth
  LV_COLUMN.cpszText    = strptr(lvstring)
  LV_COLUMN.ccchTextMax = sizeof(lvstring)+1
  LV_COLUMN.ciSubItem   = 0
  SendMessage(hListView, LVM_INSERTCOLUMN, 0, LV_COLUMN) ' listview insert column 4123
  'GetAsyncKeyState(VK_LBUTTON)
   UpdateWindow lvhwnd
  Function = hListView
End Function
'-------------------------------------------------------------------------------------
'add list view column  {AddLVC hwnd, pos, width , text, flag}
Function AddListViewColumn (byval _lvhandle as int,byval _lvpos as int,byval _lvcwidth as int,byval lvstring as string,byval _lvflag as INT) as INT
  LV_COLUMN.cmask      = 7
  LV_COLUMN.cfmt       = 0
  LV_COLUMN.ccx        =_lvcwidth
  LV_COLUMN.cpszText   = strptr(lvstring)
  SendMessage( _lvhandle, LVM_INSERTCOLUMN,_lvpos,LV_COLUMN)
End Function
'-----------------------------------------------------------------------------------.
'add listview item {AddLVI hwnd, pos, text, icon}
Function AddListViewItem (byval _lvhandle as int,byval _lvpos as int,byval lvstring as string,byval _lvicon as int) as int
  INT lvflag
  lvflag = 4097 '#LVIF_TEXT|#LVIF_DI_SETITEM
  If _lvicon
    lvflag = 3 '#LVIF_TEXT|#LVIF_IMAGE
  End If
  LV_ITEM.mask      = lvflag
  LV_ITEM.iItem     = _lvpos
  LV_ITEM.iSubItem  = 0
  LV_ITEM.pszText   = strptr(lvstring)
  LV_ITEM.iImage    =_lvicon
  SendMessage(_lvhandle,LVM_INSERTITEM, _lvpos, LV_ITEM) 'list view insert item
End Function
'----------------------------------------------------------------------------------
'add list view sub item
Function AddListViewSubItem (byval _lvhandle as int,byval _lvpos as int,byval _lvsub as int,byval lvstring as string)as INT
  LV_ITEM.mask      = 4097    '#LVIF_TEXT|#LVIF_DI_SETITEM
  LV_ITEM.iItem     = _lvpos
  LV_ITEM.iSubItem  = _lvsub
  LV_ITEM.pszText   = strptr(lvstring)
  SendMessage(_lvhandle, LVM_SETITEM, 0, LV_ITEM)
End Function
'===============================================================================​================
Function SetStatic (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
If _eflag=0
    _eflag = 0x5000010B
EndIf
hStatic = CreateWindowEx(_ext,"STATIC",_etext,_eflag,_ex,_ey,_ew,_eh,_ehwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hStatic,WM_SETFONT,_hfont,0
UpdateWindow _ehwnd
Function = hStatic
End Function

'===============================================================================​======
Function SetRichEdit (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int, byval _etext as string,byval _eflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
If _eflag=0
'0x50800080 single , 0x50B010C4 multiline
    _eflag = 0x50800080 Or ES_SUNKEN
EndIf
hRichEdit = CreateWindowEx(_ext,"richedit20a",_etext,_eflag,_ex,_ey,_ew,_eh,_ehwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hRichEdit,WM_SETFONT,_hfont,0
UpdateWindow _ehwnd
Function = hRichEdit
End Function
'===============================================================================​======
'SetProgressbar(hwnd,x,y,w,h,min,max,pos,flag,ext)
Function SetProgressBar (byval _ehwnd as int,byval _ex as int,byval _ey as int,byval _ew as int,byval _eh as int,byval _emin as int,byval _emax as int,byval _epos as int,byval _eflag as int,byval _ext as int,byval cID as INT)
  If _eflag = 0 then
    _eflag=WS_CHILD Or WS_VISIBLE
  End If
  hprogress = CreateWindowEx(_ext,"msctls_progress32","",_eflag,_ex,_ey,_ew,_eh,_ehwnd,cID,0,0)
  'UpdateWindow hprogress
  SendMessage(hprogress,PBM_SETRANGE32,_emin,_emax)
  SendMessage(hprogress,PBM_SETPOS,_epos,0)
   UpdateWindow hprogress
  Return hprogress
End Function
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::​::::::
'Progress SET  POSITION
SUB PBSetPos (byval _hpb as int,byval _pbpos as int)
If _hpb <> 0
SendMessage(_hpb,PBM_SETPOS,_pbpos,0)
UpdateWindow _hpb
End If
End SUB
'===============================================================================​======
'syn : SetRadioButton (hwnd,x,y,w,h,caption$,style,ext,controlID)
Function SetRadioButton(byval _bhwnd as int,byval _bx as int,byval _by as int,byval _bw as int,byval _bh as int, byval _btext as string,byval _bflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
If _bflag=0
    _bflag = 0x50000009
End If
_ext = 0
hButton = CreateWindowEx(_ext,"BUTTON",_btext,_bflag,_bx,_by,_bw,_bh,_bhwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hButton,WM_SETFONT,_hfont,0
UpdateWindow _bhwnd
Function = hButton
End Function
'===============================================================================​======
'syn : SetCheckBox (hwnd,x,y,w,h,caption$,style,ext,controlID)
Function SetCheckBox (byval _bhwnd as int,byval _bx as int,byval _by as int,byval _bw as int,byval _bh as int, byval _btext as string,byval _bflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
If _bflag=0
    _bflag = 0x50008003
End If
_ext = 0
hButton = CreateWindowEx(_ext,"BUTTON",_btext,_bflag,_bx,_by,_bw,_bh,_bhwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hButton,WM_SETFONT,_hfont,0
UpdateWindow _bhwnd
Function = hButton
End Function
'===============================================================================​======
Function SetComboBox(byval _cbhwnd as int,byval _cbx as int,byval _cby as int,byval _cbw as int,byval _cbh as int, byval _cbtext as string,byval _cbflag as int,byval _ext as int,byval _cID as INT) as int
INT _hfont
  If _cbflag=0
    _cbflag = 0x50A00603
  EndIf
  hComboBox = CreateWindowEx(_ext,"COMBOBOX",_cbText,_cbflag,_cbx,_cby,_cbw,_cbh,_cbhwnd,_cID,0,0)
_hfont = GetStockObject(17)
SendMessage hComboBox,WM_SETFONT,_hfont,0
UpdateWindow _cbhwnd
Function = hComboBox
End Function
'-------------------------------------------------------------------------------------------------
Function AddCBItem(byval _cbh as INT,byval _cbpos as INT,byval _cbstring as string) as iNT
  Function = SendMessage(_cbh, 330,_cbpos, strptr _cbstring) ' cb_insertString=330
End Function

'===============================================================================​======
Function SetTreeView (byval _tvhwnd as INT,byval _tvx as INT,byval _tvy as INT,byval _tvw as INT,_tvh,byval tvflag as INT,byval _tvextend as INT,byval _cID as INT) as INT
  'INT hTreeView
  If tvflag=0
    tvflag= tvflag | WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT
  End If
  'If _tvinit=0
   ' FirstTreeViewInit()
  'EndIf
hTreeView  = CreateWindowEx(_tvextend,"SysTreeView32","",tvflag,_tvx,_tvy,_tvw,_tvh,_tvhwnd,_cID,0,0)
UpdateWindow _tvhwnd
  Function = hTreeView
End Function

'-------------------------------------------------------------------------------------
'FN -> InsertItem (hwnd ,tPos, text, img, select)
Function TVInsertItem (byval hTree as INT, byval tvPos as INT, byval tvText as string , byval hImg as INT, byval tvselect as INT ) as INT
INT h
'tvi.mask           = TVIF_TEXT | TVIF_IMAGE | TVSELECTEDIMAGE
tvi.hitem             = tvPos
tvi.mask           = TVIF_TEXT | TVIF_IMAGE | TVSELECTEDIMAGE
tvi.state          = 0
tvi.statemask      = 0
tvi.pszText        = strptr(tvText)
tvi.cchtextmax    = sizeof(tvText)+1
tvi.iImage        = himg
tvi.iSelectedImage = tvselect

h = SendMessage(hTree, 4352, 0, tvi)
'UpdateWindow hTree
Function = h
End function

'===============================================================================​======
Function SetTabControl (byval _tbhwnd as INT,byval _tx as INT,byval _ty as INT,byval _tw as INT,byval _th as INT,byval _tbflag as INT,byval _ex as INT,byval cID as INT) As INT
INT _hfont
  If _tbflag=0
    _tbflag=WS_CHILD | WS_VISIBLE| TCS_HOTTRACK
  End If
  
  hTabControl = CreateWindowEx(_ex,"SysTabControl32","",_tbflag,_tx,_ty,_tw,_th,_tbhwnd,cID,0,0)
_hfont = GetStockObject(17)
SendMessage hTabControl,WM_SETFONT,_hfont,0
  UpdateWindow _tbhwnd
Function = hTabControl
End Function
'===============================================================================​======
'AddTab
Function AddTab (byval hwnd as INT ,byval tbpos as INT,byval tbtext as String ) as INT
TC_ITEM tie
tie.mask=1
tie.pszText= strptr(tbtext)
tie.cchTextMax=Len(tbtext)
tie.iImage = -1
SendMessage(hWnd,0x1307,tbpos,&tie)

End Function
'===============================================================================​======
Function SetTabText (cntID as INT,tbIndex as INT,tabText as String)
TC_ITEM tie
tie.mask=1
tie.pszText= strptr(tabText)
tie.cchTextMax=Len(tabtext)
tie.iImage = -1
SendMessage(cntID,TCM_SETITEM,tbIndex,&tie)
Return
End Function

'===============================================================================​======
SUB SetSelectedTab (cntID as INT,index as INT)
Sendmessage (cntID,TCM_SETCURSEL,index,0)

'Return tbIndex
End Sub
'===============================================================================​======

Function GetSelectedTab (cntID as INT) as INT
INT tbIndex
tbIndex = Sendmessage (cntID,TCM_GETCURSEL,0,0)

Return tbIndex
End Function

'===============================================================================​======
Function GetTabText (cntID as INT,tbIndex as INT) as string
string tabText=Space(256)
TC_ITEM tie
tie.mask=1
tie.pszText = strptr tabText
tie.cchTextMax = 256
tie.iImage = -1
Sendmessage (cntID,TCM_GETITEM,tbIndex,&tie)
Return tabText
End Function
'===============================================================================​======
Function GetTabCount (cntID as INT) as INT
INT tbCount
tbCount = Sendmessage (cntID,TCM_GETITEMCOUNT,0,0)
Return tbCount
End Function
'===============================================================================​======
Function DeleteTab (cntID as INT, index as INT ) as INT
Sendmessage (cntID,TCM_DELETEITEM,index,0)
Return 0
End Function

'===============================================================================​======

Function SetToolbar (byval _tbhwnd as INT,byval _tbflag as INT,byval _ex as INT,byval cID as INT) As INT
INT _hfont
INT  TBSTYLES = TBSTYLE_FLAT | WS_CHILD | WS_VISIBLE
  If _tbflag = 0
    _tbflag = 1342179328 | TBSTYLES |4 | &H100
  Else
   _tbflag=1342179328 | TBSTYLES |4 | _tbflag
  End If
  
  hTBControl = CreateWindowEx(_ex,"TOOLBARWINDOW32","",_tbflag,0,0,0,0,_tbhwnd, cID,0,0)
_hfont = GetStockObject(17)
SendMessage hTBControl,WM_SETFONT,_hfont,0
  UpdateWindow _tbhwnd
Function = hTBControl
End Function


'===============================================================================​======
'set tooltip control
Function SetToolTip (byval _tthwnd as INT) As INT
INT _hfont


hTTControl = CreateWindowEx(0,"tooltips_class32","", -805306368,0,0,0,0,_tthwnd,0,0,0)
SendMessage( _tthwnd, 1060, hTTControl,0)


Function = hTTControl
End Function

'===============================================================================​======
'Statusbar...
Function SetStatusBar (byval shwnd as INT,byval stext as STRING,byval sflag as INT,byval ex as INT) as INT
  If sflag=0
    sflag= 1409286400
    sflag = WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
  End If
  hStatus =CreateWindowEx(ex,"msctls_statusbar32",stext,sflag,0,0,0,0,shwnd,0,0,0)
'UpdateWindow shwnd  
  Return hStatus
End Function
'===============================================================================​========
'Trackbar...
Function SetTrackBar (byval _thwnd as INT,byval _ex as INT,byval _ey as INT,byval _ew as INT, byval _eh as INT, byval _emin as INT, byval _emax as INT, byval _epage as INT, byval _epos as INT, byval _eflag as INT, byval _ext as INT ,byval _tID as INT) as INT
  
  If _eflag=0
    _eflag = TRACKBARNORMAL |_eflag
  End If
  hTrackbar=CreateWindowEx(_ext,"msctls_trackbar32","",_eflag,_ex,_ey,_ew,_eh,_thwnd,_tID,0,0)
  SendMessage(hTrackbar, TBM_SETPAGESIZE, 0,byval _epage)
  SendMessage(hTrackbar, TBM_SETRANGEMIN, 0,byval _emin )
  SendMessage(hTrackbar, TBM_SETRANGEMAX, 0,byval _emax )
  SendMessage(hTrackbar, TBM_SETPOS,      1,byval _epos )
  Function = hTrackbar
End Function
'---------------------------------------------------------------------------------------
Function GetTrackPos (byval wnd as INT) as INT
INT tpos
  tpos=SendMessage( wnd , 1024,0,0)
Return tpos
End Function


'===============================================================================​======
Function Randomize()
INT_Seed = timeGetTime
End Function

'===============================================================================​======

Function RGB(byval red as INT,byval green as INT,byval blue as INT) as INT
  INT color
  color = red
  color = color + green*256
  color = color + blue*65536
  Return color
End Function


'===============================================================================​======


Function Rand(byval z1 as INT, byval z2 as INT) as INT
INT rnd
mov  eax,z2
sub  eax,z1
Inc  eax
imul edx,INT_Seed,0x8088405
Inc  edx
mov  INT_Seed,edx
mul  edx
add  edx,z1
mov  rnd,edx
Function = rnd
End Function



Function Key(byval cKey As INT) As INT
Function = GetAsyncKeyState(cKey)
End Function

Function EscKey() As INT
Function = GetAsyncKeyState(27)
End Function



'MsgBox--------------------------------
Function MsgBox (byval lpText AS STRING,byref lpCaption AS STRING) as INT
If lpCaption = "" then lpCaption="<MsgBox>"
Function =  MessageBox 0, lpText, lpCaption, 0
End Function
'---------------------------------------
Function Replace(byref t as string,byref w as string,byref r as string) as string
  '=======================================
  '
  INT a,b,lw,lr
  string s=t
  '
  lw=Len(w)
  lr=Len(r)
  a=1
  '  
  do
    a=Instr(a,s,w)
    If a=0 then exit do
    s=Left(s,a-1)+r+Mid(s,a+lw)
    a+=lr
  End do
  Return s
End Function
'----------------------------------
Macro Trim(dirty )
  Ltrim(Rtrim(dirty))    
End macro
'---------------------------------------------------------------------------------------
'FileDialog( $ iDir , $ filter ,$ title , % parent ,% flag )
Function FileDialog(byval Dir As String,byval filter as string ,byval Title as string ,byval Hwnd as INT,byval Flags as INT,byref defext as INT) As String
Dim ofn As OPENFILENAME
Dim filename[255] As zstring
INT retval    
    
ofn.lStructSize = 76
ofn.hwndOwner = hWnd
ofn.hInstance = GetModuleHandle(0)
ofn.lpstrFilter = ?filter
ofn.lpstrCustomFilter= NULL
ofn.nMaxCustFilter = 0
ofn.nFilterIndex = 2
ofn.lpstrFile = @filename 'zstring buffer
ofn.nMaxFile = 255
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = ?dir
ofn.lpstrTitle = ?title
If Flags = 0 then ofn.Flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
If Flags = 1 then ofn.Flags = OFN_EXPLORER Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
ofn.nFileOffset = 0
ofn.nFileExtension = 0
ofn.lpstrDefExt = ?defext
ofn.lCustData = 0
ofn.lpfnHook = 0
ofn.lpTemplateName = NULL

' Execute the dialog box
If Flags = 0 then retval = GetOpenFileName(ofn)
If Flags = 1 then retval = GetSaveFileName(ofn)
    
Return filename

End Function

'*****************************************************************************
'*******    I N I T    H D C    D R A W I N G        *************************
'*****************************************************************************
SUB InitDrawing(byval wnd as INT)
'static ww,hh as int
''get current size of window
GetSize(wnd,0,0,ww,hh)
'get window DC
hdc      = GetDC(wnd)
hdcMem   = CreateCompatibleDC(0)
hbmMem   = CreateCompatibleBitmap(hdc,ww,hh)
oldBmp   = SelectObject( hdcMem, hbmMem )
oldBrush = SelectObject(hdcMem, CreateSolidBrush( RGB(231,223,231)) )
oldPen   = SelectObject(hdcMem, CreatePen(PS_SOLID,1,RGB(231,223,231)))
'fill rectangle memDC with brush color
rc.right = ww + 1000
rc.bottom = hh + 1000

FillRect ( hdcMem,rc, oldBrush)
SetTextColor( hDC,RGB(0,0,0))
SetBkColor( hDC, RGB(231,223,231))
'blit to memDC
BitBlt(hDCmem, 0, 0, ww, hh, hdc, 0, 0, SRCCOPY)
'UpdateWindow wnd
ReleaseDC( wnd, hdc)
End SUB

' set window color =========================================================================
Sub FillSolidRect(wID as INT, x As Long, Y As Long, cx As Long, cy As Long, bbColor as INT)
    Dim hBr As Long ' rc As RECT
    hDC=GetDC(wID)
    rc.Left = x
    rc.Top = Y
    rc.right = x + cx
    rc.bottom = Y + cy
    hBr = CreateSolidBrush(bbColor)
    FillRect hDC, rc, hBr

    BitBlt(hdcMem, 0, 0, ww, hh, hdc, 0, 0, SRCCOPY)

    ReleaseDC( wID, hdc)
End Sub
'-----------------------------------------------------------------------------------------
SUB WindowColor(byval wID as INT,byval wr as INT,byval wg as INT,byval wb as INT)
INT backColor = RGB (wr,wg,wb)
FillSolidRect(wID,0,0,ww,hh,backColor)
End SUB    
'===============================================================================​=============
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: