Solved

Tooltips of CTreeCtrl in a CDialogBar

Posted on 2002-05-13
18
2,970 Views
Last Modified: 2013-11-20
Problem is:
When my CDialogBar is floating, all tooltips are appearing behind the CDialogBar.

The tooltips are fine, and on top when the CDialogBar is docked.

These tooltips are the default ones included from the CTreeCtrl.

Question is:
How can I always keep my tooltips on top, where they like to be, even when the CDialogBar is floating.
0
Comment
Question by:Crius
  • 8
  • 6
  • 4
18 Comments
 
LVL 16

Expert Comment

by:AlexNek
ID: 7006779
2 Crius
>all tooltips are appearing behind the CDialogBar
how you can see it behind?
Could you give us some code which create tooltips.
0
 
LVL 3

Author Comment

by:Crius
ID: 7006789
I can see it behind because the Tooltips are long enough that they extend beyond the CDialogBar's border.

No, I can not because these are the default, built in Tooltips that appear with the CTreeCtrl. All the source code to create these tooltips is in the MFC source code, somewhere, and I do not actually interact with them in any way.
0
 
LVL 3

Author Comment

by:Crius
ID: 7006906
This problem can be easily reproduced by doing the following:

Create a new MFC Project (I made SDI)

Create a dialog resource, set the child style, and no border, and place a tree control inside. Best to make the dialog and tree control small so you can see the tooltip poke from behind.

In the Mainfrm, add variable
      Diag1 m_Diag1;

In OnCreate of Mainfrm
     if (!m_Diag1.Create(this, IDD_DIALOG1, CBRS_LEFT, IDD_DIALOG1))
     {
         MessageBox("Thar be stormy seas ahead.", "Arrr!");
     }

     m_Diag1.SetBarStyle(m_Diag1.GetBarStyle() |
                         CBRS_LEFT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

     m_Diag1.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
     //
     // Dock the toolbars
     //
     m_Diag1.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);

     EnableDocking(CBRS_ALIGN_ANY);
     DockControlBar(&m_Diag1);


Once you've created the CDialogBar child class, override OnContextMenu (So a right click adds an item)
void Diag1::DoDataExchange(CDataExchange* pDX)
{
     CDialogBar::DoDataExchange(pDX);
     //{{AFX_DATA_MAP(Diag1)
     DDX_Control(pDX, IDC_TREE1, m_tree);
     //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Diag1, CDialogBar)
     //{{AFX_MSG_MAP(Diag1)
     ON_WM_CONTEXTMENU()
     //}}AFX_MSG_MAP
END_MESSAGE_MAP()

void Diag1::OnContextMenu(CWnd* pWnd, CPoint point)
{
    UpdateData(false);
    m_tree.InsertItem("This be a long item, yes?");
}

The problem is easily visible. While the CDialogBar is docked, you can see the tooltip fine. When the CDialogBar is floating, the tooltip appears behind.

This project took me 5 minutes to make, I hope it will help you see my problem.
0
 
LVL 3

Author Comment

by:Crius
ID: 7006919
If you create a project "Diabar", you should be able to copy and paste these files in directly.

Here are the only 6 files I changed in making this project:

// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINFRM_H__E0D87CB2_C70D_4C86_9F5C_36C5EA47D911__INCLUDED_)
#define AFX_MAINFRM_H__E0D87CB2_C70D_4C86_9F5C_36C5EA47D911__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Diag1.h"

class CMainFrame : public CFrameWnd
{
      
protected: // create from serialization only
      CMainFrame();
      DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CMainFrame)
      virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
      //}}AFX_VIRTUAL

// Implementation
public:
      virtual ~CMainFrame();
#ifdef _DEBUG
      virtual void AssertValid() const;
      virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
      CStatusBar  m_wndStatusBar;
      CToolBar    m_wndToolBar;
      Diag1 m_Diag1;

// Generated message map functions
protected:
      //{{AFX_MSG(CMainFrame)
      afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
            // NOTE - the ClassWizard will add and remove member functions here.
            //    DO NOT EDIT what you see in these blocks of generated code!
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__E0D87CB2_C70D_4C86_9F5C_36C5EA47D911__INCLUDED_)


// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "DiaBar.h"

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
      //{{AFX_MSG_MAP(CMainFrame)
            // NOTE - the ClassWizard will add and remove mapping macros here.
            //    DO NOT EDIT what you see in these blocks of generated code !
      ON_WM_CREATE()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
      ID_SEPARATOR,           // status line indicator
      ID_INDICATOR_CAPS,
      ID_INDICATOR_NUM,
      ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
      // TODO: add member initialization code here
      
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
      if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
      
      if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
            | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
            !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
      {
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create
      }

      if (!m_wndStatusBar.Create(this) ||
            !m_wndStatusBar.SetIndicators(indicators,
              sizeof(indicators)/sizeof(UINT)))
      {
            TRACE0("Failed to create status bar\n");
            return -1;      // fail to create
      }

      if (!m_Diag1.Create(this, IDD_DIALOG1, CBRS_LEFT, IDD_DIALOG1))
      {
          MessageBox("Thar be stormy seas ahead.", "Arrr!");
      }

      m_Diag1.SetBarStyle(m_Diag1.GetBarStyle() |
                             CBRS_LEFT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

      m_Diag1.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
      //
      // Dock the toolbars
      //
      m_Diag1.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);

      // TODO: Delete these three lines if you don't want the toolbar to
      //  be dockable
      m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
      EnableDocking(CBRS_ALIGN_ANY);
      DockControlBar(&m_wndToolBar);
      DockControlBar(&m_Diag1);

      return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
      if( !CFrameWnd::PreCreateWindow(cs) )
            return FALSE;
      // TODO: Modify the Window class or styles here by modifying
      //  the CREATESTRUCT cs

      return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
      CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
      CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers



#if !defined(AFX_DIAG1_H__67A6381D_83F9_4ACE_BEB3_89C9125B796E__INCLUDED_)
#define AFX_DIAG1_H__67A6381D_83F9_4ACE_BEB3_89C9125B796E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Diag1.h : header file
//

#define WM_DIAG WM_USER+1

/////////////////////////////////////////////////////////////////////////////
// Diag1 dialog

