<lots of stuff snipped out....>
Are you sure you understood my question (possibly written in "Swenglish")? Because I am not sure I understand the answer... So, just in case, I will rephrase it, but since I write this in a "text only" format, I have to introduce some "graphics" first:
This is the cursor: |
If I select a word, like when I double click it, its background will change colour, but that's not possible here, so I write it like in this example: In this sentence one [word] is selected, guess which one...
OK, let's say I have a dialog with two text fields and nothing more. Their texts' default values are Hello and Goodbye respectively.
Now, when opening the dialog, it looks like this:
|Hello
Goodbye
As you can see, the cursor is placed next to the word Hello, so if I press Delete on my keyboard, the word will be ello, right?
Now, after putting my H back so it now reads Hello again, I press my TAB key, which will make it look like this:
Hello
[Goodbye]
Goodnye is now selected, which means that if I press my keyboard's Delete key the whole word will disappear. But I don't, I press the TAB key once more instead, which will make the dialog look like this:
[Hello]
Goodbye
So, what I want, in this example, is to have the Hello selected already when I first enter the dialog, not just the cursor right next to it. Maybe I will find a solution to this too if I just give it some time... And maybe it's just not that much of a problem...
Oops! You are correct, I did not make ANY comments at all about this! You want to know if you can have the initial date field be completely selected on startup.... Hmmmm....
Option Explicit
Private oDlg As Object
Sub RunTheSillyTHing
Dim oControl
Dim oSel As New com.sun.star.awt.Selection
iProgressCount = 0
oDlg = CreateUnoDialog(GlobalScope.DialogLibraries.PitonyakDialogs.Dialog1)
oControl = oDlg.getControl("DateField1")
oControl.setDate(CDateToISO(Date()))
oSel.Min = 0
oSel.Max = 8
oControl.setSelection(oSel)
oControl = oDlg.getControl("TextField1")
oControl.setText("I am sample text")
oDlg.execute()
End Sub
Hope this helps.... I missed your question completely; bad andy!
Hi and thanks for the info. Now I have actually tried it, but it doesn't work like expected.
My date format is YYYY-MM-DD så I hade to set oSel.Max to 10 instead of 8, but that's not the point in this case. The point is that the whole date field is not selected.
This is what I want: [2005-03-30]
This is what I get: 2005-03-30|
It seems like there's just a cursor right after the 10th character.
Then I tried it for another field, in this case a text field and this time it worked like expected. It seem like date fields are a bit different, or maybe I did something wrong. Again...
Information about my dialog:
DateFieldUppdrag is the first field to be selected according to tabulator sequence set for the controls of the dialog. No controls in my dialog calls for any subroutines yet. I didn't go that far yet...
Here's my code. If you find some Swedish comments they are probably irrelevant in this case. They are for myself only, just to help me remember what I've done and why. Comments in English were added after pasting the code to this message. This is very simple stuff anyway (except that I can't get it to work properly...), so far.
Option Explicit
Dim Dlg As Object
'**********************************************************************
Sub StartDialogUppdrag
DialogLibraries.LoadLibrary("Standard")
Dlg = CreateUnoDialog(DialogLibraries.Standard.Uppdrag)
Call setDialogUppdragDefaultValues
Dlg.Execute()
End Sub
'********************************************************************** Sub setDialogUppdragDefaultValues Dim Ctl As Object Dim Sel As New com.sun.star.awt.Selection Ctl=Dlg.getControl("DateFieldFaktura") Ctl.setDate(CDateToIso(Now))
Ctl=Dlg.getControl("DateFieldUppdrag")
Ctl.setDate(CDateToIso(Now)) Sel.Min=0
Sel.Max=10
Ctl.setSelection(Sel)' These three subroutines does some settings which I believe doesn't have
' anything to do with my problem, but I include them anyway, just in case.
' Don't feel that you have to study them or anything...
Call setFakturanummer
Call addItemsComboBoxKund
Call addItemsComboBoxKontakt
End Sub'**********************************************************************
Sub setFakturanummer
Dim Ctl As Object
Dim Doc, Sheet, Cell As Object
Dim Number, Row As Long
Dim Fakturanummer As String
Dim Dt As Date
Doc=StarDesktop.CurrentComponent
Sheet=Doc.Sheets.getByName("Uppdrag")
Ctl=Dlg.getControl("PatternFieldFakturaNr")
Cell=Sheet.getCellByPosition(7,1) ' Hämtar nästa radnummer.
Row=Cell.Value
Cell=Sheet.getCellByPosition(0,Row) ' Hämtar senaste fakturanumret.
Number=Cell.Value+1 ' Exempelvis 12345
Dt=Date
Fakturanummer=Right("00"+LTrim(Str(Year(Dt))),2)+Right("000"+LTrim(Str(Number)),4) '"052345"
Ctl.setString(Fakturanummer)
End Sub
'********************************************************************** Sub addItemsComboBoxKund Dim Doc, Sheet, Cell As Object Dim AntalKunder As Integer Doc=StarDesktop.CurrentComponent Sheet=Doc.Sheets.getByName("Kunder") Cell=Sheet.getCellByPosition(8,1) AntalKunder=Cell.Value
Call addItemsComboBox(Sheet, 1, "ComboBoxKund", AntalKunder) End Sub
'********************************************************************** Sub addItemsComboBoxKontakt Dim Doc, Sheet, Cell As Object Dim AntalKontakter As Integer Doc=StarDesktop.CurrentComponent Sheet=Doc.Sheets.getByName("Kontaktpersoner") Cell=Sheet.getCellByPosition(8,1) AntalKontakter=Cell.Value
Call addItemsComboBox(Sheet, 2, "ComboBoxKontakt", AntalKontakter) End Sub
'**********************************************************************
Sub addItemsComboBox (Sheet As Object, Column As Integer, BoxName As String, AntalPoster As Integer)
' När databasen blir mycket större är det kanske lämpligt
' att, istället för att söka rakt igenom listan, börja i mitten,
' sen successivt ta sig närmare målet genom att hela tiden
' halvera hoppens längd i listan.
Dim Ctl As Object
Dim Varv, Position As Integer
Dim Post, Radtext As String
Ctl=Dlg.getControl(BoxName)
For Varv=1 To AntalPoster ' Fyll Comboboxen med kunder.
Post=Sheet.getCellByPosition(Column,Varv).String
Position=0
Do ' Sätt in varje kund på rätt plats i bokstavsordning.
Radtext=Ctl.getItem(Position)
Position=Position+1
Loop While Radtext<Post And Position<Varv
Ctl.addItem(Post, Position-1)
Next Varv
End Sub
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
