Advertisement
4_2005-2006 Miscellaneous #150404

3d effects for any object.

These codes produce 3d effects on any form or picturebox. The Etched3D and Raised3D subs produce either a raised line or an etched line around the picture box. The SunckePanel3D and the RaisedPanel3D subs produce a raised or lowered effect on the entire form or picturebox. These look great in your bas.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Sub SunkenPanel3D(obj As Object)
  ' Gives the effect of sinking the entire
  ' form or picture box, much like a 3d picture
  ' box with border style set to 1 - Fixed Single
  
  ' Hold the original scale mode
  Dim nScaleMode       As Integer
  
  ' Used for user defined scale only
  Dim sngScaleTop       As Single
  Dim sngScaleLeft      As Single
  Dim sngScaleWidth      As Single
  Dim sngScaleHeight     As Single
  
  If (TypeOf obj Is PictureBox) Or (TypeOf obj Is Form) Then
   
   nScaleMode = obj.ScaleMode
   
   If nScaleMode = 0 Then ' user defined scale
     sngScaleTop = obj.ScaleTop
     sngScaleLeft = obj.ScaleLeft
     sngScaleWidth = obj.ScaleWidth
     sngScaleHeight = obj.ScaleHeight
   End If
  
   obj.ScaleMode = 3 ' Pixel
   obj.Line (2, 2)-(obj.ScaleWidth - 1, 2), vb3DDKShadow
   obj.Line (2, 2)-(2, obj.ScaleHeight - 1), vb3DDKShadow
   obj.Line (2, obj.ScaleHeight - 2)-(obj.ScaleWidth - 1, obj.ScaleHeight - 2), vb3DHighlight
   obj.Line (obj.ScaleWidth - 2, obj.ScaleHeight - 2)-(obj.ScaleWidth - 2, 1), vb3DHighlight
   
   ' Set the scale mode back to the same as it was
   obj.ScaleMode = nScaleMode
   If nScaleMode = 0 Then
     obj.ScaleTop = sngScaleTop
     obj.ScaleWidth = sngScaleWidth
     obj.ScaleLeft = sngScaleLeft
     obj.ScaleHeight = sngScaleHeight
   End If
  End If
End Sub

Public Sub RaisedPanel3D(obj As Object)
  ' Gives the effect of raising the entire
  ' picture box. Much like a 3d Panel
  
  
  ' Hold the original scale mode
  Dim nScaleMode       As Integer
  
  ' Used for user defined scale only
  Dim sngScaleTop       As Single
  Dim sngScaleLeft      As Single
  Dim sngScaleWidth      As Single
  Dim sngScaleHeight     As Single
  
  If (TypeOf obj Is PictureBox) Or (TypeOf obj Is Form) Then
   
   nScaleMode = obj.ScaleMode
   
   If nScaleMode = 0 Then ' user defined scale
     sngScaleTop = obj.ScaleTop
     sngScaleLeft = obj.ScaleLeft
     sngScaleWidth = obj.ScaleWidth
     sngScaleHeight = obj.ScaleHeight
   End If
  
   obj.ScaleMode = 3 ' Pixel
   obj.Line (1, 1)-(obj.ScaleWidth - 1, 1), vb3DHighlight
   obj.Line (1, 2)-(1, obj.ScaleHeight), vb3DHighlight
   obj.Line (1, obj.ScaleHeight - 1)-(obj.ScaleWidth, obj.ScaleHeight - 1), vb3DShadow
   obj.Line (obj.ScaleWidth - 1, obj.ScaleHeight - 2)-(obj.ScaleWidth - 1, 1), vb3DShadow
   
   ' Set the scale mode back to the same as it was
   obj.ScaleMode = nScaleMode
   If nScaleMode = 0 Then
     obj.ScaleTop = sngScaleTop
     obj.ScaleWidth = sngScaleWidth
     obj.ScaleLeft = sngScaleLeft
     obj.ScaleHeight = sngScaleHeight
   End If
  End If
End Sub

Public Sub Raised3D(obj As Object)
  ' Gives the effect of a raised line around
  ' the form or picturebox
  
  ' Hold the original scale mode
  Dim nScaleMode       As Integer
  
  ' Used for user defined scale only
  Dim sngScaleTop       As Single
  Dim sngScaleLeft      As Single
  Dim sngScaleWidth      As Single
  Dim sngScaleHeight     As Single
  
  If (TypeOf obj Is PictureBox) Or (TypeOf obj Is Form) Then
   
   nScaleMode = obj.ScaleMode
   
   If nScaleMode = 0 Then ' user defined scale
     sngScaleTop = obj.ScaleTop
     sngScaleLeft = obj.ScaleLeft
     sngScaleWidth = obj.ScaleWidth
     sngScaleHeight = obj.ScaleHeight
   End If
  
   obj.ScaleMode = 3 ' Pixel
   obj.Line (1, 1)-(obj.ScaleWidth - 1, 1), vb3DHighlight
   obj.Line (1, 2)-(obj.ScaleWidth, 2), vb3DShadow
   obj.Line (1, 2)-(1, obj.ScaleHeight), vb3DHighlight
   obj.Line (2, 2)-(2, obj.ScaleHeight), vb3DShadow
   obj.Line (1, obj.ScaleHeight - 2)-(obj.ScaleWidth, obj.ScaleHeight - 2), vb3DHighlight
   obj.Line (1, obj.ScaleHeight - 1)-(obj.ScaleWidth, obj.ScaleHeight - 1), vb3DShadow
   obj.Line (obj.ScaleWidth - 2, obj.ScaleHeight - 2)-(obj.ScaleWidth - 2, 1), vb3DHighlight
   obj.Line (obj.ScaleWidth - 1, obj.ScaleHeight - 2)-(obj.ScaleWidth - 1, 1), vb3DShadow
   
   ' Set the scale mode back to the same as it was
   obj.ScaleMode = nScaleMode
   If nScaleMode = 0 Then
     obj.ScaleTop = sngScaleTop
     obj.ScaleWidth = sngScaleWidth
     obj.ScaleLeft = sngScaleLeft
     obj.ScaleHeight = sngScaleHeight
   End If
  End If
