<lots of stuff snipped out....>

Johnny Andersson wrote:

Andrew Douglas Pitonyak <[EMAIL PROTECTED]> skrev den Thu, 24 Mar 2005 21:51:52 -0500:

2. The event tab in that Properties dialog is just about like they are for most control elements, but it doesn't seem to work. I put a macro in some fields there but that macro was never run whatever I did. When I did the same thing for a control element the macro started when it was supposed to. Is this a bug?

I did my testing using 1.9.87. I tied the mouse click event to a subroutine similar to the following

Sub blahblahblah(x)
   iii = iii + 1
   If iii < 4 Then Print "Here I am " & iii
End Sub

I was careful to use the mouse down event. Many of the events will NEVER get to the dialog because they happen in a control and are consumed by the control. If I used something like keypress, then the focused control is likely to receive the event.


If there were a "Dialog opens" event, it would be perfect for me to use for setting default values of ever Control element in it, unless that event happens before the control elements exist, of course...

However, I found a solution for my problem (maybe there are better ways or maybe everybody already know about it, but that's what it's like when being a beginner like me...). I simply write a macro which sets all default values, since those values depend on different things, like current date and the current values of some cells in the spreadsheet my macros work with. Actually I create one macro for every default value setting, but the first one calls all the others before finishing.

This is what I expect you to do! It is not that bad to do.

[in] indicates that the argument is an "input" argument. Because it is an INPUT argument, then the value is used read, but not modified. If it said [out], then a value would be passed back in the variable.

So [in] is similar to using a pointer?

No, they are just telling you how the argument is used. Consider the following macros:


Sub TheMainSub
 Dim i As Integer
 i = 7
 SubIn(i)
 Print "After SubIn i = " & i
 SubOut(i)
 Print "After SubOut i = " & i
 SubInOut(i)
 Print "After SubInOut i = " & i
End Sub

Sub SubIN(x)
 Print "in IN x = " & x
End Sub

Sub SubOUT(x)
 x = 5
End Sub

Sub SubINOUT(x)
 x = x + 1
 Print "in INOUT x = " & x
End Sub

SubIn uses the value x as INPUT. SubOut modifies x and sends the value back and completly ignores the input value.

4. I used the method setDate, mentioned above, to set a default date. I saw that I could set a default date manually in the Properties dialog of that date control element, but there doesn't seem to be a way to set the default date to the current date. Am I wrong? And if I am, how can I do it? I just want the date field to show the current date. By the way, what's the point by setting a default date to something else than the current date?

5. When I enter my dialog I want the default date to appear in the date field, and it does. Here is the simple code for it, which I use for the very moment, until I find a better way:

' This macro opens the dialog, of course.
Dim Dlg As Object
Sub StartDialogUppdrag
    Dlg = CreateUnoDialog(DialogLibraries.Standard.Uppdrag)
    Dlg.execute()
End Sub


' When the date field gets in focus, this macro will run. Sub setDialogUppdragDefaultDate Dim Ctl As Object Dim DateToday, TestValue as Long Dim Dt As Date Ctl=Dlg.getControl("DateField")

'Just to make sure that "today's date" won't appear when you already selected another date,
'I put the next three lines inside this IF statement:
If Ctl.getDate=0 Then
DT=Date
DateToday=Year(Dt)*10000+Month(Dt)*100+Day(Dt)
Ctl.setDate(DateToday)
End If
End Sub



Since the setDate seems to require an integer (Long), the line "DateToday=Year(Dt)*10000+Month(Dt)*100+Day(Dt)" seems to be necessary. Do you know a better way to do this? I am quite a beginner on this. Well, that was not the main point anyway. The last IF statement wouldn't be necessary if the setDialogUppdragDefaultDate macro only runs the first time the dialog is started, rather than everytime the date field is in focus, but as I said before, I couldn't get that to work, see point 2. The reason why I brought that up again is that maybe the information I gave on the way down here might helped a bit to understand my question... ;D


Page 433 of my book, Use CDateToISO(Date())

You really want me to have your book, don't you? So tell me about it! How can I get it, how much do I have to pay for it?

But it or do not. The is not my really my personal advertising advertising forum. It is just that sometimes I spend time answering questions and then later they mention "Oh, I have your book". Well, now I sometiems indicate the page numbers where I discuss their particular question. My book contains more complete examples. I notice, however, that many of your questions are specifically answered in my book. If you want to know what the book is like, then download the free sample chapters. Start from


http://www.hentzenwerke.com/catalog/oome.htm

Click on the sample chapter links
http://www.hentzenwerke.com/samplechapters/zsamplechapters.htm

There is a link to a zip file which contains chapter 1 and 5.
http://www.hentzenwerke.com/samplechapters/scoome_1_15.zip

You can also download the chapters individually.
http://www.hentzenwerke.com/samplechapters/oome_sc01.pdf
http://www.hentzenwerke.com/samplechapters/oome_sc15.pdf

As for cost, it depends on where you where you purchase the book. Note that you can purchase the book from the publisher directly as a PDF document and as a bound book; if delivery is an issue. I saw it at my local book store, and you can order the book from Amazon.

What topics does it cover?
http://www.hentzenwerke.com/catalog/oometoc.htm
The detailed examples may be of help.
There, enough of a sales pitch. Remember that there is also a free document from Sun and searching the oooforum will also provide numerous examples.


6. When my dialog is started, my date field is the first to be in focus. It has to be if I want the default date to show up immediately since I don't know the answers of my own questions above. Now, the very first time it is in focus, the cursor i placed to the left of the date, which looks like this:
|2005-03-24
(The "|" is supposed to be the cursor in the example above, of course). When I press the YAB key until the date field is focused once again, the whole date is "selected" or "highlighted". Is there a way I can make that happen in the first place? That would be very useful, I think.


Already stated


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!

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm
Free Info:  http://www.pitonyak.org/oo.php


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to