VB6 implementation of customizing the font dialog for Windows to modify the font.

I didn't have time to upload the code for Kivi yesterday, so I'm doing it today. This is just for beginners in VB and Kivi. If anyone needs it, they can download and take a look. VB6 is a very old tool, but it is still necessary for undergraduate science students.

This is a very simple VB Form application that requires using the system's built-in font dialog and creating a custom font dialog to modify the font of a text area. The custom font dialog should have the same functionality as the system's font dialog.

You should be familiar with the font dialog, which allows you to modify the font name, size, boldness, italics, and other display effects of a VB control. Since it is commonly used, I won't provide a screenshot of the interface. The source code has detailed comments to facilitate Kivi's learning. If you have any questions after reading it, you can leave a comment and I will reply in the evening.

Download link for the source code:

Special code explanation:

Private Sub btn_comm_Click()
cmdDlg.Flags = 1 'Set the Flags flag to ****
cmdDlg.ShowFont 'Display the system font dialog
txtBox.Font.Name = cmdDlg.fontName 'Font name
txtBox.Font.Bold = cmdDlg.FontBold 'Bold?
txtBox.Font.Size = cmdDlg.FontSize 'Font size
txtBox.Font.Italic = cmdDlg.FontItalic 'Italic?
txtBox.Font.Underline = cmdDlg.FontUnderline 'Underline?
txtBox.Font.Strikethrough = cmdDlg.FontStrikethru 'Strikethrough
End Sub

I added the * line here. Before displaying the VB font dialog, you must set the flags parameter, otherwise you will get a font not found error.

The Flags property can be one of the following Visual Basic constants:
cdlCFScreenFonts (Screen fonts)
cdlCFPrinterFonts (Printer fonts)
cdlCFBoth (Both screen and printer fonts)

Another frustrating thing is that VB does not define the Font object. You can use Object instead. Here, I used direct assignment to make it easier for VB beginners. Kivi included!

For more information, you can refer to:

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.