Link to home
Start Free TrialLog in
Avatar of code-cracker
code-cracker

asked on

changing form or window shape!!!

Back again,
             how can u change the shape of the window or the form using api's.for eg the windows that sonique etc have.tell me any other way if not in VB to do that.

Bye
Avatar of wileecoy
wileecoy
Flag of United States of America image

Following is code to shape your form with a bitmap file.

The code takes the color in the top leftmost position (coords 0,0) and makes that transparent.  The shape of the form then becomes the shape of the bitmap that is not transparent.

What you will want to do is find a bitmap that will work properly if the top left pixel is made transparent through the whole form.  You will then want to either rename it to Main.bmp in the app.path, or change the following line of code that is in the form_load event:

Set picMainSkin.Picture = LoadPicture(App.Path & "\main.bmp")

the first comment is the module code, the second is the form code.

Unfortunately, I cannot properly credit the author - I downloaded it.
ASKER CERTIFIED SOLUTION
Avatar of wileecoy
wileecoy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
'Form1, Borderstyle = none
'Picturebox = picMainSkin
'CommandButton = Command1

Option Explicit

Private Sub Command1_Click()
    MsgBox "This is a real working form!"
End Sub

Private Sub Form_Load()
    Dim WindowRegion As Long
   
    ' I set all these settings here so you won't forget
    ' them and have a non-working demo... Set them in
    ' design time
    picMainSkin.ScaleMode = vbPixels
    picMainSkin.AutoRedraw = True
    picMainSkin.AutoSize = True
    picMainSkin.BorderStyle = vbBSNone
    Me.BorderStyle = vbBSNone
       
    Set picMainSkin.Picture = LoadPicture(App.Path & "\main.bmp")
   
    Me.Width = picMainSkin.Width
    Me.Height = picMainSkin.Height
   
    WindowRegion = MakeRegion(picMainSkin)
    SetWindowRgn Me.hWnd, WindowRegion, True
End Sub

Private Sub picMainSkin_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     
      ' Pass the handling of the mouse down message to
      ' the (non-existing really) form caption, so that
      ' the form itself will be dragged when the picture is dragged.
      '
      ' If you have Win 98, Make sure that the "Show window
      ' contents while dragging" display setting is on for nice results.
     
      ReleaseCapture
      SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&

End Sub
Avatar of JonFish85
JonFish85

dont out-do yourself on points btw
lol JonFish85 - I didn't even notice!
Avatar of DanRollins
Hi code-cracker,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept wileecoy's comment(s) as an answer.
**** there really ought to be some sort of bonus system!

code-cracker, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Comment from expert accepted as answer

Computer101
E-E Moderator