class Diag1 : public CDialogBar
{
// Construction
public:
      Diag1(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
      //{{AFX_DATA(Diag1)
      enum { IDD = IDD_DIALOG1 };
      CTreeCtrl      m_tree;
      //}}AFX_DATA


// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(Diag1)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL

// Implementation
protected:
      // Generated message map functions
      //{{AFX_MSG(Diag1)
      afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DIAG1_H__67A6381D_83F9_4ACE_BEB3_89C9125B796E__INCLUDED_)


// Diag1.cpp : implementation file
//

#include "stdafx.h"
#include "DiaBar.h"
#include "Diag1.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Diag1 dialog


Diag1::Diag1(CWnd* pParent /*=NULL*/)
      : CDialogBar()
{
      //{{AFX_DATA_INIT(Diag1)
            // NOTE: the ClassWizard will add member initialization here
      //}}AFX_DATA_INIT
}


void Diag1::DoDataExchange(CDataExchange* pDX)
{
      CDialogBar::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(Diag1)
      DDX_Control(pDX, IDC_TREE1, m_tree);
      //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Diag1, CDialogBar)
      //{{AFX_MSG_MAP(Diag1)
      ON_WM_CONTEXTMENU()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Diag1 message handlers

void Diag1::OnContextMenu(CWnd* pWnd, CPoint point)
{
    UpdateData(false);
    m_tree.InsertItem("This be a long item, yes?");
}


//Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by DiaBar.rc
//
#define IDD_ABOUTBOX                    100
#define IDR_MAINFRAME                   128
#define IDR_DIABARTYPE                  129
#define IDD_DIALOG1                     130
#define IDC_TREE1                       1000

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS                     1
#define _APS_NEXT_RESOURCE_VALUE        131
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

//Diabar.rc
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
    "#ifdef _WIN32\r\n"
    "LANGUAGE 9, 1\r\n"
    "#pragma code_page(1252)\r\n"
    "#endif //_WIN32\r\n"
    "#include ""res\\DiaBar.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
    "#include ""afxres.rc""         // Standard components\r\n"
    "#include ""afxprint.rc""       // printing/print preview resources\r\n"
    "#endif\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON    DISCARDABLE     "res\\DiaBar.ico"
IDR_DIABARTYPE          ICON    DISCARDABLE     "res\\DiaBarDoc.ico"

/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//

IDR_MAINFRAME           BITMAP  MOVEABLE PURE   "res\\Toolbar.bmp"

/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//

IDR_MAINFRAME TOOLBAR DISCARDABLE  16, 15
BEGIN
    BUTTON      ID_FILE_NEW
    BUTTON      ID_FILE_OPEN
    BUTTON      ID_FILE_SAVE
    SEPARATOR
    BUTTON      ID_EDIT_CUT
    BUTTON      ID_EDIT_COPY
    BUTTON      ID_EDIT_PASTE
    SEPARATOR
    BUTTON      ID_FILE_PRINT
    SEPARATOR
    BUTTON      ID_APP_ABOUT
END


/////////////////////////////////////////////////////////////////////////////
//
// Menu
//

IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "&New\tCtrl+N",                ID_FILE_NEW
        MENUITEM "&Open...\tCtrl+O",            ID_FILE_OPEN
        MENUITEM "&Save\tCtrl+S",               ID_FILE_SAVE
        MENUITEM "Save &As...",                 ID_FILE_SAVE_AS
        MENUITEM SEPARATOR
        MENUITEM "&Print...\tCtrl+P",           ID_FILE_PRINT
        MENUITEM "Print Pre&view",              ID_FILE_PRINT_PREVIEW
        MENUITEM "P&rint Setup...",             ID_FILE_PRINT_SETUP
        MENUITEM SEPARATOR
        MENUITEM "Recent File",                 ID_FILE_MRU_FILE1, GRAYED
        MENUITEM SEPARATOR
        MENUITEM "E&xit",                       ID_APP_EXIT
    END
    POPUP "&Edit"
    BEGIN
        MENUITEM "&Undo\tCtrl+Z",               ID_EDIT_UNDO
        MENUITEM SEPARATOR
        MENUITEM "Cu&t\tCtrl+X",                ID_EDIT_CUT
        MENUITEM "&Copy\tCtrl+C",               ID_EDIT_COPY
        MENUITEM "&Paste\tCtrl+V",              ID_EDIT_PASTE
    END
    POPUP "&View"
    BEGIN
        MENUITEM "&Toolbar",                    ID_VIEW_TOOLBAR
        MENUITEM "&Status Bar",                 ID_VIEW_STATUS_BAR
    END
    POPUP "&Help"
    BEGIN
        MENUITEM "&About DiaBar...",            ID_APP_ABOUT
    END
END


/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//

IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
    "N",            ID_FILE_NEW,            VIRTKEY, CONTROL
    "O",            ID_FILE_OPEN,           VIRTKEY, CONTROL
    "S",            ID_FILE_SAVE,           VIRTKEY, CONTROL
    "P",            ID_FILE_PRINT,          VIRTKEY, CONTROL
    "Z",            ID_EDIT_UNDO,           VIRTKEY, CONTROL
    "X",            ID_EDIT_CUT,            VIRTKEY, CONTROL
    "C",            ID_EDIT_COPY,           VIRTKEY, CONTROL
    "V",            ID_EDIT_PASTE,          VIRTKEY, CONTROL
    VK_BACK,        ID_EDIT_UNDO,           VIRTKEY, ALT
    VK_DELETE,      ID_EDIT_CUT,            VIRTKEY, SHIFT
    VK_INSERT,      ID_EDIT_COPY,           VIRTKEY, CONTROL
    VK_INSERT,      ID_EDIT_PASTE,          VIRTKEY, SHIFT
    VK_F6,          ID_NEXT_PANE,           VIRTKEY
    VK_F6,          ID_PREV_PANE,           VIRTKEY, SHIFT
END


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 235, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About DiaBar"
FONT 8, "MS Sans Serif"
BEGIN
    ICON            IDR_MAINFRAME,IDC_STATIC,11,17,20,20
    LTEXT           "DiaBar Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX
    LTEXT           "Copyright (C) 2002",IDC_STATIC,40,25,119,8
    DEFPUSHBUTTON   "OK",IDOK,178,7,50,14,WS_GROUP
END

IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 67, 84
STYLE WS_CHILD
FONT 8, "MS Sans Serif"
BEGIN
    CONTROL         "Tree1",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_TABSTOP,
                    7,7,53,70
END


#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904B0"
        BEGIN
            VALUE "CompanyName", "\0"
            VALUE "FileDescription", "DiaBar MFC Application\0"
            VALUE "FileVersion", "1, 0, 0, 1\0"
            VALUE "InternalName", "DiaBar\0"
            VALUE "LegalCopyright", "Copyright (C) 2002\0"
            VALUE "LegalTrademarks", "\0"
            VALUE "OriginalFilename", "DiaBar.EXE\0"
            VALUE "ProductName", "DiaBar Application\0"
            VALUE "ProductVersion", "1, 0, 0, 1\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

#endif    // !_MAC


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
    IDD_ABOUTBOX, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 228
        TOPMARGIN, 7
        BOTTOMMARGIN, 48
    END

    IDD_DIALOG1, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 60
        TOPMARGIN, 7
        BOTTOMMARGIN, 77
    END
END
#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE PRELOAD DISCARDABLE
BEGIN
    IDR_MAINFRAME           "DiaBar\n\nDiaBar\n\n\nDiaBar.Document\nDiaBar Document"
END

STRINGTABLE PRELOAD DISCARDABLE
BEGIN
    AFX_IDS_APP_TITLE       "DiaBar"
    AFX_IDS_IDLEMESSAGE     "Ready"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_INDICATOR_EXT        "EXT"
    ID_INDICATOR_CAPS       "CAP"
    ID_INDICATOR_NUM        "NUM"
    ID_INDICATOR_SCRL       "SCRL"
    ID_INDICATOR_OVR        "OVR"
    ID_INDICATOR_REC        "REC"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_FILE_NEW             "Create a new document\nNew"
    ID_FILE_OPEN            "Open an existing document\nOpen"
    ID_FILE_CLOSE           "Close the active document\nClose"
    ID_FILE_SAVE            "Save the active document\nSave"
    ID_FILE_SAVE_AS         "Save the active document with a new name\nSave As"
    ID_FILE_PAGE_SETUP      "Change the printing options\nPage Setup"
    ID_FILE_PRINT_SETUP     "Change the printer and printing options\nPrint Setup"
    ID_FILE_PRINT           "Print the active document\nPrint"
    ID_FILE_PRINT_PREVIEW   "Display full pages\nPrint Preview"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_APP_ABOUT            "Display program information, version number and copyright\nAbout"
    ID_APP_EXIT             "Quit the application; prompts to save documents\nExit"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_FILE_MRU_FILE1       "Open this document"
    ID_FILE_MRU_FILE2       "Open this document"
    ID_FILE_MRU_FILE3       "Open this document"
    ID_FILE_MRU_FILE4       "Open this document"
    ID_FILE_MRU_FILE5       "Open this document"
    ID_FILE_MRU_FILE6       "Open this document"
    ID_FILE_MRU_FILE7       "Open this document"
    ID_FILE_MRU_FILE8       "Open this document"
    ID_FILE_MRU_FILE9       "Open this document"
    ID_FILE_MRU_FILE10      "Open this document"
    ID_FILE_MRU_FILE11      "Open this document"
    ID_FILE_MRU_FILE12      "Open this document"
    ID_FILE_MRU_FILE13      "Open this document"
    ID_FILE_MRU_FILE14      "Open this document"
    ID_FILE_MRU_FILE15      "Open this document"
    ID_FILE_MRU_FILE16      "Open this document"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_NEXT_PANE            "Switch to the next window pane\nNext Pane"
    ID_PREV_PANE            "Switch back to the previous window pane\nPrevious Pane"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_WINDOW_SPLIT         "Split the active window into panes\nSplit"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_EDIT_CLEAR           "Erase the selection\nErase"
    ID_EDIT_CLEAR_ALL       "Erase everything\nErase All"
    ID_EDIT_COPY            "Copy the selection and put it on the Clipboard\nCopy"
    ID_EDIT_CUT             "Cut the selection and put it on the Clipboard\nCut"
    ID_EDIT_FIND            "Find the specified text\nFind"
    ID_EDIT_PASTE           "Insert Clipboard contents\nPaste"
    ID_EDIT_REPEAT          "Repeat the last action\nRepeat"
    ID_EDIT_REPLACE         "Replace specific text with different text\nReplace"
    ID_EDIT_SELECT_ALL      "Select the entire document\nSelect All"
    ID_EDIT_UNDO            "Undo the last action\nUndo"
    ID_EDIT_REDO            "Redo the previously undone action\nRedo"
END

STRINGTABLE DISCARDABLE
BEGIN
    ID_VIEW_TOOLBAR         "Show or hide the toolbar\nToggle ToolBar"
    ID_VIEW_STATUS_BAR      "Show or hide the status bar\nToggle StatusBar"
END

STRINGTABLE DISCARDABLE
BEGIN
    AFX_IDS_SCSIZE          "Change the window size"
    AFX_IDS_SCMOVE          "Change the window position"
    AFX_IDS_SCMINIMIZE      "Reduce the window to an icon"
    AFX_IDS_SCMAXIMIZE      "Enlarge the window to full size"
    AFX_IDS_SCNEXTWINDOW    "Switch to the next document window"
    AFX_IDS_SCPREVWINDOW    "Switch to the previous document window"
    AFX_IDS_SCCLOSE         "Close the active window and prompts to save the documents"
END

STRINGTABLE DISCARDABLE
BEGIN
    AFX_IDS_SCRESTORE       "Restore the window to normal size"
    AFX_IDS_SCTASKLIST      "Activate Task List"
END

STRINGTABLE DISCARDABLE
BEGIN
    AFX_IDS_PREVIEW_CLOSE   "Close print preview mode\nCancel Preview"
END

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\DiaBar.rc2"  // non-Microsoft Visual C++ edited resources
#include "afxres.rc"         // Standard components
#include "afxprint.rc"       // printing/print preview resources
#endif

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

0
 
LVL 16

Expert Comment

by:AlexNek
ID: 7007189
2 Crius
I have the same effect now, thanks for the code. I never seen it effect before. I try to find out.
0
 
LVL 3

Author Comment

by:Crius
ID: 7007215
You are most welcome. :)

A while ago, I hypothesized the CDialog is trying to be the topmost window, always over the application. I figured this is why Tooltips are getting pushed behind it. Unfortunately, I could not find a solution to the problem since Tooltips do not exist until they are actually created.

The only way I could see to access the Tooltip just before creation was overriding CWnd::OnToolHitTest, and pulling the HWND right out of the TOOLINFO structure, and manipulating it directly, calling BringWindowToTop() and such, but that seemed like such a hack, so I didn't explore that route further.

I'm looking for something I'm missing, maybe a checkmark somewhere, or a flag I passed in wrong...

Sorry I didn't mention this before - I could never get anyone to bite before. :)
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 7007244
2 Crius
I can't find solution now but first what I can see that
function
void Diag1::DoDataExchange(CDataExchange* pDX)
{
     CDialogBar::DoDataExchange(pDX);
     //{{AFX_DATA_MAP(Diag1)
     //DDX_Control(pDX, IDC_TREE1, m_tree);
     //}}AFX_DATA_MAP
}

and line UpdateData(false);
in DialogBar has no sence.
Lets try to create the dialog but as a normal dialog - tooltips must be OK.
0
 
LVL 3

Author Comment

by:Crius
ID: 7007253
Try commenting out the UpdateData(false). Run the program, See what happens.

Now try commenting out the other line, the DDX_Control(pDX, IDC_TREE1, m_tree);
run the code, see what happens.

Both are needed because UpdateData(false) is only called when the Dialog is closing, and the DDX message maps the Tree Control to the variable.

The only other way to add an item to the tree control via code would be to use GetDlgItem() and start passing around IDs, casting, or sending messages to the control.

Granted, I should have picked a better place to put the UpdateData(false), but I tried to make this code as simple as possible, and didn't want to create OnInitDialog() sending messages, and doing a full proper initialization. It wouldn't matter if I did anyway, the problem would still exist.
0
 
LVL 3

Author Comment

by:Crius
ID: 7007259
We can't create this as a normal Dialog because it isn't. A dialog is typically a one use thing which serves a function, and is eventually closed (In SDI and MDI applications, this typically happens before the application ends).

Although I can create this as a child of CDialog, the main use of this tree control is embedded into the application framework because it directly interacts with the document and views. It does not make sense to have always floating. However, there are times we want this to be repositioned, or closed, so a splitter window is out of the question.

Since it must make use of a resource, easily modifiable, and controls can dynamically be added at runtime, most toolbars were out of the question. Only CDialogBar remained, and this is, afterall, the purpose CDialogBar was created.

Besides which, CDialogBar is MFC code, and that means we don't have to maintain the source, so making our own completely custom control is unacceptable.

In short, CDialogBar or bust.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:AlexNek
ID: 7007286
2 Crius
I'm sorry, I have no time to answer. Lets try to replace some code in CMainFrame::OnCreate. Note: state after create is Float!!

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....

