--Создание и настройка окна программы
window_handle=WindowsCreate("Example: 'MaxWinApi2'",WS_OVERLAPPED,WS_SYSMENU,0,0,0,800,600,0)
WindowCenter(window_handle)
WindowSetIcon(window_handle,"Logo.ico")

--Инициализация движков программы
Init_MaxWinAPI2("Max WinAPI 2.dll")--Активация модуля MaxWinApi2

win = window_handle
aCheckSet(2,win)

win_Static1 = aStaticCreate(win,5,5,100,50)
win_Edit1   = aEditCreate(win,5,60,100,30)
win_Radio1  = aButtonCreate(win,5,90,100,20,WindowsStyleAdd(BS_AUTORADIOBUTTON,WS_GROUP))
win_Radio2  = aButtonCreate(win,5,110,100,20,BS_AUTORADIOBUTTON)
aControlSettext(win_Static1,"I'm a static control, drawed in a GM window.")
aControlSettext(win_Edit1,"Edit me, please.")
aControlSettext(win_Radio1,"Radio 1")
aControlSettext(win_Radio2,"Radio 2")

Bitmap_Static = aResourceLoadbitmap("data/WinStyle/Static.bmp")
Bitmap_Edit   = aResourceLoadbitmap("data/WinStyle/Edit.bmp")
Bitmap_Radio1 = aResourceLoadbitmap("data/WinStyle/Radio1.bmp")
Bitmap_Radio2 = aResourceLoadbitmap("data/WinStyle/Radio2.bmp")

aStylingSetbackbitmap(win_Static1,Bitmap_Static)
aStylingSetbackbitmap(win_Edit1,Bitmap_Edit)
aStylingSetbackbitmap(win_Radio1,Bitmap_Static)
aStylingSetbackbitmap(win_Radio2,Bitmap_Radio2)

win_parent = aWindowGetparent(win)

Win = aWindowCreate(0,0,200,1024,720,WindowsStyleAdd(WS_OVERLAPPEDWINDOW,WS_HSCROLL,WS_EX_ACCEPTFILES))

ToolbarSpace = 0
aWindowSettext(Win,"Max WinAPI 2 Example")

GbGradient = aGraphbufCreate(16,16)
DcGradient = aGraphbufGetdc(GbGradient)
aDrawGradient(DcGradient,0,0,16,16,0,cYellow,cLime)
GbGradient2 = aGraphbufCreate(75,20)
DcGradient2 = aGraphbufGetdc(GbGradient2)
aDrawGradient(DcGradient2,0,0,75,20,0,cYellow,cLime)
BmBrush2 = aGraphbufGetbitmap(GbGradient2)

IcSystray = 0
GbSystray = aGraphbufCreate(16,16)
DcSystray = aGraphbufGetdc(GbSystray)

Menu = aMenuCreate()

Menu_File = aMenuCreatepopup()

aMenuAddmenu(Menu,Menu_File,"&File")

Menu_File_Open = aMenuAddstring(Menu_File,"&Open")
aMenuAddseparator(Menu_File)
Menu_File_Save = aMenuAddstring(Menu_File,"&Save")
aMenuAddseparator(Menu_File)
Menu_File_Exit = aMenuAddstring(Menu_File,"&Exit")

aMenuSet(Win,Menu)
 
Toolbar = aToolbarCreate(Win,0,0)

aToolbarAddsystembitmaps(Toolbar,1)

for i=0, 14 do
	aToolbarAddbuttonimage(Toolbar,i,i)
	--aToolbar_AddButton(Toolbar,i,i)
	--aToolbar_AddButtonText(Toolbar,i,"String Text "+string(i))
end

--aToolbar_AddButtonImage(Toolbar,0,STD_FILENEW)
--aToolbar_AddButtonImage(Toolbar,1,STD_FILEOPEN)
--aToolbar_AddButtonImage(Toolbar,2,STD_FILESAVE)

aToolbarAutosize(Toolbar)

ToolbarSpace = aControlGetheight(Toolbar)

Rebar = aRebarCreate(Win)

Rebar_Band1 = 0
Rebar_Band2 = 1
Rebar_Band3 = 2

aRebarInsertband(Rebar,Rebar_Band1,RBBS_TOPALIGN)
aRebarInsertband(Rebar,Rebar_Band2,RBBS_TOPALIGN)
aRebarInsertband(Rebar,Rebar_Band3,RBBS_TOPALIGN)

