Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form in shape of frayed Parchment paper 1

Status
Not open for further replies.

SidYuca

Technical User
Nov 13, 2008
79
MX
I am looking for a way to make a form in the shape of an old sheet of parchment paper which has frayed(irregular) edges. This form will hold image boxes. I've tried to use a gif representation of the parchment with the picture property of a normal form but don't get the desired frayed/torn edges. Any help would be appreciated.
 
I've given at leats one example of how to use pretty much any shape you like as a form in this forum in the past.

It is just a question of formulating the right keyword search ... erm... let's see ...

First there's the technique shown in thread222-444672 - but that expects you to draw the shape that you need the window to be, which isn't ideal for frayed edges (but does include the technique for dragging a window that doesn't have a titlebar). And I can't find the right set of keywords to locate my original example, so here's a new version.

It assumes that you have a form with the border style set to none, and that you have loaded it with your gif. You also need to know what the transparent colour needs to be (so, if your gif of the parchment paper is drawn on a white background, the transparent color would be white). For this example I also include a button that allows us to close the form ...
Code:
[blue]Option Explicit

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Const LWA_COLORKEY = &H1&

Private Sub Form_Load()
    Dim StyleEx As Long
    Dim MaskColour As Long

    MaskColour = RGB(255, 255, 255) [green]' Colour that will be transparent, in this example white[/green]
    BackColor = MaskColour

    StyleEx = GetWindowLong(hWnd, GWL_EXSTYLE)
    StyleEx = StyleEx Or WS_EX_LAYERED
    SetWindowLong hWnd, GWL_EXSTYLE, StyleEx
    SetLayeredWindowAttributes hWnd, MaskColour, 0, LWA_COLORKEY
End Sub

Private Sub Command1_Click()
    Unload Me
End Sub[/blue]
 
That's pretty cool. Perfect for splash screens too.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
You might also want to see thread222-972212 for giving non-rectangular shapes to your form.
 
The thread I referenced earlier already covers window regions.
 
Thank you all. I am sorry that I have not responded but I was beaten down with a cold and have not been on line for some time. I really appreciate the response and will give it a try this weekend.
 
WOW.. Just what I needed and it work just as advertized.
I have one small problem.. it works too well. Let me explain.
The parchment background is mutted with several colors (including some white). So when my white border was made transparent it appeared that all was well. It wasn't until I started to add the varius images (GIFs and BMPs) to it did I notice that the whites in these pictures (heiroglyphs) became transparent. "Don't fire until you see the whites of their eyes" would not work! (They were transparent.

I know that I mnust change the color of the background..but to what? If I search for a color that is not present in any of my 122 glyphs That will be quite a Task. Let's say I mix a color in Photoshop for the background (i.e. An ugly shade of purple)How do I go about finding the 3 digits to use to define the color to eliminate?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top