TOPIC: underline option in NumberControl
underline option in NumberControl 2 Years, 4 Months ago
I'm trying to use the underline option in NumberControl. This is the code

Window(#(Number underline:true set:500 ))

If NumberControl inherits from FieldControl it should do everything FieldControl does.

Help appreciated.

Re:underline option in NumberControl 2 Years, 4 Months ago
You are right, it should. But NumberControl does not appear to accept an underline option. It is easy to fix:


New(mask = '-###,###,###', readonly = false,
    rangefrom = false, rangeto = false, width = false,
    set = false, mandatory = false, status = "", justify = "RIGHT",
    font = "", size = "", weight = "", underline = false)
    super(@.options(mask: mask, width: width,
        readonly: readonly, justify: justify, status: status,
        style: OperatingSystem() =~ '95|NT' ? ES.MULTILINE : 0,
        font: font, size: size, weight: weight, underline: underline))

If you compare the parameters for NumberControl and FieldControl you will notice there are other options "missing". (Some, like password mode, probably do not make sense for NumberControl.)

The reason this happens is that when someone adds an option to FieldControl they forget to add it to all the classes that inherit from it.

Note: If NumberControl did not have its own New, then you would not need to update it.

Note: One way to "solve" the problem is to use New(@args) to accept any arguments and then super(@args) to pass on whatever you received.
Re:underline option in NumberControl 2 Years, 4 Months ago
Thanks. I changed it and it works. I'm not sure I understand the rest of your answer if you use New(@args) and then Super(@args) your not going to be able to put in new arguments which is the whole purpose of New(@args) I would Imagine, could you also please explain the meaning of @.options.


P.S. In the middle of the Definition for NumberControl there's this function

CHAR(wParam, lParam)
with a red dot under lParam. I'm guessing this is because lParam's not used in the body but then why is it there altogether?
Last Edit: 2008/04/16 10:08 By abec.
Re:underline option in NumberControl 2 Years, 4 Months ago
@args does let you add more arguments, you just have to extract them from the args object e.g. args.underlined

To handle default arguments you can use args.GetDefault('underlined', false)

Yes, the red dot is a warning that lParam isn't used. Because of the way CHAR (and other WM_ messages) are called (with lParam a "named argument" ) it can simply be omitted.

I noticed and fixed this when I was looking at the code for you. You'll notice this kind of warning quite often in the stdlib code since it was written before we had the warning. We're gradually cleaning them up.

Where a parameter can't be omitted (because of the way it's called) you can add /*unused*/ e.g. CHAR(wParam, lParam/*unused*/)
Last Edit: 2008/04/16 17:26 By andrew.
Re:underline option in NumberControl 2 Years, 4 Months ago
Yes. This shows how usefull red dots are.