I use PB allot and have just bought FF and loving it so far, the new V3 looks to be even better ;D
used the Tutorial 2 webbrowser sample to build a custom webbrowser, thing is I need it to see the tab key and control c, v and a for copy and paste
have searched all over to find out how to do this
found this link but am not able to convert what is says to FF
http://www.microsoft.com/mind/0499/faq/faq0499.asp
I hope someone can point me in the right direction or better yet post some code to help me get through this problem
Thanks
Stanley
To get copy and paste working you need to initialize the Ole Library before the control is created, and uninitialize it after it is destroyed.
These are the declares for these functions:
DECLARE FUNCTION OleInitialize LIB "OLE32.DLL" ALIAS "OleInitialize" ( _
BYVAL pvReserved AS DWORD _ ' [in] LPVOID pvReserved
) AS LONG ' HRESULT
DECLARE SUB OleUninitialize LIB "OLE32.DLL" ALIAS "OleUninitialize" ( _
) ' void
The call to OleInitialize
OleInitialize %NULL
The call to OleUninitialize
OleUninitialize
Ask Paul for the way to add the declares to your project and the best place where to put the calls to the functions. For OleInitialize, maybe the special function FF_WinMain; for OleUninitialize, I don't see other place than WM_DESTROY.
I knew that Jose would have the answer - he always does! :) Thanks Jose - you da man.
FF_WinMain is a good place for the initialization and WM_DESTROY of the program's main form is a good place for the unitialize.
(FF_WinMain is located on the Project Explorer treeview under the branch "Special Functions").
Applications that use the following functionality must call OleInitialize before calling any other function in the COM library:
* Clipboard
* Drag and drop
* Object linking and embedding (OLE)
* In-place activation
Without calling it, the Clipboard functionality isn't available and Cut and Paste don't work.
OK, added the code you gave me, no change
still will not control V,C, or A Tab still will not work and same with the delete key
copy and paste will not work from menu but always has from right mouse click
thanks for the help so far
Stan
Click the "Explorer" tab in the "FireFly Workspace" tool window, expand the "Special Functions" node, double click FF_PumpHook and change
Function = SendMessage(GetFocus(), &H37F, 0, VarPtr(Msg))
to
Function = SendMessage(GetParent(GetParent(GetFocus())), &H37F, 0, VarPtr(Msg))
changed it to
Function = SendMessage(GetParent(GetParent(GetFocus())), &H37F, 0, VarPtr(Msg))
still the same, no change at all yet
in MSDN
http://www.microsoft.com/mind/0499/faq/faq0499.asp
they talk about the webbrowser and the missing keys
The problem is that the intrinsic controls on a Web page do not automatically receive these accelerator keys. When the WebBrowser control receives an accelerator key message, it does not automatically pass it to child controls on a Web page. Therefore, you must somehow let the WebBrowser control know that it should pass these messages to controls on your Web page.
The solution is always the same whether you are hosting the control in MFC, ATL, or standard C++: call the TranslateAcclerator method of the IOleInPlaceActiveObject interface that is implemented by the WebBrowser control. But where and how you should do this is often unclear.
they say how to fix it but they are deep into OLE and I am just learning OLE so it is way above me.
Will post the complete code so it can help others when I get it working
thanks a ton for the help so far
Stanley
After the change to Function = SendMessage(GetParent(GetParent(GetFocus())), &H37F, 0, VarPtr(Msg)) the tab key should work if the focus is on the web page. Click inside the web page to make sure it gets the focus.
I can click on controls inside the webbrowser control and they work, text boxes get normal key strokes and push buttons work like they should
Tab when pushed just tabs out of webbrowser control and will not tab to controls inside of it
can post the code I have so far for you to look at it
have not made to many changes from the sample that came with FF
Hate taking your time as I would love to see FF V3 out ASAP
this would make a good sample for FF V3 on the upside, will post the code when done
Stan
if your good with C code the web site
http://www.microsoft.com/mind/0499/faq/faq0499.asp
gives the C code for how to fix it.
I can do C but am more into basic
have power basic ( all of them from dos to win all up to date), Real basic, Pure Basic, Free Basic, VB and a raft of others
Have a few C, C++ ones but try not to use them much
Quote
Tab when pushed just tabs out of webbrowser control and will not tab to controls inside of it
That's normal. When you tab from a control outside the webbrowser control to the webbrowser, what gets the focus is the window used as the container for the webbrowser, not the web page.
This small program shows that Cut and Paste works. Is not a FireFly application. Compile it with the PB IDE.
#COMPILE EXE
#INCLUDE "WIN32API.INC"
%WM_FORWARDMSG = &H37F ' (895)
%IDC_WB = 1001
DECLARE FUNCTION OleInitialize LIB "OLE32.DLL" ALIAS "OleInitialize" ( _
BYVAL pvReserved AS DWORD _ ' [in] LPVOID pvReserved
) AS LONG ' HRESULT
DECLARE SUB OleUninitialize LIB "OLE32.DLL" ALIAS "OleUninitialize" ( _
) ' void
' *********************************************************************************************
DECLARE FUNCTION AtlAxWinInit LIB "ATL.DLL" ALIAS "AtlAxWinInit" () AS LONG
' *********************************************************************************************
' **********************************************************************************************
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
' *********************************************************************************************
' *********************************************************************************************
' AddRef method
' Increments the reference count for an interface on an object. It should be called for
' every new copy of a pointer to an interface on a given object.
' *********************************************************************************************
FUNCTION IUnknown_AddRef (BYVAL pthis AS DWORD PTR) AS DWORD
LOCAL DWRESULT AS LONG
IF pthis = %NULL THEN EXIT FUNCTION
CALL DWORD @@pthis[1] USING IUnknown_AddRef (pthis) TO DWRESULT
FUNCTION = DWRESULT
END FUNCTION
' *********************************************************************************************
' *********************************************************************************************
' Puts the address of an object in a variant and marks it as containing a dispatch variable
' *********************************************************************************************
SUB AtlMakeDispatch (BYVAL lpObj AS DWORD, BYREF vObj AS VARIANT)
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
IUnknown_AddRef lpObj
END SUB
' *********************************************************************************************
' *********************************************************************************************
' Main Window procedure
' *********************************************************************************************
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
LOCAL szUrl AS ASCIIZ * %MAX_PATH
LOCAL vVar AS VARIANT
SELECT CASE wMsg
CASE %WM_SIZE
MoveWindow GetDlgItem(hWnd, %IDC_WB), 0, 0, LOWRD(lParam), HIWRD(lParam), %TRUE
EXIT FUNCTION
CASE %WM_DESTROY
PostQuitMessage 0
EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
' *********************************************************************************************
' *********************************************************************************************
' Program entrance
' *********************************************************************************************
FUNCTION WINMAIN (BYVAL hInst AS DWORD, BYVAL hPrevInstance AS DWORD, _
BYVAL lpszCmdLine AS ASCIIZ PTR, BYVAL nCmdShow AS LONG) AS LONG
LOCAL hCtl AS DWORD
LOCAL hFont AS DWORD
LOCAL wc AS WndClassEx
LOCAL szClassName AS ASCIIZ * 80
LOCAL rc AS RECT
LOCAL hDlg AS DWORD
LOCAL hWb AS DWORD
LOCAL oWb AS DISPATCH
LOCAL pUnk AS DWORD
LOCAL vVar AS VARIANT
szClassName = "MyClass"
wc.cbSize = SIZEOF(wc)
wc.style = %CS_DBLCLKS OR %CS_HREDRAW OR %CS_VREDRAW
wc.lpfnWndProc = CODEPTR(WndProc)
wc.cbClsExtra = 0
wc.cbWndExtra = 0
wc.hInstance = hInst
wc.hCursor = LoadCursor (%NULL, BYVAL %IDC_ARROW)
wc.hbrBackground = %COLOR_3DFACE + 1
wc.lpszMenuName = %NULL
wc.lpszClassName = VARPTR(szClassName)
wc.hIcon = LoadIcon (%NULL, BYVAL %IDI_APPLICATION)
wc.hIconSm = LoadIcon (%NULL, BYVAL %IDI_APPLICATION)
CALL RegisterClassEx (wc)
SystemParametersInfo %SPI_GETWORKAREA, 0, BYVAL VARPTR(rc), 0
hDlg = CreateWindowEx(%WS_EX_CONTROLPARENT, szClassName, "WebBrowser Test", _
%WS_OVERLAPPEDWINDOW, rc.nLeft, rc.nTop, rc.nRight - rc.nLeft, _
rc.nBottom - rc.nTop, 0, 0, hInst, BYVAL %NULL)
OleInitialize %NULL ' // Initilalizes the COM library
AtlAxWinInit ' // Initializes ATL
hWb = CreateWindowEx(0, "AtlAxWin", "Shell.Explorer", %WS_CHILD OR %WS_VISIBLE, _
0, 0, 0, 0, hDlg, %IDC_WB, hInst, BYVAL %NULL)
AtlAxGetControl(hWb, pUnk)
AtlMakeDispatch(pUnk, vVar)
SET oWb = vVar
vVar = "www.powerbasic.com"
OBJECT CALL oWb.Navigate(vVar)
ShowWindow hDlg, nCmdShow
UpdateWindow hDlg
LOCAL uMsg AS tagMsg
WHILE GetMessage(uMsg, %NULL, 0, 0)
IF SendMessage(hWb, %WM_FORWARDMSG, 0, VARPTR(uMsg)) = %FALSE THEN
IF IsDialogMessage(hDlg, uMsg) = %FALSE THEN
TranslateMessage uMsg
DispatchMessage uMsg
END IF
END IF
WEND
SET oWb = NOTHING
OleUninitialize
FUNCTION = uMsg.wParam
END FUNCTION
' *********************************************************************************************
Cool, that code works
now to add the missing parts of it to my FF code
WHILE GetMessage(uMsg, %NULL, 0, 0)
IF SendMessage(hWb, %WM_FORWARDMSG, 0, VARPTR(uMsg)) = %FALSE THEN
IF IsDialogMessage(hDlg, uMsg) = %FALSE THEN
TranslateMessage uMsg
DispatchMessage uMsg
END IF
END IF
WEND
I think that is the key part I was missing, will try it and see
You can't because you don't have access to the message pump.
In the FF_PUMPHOOK function, retrieve the handle of the window that hosts the WebBrowser control wirh:
Local hWb As Dword
hWb = GetDlgItem(<form handle>, <control identifier>)
And then forward the message using:
If IsTrue SendMessage(hWb, %WM_FORWARDMSG, 0, VarPtr(Msg)) Then
Function = %TRUE
End If
this is very cool
OK got FF webbrowser seeing the control A,C,V but it will not see the TAB, when tab is pushed it tabs out of browser and will not send tab to the browser
we are getting closer to it being done, thanks a mill for you help, could not have done it with out it
BTW the pb version works perfect and tab works as it should, not sure why the FF version will not work with TAB as one would expect
Stan
The PB version doesn't have any other control besides the WebBrowser.
What do you want is not possible without getting the sources of ATL.DLL and modifying them.