[Solved] Automatic opening form to screen resolution

Discuss the database features

[Solved] Automatic opening form to screen resolution

Postby robce64 » Sat Feb 25, 2012 8:15 pm

Hello, I would like to make a macro to make me appear automatically when you open the program, a form of menus designed to screen resolution. The screen resolution is set in the macro should not be fixed but is variable depending on the screen you use. On each computer that uses the form should automatically open to full screen, even if the computers have different monitor resolutions.
Thank you! :super:
Last edited by robce64 on Mon May 07, 2012 6:13 pm, edited 1 time in total.
OOo 3.3 Win7 64bit
robce64
 
Posts: 20
Joined: Wed Feb 22, 2012 8:27 pm

Re: Automatic opening form to screen resolution

Postby robce64 » Mon Feb 27, 2012 9:35 pm

it is impossible? :shock:
OOo 3.3 Win7 64bit
robce64
 
Posts: 20
Joined: Wed Feb 22, 2012 8:27 pm

Re: Automatic opening form to screen resolution

Postby robce64 » Sun Mar 11, 2012 2:59 pm

:crazy:
OOo 3.3 Win7 64bit
robce64
 
Posts: 20
Joined: Wed Feb 22, 2012 8:27 pm

Re: Automatic opening form to screen resolution

Postby robce64 » Sat Mar 24, 2012 7:13 pm

:crazy:
OOo 3.3 Win7 64bit
robce64
 
Posts: 20
Joined: Wed Feb 22, 2012 8:27 pm

Re: Automatic opening form to screen resolution

Postby F3K Total » Sat Mar 24, 2012 7:28 pm

Yes!
But if you like anybody to help you solving you problem, you should show, what you, by yourself, did in between (since Sat Feb 25, 2012 8:15 pm), else than banging your head to a wall, to solve the problem. For example, you could search in this or other boards.
Greats R
    MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
    my current system
  • Windows 7 OOo, AOO, LOLinux Mint OOo, AOO, LO
F3K Total
Volunteer
 
Posts: 896
Joined: Fri Dec 16, 2011 8:20 pm

Re: Automatic opening form to screen resolution

Postby JPL » Tue Apr 10, 2012 12:13 pm

Hello,

to display automatically a form in full-screen when opening a database document (".odb"), maybe below a solution:

- install the Access2Base extension (http://extensions.services.openoffice.org/en/project/access2base)
- insert next code in a BASIC module of the Standard Library of your db document:

Code: Select all   Expand viewCollapse view
Sub DBOpen(Optional poEvent As Object)
REM Next 3 lines are for making Access2Base API available
   If GlobalScope.BasicLibraries.hasByName("Access2Base") then _
      GlobalScope.BasicLibraries.LoadLibrary("Access2Base")
   Call OpenConnection(ThisDatabaseDocument)
REM Now to open a form
   OpenForm "myForm"      '   Set the name of your choice ...
   Maximize()
End Sub

- Assign in the main Base window with menu items Tools + Customize... (Events tab) the above Sub ("DBOpen" in the example but use the name of your choice) to the OpenDocument event. Save in the ".odb" file itself.
- Close and re-open the ".odb" file. This will trigger the OpenDocument event.

A variant could be

Code: Select all   Expand viewCollapse view
Sub DBOpen(Optional poEvent As Object)
Const acForm = 2
Const acDatabaseWindow = 102
REM Next 3 lines are for making Access2Base API available
   If GlobalScope.BasicLibraries.hasByName("Access2Base") then _
      GlobalScope.BasicLibraries.LoadLibrary("Access2Base")
   Call OpenConnection(ThisDatabaseDocument)
REM Now to open a form
   OpenForm("myForm")      '   Set the name of your choice ...
   Maximize()
   SelectObject(acDatabaseWindow)
   Minimize()
   SelectObject(acForm, "myForm")
End Sub

This will minimize the "database window".

NB: This functionality requires at least OO3.3 !

Hoping this will help.
Windows 7 / LibO 6.0 / AOO 4.1
Ubuntu 18.04 / LibO 6.1
Access2Base extension (AOO) or standard (LibO).
BaseDocumenter extension (LibO)
Documentation on http://www.access2base.com and http://www.access2base.com/basedocumenter
JPL
Volunteer
 
Posts: 97
Joined: Fri Mar 30, 2012 3:14 pm

Re: [Solved] Automatic opening form to screen resolution

Postby Fernsguitars » Wed Jan 10, 2018 12:19 am

Hi JPL,

I tested your code within the macro used to start a HSQLDB converted database. The first one to open a form fullsize is working and listed here (your code between REM*****)

The second one that also minimalizes the 'database' window however does not open the form window fullsize. Hope it helps within the topic.

Code: Select all   Expand viewCollapse view
'Instructions for use:
' (1) manually remove any global Class Path to hsqldb.jar if setup in Tools > Options > *Office > Java/Advanced > Class Path
' (2) macro security must be set to Medium (or Low) in Tools > Options > *Office > Security > Macro Security
' (3) place this file in a dedicated (empty) database folder
' (4) add a copy of the HSQLDB engine (hsqldb.jar) to the database folder.
' (5) when copying this code to another .odb, add this macro to: Tools > Customize... > Events > Open Document

Sub Setup 'Tools > Customize... > Events > Open Document
'Globalscope.BasicLibraries.LoadLibrary("MRILib")
On Error Goto ErrorHandler
  'get the current path to this .odb file
   sPathURL = ThisDatabaseDocument.URL
   sPath = ConvertFromURL(sPathURL)
   sName = ThisDatabaseDocument.Title
   iLen = InStr(sPath, sName)
   sPath = Left(sPath, iLen-1)
      
  'setup Class Path
  ClassPath:
   sClassPath = sPath & "hsqldb.jar"
   If Not FileExists(sClassPath) Then
      sLine1 = "Please add a copy of the HSQLDB engine (hsqldb.jar) to the current folder :  "
      sLine2 = "NOTE:  This is necessary for proper wizard function, but additional benefits include : "
      sLine3 = "* enhanced portability of the database-folder"
      sLine4 = "* ensures database compatibility across computers and *Office installations"
      sLine5 = "* guards against inadvertent upgrade of your database since the results are uncertain and irreversible"
      sLine6 = "* hsqldb 2.x provides a built-in database management GUI accessible by clicking hsqldb.jar."
      iButton = MsgBox (chr(13) & sLine1 & chr(13) & chr(13) & sPath & chr(13) & chr(13) & sLine2 & chr(13) & sLine3 & _
      chr(13) & sLine4 & chr(13) & sLine5 & chr(13) & sLine6, 18, "hsqldb.jar not found")
      If iButton = 3 Then Exit Sub 'ThisDatabaseDocument.close(True)
      If iButton = 4 Then Goto ClassPath
   End If
   sClassPath = ConvertToURL(sClassPath)
   ThisDatabaseDocument.DataSource.Settings.JavaDriverClassPath = sClassPath
   
  'get the HSQL database name from the current folder
   NextFile = Dir(sPath, 0)
   While NextFile <> ""
      If (Right(NextFile, 7) = ".script") Then dbName = (Left(NextFile, Len(NextFile)-7))
      NextFile = Dir
   Wend
   
   If dbName = Empty Then
      sLine1 = "Optionally provide a name for your back-end data files. "
      sLine2 = "NOTE: The particular name is not important. The default below will suffice. "
      dbName = InputBox(sLine1 & chr(13) & chr(13) & sLine2, "Create a new database    *   JDBC  |  HSQL database engine  |  non-embedded data files   *", "mydb")
      If dbName = "" Then dbName = "mydb"
   End If
   
  'check for existing database
   sLine1 = "A new database will be created in the current folder:  "
   sLine2 = "NOTE: This folder constitutes your ""database."" "
   sLine3 = "A dedicated database folder is fully portable, and as such it may be renamed or moved as desired."
   sLine4 = "NOTE: This Base front-end file (" & sName & ") must remain in this database folder.  "
   sLine5 = "You may rename this file as desired, but do maintain the .odb extension if visible. Create a desktop shortcut to this file as desired."
   sLine6 = "NOTE: The back-end HSQL data files will be named: " & dbName & ".*  "
   sLine7 = "These files must also remain in this database folder."
   If Not FileExists(sPath & dbName & ".script") Then MsgBox sLine1 & chr(13)_
      & sPath & chr(13) & chr(13) & sLine2 & sLine3 _
      & chr(13) & chr(13) & sLine4 & sLine5 _
      & chr(13) & chr(13) & sLine6 & sLine7 _
      , 64, "Please Read"
     
  'setup Data Source URL
   sURL_prefix = "jdbc:hsqldb:"
   sURL_args = ";default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false"
   sURL = sURL_prefix & "file:///" & sPath & dbName & sURL_args
   ThisDatabaseDocument.DataSource.URL = sURL
   
REM*************************************************************************
REM Next 3 lines are for making Access2Base API available
   If GlobalScope.BasicLibraries.hasByName("Access2Base") then _
      GlobalScope.BasicLibraries.LoadLibrary("Access2Base")
   Call OpenConnection(ThisDatabaseDocument)
REM Now to open a form
   OpenForm "my form"      '   Set the name of your choice ...
   Maximize()
REM*************************************************************************
   Exit Sub

  ErrorHandler:
   MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")", 16, "Setup: macro code error"
End Sub
openoffice 4.1.2 / Windows 10 pro
Fernsguitars
 
Posts: 2
Joined: Wed Jan 10, 2018 12:01 am

Re: [Solved] Automatic opening form to screen resolution

Postby JPL » Wed Jan 24, 2018 6:44 pm

@ Fernsguitars

Thanks for the info.
(I don't remember what I tested effectively >5 years ago ... )

Anyway this works for me:
Code: Select all   Expand viewCollapse view
   SelectObject(acDatabaseWindow)
   Minimize()
   OpenForm("myForm")      '   Set the name of your choice
   Maximize()


Regards.
JPL
Windows 7 / LibO 6.0 / AOO 4.1
Ubuntu 18.04 / LibO 6.1
Access2Base extension (AOO) or standard (LibO).
BaseDocumenter extension (LibO)
Documentation on http://www.access2base.com and http://www.access2base.com/basedocumenter
JPL
Volunteer
 
Posts: 97
Joined: Fri Mar 30, 2012 3:14 pm

Re: [Solved] Automatic opening form to screen resolution

Postby Fernsguitars » Thu Jan 25, 2018 12:13 am

@ JPL

Thanks! Last year and this year I work on my business database, and sometimes I try to get info at the forum, so I will try sometimes to contribute as wel - only taking info is a bit silly - but that is a bit off topic!
openoffice 4.1.2 / Windows 10 pro
Fernsguitars
 
Posts: 2
Joined: Wed Jan 10, 2018 12:01 am


Return to Base

Who is online

Users browsing this forum: No registered users and 3 guests