$ filename "Demo3.exe"

'uses rtl32
'uses rtl64

uses WinUtil
uses autosizing


sys EDT1,EDT2,EDT3,EDT4,EDT5,EDT6,EDT7,EDT8,EDT9

enum  Control_ids
   ID_EDT1=1001
   ID_EDT2
   ID_EDT3
   ID_EDT4
   ID_EDT5
   ID_EDT6   
   ID_EDT7
   ID_EDT8
   ID_EDT9   
end enum

% Mle_Style    = WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL|WS_BORDER|ES_LEFT|ES_MULTILINE
% Mle_ExtStyle = WS_EX_CLIENTEDGE

sys hInstance=inst
MainWindow 320,340,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 3")
           EDT1=CreateControl("Edit","1",hwnd,ID_EDT1,   5, 5, 90, 90, Mle_Style, Mle_ExtStyle)
           EDT2=CreateControl("Edit","2",hwnd,ID_EDT2, 105, 5, 90, 90, Mle_Style, Mle_ExtStyle)
           EDT3=CreateControl("Edit","3",hwnd,ID_EDT3, 205, 5, 90, 90, Mle_Style, Mle_ExtStyle)

           EDT4=CreateControl("Edit","4",hwnd,ID_EDT4,   5, 105, 90, 90, Mle_Style, Mle_ExtStyle)
           EDT5=CreateControl("Edit","5",hwnd,ID_EDT5, 105, 105, 90, 90, Mle_Style, Mle_ExtStyle)
           EDT6=CreateControl("Edit","6",hwnd,ID_EDT6, 205, 105, 90, 90, Mle_Style, Mle_ExtStyle)

           EDT7=CreateControl("Edit","7",hwnd,ID_EDT7,   5, 205, 90, 90, Mle_Style, Mle_ExtStyle)
           EDT8=CreateControl("Edit","8",hwnd,ID_EDT8, 105, 205, 90, 90, Mle_Style, Mle_ExtStyle)
           EDT9=CreateControl("Edit","9",hwnd,ID_EDT9, 205, 205, 90, 90, Mle_Style, Mle_ExtStyle)

           pinCtl(EDT1, hwnd, "   0, 0",  "0.33, 0.33")
           pinCtl(EDT2, hwnd, "0.33, 0",  "0.66, 0.33")
           pinCtl(EDT3, hwnd, "0.66, 0",  "1.0 , 0.33")
            
           pinCtl(EDT4, hwnd, "   0, 0.33",  "0.33, 0.66")
           pinCtl(EDT5, hwnd, "0.33, 0.33",  "0.66, 0.66")
           pinCtl(EDT6, hwnd, "0.66, 0.33",  "1.0 , 0.66")

           pinCtl(EDT7, hwnd,  "  0, 0.66",  "0.33, 1.0")
           pinCtl(EDT8, hwnd, "0.33, 0.66",  "0.66, 1.0")
           pinCtl(EDT9, hwnd, "0.66, 0.66",  "1.0 , 1.0")

        case WM_COMMAND

        case WM_GETMINMAXINFO
'           setMinSize 200,200

        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
