Fly the Flag

Fly the Flag

The clock applet that comes with Microsoft Plus! has an interesting feature: Its window is round instead of rectangular. Surprisingly, giving your form an odd shape is easy. Add this code to a new form to give your window the shape of the Microsoft Windows logo:

 Private Type RECT	Left As Long	Top As Long	Right As Long	Bottom As LongEnd TypePrivate Declare Function BeginPath Lib "gdi32" _	(ByVal hdc As Long) As LongPrivate Declare Function TextOut Lib "gdi32" _	Alias "TextOutA" (ByVal hdc As Long, _	ByVal X As Long, ByVal Y As Long, _	ByVal lpString As String, _	ByVal nCount As Long) As LongPrivate Declare Function EndPath Lib "gdi32" _	(ByVal hdc As Long) As LongPrivate Declare Function PathToRegion Lib "gdi32" _	(ByVal hdc As Long) As LongPrivate Declare Function GetRgnBox Lib "gdi32" _	(ByVal hRgn As Long, lpRect As RECT) As LongPrivate Declare Function CreateRectRgnIndirect Lib "gdi32" _	(lpRect As RECT) As LongPrivate Declare Function CombineRgn Lib "gdi32" _	(ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, _	ByVal hSrcRgn2 As Long, _	ByVal nCombineMode As Long) As LongPrivate Const RGN_AND = 1Private Declare Function DeleteObject Lib "gdi32" _	(ByVal hObject As Long) As LongPrivate Declare Function SetWindowRgn Lib "user32" _	(ByVal hwnd As Long, ByVal hRgn As Long, _	ByVal bRedraw As Boolean) As LongPrivate Declare Function ReleaseCapture Lib "user32" _	() As LongPrivate Declare Function SendMessage Lib "user32" _	Alias "SendMessageA" (ByVal hwnd As Long, _	ByVal wMsg As Long, ByVal wParam As Long, _	lParam As Any) As LongPrivate Const WM_NCLBUTTONDOWN = &HA1Private Const HTCAPTION = 2Private Function GetTextRgn() As Long	Dim hRgn1 As Long, hRgn2 As Long	Dim rct As RECT	'Create a path for the window's shape	BeginPath hdc	TextOut hdc, 10, 10, Chr$(255), 1	EndPath hdc	'... Convert the path to a region...	hRgn1 = PathToRegion(hdc)	GetRgnBox hRgn1, rct	hRgn2 = CreateRectRgnIndirect(rct)	CombineRgn hRgn2, hRgn2, hRgn1, RGN_AND	'Return the region handle	DeleteObject hRgn1	GetTextRgn = hRgn2End FunctionPrivate Sub Form_DblClick()	'Need to be able to close the form	Unload MeEnd SubPrivate Sub Form_Load()	Dim hRgn As Long	Me.Font.Name = "Wingdings"	Me.Font.Size = 200	hRgn = GetTextRgn()	SetWindowRgn hwnd, hRgn, 1End SubPrivate Sub Form_MouseDown(Button As Integer, Shift _	As Integer, X As Single, Y As Single)	'Give us some way to move the form	ReleaseCapture	SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&End Sub

While this is a sort of novelty shape for a form, you can give a form any shape you want, provided you have a way to create the shape of the region. Look at the various region-related API calls to find methods of creating regions other than using font characters.

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