Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Power Basic

Страница: 1 |

 

  Вопрос: Просмотр web страниц Добавлено: 12.02.06 00:52  

Автор вопроса:  Серёга | Web-сайт: houselab.narod.ru | ICQ: 262809473 
Товарищи!!!
Подскажите, пожалуйста, как в программе на PowerB создать окно для просмотра web-страниц (навроде Inet Control в VB6)? И как потом управлять этим окном (Navigate, GoBack и т.д.)?
Заранее благодарен.

Ответить

  Ответы Всего ответов: 2  

Номер ответа: 1
Автор ответа:
 alex



Вопросов: 84
Ответов: 453
 Профиль | | #1 Добавлено: 12.02.06 11:47
Лови код:

  #Dim All
  #Include "win32api.inc"


  %ID_OCX     = 1001
  %IDC_URL    = 1010
  %IDC_BTNAVG = 1011
  %IDC_BTBACK = 1012
  %IDC_BTFRWD = 1013
  %IDC_LABEL1 = 1014

  Global hDlg As Dword
  Global hOcx As Dword
  Global oOcx As Dispatch


  Declare Function AtlAxWinInit Lib "ATL.DLL" Alias "AtlAxWinInit" () As Long
' *********************************************************************************************
  Declare Function AtlAxWinTerm () As Long
' *********************************************************************************************
  Function AtlAxWinTerm () As Long
    UnregisterClass ("AtlAxWin", GetModuleHandle(ByVal %NULL))
  End Function
' *********************************************************************************************
' **********************************************************************************************
  Declare Function AtlAxGetControl Lib "ATL.DLL" Alias "AtlAxGetControl" _
     ;( _
     ByVal hWnd As Dword, _   ' [in] A handle to the window that is hosting the control.
     ByRef pp As Dword _      ' [out] The IUnknown of the control being hosted.
  ;) As Dword
' *********************************************************************************************

' *********************************************************************************************
' Puts the address of an object in a variant and marks it as containing a dispatch variable
' *********************************************************************************************
  Sub AtlMakeDispatch ( _
     ByVal lpObj As Dword, _                        ' Address of the object instance
     ByRef vObj As Variant _                        ' Variant to contain this address
     ;) Export

     Local lpvObj As VARIANTAPI Ptr                 ' Pointer to a VARIANTAPI structure
     Let vObj = Empty                               ' Make sure is empty to avoid memory leaks
     lpvObj = VarPtr(vObj)                          ' Get the VARIANT address
     @lpvObj.vt = %VT_Dispatch                      ' Mark it as containing a dispatch variable
     @lpvObj.vd.pdispVal = lpObj                    ' Set the dispatch pointer address

  End Sub
' *********************************************************************************************

' *********************************************************************************************
' Main dialog callback
' *********************************************************************************************
  CallBack Function MainDlgProc()

     Local rc As RECT
     Local r As Long
     Local x As Long
     Local y As Long
     Local xx As Long
     Local yy As Long


     Select Case CbMsg

        Case %WM_SIZE
           GetClientRect CbHndl, rc
           x = rc.nLeft
           y = rc.nTop
           xx = rc.nRight - rc.nLeft
           yy = rc.nBottom - rc.nTop - 32
           MoveWindow hOcx, x, y, xx, yy, %TRUE

        Case %WM_DESTROY
           PostQuitMessage 0

        Case %WM_COMMAND
           Select Case CbCtl
              Case %IDCANCEL
                 If CbCtlMsg = %BN_CLICKED Or CbCtlMsg = 1 Then
                    ;Dialog End CbHndl, 0
                 End If
              Case %IDC_BTNAVG
                 If CbCtlMsg = %BN_CLICKED Or CbCtlMsg = 1 Then
                    Local strUrl As String, vVar As Variant
                    Control Get Text CbHndl, %IDC_URL To strUrl
                    vVar = strUrl
                    Object Call oOcx.Navigate(vVar)
                 End If
              Case %IDC_BTBACK
                 If CbCtlMsg = %BN_CLICKED Or CbCtlMsg = 1 Then
                    Object Call oOcx.GoBack
                 End If
              Case %IDC_BTFRWD
                 If CbCtlMsg = %BN_CLICKED Or CbCtlMsg = 1 Then
                    Object Call oOcx.GoForward
                 End If
           End Select

     End Select

  End Function
' *********************************************************************************************

' *********************************************************************************************
' Main
' *********************************************************************************************
  Function PBMain

     Local hInst As Dword
     Local hr As Dword
     Local OcxName As Asciiz * 255
     Local pUnk As Dword
     Local vVar As Variant
     Local uMsg As tagMsg

     OcxName = "Shell.Explorer"

     AtlAxWinInit   ' // Initializes ATL

     ;Dialog New 0, "A Web Browser in a DDT dialog",,, 528, 334, %WS_OVERLAPPEDWINDOW, 0 To hDlg
     Control Add "AtlAxWin", hDlg, %ID_OCX, OcxName, 0, 0, 0, 0, %WS_VISIBLE Or %WS_CHILD
     Control Handle hDlg, %ID_OCX To hOcx
     Control Add Label, hDlg, %IDC_LABEL1, "URL", 226, 322, 16, 12
     Control Add TextBox, hDlg, %IDC_URL, "", 250, 320, 210, 14
     Control Add Button, hDlg, %IDC_BTNAVG, "&Navigate", 470, 320, 46, 14, %WS_TABSTOP Or %BS_DEFAULT
     Control Add Button, hDlg, %IDC_BTBACK, "&Back", 5, 320, 46, 14, %WS_TABSTOP
     Control Add Button, hDlg, %IDC_BTFRWD, "&Forward", 58, 320, 46, 14, %WS_TABSTOP
     Control Set Text hDlg, %IDC_URL, "http://www.powerbasic.com"

     AtlAxGetControl(hOcx, pUnk)
     AtlMakeDispatch(pUnk, vVar)
     Set oOcx = vVar

     SetFocus(hOcx)
     ;Dialog Show Modal hDlg, Call MainDlgProc To hr

     AtlAxWinTerm   ' // Uninitializes ATL
     Set oOcx = Nothing

  End Function

Ответить

Номер ответа: 2
Автор ответа:
 alex



Вопросов: 84
Ответов: 453
 Профиль | | #2 Добавлено: 12.02.06 12:54
Еще примеры браузеров на PB:

http://www.powerbasic.com/support/forums/Forum7/HTML/002012.html
http://www.powerbasic.com/support/forums/Forum7/HTML/002042.html
http://www.powerbasic.com/support/forums/Forum7/HTML/001679.html
http://www.powerbasic.com/support/forums/Forum7/HTML/002621.html
http://www.powerbasic.com/support/forums/Forum7/HTML/002611.html

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам