|
Once you have it built and deployed, you have to run it against RegSrv32.exe to register it on the target system for IE to find it. If IE has already enumerated the toolbars and bands you may need to logoff and log back on or if you have a new version of IE you can set a registry key that IE will pickup and re-enumerate the listings without the need to logoff or kill the explorer windows.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Thanks
|
|
|
|
|
I have tried to add a button to the band.
Unfotunately the band is displayed without
any button.
I am listing below the method used in creating
the band and adding the button and would
appreciate it very much if
the reason(s) could be explained.
Thanks for your help
************************************************************************/
BOOL CToolBand::RegisterAndCreateWindow(void)
{
//If the window doesn't exist yet, create it now.
if(!m_hWnd)
{
//Can't create a child window without a parent.
if(!m_hwndParent)
{
return FALSE;
}
//If the window class has not been registered, then do so.
WNDCLASS wc;
if(!GetClassInfo(g_hInst, TB_CLASS_NAME, &wc))
{
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hInst;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(192, 192, 192));
wc.lpszMenuName = NULL;
wc.lpszClassName = TB_CLASS_NAME;
if(!RegisterClass(&wc))
{
//If RegisterClass fails, CreateWindow below will fail.
}
}
RECT rc;
GetClientRect(m_hwndParent, &rc);
//Create the window. The WndProc will set m_hWnd.
CreateWindowEx( 0,
TB_CLASS_NAME,
NULL,
WS_CHILD | WS_CLIPSIBLINGS,// | WS_BORDER,
rc.left,
rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
m_hwndParent,
NULL,
g_hInst,
(LPVOID)this);
}
SendMessage (m_hWnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
TBBUTTON tbb[1];
char szBuf[16];
int iCopy;
//add button string
LoadString(g_hInst, STD_COPY, szBuf, 16);
// Save room for second null terminator
szBuf[lstrlen(szBuf) + 1] = 0; // Double null terminate
iCopy = SendMessage(m_hWnd, TB_ADDSTRING, 0, (LPARAM) (LPSTR) szBuf);
// Fill TBBUTTON array
tbb[0].iBitmap = -1;
tbb[0].idCommand = STD_COPY;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].dwData = 0;
tbb[0].iString = iCopy;
SendMessage (m_hWnd, TB_ADDBUTTONS, (WPARAM) 1, (LPARAM) (LPTBBUTTON) &tbb);
SendMessage (m_hWnd, TB_AUTOSIZE, 0, 0);
return (NULL != m_hWnd);
}
================= END ========
|
|
|
|
|
Have you tried stepping through the code? Are you actually getting inside the first if block? I can't tell since I dont' know what the values of m_hWnd and m_hWndParent are. Also, g_hInst should be _Module.GetResourceInstance(). The other problem I see is that you have set the text for the button but not the image. Since text is not displayed except if some extended styles are set and a button style is set, the text that you have set will only show as a tooltip. Look at the BTNS_SHOWTEXT style below.
BTNS_SHOWTEXT Version 5.81. All buttons can have text, but only those buttons with the BTNS_SHOWTEXT button style will display it. This button style must be used with the TBSTYLE_LIST style, and the TBSTYLE_EX_MIXEDBUTTONS extended style. If you set text for buttons that do not have the BTNS_SHOWTEXT style, the toolbar control will automatically display it as a tooltip when the cursor hovers over the button. This feature allows your application to avoid handling the TBN_GETINFOTIP notification for the toolbar.
As a side note; Even though my example created from the wizard uses an api call to create a label, you can use the CWindow or CContainedWindow class to build up your toolbar.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
I know your are very busy but I've got a last question for you :
I need to connect a toolbar and a CommBand (the toolbar has to lanch functions of the CommBand)
Each one is hosted in the same IE window
How can I retrieve a pointer on the CommBar ?
I've try to implement the QueryInterface fonction the CommBand (it didn't work)
I've try to call QueryIntface in the toolbar with :
- a IServiceProviderPtr (from a)
- a IInputObjectSitePtr
- a IWebBrowser2Ptr
each call gives me NULL pointer
Finally I tried to lanch the Commbar with "CoCreateInstance" witch gave me a valid pointer but not on the good CommBar
Do you know were I can find any informations in the msdn ?
Sorry for making you losing your time...
Dim
A+
|
|
|
|
|
I've just find the solution of my problem in the second chapter of my Com book....
I've forgot to check in it...
so I used "CoGetClassObject" to get the factory of my second band
then I used "CreateInstance" on the factory to get the proper interface with the commbar
It's working fine and I hope that everything is correct
Bye and thanks for your articles they are really helpful
Dim
A+
|
|
|
|
|
like Remco, I'm trying to capture the backspace in an explorer toolbar.
I've try to implement the IInputObject (like it is said in the article you give to Remco) but it is not working...
The IInputObject functions are never called...
I've try several method to implement my bar (all use a CAxWindow with a HTLM control) :
- use a specific class derived from a CWindowImpl (like your CHTMlPageWnd)
- use the implementation of CWindowImpl directly in the band object provided by your atl wizard
I really need some help cause I don't know what to try next
thanks
Dim
|
|
|
|
|
I'm pretty strapped for time right now but to help you out in the meantime you should look at the MS KB article that gives you an example project of what to do called kbbar.exe
KB:Q246234 http://support.microsoft.com/support/kb/articles/q246/2/34.asp
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
thanks for the answer
Actually I forgot the idea to use an html page in my toolbar.
I used kbbar to build a more "normal" one.
The only problem i'm encountering is that i'm not able to change the ComboEx control into a Cedit control (it doesn't want to take the focus)...
thanks again
Dim
A+
|
|
|
|
|
Getting the CEdit control involves you asking your ComboBox for the Edit control and then setting focus to it in your code.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
I was tring to create the band by attaching a CDialog by pass the m_hWnd of the dialog to the band..
The code compiled fine, but the execution is not.
The band would not display my dialog, and IE freezed when I try to resize the band. Any idea how I implement the band in MFC??
BOOL Csbar::RegisterAndCreateWindow()
{
RECT rect;
::GetClientRect(m_hWndParent, &rect);
CMyDialog myDialog;
m_hWnd = myDialog.GetSafeHwnd();
return ::IsWindow(m_hWnd);
}
|
|
|
|
|
Assuming that this is the only problem; you have called the GetSafeHwnd method before you have called the dialog class' Create method, so the HWND for the dialog is not valid yet. Plus after the method exits your myDialog object will be destroyed, which will cause other problems.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Thanks for pointing that out..
I changed my code and use the modeless dialog mothod to create a dialog, but now I have a compile error in the CDialog::Create(IDD_MYDIALOG, this). I never had this kinda error before in other applications.
D:\temp\thebar\MyBand2.cpp(44) : error C2664: 'int __thiscall CDialog::Create(const char *,class CWnd *)' : cannot convert parameter 1 from 'const int' to 'const char *'
I included a dialog resource and changed my code like:
The header file:
class ATL_NO_VTABLE CMyBand2 :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMyBand2, &CLSID_MyBand2>,
public IDeskBand,
public IObjectWithSite,
public IPersistStream,
public IDispatchImpl<IMyBand2, &IID_IMyBand2, &LIBID_THEBARLib>
{
public:
CMyBand2();
DECLARE_REGISTRY_RESOURCEID(IDR_MYBAND2)
.......
.......
.......
protected:
DWORD m_dwBandID;
DWORD m_dwViewMode;
BOOL m_bShow;
BOOL m_bEnterHelpMode;
HWND m_hWndParent;
HWND m_hWnd;
IInputObjectSite* m_pSite;
CmyDlg *m_mydlg;
};
The cpp file:
BOOL CMyBand2::RegisterAndCreateWindow()
{
RECT rect;
::GetClientRect(m_hWndParent, &rect);
m_mydlg = new CmyDlg;
m_mydlg->Create(IDD_DIALOGBAR, this);
m_hWnd = m_mydlg->GetSafeHwnd();
return ::IsWindow(m_hWnd);
}
|
|
|
|
|
You can get around the first error my using MAKEINTRESOURCE, you will get a second error since your band is not a CWnd derived object. You will need to get a CWnd* from the m_hWndParent variable by using CWnd::FromHandle
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Thanks for the help Erik!
I've successfully compiled w/o using MAKEINTRESOURCE and it worked!
However, I found out that a AFX_MANAGE_STATE(AfxGetStaticModuleState()) must be added in the begging of the RegisterAndCreateWindow() function or IE will crash;
It is needed for using MFC.
CMyDialog* myToolBar;
BOOL CMyCoolBar::RegisterAndCreateWindow()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
RECT rect;
::GetClientRect(m_hWndParent, &rect);
CWnd* pParent = CWnd::FromHandle(m_hWndParent);
myToolBar = new CMyToolBar;
if (!myToolBar->Create(IDD_DIALOGBAR, pParent))
return false;
m_hWnd = myToolBar->GetSafeHwnd();
return ::IsWindow(m_hWnd);
}
|
|
|
|
|
do you have code that adds controls to erik's toolbar using MFC controls?
(I am completely new to MFC so bare with me...)
If I want to put a textbox and button, for example. In your example, you are adding a dialog box type window (CMyDialog) in which you have other controls, correct?
|
|
|
|
|
Is there a way to switch off the desk band title as default?
Thanks in advance ,
Thomas
I am a signature virus!
Help me spread and copy me to your sig!
|
|
|
|
|
Do you just want to have no title or do you want the caption area gone too? If you don't want a title just set the title constant in the cpp file to an empty string. If you want the caption are gone also, then that would have to take some research, I don't have that knowledge.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
The latter. Everytime I switch on my bar, the annyoing caption area covers more than the half of my bar. Nevertheless it is usefull. If a user wants to see it, he should be able to enable the caption, but the default should be disabled
I am a signature virus!
Help me spread and copy me to your sig!
|
|
|
|
|
I'm trying to capture the backspace in an explorer toolbar. (I've got an editbox in there) but I can't seem to be able to get it to work.
I return DLGC_WANTALLKEYS on WM_GETDLGCODE;
I've triewd to set m_pSite->OnFocusChangeIS(this, TRUE) on WM_SETFOCUS, but this gives me an ambiguous conversion error.
Any suggestions?
|
|
|
|
|
I'm writing an article on this and tabbing this week. If you can't wait for it. I suggest looking at the KBBar article on microsoft's website.
http://support.microsoft.com/support/kb/articles/Q246/2/34.ASP
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
I was running into great problems in attempting to compile a project with an IE Toolbar in once I had added the IInputObject interface (so that it could receive user input).
Upon adding the relevant lines, compiler produces errors:
error C2787: 'IInputObject' : no GUID has been associated with this object
error C2440: 'initializing' : cannot convert from 'unsigned long' to 'const struct _GUID *'
I have now got it to work by specifying _ATL_NO_UUIDOF in build settings as specified in MSDN docs on COM_INTERFACE_ENTRY Macros.
However, I not sure why this happening - I have other MSDN samples which do not require this - so if anyone can shed any light on what's going on I would be interested.
James
|
|
|
|
|
The errors you are getting are because the compiler can't find the defined interface. You are probably missing a #include that is neccessary, try inserting #include <comdef.h> into your stdafx.h and recompile. If that doesn't solve the problem then add #include <shlobj.h> into your stdafx.h header file and recompile.
The first option should do the fix since that is where the GUID is defined for IInputObject.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Is there any easy example out,
placing a dialog resource in the bar ?
Or placing other controlls like buttons & co ?
Everything is working but I have no CWnd Class
for adding Buttons/ListBoxes & Co ...
|
|
|
|
|
I'm trying to add another toolbar to IE 5 using this wizard,
I tried creating a TOOLBARCLASSNAME window class in the RegisterAndCreateWindow function
m_hWnd= ::CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
WS_CHILDWINDOW|WS_VISIBLE|TBSTYLE_TRANSPARENT|TBSTYLE_LIST|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|CCS_NODIVIDER|CCS_TOP, 0,0,0,0, m_hWndParent, NULL, g_hInst, NULL);
MoveWindow(m_hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
However instead of drawing the toolbar in the newly created band, it draws it over the top most band. I've tried various methods of moving the toolbar window but it always seems to want to draw itself over the IE menu bar.
if i use the default static control it is drawn in the correct place,
Any suggestions?
Michael
|
|
|
|
|