  //DockControlBar(&m_Diag1);
     FloatControlBar(&m_Diag1, CPoint(20,20));

     CTreeCtrl* pTree;
     CToolTipCtrl* pToolTip;

     pTree = (CTreeCtrl *)m_Diag1.GetDlgItem(IDC_TREE1);
     if (pTree != NULL){    
          pTree->InsertItem("This be a long item, yes? 1");
          pTree->EnableToolTips(TRUE);
          pToolTip = pTree->GetToolTips();
          ASSERT(pToolTip != NULL);
          pToolTip->SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE  |SWP_NOSIZE     );
     }

It works in this case.
I'll come again later.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7007335
THis might be relevant:

http://groups.google.com/groups?q=CDialogbar+and+tooltip&hl=en&selm=01bcebe3%241d3c5cd0%24498da3ce%40nergal&rnum=3

Several google threads talk about screwball problems with dialogbars and tooltips.  More than one suggested owveriding CWnd::OnToolHitTest as the best fix.

The problem has to do with the tooltip determining its parent window.  In the case of a docked toolbar, the parent is the mainframe, but when the toolbar floats, that is no good.

I suggest breakpointing CWnd::OnToolHitTest and stepping through the code.  There is also some possbly-relevant things happening in the base class OnTimer event handler.

-- Dan
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 7007360
2 Crius
I have one idea. Try to overide "CDialogBar::CalcFixedLayout" check IsFloating()
and use the next two lines:
pToolTip = GetToolTips();
pToolTip->SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE  |SWP_NOSIZE     );
   

