/* * spyInit - initialization */ static BOOL spyInit( HANDLE currinst, HANDLE previnst, int cmdshow ) { WNDCLASS wc; HANDLE memhdl; WORD i; i=i; memhdl = memhdl; /* shut up the compiler for non-NT version */ JDialogInit(); Instance = currinst; ResInstance = currinst; if( !InitGblStrings() ) { return( FALSE ); } SpyMenu = LoadMenu( ResInstance, "SPYMENU" ); #ifdef __WATCOMC__ _STACKLOW = 0; #endif MemStart(); HandleMessageInst = MakeProcInstance( (FARPROC) HandleMessage, Instance ); HintWndInit( Instance, NULL, 0 ); /* * set up window class */ if( !previnst ) { wc.style = 0L; wc.lpfnWndProc = SpyWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof( LONG_PTR ); wc.hInstance = Instance; wc.hIcon = LoadIcon( ResInstance, "APPLICON" ); wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW); #ifdef __NT__ wc.hbrBackground = NULL; #else wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); #endif wc.lpszMenuName = NULL; wc.lpszClassName = SPY_CLASS_NAME; if( !RegisterClass( &wc ) ) { return( FALSE ); } #ifdef USE_SNAP_WINDOW if( !RegisterSnapClass( Instance ) ) { return( FALSE ); } #endif } #ifndef NOUSE3D CvrCtl3DInit( Instance ); CvrCtl3dRegister( Instance ); CvrCtl3dAutoSubclass( Instance ); #endif /* * now make the main window */ LoadSpyConfig( NULL ); SpyMainWindow = CreateWindow( SPY_CLASS_NAME, /* Window class name */ SpyName, /* Window caption */ WS_OVERLAPPEDWINDOW, /* Window style */ SpyMainWndInfo.xpos, /* Initial x position */ SpyMainWndInfo.ypos, /* Initial y position */ SpyMainWndInfo.xsize, /* Initial x size */ SpyMainWndInfo.ysize, /* Initial y size */ (HWND)NULL, /* Parent window handle */ (HMENU)SpyMenu, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ if( SpyMainWindow == NULL ) { return( FALSE ); } MyTask = GetWindowTask( SpyMainWindow ); ShowWindow( SpyMainWindow, cmdshow ); UpdateWindow( SpyMainWindow ); InitMessages(); return( TRUE ); } /* spyInit */
/* * 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 */