// The window needs to be made visible once to set its WindowProc.
msgWindow.setVisible(true);
msgWindow.setVisible(false);
// Get a handle to the window.
HWND hwnd = new HWND();
hwnd.setPointer(Native.getWindowPointer(msgWindow));
// Set the WindowProc so that this instance receives window
// messages.
prevWndProc = User32.INSTANCE.SetWindowLong(hwnd,
User32.GWL_WNDPROC, this);