FileOpen Example for Visual J++

 

private void button1_click(Object source, Event e)
{
   LEADDlg1.setFileDlgFlags( 0 );

   LEADDlg1.setPreviewEnabled( true );

   LEADDlg1.setDialogTitle( "Open A File" );

   LEADDlg1.setFilter( "All |*.*|CMP|*.cmp|JPEG|*.jpg" );

   LEADDlg1.setFilterIndex( 2 );  // look for *.cmp first

   LEADDlg1.setInitialDir( "c:\\lead\\images\\" );

   LEADDlg1.setLoadPasses( 0 );

   LEADDlg1.setLoadRotated( true );

   LEADDlg1.setLoadCompressed( false );

   // if LEAD1 has a bitmap, we will load on top of it

   // otherwise, we will load into the Common Dialog control, and copy later

   // NOTE: use CreateBitmap to create a 1x1 1-bit bitmap to avoid the copy

   if( LEAD1.getBitmap () > 0 )

      LEADDlg1.setBitmap( LEAD1.getBitmap() );

   else

      LEADDlg1.setBitmap( 0 );  // free any existing bitmap reference

LEADDlg1.setUIFlags( 

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_AUTOPROCESS |

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_PROGRESSIVE |

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_MULTIPAGE |

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_LOADROTATED |

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_LOADCOMPRESSED |

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_FILEINFO |

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_SHOWSTAMP |

                        ltdlg14n.tagFileOpenDlgConstants.DLG_FO_SHOWPREVIEW );

   LEADDlg1.FileOpen( getHandle() );

   // output the results

   LEAD1.setRefBitmap ( true );

   LEAD1.setBitmap( LEADDlg1.getBitmap() );  // copy image to LEAD OCX

   LEAD1.setRefBitmap ( false );

 

   LEAD2.setBitmap ( 0 );

   LEAD2.setBitmap( LEADDlg1.getThumbnail() );  // copy thumbnail image to LEAD OCX

 

   // output the results

   edit1.setText( LEADDlg1.getFileName() );

   edit2.setText( Integer.toString( LEADDlg1.getPageNumber() ) );

   edit3.setText( new Boolean( LEADDlg1.getLoadCompressed() ).toString() );

   edit4.setText( new Boolean( LEADDlg1.getLoadRotated() ).toString() );

   edit5.setText( Integer.toString( LEADDlg1.getLoadPasses() ) );

}