/* * IEUpdateDDEEditSession */ BOOL IEUpdateDDEEditSession( void ) { img_node *node; HDDEDATA hdata; BOOL ok; hdata = (HDDEDATA)NULL; node = IEGetCurrentImageNode(); ok = (IEClientConv != (HCONV)NULL && node != NULL && EditFormat != DDENone); if( ok ) { hdata = IECreateResData( node ); ok = (hdata != (HDDEDATA)NULL); } if( ok ) { ok = DdeClientTransaction( (LPBYTE)hdata, -1, IEClientConv, hDataItem, IEClipFormats[EditFormat].format, XTYP_POKE, TIME_OUT, NULL ) != 0; } if( hdata != (HDDEDATA)NULL ) { DdeFreeDataHandle( hdata ); } if( ok ) { SetIsSaved( node->hwnd, TRUE ); } return( ok ); } /* IEUpdateDDEEditSession */
/* * saveBitmapFile - gets the bitmap data and saves it in fname. */ static bool saveBitmapFile( img_node *node ) { BITMAPARRAYFILEHEADER2 new_file; BITMAPINFO2 *bmi; long clrtable_size; RGB2 *colours; FILE *fp; char text[ HINT_TEXT_LEN ]; char filename[ _MAX_FNAME ]; bool ok; ok = false; bmi = GetXorBitmapInfo(node); if( bmi != NULL ) { clrtable_size = sizeof( RGB2 ) * ( 1 << ( node->bitcount ) ); new_file.usType = BFT_BITMAPARRAY; new_file.cbSize = sizeof( BITMAPARRAYFILEHEADER2 ); new_file.offNext = 0; new_file.cxDisplay = 0; new_file.cyDisplay = 0; new_file.bfh2.usType = BFT_BMAP; new_file.bfh2.cbSize = sizeof( BITMAPFILEHEADER2 ); new_file.bfh2.xHotspot = 0; new_file.bfh2.yHotspot = 0; new_file.bfh2.offBits = new_file.cbSize + clrtable_size; memcpy( &(new_file.bfh2.bmp2), bmi, sizeof( BITMAPINFOHEADER2 ) ); colours = (void *)&(bmi->argbColor[0]); fp = fopen( node->fname, "wb" ); if( fp != NULL ) { if( fseek( fp, 0L, SEEK_SET ) == 0 ) { if( fwrite( &new_file, sizeof( BITMAPARRAYFILEHEADER2 ), 1, fp ) == 1 ) { if( fwrite( colours, clrtable_size, 1, fp ) == 1 ) { if( writeDataInPieces( bmi, fp, node ) ) { ok = true; } else { MessageBox( HMainWindow, "Error writing file!", "Error", MB_OK | MB_ICONEXCLAMATION ); SetHintText( "Error saving file" ); } } } } fclose( fp ); } FreeDIBitmapInfo( bmi ); if( ok ) { AllowRestoreOption( node ); SetIsSaved( node->hwnd, TRUE ); GetFnameFromPath( node->fname, filename ); sprintf( text, "Bitmap saved to '%s'", filename ); SetHintText( text ); } } return( ok ); } /* saveBitmapFile */
/* * lastChanceSave - is called when the user quits and the current image * is not yet saved. Returns FALSE if CANCEL * is selected, otherwise, it returns TRUE. */ static BOOL lastChanceSave( img_node *node ) { int retcode; int how; HMENU hmenu; char *title; char *text; char *msg_text; char filename[ _MAX_PATH ]; if( !node ) return( TRUE ); IECheckIfActiveWindow(); if( strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) != 0 ) { GetFnameFromPath( node->fname, filename ); how = SB_SAVE; } else { strcpy( filename, node->fname ); how = SB_SAVE_AS; } retcode = IDCANCEL; title = IEAllocRCString( WIE_EXITTITLE ); if( ImgedIsDDE ) { text = IEAllocRCString( WIE_QUERYIMAGEUPDATE ); } else { text = IEAllocRCString( WIE_QUERYIMAGESAVE ); } if( text ) { msg_text = (char *)MemAlloc( strlen( text ) + strlen( filename ) + 1 ); if( msg_text ) { sprintf( msg_text, text, filename ); retcode = _wpi_messagebox( HMainWindow, msg_text, title, MB_YESNOCANCEL | MB_ICONQUESTION ); MemFree( msg_text ); } IEFreeRCString( text ); } if( title ) { IEFreeRCString( title ); } if (retcode == IDYES) { if( ImgedIsDDE ) { #ifndef __OS2_PM__ if( IEUpdateDDEEditSession() ) { SetIsSaved( node->hwnd, TRUE ); } else { PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); } #else PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); #endif } else { if (!SaveFile( how )) { PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); } else { hmenu = _wpi_getmenu( HMainWindow ); _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE ); SetIsSaved( node->hwnd, TRUE ); } } } else if (retcode == IDCANCEL) { return (FALSE); } return (TRUE); } /* lastChanceSave */
/* * ChangeImageSize - changes the size of the current image being edited */ void ChangeImageSize( void ) { img_node *node; WPI_DLGPROC dlgproc; WPI_DLGRESULT button_type; img_node new_node; WPI_PRES pres; HDC srcdc; WPI_PRES srcpres; HDC destdc; WPI_PRES destpres; HBITMAP oldsrc; HBITMAP olddest; int retcode; WPI_PARAM2 lparam; WPI_RECT rc; short new_width; short new_height; int y_src; int y_dest; char *title; char *text; node = GetCurrentNode(); if( node == NULL ) { return; } if( node->imgtype != BITMAP_IMG ) { return; } imgHeight = node->height; imgWidth = node->width; dlgproc = _wpi_makedlgprocinstance( ChangeSizeDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, IMAGESIZE, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { return; } if( imgWidth == node->width && imgHeight == node->height ) { PrintHintTextByID( WIE_IMAGESIZEUNCHANGED, NULL ); return; } title = IEAllocRCString( WIE_INFORMATIONTEXT ); text = IEAllocRCString( WIE_RESETUNDOSTACKWARNING ); retcode = _wpi_messagebox( HMainWindow, text, title, MB_YESNO | MB_ICONINFORMATION ); if( text != NULL ) { IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } if( retcode == WPI_IDNO ) { return; } new_node.width = (short)imgWidth; new_node.height = (short)imgHeight; new_node.bitcount = node->bitcount; new_node.imgtype = BITMAP_IMG; MakeBitmap( &new_node, TRUE ); pres = _wpi_getpres( HWND_DESKTOP ); srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc ); destpres = _wpi_createcompatiblepres( pres, Instance, &destdc ); _wpi_releasepres( HWND_DESKTOP, pres ); oldsrc = _wpi_selectbitmap( srcpres, node->hxorbitmap ); olddest = _wpi_selectbitmap( destpres, new_node.hxorbitmap ); if( stretchImage ) { _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight, srcpres, 0, 0, node->width, node->height, SRCCOPY ); } else { #ifdef __OS2_PM__ y_src = node->height - imgHeight; if( y_src < 0 ) { y_src = 0; y_dest = imgHeight - node->height; } else { y_dest = 0; } #else y_src = 0; y_dest = 0; #endif _wpi_bitblt( destpres, 0, y_dest, node->width, node->height, srcpres, 0, y_src, SRCCOPY ); } _wpi_getoldbitmap( srcpres, oldsrc ); oldsrc = _wpi_selectbitmap( srcpres, node->handbitmap ); _wpi_getoldbitmap( destpres, olddest ); olddest = _wpi_selectbitmap( destpres, new_node.handbitmap ); if( stretchImage ) { _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight, srcpres, 0, 0, node->width, node->height, SRCCOPY ); } else { _wpi_bitblt( destpres, 0, 0, node->width, node->height, srcpres, 0, 0, SRCCOPY ); } _wpi_getoldbitmap( srcpres, oldsrc ); _wpi_getoldbitmap( destpres, olddest ); _wpi_deletebitmap( node->hxorbitmap ); _wpi_deletebitmap( node->handbitmap ); _wpi_deletecompatiblepres( srcpres, srcdc ); _wpi_deletecompatiblepres( destpres, destdc ); node->hxorbitmap = new_node.hxorbitmap; node->handbitmap = new_node.handbitmap; node->width = (short)imgWidth; node->height = (short)imgHeight; SetIsSaved( node->hwnd, FALSE ); ResetUndoStack( node ); RePositionViewWnd( node ); _wpi_getclientrect( node->hwnd, &rc ); new_width = (short)_wpi_getwidthrect( rc ); new_height = (short)_wpi_getheightrect( rc ); lparam = WPI_MAKEP2( new_width, new_height ); ResizeChild( lparam, node->hwnd, false ); DisplayImageText( node ); WriteSetSizeText( WIE_NEWIMAGESIZE, imgWidth, imgHeight ); } /* ChangeImageSize */
/* * lastChanceSave - called when the user quits and the current image * is not yet saved * - return FALSE if CANCEL is selected * - otherwise, it return TRUE */ static BOOL lastChanceSave( HWND hwnd ) { int retcode; int how; HMENU hmenu; img_node *node; img_node *icon; char *title; char *text; char *msg_text; char filename[_MAX_PATH]; if( !DoImagesExist() ) { return( TRUE ); } node = SelectImage( hwnd ); if( node == NULL ) { return( TRUE ); } icon = GetImageNode( hwnd ); while( icon != NULL ) { if( icon->issaved ) { return( TRUE ); } icon = icon->nexticon; } if( strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) != 0 ) { GetFnameFromPath( node->fname, filename ); how = SB_SAVE; } else { strcpy( filename, node->fname ); how = SB_SAVE_AS; } retcode = WPI_IDCANCEL; title = IEAllocRCString( WIE_CLOSETITLE ); text = IEAllocRCString( WIE_QUERYIMAGESAVE ); if( text != NULL ) { msg_text = (char *)MemAlloc( strlen( text ) + strlen( filename ) + 1 ); if( msg_text != NULL ) { sprintf( msg_text, text, filename ); retcode = _wpi_messagebox( HMainWindow, msg_text, title, MB_YESNOCANCEL | MB_ICONQUESTION ); MemFree( msg_text ); } IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } if( retcode == WPI_IDYES ) { if( !SaveFile( how ) ) { PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); } else { hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) ); _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE ); SetIsSaved( hwnd, TRUE ); } } else if( retcode == WPI_IDCANCEL ) { return( FALSE ); } return( TRUE ); } /* lastChanceSave */
/* * DrawAreaWinProc - window procedure for the drawing area window * - this window is an MDI window */ MRESULT CALLBACK DrawAreaWinProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { static WPI_POINT start_pt = { -1, -1 }; static WPI_POINT end_pt = { -1, -1 }; static WPI_POINT prev_pt = { -1, -1 }; static WPI_POINT new_pt = { -1, -1 }; static WPI_POINT pt1; static BOOL flbuttondown = FALSE; static BOOL frbuttondown = FALSE; static BOOL fdraw_shape = FALSE; static BOOL firsttime; static BOOL wasicon; int mousebutton; WPI_POINT pointsize; WPI_POINT pt2; #ifndef __OS2_PM__ CREATESTRUCT *cs; MDICREATESTRUCT *mdi_cs; MINMAXINFO *minmax; #endif img_node *node; int i; switch ( msg ) { case WM_CREATE: #ifndef __OS2_PM__ cs = (CREATESTRUCT __FAR *)lparam; mdi_cs = (MDICREATESTRUCT __FAR *)cs->lpCreateParams; node = (img_node *)mdi_cs->lParam; for( i = 0; i < node->num_of_images; i++ ) { node[i].hwnd = hwnd; } AddImageNode( node ); CreateUndoStack( node ); setTheCursor( -1, hwnd ); wasicon = FALSE; #endif firsttime = TRUE; i = i; return( 0 ); case WM_MDIACTIVATE: if( IMGED_GET_MDI_FACTIVATE( hwnd, wparam, lparam ) ) { if( _wpi_isiconic( hwnd ) ) { wasicon = TRUE; break; } else { wasicon = FALSE; FocusOnImage( hwnd ); } } return( 0 ); #ifndef __OS2_PM__ case WM_GETMINMAXINFO: node = SelectImage( hwnd ); if( node != NULL ) { minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = node->width + 2 * _wpi_getsystemmetrics( SM_CXFRAME ); minmax->ptMinTrackSize.y = node->height + 2 * _wpi_getsystemmetrics( SM_CYFRAME ) + _wpi_getsystemmetrics( SM_CYCAPTION ) - 1; } break; #endif case UM_SHOWVIEWWINDOW: ShowViewWindows( hwnd ); return 0; case WM_SIZE: if ( _imgwpi_issizerestored( wparam ) ) { ResizeChild( lparam, hwnd, firsttime ); firsttime = FALSE; if( wasicon ) { FocusOnImage( hwnd ); wasicon = FALSE; } #ifndef __OS2_PM__ } else if ( _imgwpi_issizeminimized( wparam ) ) { node = SelectImage( hwnd ); HideViewWindow( hwnd ); DeleteActiveImage(); ClearImageText(); SendMessage( ClientWindow, WM_MDINEXT, (WPARAM)(LPVOID)hwnd, 0L ); wasicon = TRUE; #endif } return( 0 ); #ifndef __OS2_PM__ case WM_CHAR: pointsize = GetPointSize( hwnd ); if( LOWORD( wparam ) == ESC_CHAR ) { if( !(lparam & 0x40000000) ) { switch( toolType ) { case IMGED_PASTE: fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; DontPaste( hwnd, &pt1, pointsize ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( !flbuttondown && !frbuttondown ) { break; } fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); SetRectExists( FALSE ); } else { OutlineRegion( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } break; default: break; } } } return( 0 ); #endif case WM_MOUSEMOVE: pointsize = GetPointSize( hwnd ); #ifdef __OS2_PM__ WinSetPointer( HWND_DESKTOP, hCursor[cursorIndex] ); #endif IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ OutlineSnap(); #endif break; case IMGED_PASTE: pt1.x = new_pt.x / pointsize.x; pt1.y = new_pt.y / pointsize.y; pt2.x = prev_pt.x / pointsize.x; pt2.y = prev_pt.y / pointsize.y; if( pt1.x != pt2.x || pt1.y != pt2.y ) { DragClipBitmap( hwnd, &pt1, pointsize ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, LMOUSEBUTTON ); } else if( frbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, RMOUSEBUTTON ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( flbuttondown || frbuttondown ) { if( new_pt.x / pointsize.x != end_pt.x / pointsize.x || new_pt.y / pointsize.y != end_pt.y / pointsize.y ) { if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else { OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } end_pt = new_pt; SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize ); } } else { SetPosInStatus( &new_pt, &pointsize, hwnd ); } break; case IMGED_FILL: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; default: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; } prev_pt = new_pt; return( 0 ); case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: pointsize = GetPointSize( hwnd ); SetCapture( hwnd ); if( msg == WM_LBUTTONDOWN ) { if( frbuttondown ) { break; } #ifdef __OS2_PM__ node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } #endif flbuttondown = TRUE; mousebutton = LMOUSEBUTTON; } else { if( flbuttondown ) { break; } node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } frbuttondown = TRUE; mousebutton = RMOUSEBUTTON; } fdraw_shape = TRUE; IMGED_MAKEPOINT( wparam, lparam, start_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ TransferImage( hwnd ); #endif fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: BeginFreeHand( hwnd ); DrawSinglePoint( hwnd, &start_pt, mousebutton ); break; case IMGED_LINE: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_CLIP: IMGED_MAKEPOINT( wparam, lparam, end_pt ); RedrawPrevClip( hwnd ); OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_FILL: FillArea( &start_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_HOTSPOT: SetIsSaved( hwnd, FALSE ); prev_pt.x = start_pt.x / pointsize.x; prev_pt.y = start_pt.y / pointsize.y; SetNewHotSpot( &prev_pt ); break; default: break; } prev_pt = new_pt; return 0; case WM_LBUTTONUP: case WM_RBUTTONUP: pointsize = GetPointSize( hwnd ); IMGED_MAKEPOINT( wparam, lparam, end_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); if( msg == WM_LBUTTONUP ) { mousebutton = LMOUSEBUTTON; } else { mousebutton = RMOUSEBUTTON; } if( fdraw_shape ) { switch( toolType ) { case IMGED_PASTE: PasteImage( &start_pt, pointsize, hwnd ); flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown || frbuttondown ) { EndFreeHand( hwnd ); RecordImage( hwnd ); } break; case IMGED_LINE: DrawLine( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: DisplayRegion( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_CLIP: SetClipRect( hwnd, &start_pt, &end_pt, pointsize ); break; default: break; } fdraw_shape = FALSE; } ReleaseCapture(); flbuttondown = FALSE; frbuttondown = FALSE; prev_pt = new_pt; return( 0 ); case WM_PAINT: RepaintDrawArea( hwnd ); return( 0 ); case WM_QUERYENDSESSION: case WM_CLOSE: if( lastChanceSave( hwnd ) ) { CloseCurrentImage( hwnd ); return( (MRESULT)1 ); } else { return( (MRESULT)0 ); } #ifndef __OS2_PM__ case WM_DESTROY: SetCursor( LoadCursor( NULL, IDC_ARROW ) ); return( 0 ); #endif default: break; } return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) ); } /* DrawAreaWinProc */
/* * saveImageFile - saves a cursor or icon file */ static bool saveImageFile( img_node *node ) { BITMAPARRAYFILEHEADER2 new_file; BITMAPFILEHEADER2 *and_part; BITMAPFILEHEADER2 *xor_part; BITMAPINFO2 *andbmi; BITMAPINFO2 *xorbmi; long clrtable_size; long and_size; ULONG nextoff; RGB2 *colours; FILE *fp; char text[ HINT_TEXT_LEN ]; char filename[ _MAX_FNAME ]; img_node *new_image; bool ok; ok = false; fp = fopen( node->fname, "wb" ); if( fp != NULL ) { if( fseek( fp, 0L, SEEK_SET ) == 0 ) { ok = true; nextoff = 0; for( new_image = node; new_image != NULL; new_image = new_image->nexticon ) { new_file.usType = BFT_BITMAPARRAY; new_file.cbSize = sizeof( BITMAPARRAYFILEHEADER2 ); new_file.offNext = nextoff; new_file.cxDisplay = 0; new_file.cyDisplay = 0; and_part = fillFileHeader( new_image ); memcpy( &(new_file.bfh2), and_part, sizeof( BITMAPFILEHEADER2 ) ); /* * First the info for the AND mask */ andbmi = GetAndBitmapInfo( new_image ); if( andbmi == NULL ) { ok = false; } else { clrtable_size = sizeof( RGB2 ) * ( 1 << new_image->bitcount ); and_size = sizeof( RGB2 ) * 2; new_file.bfh2.offBits = new_file.offNext + new_file.cbSize + and_size + clrtable_size + sizeof( BITMAPFILEHEADER2 ); memcpy( &(new_file.bfh2.bmp2), andbmi, sizeof( BITMAPINFOHEADER2 ) ); colours = (void *)&(andbmi->argbColor[0]); if( fwrite( &new_file, sizeof( BITMAPARRAYFILEHEADER2 ), 1, fp ) != 1 ) { ok = false; } else if( fwrite( colours, and_size, 1, fp ) != 1 ) { ok = false; } FreeDIBitmapInfo( andbmi ); } MemFree( and_part ); if( ok ) { /* * Now we write the XOR part */ xor_part = fillFileHeader( new_image ); xorbmi = GetXorBitmapInfo( new_image ); if( xorbmi == NULL ) { ok = false; } else { xor_part->offBits = new_file.bfh2.offBits + BITS_TO_BYTES( new_image->width, 2 * new_image->height ); memcpy( &(xor_part->bmp2), xorbmi, sizeof( BITMAPINFOHEADER2 ) ); colours = (void *)&(xorbmi->argbColor[0]); if( fwrite( xor_part, sizeof( BITMAPFILEHEADER2 ), 1, fp ) != 1 ) { ok = false; } else if( fwrite( colours, clrtable_size, 1, fp ) != 1 ) { ok = false; } FreeDIBitmapInfo( xorbmi ); } MemFree( xor_part ); nextoff = nextoff + sizeof( BITMAPARRAYFILEHEADER2 ) + and_size + sizeof( BITMAPFILEHEADER2 ) + clrtable_size; } if( !rc ) { break; } } } fclose( fp ); } if( ok ) { /* * Now we write the bits for all the images in the file. */ if( !writeImageBits( fp, node ) ) { return( false ); } AllowRestoreOption( node ); SetIsSaved( node->hwnd, TRUE ); GetFnameFromPath( node->fname, filename ); if( node->imgtype == ICON_IMG ) { sprintf( text, "Icon saved to '%s'", filename ); } else { sprintf( text, "Pointer saved to '%s'", filename ); } SetHintText( text ); } return( ok ); } /* saveImageFile */