Solved

How can i show a form oval shape at runtime

Posted on 2000-02-25
2
308 Views
Last Modified: 2006-11-17
How can i show a form oval shape at runtime
0
Comment
Question by:itacan
2 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 50 total points
ID: 2557874
From an answer previously given by Dalin:

Creating Win32 region windows
                       By AlMoataz B. Ahmed, AlMoataz_m@hotmail.com

                       The Win32 API includes a really amazing feature called
                       region windows. A window under Win32 no longer has to be
                       rectangular! In fact, it can be any shape that may be
                       constructed using Win32 region functions. Using the
                       SetWindowRgn Win32 function from within VB is so simple,
                       but the results are unbelievable. The following example
                       shows a VB form that is NOT rectangular. Enjoy!

                       ' This goes into the General Declarations section:
                         
                       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 SetWindowRgn Lib "user32" _
                       (ByVal hWnd As Long, ByVal hRgn As Long, _
                       ByVal bRedraw As Boolean) As Long
                         

                       Private Sub Form_Load()
                         Show 'The form!
                         SetWindowRgn hWnd, _
                         CreateEllipticRgn(0, 0, 300, 200), _
                         True
                       End Sub


0
 
LVL 13

Expert Comment

by:crazyman
ID: 2558623
'Make a New project. To the form Add a picture box And a Command button.

Option Explicit
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 SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long

Private Sub Form_Load()
    Dim hr&, dl&
    Dim usew&, useh&
    usew& = Me.Width / Screen.TwipsPerPixelX
    useh& = Me.Height / Screen.TwipsPerPixelY
    hr& = CreateEllipticRgn(0, 0, usew, useh)
    dl& = SetWindowRgn(Me.hWnd, hr, True)
End Sub
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now