Borland C++ 16-bit applications problem




16-bit OWL applications, generated with Borland C++ 4.5x or 5.x, under Windows 2000 cause Access Violation in WOW32.DLL when the mouse is moved over the 'X' button and a tooltip is about to be displayed.

One possible solution is to turn off tooltips for the caption buttons.

There is better solution, posted by Regis St-Gelais:

/*------------------------------------------------------------------------------------------------
With the invaluable help of James S. Whitehead,
I was able to resolve the problem of the infamus ToolTip Crash with OWL
16bits under Windows 2000.
The key is to trap the hit test only when we hit one of the system menu
button.
*/

DEFINE_RESPONSE_TABLE1(TDFrameUmt, TDecoratedFrame)
    EV_WM_NCHITTEST,
    EV_WM_NCLBUTTONDOWN,
    EV_WM_NCLBUTTONUP,
END_RESPONSE_TABLE;

uint TDFrameUmt::EvNCHitTest(TPoint& point)
    {
    uint retVal;

    retVal = TDecoratedFrame::EvNCHitTest(point);
    if (!hitOK)
        {
        uLastHit = retVal;
             // uLastHit saves what would have been
             // the actual Hit Test return value
        tpSave = point;
             // tpSave is a member of your frame
             // (and client) class
             // until it would be needed for the user.

        if ( (retVal==HTMAXBUTTON) || (retVal==HTMINBUTTON) || (retVal==20) )
           {
           retVal = 32;
               // 32 is a value that is not normally
               // supported by Windows (0-21 are Windows values)
               // Using it prevents the Windows tooltips from displaying
           }
        }
    return retVal;
    }

void TDFrameUmt::EvNCLButtonUp(uint hitTest, TPoint& point)
    {
    LPARAM lP;

    if (hitTest == 32) // If we hit one of the system menu button
        {
        //  We have been trapping hit test return values,
        //  but now we need to activate one of the system menu button
        //  So, resend the last sequence of messages with hitOK set to TRUE
        //  so the messages are processed normally
        hitOK = TRUE;
        lP = LPARAM MAKELPARAM(tpSave.x, tpSave.y);
        SendMessage(WM_NCHITTEST, 0, lP);
        SendMessage(WM_NCMOUSEMOVE, uLastHit, lP);
        PostMessage(WM_NCLBUTTONUP, uLastHit, lP);
        hitOK = FALSE;
        }
    else // Process normaly
       TDecoratedFrame::EvNCLButtonUp(hitTest,point);
     }

void TDFrameUmt::EvNCLButtonDown(uint hitTest, TPoint& point)
    {
    LPARAM lP;

    if (hitTest == 32) // If we hit one of the system menu button
        {
        //  We have been trapping hit test return values,
        //  but now we need to activate one of the system menu button
        //  So, resend the last sequence of messages with hitOK set to TRUE
        //  so the messages are processed normally
        hitOK = TRUE;
        lP = LPARAM MAKELPARAM(tpSave.x, tpSave.y);
        SendMessage(WM_NCHITTEST, 0, lP);
        SendMessage(WM_NCMOUSEMOVE, uLastHit, lP);
        PostMessage(WM_NCLBUTTONDOWN, uLastHit, lP);
        hitOK = FALSE;
        }
    else // Process normaly
        TDecoratedFrame::EvNCLButtonDown(hitTest,point);
    }


Back to home Back to main