/* * Default window procedure * * Copyright 1993, 1996 Alexandre Julliard * Copyright 1995 Alex Korobka * Copyright 2022 Jacek Caban for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #if 0 #pragma makedep unix #endif #include "win32u_private.h" #include "ntuser_private.h" #include "wine/server.h" WINE_DEFAULT_DEBUG_CHANNEL(win); static BOOL set_window_text( HWND hwnd, const void *text, BOOL ansi ) { static const WCHAR emptyW[] = { 0 }; WCHAR *str; WND *win; /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP) * may have child window IDs instead of window name */ if (text && IS_INTRESOURCE(text)) return FALSE; if (text) { if (ansi) str = towstr( text ); else str = wcsdup( text ); if (!str) return FALSE; } else str = NULL; TRACE( "%s\n", debugstr_w(str) ); if (!(win = get_win_ptr( hwnd ))) { free( str ); return FALSE; } free( win->text ); win->text = str; SERVER_START_REQ( set_window_text ) { req->handle = wine_server_user_handle( hwnd ); if (str) wine_server_add_data( req, str, lstrlenW( str ) * sizeof(WCHAR) ); wine_server_call( req ); } SERVER_END_REQ; release_win_ptr( win ); user_driver->pSetWindowText( hwnd, str ? str : emptyW ); return TRUE; } LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi ) { LRESULT result = 0; switch (msg) { case WM_NCCREATE: if (lparam) { CREATESTRUCTW *cs = (CREATESTRUCTW *)lparam; set_window_text( hwnd, cs->lpszName, ansi ); result = 1; } break; case WM_NCDESTROY: { WND *win = get_win_ptr( hwnd ); if (!win) return 0; free( win->text ); win->text = NULL; if (user_callbacks) user_callbacks->free_win_ptr( win ); win->pScroll = NULL; release_win_ptr( win ); return 0; } case WM_SETTEXT: result = set_window_text( hwnd, (void *)lparam, ansi ); break; } return result; }