@@ -1521,30 +1521,32 @@ LRESULT WM_PAINT (long wParam, long lParam) {
1521
1521
RECT prcTarget = new RECT ();
1522
1522
OS .SetRect (prcTarget , ps .left , ps .top , ps .right , ps .bottom );
1523
1523
long hBufferedPaint = OS .BeginBufferedPaint (hDC , prcTarget , flags , null , phdc );
1524
- GCData data = new GCData ();
1525
- data .device = display ;
1526
- data .foreground = getForegroundPixel ();
1527
- Control control = findBackgroundControl ();
1528
- if (control == null ) control = this ;
1529
- data .background = control .getBackgroundPixel ();
1530
- data .font = Font .win32_new (display , OS .SendMessage (handle , OS .WM_GETFONT , 0 , 0 ), nativeZoom );
1531
- data .uiState = (int )OS .SendMessage (handle , OS .WM_QUERYUISTATE , 0 , 0 );
1532
- if ((style & SWT .NO_BACKGROUND ) != 0 ) {
1533
- /* This code is intentionally commented because it may be slow to copy bits from the screen */
1534
- //paintGC.copyArea (image, ps.left, ps.top);
1535
- } else {
1536
- RECT rect = new RECT ();
1537
- OS .SetRect (rect , ps .left , ps .top , ps .right , ps .bottom );
1538
- drawBackground (phdc [0 ], rect );
1524
+ if (hBufferedPaint != 0 && phdc [0 ] != 0 ) {
1525
+ GCData data = new GCData ();
1526
+ data .device = display ;
1527
+ data .foreground = getForegroundPixel ();
1528
+ Control control = findBackgroundControl ();
1529
+ if (control == null ) control = this ;
1530
+ data .background = control .getBackgroundPixel ();
1531
+ data .font = Font .win32_new (display , OS .SendMessage (handle , OS .WM_GETFONT , 0 , 0 ), nativeZoom );
1532
+ data .uiState = (int )OS .SendMessage (handle , OS .WM_QUERYUISTATE , 0 , 0 );
1533
+ if ((style & SWT .NO_BACKGROUND ) != 0 ) {
1534
+ /* This code is intentionally commented because it may be slow to copy bits from the screen */
1535
+ //paintGC.copyArea (image, ps.left, ps.top);
1536
+ } else {
1537
+ RECT rect = new RECT ();
1538
+ OS .SetRect (rect , ps .left , ps .top , ps .right , ps .bottom );
1539
+ drawBackground (phdc [0 ], rect );
1540
+ }
1541
+ GC gc = createNewGC (phdc [0 ], data );
1542
+ Event event = new Event ();
1543
+ event .gc = gc ;
1544
+ event .setBounds (DPIUtil .scaleDown (new Rectangle (ps .left , ps .top , width , height ), getZoom ()));
1545
+ sendEvent (SWT .Paint , event );
1546
+ if (data .focusDrawn && !isDisposed ()) updateUIState ();
1547
+ gc .dispose ();
1548
+ OS .EndBufferedPaint (hBufferedPaint , true );
1539
1549
}
1540
- GC gc = createNewGC (phdc [0 ], data );
1541
- Event event = new Event ();
1542
- event .gc = gc ;
1543
- event .setBounds (DPIUtil .scaleDown (new Rectangle (ps .left , ps .top , width , height ), getZoom ()));
1544
- sendEvent (SWT .Paint , event );
1545
- if (data .focusDrawn && !isDisposed ()) updateUIState ();
1546
- gc .dispose ();
1547
- OS .EndBufferedPaint (hBufferedPaint , true );
1548
1550
}
1549
1551
OS .EndPaint (handle , ps );
1550
1552
} else {
0 commit comments