0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 7007731
A very tough problem.  As best as I can tell, it relates to the fact that the ParentOwner or the tree changes from CFrameWnd to CMiniDockFrameWnd.  

There are several workarounds, but this seems to be the easiest to implemtn:

Have the ClassWizard add an PreTransaletMessage handler to the CMainFrame.  Put this code in there:

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
     CTreeCtrl* pTree= (CTreeCtrl*) m_DlgBar.GetDlgItem( IDC_TREE1 );
     if (pMsg->hwnd == pTree->m_hWnd ) {
          CToolTipCtrl* pToolTip = pTree->GetToolTips();
          if ( pToolTip->IsWindowVisible() ) {
               pToolTip->SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
          }
     }
     return CFrameWnd::PreTranslateMessage(pMsg);
}
0
 
LVL 3

Author Comment

by:Crius
ID: 7008844
AlexNek, your solution did not work because if you dock the CDialogBar, and then refloat it, the problem returns. Besides which, I want the CDialogBar to start docked.

Thank you Dan, your solution worked well. It is unfortunate that I have to always call to have the Window Position set to top, but I suppose if I didn't, MFC code would have to anyway.

You are my saviour Dan, on several different occasions now. :) Thanks for this reference to the google groups. I hadn't realized there was an MFC newsgroup available.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7009058
The beauty of google is also its ugliness -- you can type in two or three keywords and get hundreds of hits.  Then you can spend 10 minutes working through a thread only to find that its about an obscure bug in an early beta version of MFC 4.0

