Exemple #1
0
/*
 * CloseCurrentImage - Gets the current image the user is editing and deletes
 *                     the node from the linked list and sends a message to
 *                     destroy the mdi child (this will activate another
 *                     child then).
 */
void CloseCurrentImage( HWND hwnd )
{
    img_node    *node;
    char        file_name[ _MAX_PATH ];
    BOOL        ret;

    node = SelectImage( hwnd );
    if (!node) return;
    ret = DestroyWindow( _wpi_getframe(node->viewhwnd) );
    GetFnameFromPath( node->fname, file_name );
    DeleteUndoStack( hwnd );
    if ( !DeleteNode(hwnd) ) {
        WImgEditError( WIE_ERR_BAD_HWND, WIE_INTERNAL_002 );
        return;
    }
    DeleteActiveImage();
    ClearImageText();

    GrayEditOptions();
    PrintHintTextByID( WIE_FILEHASBEENCLOSED, file_name );
    SetWindowText( _wpi_getframe(HMainWindow), IEAppTitle );

#ifdef __OS2_PM__
    ret = DestroyWindow( _wpi_getframe(hwnd) );
#else
    SendMessage(ClientWindow, WM_MDIDESTROY, (WPARAM)hwnd, 0L);
#endif
} /* CloseCurrentImage */
Exemple #2
0
/*
 * CloseAllImages - used in the close all menu option
 */
void CloseAllImages( void )
{
    img_node    *head;
    img_node    *current;
    WPI_PARAM1  p1;
    HWND        parent;

    head = GetHeadNode();
    if( !head ) {
        PrintHintTextByID( WIE_NOIMAGESTOCLOSE, NULL );
        return;
    }

    current = head;
    while( current ) {
        if( !(current->issaved) ) {
            p1 = WPI_MAKEP1( current->hwnd, 0 );
            parent = _wpi_getparent( current->hwnd );
#ifdef __OS2_PM__
            _wpi_sendmessage(parent, WM_ACTIVATE, (WPI_PARAM1)p1, 0L);
#else
            _wpi_sendmessage( parent, WM_MDIRESTORE, (WPI_PARAM1)p1, 0L );
            _wpi_sendmessage(ClientWindow, WM_MDIACTIVATE, (WPI_PARAM1)p1, 0L);
#endif

            if( !(lastChanceSave(current)) ) {
                return;
            }
        }
        current = current->next;
    }

    DeleteActiveImage();
    while( head ) {
        closeTheImage( head );
        head = GetHeadNode();
    }

    ClearImageText();
    GrayEditOptions();
    PrintHintTextByID( WIE_ALLIMAGESCLOSED, NULL );
    _wpi_setwindowtext( _wpi_getframe(HMainWindow), IEAppTitle );
} /* CloseAllImages */
Exemple #3
0
/*
 * imgEditInit - initialization
 */
static BOOL imgEditInit( HANDLE currinst, HANDLE previnst, int cmdshow )
{
    WNDCLASS    wc;
    HMENU       menu;
    HDC         hdc;
    BOOL        maximized;
    int         show_state;

    hdc = GetDC( NULL );
    ColorPlanes = GetDeviceCaps( hdc, PLANES );
    BitsPerPixel = GetDeviceCaps( hdc, BITSPIXEL );
    ReleaseDC( NULL, hdc );

    Instance = currinst;
    IEInitErrors( currinst );
    IEInitGlobalStrings();

    if( ImgedIsDDE ) {
        menu = LoadMenu( Instance, "IMGEDDDEMENU" );
    } else {
        menu = LoadMenu( Instance, "IMGEDMENU" );
    }

    hBitmapIcon = LoadIcon( Instance, "BitmapIcon" );
    hIconIcon = LoadIcon( Instance, "IconIcon" );
    hCursorIcon = LoadIcon( Instance, "CursorIcon" );
    hAccel = LoadAccelerators( Instance, "Accelerators" );

    IECtl3dInit( Instance );

#if defined( __NT__ )
    hBkBrush = CreateSolidBrush( GetSysColor( COLOR_BTNFACE ) );
#endif

    /*
     * set up window class
     */
    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = ImgEdFrameProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = LoadIcon( Instance, "APPLICON" );
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = NULL;
        wc.lpszMenuName = NULL;
        wc.lpszClassName = className;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    /*
     * This is the child of the MDI frame window (of it's client window actually).
     */
    if( !previnst ) {
        wc.style = CS_BYTEALIGNWINDOW | CS_CLASSDC | CS_DBLCLKS;
        wc.lpfnWndProc = DrawAreaWinProc;
        wc.cbClsExtra = sizeof( HCURSOR );
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = hBitmapIcon;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = DrawAreaClassB;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = CS_BYTEALIGNWINDOW | CS_CLASSDC | CS_DBLCLKS;
        wc.lpfnWndProc = DrawAreaWinProc;
        wc.cbClsExtra = sizeof( HCURSOR );
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = hIconIcon;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = DrawAreaClassI;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = CS_BYTEALIGNWINDOW | CS_CLASSDC | CS_DBLCLKS;
        wc.lpfnWndProc = DrawAreaWinProc;
        wc.cbClsExtra = sizeof( HCURSOR );
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = hCursorIcon;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = DrawAreaClassC;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = ViewWindowProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = ViewWinClass;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = ColorPalWinProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = PaletteClass;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    handCursor = LoadCursor( Instance, "HandCursor" );
    if( !previnst ) {
        wc.style = CS_DBLCLKS;
        wc.lpfnWndProc = ColorsWndProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = handCursor;
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = "ColorsClass";
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = CS_DBLCLKS;
        wc.lpfnWndProc = ScreenWndProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = handCursor;
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = "ScreenClass";
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = CurrentWndProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = "CurrentClass";
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = BitmapPickProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = NULL;
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = BitmapPickClass;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    /*
     * Now make the main window.
     */
    LoadImgedConfig();
    maximized = ImgedConfigInfo.ismaximized;

    InitPalette();
    HMainWindow = CreateWindow(
        className,                              /* Window class name */
        IEAppTitle,                             /* Window caption */
        WS_OVERLAPPEDWINDOW | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
        | WS_DLGFRAME,                          /* Window style */
        ImgedConfigInfo.x_pos,                  /* Initial X position */
        ImgedConfigInfo.y_pos,                  /* Initial Y position */
        ImgedConfigInfo.width,                  /* Initial X size */
        ImgedConfigInfo.height,                 /* Initial Y size */
        (HWND)NULL,                             /* Parent window handle */
        (HMENU)menu,                            /* Window menu handle */
        Instance,                               /* Program instance handle */
        NULL );                                 /* Create parameters */

    if( HMainWindow == NULL ) {
        return( FALSE );
    }

    if( maximized ) {
        if( cmdshow == SW_SHOW || cmdshow == SW_SHOWNORMAL ) {
            show_state = SW_SHOWMAXIMIZED;
        } else {
            show_state = cmdshow;
        }
    } else {
        show_state = cmdshow;
    }
    ShowWindow( HMainWindow, show_state );
    UpdateWindow( HMainWindow );

    if( !ImgedIsDDE && !NoTitleScreen ) {
        DisplayTitleScreen( Instance, HMainWindow, 2000, IEAppTitle );
    }

    CreateColorPal();
    InitTools( HMainWindow );
    GrayEditOptions();

#ifdef __NT__
    DragAcceptFiles( HMainWindow, TRUE );
#endif
    //SetActiveWindow( HMainWindow );
    BringWindowToTop( HMainWindow );
    return( TRUE );

} /* imgEditInit */