Skip to main content

[archive] Attempting to modify a font in an ActiveX

  • February 15, 2010
  • 2 replies
  • 0 views

[Migrated content. Thread originally posted on 15 February 2010]

We are using a CheckListBox ActiveX Control which seems to work pretty well.
The problem is, we want the font to match the other controls on the screen.
In the VB examples that came with the control they call the windows font dialog box then move the font object to the control. I tried to simulate this using a call to W$FONT with no effect.

The .def looks like this:

*[Class: @_DCheckListBox] Font
* Returns a Font object.
PROPERTY-GET, -512, @Font
RETURNING "Font*", TYPE 9
*[Class: @_DCheckListBox] Font
* Returns a Font object.
PROPERTY-PUT, -512, @Font,
"Font* (Property_Value)", TYPE 9

I have tried this:

77 list-font handle of font.

display CheckListBox
handle in ChkList-handle
line 2 col 5 lines 3 size 22
visible 1
EVENT PROCEDURE IS ChkList-EVENT.

inquire ChkList-handle @Font() in list-font.

* initialize wfont-data.
call "w$font" using WFONT-CHOOSE-FONT, list-font,
wfont-data giving wfont-status.

MODIFY ChkList-handle @Font(list-font).

This is how they do it in VB.net:

' Change the font property of the CheckListBox control
Private Sub btnFont_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnFont.Click
FontDialog1.Color = ChkList1.ForeColor
FontDialog1.Font = ChkList1.Font
FontDialog1.ShowDialog()
If FontDialog1.Font.Name <> "" Then
ChkList1.Font = FontDialog1.Font
ChkList1.ForeColor = FontDialog1.Color
End If
End Sub

We do not use Acubench.
Any ideas would be greatly appreciated.

Thanks,
Steve

2 replies

[Migrated content. Thread originally posted on 15 February 2010]

We are using a CheckListBox ActiveX Control which seems to work pretty well.
The problem is, we want the font to match the other controls on the screen.
In the VB examples that came with the control they call the windows font dialog box then move the font object to the control. I tried to simulate this using a call to W$FONT with no effect.

The .def looks like this:

*[Class: @_DCheckListBox] Font
* Returns a Font object.
PROPERTY-GET, -512, @Font
RETURNING "Font*", TYPE 9
*[Class: @_DCheckListBox] Font
* Returns a Font object.
PROPERTY-PUT, -512, @Font,
"Font* (Property_Value)", TYPE 9

I have tried this:

77 list-font handle of font.

display CheckListBox
handle in ChkList-handle
line 2 col 5 lines 3 size 22
visible 1
EVENT PROCEDURE IS ChkList-EVENT.

inquire ChkList-handle @Font() in list-font.

* initialize wfont-data.
call "w$font" using WFONT-CHOOSE-FONT, list-font,
wfont-data giving wfont-status.

MODIFY ChkList-handle @Font(list-font).

This is how they do it in VB.net:

' Change the font property of the CheckListBox control
Private Sub btnFont_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnFont.Click
FontDialog1.Color = ChkList1.ForeColor
FontDialog1.Font = ChkList1.Font
FontDialog1.ShowDialog()
If FontDialog1.Font.Name <> "" Then
ChkList1.Font = FontDialog1.Font
ChkList1.ForeColor = FontDialog1.Color
End If
End Sub

We do not use Acubench.
Any ideas would be greatly appreciated.

Thanks,
Steve
Steve,

You have to use the activex font definition found in acuclass.def. Below is an example I used for an activex grid control. We had the font definition stored in a file and just recalled it for the grid (using W$font).

Rob



01 GRID-FONT-HANDLE       HANDLE OF IFONTDISP.

...

Initialize Wfont-data
Call "w$font" Using Wfont-describe-font, Grid-font, Wfont-data
   Giving ws-status.
If Ws-status = 1
  Inquire grid-handle @font In Grid-font-handle
  Modify Grid-font-handle
           @name = Wfont-name
           @size = Wfont-size
           @bold = Wfont-bold-state
           @underline = Wfont-underline-state
           @italic = Wfont-italic-state
           @strikethrough = Wfont-strikeout-state
           @charset = Wfont-char-set
  Destroy grid-font-handle
End-if.

[Migrated content. Thread originally posted on 15 February 2010]

We are using a CheckListBox ActiveX Control which seems to work pretty well.
The problem is, we want the font to match the other controls on the screen.
In the VB examples that came with the control they call the windows font dialog box then move the font object to the control. I tried to simulate this using a call to W$FONT with no effect.

The .def looks like this:

*[Class: @_DCheckListBox] Font
* Returns a Font object.
PROPERTY-GET, -512, @Font
RETURNING "Font*", TYPE 9
*[Class: @_DCheckListBox] Font
* Returns a Font object.
PROPERTY-PUT, -512, @Font,
"Font* (Property_Value)", TYPE 9

I have tried this:

77 list-font handle of font.

display CheckListBox
handle in ChkList-handle
line 2 col 5 lines 3 size 22
visible 1
EVENT PROCEDURE IS ChkList-EVENT.

inquire ChkList-handle @Font() in list-font.

* initialize wfont-data.
call "w$font" using WFONT-CHOOSE-FONT, list-font,
wfont-data giving wfont-status.

MODIFY ChkList-handle @Font(list-font).

This is how they do it in VB.net:

' Change the font property of the CheckListBox control
Private Sub btnFont_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnFont.Click
FontDialog1.Color = ChkList1.ForeColor
FontDialog1.Font = ChkList1.Font
FontDialog1.ShowDialog()
If FontDialog1.Font.Name <> "" Then
ChkList1.Font = FontDialog1.Font
ChkList1.ForeColor = FontDialog1.Color
End If
End Sub

We do not use Acubench.
Any ideas would be greatly appreciated.

Thanks,
Steve
Rob,

Thanks so much! That worked like a charm.

Thanks,
Steve