$ filename "Demo5.exe"

'uses rtl32
'uses rtl64

uses WinUtil
uses autosizing

% SS_LEFT=0
% SS_NOTIFY=0x0100
% CBS_DROPDOWNLIST=3
% CBS_HASSTRINGS=0x0200

sys List1, List2, List3, Lable1, Lable2, Lable3, Btn_Clear, Btn_Remove, Btn_Add, Btn_Fill, Btn_Ok, Btn_Cancel 

enum  Control_ids
   ID_List1=1001 
   ID_List2 
   ID_List3 
   ID_Lable1 
   ID_Lable2 
   ID_Lable3 
   ID_Btn_Clear 
   ID_Btn_Remove 
   ID_Btn_Add 
   ID_Btn_Fill 
   ID_Btn_Ok 
   ID_Btn_Cancel
end enum

% Btn_Style    = WS_CHILD|WS_VISIBLE|WS_TABSTOP
% Btn_ExtStyle = WS_EX_STATICEDGE
% LText_Style    = WS_CHILD|WS_VISIBLE|WS_TABSTOP|SS_LEFT|SS_NOTIFY
% Listbox_Style    = WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL|WS_BORDER
% Listbox_ExtStyle = WS_EX_CLIENTEDGE
% DropDownList_Style    = WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL|CBS_DROPDOWNLIST|CBS_HASSTRINGS
% DropDownList_ExtStyle = WS_EX_CLIENTEDGE


sys hInstance=inst
MainWindow 345,410,WS_OVERLAPPEDWINDOW

function createControl(string ctlclass, string Text, sys hwnd, int id, x,y,w,h, int Style, optional ExStyle=0) as sys
   sys hCtrl
   hCtrl=CreateWindowEx(ExStyle, ctlclass, Text, Style, x,y,w,h,  hWnd, id, hInstance, null)
   if hCtrl=null then mbox "Error: Cannot create " ctlclass
   return hCtrl
end function

function WndProc(sys hwnd, uint uMsg, sys wParam, lParam) as sys callback

    select uMsg

        case WM_CREATE
           SetWindowText(hwnd, "Autosize Demo 5")
           List1 = CreateControl("ListBox","",hwnd,ID_List1, 12, 28, 132, 272, Listbox_Style, Listbox_ExtStyle)
           List2 = CreateControl("ListBox","",hwnd,ID_List2, 184, 28, 132, 272, Listbox_Style, Listbox_ExtStyle) 
           Lable1 = CreateControl("Static","All Options",hwnd,ID_Lable1, 12, 8, 110, 20, LText_Style)
           Lable2 = CreateControl("Static","Selected",hwnd,ID_Lable2, 184, 8, 132, 20, LText_Style) 
           Btn_Clear = CreateControl("Button","<<---",hwnd,ID_Btn_Clear, 148, 32, 32, 32, Btn_Style, Btn_ExtStyle)
           Btn_Remove = CreateControl("Button","<-",hwnd,ID_Btn_Remove, 148, 68, 32, 32, Btn_Style, Btn_ExtStyle)
           Btn_Add = CreateControl("Button","->",hwnd,ID_Btn_Add, 148, 104, 32, 32, Btn_Style, Btn_ExtStyle)
           Btn_Fill = CreateControl("Button","--->>",hwnd,ID_Btn_Fill, 148, 140, 32, 32, Btn_Style, Btn_ExtStyle)
           Lable3 = CreateControl("Static","DropDown",hwnd,ID_Lable3, 12, 292, 132, 16, LText_Style)
           List3 = CreateControl("ComboBox","",hwnd,ID_List3, 8, 308, 308, 124, DropDownList_Style, DropDownList_ExtStyle)           
           Btn_Ok = CreateControl("Button","Ok",hwnd,ID_Btn_Ok, 8, 340, 88, 28, Btn_Style, Btn_ExtStyle)
           Btn_Cancel = CreateControl("Button","Cancel",hwnd,ID_Btn_Cancel, 228, 340, 88, 28, Btn_Style, Btn_ExtStyle)

           pinCtl(Lable1, hwnd, "TL")
           pinCtl(Lable2, hwnd, "TM")
           pinCtl(List1, hwnd, "TL","BM")
           pinCtl(List2, hwnd, "TM","BR")
           pinCtl(Btn_Clear, hwnd, "TM" )
           pinCtl(Btn_Remove, hwnd, "TM" )
           pinCtl(Btn_Add, hwnd, "TM" )
           pinCtl(Btn_Fill, hwnd, "TM" )
           pinCtl(Lable3, hwnd, "BL" )
           pinCtl(List3, hwnd, "BL","BR" )
           pinCtl(Btn_Ok, hwnd, "BL" )
           pinCtl(Btn_Cancel, hwnd, "BR" )

        case WM_COMMAND
           if loword(wParam) = ID_Btn_Cancel then 'Id
              SendMessage(hWnd, WM_CLOSE,0,0)
           end if

        case WM_GETMINMAXINFO
           setMinSize 345,410

        case WM_SIZE
           resizeControls(hwnd)

        case WM_CLOSE
           DestroyWindow(hwnd)

        case WM_DESTROY
           PostQuitMessage(0)

        case else
           return DefWindowProc(hwnd, uMsg, wParam, lParam)

    end select

    return 0
end function
