/* * SelectDynamicBitmap - Lets the user select the bitmap from the screen. */ BOOL SelectDynamicBitmap( img_node *node, int imgcount, char *filename ) { HDC hdc; HDC memdc; HBITMAP oldbitmap; HWND bitmappickwindow; MSG msg; RECT screen_coords; if (IsZoomed(HMainWindow)) { prevState = SW_SHOWMAXIMIZED; } else { prevState = SW_SHOWNORMAL; } #ifdef __NT__ RegisterSnapClass(Instance); ShowWindow(HMainWindow, SW_SHOWMINIMIZED); ShowWindow(HMainWindow, SW_HIDE); deskTopWindow = DisplayDesktop( HMainWindow ); #else ShowWindow( HMainWindow, SW_SHOWMINIMIZED ); ShowWindow(HMainWindow, SW_HIDE); #endif bitmappickwindow = CreateWindow( BitmapPickClass, /* Window class name */ "", /* Window caption */ WS_CHILDWINDOW, /* Window style */ 0, /* Initial X position */ 0, /* Initial Y position */ 0, /* Initial X size */ 0, /* Initial Y size */ HMainWindow, /* Parent window handle */ (HMENU) NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ if( bitmappickwindow == NULL ) return FALSE; while(notDestroyed && GetMessage(&msg, bitmappickwindow, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (bmpRegion.right > bmpRegion.left) { screen_coords.left = bmpRegion.left; screen_coords.right = bmpRegion.right; } else { screen_coords.left = bmpRegion.right; screen_coords.right = bmpRegion.left; } if (bmpRegion.bottom > bmpRegion.top) { screen_coords.bottom = bmpRegion.bottom; screen_coords.top = bmpRegion.top; } else { screen_coords.bottom = bmpRegion.top; screen_coords.top = bmpRegion.bottom; } if ( (screen_coords.right - screen_coords.left == 0) || (screen_coords.bottom - screen_coords.top == 0) ) { ShowWindow( HMainWindow, prevState ); #ifdef __NT__ DestroyWindow( deskTopWindow ); #endif IEDisplayErrorMsg( WIE_APPNAME, WIE_INVALIDREGIONSELECTED, MB_OK | MB_ICONINFORMATION ); notDestroyed = TRUE; return(FALSE); } node->imgtype = BITMAP_IMG; node->width = (short)(screen_coords.right-screen_coords.left); node->height = (short)(screen_coords.bottom-screen_coords.top); node->bitcount = 4; // ????? node->hotspot.x = 0; node->hotspot.y = 0; node->num_of_images = 1; node->nexticon = NULL; node->issaved = FALSE; node->next = NULL; if( filename != NULL ) { strcpy( node->fname, filename ); } else { sprintf( node->fname, "%s (%d)", IEImageUntitled, imgcount ); } MakeBitmap( node, TRUE ); hdc = GetDC(NULL); memdc = CreateCompatibleDC( hdc ); oldbitmap = SelectObject( memdc, node->handbitmap ); PatBlt( memdc, 0, 0, node->width, node->height, BLACKNESS ); SelectObject( memdc, node->hxorbitmap ); BitBlt(memdc, 0, 0, node->width, node->height, hdc, screen_coords.left, screen_coords.top, SRCCOPY); ReleaseDC(NULL, hdc); SelectObject( memdc, oldbitmap ); DeleteDC( memdc ); ShowWindow( HMainWindow, prevState ); #ifdef __NT__ DestroyWindow( deskTopWindow ); #endif notDestroyed = TRUE; return(TRUE); } /* SelectDynamicBitmap */
/* * SnapPicture - minimize the image editor and prepare to snap the picture */ void SnapPicture( void ) { img_node *node; POINT pt; HWND hwnd; RECT cliprect; node = GetCurrentNode(); if( node == NULL ) { return; } firstTime = 2; GetCursorPos( &pt ); if( DoesRectExist( &cliprect ) ) { snapWidth = cliprect.right - cliprect.left; snapHeight = cliprect.bottom - cliprect.top; topLeft.x = cliprect.left; topLeft.y = cliprect.top; rectExists = TRUE; } else { snapWidth = node->width; snapHeight = node->height; topLeft.x = 0; topLeft.y = 0; rectExists = FALSE; } if( IsZoomed( HMainWindow ) ) { previousState = SW_SHOWMAXIMIZED; } else { previousState = SW_SHOWNORMAL; } snapWindow = node->hwnd; #ifdef __NT__ hwnd = hwnd; RegisterSnapClass( Instance ); ShowWindow( HMainWindow, SW_SHOWMINIMIZED ); ShowWindow( HMainWindow, SW_HIDE ); InvalidateRect( HWND_DESKTOP, NULL, TRUE ); // force the desktop window to be redrawn RedrawWindow( HWND_DESKTOP, NULL, NULL, RDW_ERASE | RDW_UPDATENOW | RDW_ERASENOW | RDW_ALLCHILDREN | RDW_INVALIDATE ); SetDeskTopHook( deskTopWindowHook ); deskTopWindow = DisplayDesktop( HMainWindow ); #else SetCapture( node->hwnd ); ShowWindow( HMainWindow, SW_SHOWMINIMIZED ); ShowWindow( HMainWindow, SW_HIDE ); hwnd = WindowFromPoint( pt ); #if 0 if( hwnd == GetDesktopWindow() ) { return; } #endif // this code makes sure that the window under the cursor is redrawn // Why? gets rid of the XOR turd RedrawWindow( hwnd, NULL, NULL, RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_INVALIDATE ); #endif prevToolType = SetToolType( IMGED_SNAP ); prevCursor = SetCursor( NULL ); #ifdef __NT__ SetCapture( node->hwnd ); #endif PostMessage( node->hwnd, WM_MOUSEMOVE, (WPARAM)0, MAKELPARAM( pt.x, pt.y ) ); Yield(); } /* SnapPicture */