programming4us
programming4us
ENTERPRISE

Microsoft Dynamics AX 2009 : Building Lookups - Choosing a font

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
The Dynamics AX Options from Tools menu allows users to define their preferred fonts and sizes for various application areas. In custom functionality, it might also be necessary to add similar options allowing configuring font properties.

In this recipe, we will add an option to select a font in the Form setup form in the Accounts receivable module for sales invoice layout. The code in this recipe could be used in conjunction with the code that reads this parameter and actually changes invoice font.

How to do it...

  1. 1. Open the CustFormLetterParameters table in AOT.

  2. 2. Add a new field:

    Property Value
    Type String
    Name InvoiceFontName
    ExtendedDataType FontName

  1. 3. Add one more field:

    Property Value
    Type Integer
    Name InvoiceFontSize
    ExtendedDataType FontSize

  1. 4. Open the CustFormLetterParameters form in AOT, and add a new display method to the CustFormLetterParameters data source:

    display Name displayInvoiceFont(
    CustFormLetterParameters _custFormLetterParameters)
    
    {;
    if (CustFormLetterParameters.InvoiceFontName)
    {
    return strfmt(
    "%1, %2",
    _custFormLetterParameters.InvoiceFontName,
    _custFormLetterParameters.InvoiceFontSize);
    }
    return "";
    }
    
  2. 5. Add a new group to the Invoice tab page right after the GroupInvoice group:

    Property Value
    Name GroupFont
    Caption Font
    Columns 2
    Columnspace 0

  1. 6. Add a StringEdit control to the newly created group:

    Property Value
    Name InvoiceFont
    AutoDeclaration Yes
    Label Font name & size
    DataSource CustFormLetterParameters
    DataMethod displayInvoiceFont

  1. 7. Add a new Button to the same group:

    Property Value
    Name InvoiceFontLookup
    ButtonDisplay Image only
    NormalResource 2633

  1. 8. Override clicked() on the InvoiceFontLookup button with the following code:

    void clicked()
    
    {
    container font;
    ;
    font = WinAPI::chooseFont(
    element.hWnd(),
    SysFontType::ScreenFont,
    CustFormLetterParameters.InvoiceFontName,
    CustFormLetterParameters.invoiceFontSize);
    if (conlen(font))
    {
    CustFormLetterParameters.InvoiceFontName =
    conpeek(font,1);
    CustFormLetterParameters.InvoiceFontSize =
    conpeek(font,2);
    InvoiceFont.update();
    }
    }
    
  2. 9. Here is how it looks in AOT after all the modifications have been done:

  1. 10. To test the results, open Accounts receivable | Setup | Forms | Form Setup, and click on the Font lookup button on the Invoice tab page:

  1. 11. Upon its closure, the lookup fills in the Font name & size field with the selected values:

How it works...

First, we create two new fields in the CustFormLetterParameters table for storing font name and size. We use standard FontName and FontSize extended data types to make sure that the fields inherit the correct properties.

Next, we modify the CustFormLetterParameters form. We will be adding the Font name & size control, which is bound to the display method displayInvoiceFont(). The method resides on the CustFormLetterParameters form data source and is responsible for displaying font name and size in one line separated by a comma. In this way, we save some form layout space instead of displaying font name and size in separate fields.

Dynamics AX does not have a standard font control so we "fake" it by placing a StringEdit field followed by a Button control together in one form group. We need to set few of the group's properties to make sure it has two columns, and there is no space between group elements, so the user will see those two controls as one.

The last thing to do is to modify the button. To make sure that it looks exactly like existing Dynamics AX font controls, we change its properties so that the appearance changes to a small three dot button. The clicked() method has to be overridden with the code that calls the lookup. Here, we use chooseFont() method of WinAPI application class to display the standard Windows font selection dialog. This method accepts four arguments:

  1. 1. Current window handler.

  2. 2. Selection between screen or printer font.

  3. 3. Current font name, which will be preselected in the lookup.

  4. 4. Current font size, which will be preselected in the lookup.

The chooseFont() method returns a container of two elements, where the first one is font name and the second one is a size. Note that although the font selection dialog contains Font style section, the style is not returned by this method.

Other  
  •  Microsoft Dynamics AX 2009 : Building Lookups - Picking a color
  •  Microsoft Dynamics AX 2009 : Building Lookups - Selecting a file
  •  Programming .NET Components : Remoting - Leasing and Sponsorship (part 3) - Sponsorship Management
  •  Programming .NET Components : Remoting - Leasing and Sponsorship (part 2) - Providing a Sponsor, Leasing and Remote Activation Modes
  •  Programming .NET Components : Remoting - Leasing and Sponsorship (part 1) - Lease Properties, Configuring a Lease, Renewing a Lease
  •  DisplayPort 1.2 - Meet HDMI’s Smarter Brother
  •  HP ProLiant Servers AIS : Processors and Multiprocessing - The Processor Performance Evolution
  •  HP ProLiant Servers AIS : Processors and Multiprocessing - How Processors Work
  •  How To Get The Best From Your Batteries (Part 2)
  •  How To Get The Best From Your Batteries (Part 1)
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us