Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 691
  • Last Modified:

Docking Dialog/Window and CHtmlView

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
bilbo062901
Asked:
bilbo062901
  • 18
  • 15
1 Solution
 
migelCommented:
Hi!
what exactly problem you get?
Can you insert CHTMLView in the CDialogBar?
or you need dockacble resizeble HTML view?
0
 
bilbo062901Author Commented:
Dear Migel,
Thank you for your response.  I need a dockable, resizable HTML view.
0
 
migelCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
bilbo062901Author Commented:
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
 
migelCommented:
Ok
I will work under this problem
0
 
migelCommented:
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
 
bilbo062901Author Commented:
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
 
bilbo062901Author Commented:
Dear Migel,
Thank you.  It totally worked.
0
 
bilbo062901Author Commented:
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
 
migelCommented:
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
 
migelCommented:
Hello!
anybody here?
0
 
bilbo062901Author Commented:
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
 
migelCommented:
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
 
bilbo062901Author Commented:
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
 
migelCommented:
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
 
bilbo062901Author Commented:
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
 
migelCommented:
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
 
bilbo062901Author Commented:
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
 
bilbo062901Author Commented:
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
 
migelCommented:
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
 
bilbo062901Author Commented:
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
 
migelCommented:
I already see it.
My question remains same:
0
 
bilbo062901Author Commented:
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
 
bilbo062901Author Commented:
Migel,
I almost forgot, Flat toolbars would also be nice.  

Thanks
0
 
bilbo062901Author Commented:
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
 
migelCommented:
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
 
bilbo062901Author Commented:
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
 
migelCommented:
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
 
bilbo062901Author Commented:
Yes.  I will start a new one later this afternoon.

Thank you for all your help...
0
 
bilbo062901Author Commented:
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
 
migelCommented:
Hi!
I lock this Q since you get Answer to the primary Q aren`t you?
0
 
bilbo062901Author Commented:
Hi Migel,
I accepted the answer from you, did I not?  Let me know and I will give you the credit immediately.

Thanks
0
 
migelCommented:
hm
This topic remain opened, so no acceptance (may be EE troubles??)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 18
  • 15
Tackle projects and never again get stuck behind a technical roadblock.
Join Now