Welcome Guest!
 VB 6 Helper
 Previous Message All Messages Next Message 
VB6 Helper Newsletter  Rod Stephens
 May 07, 2004 21:27 PDT 

I am attending Tech Ed in San Diego May 2328
(http://www.microsoft.com/seminar/teched2004/default.mspx). If you're
going, too, drop me an email (RodSte-@vb-helper.com) and perhaps we
can all get together.

Have a great week and thanks for subscribing!


    VB6 Contents:
1. New HowTo: Make an MDI application with an MRU list
2. New HowTo: Use API functions to change a ProgressBar's foreground and
background colors
3. New HowTo: Make moving graphs drawn in PictureBoxes
4. Converted HowTo: See if the mouse is moving even when it is not over
the program
5. Converted HowTo: Make a geography game
6. Converted HowTo: Let the user move controls

    Both Contents:
7. New Link
8. Karen Watterson's Weekly Destinations and Diversions (D & D)
1. New HowTo: Make an MDI application with an MRU list

This example also demonstrates some MDI features such as a Windows menu
that displays a list of MDI child forms, commands that arrange the MDI
children, and commands that minimize and restore the MDI children.

The m_FileTitles and m_FileNames collections hold the titles (without
directory path) and names of the files in the MRU list. Subroutine
AddToMRUList adds a file to the top of the list, removing duplicates.

Subroutine ShowMRUList uses the form's MRU list menu entries to display
the list.

Private m_FileTitles As Collection
Private m_FileNames As Collection

' Add this file to the MRU list.
Private Sub AddToMRUList(ByVal file_title As String, ByVal file_name As
Dim i As Integer

    ' Add the entry at the top of the list.
    If m_FileTitles.Count = 0 Then
        m_FileTitles.Add file_title
        m_FileNames.Add file_name
        m_FileTitles.Add file_title, , 1
        m_FileNames.Add file_name, , 1
    End If

    ' Remove any duplicates.
    For i = m_FileTitles.Count To 2 Step -1
        If m_FileNames(i) = file_name Then
            m_FileTitles.Remove i
            m_FileNames.Remove i
        End If
    Next i

    ' Remove entries beyond four.
    Do While m_FileTitles.Count > 4
        m_FileTitles.Remove 5
        m_FileNames.Remove 5

    ' Redisplay the list.

    ' Save the MRU list.
End Sub

' Display the MRU list.
Private Sub ShowMRUList()
Dim i As Integer

    For i = 1 To m_FileTitles.Count
        mnuFileMRU(i).Caption = "&" & Format$(i) & " " & m_FileTitles(i)
        mnuFileMRU(i).Visible = True
    Next i

    ' If any file is visible, display the MRU separator.
    mnuFileMRUSep.Visible = mnuFileMRU(1).Visible
End Sub

Subroutine SaveMRUList saves the MRU list into the Registry. It deletes
any Registry entries for files that are not in use. For example, if the
MRU list contains only 2 files, then this routine deletes the entries
for files 3 and 4.

Note that the program saves the list every time it changes. It's really
annoying if your program crashes and doesn't know about the last file
you used.

Subroutine LoadMRUList reloads the list from the Registry.

' Save the MRU list.
Private Sub SaveMRUList()
Dim i As Integer

    ' Save the MRU files.
    For i = 1 To m_FileTitles.Count
        SaveSetting "MRUDemo", "MRU", "Title" & Format$(i),
        SaveSetting "MRUDemo", "MRU", "File" & Format$(i),
    Next i

    ' Delete any old entries.
    On Error Resume Next
    For i = m_FileTitles.Count + 1 To 4
        DeleteSetting "MRUDemo", "MRU", "Title" & Format$(i)
        DeleteSetting "MRUDemo", "MRU", "File" & Format$(i)
    Next i
End Sub

' Load the MRU list.
Private Sub LoadMRUList()
Dim i As Integer
Dim txt As String

    Set m_FileTitles = New Collection
    Set m_FileNames = New Collection

    ' Get the MRU files.
    For i = 1 To 4
        txt = GetSetting("MRUDemo", "MRU", "Title" & Format$(i), "")
        If Len(txt) = 0 Then Exit For

        m_FileTitles.Add txt
        m_FileNames.Add GetSetting("MRUDemo", "MRU", "File" &
Format$(i), "")
    Next i
End Sub

When the program starts, it calls subroutines LoadMRUList and
ShowMRUList to load and display the MRU list.

Private Sub Form_Load()
    dlgFile.Flags = _
        cdlOFNFileMustExist Or _
        cdlOFNHideReadOnly Or _
    dlgFile.CancelError = True
    dlgFile.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
    dlgFile.FilterIndex = 2

End Sub

Subroutine LoadFile loads a file and calls AddToMRUList to add the file
to the list.

' Load the file and add it to the MRU list.
Private Sub LoadFile(ByVal file_title As String, ByVal file_name As
Dim fnum As Integer
Dim frm As Form1

    On Error GoTo FileLoadError
    fnum = FreeFile
    Open file_name For Input As fnum
    Set frm = New Form1
    frm.txtFile.Text = Input$(LOF(fnum), #fnum)
    Close #fnum

    AddToMRUList file_title, file_name

    frm.Caption = file_title
    Exit Sub

    MsgBox "Error " & Format$(Err.Number) & _
        " reading file." & vbCrLf & Err.Description
    Exit Sub
End Sub

When you select an MRU list menu entry, the event handler calls
subroutine LoadFile to reload the file. This also moves the file to the
top of the MRU list.

If you use the File menu's Open command to open a file, the event
handler calls subroutine LoadFile to load the file and add it to the MRU

' Open the selected file.
Private Sub mnuFileMRU_Click(Index As Integer)
    LoadFile m_FileTitles(Index), m_FileNames(Index)
End Sub

Private Sub mnuFileOpen_Click()
    On Error Resume Next

    If Err.Number = cdlCancel Then
        Exit Sub
    ElseIf Err.Number <> 0 Then
        MsgBox "Error " & Format$(Err.Number) & _
            " selecting file." & vbCrLf & Err.Description
        Exit Sub
    End If

    LoadFile dlgFile.FileTitle, dlgFile.FileName
End Sub
2. New HowTo: Use API functions to change a ProgressBar's foreground and
background colors

Thanks to Dipak Auddy (aud-@gawab.com).

To set the control's background color, use the SendMessage API function
to send the control the PBM_SETBKCOLOR message together with the color.
To set the foreground color, send the PBM_SETBARCOLOR message.

Public Sub SetPBackColor(ByVal hwndProgBar As Long, Optional ByVal color
As Long = vbWhite)
    Call SendMessage(hwndProgBar, PBM_SETBKCOLOR, 0&, ByVal color)
End Sub

Public Sub SetPForeColor(ByVal hwndProgBar As Long, Optional ByVal color
As Long = vbGreen)
    Call SendMessage(hwndProgBar, PBM_SETBARCOLOR, 0&, ByVal color)
End Sub
3. New HowTo: Make moving graphs drawn in PictureBoxes

Thanks to Deepesh Agarwal (mail2m-@softhome.net).

When a timer fires, the program generates a new random value to add to
its graphs. For the scrolling graph, the control erases its graph and
redraws it shifted to the left. For the non-scrolling graph, the program
draws the next line on the right. When this graph is full, the program
erases it and starts over. See the code for details.
4. Converted HowTo: See if the mouse is moving even when it is not over
the program

Use a Timer to periodically check the mouse's position using the
GetCursorPos API function.

' Get the mouse's current position and see if it
' has moved since last time.
Private Sub tmrCheckMouse_Timer()
Static done_before As Boolean
Static last_point As POINTAPI

Dim cur_point As POINTAPI

    ' If we have done this before, compare the
    ' current mouse position to the previous one.
    If done_before Then
        GetCursorPos cur_point
        If (cur_point.x <> last_point.x) Or _
           (cur_point.y <> last_point.y) _
            lblMoving.Caption = "Moving"
            lblMoving.Caption = "Stationary"
        End If
        ' Record the cursor position.
        last_point = cur_point
        done_before = True
        ' Just record the cursor position.
        GetCursorPos last_point
    End If
End Sub
5. Converted HowTo: Make a geography game

When the user clicks on a point on the map, the program uses the
FloodFill API function to fill the area clicked. It then checks the
desired state's identifier pixel to see if it has been colored. If it
has, then the user clicked the right region.

This zip file also includes a program that helps make a database of
positions of points in each state for a map.
6. Converted HowTo: Let the user move controls

Thanks to Hisham Nassef (hish-@hotmail.com).

In a control's MouseDown event handler, save the mouse position. In the
MouseMove event handler, move the control by the distance the mouse has

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    xDown = X
    yDown = Y
End Sub

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    If Button <> vbRightButton Then Exit Sub

    MoveCtl Command1, X, Y
End Sub

Private Sub MoveCtl(ctl As Object, X As Single, Y As Single)
Dim newLeft As Single
Dim newTop As Single

    newLeft = ctl.Left + X - xDown
    newTop = ctl.Top + Y - yDown
    ctl.Move newLeft, newTop
End Sub
7. New Link

A new site featuring news, code samples, links, as well as listings of
training providers, consultants, and component developers.
8. Karen Watterson's Weekly Destinations and Diversions (D & D)

- Professor Steve Abbott's text analysis program
<http://www.pinpub.com/html/main.isx?sub=63&story=2729> with source in
both VB6 and VB.NET.

- Splendid March/April issue of CoDe Magazine
Related: Mike Snell and Lars Powers' article archives

- Good article on the three main techniques for validating XML documents
against XML schema
<http://otn.oracle.com/pub/articles/vohra_xmlschema.html>. Related: Bill
Hatfield's article on using XML to store data

- You've read about aspect-oriented programming (AOP), a technology that
lets you deal with "aspects" or concerns that cut across business
systems as modular units. eWeek describes how IBM is planning to support
AOP <http://www.eweek.com/article2/0,1759,1572818,00.asp>. (My search of
TechEd sessions seems to indicate that AOP won't be discussed this year,
though SOA will). eWeek on IBM's support for SOA

- Accessing Oracle 9i Stored Procedures Using ADO.NET

- MVP Tibor Karaszi's article on the SQL Server RESTORE command
Related: SQL Server articles, tips and tricks

- Dino Esposito's MSDN article on the evolution of SQL Server data
access model for SQL Server

- Good article on huge data warehouses
(VLDBs), including a good Q&A with Ken Collins, Director of Information
Management for Amazon.com (15TB raw info).

- How to delete a DTS package
Related: Using DTS package logs

- Interesting article about "ambidextrous organizations" in the April
2004 HBR (subscription required). Read Boris Dursin and Gergana
Todorova's 30-page Sept 2003 PDF on the topic

- Deep computing at IBM

- Peter Denning on the difference between invention and innovation

Selected KB articles
- 837910 Mouse wheel events do not work in the VB6 IDE.

- 320108 PRB: Office Automation Fails with an Incompatible RPC Stub

- 815545 An unhandled exception of the 'System.ArgumentException' type
occurs after you rename the columns of a DataSet object.

- 836672 How to sum the fields in a Windows Forms DataGrid control and
then display the calculated totals in a footer by using VB.NET.

- 815545 An unhandled exception of the 'System.ArgumentException' type
occurs after you rename the columns of a DataSet object.

- 313091 How to create keys by using VB.NET for use in Forms

- 834060 Current directory for an ActiveX EXE object is set to the
location of the system directory and not to the location of the invoking
client in VB.NET.

- 324321 How to troubleshoot error 15401.

- 827690 How to use Sqldumper.exe to generate dump files for Windows

- 839269 You may not be able to connect to an instance of SQL Server
that is configured to use the Named Pipes server network library on a
computer that is running Windows XP SP2.

- 838010 Problems occur when you use the Rich TextBox Control 6.0 in
Office XP and in Office 2003.

- 303875 Office 2000 Speller update.

- 828450 Why service packs, updates, and security patches may require
the Office 2000 CD-ROM.

- 839018 The NET SEND command may not work correctly on a computer that
is running Windows XP SP2.

- 839278 BUG: The changes in a remote subscriber aren't updated to the
publisher for a queued updating replication that uses Message Queuing on
a computer that's running XP SP2.

- 832672 Numbering scheme for product code GUIDs in Office 2003.

- 283159 Speech Recognition FAQs.

- 330008 MS02-059: Flaw in Word Fields and Excel External Updates May
Lead to Information Disclosure.

- 837824 Word 2003 hotfix package: March 22, 2004.

- 322389 How to Obtain the Latest Windows XP Service Pack.

- 822603 Availability of the Windows XP SP1 USB 1.1 and 2.0 Update.

Worth Noting
- Microsoft Acquires BI vendor, ActiveViews Inc
<http://www.activeviews.com/> and Microsoft Acquires ActiveViews'
Business Intelligence Functionality

- BASIC hits 40
What more can we say?

- Palm's new Cobalt OS has better support for databases, data security,
and a new schema database type (in addition to record and resource
databases). Two developer articles

- Apply for Microsoft Application Translator
<http://www.microsoft.com/globaldev/tools/mat.mspx> (MAT) beta program.

- VB at the Movies <http://msdn.microsoft.com/vbasic/atthemovies/>. Free
copies of VB .NET 2003 Standard Edition.

- Free InfoPath training exercises

- DotNetNuke <http://www.dotnetnuke.com/> (DNN) - open source portal
program based on IBuySpy (IBS). Related article: Building a Internet
Portal (for Free!) with DotNetNuke

- niceSQL <http://home.broadpark.no/~ihalvor/>, shareware ($US 20 to
register) SQL formatter. Requires .NET Framework 1.1.

- Free utilities for SQL Server: QALite
<http://rac4sql.net/qalite_main.asp>, and ObjectScriptr
<http://rac4sql.net/objectscriptr_main.asp>. Also from RAC: a handy BOL
link to MSDN URL converter <http://rac4sql.net/BOL2MSDN.aspx>.

- SQL Server Centric .NET Code Generator
(code named OlyMars, unsupported Microsoft product).

- GlueCode's open source business process engine

- Zeroping Beta <http://zeroping.home.att.net/>. Zeroping is a mutator
that replaces Unreal Tournament's normal, server-side hit test code with
client-side routines. According to Zeroping's creator, John Fraser,
"Zeroping is an experiment, not a crusade," adding that his goal is to
show that client-side hitscan is appropriate for serious play.

- SourceForge's Windows Installer XML (WiX) toolset

- Help Integration Wizard
is a beta tool to help you add your tool's help to the Visual Studio
Help Collection.

- SourceForge project for testing regular expressions
<http://regulator.sourceforge.net> - featuring syntax highlighting and
web-service integration with Regexlib.com's database of online regular

Potentially Interesting
- Ergito <http://www.ergito.com>. Online scientific publisher with an
impressive selection of free content including papers on classic
discoveries and even textbooks and/or chapters. Example: Chapter on
plant cells <http://www.ergito.com/toc.jsp?bcs=CBIO.4.13>.

- Photos of Martian "Endurance" crater from Opportunity
<http://www.jpl.nasa.gov/releases/2004/119.cfm>. Related: NASA en
Espanol <http://www.nasa.gov/about/highlights/En_Espanol.html>.

- Give stuff away free <http://www.freecycling.org> (posts by state).

- Good tutorials on Linux file commands and AWK: Guide to Linux File
Command Mastery
<http://otn.oracle.com/pub/articles/calish_file_commands.html> and AWK:
The Linux Administrators' Wisdom Kit

- Oracle OTN's search page for code, HowTo's, tutorials
<http://otn.oracle.com/sample_code/index.html>. Related: Technical
resources for developers and system architects
<http://otn.oracle.com/developer/index.html>, New to Oracle
<http://otn.oracle.com/new/index.html>, and Oracle Links

- Periodic Table of Poetry
<http://www.iscifistory.com/scifaku/elements/periodichaiku.asp> (haiku).

- Find out how to locate this month's comets <http://stardate.org/>.

- Find out about bird banding <http://www.pwrc.usgs.gov/bbl/>.

- Interesting article on Francis Bacon's theory of communication and
Cited from FB's Novum Organon: "For the mind of man is far from the
nature of a clear and equal glass, wherein the beams of things should
reflect according to their true incidence; nay, it is rather like an
enchanted glass, full of superstition and imposture, if it be not
delivered and reduced."

- Scads of info about the Cold War
<http://www.deepcold.com/deepcold/SITES.HTML> from the perspective of
space research. Related: an excerpt from Thomas Reed's new book on tech
sabotage during the Cold War

- Interesting article in the 5/7/04 issue of the WSJ on the rising price
of concert tickets <http://online.wsj.com/home/us> ("Parsley, Sage, and
$350 Tickets"). Free reg. required.

- Stockholm Water Institute's archive of articles about water
<http://www.siwi.org/downloads/downarticles.html>. Related: Prize
winners <http://www.siwi.org/swp/swplaureates.html>.

- Current (May 2004) issue of Game Developer (not online) features an
interesting article on what the next ten years might bring. Related: an
assortment of "classic" archived articles
<http://www.gamasutra.com/php-bin/article_display.php>. And a veritable
mother lode of conference slides <http://www.gdconf.com/archives/2004/>
(and /2003, /2002, etc.). Also related: developing games for the XP
Media Center Edition

- The British Museum site

- Canyons, Cultures, and Environmental Change
<http://www.cpluhna.nau.edu/index.htm> (land use history of the Colorado

- Not sure how to read a financial statement? <http://www.quickmba.com/>

- Bose-Einstein condensate spin state induced in Han purple, BaCuSi2O6

- Good article on normalizing reference data

- Trees limited to 130 meters?

- Gallery of images of from Virginia Tech's fluid mechanics department

- (US) Science and Engineering Indicators 2004

- Really cool scientific toys and kits

- Edge <http://www.edge.org/> - monthly collection of good essays.
Example: interview with Gary Marcus on language, biology, and the mind

- July 20-24 NHII 2004 conference
<http://www.hsrnet.net/nhii/welcome.htm> (Washington, DC) on electronic
healthcare and the required infrastructure.

- Business author Steve Denning focuses on the role of storytelling

- Is human appreciation of art hard wired

- Is Xen the next big thing
Unifying Tables Objects And Documents
Microsoft Research Looks to Extend C#

- Traveling to Prince Edward Island <http://www.peipotatomuseum.com/>?

- Audio book interviews <http://www.wiredforbooks.org/>.

- Perfect Mother's Day gift for the Mom who has everything - a
build-your-own Enigma machine
And only 120 pounds.

Post questions at:
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Food & Drink
 Health & Fitness
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.