aRebarSetbandsizes(Rebar,Rebar_Band2,50,15,15,15)
aRebarSetbandsizes(Rebar,Rebar_Band3,400,15,15,15)

hRebar = aControlGethandle(Rebar)

Rebar_Progress1 = aProgressCreate(hRebar,0,0,0,0)

aRebarSetbandtext(Rebar,Rebar_Band1,"I'm a rebar control")
aRebarSetbandchild(Rebar,Rebar_Band2,aControlGethandle(Rebar_Progress1))

aControlSetpos(Rebar,0,ToolbarSpace)

ToolbarSpace = ToolbarSpace + aRebarGetbarheight(Rebar)

Status1 = aStatusCreate(Win)

aStatusSetparts(Status1,3,100,200,200)

aStatusSettext(Status1,0,"Statusbar...")
aStatusSettext(Status1,1,"You can click me...")

StatusSpace = aControlGetheight(Status1)

aWindowSetzorder(Win,HWND_TOPMOST)
aWindowSetzorder(Win,HWND_TOP)

aScrollSetrange(Win,0,0,100,10)

aStylingSetautotransparency(1)

aCheckSet(1,Win)

aWindowSetfocus(win)

ClientWidth = aWindowGetclientwidth(Win)
ClientHeight = aWindowGetclientheight(Win)

Static1 = aStaticCreate(Win,5,5+ToolbarSpace,790,70,SS_BITMAP)
Bitmap1 = aResourceLoadbitmap("toplogo.bmp")
aStaticSetimage(Static1,0,Bitmap1)

Win_Tab = aTabCreate(Win,6,80+ToolbarSpace,ClientWidth-211,ClientHeight-110-ToolbarSpace-StatusSpace,WS_CLIPSIBLINGS)

X = aControlGetx(Win_Tab)
Y = aControlGety(Win_Tab)
W = aControlGetwidth(Win_Tab)
H = aControlGetheight(Win_Tab)

aStylingSetautotransparency(0)

Win_StatusEdit = aEditCreate(Win,ClientWidth-200,5+ToolbarSpace,195,ClientHeight-15-ToolbarSpace-StatusSpace,WindowsStyleAdd(ES_MULTILINE,ES_AUTOVSCROLL,ES_READONLY),WS_EX_CLIENTEDGE)

StatusText = ""

aStylingSetautotransparency(1)

--aWindow_Redraw(Win)


Tab = aControlGethandle(Win_Tab)

aWindowRedraw(Tab)

--aWindow_Show(Tab,SW_SHOW)

aTabInsertitem(Win_Tab,0,"Controls")
aTabInsertitem(Win_Tab,1,"Search")

aControlSetautotab(0)

Group1 = aButtonCreate(Tab,5,25,ClientWidth-225,ClientHeight-142-ToolbarSpace,WindowsStyleAdd(BS_GROUPBOX,BS_NOTIFY))
aControlSettext(Group1,"Group control")

Static2 = aStaticCreate(Tab,10,40,100,20)
aControlSettext(Static2,"Static control")

Group2 = aButtonCreate(Tab,10,60,215,60,WindowsStyleAdd(BS_GROUPBOX,BS_NOTIFY))
aControlSettext(Group2,"Checkboxes")

Checkbox1 = aButtonCreate(Tab,15,75,100,20,WindowsStyleAdd(BS_AUTOCHECKBOX,BS_NOTIFY))
Checkbox2 = aButtonCreate(Tab,120,75,100,20,WindowsStyleAdd(BS_AUTOCHECKBOX,BS_NOTIFY))
Checkbox3 = aButtonCreate(Tab,15,95,100,20,WindowsStyleAdd(BS_AUTOCHECKBOX,BS_NOTIFY))
Checkbox4 = aButtonCreate(Tab,120,95,100,20,WindowsStyleAdd(BS_AUTOCHECKBOX,BS_NOTIFY))

aControlSettext(Checkbox1,"Checkbox 1")
aControlSettext(Checkbox2,"Checkbox 2")
aControlSettext(Checkbox3,"Checkbox 3")
aControlSettext(Checkbox4,"Checkbox 4")

aButtonSetcheck(Checkbox1,BST_CHECKED)
aButtonSetcheck(Checkbox3,BST_CHECKED)

