Solved

Docking Dialog/Window and CHtmlView

Posted on 2001-06-29
33
656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 18
  • 15
33 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6238434
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
ID: 6238500
Dear Migel,
Thank you for your response.  I need a dockable, resizable HTML view.
0
 
LVL 12

Expert Comment

by:migel
ID: 6239385
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bilbo062901
ID: 6239490
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
ID: 6239512
Ok
I will work under this problem
0
 
LVL 12

Expert Comment

by:migel
ID: 6239583
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
ID: 6239611
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
ID: 6239720
Dear Migel,
Thank you.  It totally worked.
0
 

Author Comment

by:bilbo062901
ID: 6246087
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
ID: 6247480
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
ID: 6276335
Hello!
anybody here?
0
 

Author Comment

by:bilbo062901
ID: 6286101
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
ID: 6286132
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
ID: 6286195
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
ID: 6286299
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
ID: 6286545
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
 
LVL 12

Expert Comment

by:migel
ID: 6286820
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
ID: 6286942
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
ID: 6287310
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
ID: 6288681
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
ID: 6289559
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
ID: 6289599
I already see it.
My question remains same:
0
 

Author Comment

by:bilbo062901
ID: 6289619
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
ID: 6289622
Migel,
I almost forgot, Flat toolbars would also be nice.  

Thanks
0
 

Author Comment

by:bilbo062901
ID: 6309704
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
ID: 6313922
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
ID: 6318259
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
ID: 6319110
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
ID: 6319132
Yes.  I will start a new one later this afternoon.

Thank you for all your help...
0
 

Author Comment

by:bilbo062901
ID: 6324089
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
ID: 6358396
Hi!
I lock this Q since you get Answer to the primary Q aren`t you?
0
 

Author Comment

by:bilbo062901
ID: 6359362
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
ID: 6359405
hm
This topic remain opened, so no acceptance (may be EE troubles??)
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
In this post we will learn different types of Android Layout and some basics of an Android App.
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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

734 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