Solved

Docking Dialog/Window and CHtmlView

Posted on 2001-06-29
33
593 Views
Last Modified: 2013-11-20
I am trying to delvelp an application with a dockable window/dialog (as in Visual Studio) that can display HTML files using the CHtmlView class.  Does anyone know how this can be done, or is aware of sample codes or libraries (shareware or commercial) that can facilitate this project?

I should note that I have examples of dockable windows/dialogs and I also know how to create a HtmlView in a dialog, but I am unable to combine the two.

Any  help in this matter is greatly appreciated.

Thanks
0
Comment
Question by:bilbo062901
  • 18
  • 15
33 Comments
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
what exactly problem you get?
Can you insert CHTMLView in the CDialogBar?
or you need dockacble resizeble HTML view?
0
 

Author Comment

by:bilbo062901
Comment Utility
Dear Migel,
Thank you for your response.  I need a dockable, resizable HTML view.
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
ok
did you look at www.codeguru.com at docking window section?
http://www.codeguru.com/docking/docking_window2.shtml - you can use this code
just derive your own class from CSizingControlBar and add CHTMLView as child.
0
 

Author Comment

by:bilbo062901
Comment Utility
Dear Migel,
I did look at codeguru before.  Are you telling me that you can attach a view class (i.e. CHtmlView) a CSizingControlBar class?  Because I don't think that works, or at least I haven't gotten it to work.  Have you ever seen a sample application?

Still thank you so much for your response.  I will read the article again.
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Ok
I will work under this problem
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
here is my results:
I use article i mentoned above so I place here only differencies:
1.
in the CMyBar.h
replace
CButton m_wndChild; to CHtmlView*     m_pwndChild;
2.
in the CMyBar.cpp:
//a)
CMyBar::CMyBar()
{
m_pwndChild = NULL; //!!!!
}

//b)
int CMyBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (baseCMyBar::OnCreate(lpCreateStruct) == -1)
        return -1;
// start creation of the view!
     m_pwndChild = (CHtmlView*)(RUNTIME_CLASS(CHtmlView)->CreateObject());
     if (m_pwndChild)
          if (!m_pwndChild->Create(NULL, "MyView",
               WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this, ID_EDIT_PASTE))
               return -1;
     m_pwndChild->Navigate2("F:"\projects"\resize"\READMEVC.HTM"); // put here your startup page URL
    return 0;
}

c)
void CMyBar::OnSize(UINT nType, int cx, int cy)
{
    baseCMyBar::OnSize(nType, cx, cy);

    // TODO: Add your message handler code here
    CRect rc;
    GetClientRect(rc);

     if (m_pwndChild) // here changes too
          m_pwndChild->MoveWindow(rc);
}

hope this helps you
0
 

Author Comment

by:bilbo062901
Comment Utility
Dear Migel,
Thank you so much for all your help.  I will take a look at this code, try it and if it does what I think it does, I will surely give you the much deserved credit.  Once again thank you very much and I will speak to you early next week.
0
 

Author Comment

by:bilbo062901
Comment Utility
Dear Migel,
Thank you.  It totally worked.
0
 

Author Comment

by:bilbo062901
Comment Utility
Hi Migel,
If you get this can you please post a comment for me.  If I try to create a class derived from CHtmlView, I am unable to message map, for example I can't get "my" OnBeforeNavigate2() to be called.  Any ideas?

Any help is greatly appreciated.
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
it is a second question, isn`t it?
It must be called since it is virtual function.
check your declaration in te derived class.
Or ClassWizard doesn`t show it for you? in this case you have to write virtual methods manually - open afxhtml.h and copy needed declarations to the your class.
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hello!
anybody here?
0
 

Author Comment

by:bilbo062901
Comment Utility
Hi Migel,
Sorry its taken me so long to get back to you, but i think the server was down on Friday.   Thanks to you I now have a working docking window with an embedded HtmlView object.  Is there anyway you know to add a toolbar to a docking window?