Group3 = aButtonCreate(Tab,230,60,215,60,BS_GROUPBOX)

Radio1a = aButtonCreate(Tab,235,75,100,20,WindowsStyleAdd(BS_AUTORADIOBUTTON,WS_GROUP,BS_NOTIFY))
Radio1b = aButtonCreate(Tab,340,75,100,20,WindowsStyleAdd(BS_AUTORADIOBUTTON,BS_NOTIFY))
Radio2a = aButtonCreate(Tab,235,95,100,20,WindowsStyleAdd(BS_AUTORADIOBUTTON,WS_GROUP,BS_NOTIFY))
Radio2b = aButtonCreate(Tab,340,95,100,20,WindowsStyleAdd(BS_AUTORADIOBUTTON,BS_NOTIFY))

aButtonSetcheck(Radio1a,BST_CHECKED)
aButtonSetcheck(Radio2b,BST_CHECKED)

aControlSettext(Radio1a,"Radio 1a")
aControlSettext(Radio2a,"Radio 2a")
aControlSettext(Radio1b,"Radio 1b")
aControlSettext(Radio2b,"Radio 2b")

Button1 = aButtonCreate(Tab,450,75,75,20,BS_NOTIFY)
Button2 = aButtonCreate(Tab,450,95,75,20,BS_NOTIFY)

aControlSettext(Button1,"Button 1")
aControlSettext(Button2,"Button 2")

aStylingSetautotransparency(0)
Edit1 = aEditCreate(Tab,530,75,75,20,WindowsStyleAdd(ES_AUTOHSCROLL,WS_TABSTOP),WS_EX_CLIENTEDGE)

aStylingSetbackbitmap(Edit1,BmBrush2)

Updown1 = aUpdownCreate(Tab,0,0,10,15,WindowsStyleAdd(UDS_SETBUDDYINT,UDS_ARROWKEYS,UDS_ALIGNRIGHT))

aUpdownSetbuddy(Updown1,Edit1) --Set Buddy
aUpdownSetrange(Updown1,0,100) --Set Range

aStylingSetautotransparency(1)
Edit2 = aEditCreate(Tab,530,95,75,20,WindowsStyleAdd(ES_AUTOHSCROLL,WS_TABSTOP))

aControlSettext(Edit1,"0")
aControlSettext(Edit2,"Edit 2")

Ip1 = aIpaddressCreate(Tab,610,75,100,20)
Ip2 = aIpaddressCreate(Tab,610,96,100,20)

aIpaddressSetvalue(Ip1,168,0,0,81)
aIpaddressSetvalue(Ip2,255,255,255,0)

aStylingSetautotransparency(0)

Listbox1 = aListboxCreate(Tab,10,125,150,175,WindowsStyleAdd(LBS_NOINTEGRALHEIGHT,LBS_NOTIFY),WS_EX_CLIENTEDGE)

aListboxAddstring(Listbox1,"Listbox string 1")
aListboxAddstring(Listbox1,"Listbox string 2")
aListboxAddstring(Listbox1,"Listbox string 3")
aListboxAddstring(Listbox1,"Listbox string 4")

Listview1 = aListviewCreate(Tab,165,125,150,175,WindowsStyleAdd(LVS_REPORT,WS_EX_CLIENTEDGE))

aListviewSetextendedstyle(Listview1,LVS_EX_FULLROWSELECT)

aListviewInsertcolumntext(Listview1,0,30,"ID")
aListviewInsertcolumntext(Listview1,1,115,"Name")

aListviewInsertitemtext(Listview1,0,0,"0")
aListviewInsertitemtext(Listview1,1,0,"Listview Item 0")
aListviewInsertitemtext(Listview1,0,1,"1")
aListviewInsertitemtext(Listview1,1,1,"Listview Item 1")
aListviewInsertitemtext(Listview1,0,2,"2")
aListviewInsertitemtext(Listview1,1,2,"Listview Item 2")

Calendar1 = aMonthcalCreate(Tab,320,125,175,175,0,WS_EX_CLIENTEDGE)

RichEdit1 = aRicheditCreate(Tab,500,125,175,175,0,WS_EX_CLIENTEDGE)

aRicheditLoadfile(RichEdit1,"Document.rtf")

Combobox1 = aComboboxCreate(Tab,10,305,175,20,WindowsStyleAdd(CBS_HASSTRINGS,CBS_DROPDOWNLIST))

