Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtIconEditDlg bug Collapse All
Subject Author Date
Hans Bergmeister Aug 9, 2007 - 8:28 AM

Hello,

we just found a bug in CExtIconEditDlg. It can be easily reproduced with the IconEditor sample:

1. Build and start the IconEditor sample.
2. Double click the first icon in the list - this will open the CExtIconEditDlg window.
3. Call "Cut" in the toolbox.
4. Call "Paste".

The image is not pasted correctly.

Hans Bergmeister May 19, 2008 - 8:19 AM

Hello,


 


did you find a resolution for this bug in the meantime? We can easily reproduce this problem on other computers, too. We are even able to produce "blue screens" here by copying and pasting an image into itself with your IconEditor sample code.


Thus this more and more turns out to be a severe problem!


 


 


 


 

Technical Support May 19, 2008 - 1:24 PM

The really strange thing is that the crashes or incorrect pasted images can appear on some ATI cards only. It looks like the following version of the CExtImageEditWnd::IedCopyToClipboard() and CExtImageEditWnd::IedCutToClipboard() methods solves the problem:

bool CExtImageEditWnd::IedCopyToClipboard(
 bool bSelectionOnly // = false
 ) const
{
 ASSERT_VALID( this );
 if( !IedCanCopy( bSelectionOnly ) )
  return false;
HBITMAP hBitmap = IedSelectionGetHBITMAP();
 if( hBitmap == NULL )
 {
  ASSERT( FALSE );
  return false;
 }
 if( ! ::OpenClipboard( GetSafeHwnd() ) )
 {
  ASSERT( FALSE );
  return false;
 }
 if( ! ::EmptyClipboard() )
 {
  ASSERT( FALSE );
  VERIFY( ::CloseClipboard() );
  return false;
 }
 ::GdiFlush();
HGLOBAL hGlobal =
  CExtBitmap::stat_HBITMAPtoHGLOBAL(
   hBitmap
   );
 if( hGlobal == NULL )
 {
  ASSERT( FALSE );
  VERIFY( ::CloseClipboard() );
  return false;
 }
 ::SetClipboardData( CF_DIB, hGlobal );
 ::SetClipboardData( CF_BITMAP, (HGLOBAL)CExtBitmap::stat_CloneBitmap( hBitmap ) );
 VERIFY( ::CloseClipboard() );
 return true;
}

bool CExtImageEditWnd::IedCutToClipboard(
 bool bSelectionOnly, // = false
 bool bRedrawWnd // = true
 )
{
 if( !IedCanCut( bSelectionOnly ) )
  return false;
HBITMAP hBitmap = IedSelectionGetHBITMAP();
 if( hBitmap == NULL )
 {
  ASSERT( FALSE );
  return false;
 }
 if( ! ::OpenClipboard( GetSafeHwnd() ) )
 {
  ASSERT( FALSE );
  return false;
 }
 if( ! ::EmptyClipboard() )
 {
  ASSERT( FALSE );
  VERIFY( ::CloseClipboard() );
  return false;
 }
 ::GdiFlush();
HGLOBAL hGlobal =
  CExtBitmap::stat_HBITMAPtoHGLOBAL( hBitmap );
 if( hGlobal == NULL )
 {
  ASSERT( FALSE );
  VERIFY( ::CloseClipboard() );
  return false;
 }
 ::SetClipboardData( CF_DIB, hGlobal );
 ::SetClipboardData( CF_BITMAP, (HGLOBAL)CExtBitmap::stat_CloneBitmap( hBitmap ) );
 VERIFY( ::CloseClipboard() );

CRect rcSelection = m_arrImgEditData[m_nUndoPos]->m_rcSelection;
 if( rcSelection.IsRectEmpty() )
 {
  rcSelection = CRect( CPoint(0,0), IedSizeGet() );
  ASSERT( !rcSelection.IsRectEmpty() );
  IedPushUndo( __EUT_IMAGE_CUT );
 } // if( rcSelection.IsRectEmpty() )
 else
  IedPushUndo( __EUT_SELECTION_CUT );

 _EmptyCache();
 { // BLOCK: surface DC
  CSurfaceDC dc( m_arrImgEditData[m_nUndoPos]->GetBmpSurface() );
  dc.FillSolidRect( &rcSelection, IedColorBackgroundGet() );
 } // BLOCK: surface DC

 IedUndo( 0 );
 
 if( bRedrawWnd )
 {
  if( (IedGetStyle() & __EIEDWS_OUTER_TOOLS) == 0 )
  {
   rcSelection = OnIedPicToClient( rcSelection, false );
   rcSelection.InflateRect( OnIedMeasureToolSize() );
   rcSelection.InflateRect( 2, 2 );
   InvalidateRect( &rcSelection );
  } // if( (IedGetStyle() & __EIEDWS_OUTER_TOOLS) == 0 )
  else
   Invalidate();
  UpdateWindow();
 } // if( bRedrawWnd )
 return true;
}


Hans Bergmeister May 20, 2008 - 9:01 AM

Hello,


 


yes, the fix seems to help - at least on our computer, where we encountered this problem. Many thanks for taking care.


 

Technical Support Aug 9, 2007 - 12:06 PM

We confirm this may happen in some particular situations:

1) You have copied one image and paste it into another. Both images are palette based and have different palettes.
2) You are copying/pasting on a desktop with video mode less than 24/32 bit.
3) You copied 24/32 bit image and paste it into a low color image.

The same occurs in MSPAINT.EXE (Paint Brush bitmap editor provided with any Windows OS version).

Hans Bergmeister Aug 9, 2007 - 12:37 PM

Hello,

I am afraid, that none of the three conditions applies. Did you really try this scenario? It is my impression, that you responded without trying it yourself.

1.
I call cut and paste directly after another, without anything between. Thus I copy the image and paste it into the SAME image with the SAME palette.

2.
The video mode, where this occurs is 32 bit.

3.
Since I don’t do anything between cut and paste, the format of the image remains unchanged.

The same does NOT occur in MSPAINT.EXE. Try the scenario yourself, please, with both, your editor and MSPAINT and you will see, that this is a clear bug in Prof-UIS, nothing else.

Technical Support Aug 10, 2007 - 10:43 AM

Thank you for reporting the problem. We successfully reproduced the problem on one of our computers. Here are the results of testing.

Computer 1. Windows XP SP2, NVIDIA GeForce 7300GT. Works OK
Computer 2. Windows Vista, NVIDIA GeForce 7300GT. Works OK
Computer 3. Windows XP SP2, Gigabyte RADEON X600PRO. Bug is confirmed

We will debug the problem on the third computer. Could you tell us what video adapter you are using?

Hans Bergmeister Aug 10, 2007 - 10:49 AM

Hello,

I am happy, that you were able now to reproduce the bug.

Here the bug occurs on Windows XP SP2, NVIDIA Quadro NVS 285, 2 x with two DVI monitors connected.