Thank you.
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
it is simple (but costs more points :-) since you have first Q. ansvered, aren`t you? ):
add member to the class CToolBar m_ToolBar;
add typical toolbar initialisation into theOnCreate method and
add some layout managmemt in the OnSize handler.
is it clear enough?
0
 

Author Comment

by:bilbo062901
Comment Utility
Dear Migel,
I'll be more than happy to assign more points :)
I have declared a CToolBar varialbe (i.e. m_TooBar) and I have initialized it as you mentione, though I am not sure if i initialized it correctly.  However I haven't made any changes to the OnSize handler, what changes are you talking about.  My ToolBar seems to be created but isn't visible.  Any clues?

Thanks
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
here is code:
int CMyBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (baseCMyBar::OnCreate(lpCreateStruct) == -1)
        return -1;

    if (!m_wndChild.Create(_T("Paste"),
        WS_CHILD|WS_VISIBLE,
        CRect(0,0,0,0), this, ID_EDIT_PASTE))
        return -1;

     if (!m_wndToolBar.Create(this) ||
          !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
     {
          TRACE0("Failed to create toolbar"n");
          return -1;      // fail to create
     }

    // older versions of Windows* (NT 3.51 for instance)
    // fail with DEFAULT_GUI_FONT
    if (!m_font.CreateStockObject(DEFAULT_GUI_FONT))
        if (!m_font.CreatePointFont(80, "MS Sans Serif"))
            return -1;

    m_wndChild.SetFont(&m_font);
     CRect rect(0, 0, 32767, 32767);
     RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery,
          &rect, &rect, FALSE);
     RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposExtra,
          NULL, &rect, TRUE);
return 0;
}

void CMyBar::OnSize(UINT nType, int cx, int cy)
{
    baseCMyBar::OnSize(nType, cx, cy);

    // TODO: Add your message handler code here
     CRect rcTool;
     m_wndToolBar.GetWindowRect(&rcTool);
     m_wndToolBar.MoveWindow(0, 0, rcTool.Width(), rcTool.Height());
    CRect rc;
    GetClientRect(rc);

    m_wndChild.MoveWindow(0, rcTool.Height(), rc.Width(), rc.Height()-rcTool.Height());
}
0
 

Author Comment

by:bilbo062901
Comment Utility
Migel,
Great job again.  I am very impressed.  That seems to work, though i had to change "reposExtra" to "reposDefault" otherwise it crashed.  Do you know how to have the toolbar not have any vertical lines between the buttons and more importantly not to have that big vertical bar on top because  it ends in the middle (which might have something to do with my changing the options you suggested.)

But it works, though I still have to figure out how to intercept messages, when a button is clicked (I have very little experience in this).

Thank you so much.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
to remove gaps between tool buttons just edit toolbar resource and remove separators.
to remove line (do yoou mean horizontal line??)
modify style of your toolbar:

     if (!m_wndToolBar.Create(this) ||
          !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
          {
          TRACE0("Failed to create toolbar!"n");
          return -1;     // fail to create
          }
     m_wndToolBar.SetBarStyle(CBRS_TOP);//<<!!

0
 

Author Comment

by:bilbo062901
Comment Utility
Migel,
Great job again.  I am very impressed.  That seems to work, though i had to change "reposExtra" to "reposDefault" otherwise it crashed.  Do you know how to have the toolbar not have any vertical lines between the buttons and more importantly not to have that big vertical bar on top because  it ends in the middle (which might have something to do with my changing the options you suggested.)

But it works, though I still have to figure out how to intercept messages, when a button is clicked (I have very little experience in this).

Thank you so much.
0
 

Author Comment

by:bilbo062901
Comment Utility
Migel,
SetBarStyle() doesn't get rid of the "horizontal" line.  At least I can't figure it out.  Furthermore some of the options cause the toolbar to not even show.

I also can't get rid of the vertical lines dividing the buttons.

Any ideas?

Thanks
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
what OS you use?
under windows NT 4 -2000 all seems OK.

>>I also can't get rid of the vertical lines dividing the buttons.
what vertical  lines?? do you mean separators or something else?
Or you need FLAT toolbar like IE? and latest MS office?
0
 

Author Comment

by:bilbo062901
Comment Utility
Migel,
SetBarStyle() doesn't get rid of the "horizontal" line.  At least I can't figure it out.  Furthermore some of the options cause the toolbar to not even show.

I also can't get rid of the vertical lines dividing the buttons.

Any ideas?

Thanks
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
I already see it.
My question remains same:
0
 

Author Comment

by:bilbo062901
Comment Utility
Hi Migel,
I am using 2000, but the application will have to run under NT4, 98, and 2000.

The horizontal bar I am referring to is a gray line just above or below the buttons (depending on the setting) and since the toolbar isn't being resized to fit the frame (MyBar) the line sort of ends in the middle.  Again, I changed your code slightly because using reposExtra crashed so I changed it to reposDefault for the RepositionBars() function.  Before I add the toolbar I am adding a HtmlView which might be the reason (not sure).

Also I had to modify the CSizingControlBar::OnSize(...) to take out the assertion there because it will only deal with one child window, so any other child window (i.e. toolbar, button, etc...) cause an assertion failure.

Thank you so much for all the help you've given me.  I've learened a lot from you.
0
 

Author Comment

by:bilbo062901
Comment Utility
Migel,
I almost forgot, Flat toolbars would also be nice.  

Thanks
0
 

Author Comment

by:bilbo062901
Comment Utility
Hi Migel,
I have a question and let me know and I will assign points to it.  I have a CToolBar class in my code (thank you,) but when CMyBar is floating the toolbar buttons all become inactive.  Any ideas why?
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
it is strange since I have test project and all buttons have valid state.
May be you define your commands handler in the view not in the mainframe?
0
 

Author Comment

by:bilbo062901
Comment Utility
Hi Migel,
I got it working by defining the command handler in my App instead of the mainframe.  

The thing I can't quite figure out is how to have my CMyBar class call a function in the CView part of the application.  Any ideas?

Thanks
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Dear Bilbo
We solve several problems there so I think we can close this thread and open new one for resolution your next problem.
Do you agree??
0
 

Author Comment

by:bilbo062901
Comment Utility
Yes.  I will start a new one later this afternoon.

Thank you for all your help...
0
 

Author Comment

by:bilbo062901
Comment Utility
Hi Migel,
I just posted a question on how to send messages from my CMybar class to my CMyview class.  Just wanted to let you know.

Thanks
0
 
LVL 12

Accepted Solution

by:
migel earned 100 total points
Comment Utility
Hi!
I lock this Q since you get Answer to the primary Q aren`t you?
0
 

Author Comment

by:bilbo062901
Comment Utility
Hi Migel,
I accepted the answer from you, did I not?  Let me know and I will give you the credit immediately.

Thanks
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
hm
This topic remain opened, so no acceptance (may be EE troubles??)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 67
Host to IP 7 73
if loop in java 3 113
bigDiff challenge 17 74
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now