End Sub

Public Sub Etched3D(obj As Object)
  ' Gives the effect of an eteched line around the
  ' form or picture box.
  ' Hold the original scale mode
  Dim nScaleMode       As Integer
  
  ' Used for user defined scale only
  Dim sngScaleTop       As Single
  Dim sngScaleLeft      As Single
  Dim sngScaleWidth      As Single
  Dim sngScaleHeight     As Single
  
  If (TypeOf obj Is PictureBox) Or (TypeOf obj Is Form) Then
   
   nScaleMode = obj.ScaleMode
   
   If nScaleMode = 0 Then ' user defined scale
     sngScaleTop = obj.ScaleTop
     sngScaleLeft = obj.ScaleLeft
     sngScaleWidth = obj.ScaleWidth
     sngScaleHeight = obj.ScaleHeight
   End If
  
   obj.ScaleMode = 3 ' Pixel
   obj.Line (1, 1)-(obj.ScaleWidth - 1, 1), vb3DShadow
   obj.Line (1, 2)-(obj.ScaleWidth, 2), vb3DHighlight
   obj.Line (1, 2)-(1, obj.ScaleHeight), vb3DShadow
   obj.Line (2, 2)-(2, obj.ScaleHeight), vb3DHighlight
   obj.Line (1, obj.ScaleHeight - 2)-(obj.ScaleWidth, obj.ScaleHeight - 2), vb3DShadow
   obj.Line (1, obj.ScaleHeight - 1)-(obj.ScaleWidth, obj.ScaleHeight - 1), vb3DHighlight
   obj.Line (obj.ScaleWidth - 2, obj.ScaleHeight - 2)-(obj.ScaleWidth - 2, 1), vb3DShadow
   obj.Line (obj.ScaleWidth - 1, obj.ScaleHeight - 2)-(obj.ScaleWidth - 1, 1), vb3DHighlight
   
   ' Set the scale mode back to the same as it was
   obj.ScaleMode = nScaleMode
   If nScaleMode = 0 Then
     obj.ScaleTop = sngScaleTop
     obj.ScaleWidth = sngScaleWidth
     obj.ScaleLeft = sngScaleLeft
     obj.ScaleHeight = sngScaleHeight
   End If
  End If
End Sub
<h3>Creating a popunder window</h3>
<p>I feel guilty writing this tutorial, but as the saying goes, &quot;give the
people what they want&quot;, or to be more precise, developers. A lot of
developers would like to know how to implement popunder windows on their site as
a way to broadcast advertising. Yes it's annoying for the visitor, but proven
quite effective in getting attention.</p>
<p>Creating a popunder window is very simple, by using Javascript. Basically one
would use the same method for creating a popup window, but then
&quot;unfocus&quot; it. Here is the code in full force:</p>
<pre>&lt;script&gt;
win2=window.open(&quot;http://www.msn.com&quot;)
win2.blur()
window.focus()
&lt;/script&gt;</pre>
<p>That's it! I open a window by invoking &quot;window.open()&quot;, blur it,
then redirect the focus to the main window instead. Translation- the popup
window becomes a popunder instead.</p>
<p>You can even customize the pop under window so certain standard features are
removed, like the toolbar, or configure the window's size. Here's an example of
each:</p>
<pre>&lt;script&gt;
win2=window.open(&quot;http://www.msn.com&quot;,&quot;&quot;,toolbar=0)
win2.blur()
window.focus()
&lt;/script&gt;</pre>
<pre>&lt;script&gt;
win2=window.open(&quot;http://www.msn.com&quot;,&quot;&quot;,&quot;width=500,height=250&quot;)
win2.blur()
window.focus()
&lt;/script&gt;</pre>
<p>You've probably seen more sophisticated popunder scripts that control the
&quot;frequency&quot; of the popunder, such as popping up only once per browser
session. Instead of reinventing the wheel, I'll simply point you to a nice
example of this on JavaScript Kit: <a href="http://javascriptkit.com/script/script2/popunder.shtml">http://javascriptkit.com/script/script2/popunder.shtml</a></p>
<p>Have fun with popping under your windows.</p>

Upload
Original Comments (3)
Recovered from Wayback Machine