ImageGear Professional v18.2 > User Guide > Getting Started > MS Visual Basic 6.0 Application > Adding the Code |
Copy Code
|
|
---|---|
Private currentPage As IGPage Private currentPageDisp As IGPageDisplay Private currentFileDialog As IGFileDlg Private Sub Form_Load() On Error GoTo ErrorHandler IGCoreCtl1.License.SetSolutionName "Accusoft" IGCoreCtl1.Result.NotificationFlags = IG_ERR_OLE_ERROR IGCoreCtl1.AssociateComponent IGFormatsCtl1.ComponentInterface IGCoreCtl1.AssociateComponent IGDisplayCtl1.ComponentInterface IGDlgsCtl1.GearFormats = IGFormatsCtl1.ComponentInterface IGDlgsCtl1.GearCore = IGCoreCtl1.ComponentInterface IGDlgsCtl1.GearDisplay = IGDisplayCtl1.ComponentInterface Set currentFileDialog = IGDlgsCtl1.CreateFileDlg Set currentPage = IGCoreCtl1.CreatePage Set currentPageDisp = IGDisplayCtl1.CreatePageDisplay(currentPage) IGPageViewCtl1.PageDisplay = currentPageDisp IGPageViewCtl1.UpdateView Exit Sub ErrorHandler: MsgBox "Errors on stack? " & IGCoreCtl1.Result.isOk & vbCrLf & Err.Description, vbCritical, "An error has occurred" End Sub Private Sub Form_Resize() If Me.Height > 0 Then IGPageViewCtl1.Height = Me.ScaleHeight End If If Me.Width > 0 Then IGPageViewCtl1.Width = Me.ScaleWidth End If End Sub |
The code above includes:
IGCoreCtl Control | License.SetSolutionName | This method of the IGLicense Object sets the solution name for the ImageGear license. |
Result.NotificationFlag | This method of the IGResult Object tells ImageGear to report errors using the VB On Error mechanism. | |
AssociateComponent | This method associates ImageGear components with the Core control. | |
CreatePage | This method creates and returns a new IGPage Object. | |
Result.isOk | This property of the IGResult Object tells if there are any errors on the error stack. | |
IGDlgsCtl Control | GearFormats | This property sets the current Formats control used by the Dialog control. |
GearCore | This property sets the current Core control used by the Dialog control | |
IGDisplayCtl Control | CreatePageDisplay | This method creates a new IGPageDisplay Object for the specified IGPage Object. |
IGPageViewCtl Control | PageDisplay | This property sets the current Page Display object displayed by the Page View control. |
UpdateView | This method causes the Page View control to redraw itself. |
Copy Code
|
|
---|---|
Private Sub mnuOpen_Click() On Error GoTo ErrorHandler Dim loadDialogOptions As IGFileDlgPageLoadOptions Set loadDialogOptions = _ IGDlgsCtl1.CreateFileDlgOptions(IG_FILEDLGOPTIONS_PAGELOADOB J) If currentFileDialog.Show(loadDialogOptions) Then IGFormatsCtl1.LoadPageFromFile currentPage, loadDialogOptions.FileName, _ loadDialogOptions.PageNum End If IGPageViewCtl1.UpdateView Exit Sub ErrorHandler: MsgBox "Errors on stack? " & IGCoreCtl1.Result.isOk & vbCrLf & Err.Description, vbCritical, "An error has occurred" End Sub |
The code above includes:
IGDlgsCtl Control | CreateFileDlgOptions | This method creates a file dialog options object that will contain for example the filename and page number. |
IGFileDlg Object | Show | This method shows the file dialog and returns True of the user clicked OK. |
IGFormatsCtl Control | LoadPageFromFile | This method loads an image into the specified IGPage Object from the specified filename. |
Copy Code
|
|
---|---|
Private Sub mnuZoomIn_Click() On Error GoTo ErrorHandler Dim zoomzoom As IGDisplayZoomInfo Set zoomzoom = currentPageDisp.GetZoomInfo(IGPageViewCtl1.hWnd) zoomzoom.HZoom = zoomzoom.HZoom * 1.25 zoomzoom.VZoom = zoomzoom.VZoom * 1.25 zoomzoom.Mode = IG_DSPL_ZOOM_H_FIXED Or IG_DSPL_ZOOM_V_FIXED currentPageDisp.UpdateZoomFrom zoomzoom IGPageViewCtl1.UpdateView Exit Sub ErrorHandler: MsgBox "Errors on stack? " & IGCoreCtl1.Result.isOk & vbCrLf & Err.Description, vbCritical, "An error has occurred" End Sub |
The above code zooms the image to 125 percent, or 5/4ths, of its size (zoom in by 25 percent).
Copy Code
|
|
---|---|
Private Sub mnuZoomOut_Click() On Error GoTo ErrorHandler Dim zoomzoom As IGDisplayZoomInfo Set zoomzoom = currentPageDisp.GetZoomInfo(IGPageViewCtl1.hWnd) zoomzoom.HZoom = zoomzoom.HZoom * 0.8 zoomzoom.VZoom = zoomzoom.VZoom * 0.8 zoomzoom.Mode = IG_DSPL_ZOOM_H_FIXED Or IG_DSPL_ZOOM_V_FIXED currentPageDisp.UpdateZoomFrom zoomzoom IGPageViewCtl1.UpdateView Exit Sub ErrorHandler: MsgBox "Errors on stack? " & IGCoreCtl1.Result.isOk & vbCrLf & Err.Description, vbCritical, "An error has occurred" End Sub |
The above code zooms "out", decreasing the image to 4/5ths of its size, thereby canceling the effect of the zoom in above.
The code above includes:
IGPageDisplay Object | GetZoomInfo | This method creates and returns a new IGDisplayZoomInfo Object that contains zoom mode and values. |
UpdateZoomFrom | This method sets zoom mode and values from the specified IGDisplayZoomInfo Object. |