Welcome!

PowerBuilder Authors: Chris Pollach, Yeshim Deniz, Jayaram Krishnaswamy, Kevin Benedict, Avi Rosenthal

Related Topics: PowerBuilder

PowerBuilder: Article

Implementing the Microsoft Rich Edit Control

Part 1

The mousemove event contains three different blocks of code. One, not shown, implements the tooltip user object. The second one calls the of_backgroundon object method that determines which toolbar item (if any) is shown as shaded by making the filled box picture underneath it visible (see Listing 3). The third section of the mousemove event enables the mouseleave event. PowerBuilder doesn't have an event id mapped to the WM_MOUSELEAVE Windows message (the one fired when the mouse moves off a control), so we have to do a little work to access it. First, we set an instance variable (ib_mousemove) noting that the mousemove event has fired. Then we call the TrackMouseEvent Windows API function, telling it that the mouse event we're interested in is the WM_MOUSELEAVE event (the TrackMouseEvent lets us monitor more events than this, but this is the only one we need).

mousemove
integer li_x, li_y
s_trackmouseevent lstr_TRACKMOUSEEVENT

IF NOT ib_mouseover THEN
  ib_mouseover = TRUE
  lstr_TrackMouseEvent.cbSize = 16
  lstr_TrackMouseEvent.dwFlags = TME_LEAVE
  lstr_TrackMouseEvent.hwndTrack = Handle (This)
  lstr_TrackMouseEvent.dwHoverTime = 0
  TrackMouseEvent(lstr_TRACKMOUSEEVENT)
End If

The Windows API will now send that event to the control, but since there isn't an event id mapped to WM_MOUSELEAVE, it will be picked up in the "other" event of the control instead. So we monitor for that message in the other event, and call our custom "mouseleave" event from there.

other
CHOOSE CASE Message.Number
  CASE WM_MOUSELEAVE
   this.Event MouseLeave()
CASE ELSE
  //
END CHOOSE

Finally we turn off our instance variable in the mouseleave event, and then make sure that whichever background image was made visible (if any) is hidden.

mouseleave
ib_mouseover = FALSE

//Turn all the backgrounds off
this.object.p_bold_background.visible = 0
this.object.p_italic_background.visible = 0
this.object.p_underline_background.visible = 0
this.object.p_strikeout_background.visible = 0
this.object.p_alignleft_background.visible = 0
this.object.p_alignright_background.visible = 0
this.object.p_aligncenter_background.visible = 0
this.object.p_alignfull_background.visible = 0
this.object.p_spacingsingle_background.visible = 0
this.object.p_spacingoneandhalf_background.visible = 0
this.object.p_spacingdouble_background.visible = 0
this.object.p_spellcheck_background.visible = 0
this.object.p_textcolor_background.visible = 0

The u_toolbar control contains a couple of object functions that are intended to be called from outside the control. The of_setdefaults method was mentioned previously as the one that's used to set the font name and font size shown as the default in the dropdown list boxes. Note that the fontsize can be 0 (and the fontname an empty string) if the user has selected a block of text in the control that contains text that's in different fonts and/or different sizes.

of_setdefaults
IF this.RowCount() > 0 THEN
  this.object.fontname[1] = as_fontname
  IF ai_fontsize < 1 THEN
   this.object.fontsize[1] = ''
  ELSE
   this.object.fontsize[1] = String ( ai_fontsize )
  END IF
END IF

The of_setstaus method is used by the u_rte object to update the "selection" status of the toolbar items based on the current selection in the u_richedit control. The method simply shows (or hides) the picture control with the transparent box underneath the toolbar item based on its selected status.

of_setstatus
string ls_modify

IF ab_selected THEN
  ls_modify = as_object + '_box.visible=1'
ELSE
  ls_modify = as_object + '_box.visible=0'
END IF

this.Modify ( ls_modify )

Return 1

More Stories By Bruce Armstrong

Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.

More Stories By Demetrios Tsakiris

Demetrios Tsakiris is a senior programmer at Integrated Data Services. He has been working with PowerBuilder since version 5.0 and has a total of 5 1/2 years in the programming world. Demetrios is also an Oracle, Sybase, and Unix developer.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.