VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create a ying yang form

by Waty Thierry (60 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 30th March 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create a ying yang form

API Declarations


' * Programmer Name : Thomas Detoux
' * Web Site : http://www.vbasic.org/
' * E-Mail : [email protected]
' * Date : 8/12/98
' * Time : 14:41
' * Module Name : WingWang_Module
' * Module Filename : YingYang.bas
' **********************************************************************
' * Comments : Create YING YANG forms
' * Sample of call
' * Call YingYang(Me)
' *
' *
' **********************************************************************

Option Explicit

'Créé une region en forme de rectangle entre les points (X1,Y1) et (X2,Y2)
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

'Créé une région en forme d'éllipse entre les points (X1,Y1) et (X2,Y2)
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

'Combine deux régions pour en créer unr troisième selon le mode nCombineMode
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long

'Supprime un objet et libère de la mémoire
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

'Créé une feuille ayant la forme d'une région
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

'Constantes pour CombineRgn
Private Const RGN_AND = 1 'Intersection des deux régions
Private Const RGN_OR = 2 'Addition des deux régions
Private Const RGN_XOR = 3 'Difficile à décrire ... essayez
'En fait, c'est un XOR : l'addition des 2 régions
'en retirant les parties communes aux 2 régions
Private Const RGN_DIFF = 4 'Soustraction de la région 2 à la région 1
Private Const RGN_COPY = 5 'Copie la région 1

Private YY As Long


Rate Create a ying yang form



' * Programmer Name  : Thomas Detoux
' * Web Site         : http://www.vbasic.org/
' * E-Mail           : [email protected]
' * Date             : 8/12/98
' * Time             : 14:41
' * Module Name      : WingWang_Module
' * Module Filename  : YingYang.bas
' **********************************************************************
' * Comments         : Create YING YANG forms
' *  Sample of call
' *    Call YingYang(Me)
' *
' *
' **********************************************************************
Public Sub YingYang(obj As Form)
   
   'Déclaration des différents "handles" des différentes "régions" de la feuille, qui, réunies, formeront le Ying Yang
   Dim Cercle        As Long
   Dim Rect          As Long
   Dim PCercleH      As Long
   Dim PCercleB      As Long
   Dim HCercle       As Long
   Dim Cadre         As Long
   Dim TrouB         As Long
   Dim TrouH         As Long
   Dim CercleBis     As Long
   Dim HCercleBis    As Long
   Dim CercleBisBis  As Long
   Dim Ying_Yang     As Long
   Dim YYang         As Long
   
   Dim H             As Long
   Dim L             As Long
   Dim HBord         As Long
   Dim LBord         As Long
   Dim HT            As Long
   Dim LT            As Long
   
   H = obj.Height / Screen.TwipsPerPixelY
   L = obj.Width / Screen.TwipsPerPixelX
   
   HBord = Int(H / 100)
   LBord = Int(L / 100)
   
   HT = Int(H / 10)
   LT = Int(L / 10)
   
   'Création des différentes "régions", et combinaisons entre elles
   'Attention : pour réaliser une combinaison, la variable-région de destination
   'doit déjà avoir été intialisée en lui affectant une région auparavant.
   
   HCercle = CreateEllipticRgn(((L - (2 * LBord)) / 4) + LBord, ((H - (2 * HBord)) / 2) + HBord, 3 * (((L - (2 * LBord)) / 4) + LBord), (H - HBord))
   Cercle = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   Rect = CreateRectRgn(L / 2, 0, L, H)
   CombineRgn HCercle, Cercle, Rect, RGN_DIFF
   
   HCercleBis = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   PCercleB = CreateEllipticRgn(((L - (2 * LBord)) / 4) + LBord, ((H - (2 * HBord)) / 2) + HBord, 3 * (((L - (2 * LBord)) / 4) + LBord), (H - HBord))
   CombineRgn HCercleBis, HCercle, PCercleB, RGN_DIFF
   
   CercleBis = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   PCercleH = CreateEllipticRgn(((L - (2 * LBord)) / 4) + LBord, HBord, 3 * (((L - (2 * LBord)) / 4) + LBord), ((H - (2 * HBord)) / 2) + HBord)
   CombineRgn CercleBis, Cercle, PCercleH, RGN_DIFF
   
   CercleBisBis = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   HCercle = CreateEllipticRgn(0, 0, L, H)
   CombineRgn CercleBisBis, CercleBis, HCercleBis, RGN_DIFF
   
   Ying_Yang = CreateEllipticRgn(0, 0, L, H)
   Cadre = CreateEllipticRgn(0, 0, L, H)
   CombineRgn Ying_Yang, Cadre, CercleBisBis, RGN_DIFF
   
   YYang = CreateEllipticRgn(0, 0, L, H)
   TrouB = CreateEllipticRgn(((L - (2 * LBord)) / 2) + LBord - (LT / 2), ((3 * (H - (2 * HBord)) / 4)) + HBord - (HT / 2), ((L - (2 * LBord)) / 2) + LBord + (LT / 2), ((3 * (H - (2 * HBord)) / 4)) + HBord + (HT / 2))
   CombineRgn YYang, Ying_Yang, TrouB, RGN_OR
   
   YY = CreateEllipticRgn(0, 0, L, H)
   TrouH = CreateEllipticRgn(((L - (2 * LBord)) / 2) + LBord - (LT / 2), ((H - (2 * HBord)) / 4) + HBord - (HT / 2), ((L - (2 * LBord)) / 2) + LBord + (LT / 2), ((H - (2 * HBord)) / 4) + HBord + (HT / 2))
   CombineRgn YY, YYang, TrouH, RGN_DIFF
   
   SetWindowRgn obj.hwnd, YY, True 'Applique la région finale à la feuille
   
   'Suppression des régions
   DeleteObject Cercle
   DeleteObject Rect
   DeleteObject PCercleH
   DeleteObject PCercleB
   DeleteObject HCercle
   DeleteObject Cadre
   DeleteObject TrouB
   DeleteObject TrouH
   DeleteObject CercleBis
   DeleteObject HCercleBis
   DeleteObject CercleBisBis
   DeleteObject Ying_Yang
   DeleteObject YYang

End Sub



Download this snippet    Add to My Saved Code

Create a ying yang form Comments

No comments have been posted about Create a ying yang form. Why not be the first to post a comment about Create a ying yang form.

Post your comment

Subject:
Message:
0/1000 characters