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 » Next questions about grids Collapse All
Subject Author Date
Gevork Odabashyan Jun 27, 2007 - 6:13 AM

Hello

How can I constrain the size of input text in a CExtGridCellString?

Next, I have a CExtPropertyGrid in a CExtResizablePropertyPage. When this grid has focus and the CTRL is pressed, input focus moves to next control in the property page. But I your property grid sample input focus inside property grid changes to next cell in this case. What I need to do to have the same behavior?

Thank for support

Suhai Gyorgy Jun 27, 2007 - 6:33 AM

1. CExtGridCellEx::LimitTextSet can be used for this purpose.

2. Isn’t it the TAB key instead of CTRL key?
I guess you should override PreTranslateMessage in your CExtResizablePropertyPage-derived class and if the message is the WM_CHAR message with TAB virtual key, let the grid have first crack at the message (call PreTranslateMessage of grid)

Suhai Gyorgy Jun 27, 2007 - 7:51 AM

Sorry, there were some mistakes in last post about handling TAB key. Here’s code:

BOOL CMyResizablePage::PreTranslateMessage(MSG* pMsg)
{
	if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB && GetFocus() == &m_wndPropGrid)
		return m_wndPropGrid.PreTranslateMessage(pMsg);
	return CExtResizablePropertyPage::PreTranslateMessage(pMsg);
}

Gevork Odabashyan Jun 28, 2007 - 4:23 AM

Can Prof-UIS support help on TAB problem?

Gevork Odabashyan Jun 28, 2007 - 4:22 AM

Thanks, Gyorgy, but your code about TAB key doesn’t work. First, CExtPropertyGridCtrl::PreTranslateMessage() is protected, but even after that, GetFocus() == &m_wndPropGrid doesn’t work. I don’t know why.

Suhai Gyorgy Jun 28, 2007 - 6:33 AM

One more addition to the code to be on the save side:

BOOL CMyResizablePage1::PreTranslateMessage(MSG* pMsg)
{
	if (
		pMsg->message == WM_KEYDOWN 
		&& pMsg->wParam == VK_TAB
		&& m_PropGridCtrl.IsChild(GetFocus())
		&& m_PropGridCtrl.GetActiveGrid() != NULL 
	)
	{
		m_PropGridCtrl.GetActiveGrid()->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
		return TRUE;
	}
	return CExtResizablePropertyPage::PreTranslateMessage(pMsg);
}

Gevork Odabashyan Jun 29, 2007 - 2:58 AM

Thanks, Gyorgy! But your code still doesn’t work. Propery page’s focus remains on the CExtProperyGridWnd, wich has no reaction on this forwarded messge.

Suhai Gyorgy Jun 29, 2007 - 4:55 AM

I really don’t know what the problem is, as it is working for me.
You can download the sample I worked with from here. It is a modified version of ProfUIS’s ResizablePropertySheet sample.

Gevork Odabashyan Jul 2, 2007 - 5:53 AM

Thanks a lot Gyorgy! I’m very pleased for your help.
Your code works well. But I have changed CMyResizablePage1::GetPropertyStore() method to this:

CExtPropertyStore * CMyResizablePage1::GetPropertyStore()
{
    ASSERT_VALID( this );
    if( m_pPS != NULL )
        return m_pPS;

    m_pPS = new CExtPropertyStore;

    CExtPropertyCategory* pCat = 0;
    CExtPropertyValue* pItem = 0;

    for (DWORD i = 0; i < 3; ++i)
    {
        pCat = new CExtPropertyCategory(_T("TestCategory"));
        if (m_pPS->ItemInsert(pCat))
        {
            for (DWORD j = 0; j < 5; ++j)
            {
                pItem = new CExtPropertyValue(_T("TestName"));
                if (pCat->ItemInsert(pItem))
                {
                    CExtGridCellString* pValue = STATIC_DOWNCAST(CExtGridCellString,
                        pItem->ValueActiveGetByRTC(RUNTIME_CLASS(CExtGridCellString)));
                    pValue->ModifyStyleEx( __EGCS_EX_WRAP_TEXT);
                    pItem->HeightPxSet(50);
                    pValue->LimitTextSet(50);
                }
            }
        }
    }

    return m_pPS;
}

This is like the code in my project. The TAB key doesn’t work in this case. I have sent your project to support. I hope they will check what’s wrong.

Suhai Gyorgy Jun 28, 2007 - 6:27 AM

I’m sorry, you are right, I’ve tested the code with another control which didn’t have PreTranslateMessage protected and no child controls either, so GetFocus worked on that.

But now I’ve made a little sample application with PropertySheet and PropertyGrid, and the following code works.

BOOL CMyResizablePage1::PreTranslateMessage(MSG* pMsg)
{
	if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB && m_PropGridCtrl.IsChild(GetFocus()))
	{
		m_PropGridCtrl.GetActiveGrid()->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
		return TRUE;
	}
	return CExtResizablePropertyPage::PreTranslateMessage(pMsg);
}

Still, I’d also like to hear from Support whether this solution is acceptable and safe.

And even though PropertyGrid sample works as you’ve described (TAB goes through all property items of grid) I’m not sure if this is a good design: once you get inside the grid by pressing TAB, there’s no way out, you can only get to the other controls of the dialog if you use the mouse.