...poco a poco los impulsos eléctricos comenzaron a llenar la memoria de su cerebro de silicio. Tras un pequeño parpadeo que ilumino sus ojos, cobro vida...
Mini BASIC
/*
An example of the MiniBASIC Browser Window class
Requires MiniBASIC 1.163 or greater
*/
##NOCONSOLE
WINDOW win,urldlg
BROWSER cont
STRING caption
STRING gURL
INT tbArray[9]
CONST idBack = 0x100
CONST idForward = 0x101
CONST idStop = 0x102
CONST idRefresh = 0x103
CONST idHome = 0x104
CONST idSearch = 0x105
CONST idPrint = 0x106
Const ES_WANTRETURN = 0x1000
@API GetSysColor(nIndex as INT),UINT
'open our main window and browser containing window
win.Open(0,0,800,600, WS_OVERLAPPEDWINDOW| WS_CAPTION | WS_MINIMIZEBOX| WS_MAXIMIZEBOX | WS_VISIBLE | CENTERED,0,"BROWSER TEST",NULL,&handler)
cont.Create(0,0,800,580,WS_CHILD | WS_VISIBLE,0,"",win,&browsehandler)
'A URL entry window used as a toolbar
urldlg.Open(0,0,800,35, WS_CHILD | WS_VISIBLE| WS_BORDER,0,"",win,&UrlHandler)
urldlg.AddControl(CT_EDIT,"",54,6,500,22, CS_EDITMULTI| ES_WANTRETURN| CS_EDITAUTOV,0,2)
urldlg.AddControl(CT_STATIC,"URL",21,8,31,16,0x5000010B,0,3)
urldlg.SetWindowColor(GetSysColor(15))
urldlg.SetFont("MS Sans Serif",-13,400,0,2)
'add a status window for messages
win.AddControl(CT_STATUS,"Status",0,0,0,0,0,0,2)
'create a toolbar. It will send its messages to the main window
win.AddControlEx("ToolbarWindow32","",0,0,0,0,0x00001000|0x00000800,0,999)
AddToolbarButton(win,999,0,idBack,"Back")
AddToolbarButton(win,999,1,idForward,"Forward")
AddToolbarButton(win,999,2,idStop,"Stop")
AddToolbarButton(win,999,3,idRefresh,"Refresh")
AddToolbarButton(win,999,4,idHome,"Home")
AddToolbarButton(win,999,5,idSearch,"Search")
AddToolbarButton(win,999,6,idPrint,"Print")
EnableToolbarButton(win,999,idBack,FALSE)
EnableToolbarButton(win,999,idForward,FALSE)
'Set the browser, status window and toolbars initial size
ResizeAll()
'Browse to some page
cont.Navigate("http://aicsharp.blogspot.com.es/")
do:processmessages:until win.GetHandle()=0
END
FUNC browsehandler(BROWSER br),INT
SELECT br.message
CASE ID_BEFORENAV
urldlg.SetControltext(2,br.GetURL())
CASE ID_NAVCOMPLETE
urldlg.SetControltext(2,br.GetURL())
'best place to update toolbar buttons
EnableToolbarButton(win,999,idBack,br.IsBackEnabled())
EnableToolbarButton(win,999,idForward,br.IsForwardEnabled())
CASE ID_STATUSTEXTCHANGE
win.SetControlText(2, br.GetStatusText())
CASE ID_TITLECHANGE
win.SetCaption("Browser Test - "+br.GetTitle())
ENDSELECT
RETURN 0
ENDF
FUNC handler (WINDOW wnd),INT
SELECT wnd.message
CASE ID_CLOSE
urldlg.Close()
cont.Close()
win.Close()
CASE WM_SIZE
ResizeAll()
CASE ID_CONTROL
IF wnd.NotifyCode = 0 /* ignore any tooltip messages */
SELECT wnd.ControlID
CASE idBack
cont.GoBack()
CASE idForward
cont.GoForward()
CASE idStop
cont.StopNav()
CASE idRefresh
cont.Refresh()
CASE idHome
cont.GoHome()
CASE idSearch
cont.Search()
CASE idPrint
cont.PrintPage()
ENDSELECT
ENDIF
ENDSELECT
RETURN 0
ENDF
FUNC UrlHandler(WINDOW wnd)
dstring temp[1024]
DIM rcClient as RECT
SELECT wnd.message
CASE ID_CONTROL
SELECT wnd.ControlID
CASE 1
cont.Navigate(urlDlg.GetControlText(2))
CASE 2
SELECT wnd.NotifyCode
CASE EN_CHANGE
temp = urlDlg.GetControlText(2)
IF INSTR(temp,"\n")
cont.Navigate(temp)
ENDIF
ENDSELECT
ENDSELECT
CASE WM_SIZE
'dynamically adjust the size of the edit control.
rcClient = urldlg.GetClientRect()
urldlg.SetSize(54,6,rcClient.right - 58,22, 2)
ENDSELECT
RETURN 0
ENDF
FUNC ResizeAll
'use rects for convenience.
RECT rcClient,rcStatus,rcUrl
'tell the status bar and toolbar to resize itself
win.SendMessage(WM_SIZE,0,0,2)
win.SendMessage(WM_SIZE,0,0,999)
rcClient = win.GetClientRect()
'get the size of the statusbar
rcStatus = win.GetWindowRect(2)
'subtract the 'height' of the status bar control
rcClient.bottom -= (rcStatus.bottom - rcStatus.Top)
'get the size of the toolbar
'subtract the 'height' of the toolbar. Do this by increasing the top of the rectangle by
'the height of the toolbar and also reducing the height of the rectangle accordingly
rcStatus = win.GetWindowRect(999)
rcClient.top += (rcStatus.bottom - rcStatus.top)
rcClient.bottom -= (rcStatus.bottom - rcStatus.top)
'make room for our URL entry window
rcUrl = urldlg.GetWindowRect()
int URLHeight = rcUrl.bottom - rcUrl.top
rcClient.top += (rcUrl.bottom - rcUrl.top)
rcClient.bottom -= (rcUrl.bottom - rcUrl.top)
'set the size of the browsers containing window
cont.SetSize(rcClient.left,rcClient.top,rcClient.right,rcClient.bottom)
'finally set the size of the url window
urldlg.SetSize(rcClient.left,rcClient.top - URLHeight,(rcClient.right-rcClient.left),URLHeight)
RETURN
ENDF
/*temporary toolbar functions until MiniBASIC has built in ones*/
TYPE TBBUTTON
int iBitmap
int idCommand
CHAR fsState
CHAR fsStyle
CHAR bReserved[2]
UINT *dwData
INT *iString
ENDTYPE
Const BTNS_SHOWTEXT = 0x00000040
const TB_INSERTBUTTON = 0x400 + 21
const TB_BUTTONSTRUCTSIZE = 0x400 + 30
Const TB_SETSTATE = 0x400 + 17
Const TB_GETSTATE = 0x400 + 18
Const TBSTATE_ENABLED = 0x00000004 ' The button accepts user input
Const TBSTATE_HIDDEN = 0x00000008 ' The button is not visible and cannot receive user input
Const TBSTATE_INDETERMINATE = 0x00000010 ' The button is grayed
Const TBSTATE_WRAP = 0x00000020 ' The button is followed by a line break
Const TBSTATE_ELLIPSES = 0x00000040 ' The button's text is cut off and an ellipsis is displayed
Const TBSTATE_MARKED = 0x00000080 ' The button is marked
func AddToolbarButton(WINDOW *win,int ctrlID, int pos,int CmdID, string text)
TBBUTTON tb
win->SendMessage(TB_BUTTONSTRUCTSIZE,len(tb),0,ctrlID)
tb.iBitmap = -1
tb.idCommand = CmdID
tb.fsState = TBSTATE_ENABLED
tb.fsStyle = BTNS_SHOWTEXT
tb.dwData = NULL
tb.iString = text
win->SendMessage(TB_INSERTBUTTON,pos,&tb,ctrlID)
endf
func EnableToolbarButton(WINDOW *win,int ctrlID, int CmdID, int bEnable)
uint state = win->SendMessage(TB_GETSTATE,CmdID,0,ctrlID)
state &= NOT(TBSTATE_ENABLED)
state |= TBSTATE_ENABLED * bEnable
win->SendMessage(TB_SETSTATE,CmdID,state & 0xFFFF,ctrlID)
endf
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.