Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2005, 11:07 AM
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with form layout

Is it possible to change the shape of a form using vb ?

 
Old February 15th, 2005, 12:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Yup. Takes lots of Windows API calls though. Check this out. Drew on the Database Advisor's forum wrote it.

Create a form and add the following event handlers behind two command buttons.

Private Sub Command0_Click()
    HoleOutForm Me.hwnd
    DoCmd.Close acForm, Me.Name
End Sub

Private Sub Command1_Click()
    HoleOutForm Application.hWndAccessApp
    DoCmd.Quit
End Sub

Then add this to a standard module, open the form, click the buttons, and be amazed! Works in A2K2 for sure:

Option Compare Database

Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, _
ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Declare Function CreateEllipticRgn Lib _
"gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 _
As Long) As Long

Private Declare Function CombineRgn Lib "gdi32" (ByVal _
hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal _
nCombineMode As Long) As Long

Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, _
    ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 _
    As Long) As Long

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Const RGN_XOR = 3

Function HoleOutForm(ByVal intHwnd As Long)
    Dim X As Long
    Dim rt As RECT
    Dim rtCircle As RECT
    Dim dwReturn As Long
    Dim InitialRegion As Long
    Dim i As Long
    Dim intMax As Long
    dwReturn = GetWindowRect(intHwnd, rt)
    rt.Bottom = rt.Bottom - rt.Top
    rt.Top = 0
    rt.Right = rt.Right - rt.Left
    rt.Left = 0
    InitialRegion = CreateRectRgn(rt.Left, rt.Top, rt.Right, rt.Bottom)
    rtCircle.Bottom = ((rt.Bottom - rt.Top) / 2) + rt.Top + 1
    rtCircle.Top = ((rt.Bottom - rt.Top) / 2) + rt.Top - 1
    rtCircle.Right = ((rt.Right - rt.Left) / 2) + rt.Left + 1
    rtCircle.Left = ((rt.Right - rt.Left) / 2) + rt.Left - 1
    If rt.Bottom > rt.Right Then
        intMax = rt.Bottom
    Else
        intMax = rt.Right
    End If
    For i = 1 To intMax
        X = CreateEllipticRgn(rtCircle.Left, rtCircle.Top, rtCircle.Right, _
    rtCircle.Bottom)
        InitialRegion = CreateRectRgn(rt.Left, rt.Top, rt.Right, rt.Bottom)
        dwReturn = CombineRgn(InitialRegion, InitialRegion, X, RGN_XOR)
        SetMainWindowRegion InitialRegion, intHwnd
        rtCircle.Bottom = rtCircle.Bottom + 1
        rtCircle.Top = rtCircle.Top - 1
        rtCircle.Left = rtCircle.Left - 1
        rtCircle.Right = rtCircle.Right + 1
        DeleteObject X
        DeleteObject InitialRegion
    Next i
    DeleteObject X
    DeleteObject InitialRegion
End Function

Private Function SetMainWindowRegion(cRgn As Long, intHwnd As Long)
    Dim dwReturn As Long
    dwReturn = SetWindowRgn(intHwnd, cRgn, True)
End Function








Similar Threads
Thread Thread Starter Forum Replies Last Post
Form layout lisabb ASP.NET 2.0 Basics 1 May 25th, 2007 12:19 PM
Layout problem roy_mm Reporting Services 1 September 28th, 2006 03:43 PM
datalist layout silverfox_1188 Classic ASP Components 0 May 11th, 2005 04:16 PM
layout adflynn Java GUI 0 November 9th, 2004 06:33 AM
Table Layout benskywalker Dreamweaver (all versions) 3 October 22nd, 2003 11:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.