Program Backgrounds - basic.visual
This is a discussion on Program Backgrounds - basic.visual ; Hi,
A client has requested that I change the design of the program to something
similar to the following:
http://www.mhims.co.uk/PROGRAM%20BACKGROUND.jpg
http://www.mhims.co.uk/PROGRAM%20BACKGROUND2.jpg
Can I use VB6 to create this? I was thinking about making it in flash and
then using the ...
-
Program Backgrounds
Hi,
A client has requested that I change the design of the program to something
similar to the following:
http://www.mhims.co.uk/PROGRAM%20BACKGROUND.jpg
http://www.mhims.co.uk/PROGRAM%20BACKGROUND2.jpg
Can I use VB6 to create this? I was thinking about making it in flash and
then using the flash component in VB6 on a form set as transparent.
Or should I be looking to change language?
Cheers,
Michael
-
Re: Program Backgrounds
"Michael" <mqiqcqhqaqeqlqhqiqmqsq@qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> wrote
in message news:7AO1h.138577$3D1.88321@fe3.news.blueyonder.co.uk...
> A client has requested that I change the design of the program
> to something similar to the following:
> http://www.mhims.co.uk/PROGRAM%20BACKGROUND.jpg
> Can I use VB6 to create this?
I'm not sure what you mean. Do you mean that you want to create a
irregularly shaped Form? If so then you certainly can do it in VB6. There
are all sorts of different methods to choose from. For example you can use
the various Region APIs to create regions of various shapes and you can
combine a number of different regions in a number of different ways.
Alternatively if you want to make a Form the shape of a supplied bitmap you
can create the bitmap (in a paint package or something) using white pixels
for the "invisible areas" and then write your Form Load code so that it runs
through the bitmap scan lines creating regions and adding them together to
form a composite region the same shape as the bitmap. Your code can then
assign the bitmap picture to the Form's Picture property and you'll end up
with a Form the same shape as the parts of the bitmap that are not white.
Another method is to use the various drawing functions inside a BeginPath
and EndPath loop. This method works best in versions of Windows later than
Win98. Here is an example of the latter method (BeginPath and EndPath).
Start a new VB project (just one Form) and at design time set the Form's
BorderStyle property to None in the properties window. Then paste in the
following code and run the program:
Mike
Option Explicit
Private Declare Function BeginPath Lib "gdi32" _
(ByVal hdc 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 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 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, ByVal lParam As Any) As Integer
Private Declare Function RoundRect Lib "gdi32" _
(ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long, _
ByVal X3 As Long, ByVal Y3 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
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Form_Load()
' Note: The BeginPath / EndPath stuff doesn't work too well
' under Win98. It deals with text okay but not with rounded
' rectangles and circles and stuff. So in Win98 use CreateRgn
' and CombineRgn APIs instead.
Dim s1 As String, NewRgn As Long
s1 = "Rum and Coke"
With Me
.ScaleMode = vbPixels
.BackColor = vbMagenta
.Font.Name = "Times New Roman"
.Font.Italic = True
.Font.Bold = True
.Font.Size = 72
.Width = .ScaleX(.TextWidth(s1) + 20, vbPixels, vbTwips)
.Height = .ScaleY(.TextHeight(s1), vbPixels, vbTwips)
End With
BeginPath Me.hdc
RoundRect Me.hdc, 0, 0, Me.ScaleWidth, Me.ScaleHeight, 30, 30
TextOut Me.hdc, 10, 0, s1, Len(s1)
EndPath Me.hdc
NewRgn = PathToRegion(Me.hdc)
SetWindowRgn Me.hwnd, NewRgn, True
DeleteObject NewRgn
End Sub
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Form_DblClick()
Unload Me
End Sub
-
Re: Program Backgrounds
I've done these with VB5 :-)
http://i145.photobucket.com/albums/r...h/SyncTime.gif
http://i145.photobucket.com/albums/r...ish/vPoker.gif
http://i145.photobucket.com/albums/r...sh/vPoker2.gif
http://i145.photobucket.com/albums/r...sh/vPoker3.gif
Basically, just a bunch of graphics, subclassing for titlebar stuff, etc.
UserControls for the buttons (the buttons themselves are images),
checkboxes, option buttons, first one's titlebar. For the rounded off
corners of the vPoker ones, "region" code similar to what Mike posted.
Also, you have to account for standard Winders functionalities, like
left-clicking on titlebar icon, keyboard navigation, etc. And if you use
controls such as listboxes and combos, you may have to delve into the world
of owner-drawn controls to retain aesthetics.
A lot of work, both in VB and outside of VB, to make a "pretty" GUI. But
once you have things worked out, and do things wisely like using
UserControls and such, it's easier to implement in other projects from a VB
standpoint (still gotta do the graphics though).
"Michael" <mqiqcqhqaqeqlqhqiqmqsq@qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> wrote
in message news:7AO1h.138577$3D1.88321@fe3.news.blueyonder.co.uk...
> Hi,
>
> A client has requested that I change the design of the program to
something
> similar to the following:
> http://www.mhims.co.uk/PROGRAM%20BACKGROUND.jpg
> http://www.mhims.co.uk/PROGRAM%20BACKGROUND2.jpg
>
> Can I use VB6 to create this? I was thinking about making it in flash and
> then using the flash component in VB6 on a form set as transparent.
>
> Or should I be looking to change language?
>
> Cheers,
>
> Michael
-
Re: Program Backgrounds
"Mike Williams" <mike@WhiskyAndCoke.com> wrote in message
news:ei8gfa$ri4$1@web.aioe.org...
> "Michael" <mqiqcqhqaqeqlqhqiqmqsq@qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> wrote
> in message news:7AO1h.138577$3D1.88321@fe3.news.blueyonder.co.uk...
>
>> A client has requested that I change the design of the program
>> to something similar to the following:
>> http://www.mhims.co.uk/PROGRAM%20BACKGROUND.jpg
>> Can I use VB6 to create this?
>
> I'm not sure what you mean. Do you mean that you want to create a
> irregularly shaped Form? If so then you certainly can do it in VB6. There
> are all sorts of different methods to choose from. For example you can use
> the various Region APIs to create regions of various shapes and you can
> combine a number of different regions in a number of different ways.
> Alternatively if you want to make a Form the shape of a supplied bitmap
> you can create the bitmap (in a paint package or something) using white
> pixels for the "invisible areas" and then write your Form Load code so
> that it runs through the bitmap scan lines creating regions and adding
> them together to form a composite region the same shape as the bitmap.
> Your code can then assign the bitmap picture to the Form's Picture
> property and you'll end up with a Form the same shape as the parts of the
> bitmap that are not white. Another method is to use the various drawing
> functions inside a BeginPath and EndPath loop. This method works best in
> versions of Windows later than Win98. Here is an example of the latter
> method (BeginPath and EndPath). Start a new VB project (just one Form) and
> at design time set the Form's BorderStyle property to None in the
> properties window. Then paste in the following code and run the program:
>
> Mike
>
> Option Explicit
> Private Declare Function BeginPath Lib "gdi32" _
> (ByVal hdc 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 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 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, ByVal lParam As Any) As Integer
> Private Declare Function RoundRect Lib "gdi32" _
> (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
> ByVal X2 As Long, ByVal Y2 As Long, _
> ByVal X3 As Long, ByVal Y3 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
> Const WM_NCLBUTTONDOWN = &HA1
> Const HTCAPTION = 2
>
> Private Sub Form_Load()
> ' Note: The BeginPath / EndPath stuff doesn't work too well
> ' under Win98. It deals with text okay but not with rounded
> ' rectangles and circles and stuff. So in Win98 use CreateRgn
> ' and CombineRgn APIs instead.
> Dim s1 As String, NewRgn As Long
> s1 = "Rum and Coke"
> With Me
> .ScaleMode = vbPixels
> .BackColor = vbMagenta
> .Font.Name = "Times New Roman"
> .Font.Italic = True
> .Font.Bold = True
> .Font.Size = 72
> .Width = .ScaleX(.TextWidth(s1) + 20, vbPixels, vbTwips)
> .Height = .ScaleY(.TextHeight(s1), vbPixels, vbTwips)
> End With
> BeginPath Me.hdc
> RoundRect Me.hdc, 0, 0, Me.ScaleWidth, Me.ScaleHeight, 30, 30
> TextOut Me.hdc, 10, 0, s1, Len(s1)
> EndPath Me.hdc
> NewRgn = PathToRegion(Me.hdc)
> SetWindowRgn Me.hwnd, NewRgn, True
> DeleteObject NewRgn
> End Sub
>
> Private Sub Form_MouseDown(Button As Integer, _
> Shift As Integer, X As Single, Y As Single)
> ReleaseCapture
> SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
> End Sub
>
> Private Sub Form_DblClick()
> Unload Me
> End Sub
>
Thanks guys....
Is there anyway to use a picture box with rounded corners?
I'd like to stick with the 'rounded' look but would prefer a gradient in the
background, and was wondering if i could use a rounded picrture box and
display the background of my choice in it...Or is there a better way?
Sorry if it's confusing but it's kinda hard to explain :-)
Cheers,
Michael
-
Re: Program Backgrounds
Michael wrote:
> Thanks guys....
> Is there anyway to use a picture box with rounded corners?
> I'd like to stick with the 'rounded' look but would prefer a
> gradient in the background, and was wondering if i could use
> a rounded picrture box and display the background of my
> choice in it...Or is there a better way?
Rather than ask for things like "Picture Box with rounded corners" I
think you would be better off explaining *in detail* exactly what it is
you want to do (without mentioning specific controls). Forget about
programming. Just explain your requirements in standard English. There
will probably be lots of different ways of achieving your aims. For
example, you can create a Form of any shape you desire (the exact shape
of a specific bmp file for example, with the white parts transparent)
and after you have created the Form in the desired shape you can then
assign the bmp to the Form's Picture property. This will result in a
Form that looks exactly like your bmp file, in effect a bmp image that
looks just like the bmp you used, but which is in fact a VB Form, that
you can drag around the display and on which you can place whatever
Controls you want. If you can post an email address (create a "throw
away" Yahoo email address specifically for the purpose if you wish)
I'll send you some VB code that includes the appropriate bitmap to show
what I mean.
Mike
-
Re: Program Backgrounds
"Mike Williams" <gagamomo@yahoo.co.uk> wrote in message
news:1162417974.750888.73990@h48g2000cwc.googlegroups.com...
>
> Michael wrote:
>
>> Thanks guys....
>> Is there anyway to use a picture box with rounded corners?
>> I'd like to stick with the 'rounded' look but would prefer a
>> gradient in the background, and was wondering if i could use
>> a rounded picrture box and display the background of my
>> choice in it...Or is there a better way?
>
> Rather than ask for things like "Picture Box with rounded corners" I
> think you would be better off explaining *in detail* exactly what it is
> you want to do (without mentioning specific controls). Forget about
> programming. Just explain your requirements in standard English. There
> will probably be lots of different ways of achieving your aims. For
> example, you can create a Form of any shape you desire (the exact shape
> of a specific bmp file for example, with the white parts transparent)
> and after you have created the Form in the desired shape you can then
> assign the bmp to the Form's Picture property. This will result in a
> Form that looks exactly like your bmp file, in effect a bmp image that
> looks just like the bmp you used, but which is in fact a VB Form, that
> you can drag around the display and on which you can place whatever
> Controls you want. If you can post an email address (create a "throw
> away" Yahoo email address specifically for the purpose if you wish)
> I'll send you some VB code that includes the appropriate bitmap to show
> what I mean.
>
> Mike
>
Thanks Mike, that's essentially what I'm trying to get.
My address - (remove SPA): johnSPAhh@blueyonder.co.uk
Cheers,
Michael
-
Re: Program Backgrounds
"Michael" <mqiqcqhqaqeqlqhqiqmqsq@qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> wrote
in message news:xmq2h.45878$r61.31258@text.news.blueyonder.co.uk...
> Thanks Mike, that's essentially what I'm trying to get.
Okay. Example project on the way to you.
Mike
-
Re: Program Backgrounds
FAO Mike Williams.
Hi Mike,
I have been reading your replies on this subject and I think it could help
me.
Does VB5 support the region function?
I would appreciate some sample code if you would be so kind.
Regards
Richard
-
Re: Program Backgrounds
Richard wrote:
> Hi Mike, I have been reading your replies on this subject and
> I think it could help me. Does VB5 support the region function?
> I would appreciate some sample code if you would be so kind.
Yes. As far as accessing the various API functions is concerned there
isn't a lot of difference between VB5 and VB6, and you can use the
various region functions with no problem at all. Also If you want an
alternative which has a number of advantages over regions you can use
the various layered window API functions instead, but those only work
on Win2K and WinXP onwards whereas the region functions work with
anything from Win95 onwards. Here is some code using regions. Paste it
into a VB Form containing a picture box and set the Form's BorderStyle
property at design time to None. You can either draw a picture or load
one in from file. The example draws a picture, but the "load from file"
code is also there but commented out. As it stands the code treats all
white pixels in the image as being transparent, but you an easily
change that to any other colour you wish. In this simple example any
part of the picture that needs to be seen cannot be the same colour as
the transparent colour, but you can make it "nearly the same colour" if
you wish. By the way, as you will see when you run the code, I failed
miserably in Art at school ;-)
Mike
Option Explicit
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 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 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 SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Any) As Integer
Private Declare Function ReleaseCapture _
Lib "user32" () As Long
Private Declare Function GetDIBits Lib "gdi32" _
(ByVal hdc As Long, ByVal hBitmap As Long, _
ByVal nStartScan As Long, ByVal nNumScans As Long, _
lpBits As Any, lpBI As BITMAPINFO, _
ByVal wUsage As Long) As Long
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
End Type
Private Const DIB_RGB_COLORS = 0
Private Const BI_RGB = 0
Private Const RGN_COPY = 5
Private Const RGN_OR = 2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private counter As Long
Private Sub Form_Load()
Dim x As Long, y As Long
Me.ScaleMode = vbPixels
With Picture1
.ScaleMode = vbPixels
.BorderStyle = vbBSNone
.Visible = False
.AutoRedraw = True
' the following lines draw a picture
.Width = 200
.Height = 240
.BackColor = vbWhite
.FillStyle = vbFSSolid
.FillColor = vbBlue
Picture1.Circle (100, 160), 78
Picture1.FillColor = vbCyan
Picture1.Circle (140, 65), 20
Picture1.Circle (160, 25), 12
Picture1.Circle (60, 65), 20
Picture1.Circle (40, 25), 12
.FillColor = vbWhite
Picture1.Circle (65, 130), 15
Picture1.Circle (135, 130), 15
Picture1.Circle (100, 200), 25
' the following lines load a picture from file
' instead of the drawing if desired
'.AutoSize = True
'.Picture = LoadPicture("c:\god2.bmp")
Me.Width = Me.ScaleX(.Width, Me.ScaleMode, vbTwips)
Me.Height = Me.ScaleY(.Height, Me.ScaleMode, vbTwips)
End With
Me.Picture = Picture1.Image
SetWindowRgn Me.hwnd, RegionFromPicture(Picture1), True
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Function RegionFromPicture _
(Mask As PictureBox) As Long
Dim FullRgn As Long, LineRgn As Long, TempRgn As Long
Dim x As Long, y As Long, MaskPixel As Boolean
Dim xLeft As Long, xRight As Long, PicOld As Boolean
FullRgn = CreateRectRgn(0, 0, 0, 0)
TempRgn = CreateRectRgn(0, 0, 0, 0)
Dim wide As Long, high As Long
wide = Picture1.ScaleWidth
high = Picture1.ScaleHeight
ReDim myArray(0 To wide - 1, 0 To high - 1) As Long
Dim bmapinfo As BITMAPINFO
With bmapinfo.bmiHeader
.biSize = 40
.biWidth = wide
.biHeight = -high
.biPlanes = 1
.biBitCount = 32
.biCompression = BI_RGB
End With
GetDIBits Mask.hdc, Mask.Image, 0, high, _
myArray(0, 0), bmapinfo, DIB_RGB_COLORS
For y = 0 To high - 1
For x = 0 To wide - 1
MaskPixel = (myArray(x, y) <> vbWhite)
If MaskPixel = True Then
If PicOld = False Then
xLeft = x
End If
PicOld = True
Else
If PicOld = True Then
xRight = x
LineRgn = CreateRectRgn(xLeft, y, xRight, y + 1)
CombineRgn TempRgn, FullRgn, LineRgn, RGN_OR
CombineRgn FullRgn, TempRgn, TempRgn, RGN_COPY
DeleteObject LineRgn
End If
PicOld = False
End If
Next x
If PicOld = True Then
xRight = x
LineRgn = CreateRectRgn(xLeft, y, xRight, y + 1)
CombineRgn TempRgn, FullRgn, LineRgn, RGN_OR
CombineRgn FullRgn, TempRgn, TempRgn, RGN_COPY
DeleteObject LineRgn
End If
PicOld = False
Next y
DeleteObject TempRgn
RegionFromPicture = FullRgn
End Function
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, x As Single, y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Form_DblClick()
Unload Me
End Sub
-
Re: Program Backgrounds
.. . . by the way, something I should have stressed more than I did in
my previous response, you need to set the Form's BorderStyle property
to None at design time.
Mike
Similar Threads
-
By Application Development in forum Adobe Photoshop
Replies: 1
Last Post: 02-05-2007, 05:28 PM
-
By Application Development in forum Adobe Photoshop
Replies: 0
Last Post: 02-05-2007, 04:18 PM
-
By Application Development in forum Adobe Premiere
Replies: 2
Last Post: 10-31-2006, 02:29 PM
-
By Application Development in forum Graphics
Replies: 1
Last Post: 08-14-2006, 01:33 PM
-
By Application Development in forum Adobe Photoshop
Replies: 50
Last Post: 09-01-2004, 07:01 PM