Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Dialog does not appear in the window of a CExtControlBar Collapse All
Subject Author Date
Andreas Werner Oct 24, 2006 - 2:30 AM

Hallo,

I have created a dialog resource with graphical tool in Visual Studio. The dialog contains two list boxes. I have
changed the source files, that have been created in VS in the following way:



First the header file:

#if !defined(AFX_DIALOG1_H__C8B9C3A0_46A7_408E_8092_33EC22F40DB7__INCLUDED_)
#define AFX_DIALOG1_H__C8B9C3A0_46A7_408E_8092_33EC22F40DB7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Dialog1.h : Header-Datei
//

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CDialog1

class CDialog1 : public CExtResizableDialog
{
// Konstruktion
public:
    CDialog1(CWnd* pParent = NULL); // Standardkonstruktor

// Dialogfelddaten
    //{{AFX_DATA(CDialog1)
    enum { IDD = IDD_DIALOG1 };
    //}}AFX_DATA


// Überschreibungen
    // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen
    //{{AFX_VIRTUAL(CDialog1)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV-Unterstützung
    //}}AFX_VIRTUAL

// Implementierung

protected:

    // Generierte Nachrichtenzuordnungsfunktionen
    //{{AFX_MSG(CDialog1)
    virtual BOOL OnInitDialog();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ fügt unmittelbar vor der vorhergehenden Zeile zusätzliche Deklarationen ein.

#endif // AFX_DIALOG1_H__C8B9C3A0_46A7_408E_8092_33EC22F40DB7__INCLUDED_





Second the cpp file:

// Dialog1.cpp: Implementierungsdatei
//

#include "stdafx.h"
#include "fullscreenstate.h"
#include "Dialog1.h"

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

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CDialog1


CDialog1::CDialog1(CWnd* pParent /*=NULL*/)
    : CExtResizableDialog(CDialog1::IDD, pParent)
{
    //{{AFX_DATA_INIT(CDialog1)
    //}}AFX_DATA_INIT
}


void CDialog1::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CDialog1)
    //}}AFX_DATA_MAP
}




BEGIN_MESSAGE_MAP(CDialog1, CDialog)
    //{{AFX_MSG_MAP(CDialog1)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen für Nachrichten CDialog1

BOOL CDialog1::OnInitDialog()
{
    CExtResizableDialog::OnInitDialog();
    AddAnchor(IDC_LIST1, CPoint(0,0), CPoint(200,200));
    AddAnchor(IDC_LIST2, CPoint(0,200), CPoint(100,100));

    
    // TODO: Zusätzliche Initialisierung hier einfügen
    
    return TRUE; // return TRUE unless you set the focus to a control
     // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
}


In the FullScreenState example I have added the following code to the OnCreate method of the main frame:

    CDialog1* pDlg = new CDialog1 ();
    
        
    if( !pDlg->Create(IDD_DIALOG1, &m_wndResizableBar0))
    {
        TRACE0("Failed to create m_wndInBarDlg\n");
        return -1;
    }

When I run the application I can see in the debugger, that the OnInitDialog method gets invoked by the framework, but the list boxes in the window of the dialog do not appear in the window of the CExtControlBar instance m_wndResizableBar0. It seems that dialog is not connected correctly to its parent window.

Suhai Gyorgy Oct 24, 2006 - 5:05 AM

Most probably the problem is with style you set for your dialog. It has to have these style (in addition to those you want to set): WS_CHILD | WS_CLIPCHILDREN | NOT WS_BORDER Probably you also want to set WS_VISIBLE style.

If it is still not working, try adding a CDialog1 variable to your MainFrame class and use that instead of a CDialog pointer inside your OnCreate only. You can check how it’s done in the ProfStudio sample.

And maybe reading this FAQ can help you as well.

Andreas Werner Oct 24, 2006 - 7:37 AM

Hallo and thank you for your help!

The dialog now appears with the right style settings. Now I have changed the implementation of the OnInitDialog method. Now I create a class that is derived form CExtPropertyGridCtrl and I put it onto the dialog on runtime. This works good. Using the constraints with AddAnchor the property grid changes its size properly.
I have only one Problem. I want the property grid to have the same width as the dialog. Now I have 280 hard coded, as shown in the code below Can I determine the width and the hight of the dialog or of the dialogs parent?.

BOOL CDialog1::OnInitDialog()
{
    CExtResizableDialog::OnInitDialog();

    LPRECT lpRect;
    if( !m_PGC.Create(this,
            IDC_PROPERTY_GRID_CTRL,            
            CRect(0,0,280,0)
            )
        )
    {
        TRACE0("Failed to create m_wndInBarColorPicker\n");
        return -1;        // fail to create
    }
    m_PGC.InitPropertyGrid();
    AddAnchor(IDC_PROPERTY_GRID_CTRL, CPoint(0,0), CPoint(100,100));
    // TODO: Zusätzliche Initialisierung hier einfügen
    
    return TRUE; // return TRUE unless you set the focus to a control
     // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
}

Suhai Gyorgy Oct 24, 2006 - 7:59 AM

In this case I’d recommend you not to use a dialog, but rather have your PropertyGridCtrl be the child of the control bar, as it is done in the ProfStudio sample. But if you have any special reason why you want to use a dialog here, you can try this code modification, although I’m afraid it might not work in every case:

BOOL CDialog1::OnInitDialog() 
{
	CExtResizableDialog::OnInitDialog();
 
	CRect rectWnd;
	GetClientRect(&rectWnd);
	if( !m_PGC.Create(this,
		IDC_PROPERTY_GRID_CTRL,            
		CRect(0, 0, rectWnd.Width, rectWnd.Height)
		)
	)
	{
		TRACE0("Failed to create m_wndInBarColorPicker\n");
		return -1;        // fail to create
	}
 ...
}

Andreas Werner Oct 24, 2006 - 8:20 AM

Thank you for Help,

the code works in my case. I need this because I am going to add another control to the dialog. Both controls shall use the full width of the dialog and share its height. Now as I can put one single control to the panel and calculate its size at runtime I am going to put the second control on it.

What problem may occur with code?

Is it possible to integrate a CExtPropertyGridCtrl or any other CExt...Ctrl into the graphical designer of Visual Studio? This way I could give the controls zero indents to the border of the dialog at design time?

Technical Support Oct 26, 2006 - 5:18 AM

Chris is right, you can create the property grid as a custom control, which can be placed as you want in the dialog template at design time.

Suhai Gyorgy Oct 24, 2006 - 8:44 AM

First I thought code might casue problem because dialog doesn’t have the right size when the OnInitDialog is called. But I realized that even though the dialog doesnt have the right size at that point, AddAnchor makes sure controls are resized when dialog is resized.

In Visual Studio you can use a custom control in design mode and give class name ProfUIS-PropertyGridCtrl, style 0x50010000 and extended style 0x0 to it. You can see how it’s done in PropertyGrid sample. For other controls... if the control is derived from one of the MFC controls, you can use those MFC controls at design time and in DoDataExchange just add variables of Prof-UIS classes to those control IDs. For other Prof-UIS controls: Try searching for that control in ProfUIS sample codes and see what custom control class they use there.

Technical Support Oct 24, 2006 - 7:11 AM

In addition to what Chris wrote, we would like to ask you to check that the Visible flag for the dialog template is turned on.