Can the windows title bar be changed?

I"m not sure if I’m using the correct terminology, so I’ve added an Image below to point it out (Yellow and Blue Arrow)

Is there a way to change/remove the Exit,Max,Min buttons, along with the Title, in the windows title bar?

Thanks.

For removing the Min, Max buttons use a macro which at the start of the odb, minimizes the Libreoffice window to the taskbar while opening a “Main Menu” form. The close X will remain however. A solution for the title bar will follow soon after this post!

  • Edit Macros and create the sub routine in a module of the odb (Standard / Module1).
  • Without opening any forms, attach to the Open Document event of the opened odb file: LO Main window menu - Tools - Customize - Events. Save the odb, close, and reopen. “Enable Macros”
  • To revert the changes, “Disable Macros” upon opening the odb, remove the macro from the odb file Open Document event. The macre does not need to be deleted unless desired. Save and reopen! Here is the sub:

Sub winLOMin()
Dim objA, objB, objC
objA=thisDatabaseDocument.formDocuments()
If objA.hasByName(“Main Menu”) then
objB=objA.getByName(“Main Menu”)
Else
Exit sub
Endif
objC=thisDatabaseDocument.currentController()
objC.connect()
doEvents
objB.open()
doEvents
objC.frame.containerWindow.isMinimized()=true
End Sub

Thank you for getting back to me.

I think that I’m missing something (probably something asinine) . I’ve added some message boxes (as you will see), and when this is run, I’m getting the “Exit Sub” message. In design mode or not, same message. Thoughts?

Sub winLOMin()
DIM objA, objB, objC
objA=thisDatabaseDocument.formDocuments()
If objA.hasByName(“MainForm”) then
objB=objA.getByName(“MainForm”)
Else
msgbox(“Exit Sub”)
Exit sub
Endif
objC=thisDatabaseDocument.currentController.connect()
objB.open()
doEvents
objC.frame.containerWindow.isMinimized()=true
msgbox(“Finished”)
End Sub

The msgbox is a good debug tool! Looks like you have the wrong Form name! What is the name of the database Form that you want to open along with the odb? Mine is “Main Menu”. Yours may be something else. “MainForm” is usually the name of the first control within a database form, followed by “SubForm” and so on… These are typically not names given to database forms. The database form name is the name you gave the Form when it was created and is now in the database Forms list (LO Base main window - Forms). For example, my “Main Menu” database form has its first control named “MainForm” and a second subform control named “SubForm”. These have nothing to do with the database form name as they are merely control or controller names. My form name is “Main Menu”. I also have other database forms named “Businesses”, “Contacts”, etc…)

Yes, having them both called form is very confusing. My DB Form title is Frm_MainForm so THAT was an easy fix. However…

Replace the code in proximity to the errant highlighted code with these lines:

  • objC=thisDatabaseDocument.currentController()
  • objC.connect()
  • doEvents
  • objB.open()
  • doEvents
  • objD=objC.frame.containerWindow()
  • objD.isMinimized()=true
    You will also need to add objD to the object declarations (DIM…) I apologize for the missteps.

I received the msg “Finished”, LO is minimized, but the min/max buttons are still present.

(Don’t worry about missteps, I have them all the time lol)

Yes, there is a part two… working on it. Mainly about hiding the menus on the form.

Try appending these lines after objD.isMinimized()=true:

  • doEvents
  • objE=thisComponent.currentController()
  • objE.frame.layoutManager.visible()=false
    Again add objE to object declaration line!
  • If this doesn’t work you will have to create another sub routine that includes these two lines and then attach it to Frm_MainForm’s Tools - Customize - Events - Open Document event. Give the sub a name like hideFormMenu() and you can figure out the rest.

Nothing changed after adding those lines and adding objE. :expressionless:
The min/max buttons still work as well.
(Code is so much fun haha)

Updated previous post!

Gotcha. I’m on it.

Just so we’re on the same page, this is what I’ve got:

Sub winLOMin()
DIM objA, objB, objC, objD, objE
objA=thisDatabaseDocument.formDocuments()
If objA.hasByName(“Frm_MainForm”) then
objB=objA.getByName(“Frm_MainForm”)
Else
msgbox(“Exit Sub”)
Exit sub
Endif
objC=thisDatabaseDocument.currentController()
objC.connect()
doEvents
objB.open()
doEvents
objD=objC.frame.containerWindow()
objD.isMinimized()=true
doEvents
hideFormMenu

End Sub

Sub hideFormMenu()
DIM objE
objE=thisComponent.currentController()
objE.frame.layoutManager.visible()=false
msgbox(“Finished”)
End Sub

Is this what you meant? Would moving those two lines to their own Sub change anything? or did I miss something?

Still the same (buttons still there and working, and LO is minimizing)