I want to acknowledege that part of my solution was based on the code provided by AlexNek.  Once I was able to zero-in on the best/easiest way to trap a tip notification, I used his basic code to force it forward.

BTW, I think that if you use a CListView you will have similar problems.  Note that there are no problems with regular buttons or edit boxes.  It seems to relate to the fact that the Tree is a Common Control.  I also think that similar problems will come up with ActiveX controls.  I would also expect some problems with ComboBoxes because I saw that MFC was doing some special-casing for these controls.  I'd like to have found a cleaner, more general solution, but once something works, what the heck.

-- Dan
0
 
LVL 3

Author Comment

by:Crius
ID: 7009140
It was mostly my assumption that I was the only one experiencing this problem that prompted me to post it here, with so many points. Codeguru.com, and codeproject.com, along with the entire MSDN help references were not able to help me with this problem.

We all knew that BringWindowToTop, in some form, would have worked. I mentioned that early in this question.

The trouble really was knowing the best place to place this code. My own research pointed to CWnd::OnToolHitTest (just going through the help files), but I didn't like this solution. While we all would have preferred a cleaner, since it does appear to be an MFC bug, a cleaner solution likely doesn't exist.

I have added the Google Group reference to my bookmarks, and already tried a search test with "CDialogBar Tooltip", and the article you referenced showed on the first page. It's not an article I found nearly as helpful as your answer though. Still, I am happy to have another place to look for solutions - it will ensure my questions are even harder to answer in the future. Muwahahahahahaha... err.
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 7009598
2 DanRollins
>I want to acknowledege that part of my solution was based on the code provided by AlexNek.  
Thanks. We could build a good team :). Did you remember my first days at EE?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7009670
AlexNek,
Ah, yes... I think i accused you of stealing my answer once or twice.  No hard feelings I hope :)


Crius,
Bring'em on!
Muwahahahahahaha... MUUUUUUWAHHHAHHHAAAAAHHAAHaaa!
-- Dan
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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: …

759 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

21 Experts available now in Live!

Get 1:1 Help Now