Native window decorations: when resizing a window to the right or to the bottom, then first fill the new space with the window background color (instead of black) before the layout is updated (issue #339)

This commit is contained in:
Karl Tauber
2021-07-31 18:02:10 +02:00
parent d3e39a1359
commit 4ab90065dc
7 changed files with 108 additions and 6 deletions

View File

@@ -52,6 +52,13 @@ JNIEXPORT void JNICALL Java_com_formdev_flatlaf_ui_FlatWindowsNativeWindowBorder
FlatWndProc::updateFrame( reinterpret_cast<HWND>( hwnd ), state );
}
extern "C"
JNIEXPORT void JNICALL Java_com_formdev_flatlaf_ui_FlatWindowsNativeWindowBorder_00024WndProc_setWindowBackground
( JNIEnv* env, jobject obj, jlong hwnd, jint r, jint g, jint b )
{
FlatWndProc::setWindowBackground( reinterpret_cast<HWND>( hwnd ), r, g, b );
}
extern "C"
JNIEXPORT void JNICALL Java_com_formdev_flatlaf_ui_FlatWindowsNativeWindowBorder_00024WndProc_showWindow
( JNIEnv* env, jobject obj, jlong hwnd, jint cmd )
@@ -174,6 +181,17 @@ void FlatWndProc::updateFrame( HWND hwnd, int state ) {
fwp->wmSizeWParam = -1;
}
void FlatWndProc::setWindowBackground( HWND hwnd, int r, int g, int b ) {
// delete old background brush
HBRUSH oldBrush = (HBRUSH) ::GetClassLongPtr( hwnd, GCLP_HBRBACKGROUND );
if( oldBrush != NULL )
::DeleteObject( oldBrush );
// create new background brush
HBRUSH brush = ::CreateSolidBrush( RGB( r, g, b ) );
::SetClassLongPtr( hwnd, GCLP_HBRBACKGROUND, (LONG_PTR) brush );
}
LRESULT CALLBACK FlatWndProc::StaticWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
FlatWndProc* fwp = (FlatWndProc*) hwndMap->get( hwnd );
if( fwp == NULL )