Esempio n. 1
0
/*
 * IEDDEDumpConversation
 */
BOOL IEDDEDumpConversation( HINSTANCE inst )
{
    HCONV       hconv;
    HSZ         hservice;
    HSZ         htopic;
    BOOL        ok;

    ok = IEDDEStart( inst );

    if( ok ) {
        hservice = DdeCreateStringHandle( IdInst, WRE_SERVICE_NAME, CP_WINANSI );
        ok = (hservice != (HSZ)NULL);
    }

    if( ok ) {
        htopic = DdeCreateStringHandle( IdInst, WRE_IMAGE_DUMP, CP_WINANSI );
        ok = (htopic != (HSZ)NULL);
    }

    if( ok ) {
        // We expect the server to reject this connect attempt.
        // If it doesn't, then we terminate the conversation.
        hconv = DdeConnect( IdInst, hservice, htopic, (LPVOID)NULL );
        if( hconv != (HCONV)NULL ) {
            DdeDisconnect( hconv );
        }
    }

    if( hservice != (HSZ)NULL ) {
        DdeFreeStringHandle( IdInst, hservice );
    }

    if( htopic != (HSZ)NULL ) {
        DdeFreeStringHandle( IdInst, htopic );
    }

    IEDDEEnd();

    if( !ok ) {
        IEDisplayErrorMsg( WIE_DDEINITTITLE, WIE_DDETERMINATIONMSG,
                           MB_OK | MB_ICONINFORMATION );
    }

    return( ok );

} /* IEDDEDumpConversation */
Esempio n. 2
0
/*
 * 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 */
Esempio n. 3
0
/*
 * NewImage - create a new image and return the image type (bitmap, icon, or cursor)
 */
int NewImage( int img_type, const char *filename )
{
    WPI_DLGPROC         dlgproc;
    INT_PTR             button_type;
    short               width;
    short               height;
    short               bcount;
    img_node            node;
    char                ext[_MAX_EXT];

    // If filename is not NULL and we don't know the image type,
    // then guess based on the file extesion.
    if( filename != NULL && img_type == UNDEF_IMG ) {
        _splitpath( filename, NULL, NULL, NULL, ext );
        if( stricmp( ext, ".bmp" ) == 0 ) {
            img_type = BITMAP_IMG;
        } else if( stricmp( ext, ".ico" ) == 0 ) {
            img_type = ICON_IMG;
        } else if( stricmp( ext, ".cur" ) == 0 ) {
            img_type = CURSOR_IMG;
        }
    }

    if( img_type == UNDEF_IMG ) {
        dlgproc = _wpi_makedlgprocinstance( SelImgDlgProc, Instance );
        button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, SELECTIMAGE, 0L );
        _wpi_freedlgprocinstance( dlgproc );

        if( button_type == DLGID_CANCEL ) {
            return( FALSE );
        }
    } else {
        imgType = img_type;
    }

    imageCount++;

    switch( imgType ) {
    case BITMAP_IMG:
        dlgproc = _wpi_makedlgprocinstance( SelBitmapDlgProc, Instance );
        button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, BITMAPTYPE, 0L );
        _wpi_freedlgprocinstance( dlgproc );
        if( button_type == DLGID_CANCEL ) {
            imgType = UNDEF_IMG;
            imageCount--;
            return( imgType );
        } else if( button_type == SEL_SELECT ) {
#ifdef __OS2_PM__
            IEDisplayErrorMsg( WIE_NOTE, WIE_NOTIMPLEMENTED, MB_OK | MB_ICONINFORMATION );
            return( FALSE );
#else
            if( !SelectDynamicBitmap( &node, imageCount, filename ) ) {
                return( FALSE );
            }
#endif
        } else {
            initializeImage( &node, filename );
        }
        break;

    case ICON_IMG:
        if( !CreateNewIcon( &width, &height, &bcount, TRUE ) ) {
            imgType = UNDEF_IMG;
            return( imgType );
        }
        imgWidth = width;
        imgHeight = height;
        bitCount = bcount;
        initializeImage( &node, filename );
        break;

    case CURSOR_IMG:
#ifdef __OS2_PM__
        if( !CreateNewIcon( &width, &height, &bcount, FALSE ) ) {
            imgType = UNDEF_IMG;
            return( imgType );
        }
        imgWidth = width;
        imgHeight = height;
        bitCount = bcount;
#else
        dlgproc = MakeProcInstance_DLG( SelCursorDlgProc, Instance );
        button_type = JDialogBox( Instance, "CURSORTYPE", HMainWindow, dlgproc );
        FreeProcInstance_DLG( dlgproc );
        if( button_type == IDCANCEL ) {
            imgType = UNDEF_IMG;
            return( imgType );
        }
#endif
        initializeImage( &node, filename );
        break;

    default:
        return( FALSE );
    }

    node.wrinfo = NULL;
    node.lnode = NULL;

    CreateNewDrawPad( &node );

    SetupMenuAfterOpen();

    return( imgType );

} /* NewImage */