How does the MessageView control work?

Post your Gambas programming questions here.
User avatar
stevedee
Posts: 378
Joined: Monday 20th March 2017 6:06pm

How does the MessageView control work?

Post by stevedee » Wednesday 03rd February 2021 2:16pm

Just out of curiosity, does anyone know how you are supposed to use the MessageView control?

Its not a problem getting it to display a single message, but the help file says;
"Messages are displayed successively, and the message panel is closed only when there is no message to read anymore."

This makes me think it should have a string array associated with it, but if you just write code like this;
  MessageView1.Border = True
  MessageView1.Open("My 1st message")
  MessageView1.Open("My 2nd message")
  MessageView1.Open("My 3rd message")
...it will display the first message along with a "next" button but not show subsequent messages.

Using the Object Inspector does not show were these messages are held within MessageView.

User avatar
PJBlack
Posts: 103
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: How does the MessageView control work?

Post by PJBlack » Wednesday 03rd February 2021 3:05pm

didn't get it to work :(

but maybe ...
MessageView1.Border = True
MessageView1.Open("My 1st message")
MessageView1.Close
MessageView1.Open("My 2nd message")
MessageView1.Close
MessageView1.Open("My 3rd message")
MessageView1.Close

User avatar
cogier
Site Admin
Posts: 646
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How does the MessageView control work?

Post by cogier » Wednesday 03rd February 2021 5:54pm

PJBlack wrote:
Wednesday 03rd February 2021 3:05pm
didn't get it to work :(
Nor me, came up with a similar solution.

User avatar
BruceSteers
Posts: 390
Joined: Thursday 23rd July 2020 5:20pm

Re: How does the MessageView control work?

Post by BruceSteers » Wednesday 03rd February 2021 6:23pm

i had a play.

It works as expected if you also give the icon argument.

MessageView1.Border = True
MessageView1.Open("My 1st message", Picture["icon:/48/ok"])
MessageView1.Open("My 2nd message", Picture["icon:/48/ok"])
MessageView1.Open("My 3rd message", Picture["icon:/48/ok"])

possibly a bug worth reporting?

the control passes the optional icon argument like this ..
  $hIcon = Icon
  If Not Icon Then 
    Try $hIcon = Picture["icon:/32/warning"]
    If Error Then $hIcon = Picture["img/32/warning.png"]
  Endif
that looks okay to me.

the line that fails is in DoOpen()
 $H = Max($hIcon.H + Desktop.Scale * 2, Me.Font.RichTextHeight($sText, GetTextWidth()) + Desktop.Scale * 4)
the Warning icon shows if no icon argument is given so where it's going wrong i have no idea :-\
Last edited by BruceSteers on Wednesday 03rd February 2021 6:34pm, edited 1 time in total.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
stevedee
Posts: 378
Joined: Monday 20th March 2017 6:06pm

Re: How does the MessageView control work?

Post by stevedee » Wednesday 03rd February 2021 6:31pm

BruceSteers wrote:
Wednesday 03rd February 2021 6:23pm
i had a play.

It works as expected if you also give the icon argument...
Thanks Bruce, I came to the same conclusion about half an hour ago.

I'm still trying to work out where the text is stacked, thought it would be in a Children object.

User avatar
BruceSteers
Posts: 390
Joined: Thursday 23rd July 2020 5:20pm

Re: How does the MessageView control work?

Post by BruceSteers » Wednesday 03rd February 2021 6:39pm

stevedee wrote:
Wednesday 03rd February 2021 6:31pm
BruceSteers wrote:
Wednesday 03rd February 2021 6:23pm
i had a play.

It works as expected if you also give the icon argument...
Thanks Bruce, I came to the same conclusion about half an hour ago.

I'm still trying to work out where the text is stacked, thought it would be in a Children object.
nah looking at the code it's in a private string list..

Private $aText As New String[]
Private $aIcon As New Picture[]

https://gitlab.com/gambas/gambas/-/blob ... View.class

BruceS
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
stevedee
Posts: 378
Joined: Monday 20th March 2017 6:06pm

Re: How does the MessageView control work?

Post by stevedee » Wednesday 03rd February 2021 6:42pm

BruceSteers wrote:
Wednesday 03rd February 2021 6:23pm
...possibly a bug worth reporting?...
The help information is correct, in that it does NOT indicate that the image icon is optional...so my stupidity created the problem. Just surprised that the IDE did not protect me from myself by raising a syntax error. :o

User avatar
BruceSteers
Posts: 390
Joined: Thursday 23rd July 2020 5:20pm

Re: How does the MessageView control work?

Post by BruceSteers » Wednesday 03rd February 2021 6:56pm

stevedee wrote:
Wednesday 03rd February 2021 6:42pm
BruceSteers wrote:
Wednesday 03rd February 2021 6:23pm
...possibly a bug worth reporting?...
The help information is correct, in that it does NOT indicate that the image icon is optional...so my stupidity created the problem. Just surprised that the IDE did not protect me from myself by raising a syntax error. :o
No it's a bug.

I just submitted a fix for Ben.
https://gitlab.com/bsteers4/gambas/-/co ... e22bcf621a

checking if an icon argument had been passed and setting the default happened "after" this bit of code...

 If Me.Visible Then
    
    $aText.Add(Text)
    $aIcon.Add(Icon)
    UpdateButton
    Return

  Endif

so in that instance the default icon had not been set.
i moved the default icon setting bit to up before that code and changed Icon to $hIcon.
if Ben thinks the fix is good it will soon be all better :)

Bruce.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
stevedee
Posts: 378
Joined: Monday 20th March 2017 6:06pm

Re: How does the MessageView control work?

Post by stevedee » Wednesday 03rd February 2021 7:05pm

BruceSteers wrote:
Wednesday 03rd February 2021 6:56pm
...No it's a bug.

I just submitted a fix for Ben.
https://gitlab.com/bsteers4/gambas/-/co ... e22bcf621a
Bruce you are a star!

Many thanks for taking the time to look at this.

User avatar
BruceSteers
Posts: 390
Joined: Thursday 23rd July 2020 5:20pm

Re: How does the MessageView control work?

Post by BruceSteers » Wednesday 03rd February 2021 8:43pm

stevedee wrote:
Wednesday 03rd February 2021 7:05pm
BruceSteers wrote:
Wednesday 03rd February 2021 6:56pm
...No it's a bug.

I just submitted a fix for Ben.
https://gitlab.com/bsteers4/gambas/-/co ... e22bcf621a
Bruce you are a star!

Many thanks for taking the time to look at this.
Happy to help 😎
The commit has been merged already so its all fixed now 😊
I'm happy I've helped you and saved Ben a little time. All is good 🙂
Wishing well
Bruce

If at first you don't succeed , try it differently.

Post Reply