|
-
Feb 27th, 2001, 01:27 PM
#1
Thread Starter
Fanatic Member
Here is the code that turns ur code to Microsoft Logo...I got it from my old floppy. I remember i copied it from a site but don't remember the site. Enjoy it
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private 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 Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function GetRgnBox Lib "gdi32" (ByVal hRgn As Long, lpRect As RECT) _
As Long
Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) 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 Const RGN_AND = 1
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject 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 Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private 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, hRgn1, hRgn1, RGN_AND
'Return the region handle
DeleteObject hRgn1
GetTextRgn = hRgn2
End Function
Private Sub Form_DblClick()
'Need to be able to close the form
Unload Me
End Sub
Private Sub Form_Load()
Dim hRgn As Long
Me.Font.Name = "Wingdings"
Me.Font.Size = 200
hRgn = GetTextRgn()
MsgBox "Remember, Double Click on Flag to Close Me", vbInformation
SetWindowRgn hwnd, hRgn, 1
End Sub
Private 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
Private Sub Timer1_Timer()
'Cycle the color of the form to give it and interesting look
Me.BackColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
Faisal Muhammed
Homepage:I Started making it in 1994 ...Still Under Construction  
Using
Visual Basic 6.0 Enterprise SP5
Embedded Visual Basic 3.0
SQL Server 2000
Windows 2000 Proff
Delphi 6.0
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-
Feb 27th, 2001, 02:30 PM
#2
Fanatic Member
that is very cool, i would be interrested if you can get other shapes to do that.
Very Cool
Later Days
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Feb 27th, 2001, 04:17 PM
#3
PowerPoster
You can make any shape you can think of with this program...
http://www.fortunecity.com/skyscrape...tml?VBSFC.html
-
Feb 27th, 2001, 04:49 PM
#4
Fanatic Member
yeah i already have that program, i also like the animated shaped form creatir that there is now, i meant is there any way to create microsoft related shapes like that, in the similar way that this one was created, faisalkm can you remeber where you got it from ??
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Feb 27th, 2001, 07:13 PM
#5
-
Feb 28th, 2001, 02:10 AM
#6
Thread Starter
Fanatic Member
-
Feb 28th, 2001, 03:17 AM
#7
Addicted Member
Hey, I've already seen that before....here is the few part of it....
*********************************************
Fly the Flag
VB4 32, VB5, VB6
Level: Advanced
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 Long
End Type
............................................
............................................
Private 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.
Ben Baird, Twin Falls, Idaho
********************************************
That is all....
However, you can make your form in any shape you like.
For example, to make your form like an ellipse try this one:
Option Explicit
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) 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 Sub Form_Load()
Dim Rgn As Long
MsgBox "Right-Click on the Title Bar to close the form!"
Rgn = CreateEllipticRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
SetWindowRgn Me.hWnd, Rgn, True
End Sub
'Alternatively you can also use CreateRectRgn to create a rectangular region.
'I do a have a function that makes the shape of
'your form into the shape of its picture. For example,
'your bitmap is a star shape bitmap with a background
'of white, this function will make your form looks
'like the bitmap floating on the desktop! If anyone,
'interested I will post it here.
 Stupidity is better than cure.
VB6 SP5 Enterprise Ed.
C, Pascal, VC++ 6.0
Running Win98 SE and Win2000 Prof. Ed.
Email me at : [email protected]
-
Mar 2nd, 2001, 11:44 AM
#8
Addicted Member
Originally posted by faisalkm
!!!!!!!!!!!!!!!Great......................
Any idea to put a border on this form?...to make it 3d?
Hey, faisalkm I have already post the functions. Chk this
thread.
http://forums.vb-world.net/showthrea...threadid=58374
 Stupidity is better than cure.
VB6 SP5 Enterprise Ed.
C, Pascal, VC++ 6.0
Running Win98 SE and Win2000 Prof. Ed.
Email me at : [email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|