Internet Explorer Pager Control ...


This article was contributed by Svetoslav Chakaroff.

Environment: VC6

Hi, I was 14 years old when i wrote that control (almost when it came up to IE5.5) when I saw it

for first time I said to myself: "I will make my own" because 1.I like it

2.I havent been able to find it...But however - that is the story of that control.

How to Use:

1. Projects->Add to Project->Files->SpawnFrameWnd.h/.cpp;IEPagerCtrl.h/.cpp;MenuSpawn.h/.cpp

2. MainFrm.h changes:

#include "IEPagerCtrl.h" #include "SpawnFrameWnd.h" ------------------------------------------------------------- //General message map functions protected: //AFX_MSG(CMainFrame) //add this: afx_msg void OnArrow(); ------------------------------------------------------------- Replace "CFrameWnd" with "CSpawnFrameWnd" Replace "CToolBar m_wndToolBar" with "CIEPagerCtrl m_wndToolBar"

3. View->Resource Symbols->New->Name: ID_ARROW -> OK

4. MainFrm.cpp changes:

BEGIN _MESSAGE_MAP(........) ON_COMMAND(ID_ARROW, OnArrow) . . . . .

5. Replace "CFrameWnd" with "CSpawnFrameWnd"(everywhere, try with

replace action from the edit menu and replace all)

6. Add message handler to WM_SIZE, and add this code to the message

replace the OnSize with that: void CMainFrame::OnSize(UINT nType, int cx, int cy) { if ( nType == SIZE_MINIMIZED ) { cx1 = cx;cy1 = cy; } else if ( nType == SIZE_RESTORED && cx1 != 0 && cy1 != 0) { m_wndToolBar.SetSize(cx1); } m_wndToolBar.SetSize(cx); Invalidate(); CSpawnFrameWnd::OnSize(nType, cx, cy); }and then add that before it: "int cx1 = 0,cy1 = 0;" as global variables.

7. Add this source code to the MainFrm.cpp

void CMainFrame::OnArrow() { HMENU lMenu; CPoint pPoint; lMenu = ::CreatePopupMenu(); if ( lMenu != NULL ) { BUTTONSINFO butInfo[100]; int nButtons = m_wndToolBar.GetHiddenButtonsInfo ( butInfo ); for ( int i = 0; i < nButtons; i++ ) { if ( butInfo[i].nStyle == TBSTYLE_SEP && i == 0 ) {} else ::AppendMenu(lMenu, MF_ENABLED | MF_STRING , butInfo[i].nID, butInfo[i].strToolTip ); } CMenu *pMenu; pMenu = pMenu->FromHandle ( lMenu ); CRect rect; m_wndToolBar.GetToolBarCtrl().GetRect(ID_ARROW , &rect); m_wndToolBar.ClientToScreen(&rect); m_wndToolBar.GetToolBarCtrl().PressButton( ID_ARROW ); pMenu->TrackPopupMenu ( TPM_LEFTBUTTON, rect.left, rect.bottom, this, NULL ); m_wndToolBar.GetToolBarCtrl().PressButton( ID_ARROW, FALSE ); } else TRACE0("ERROR: lMenu = NULL"); }

8. Add this source code to the CMainFrame construction:

cSpawn.LoadToolBarResource( IDR_MAINFRAME );

9. Add the bitmaps IDB_ARROW and IDB_MENUCHK

That's it!!! Special thanks for the Spawn class - it gives me the ability of settings bitmaps for the Menus!!! - the most important.
P.S.I am really sorry for my BAD English - I am from Bulgaria, and my English is in process of developement;)

I hope you like what I did:)

Downloads

Download Demo Project - 59.9 Kb
Download Source Code - 10.5 Kb

History

Date Posted: January 15, 2002