|
-
Feb 9th, 2002, 04:30 PM
#1
Thread Starter
Frenzied Member
Programming FAQ -- show off your cool tips here!
I am wanting to start a programming FAQ ( http://www.piqsoftware.com/projects/apochfaq/ ).
However, I do NOT want to cover the basic stuff like "how to make a command button" and that sort of junk.
If you have a cool tip or trick that you'd like to share, just post it here and I'll put it up -- with whatever credits you like (name, email, website, whatever)
Go for it!
Last edited by mlewis; Feb 10th, 2002 at 03:14 PM.
-
Feb 9th, 2002, 04:41 PM
#2
Thread Starter
Frenzied Member
I'll get you started:
How to make a really cool shaped window
Put this into a module:
VB Code:
Public Function GetTransparencyRgn(ByVal TheForm As Form) As Long
Dim hrgn As Long, hrgn2 As Long
Dim Temp As Long
Dim I As Integer, J As Integer
Dim BeginX As Integer
Dim PrevX As Integer
Dim PrevEX As Integer
Dim Rows As Integer
Dim Flag As Boolean
Dim BeginRow As Integer
Dim H As Long
Dim ht As Integer, wd As Integer
hrgn = CreateRectRgn(0, 0, 0, 0)
BeginX = -1
PrevX = -1
PrevEX = -2
Rows = 1
With TheForm.PicMask
H = .hdc
ht = .ScaleHeight
wd = .ScaleWidth
End With
For J = 0 To ht
Flag = False
For I = 0 To wd
' change the RGB numbers here to change the transparent color
If GetPixel(H, I, J) <> RGB(255, 255, 0) Then
If BeginX = -1 Then
If PrevX <> I Then
Temp = CreateRectRgn(PrevX, J, PrevEX, J)
BeginX = -1
CombineRgn hrgn, hrgn, Temp, RGN_OR
DeleteObject Temp
Rows = 1
End If
BeginX = I
If PrevX = I Then
If Not Flag Then BeginRow = J
Flag = True
Rows = Rows + 1
End If
PrevX = BeginX
End If
Else
If BeginX <> -1 Then
If Flag Then
Rows = Rows + 1
Else
BeginRow = J
Rows = 1
Temp = CreateRectRgn(BeginX, BeginRow, I, J + Rows)
BeginX = -1
CombineRgn hrgn, hrgn, Temp, RGN_OR
DeleteObject Temp
End If
PrevEX = I
End If
End If
Next I
If BeginX >= (I - 1) Then
BeginRow = J
Rows = 1
Temp = CreateRectRgn(BeginX, BeginRow, I, J + Rows)
BeginX = -1
CombineRgn hrgn, hrgn, Temp, RGN_OR
DeleteObject Temp
PrevEX = I
End If
Next J
GetTransparencyRgn = hrgn
End Function
And in the form:
VB Code:
Private Sub Form_Load()
Dim hrgn As Long
hrgn = GetTransparencyRgn(Me)
SetWindowRgn hwnd, hrgn, 1
End Sub
Put a PictureBox onto the form that is named PicMask. Set its Visible property to false, AutoRedraw to True, and ScaleMode to 3 - vbPixels.
Next, make a BMP file that has the shape you want. The transparent color is yellow (RGB 255, 255, 0) but you can change it easily (see the code for details). Everything that is yellow (or whatever color you set) will be see-through.
Note also that the form's ScaleMode property must be 3-vbPixels.
-
Feb 9th, 2002, 04:50 PM
#3
Frenzied Member
I think you forgot to include the API calls with that code...
You just proved that sig advertisements work.
-
Feb 9th, 2002, 05:01 PM
#4
Thread Starter
Frenzied Member
-
Feb 9th, 2002, 05:25 PM
#5
-= B u g S l a y e r =-
-
Feb 9th, 2002, 05:30 PM
#6
-= B u g S l a y e r =-
Lewis, this is a must for any FAQ out there 
VB Easter Bunny
1. From VB's View Menu, select toolbar, then customize......
2. In the resulting dialog, click On the Command Tab.
3. In the Categories List, Select Help.
4. Select "About Microsoft Visual Basic" In the Command List, And drag it To any menu Or the toolbar.
5. Right-click On the Item you just dragged And rename it To "Show VB Credits" (without quotes).
6. Then Close the "Customize" dialog And click On the
"Show VB Credits"
-
Feb 9th, 2002, 05:38 PM
#7
Thread Starter
Frenzied Member
Yeah I open that every once in a while when I'm in the mood for some funky music
-
Feb 9th, 2002, 05:42 PM
#8
-= B u g S l a y e r =-
Play a midi using API
VB Code:
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _
hwndCallback As Long) As Long
Private Sub Command1_Click()
Dim ret As Integer
Dim sSong As String
'start the song
sSong = App.Path & "\midisong.mid"
ret = mciSendString("open " & Chr(34) & sSong & Chr(34) & " type sequencer alias to_town", 0&, 0, 0)
ret = mciSendString("play to_town", 0&, 0, 0)
End Sub
Private Sub Command2_Click()
Dim ret As Integer
'stop playing the song
ret = mciSendString("close to_town", 0&, 0, 0)
End Sub
want simple but often asked stuff like that?
-
Feb 9th, 2002, 05:45 PM
#9
Thread Starter
Frenzied Member
That works, but I was thinking of little known let really cool stuff like the wacky-shaped window demo above...
Give me a while and I'll update that stuff real quick.
-
Feb 9th, 2002, 06:11 PM
#10
Thread Starter
Frenzied Member
All added 
Anyone else?
-
Feb 12th, 2002, 03:20 PM
#11
Fanatic Member
haven't read through all the posts, but...
this code
Code:
If a = "Hello" Then
b = "Hi"
Else
b = "Bye"
End If
has the same effect as
Code:
b = Iif(a = "Hello", "Hi", "Bye)
-
Feb 13th, 2002, 12:17 PM
#12
Originally posted by mlewis
Not true!
Try this:
If a = "Hello" Then
MsgBox "hi"
Else
MsgBox "Bye"
End if
And then try:
Dim a
a = "goobl"
IIf a = "Hello", MsgBox("Hi"), MsgBox("Bye")
OOPS!
well
i'm not sure but i think that this will do it right
VB Code:
Msgbox Iif(A= "Hello, "Hii" , "Bye")
what i know about Iif (i just knew it 3 minutes ago) is that it returns the first value given if the condition is tru and the second if none so that code should do it right
-
Feb 14th, 2002, 03:30 PM
#13
PowerPoster
I use the ADO helper from M$. Here are 2 files
-
Feb 14th, 2002, 03:31 PM
#14
PowerPoster
-
Feb 14th, 2002, 03:50 PM
#15
Thread Starter
Frenzied Member
Thank you! What an excellent tip!
That's not a tip dude. Thats code. I don't want Microsoft code. I want real tips, real things that people have come up with.
-
Feb 14th, 2002, 03:51 PM
#16
PowerPoster
Originally posted by mlewis
Thank you! What an excellent tip!
That's not a tip dude. Thats code. I don't want Microsoft code. I want real tips, real things that people have come up with.
well.....you may not like it but it sure is efficient when using databases
-
Feb 14th, 2002, 05:32 PM
#17
Cheesy but neat effect! (As Willard Scott used to say in the commercials, "Don't forget the cheese!")
Make a form "scroll away" when closing.
VB Code:
Option Explicit
'Written by Carl Armbruster
'Make a form "scoll away" at close
' May be used and distributed freely!
' no nasty copyrights here mlewis!
Dim intStartWidth As Integer
Dim intStartHeight As Integer
Dim intUpperLimit As Integer
Dim i As Integer
Private Sub Form_Unload(Cancel As Integer)
intStartWidth = Width
intStartHeight = Height
If intStartWidth > intStartHeight Then
intUpperLimit = intStartWidth
Else
intUpperLimit = intStartHeight
End If
On Error Resume Next 'making the form
'too small gives an error!
For i = intUpperLimit To 1 Step -1
Width = Width - 1
Height = Height - 1
Next i
End Sub
-
Feb 14th, 2002, 05:55 PM
#18
Hyperactive Member
mlewis - what do you think????
Armbruster: Please take this msg not to serious
VB Code:
Option Explicit
Private Sub Form_Unload(Cancel As Integer)
Dim intCounter As Integer
Dim intMax As Integer
Dim intHeight As Integer
Dim intWidth As Integer
intWidth = Me.Width
intHeight = Me.Height
If intWidth > intHeight Then
intMax = intWidth
Else
intMax = intHeight
End If
On Error Resume Next
For intCounter = intMax To 1 Step -1
Me.Width = Me.Width - 1
Me.Height = Me.Height - 1
Next intCounter
End Sub
This code was originally posted by Armbruster - I changed a few
things - so if I would claim now I wrote this procedure first who
is right??
To make it clear again I DID NOT write this procedure I only
wand to use it to show my point.
Face it if I would ask 20 developers to write a procedure which
close an app by "scrolling away" we would have at lease 2
simelare procedures.
-
Feb 14th, 2002, 09:13 PM
#19
Thread Starter
Frenzied Member
Well you have a point, that all our procedures would be similar.
That's kind of the idea of a FAQ isn't it? To provide common answers to common problems? Frequently asked Questions 
In this case, I have NO way to prove if you or arm wrote the code first. However, arm posted first so he would get credit in the FAQ.
-
Feb 15th, 2002, 03:06 AM
#20
Fanatic Member
Herk, how about this?
This sure looks yummy! The form just go on circulating
VB Code:
'In a form code...
Dim Degree as Integer
Const Distance = 1000 ' twips
Private Sub Form_Load()
Timer1.Interval = 1
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Degree = Degree + 1
If Degree > 360 Then Degree = 0
Radian = Degree / 57.2958
X = COS(Radian) * Distance
Y = SIN(Radian) * Distance
Me.Top = (Screen.Width \ 2) + X
Me.Left = (Screen.Height \ 2) + Y
End Sub
Last edited by jian2587; Feb 15th, 2002 at 03:15 AM.
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
-
Feb 15th, 2002, 03:23 AM
#21
Fanatic Member
Err...Could u put QBasic and Assembly section as well in ur
Apoch site?
That'll b great
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
-
Feb 15th, 2002, 11:16 AM
#22
Thread Starter
Frenzied Member
lol, I'd love to add those sections, but I'd need tips for them first. I have plenty of QBasic lore in my old shriveled brain, but I don't know if anyone is interested.
Also, I will be gone on business until Wednesday, so please do not dispair if your tips aren't published for a while. I'll try to check up on this thread often while I'm away, but who knows
-
Feb 15th, 2002, 07:32 PM
#23
Originally posted by mlewis
lol, I'd love to add those sections, but I'd need tips for them first. I have plenty of QBasic lore in my old shriveled brain, but I don't know if anyone is interested.
Also, I will be gone on business until Wednesday, so please do not dispair if your tips aren't published for a while. I'll try to check up on this thread often while I'm away, but who knows
Why don't you let members on your site to publish the code and tips for you? It would give you more time to do the other thing you have to do. Why don't you give the member of your site jobs e.g someone (some ppl) to put the code up on the site.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 16th, 2002, 10:44 AM
#24
Fanatic Member
yup, why don't u appoint some commitee members?
Or atleast make a page which enable others to post
tips and update it automatically.
This is getting cool and cool and cool!
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
-
Feb 16th, 2002, 06:09 PM
#25
Originally posted by jian2587
yup, why don't u appoint some commitee members?
Or atleast make a page which enable others to post
tips and update it automatically.
This is getting cool and cool and cool!
Alright lets take a vote. who think commitee would be a good idea?
I reckon it would work.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 16th, 2002, 08:14 PM
#26
Hyperactive Member
How much I can charge if I get member of this commite.
Do I get a commite car?
Are there any other benefits involved????
-
Feb 17th, 2002, 01:25 AM
#27
Originally posted by Bongo
How much I can charge if I get member of this commite.
Do I get a commite car?
Are there any other benefits involved????
HeHe I wish first we have to see if he will agree to the idea.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 17th, 2002, 01:31 AM
#28
Originally posted by mlewis
That's right!
I've copyrighted my software before, and I know the penalties can be pretty stiff. Technically, you can only claim copyright "rights" if you register the thing, but you can still claim *Some* rights by putting a notice in it.
However, since all the code submitted (except that example) did not have any copyright, and could very easily be re-written by any one of us so as not to be copyrightable, I don't lose any sleep over it
I know it cost alot of money to get a program copy written by how much exactly are we talking?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 17th, 2002, 05:21 AM
#29
Fanatic Member
Grab handle
Here's some short and easy code to put a grab handle (shangle) at the bottom right of a window for resizing:
Pretty sure I wrote it all, but it's so long ago I couldn't swear to it.
Anyway, I'm claiming the copyright and releasing it to you, so if I'm wrong it's only me who is in trouble, not you.
Brian
(Fighting with the RightToLeft bugs in VS 2005)
-
Feb 17th, 2002, 10:44 AM
#30
Fanatic Member
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
-
Feb 17th, 2002, 01:02 PM
#31
New Member
To reply on the copywrighting stuff if you put a disk into a envelope and send it to yourself it will have a time stamp on it proving you made it origanlly (if the time is right) it has worked before with people. hope this helped
VB is powerful if you know how to use it!!!
-
Feb 17th, 2002, 01:24 PM
#32
Hyperactive Member
Originally posted by SeizeTheDay
To reply on the copywrighting stuff if you put a disk into a envelope and send it to yourself it will have a time stamp on it proving you made it origanlly (if the time is right) it has worked before with people. hope this helped
I found an envelope at home dated 12.03.1981. Do you think I can now claimthe copyright of Windows?
-
Feb 17th, 2002, 04:52 PM
#33
Good Ol' Platypus
To get the free memory, use the GlobalMemoryStatus API and the MEMORYSTATUS Type:
VB Code:
Option Explicit
Public Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
Public Type MEMORYSTATUS
dwLength As Long
dwMemoryLoad As Long
dwTotalPhys As Long
dwAvailPhys As Long
dwTotalPageFile As Long
dwAvailPageFile As Long
dwTotalVirtual As Long
dwAvailVirtual As Long
End Type
Public Type Fraction 'UDT made by me, Copyrighted ;) hehe
fAmount As Long
fMax As Long
End Type
Function GetPhysicalMemory() As Fraction
Dim Memory As MEMORYSTATUS
Call GlobalMemoryStatus(Memory)
GetPhysicalMemory.fAmount = Memory.dwAvailPhys
GetPhysicalMemory.fMax = Memory.dwTotalPhys
End Function
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 17th, 2002, 05:32 PM
#34
Originally posted by SeizeTheDay
To reply on the copywrighting stuff if you put a disk into a envelope and send it to yourself it will have a time stamp on it proving you made it origanlly (if the time is right) it has worked before with people. hope this helped
Wierd but funny.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 17th, 2002, 05:34 PM
#35
Originally posted by Bongo
I found an envelope at home dated 12.03.1981. Do you think I can now claimthe copyright of Windows?
Yeah then sue Microsoft for billions.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 18th, 2002, 12:03 AM
#36
New Member
anyone call show me how to call an application using VB. Thank you!!!!!
-
Feb 18th, 2002, 12:23 AM
#37
Originally posted by Everything
anyone call show me how to call an application using VB. Thank you!!!!!
Just using the shell command.
i.e Shell ("c:\windows\explorer.exe")
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 18th, 2002, 01:38 AM
#38
Fanatic Member
Originally posted by SeizeTheDay
To reply on the copywrighting stuff if you put a disk into a envelope and send it to yourself it will have a time stamp on it proving you made it origanlly (if the time is right) it has worked before with people. hope this helped
If it arrived next day, what would the equivalent Baud rate be?
What's the best speed you could manage? If you sent a stack of CD's from Amsterdam to London by UPS, would it be faster than transferring the data by modem? Would it be cheaper? What's the break-even point? Hey - I actually had to do this at one time. Never did figure out which was better. We used to use UPS for anything bigger than 50Mb, but that was more to do with getting to the pub on time than anything technical.
Highest theoretical baudrate? It's the Space Shuttle in orbit with the cargo bay full of DVD's.
Brian
(Fighting with the RightToLeft bugs in VS 2005)
-
Feb 18th, 2002, 04:49 AM
#39
Hyperactive Member
Re: Important!
[QUOTE
mxnmx -- that code is copyrighted; I'd rather not use it because I don't have permission from the author. Thanks anyway [/B]
[/QUOTE]
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2002 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
Feb 18th, 2002, 05:07 AM
#40
Fanatic Member
Re: Re: Important!
Originally posted by Bongo
[QUOTE
mxnmx -- that code is copyrighted; I'd rather not use it because I don't have permission from the author. Thanks anyway
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2002 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' [/B][/QUOTE]
There is such a thing as triviality of copyright and the courts would take that into account in any copyright litigation.
Just because you wrote something and put your 'copyright' on it does not mean you own the copyright. A court may decide against you if it was a trivial construction or an adaptation of a existing common construction.
e.g. if you come up with a new and faster sort algo, then that's almost certainly covered. If you take something out of book, or out of MSDN, or you just type out a commonly used bit of code, then it's not your copyright, even if you hack it about and rearrange it, unless it includes some substantial new functionality.
This probably covers almost anything under a few hundred lines of code - unless it is really unusual.
You see lots of bits of short code, - e.g. API call wrappers to handle the registry etc. - that somebody has marked 'copyright'. I don't think so. If it came down to the wire, the earliest similar code was probably written by Microsoft when they were testing the API before it was even released. Any general routine, unless it's VERY unusual has almost certainly been written before. Don't even think of copyrighting a hex to dec converter. It was probably first written in the 60's.
Now the above is not to say that people who have provided these routines have not put a lot of work in to them. They deserve some credit for it, even if it's just leaving their name in the header. Also, it would be wrong for a commercial site to SELL such code (or access to it) without due recompense - and that should be resisted.
But legal protection? In most cases I think not. Who's going to go to pay a lawyer to fight over twenty lines of code anyway?
It comes down to what's polite, rather than what's legal - and certainly you should ask the author's permission to quote his code unless it is explicitly given in the header (which of course somebody else could already have changed without permission!).
I'd just follow your conscience and not worry too much about the outcome.
Last edited by BrianHawley; Feb 18th, 2002 at 05:19 AM.
Brian
(Fighting with the RightToLeft bugs in VS 2005)
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
|