Gimme a few

Use this code in a seperate module (standard / module2) and attach to Frm_MainForm “When loading” event under Form - Form properties - Events The macro name is “btnCloseDisable”.

Option Explicit

Dim objA
Dim lngA as Long

Declare Function GetWindowLong Lib "user32.dll" _
	Alias "GetWindowLongA" (ByVal lngA As Long, ByVal idx As Long) As Long

Declare Function SetWindowLong Lib "user32.dll" _
	Alias "SetWindowLongA" (ByVal lngA As Long, ByVal idx As Long, ByVal newLong As Long) As Long

Declare Function GetSystemMenu Lib "user32.dll" _
	Alias "GetSystemMenu" (ByVal lngA As Long, ByVal revert As Boolean) As Long

Declare Function DeleteMenu Lib "user32.dll" _
	Alias "DeleteMenu" (ByVal hMenu As Long, ByVal id As Long, ByVal flags As Long) As Boolean

Declare Function FindWindowEx Lib "user32.dll" _
	Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChild As Long, ByVal className As String, ByVal windowName As Long) As Long

Declare Function GetWindowText Lib "user32.dll" _
	Alias "GetWindowTextA" (ByVal lngA As Long, ByVal strA As String, ByVal maxCount As Long) As Long

Declare Function SendMessage Lib "user32.dll" _
	Alias "SendMessageA" (ByVal lngA As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Const SYSTEM_WIN32 as Integer=1
Const GWL_EXSTYLE as Long=-20&
Const WS_EX_TOOLWINDOW as Long=&h00000080&
Const WS_EX_APPWINDOW as Long=&h00040000&
Const SC_CLOSE as Long=&h0000F060&
Const MF_BYCOMMAND as Long=&h00000000&
Const WM_CLOSE as Long=&h00000010&

Sub btnCloseDisable()
	objA = thisComponent.DrawPage.Forms.getbyIndex(0)
lngA=objA.Parent.Parent.CurrentController.Frame.getContainerWindow().getWindowHandle(dimarray(), SYSTEM_WIN32)
	SetWindowLong(lngA, GWL_EXSTYLE, (GetWindowLong(lngA, GWL_EXSTYLE) And Not WS_EX_APPWINDOW) Or WS_EX_TOOLWINDOW)
	DeleteMenu(GetSystemMenu(lngA, False), SC_CLOSE, MF_BYCOMMAND)
	FreeLibrary("user32.dll")
End Sub

Well, I got it in there and cohesive. When I try to edit the form to set the “When Loading”, this is what it looks like hahaha (going to go REM the other code to see if that changes this as I can’t access anything at the moment) Oh, just FYI, when I just run the form, it runs like it’s supposed too (buttons still there tho). Still working on trying to get it in “When Loading”

Yes, you will want to remove the hideFormMenu macro from the form event

That let me into the regular Edit screen, but now there is no “When Loading” option in the list for Macros.

I’m starting to think that LO has something against me hahaha

OK.

  • Do not call the hideFormMenu sub from the winLOMin() They are independant of eachother.
  • Remove the hideFormMenu() macro from all form events for now.
  • Create the new module which starts with declaring Dim objA and then Dim lngA as Long
  • Call that macro from Frm_MainForm “When loading” event in Form - Form Properties - Events
    I remember when I first found this macro it took a couple of days to get it right. For clarification, each macro is assigned differently.
  • winLOMin() macro is assigned in the opened Main LO window, Tools - Customize - Events - Open Document
  • hideFormMenu() macro is assigned while editing the form, Form - Tools - Customize - Events - Open Document. Leave this one unassigned for now. I have mods so that menus show when editing the form.
  • Standard / Module2 btnCloseHide() is assigned while editing the form, Form - Form Properties - Events - When loading

OK, I’ve removed any call to the hideFormMenu. New module created, and set to “When Loading” event in Form Properties. I don’t see any difference when running or editing the form.

I’ll bet it did take a while, that’s a hefty bit of code.

I tried adding the HideFormMenu back, just to see. It still looks like the last image I sent lol

Updated previous post! Are any errors? That Module2 probably needs to be created in the “My Macros & Dialogs” / Standard library in the left navigation pane of the basic editor window. Afterwards, reassign the macro in the Form - Form Properties - Events - When loading - as its address will have changed. Let me see if I can come up with a working sample of my form with macros. Then you should be able to model your own from it.

No errors, but still nothing. Let me try something, give me a few.

OK, I got it to work in a LODB that I had trimmed down to barebones, so it’s conflicting with something on my end. I’ll track it down. Thank you so much!! (This is one of the reasons I enjoy code lol)
What about that hideFormMenu macro?
Is it possible to change the title?

Update: I was able to get it to work in my original LODB. I had it set to reloading instead of loading sigh