Add method void nsTextWidget::SubclassWindow(BOOL bState)

and LRESULT CALLBACK nsTextWidget::TextWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 to filter out the "ding" when the return key is pressed.
This commit is contained in:
rods%netscape.com 1998-08-03 22:31:07 +00:00
parent ffa3eb84e6
commit 086bb72002
2 changed files with 52 additions and 0 deletions

View File

@ -62,6 +62,50 @@ nsresult nsTextWidget::QueryObject(const nsIID& aIID, void** aInstancePtr)
return result;
}
// -----------------------------------------------------------------------
//
// Subclass (or remove the subclass from) this component's nsWindow
// this is need for filtering out the "ding" when the return key is pressed
//
// -----------------------------------------------------------------------
void nsTextWidget::SubclassWindow(BOOL bState)
{
NS_PRECONDITION(::IsWindow(mWnd), "Invalid window handle");
if (bState) {
// change the nsWindow proc
mPrevWndProc = (WNDPROC)::SetWindowLong(mWnd, GWL_WNDPROC,
(LONG)nsTextWidget::TextWindowProc);
NS_ASSERTION(mPrevWndProc, "Null standard window procedure");
// connect the this pointer to the nsWindow handle
::SetWindowLong(mWnd, GWL_USERDATA, (LONG)this);
}
else {
(void) ::SetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
mPrevWndProc = NULL;
}
}
//-------------------------------------------------------------------------
//
// the nsTextWidget procedure for all nsTextWidget in this toolkit
// this is need for filtering out the "ding" when the return key is pressed
//
//-------------------------------------------------------------------------
LRESULT CALLBACK nsTextWidget::TextWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
// Filters the "ding" when hitting the return key
if (msg == WM_CHAR) {
long chCharCode = (TCHAR) wParam; // character code
if (chCharCode == 13 || chCharCode == 9) {
return 0L;
}
}
return nsWindow::WindowProc(hWnd, msg, wParam, lParam);
}
//-------------------------------------------------------------------------
//
// move, paint, resizes message - ignore

View File

@ -46,6 +46,8 @@ public:
virtual PRBool OnResize(nsRect &aWindowRect);
virtual void GetBounds(nsRect &aRect);
virtual void SubclassWindow(BOOL bState);
// nsIWidget interface
BASE_IWIDGET_IMPL
@ -53,6 +55,12 @@ protected:
virtual LPCTSTR WindowClass();
virtual DWORD WindowStyle();
virtual DWORD WindowExStyle();
static LRESULT CALLBACK TextWindowProc(HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam);
};
#endif // nsTextWidget_h__