aComboboxAddstring(Combobox1,"Combobox string 1")
aComboboxAddstring(Combobox1,"Combobox string 2")
aComboboxAddstring(Combobox1,"Combobox string 3")

aComboboxSetsel(Combobox1,0)

Hotkey1 = aHotkeyCreate(Tab,10,330,175,20)

aHotkeySetkey(Hotkey1,HOTKEYF_ALT,vk_f4)

DateTime1 = aDatetimeCreate(Tab,10,355,175,20)

Progress1 = aProgressCreate(Tab,10,380,175,15)

aStylingSetautotransparency(1)

--Trackbar1 = aTrackbar_Create(Tab,10,400,175,20)

aStylingSetautotransparency(0)

Scrollbar1 = aScrollbarCreate(Tab,10,425,175,15,SBS_HORZ)
aScrollbarEnable(Scrollbar1,ESB_ENABLE_BOTH)
aScrollbarSetrange(Scrollbar1,0,1000,500)
aScrollbarSetpos(Scrollbar1,50)

aScrollbarShow(Scrollbar1,1)

Treeview1 = aTreeviewCreate(Tab,190,305,175,125,WindowsStyleAdd(TVS_LINESATROOT,TVS_HASBUTTONS,TVS_HASLINES,TVS_EDITLABELS),WS_EX_CLIENTEDGE)

Treeview1_Item1 = aTreeviewInsertitem(Treeview1,0,0,1)
Treeview1_Item2 = aTreeviewInsertitem(Treeview1,Treeview1_Item1,Treeview1_Item1,1)
Treeview1_Item3 = aTreeviewInsertitem(Treeview1,Treeview1_Item2,Treeview1_Item2,0)

aTreeviewSetitemtext(Treeview1,Treeview1_Item1,"Item1")
aTreeviewSetitemtext(Treeview1,Treeview1_Item2,"Item2")
aTreeviewSetitemtext(Treeview1,Treeview1_Item3,"Item3")

aTreeviewExpand(Treeview1,Treeview1_Item1,1)
aTreeviewExpand(Treeview1,Treeview1_Item2,1)

aStylingSetautotransparency(1)

Animation1 = aAnimationCreate(Tab,400,305,175,125,ACS_TRANSPARENT)

aAnimationOpen(Animation1,"copy.avi")

aAnimationPlay(Animation1,0,-1,-1) 

Syslink = aSyslinkCreate(Win,5,ClientHeight-25-StatusSpace,250,20)

aControlSettext(Syslink,'? 2007 - <A id="0">www.hobbl.com</a>')


aControlSetautotab(1)

Tab2_Group1 = aButtonCreate(Tab,5,25,400,435,BS_GROUPBOX)
aControlSettext(Tab2_Group1,"Blablablabla")

--Tab2_Static1 = aStatic_Create(Tab,10,40,250,20)
--aControl_SetText(Tab2_Static1,"Search results: ")

--Tab2_Button1 = aButton_Create(Tab,327,35,75,20)
--aControl_SetText(Tab2_Button1,"Search...")
--Tab2_Listview1 = aListview_Create(Tab,10,60,391,395,LVS_REPORT,WS_EX_CLIENTEDGE)

--aListview_InsertColumnText(Tab2_Listview1,0,75,"Handle")
--aListview_InsertColumnText(Tab2_Listview1,1,300,"Text")*/

aTabSetcursel(Win_Tab,0)

aSystrayAdd(Win,"Max WinAPI 2",0)

GbGradient = aGraphbufCreate(16,16)
GbSystray = aGraphbufCreate(16,16)

DcGradient = aGraphbufGetdc(GbGradient)
DcSystray = aGraphbufGetdc(GbSystray)

aDrawGradient(DcGradient,0,0,16,16,0,cYellow,cLime)

FoSystray = aDrawCreatefont("Arial",6)

aSystrayPrepareballoon("Max WinAPI 2","Hi! Thanks for using the Max WinAPI 2 example.Check out the dynamic system tray icon.",0,NIIF_INFO)

aSystraySetballoon(Win,0)

aWindowRedraw(Win)

while WindowsExists(window_handle) do
	WindowsRefresh()
	KeyRefresh()
	fps=CallFps(30)
	
	if KeyReleased(VK_ESCAPE) then WindowsDestroy(window_handle) end
end