PrintRotatedText – Display a rotated message

PrintRotatedText – Display a rotated message

Const LF_FACESIZE = 32Private Type LOGFONT    lfHeight As Long    lfWidth As Long    lfEscapement As Long    lfOrientation As Long    lfWeight As Long    lfItalic As Byte    lfUnderline As Byte    lfStrikeOut As Byte    lfCharSet As Byte    lfOutPrecision As Byte    lfClipPrecision As Byte    lfQuality As Byte    lfPitchAndFamily As Byte    lfFaceName As String * LF_FACESIZEEnd TypePrivate Declare Function SetGraphicsMode Lib "gdi32" (ByVal hdc As Long, _    ByVal iMode As Long) As LongPrivate Declare Function MulDiv Lib "Kernel32" (ByVal nNumber As Long, _    ByVal nNumerator As Long, ByVal nDenominator As Long) As LongPrivate Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _    ByVal nIndex As Long) As LongPrivate Declare Function CreateFontIndirect Lib "gdi32" Alias _    "CreateFontIndirectA" (lpLogFont As LOGFONT) As LongPrivate Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _    ByVal hObject As Long) As LongPrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As _    LongPrivate Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (dest As _    Any, Source As Any, ByVal bytes As Long)' Print rotated text' The first argoment can be a form, a picture box, the Printer, and in general' any VB object that supports the Font and the hDC properties.' Text is the string to be printed' Angle is the orientation, in 10th of degrees (default is 90°)' X and Y are the printing coordinates (omit to use the current coordinates)'' Note: you get best results when using TrueType fontsSub PrintRotatedText(PB As Object, ByVal Text As String, _    Optional ByVal Angle As Integer = -900, Optional x As Variant, _    Optional y As Variant)    Dim hfont As Long, holdfont As Long    Dim Font As LOGFONT       Const GM_ADVANCED = 2    Const LOGPIXELSY = 90    SetGraphicsMode PB.hdc, GM_ADVANCED        ' Create a Font object, similar to the current font in PB    ' but with a different orientation    Font.lfHeight = -MulDiv(PB.FontSize, GetDeviceCaps(PB.hdc, LOGPIXELSY), 72)    Font.lfWidth = 0    Font.lfEscapement = Angle    Font.lfOrientation = Angle    Font.lfWeight = IIf(PB.FontBold, 700, 400)    Font.lfItalic = IIf(PB.FontItalic, 1, 0)    Font.lfUnderline = IIf(PB.FontUnderline, 1, 0)    Font.lfStrikeOut = IIf(PB.FontStrikethru, 1, 0)    Font.lfCharSet = 0    Font.lfOutPrecision = 0    Font.lfClipPrecision = 0    Font.lfQuality = 2    Font.lfPitchAndFamily = 33    Font.lfFaceName = PB.FontName & vbNullChar        hfont = CreateFontIndirect(Font)    holdfont = SelectObject(PB.hdc, hfont)        ' Account for X,Y coordinates    If Not IsMissing(x) Then PB.CurrentX = x    If Not IsMissing(y) Then PB.CurrentY = y        ' do the printing    PB.Print Text    ' reselect the old font    SelectObject PB.hdc, holdfont     ' destroy the font object just created    DeleteObject hfontEnd Sub

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as