mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
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:
parent
ffa3eb84e6
commit
086bb72002
@ -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
|
||||
|
@ -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__
|
||||
|
Loading…
Reference in New Issue
Block a user