SISÄLLYSLUETTELO

Mistä oikein on kyse?

3d

3d

3d

3d

3d

3d

3d (long)

3dpanel

3dpanel

3dpanel

3dpanel controls

3dpanel label

3dpanels & labels

Acc. pros/cons

Acc: add index

Acc: autorepair

Acc: better datamanage

Acc: borrow struct.

Acc: close DB/Dynasets

Acc: closing db

Acc: corrupted db

Acc: corrupted db

Acc: count records

Acc: CreateSnapShot

Acc: db-sql tip

Acc: Dev.Toolkit

Acc: diff. versions

Acc: diff. versions

Acc: equati from TextB

Acc: install. ISAM?

Acc: modifying db

Acc: multiusers?

Acc: no DataControl

Acc: opening db

Acc: pass table vars

Acc: rec.no aft.seek

Acc: res.errors

Acc: sep.data/query

Acc: sep.query/data

Acc: set db to nothing

Acc: tips

Accelerator key

Accelerator key

Acrobat PDF

Age compute

Age compute

Allways on top

Allways on top

Allways on top

Allways on top

Allways on top

AnsiToOem

AnsiToOem

API

API

API title of open Wnd

API writing data back

API?

Appl. title heading

Autodesk animating

AVI play

AVI play

Background paint

Background paint

Background paint

Background shaded

Background to MDI

Barcodes

Beta tester for MS??

Bit manipulaatio

Bit manipulation

Bit manipulation

Bit manipulation

Bit manipulation

BitBlt

BitBlt flicker-free

BitBlt kuvan kopioin

BitBlt overflow

BitBlt transparency

BitBlt using

Bitmap 256 palet

Bitmap animate BMP

Bitmap hot-spots

Bitmap hot-spots

Bitmap Load & cursor

Bitmap PICCLIP

Bitmap PICCLIP

Bitmap PICCLIP

Bitmap PICCLIP

Bitmap PICCLIP

Bitmap smooth display

Bitmap vs. ICO

Bitmaps

Bitmaps

Bmp storing

Bmp vs. RLE

Bmps and DB

Bmps etc.

Book multimedia

Book multimedia

Books

Bugs

Byte & bit

Byte & hex

Byte & hex

Byte & hex

ByVal

ByVal

Caller-ID

Capital. firstname

Caption bar small

Cards DLL

Carrier detect

CD

CD lengths

Checkbox modifying

Class inheritance

CLBV-digest

Clicking on line ctrl

Clipboard format custo

Clock make

CmdBtn w/Picture

CmdBtn w/Picture

CmdButn free

CmdButton 2 lines

CmdButton 2 lines

CmdButton set color

CmdButton toggle

CmdButton using Mouse

CmnDlg

CmnDlg

Code placement

Coding standards

Color shifts in *.hlp

Colors & system colors

Colors 16/256?

Colors 16/256?

Colors 256

Colors 256 colors

Colors constants

Colors show user

Comlyr

Comlyr

Comlyr

Comlyr Acc2comp.t

Copy files

Copy files, gauge

Copy fr. dir to dir

Copying arrays

Credit card validation

Ctl3D

Ctl3D

Ctl3D

Ctl3d

Ctl3d & Ctl3dv2

Ctl3D in controls

Ctl3d on forms

Ctl3d use it ok!

Ctl3d/Ctl3dv2 lue!

Ctrls lining up

Cursor control

Cursor custom

Cursor custom

Cursor custom

Cursor custom

Cursor GetCursorPos

Cursor GetCursorPos1

Cursor hide

Cursor hide

Cursor hide

Cursor hide

Cursor move

Cursor move

Cursor move

Cursor move

Cursor move

Data types converting

Datactrl missing/ide

Date of file

Dates

Dates

Dates

Dates

Dates comparing

Dates day of week

Dates formatting

Dates in listbox

Dates internationaliz

Dates internationaliz

Dates Julian convert

Dates leap year etc.

Dates no of weekdays

Dates number of day

Dates US & UK ??

Dates US & UK ??

Dates US & UK??

Dates USA/Europe

Dates USA/Europe

Debug.print leave!

Decompiler *.hlp

Decompiler *.hlp

Decompiler *.hlp

Decompiler VB

Decompiler VB

Delay

Delay

Delay

Delay

Delay

Delay

Delay

Delay

Delay ok 1

Delay ok 2

Delay ok 3/1

Delay ok 3/2

Delay ok 4

Delay ok 5

Delay ok_not

Delphi

Delphi documentation

Developm. enviroment?

DIM/%

Disable ALT+TAB

Disable ALT+TAB

Disable close

Disable close

Disable user input

Disable user input

Disable user input

Discompiler VB!

Disk free space

Disk free space

Disk label reading

Disk serial number

Disk serial number

Disk serial number

Display form

Display form 2

Display form faster

Display port.problems

Display port.solution

Display speed up

DLL and strings

DLL Borland<->MS

DLL browsing DLL

DLL callback

DLL calling

DLL calling

DLL calling

DLL calling

DLL calling

DLL calling & strings

DLL create in Borland

DLL create in Borland

DLL create with VB

DLL from Delphi

DLL function searcher

DLL help to create

DLL help to create

DLL long

DLL passing strings

DLL's left in memory

DLL's left in memory

DLL/VBX list loaded

DLLs un/reloading

DoEv avoid long loops

DoEvents better!

Drag & drop

Drag & drop

Drag & drop

Draw flow charts

Drive type iden

DriveListBox

Dynamic ctrls

Dynamic ctrls

Dynamic forms

EMS CDROM 59.50$

Encrypting

END

Energy saving monitor

Energy Star monitor

Enter

Enter

Error 3043

Error codes Acc 2.0 ?

Error codes Acc. 2.0

Error general

Error global errhandl

Error handling

Error Local error

Error placement of Er

Errorcodes vb 3.0

Exe limit

Exe making

Exe size

Exe size

Exe/ide

Exe/ide

Exe/ide

Exists

Exists

Exists

Exists

Exists

Exists

Exists

Exists

Exists

Exists

FAQs

Files > 64kB

Files associating

Files binary

Files binary in C

Files create temp

Files howto kill

Files open w/o ch.dat

Files random access

Files reading a Byte

Files sarjaportista

Files subdirs

Files Txt import

Find app.title

Find strings

Find strings

Find strings CboBox

Find strings CboBox

Find window

Find window

FindWindow

Flash eliminate

Font sizes

Fonts detect size

Fonts faster reading

Fonts print samples

Fonts reading fonts

Fonts smaller

Fonts TT

Form height?

Formatting a floppy

Forms

Forms arrays of

Forms call 2. proc.

Forms create runtime

Forms drag from FileM

Forms frm within othe

Forms hiding

Forms hiding

Forms hiding

Forms hiding

Forms hiding

Forms hiding

Forms limiting size

Forms loaded?

Forms move minimized

Forms resizing, good!

Forms save as image

Forms sizing

Forms sizing

Forms speed up

Forms true size of

Forms unloading

Forms which called?

Forms which is loaded

Frames copying btns

Frames option groups

Frames putting labels

Free space

FreeFile???

FRX extension

FTP site

FTP site WWW

FTP-site

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Full-text search

Gauge

Gauge

Gauge

GDI & User resourc

GDI & User resourc

GDI & User resources

GetModuleUsage

GetModuleUsage

GetModuleUsage

GetModuleUsage

GetModuleUsage

GetModuleUsage

GetProfileString

GetProfileString

GetProfileString

Graphics APIs

Graphics general

Graphics grow letters

Graphics new Wing API

Graphics painting only

Graphics timer & chang

Graphics transition

Grid alignment

Grid loading

Grid placing bitmap

Hex to Dec

Hex to Dec

Hex to Dec

Hinstance to hWnd

Hmemcpy copying

Hmemcpy with arrays

Hotkey in menus

Html->hlp

hWnd ... to HINSTANCE

Hwnd parent/child

hWnd retrieve handle

Icon animate

Icons

Icons 1

Icons 2

Icons 3

Icons fitting on btn

Icons how-to

IIF/Msafix.dll

Image ctrl as button

Inheritance

Inheritance

INI

INI and DBs

INI bugs in docs

INI bugs in docs!!

INI delete entry

INI finnish

INI internat.settings

INI manipulating

INI prgm's settings

INI read, write etc.

INI read/write

INI reading

INI summary

INI VB:n ini ja Help

INI VB:n ini ja Help

INI VB:n INI ym.

INI why app.ini ??

Instances detect prev

Instances detect prev

Instances prev.copies

Internationalize

Internationalize

Internationalize

Internationalize

Internationalize

Joystick

Joystick code

Key pressed

Keyb.buffer clearing

Kysymys

Landscape/portrait

Line breaks

Line breaks

Line breaks

Line Feeds to CRLF

Line speed up

Linked ListBox

Linked ListBox

Linked ListBox

Linked ListBox

Linked ListBox

ListBox > 64 k

Listbox > 64k

ListBox > 64kB

ListBox 500K needed

ListBox adding icons

ListBox Cbo preselect

ListBox graphics

ListBox ItemData etc.

ListBox layout probl.

ListBox LB_AddString

ListBox many fields

ListBox PgUp/PgDn

ListBox redraw

ListBox RemoveItem

ListBox resize fixed!

ListBox sample phone

ListBox scroll

ListBox searches

ListBox searches

ListBox searches

ListBox select all

ListBox size changing

ListBox size changing

ListBox sort desc.

ListBox syncronizing

ListBox trap scroll

Lists

Long

LostFocus

MDI active child?

MDI active child?

MDI change color!

MDI child form size

MDI children

MDI faster display

MDI minim.caption

MDI pros and cons

MDI removing maximize

MDI sending messages

MediaView

MediaView

MediaView long

MediaView new list

Menus add to oth. pgms

Menus itse lisätyt?

Menus msgblaster etc.

Menus multiple

Menus pop-up

Metafiles

Metafiles

Milliseconds

Milliseconds

Milliseconds

Milliseconds

Milliseconds

Milliseconds

Milliseconds

Milliseconds summary

Modular desig

Modules & memory

Mouse btn up/down

Mouse cursor

Mouse leaving form

Mouse on ? word

Mouse restrict movem.

MouseDown on MDI

MS fileitä

MS Pro Exam

MS Viewer 2.0

Msafinx.dll

Msajt200.dll

MsComm.Vbx Quirks

MSDN

MSDN cd-rom

MSDN cdrom

MSDN cdrom

MSDN cdrom

MSDN FAQ

MsgBlaster & forms

MsgBlaster 32-bit

MsgBlaster documentat

MsgBlaster using

MsgBox

MsgBox custom

Name of ctrl/frm runti

Naming & coding

NetWare

Network logging

Network Type

Networks

Networks find drives

Novell

Novell

Novell Netware

Novell NetWare

Null

Null

Obj.not Array

Obj.not Array

Obj.not Array

Obj.not Array

Obj.not Array

ODBC db closing

ODBC driver/API calls

ODBC performance

ODBC speed up Oracle

OLE and Excel

OLE VB&Word

OLE2UI

On top Windows

Option Explicit

Out of memory

Out of memory

Out of memory

Out of memory

Outline exp./select1

Outline exp./select2

P-code

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Parameters passing

Passing by reference

Password encrypt

Password encrypt

Password encrypt

Password encrypt

Password encrypt

Path runtime dir

Path stripp.filenames

PC speakers sounds

Performance

PicBox disab. update

Picture remove

Picture remove/delete

Picture remove/delete

Picture remove/delete

PictureBox copy scree

PictureBox ctl array1

PictureBox ctl array2

Postlists

Preview

Preview

Preview

Preview

Printer ch.orientatio

Printer change

Printer controlling

Printer controlling

Printer controlling

Printer orientation

Printer orientation

Printer printer ready

Printing change orien

Printing device FILE

Printing graph

Printing long names

Printing orient. etc.

Printing strings 1

Printing strings 2

Printing Word/Wp files

Printing X/Y-coords

Q/A database

QueryUnload

QuickSort

QuickSort

QuickSort

QuickSort

QuickSort

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes

Quotes etc.

Quotes summary

Read 1 byte

Readonly

Readonly

Readonly

Readonly

Readonly

Readonly

Readonly

Readonly

Readonly

Redraw off

Redraw off

Redraw off

Redraw off

Redraw off

Redraw off

REG.DAT&associat.appl.

Registration db

Registry database

Registry database

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Resolution

Rounding numbers

Screen autom.scaling

Screen autom.scaling

Screen refresh&updatW

Screen saver

Screen saver

Scroll bar slider

Scroll bars on forms

Scroll bars on forms

Scroll forms

Scroll forms

Scrollbar

Scrolling

Scrolling

Scrolling

Scrolling

Scrolling

Scrolling

Scrolling

Scrolling

Scrolling

Scrolling

Scrolling like movies

Scrolling like movies

Scrolling report 1/2

Scrolling report 2/2

Scrolling report 3/3

Scrolling static text

Scrolling1

Scrolling2

Search incr.

Search incr.

Search incr.

Search incr.

Security

Setup

Setup expand

Setup missing MSAFINX

Setup wizard

Setup Wizard

Setup/commdlg

Share

Share/Vshare

Share/Vshare3

Shell

Shell

Shell WinExec

Shell/dos/icons

Shelling

Shelling terminating

Sort

Sort

Sort

Sort

Sort recursion

Sound Blaster

Sound various subs

Sounds

Sounds

Sounds API calls

Sounds API decs

Sounds text to speech

Speed up

Speed up

Speed up

Speed up

Speed up db

Speed up SHELL

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen

Splash screen on top

SQL

SQL

SQL

SQL

SQL

SQL

SQL Dynaset to ASCII

SQL filter & Snapshot

SQL insert 1

SQL insert 2

SQL parameter query

SQL parameters 1

SQL parameters 2

SQL queries

SQL query listbox

SQL stored pro

SQL Workshop 3.0

SQLstored pro

Stack double!

Stack increasing

Status bar

Status bar

Status bar menu items

Status bar on menus

Status bar status bar

Stopwatch

Strings C style

Strings how wide

Strings how wide

System colors manipul

System menu

System menu

System menu

System menu acc.

System menu add

System menus

System rerources

System resources

System resources

Tab key

Tab key trap

Tab stops

Tab stops

Tab stops

Task killing

Task list

Text search fuzzy

Text search fuzzy

TextBox <--> label

TextBox > 32K

TextBox > 32k

TextBox > 64k

TextBox align ignored

TextBox append 1

TextBox append 2

TextBox append 3

TextBox append 5

TextBox center text

TextBox color disable

TextBox cursor to end

TextBox cursor to end

TextBox cursor to end

TextBox diff.colors

TextBox disabling etc

TextBox ENTER

TextBox Find & Scroll

TextBox find/scroll

TextBox forc. left

TextBox forc. left

TextBox ForeColor

TextBox highlight

TextBox highlight

TextBox highlighting

TextBox indiv. lines

TextBox Input filter

TextBox ins/overwrite

TextBox moving around

TextBox printing

TextBox printing

TextBox read file

TextBox read file

TextBox read files

TextBox readonly

TextBox right justify

TextBox tabstops

TextBox text parser

TextBox transparent

TextBox txt to PicBox

TextBox uppercase

Time 100th's of sec

Time 100th's of sec

Timer increase interv

Timer unreliable

TimerCount

Titlebar remove

Titlebar small

Toolbar floating

Toolbox horiz. ide

Tooltip

Tooltips

Tooltips capture mouse

Tooltips demo

Tooltips sample

Tooltips sample

Transparent

Trap alt + F4

Trap alt + tab

Trap alt + tab

TT-fonts install

Undo

Variant

VB .Frm to .Rc

VB 2 copies VB

VB 4.0

VB 4.0

VB 4.0

VB 4.0

VB 4.0

VB 4.0

VB 4.0

VB 4.0

VB 4.0

VB 4.0 books

VB 4.0 pricing

VB address of vars

VB closing applica

VB colored buttons

VB comparing ctrl var

VB extract imag. FRX

VB filled polygons

VB find exes

VB func. return array

VB hiding an applicati

VB history

VB Magazine

VB Magazine

VB Magazine

VB mail reader pgm

VB on CDROM

VB on CDROM

VB pass ctrl-arrays

VB personalization

VB Power ToolKit

VB prog Name & Path

VB Prog.Manager

VB reboot & start Win

VB Systems Journal

VB text to speech

VB Tips&Tric

VB vbx+dll+exe!

VB which app. running

VB written in VB???

VB yleistä

VBFAQ del pic propert

VBFAQ detect prev ins

VBFAQ general info

VBFAQ index&db&dctrl

VBFAQ install.ISAM

VBFAQ text/binary

VBFAQ where?

VBPJ European subscri

VBPJ listings internet

VBPJ news

Vbx Borland

Vbx create

Vbx create Borland

Vbx create Borland

Vbx create Borland

Vbx create Borland

Vbx create w, MS VC++

Vbx free db2stff.zip

Vbxs 0$!

Version stamp

Video mode

Virtual forms

Virtual ListBox

Virtual ListBox

Virtual ListBox

Virtual ListBox

VisBas-l

VisBas-l

VisBas-l

VisBas-l

Visbas-l

VisBas-l (long)

VSVBX general

VSVBX Lic.file

VSVBX tab controls

VSVBX tab ctrls

VSVBX tab ctrls

Wallpaper

Wallpaper

Wav

Wav

Wav Beep cmds

Wav play

Wav play

Wav vol.ctrl

Wav/Mid

WHAT6

WHAT6

Window manipulation

Window resources

Windows directory

Windows directory

WinHelp

WinHelp

WinHelp 4.0

WinHelp 4.0

WinHelp 4.0

WinHelp bullets W6

WinHelp embedded wnds

WinHelp general

WinHelp nonscr.paragr

WinHelp partial key

WinHelp resources

WinHelp resources

WinHelp smart quotes

WMF handle

WMF print

WMF print

Word 6.0 -> WinHelp

Word 6.0 removing Tip

Www books

Www home pag

Www Q/A db

Www sites

Www sites

Www VBIT

Www-link

Www-magazine

Www-site

Www-site

Www-sites

Www/ftp site


Mistä oikein on kyse

Mistä oikein on kyse?

Olen kerännyt Visual Basicia koskevia viestejä internetistä runsaan vuoden. Tällä hetkellä
saan päivittäin eri postituslistoilta ja alueilta yli neljäsataa viestiä. Näiden joukosta olen seulonut
mielenkiintoisimmat.

Täyshakuun eli Full-text -searchiin tarvittavat kolme DLL:ää ovat vapaasti imuroitavissa
Microsoftin ftp-palvelimelta. Helppi-tiedostoa voidaan käyttää myös ilman indeksiä. Silloin tulee
alussa muutama virheilmoitus eikä vapaa tekstihaku ole tietenkään käytettävissä.

Toivottavasti löydät mielenkiintoista asiaa...


matti.harju@pcb.compart.fi


3d

LUOKKA: 3d

Date: 06/17/94 (20:48)              Number: 9433 of 9506 (Refer# NONE)

From: EDSTAFF@MCS.COM

Subj: Demo of how to do 3d without a vbx

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here's some code I put together that works pretty nicely.

It's actually quite simple. The 3d effect produced by the code below will

produce 3d frames on *any* control including lightweights.   The 3d effect is

modelled after the 3d effect on controls in Access2. Use the Frame sub for

controls that are directly on a form. Use Frame2 to if you have controls that

are on a panel of some sort or group box, you will want to place a picture box

on the panel and then the other controls on the picture box. This is

necessarybecause otherwise I have now way to use the line methods.

Any questions, bugs, complaints or criticisms should be sent directly to me.

It's fast and it's free. Enjoy.

Sub frame (f As Form, c As Control)

    Dim offset%

    Dim oldScaleMode%

    If c.Visible = False Then Exit Sub

    oldScaleMode = f.ScaleMode

    f.ScaleMode = PIXELS

    offset = 1

    f.DrawWidth = 1

    f.ForeColor = BLACK

    'top:

    f.Line (c.Left - offset, c.Top - offset)-Step(c.Width + offset, 0)

    'left:

    f.Line (c.Left - offset, c.Top - offset)-Step(0, c.Height + offset)

    offset = 2

    f.ForeColor = DARK_GREY

    'top:

    f.Line (c.Left - offset, c.Top - offset)-Step(c.Width + offset + 1, 0)

    'left:

    f.Line (c.Left - offset, c.Top - offset)-Step(0, c.Height + offset + 1)

    offset = 1

    f.ForeColor = LT_GRAY

    'bottom:

    f.Line (c.Left - offset, c.Top + c.Height + offset)-Step(c.Width + offset,0)

    'right:

    f.Line (c.Left + c.Width, c.Top - offset)-Step(0, c.Height + offset)

    f.ForeColor = WHITE

    offset = 1

'    'bottom:

    f.Line (c.Left - offset - 1, c.Top + c.Height + offset)-Step(c.Width +

offset + 3, 0)

'    'right:

    f.Line (c.Left + c.Width + 1, c.Top - offset - 1)-Step(0, c.Height + offset

+ 2)

 '   ' Leave everything the way we found it

    f.ScaleMode = oldScaleMode

End Sub

Sub Frame2 (p As Control, c As Control)

    Dim offset%

    Dim oldScaleMode%

    oldScaleMode = p.ScaleMode

    If c.Visible = False Then Exit Sub

    p.ScaleMode = PIXELS

    offset = 1

    p.DrawWidth = 1

    p.ForeColor = BLACK

    'top:

    p.Line (c.Left - offset, c.Top - offset)-Step(c.Width + offset, 0)

    'left:

    p.Line (c.Left - offset, c.Top - offset)-Step(0, c.Height + offset)

    offset = 2

    p.ForeColor = DARK_GREY

    'top:

    p.Line (c.Left - offset, c.Top - offset)-Step(c.Width + offset + 1, 0)

    'left:

    p.Line (c.Left - offset, c.Top - offset)-Step(0, c.Height + offset + 1)

    offset = 1

    p.ForeColor = LT_GRAY

    'bottom:

    p.Line (c.Left - offset, c.Top + c.Height + offset)-Step(c.Width + offset,

0)

    'right:

    p.Line (c.Left + c.Width, c.Top - offset)-Step(0, c.Height + offset)

    p.ForeColor = WHITE

    offset = 1

'    'bottom:

    p.Line (c.Left - offset - 1, c.Top + c.Height + offset)-Step(c.Width +

offset + 3, 0)

'    'right:

    p.Line (c.Left + c.Width + 1, c.Top - offset - 1)-Step(0, c.Height + offset

+ 2)

 '   ' Leave everything the way we found it

    p.ScaleMode = oldScaleMode

End Sub


3d

LUOKKA: TextBox

23903 (148+)  straffin@ix.netcom.com  06.07.95  19:17

John C. Straffin: "Re: 3D Listbox (plus more questions)"

visualware@interramp.com (John M. Miano) wrote:

>In article <544946068wnr@air21.demon.co.uk>, Pete Merrick

<pete@air21.demon.co.uk>

says:

>>I'm probably missing something very simple here, but how do I give a

>>List Box that sunken, 3D effect that seems so common in apps these

>>days ?

>Three ways I can think of off hand:

>1. Buy a 3rd party set of controls.  I highly recommend Aware VBX

>from Far Point.  There are others as wel.

>2. There are controls you can find that give every control on a form

>a 3D effect.

>3. You could use a window subclassing control and interecept the

>messages used to paint the control and draw your own 3d border.

>4. Take the 3D panel control that comes with VB Pro.  Set the autosize

>property to child to panel.  Set the panel's bevel inner porperty to

>lowered.  Draw a list box on the panel.  Set the list box's border

>style to none.

>That's four.

>

>John

All of these ways require you to package yet another .VBX with your

app and the free one (#4, if you own VB3Pro) still doesn't give you

the "Microsoft" 3D look.  I wanted the MS 3D look, so I took a screen

shot of an MS Word 6.0 sunken text box and examined it.  The following

code works just great for duplicating the MS 3D effect for text boxes,

list boxes, and grids (your milage may vary.)

1) If your text boxes are not directly on the form, put a picture

control under your text box(es). (Mine are on a 3D frame.  One picture

control works for the whole frame.)  Also, select border = none on the

text boxes.

2) Enter the following Subs (Mine are in a .BAS file)

~Declarations

Global PixH As Integer

Global PixV As Integer

~In the formMain_Load

PixH = Screen.TwipsPerPixelX

PixV = Screen.TwipsPerPixelY

(side question - where could I/should I put this in the .BAS?  Would

it not be as inefficient as I think to put it in _all 3_ of my MS-3D

Subs?)

~The functions

Sub MakeText3D (ToBe3D As Control, Container As Control)

    DrawWidth = 1

    Container.AutoRedraw = True

    'Black lines

    Container.Line (ToBe3D.Left - PixH, ToBe3D.Top +

...ToBe3D.Height)-(ToBe3D.Left - PixH, ToBe3D.Top - PixV), &H0&

    Container.Line (ToBe3D.Left - PixH, ToBe3D.Top -

...PixV)-(ToBe3D.Left + ToBe3D.Width, ToBe3D.Top - PixV), &H0&

    'Dark Gray lines

    Container.Line (ToBe3D.Left - (2 * PixH), ToBe3D.Top +

...ToBe3D.Height + PixV)-(ToBe3D.Left - (2 * PixH), ToBe3D.Top -

...(2 * PixV)), &H808080

    Container.Line (ToBe3D.Left - (2 * PixH), ToBe3D.Top -

...(2 * PixV))-(ToBe3D.Left + ToBe3D.Width + PixH, ToBe3D.Top -

...(2 * PixV)), &H808080

    'Light Gray lines

    Container.Line (ToBe3D.Left - PixH, ToBe3D.Top +

...ToBe3D.Height)-(ToBe3D.Left + ToBe3D.Width, ToBe3D.Top +

...ToBe3D.Height), &HC0C0C0

    Container.Line (ToBe3D.Left + ToBe3D.Width, ToBe3D.Top +

...ToBe3D.Height)-(ToBe3D.Left + ToBe3D.Width, ToBe3D.Top -

...(2 * PixV)), &HC0C0C0

    'White lines

    Container.Line (ToBe3D.Left - (2 * PixH), ToBe3D.Top +

...ToBe3D.Height + PixV)-(ToBe3D.Left + ToBe3D.Width + PixH,

...ToBe3D.Top + ToBe3D.Height + PixV), &HFFFFFF

    Container.Line (ToBe3D.Left + ToBe3D.Width + PixH, ToBe3D.Top +

...ToBe3D.Height + PixV)-(ToBe3D.Left + ToBe3D.Width + PixH,

...ToBe3D.Top - (3 * PixV)), &HFFFFFF

End Sub

(Wow...that was longer than I thought...if you want the others, e-mail

me.  If enough ask, I'll post them too (as seperate posts.))

3) Make the following call in the formWithTheTextBox_Load

    Call MakeText3D(form!txtBox, form!pctControl)

That's it!  And it looks great!

Side question #2:  How much impact on application size/performance

will the necessary picture controls have on my app?

- John (straffin@ix.netcom.com)


3d

LUOKKA: TextBox

Date: 08/20/94 (00:46)              Number: 16328 of 16389 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: 3D Text Box?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 08-18-94 MILLARD@NETCOM.COM  wrote:

M>"Arjen Broeze" <arjen@shear.iaf.nl> writes:

M>>Place a text-box on a threed-panel or draw lines around it yourself

M>in >the Form_Paint event. If you need example code of this let me

M>know.

M>This works well, but I wanted to dynamically load multiple instances

M>of this 3d text box at run time in a control array, but when I load

M>more instances of the text box, they are placed in the same 3dpanel.

M>Bummer. If anyone knows how to load mutiple instances of a 3d text box

M>control let me know.

You'll need to load a new 3dPanel _AND_ a new text box, then use the

SetParent API function to make the textbox a child of the panel.  It's

easier to just load a new textbox and paint a few lines around it.

Alternatively, VSVBX.VBX (by videosoft) has an elastic control that,

among other things, can be set to automatically give a 3d look to all

child controls.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


3d

LUOKKA: TextBox

Date: 11/13/94 (20:12)              Number: 26708 of 26823 (Refer# NONE)

From: ELIJAH@BGA.COM

Subj: Re: 3D text input box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: Is there any easy way to create a 3D text box control (such as in some

: Windows applications)?

'I have not used it yet but this code purports to do just that:

Sub Draw3dFrame (f As Form, C As Label)

'draw label size you want frame -- no autosize

'label font must be same as form font!

Const White = &HFFFFFF

Const DarkGrey = &H808080

Dim X1%, X2%, Y1%, Y2%, FrameHeight%, FrameWidth%, FrameLeft%,

FrameTop%

f.DrawWidth = 1

FrameLeft% = C.Left

FrameTop% = C.Top

FrameHeight% = C.Height

FrameWidth% = C.Width

'Draw left of label

X1% = FrameLeft% - 60

X2% = FrameLeft% - 180

Y1% = FrameTop% + (f.TextHeight(C.Caption) / 2) - 60

f.ForeColor = DarkGrey

f.Line (X1%, Y1%)-(X2, Y1%)

Y1% = Y1% + 20

f.ForeColor = White

f.Line (X1%, Y1%)-(X2, Y1%)

'Draw left side

Y2% = Y1% + FrameHeight%

f.ForeColor = DarkGrey

f.Line (X2%, Y1%)-(X2%, Y2%)

X2% = X2% + 20

f.ForeColor = White

f.Line (X2%, Y1%)-(X2%, Y2%)

'draw bottom

X1% = X2%

X2% = FrameLeft% + FrameWidth%

f.ForeColor = DarkGrey

f.Line (X1%, Y2)-(X2%, Y2%)

Y2% = Y2% + 15

f.ForeColor = White

f.Line (X1%, Y2)-(X2%, Y2%)

'draw right

Y1% = FrameTop% + (f.TextHeight(C.Caption) / 2) - 60

f.Line -(X2%, Y1%)

f.ForeColor = DarkGrey

X1% = X2% - 20

f.Line (X1%, Y2% - 20)-(X1%, Y1% + 20)

'draw top to label right

X2% = FrameLeft% + f.TextWidth(C.Caption) + 60

f.Line (X1%, Y1% - 15)-(X2%, Y1% - 15)

f.ForeColor = White

f.Line (X1%, Y1%)-(X2%, Y1%)

End Sub

source - Paul Bonner VB Utilities Ziff Davis Press


3d

LUOKKA: TextBox

Date: 11/15/94 (16:47)              Number: 26880 of 26882 (Refer# NONE)

From: ROBERTW@NETCOM.COM

Subj: Re: 3D Text Boxes?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: Yes, I know, this is stupid question #328, but how do I get text boxes to

: show up in 3D like they do on the common dialogs with I do the

3DCTRL.DLL

: stuff?  Just sign me confused - everything else on my form shows up in

: 3D except the damned text boxes.

Put your text box in a 3Dpanel.  Set the panel's autosize property to

"autosize child to panel".  Play with the panel's bevel properties until

you get the look you want.

Robert Wallace

robertw@netcom.com


3d

LUOKKA: TextBox

Date: 11/29/94 (12:14)              Number: 28318 of 28326 (Refer# NONE)

From: BEMILLER@AMOCO.COM

Subj: Re: panel3d with textbox

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>In design time I created a panel3d and inside I put a text box.

>Both are defined as arrays.  In runtime I load both but the text

>box doesn't show up inside the new panel3d.  Can anyone tell me

>where the problem is?

When the new text control is loaded, it's parent needs to be set to the 3D

panel. Try the following example:

'1) place a 3d panel on a form, and draw a text control in it

'2) place this function declaration in a module

'3) listen to toad the wet sprocket :-) (obscure band name)

Declare Function setparent Lib "User" (ByVal hWndChild As Integer, ByVal

hWndNewParent As Integer) As Integer

Sub Form_Load ()

Dim rc%, i%

  For i = 1 To 5

    Load panel3d1(i)

    Load Text1(i)

    panel3d1(i).Top = panel3d1(i - 1).Top + 500

    panel3d1(i).Visible = True

    Text1(i).Visible = True

    rc = setparent(Text1(i).hWnd, panel3d1(i).hWnd)

  Next

End Sub


3d

LUOKKA: TextBox

Date: 11/30/94 (16:40)              Number: 28462 of 28468 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: panel3d with textbox

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>In design time I created a panel3d and inside I put a text box.

>Both are defined as arrays.  In runtime I load both but the text

>box doesn't show up inside the new panel3d.  Can anyone tell me

>where the problem is?

Yup. When you load your new panel and textbox, the presumptive parent of

the second instance of the textbox is the *first* instance of the panel.

You'll have to use an explicit SetParent call to make it work as you want it.

Sample code follows...

VERSION 2.00

Begin Form Form1

   BackColor       =   &H00C0C0C0&

   Caption         =   "Form1"

   ClientHeight    =   3180

   ClientLeft      =   1095

   ClientTop       =   1485

   ClientWidth     =   8145

   Height          =   3585

   Left            =   1035

   LinkTopic       =   "Form1"

   ScaleHeight     =   3180

   ScaleWidth      =   8145

   Top             =   1140

   Width           =   8265

   Begin SSPanel Panel3D1

      BevelInner      =   1  'Inset

      Caption         =   "Panel3D1"

      Height          =   1995

      Index           =   0

      Left            =   300

      TabIndex        =   0

      Top             =   540

      Width           =   2775

      Begin TextBox Text1

         Height          =   1875

         Index           =   0

         Left            =   60

         TabIndex        =   1

         Text            =   "Text1"

         Top             =   60

         Width           =   2655

      End

   End

End

Option Explicit

'

Declare Function SetParent Lib "User" (ByVal hWndChild As Integer, ByVal

hWndNewParent As Integer) As Integer

Sub Form_Load ()

Dim ix As Integer

    Show

    DoEvents

    Load Panel3D1(1)

    Panel3D1(1).Left = Panel3D1(1).Left + Panel3D1(0).Width

    Load Text1(1)

    ix = SetParent(Text1(1).hWnd, Panel3D1(1).hWnd)

    Panel3D1(1).Visible = True

    Text1(1).Visible = True

End Sub


3d (long)

LUOKKA: 3d

Date: 04-05-95 (21:09)              Number: 285004 of 286568 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Ctl3D in Forms  VB Solution

This is my code for 3D borders on Forms.

there are 4 files included in the mail.

3DFRAME.TXT     Description of the BAS module

3DFRAME.BAS     The BAS module

3DFRAME.MAK     Demo MAK file

3DFRAME.FRM     Demo FRM file

Start file ----------3DFRAME.TXT----------

              3DFrame

This is a VB code that puts 3D frame on forms with fixed double.  To use this

you need to have MsgBlast v. 2.2a (2.2).

Whith this code and MsgBlast you can give your forms a 3D look but you just

have to include one .BAS file and insert 2 lines of code.

To use this you must include 3DFrame.BAS in your project and

MsgBlast.VBX.  In the Form_Load event you put the line :

Call Init3DFrame(MsgBlast, Me)

and in the MsgBlaster_Message you put the line :

Call Paint3DFrame(Me, MsgVal, True/False)

The form is not painted properly after CommonDialog Box.  I have debuged

this some and I have not found any call to the form when the form is to be

repainted after the CommonDialog box goes away.   Just use this call after

the

CommonDialog box goes:

Call Paint3DFrame(Me, DRAW, True/False) and the 3D border will be drawn.

The True/False parameter shold be True OR False. This parameter indicates

if the control box should be in 3D or not.  Try this out.

For you who don't have MsgBlast you can get it at ftp.mcs.com in the

mcsnet.users™edstaff directory

You are free to do what ever you choose with this code.  I take no guarenty

on anything about this. You use this on your own risk.

Any comments/requests are wellcome:

Olafur Orn Jonsson, Iceland

oliorn@ibm.is

End file ----------3DFRAME.TXT----------

Start file ----------3DFRAME.BAS----------

Option Explicit

Type RECT

  Left As Integer

  Top As Integer

  Right As Integer

  Bottom As Integer

End Type

Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, lpRect As

RECT)

'Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

Integer

Const SM_CYCAPTION = 4

Const SM_CXBORDER = 5

Const SM_CYBORDER = 6

Const SM_CXDLGFRAME = 7

Const SM_CYDLGFRAME = 8

Declare Function CreatePen Lib "GDI" (ByVal nPenStyle As Integer, ByVal

nWidth As Integer, ByVal crColor As Long) As Integer

Const PS_SOLID = 0

Declare Function SelectObject Lib "GDI" (ByVal hDC As Integer, ByVal

hObject

As Integer) As Integer

Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As

Integer

Declare Function GetWindowDC Lib "User" (ByVal hWnd As Integer) As

Integer

Declare Function GetDC Lib "User" (ByVal hWnd As Integer) As Integer

Type PAINTSTRUCT

  hDC         As Integer

  fErase      As Integer

  rcPaint     As RECT

  fRestore    As Integer

  fIncUpdate  As Integer

  rgbReserved As String * 16

End Type

Declare Function BeginPaint Lib "User" (ByVal hWnd As Integer, lpPaint As

PAINTSTRUCT) As Integer

Declare Function MoveTo Lib "GDI" (ByVal hDC As Integer, ByVal X As

Integer,

ByVal Y As Integer) As Long

Declare Function LineTo Lib "GDI" (ByVal hDC As Integer, ByVal X As

Integer,

ByVal Y As Integer) As Integer

Declare Sub EndPaint Lib "User" (ByVal hWnd As Integer, lpPaint As

PAINTSTRUCT)

Declare Function ReleaseDC Lib "User" (ByVal hWnd As Integer, ByVal hDC

As

Integer) As Integer

Const LightGrayPenColor = &HC0C0C0

Const DarkGrayPenColor = &H808080

Const WhitePenColor = &HFFFFFF

Const BlackPenColor = &H0&

Const WM_NCACTIVATE = &H86

Const WM_NCPAINT = &H85

Const WM_ACTIVATE = &H6

Const WM_ACTIVATEAPP = &H1C

Const WM_USER = &H400

Global Const DRAW = WM_USER + 1

Const PREPROCESS = -1

Const EATMESSAGE = 0

Const POSTPROCESS = 1

Const FIXED_DOUBLE = 3   ' 3 - Fixed Double (Forms only)

Sub Init3DFrame (MsgBlast As Control, Frm As Form)

  Frm.BackColor = LightGrayPenColor

  MsgBlast.hWndTarget = Frm.hWnd

  MsgBlast.MsgList(0) = WM_NCPAINT

  MsgBlast.MsgPassage(0) = PREPROCESS

  MsgBlast.MsgList(1) = WM_NCACTIVATE

  MsgBlast.MsgPassage(1) = PREPROCESS

End Sub

Sub Paint3DFrame (Frm As Form, MsgVal As Integer, ControlBox3D As

Integer)

  Dim Window      As RECT

  Dim Paint       As PAINTSTRUCT

  Dim XSize       As Integer

  Dim YSize       As Integer

  Dim Caption     As Integer

  Dim hDC         As Integer

  Dim iret        As Integer

  Dim lret        As Long

  Dim DarkPen     As Integer

  Dim LightPen    As Integer

  Dim WhitePen    As Integer

  Dim BlackPen    As Integer

  Dim OldPen      As Integer

  Dim I           As Integer

  Dim hWnd        As Integer

  If (MsgVal = WM_NCACTIVATE Or MsgVal = WM_NCPAINT Or MsgVal =

TEIKNA) And

(Frm.BorderStyle = FIXED_DOUBLE) Then

    hWnd = Frm.hWnd

    Call GetWindowRect(hWnd, Window)

    XSize = GetSystemMetrics(SM_CXDLGFRAME)

    YSize = GetSystemMetrics(SM_CYDLGFRAME)

    Caption = GetSystemMetrics(SM_CYCAPTION)

    DarkPen = CreatePen(PS_SOLID, 1, DarkGrayPenColor)

    LightPen = CreatePen(PS_SOLID, 1, LightGrayPenColor)

    WhitePen = CreatePen(PS_SOLID, 1, WhitePenColor)

    BlackPen = CreatePen(PS_SOLID, 1, BlackPenColor)

    hDC = GetWindowDC(hWnd)

    Paint.hDC = hDC

    Paint.rcPaint = Window

    iret = BeginPaint(hDC, Paint)

    OldPen = SelectObject(hDC, DarkPen)

    lret = MoveTo(hDC, 0, Window.Bottom - Window.Top - 1)

    iret = LineTo(hDC, 0, 0)

    iret = LineTo(hDC, Window.Right - Window.Left - 1, 0)

    iret = SelectObject(hDC, BlackPen)

    lret = MoveTo(hDC, Window.Right - Window.Left - 1, 0)

    iret = LineTo(hDC, Window.Right - Window.Left - 1, Window.Bottom -

Window.Top - 1)

    iret = LineTo(hDC, 0, Window.Bottom - Window.Top - 1)

    iret = SelectObject(hDC, WhitePen)

    lret = MoveTo(hDC, 1, Window.Bottom - Window.Top - 2)

    iret = LineTo(hDC, 1, 1)

    iret = LineTo(hDC, Window.Right - Window.Left - 2, 1)

    iret = SelectObject(hDC, DarkPen)

    lret = MoveTo(hDC, 1, Window.Bottom - Window.Top - 2)

    iret = LineTo(hDC, Window.Right - Window.Left - 2, Window.Bottom -

Window.Top - 2)

    iret = LineTo(hDC, Window.Right - Window.Left - 2, 0)

    iret = SelectObject(hDC, LightPen)

    For I = 2 To YSize

      lret = MoveTo(hDC, 2, I)

      iret = LineTo(hDC, Window.Right - Window.Left - 2, I)

      lret = MoveTo(hDC, 2, Window.Bottom - Window.Top - I - 1)

      iret = LineTo(hDC, Window.Right - Window.Left - 2, Window.Bottom -

Window.Top - I - 1)

    Next I

    For I = 2 To XSize

      lret = MoveTo(hDC, I, 2)

      iret = LineTo(hDC, I, Window.Bottom - Window.Top - 2)

      lret = MoveTo(hDC, Window.Right - Window.Left - I - 1, 2)

      iret = LineTo(hDC, Window.Right - Window.Left - I - 1, Window.Bottom -

Window.Top - 2)

    Next I

    If Len(Frm.Caption) Or Frm.ControlBox Then

      iret = SelectObject(hDC, DarkPen)

      lret = MoveTo(hDC, XSize + 1, Caption + YSize - 1)

      iret = LineTo(hDC, XSize + 1, YSize)

      iret = LineTo(hDC, Window.Right - Window.Left - XSize - 2, YSize)

      iret = SelectObject(hDC, WhitePen)

      lret = MoveTo(hDC, Window.Right - Window.Left - XSize - 2, YSize + 1)

      iret = LineTo(hDC, Window.Right - Window.Left - XSize - 2, Caption +

YSize - 1)

      iret = LineTo(hDC, XSize, Caption + YSize - 1)

    End If

    If Frm.ControlBox And ControlBox3D Then

      lret = MoveTo(hDC, XSize + 2, YSize + Caption - 2)

      iret = LineTo(hDC, XSize + 2, YSize + 1)

      iret = LineTo(hDC, XSize + Caption, YSize + 1)

      iret = SelectObject(hDC, DarkPen)

      lret = MoveTo(hDC, XSize + Caption - 1, YSize)

      iret = LineTo(hDC, XSize + Caption - 1, YSize + Caption - 2)

      iret = LineTo(hDC, XSize + 1, YSize + Caption - 2)

    End If

    iret = SelectObject(hDC, OldPen)

    Call EndPaint(hWnd, Paint)

    iret = ReleaseDC(hWnd, hDC)

    iret = DeleteObject(DarkPen)

    iret = DeleteObject(LightPen)

    iret = DeleteObject(WhitePen)

    iret = DeleteObject(BlackPen)

  End If

End Sub

End file ----------3DFRAME.BAS----------

Start file ----------3DFRAME.MAK----------

3DFRAME.FRM

C:™WINDOWS™SYSTEM™MSGBLAST.VBX

3DFRAME.BAS

ProjWinSize=23,552,248,215

ProjWinShow=2

IconForm="Form1"

Title="3DFRAME"

ExeName="3DFRAME.EXE"

End file ----------3DFRAME.MAK----------

Start file ----------3DFRAME.FRM----------

VERSION 2.00

Begin Form Form1

   BackColor       =   &H00FFFFFF&

   BorderStyle     =   3  'Fixed Double

   Caption         =   "Gluggi"

   ClientHeight    =   1455

   ClientLeft      =   2565

   ClientTop       =   1935

   ClientWidth     =   2295

   Height          =   1830

   Left            =   2520

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   97

   ScaleMode       =   3  'Pixel

   ScaleWidth      =   153

   Top             =   1605

   Width           =   2385

   Begin MsgBlaster MsgBlast

      Prop8           =   "Click on ""..."" for the About Box ---->"

      Prop9           =   "Click on ""..."" for the Message Center --->"

      Left            =   120

      MsgList         =   3DFRAME.FRX:0000

      MsgPassage      =   3DFRAME.FRX:0064

      TargetName      =   ""

      Top             =   120

      UserMsgs        =   3DFRAME.FRX:0096

      Version         =   "2.2"

   End

   Begin CommandButton Command1

      Caption         =   "End Demo"

      Height          =   375

      Left            =   120

      TabIndex        =   0

      Top             =   960

      Width           =   2055

   End

End

Option Explicit

Sub Command1_Click ()

  End

End Sub

Sub Form_Load ()

  Call Init3DFrame(MsgBlast, Me)

End Sub

Sub MsgBlast_Message (MsgVal As Integer, WParam As Integer, lParam As

Long,

ReturnVal As Long)

  Call Paint3DFrame(Me, MsgVal, True)

End Sub

End file ----------3DFRAME.FRM----------

oliorn@ibm.is

Olafur Orn Jonsson

Alfheimar 70

101 Reykjavik

Iceland


3dpanel

LUOKKA: 3d

Date: 01/16/95 (13:25)              Number: 187424 of 187649 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: 3dpanel?

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>Is it possible to send a 3dpanel to "the back" so that controls may be

>placed on it "to the front" to give a 3D look to a form.

One other comment here, based on a problem which I have recently

overcome.

VB keeps things in three layers. Output of graphics methods is in the back

layer, then in theory come controls. It seems however that 3d frames (I

assume panels have the same problem) are in the third, frontmost layer. If,

like me, you have a control which you want to move around the form,

sometimes going outside the panel or frame in question, then you need to

contain it in its own panel or frame, resizing to that of the contents, in

order for it to appear on top of 3d controls.

If the other comments don't solve your problem, and this sounds like it's on

the right lines, email me direct (dwm@dld.dircon.co.uk).

==========================================================

David Musgrove

Telephone: +44 (0)171 229 1449    Fax: +44 (0)171 727 0281


3dpanel

LUOKKA: 3d

Date: 01/17/95 (11:58)              Number: 188627 of 188847 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: 3dpanel?

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

I recently read about this simple property setting for the 3d panel that left

me completely dumbfounded that this was not more obvious to me.  Since no

one has mentioned it yet, I figured I'd pass it on, if only just as a reminder.

Once you set your 3D panel on the form and place another object in it, set

the "autosize" property to "3"(autosize child to parent).

This solved one of my greatest problems with creating a 3D look, aligning the

child and properly fitting it inside the panel.  The autosize works with

everything I've stuck in a panel from a grid control to list box to a text

box.  Hope this helps.


3dpanel

LUOKKA: 3d

Date: 01/25/95 (10:51)              Number: 197819 of 198183 (Refer# NONE)

From: BRIAND@AZTEC.INRE.ASU.EDU

Subj: Re: 3D Forms

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

The way I give forms a 3-D apperance is to create a form, I'll call it

Form1, and a 3-D Panel (threed.VBX), which I call pnlForm.  Then, in the

Form.Resize event, I place the following code:

        pnlForm.Top = 0

        pnlForm.Left = 0

        pnlForm.Width = Form1.ScaleWidth

        pnlForm.Height = Form1.ScaleHeight

Then, I just place all of my controls on the 3-D panel.

briand


3dpanel controls

LUOKKA: 3d

17776 (123+)  ceddy@ipctech.com  18.05.95  17:57

Craig Eddy: "Re: Adding existing controls to a three-D panel"

In article <3pars7$mu9@ankh.iia.org>, ssingh@ios.com (Surendra Singh)

wrote:

>Is there any way to add existing controls to a three-d panel? If I drop a

>control on the three-d panel it goes behind the panel. Any new controls

>created and placed directley on the panel work fine.

>In the past I have deleted the control and created a new one with the

>same name. I really don't want to do this. Is there a solution???

After you Edit/Cut (ctrl-x) the controls from the form, click on the 3D panel

to make sure it is selected. Then Edit/Paste (ctrl-v) and the items will now

be actually IN the 3D panel container. To verify this, move the panel and the

controls you just pasted should move too.

Craig


3dpanel label

LUOKKA: VBgen

9755 (15+)  cstuart@metronet.com  17.03.95  12:57

Chuck Stuart: "Re: How to put label on top of 3dpanel?"

>How can I put a label on top of a 3d-panel?  I'm basically trying to use

>a 3dpanel as a backdrop for other buttons and this one label.  When I use

>"bring to front" on all the buttons and the label, the label never shows

>up, but is eclipsed by the panel.  I can make the label show up if I make

>the 3d-panel not visible of course, but then what's the point?

The label is in a different graphical level and in order to be visible on a

panel, it must be 'drawn' on the panel. Actually all controls placed within

a container should be 'drawn' on the container.

1. Select the label on the toolbar.

2. Move the cursor to the panel. The cursor will change to a crosshair.

3. Holding the left button down, draw the outline of the label.

Notice that when controls are drawn on a container and the container is

moved,

all the controls inside the container also move.


3dpanels & labels

LUOKKA: 3d

Date: 12/22/94 (10:52)              Number: 30471 of 30737 (Refer# NONE)

From: AJM@GEAC.CO.NZ

Subj: Re: VB/Win Label won't go on SSPanel

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

.....

>My question (I'll probably get trashed for this one, but I couldn't

>find an answer in the manual) concerns placing a Label on a SSPanel.

>I'm using VB/Win Pro 3.0 and cannot get a Label to go on top of a

>SSPanel. Tried Bring to Front/Send to back, lotsa other things.

>Can it be done?

Why should you be trashed? It is a perfectly reasonable question.

Unfortunately, the answer is, no, you can't. Because labels are

'lightweight' controls, they do not exist at runtime as real windows -

that is, they do not have an hWnd. Therefore their zorder is such that

they always display 'behind' real windows.

However, 3d panels have captions, and you can align the caption quite

flexibly on the panel, so why not just put the text you would have put in

the label into the panel caption. Or use another 3d panel like a label

control; you *will* be able to put it on top of another panel as it is a

real window.

There is one gotcha. 3d panels always wrap their captions, which may

under some circumstances be annoying. But if the panel's wide enough to

fit the text, you won't have a problem.

Actually, I use 3d panels all over the place. They are the ideal general

purpose control for frames (use SetParent to give them children) or

labels, or status bars, and if you set the font to a very small one, you

can size them down to weeny little black boxes and use them as drawing

handles too. Plus they don't seem to consume a lot of resource. Also you

can bitblt images onto them, so they make cheap picture boxes. And they

have a good selection of events (not paint though, which is a shame).

----------------------------Jatkuu..------------------------------------

Of course. My apologies. If you make the panel the parent at design

time VB *can* handle it. But this *must* be done at design time. I had

assumed that the requirement was to do this at runtime - and I see now I

may have misunderstood the original question. Since labels don't have an

hWnd, I cannot see how you would establish the parent/child relationship

at runtime since SetParent requires an hWnd. If you simply moved the

label to occupy the same coordinates as the panel it would be obscured by

the panel.

I assume, though this doesn't seem to be extremely well-documented, that

VB actually does paints in three stages; (a) it gives you a paint event

and you do your stuff. (b) it then lets the child windows repaint - they

have WM_PAINT messages already queued at the time your paint event is

fired (and a doevents will let them paint first) and (c) based on

design-time knowledge of lightweight control parent-child relationships,

VB then paints the lightweight controls.

But I didn't think that this design-time relationship between a

lightweight control (which at design time is a real window (isn't it?),

but which at runtime is not) could be changed at runtime.

Once again, I must apologise if I misled anyone. I would hate to spread

misinformation.


Acc. pros/cons

LUOKKA: Access

3. Is the Access Engine and Visual Basic Pro good enough for database

work?

   That, of course, depends. Generally the answer is "yes", but you may

   need some third-party add-on products.

   These are the major weaknesses of VBPro's database functions:

   a. Limited data controls: No add, delete or search button; no bound list

      box or masked edit control and - the worst - no bound grid!

   b. No run-time query builder ("how good is your user in SQL?") or report

      builder.

   c. No direct advanced control of the Access 1.1 (or 2) Database Engine

      (ie. security, optimization, etc).

   d. SQL us SLOW. Handcoding is much faster (but harder to code)

   The good news is that lots of companies are willing to sell you products

   which address one or more of the above weaknesses.

   Also, if you build a database application with advanced database

   relations, it can be a good idea to build the database itself with

   Access and the front-end with VON BECKER.


Acc: add index

LUOKKA: Access

Date: 09/17/94 (20:00)              Number: 19862 of 19876 (Refer# NONE)

From: LGAINOUS@IX.NETCOM.COM

Subj: Re: Please HELP, SEEK method...

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>So, how to make the table indexed by one of the fields other than the

>primary key.

sub makeIndex()

'// Creates a secondary index in a table from one or multiple columns

'// Les Gainous 06/23/94

Dim dbTmp As database

Dim idxTmp As New Index  ' Create new Index object.

'// make up a name for this new index

idxTmp.Name = "Your_Index_Name"  ' Set Index properties.

'// substitute the column name(s) in the next line with

'// yours (separate them with ";"

idxTmp.Fields = "LastName;FirstName"

'// true if index is to be unique for each row, set to

'// false, otherwise

idxTmp.Unique = True

'// append the new index to the indexes collection of the table

'// first open the database in exclusive mode

Set dbTmp = OpenDatabase("c: vb apps adams gpo.mdb", true)

dbTmp.TableDefs("yourTableName").Indexes.Append idxTmp

end sub


Acc: autorepair

LUOKKA: Access

Date: 04-21-95 (03:20)              Number: 297290 of 301771 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Auto Repair Access Files

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

---------------------------------------------------------------

Function CheckDB (DBName As String) As Integer

  Dim MyDB As Database

  Dim DidRetry As Integer

  On Local Error Resume Next

  DidRetry = False

DoOpenDatabase:

  Err = 0

  Set MyDB = OpenDatabase(DBName)

  If Err = 3043 Then

    ' Disk or Network Error

    MsgBox "Database Engine Error.  Please restart Windows and this

application.", 16

    End

  ElseIf Err = 3049 Then

    ' Database Corrupted

    If Not DidRetry Then

      ' Try to repair Database

      RepairDatabase DBName

      DidRetry = True

      GoTo DoOpenDatabase

    Else

      MsgBox "Database repair failed.  Please contact your local support

person.", 16

      End

    End If

  End If

End Function

----------------------------------------------------------------

Brent McCray

Pacific Gas & Electric Company


Acc: better datamanage

LUOKKA: Access

6917 (18+)  moslon@interlog.com  04.07.95  07:04

Mike Oslon: "OsloData available via FTP"

I have written a REALLY useful (in my opinion) Database Manager

Application ('OsloData')

It is now available via FTP at:

ftp.apexsc.com in direcory /pub/cgvb/uploads

and also from my WWW site: http://www.interlog.com/~moslon/

Some of its features:

----------------------

     An integrated MDI app

     Support Installable ISAMS (MS Access, dBASE, FoxPro,

Paradox, and Btrieve)

     Supports ODBC

     Supports Transactions

     Supports OLE 2.0 objects stored in DBs

     Supports Pictures stored in DBs (BMP, ICO, WMF, DIB, RLE)

     Interactive data and structure manipulation

     Powerful SQL generation tool (Select, Crosstab, and Action

      queries) - without errors, unlike VISDATA

     Supports ODBC SQL as well as Access SQL (translation)

     Transferring data between databases (also of different types)

     Multiple Databases open

     Parameter SQL queries

     Many other features (ODBC and ISAMs configuration, SQL query

      files, using different verions of MSAJT___.DLL, ...)

     Printing Data

     Professional Standard Interface etc.

You can use OsloData instead of MS Query or as any other DB

browsing/admininstration tool.

  SQL generated by OsloData is fully compatible with all standard ODBC

databases. It can use correlation names, create inner and outer joins, etc,

etc.

  It has very good compatibility with various ODBC drivers. It can connect to

some data sources to which other apps (MS Access, PowerBuilder, MS

Query) cannot.

  The performance is often very good compared to many other programs.

When testing my app with an ODBC DB on a computer with 8M RAM, it took

about 40 sec for PowerBuilder to retrieve all the records from a table, but

OsloData did it in 13 sec.

It's only a beta now. So it would be free if you are interested.

Please e-mail:

moslon@interlog.com


Acc: borrow struct.

LUOKKA: Access

1622 (28+)  rdandrea@csn.org  20.01.95  16:37

Ralph D'Andrea: "Re: Borrow table structure?"

>What's the easiest way to create a new (external) table that borrows the

>structure of an existing table?  I would like to do this in as general a way

>as possible so I can re-use the code, so I'm looking for a method that

>doesn't require that I know the structure of the first table.  The equivalent

>to what I want to do in ObjectPal, for example, is:

>CREATE "Newtable"

>  LIKE "Existingtable"

>ENDCREATE

Well, I hate to answer my own post, but here goes.  I couldn't find a 1-line

way to do it, but I had to move on so I decided to use "brute force and

ignorance."  Which I guess is one of the redeeming qualities of VB.  There's

always SOME way to do it:

Sub clonetable (dbname$, dbtype$, oldtable$, newtable$)

Dim db As database

Dim tb As tabledef

Dim t As New tabledef

Dim nf%

Dim ni%

Dim i%

newtable$ = UCase$(newtable$)

oldtable$ = UCase$(oldtable$)

Set db = OpenDatabase(dbname$, True, False, dbtype$)

Set tb = db.TableDefs(oldtable$)

'see if table exists

ok% = 1

For i% = 0 To db.TableDefs.Count - 1

 If db.TableDefs(i%).Name = newtable$ Then

    ok% = MsgBox("Table " + newtable$ + " Will Be Replaced", 16 + 1, "")

   If ok% = 1 Then     db.TableDefs.Delete newtable$

    Else

     Stop

    End If

    Exit For

 End If

Next

t.Name = newtable$

'Set up the fields

nf% = tb.Fields.Count

ReDim tf(nf%) As New field

For i% = 0 To nf% - 1

    tf(i%).Name = tb.Fields(i%).Name

    tf(i%).Type = tb.Fields(i%).Type

    tf(i%).Size = tb.Fields(i%).Size

    t.Fields.Append tf(i%)

Next

'Set up the indices

ni% = tb.Indexes.Count

ReDim ti(ni%) As New index

For i% = 0 To ni% - 1

    ti(i%).Unique = tb.Indexes(i%).Unique

    ti(i%).Primary = tb.Indexes(i%).Primary

    ti(i%).Fields = tb.Indexes(i%).Fields

    t.Indexes.Append ti(i%)

Next

db.TableDefs.Append t

db.Close

End Sub


Acc: close DB/Dynasets

LUOKKA: Access

Date: 10/24/94 (10:32)              Number: 24280 of 24335 (Refer# NONE)

From: S914401@MINYOS.XX.RMIT.EDU.AU, S.i.C

Subj: Re: Closing DB before Dynasets

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>>My program closes the db in the final unload event. Sometimes this

>>generates an error because some dynaset has not been closed yet. Is

>>there a way identify that dynaset? Is there a way to generate a list of all

>>open dynasets?

>I have some more info about the above problem:

>err= 3219

>error(err)=Can't perform operation; it is illegal.

>The above error is what I get when I try to db.Close. I've seen this before

>when I forgot to close a global dynaset. I still get it intermitantly but I've

>accounted for all my global dynasets. What else can cause it??

Yeah, I,ve come accross this problem too. I found a fix by setting all

dynasets to nothing eg:

set FDS = ProductionDB.CreateDynaset(SQlstmt)

'then do something with dynaset then

'when finished

set FDS = Nothing

I also read somewhere that VB dosen't deallocate memory uses for module

level variables ie if you close a form that has module level variables and

then reopen that form all your variables are still there and have the same

values as when you last closed the form. Of course this dosen't matter to

much with simple variables like integers etc when we are talking about

dynasets which in reality are a set of pointers It may also pay to set the

form to nothing when closing it as well.

eg

Sub Form_Unload()

 Set FormName = Nothing

End Sub

Patrick


Acc: closing db

LUOKKA: Access

Date: 09/12/94 (12:30)              Number: 19107 of 19125 (Refer# NONE)

From: SCHOMMLER@RZI.NGATE.UNI-REGENSBURG.DE, Marcus

Schommler

Subj: Re: close database within the application???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Before you can close a database all tables must be closed. I use a global

array for all tables I use in my app. Closing the tables is then:

    For i = 1 To UBound(tblArr)

        If Not (tblArr(i) Is Nothing) Then tblArr(i).Close

    Next

After that I close the database itself.

Marcus


Acc: corrupted db

LUOKKA: Access

Date: 08/25/94 (08:00)              Number: 16939 of 17020 (Refer# NONE)

From: DEANH36899@AOL.COM

Subj: Re: HELP: '' is corrupted or isn't a MS Access database

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Paul (e01jjymo@tuzo.erin) asked about corrupt Access database error.

We have run accross that same message.  When VB is running a query and

the PC is shutdown the Access database seems to currupt itself.  The way

we go around this problem is to place an ON ERROR statement before we

open the database.  If there is an error then we execute a statement like ...

Repair "C: TEST.MDB" .. and then try to open it a second time.  I'm not

sure if that's the exact syntax or not but I think it's close.  I'm not

sure why VB/Access doesn't try and automatically do this but at least the

"fix" has worked for us so far.

Here is the subroutine that we use to "fix" the problem we've run into:

Sub OpenMapDB ()

   Dim FirstTry As Integer

   FirstTry = True

   On Error GoTo MapDBerror

   Set MapDB = OpenDatabase("SAMPLE.MDB", True, False)

   Exit Sub

MapDBerror:

   If FirstTry Then

      FirstTry = False

      RepairDatabase "SAMPLE.MDB"

      Resume

   Else

      MsgBox "Unrecoverable error opening : SAMPLE.MDB", 16, "Database

          Error"

   End If

End Sub

We are using VB 3.0 Pro.  I'm not sure if the standard version has the

RepairDatabase subroutine or not.  It's quite possible that the problems

in this disscussion are not caused (or fixed) by the same thing.  I hope

this helps to clarify my previous message.

Dean


Acc: corrupted db

LUOKKA: Access

Date: 08/27/94 (09:25)              Number: 17248 of 17271 (Refer# NONE)

From: LARRY.CLARK@SPCUG.SACBBX.COM, Larry Clark

Subj: Re: HELP: '' is corrupted

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

PA>I did try to repair the database using data manager but it still gives me

PA>the warning message.

   I have discovered cases where the Access message says "you need to

   repair and compact your database." If I simply repair it, Access says

   it's fine, but it corrupts immediately thereafter. If I do (as the

   message says) both the repair and the compact, all becomes well. Even

   if the message isn't explicit, try following the repair with a

   compact.


Acc: count records

LUOKKA: Access

Date: 09/20/94 (19:53)              Number: 20142 of 20148 (Refer# NONE)

From: WOLFS@TIGER.DIALIX.OZ.AU

Subj: Re: Counting database records

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>: suggests you should use MoveLast and Recordcount but they are very

>:slow in larger dynasets.

Although you can get the precise number of records with

this - just think how long you need to wait for the result

if your table contains 50.000+ rows.

Try this one:

   Const DB_TABLE = 1  ' Constant taken from DATACONS.TXT file.

   Dim db As Database

   Dim snap As Snapshot

   Set db = OpenDatabase("C: MYDB.MDB")

   Set snap = db.ListTables()  ' Copy Table information to Snapshot.

   Do While Not snap.EOF

      If snap("TableType") = DB_TABLE Then

      'Enter the Table name for which you want a record count:

         If snap("Name") = "Mytable" Then

            MyRecordCount = snap("RecordCount")

         End If

      End If

      snap.MoveNext  ' Move to next record.

   Loop

   snap.Close

Courtesey VB_KB Article ID: Q109053

--

 Regards ... Wolf


Acc: CreateSnapShot

LUOKKA: Access

Date: 05/02/94 (15:26)              Number: 4982 of 4992 (Refer# NONE)

From: EDSTAFF@MCS.COM

Subj: Re:  VB WIN  Help with CreateSnapShot

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Creating a Snapshot is a snap (sorry, couldn't resist).

Let say you opened a database:

' in a module someplace

Global gdbYourDB as DATABASE

'presumably in some startup code someplace

 Set gdbYourDB = OpenDatabase("yourdb.mdb")

'  Now you want to create a snapshot based on a query you created in the

'  database. Let's say you have a query defined in the database called

'  qryMyQuery.

Dim qdYourQuery as QueryDef

Dim ssYourSnapShot as SnapShot

Set qdYourQuery = gdbYourDB.OpenQueryDef("qryMyQuery")

'   If the query had parameters you would set them thusly:

qdYourQuery!Parm1

qdYourQuery!Parm2

' etc...

' Now you can create your snapshot

  Set ssYourSnapShot = qdYourQuery.CreateSnapShot()

   qdYourQuery.Close  ' Don't need this anymore

' Then you would probably say something like

If ssYourSnapShot.RecordCount > 0 then

     ssYourSnapShot.MoveLast

     ssYourSnapShot.MoveFirst

     Do While ssYourSnapShot.EOF = FALSE

             '  Do whatever you want with the data

             ssYourSnapShot.MoveNext    '  Don't forget this

     Loop

Endif

ssYourSnapShot.Close


Acc: db-sql tip

LUOKKA: Access

Date: 07-12-95 (21:42)              Number: 385888 of 386776 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Tip on database performance trick

From: Kenneth Lassesen <kenl@MICROSOFT.COM>

If you set TraceSQLMode=1 to the ÄODBCÅ section of the MSACC20.INI

file/or your app's INI file , you will get a trace of the SQL statement

which is sent to the driver.  This will tell you whether it is Jet or

the driver which is causing the problem.

        Ken


Acc: Dev.Toolkit

LUOKKA: Access

==============================================================

Date:         Tue, 11 Oct 1994 15:20:00 CDT

From:         TOUGH Brad <btough@SHL.COM>

Subject:      Access and VB 3.0 ?'s (part 2 of 4) part III

>> >Where would one get such a beast?  and how much $$$ are we talking?

>> Let's see... the box says 100 bucks US or 135 CDN. It's shrinkwrap stuff

>> so any dealer should have it. I got mine "free" for attending a $400

>> seminar. Haven't looked at it to much yet. It includes:

>Whew....from what others were saying, it was gonna cost me big $$$.

Sorry Mike, I didn't read the fine print, 100 bucks is the upgrade price

from VB 3.0.

Brad

==============================================================

Date:         Fri, 7 Oct 1994 08:37:00 CDT

From:         TOUGH Brad <btough@SHL.COM>

Subject:      Access and VB 3.0 ?'s (part 2 of 4) part II

>> >Second -- There is no way to distribute an app created with Access 2.0

>> >unless the receiving end also has Access 2.0?  I would have to create a

>> >front end using VB 3....

>> You need the Access Developer's Toolkit, it comes with a run-time version

>>of Access that you can distribute with your apps. (sortof access-lite).

>Where would one get such a beast?  and how much $$$ are we talking?

Let's see... the box says 100 bucks US or 135 CDN. It's shrinkwrap stuff so

any dealer should have it. I got mine "free" for attending a $400 seminar.

Haven't looked at it to much yet. It includes:

     Data Access Objects, sample code and sample apps.

     OLE Custom Controls (2.0 I assume)

     Help Compiler

     A run-time version of MS Access

     Microsoft Graph, add graphing power to your apps.

     Setup Wizard, hope it's better than the VB one.

     Access 2.0 Compatibility Layer.

     A bunch of API declarations and constants

     two new books for your bookshelf,

     Microsoft Access Language ref.

     Advanced Topics in Access.

Brad Tough - Senior Programmer/Analyst

SHL Systemhouse - Vancouver, BC   tel: (604) 681-9441

btough@shl.com".eh"


Acc: diff. versions

LUOKKA: Access

Date: 12/10/94 (17:56)              Number: 149836 of 149927 (Refer# NONE)

Subj: Re: VB Apps with different versins of Access d/BASE (1.1 / 2

From: "G. Wallace" <gwallace@INFINET.COM>

I would check out the possibility of using an INI file for your program.

As I understand it you would have to specify that your program uses a

particular ini file and in the ini file you have to specify the

MSAJT200.dll engine would be used in your application.  Also you would

have to install the compatibility layer msajt112.dll on the system.  You

ahould check with Microsoft to find out how it impliment this, but I

think it will do the job for you.

Gary.>>>>>


Acc: diff. versions

LUOKKA: Access

Date: 12/13/94 (01:29)              Number: 151697 of 152407 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: VB Apps with different versins of Access d/BASE (1.1 / 2

> I've got a user using my application (written in VB3.0 Prof and Ms Access

> 2.0) on her machine.  She is also running another VB application written

> in VB 3.0 Prof (I think) and using Ms Access 1.1.

> Are there any known tricks of the trade for making two diff VB applications

> co-exist on a machine, but each using a different version of the Access

> database?

The problem lies in the fact that the two different versions both use a

file called VBDB300.DLL, but they are different and incompatible between

the two versions.

My suggestion is to find the Ver 1.1 VBDB300.DLL dated 4/28/93 and move

it to the directory of the application that uses the 1.1 JET engine.  Then,

make sure the Ver 2.0 VBDB300.DLL dated 3/24/94 is in your system

directory.

This will allow you to run the two applications on the same machine, but

not at the SAME time.  That seems to be impossible.

______________________________________________

Mark D. Richards

Windows Software Engineer

Hydrosphere Resource Consultants, Inc.

Hydrosphere Data Products, Inc.

1002 Walnut Suite 200, Boulder, CO 80302


Acc: equati from TextB

LUOKKA: Access

Date: 10/22/94 (03:10)              Number: 23957 of 24188 (Refer# NONE)

From: FERNANDO.MONTEIRO%MANDIC@IBASE.ORG.BR, Fernando

Monteiro

Subj: Re: Equations from Textbo

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I am writing a mathematical program.  I would like to be able to type in an

>equation into a textbox while the program is running and have Visual Basic

>understand it. I'll show you what my problem is with an example.

>I put 'dim x%', 'dim y%', and 'x=5' into Form_Load. If while the program is

>running, I type 'x+5' into a textbox, and later on in the program I say

>'y=val(text1.text)', why doesn't y equal 10?

>Any help in solving this problem would be appreciated.  Thanks.

 Rl> I'm not sure you can do that in plain VB. You might be interested in a

 Rl> small dll we publish called Parser/TP that can be connceted to a VB

 Rl> program.

 Rl> Take a look at SimTel's turbopas directory, for parstp30.zip .

 Rl> The package includes sample VB code.

   You don't need to use a dll to solve your problem. Try the following

 lines and you'll get the result you want.

     dim MY_DB as database

     dim MY_SN as snapshot

     Text1.text = "X+5" 'User entry

     set MY_DB = opendatabase("dummy.mdb",false,false)

     set MY_SN = MY_DB.createsnapshot("Select " & str$(X%) &

                                       rigth$(Text1.text,2) &

                                       " as Expr1 From Dummy_Table")

     Text2.text = MY_SN("Expr1") 'User result

  Please, mind that the Dummy_Table must have just one row and at least

  one column.

  That's works and you can use any SQL supported expressions as:

    (3+7)^6

    (5*9)+(6/2)^4

    INT(7/2)*9

    etc.

  Fernando Monteiro


Acc: install. ISAM?

LUOKKA: Access

Date: 10/15/94 (15:26)              Number: 23113 of 23204 (Refer# NONE)

From: ROBERTW@NETCOM.COM

Subj: Re: Couldn't find installable ISAM?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Possible Reasons for Couldn't Find Installable ISAM Error

Article ID: Q107672

--------------------------------------------------------------------

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 3.0

--------------------------------------------------------------------

SUMMARY

=======

There are a number of reasons that can cause the 'Couldn't Find

Installable ISAM' error message. Below is a list of the possible

reasons for the error.

MORE INFORMATION

================

The Data Access Guide in "Professional Features Book 2" has information

in the sections: 'General Tips for Using External Tables' and

'Initialization File Details' that can be used as an additional reference.

These sections begin on pages 134 and 148.

The path for the installable ISAM driver should be listed in the

file VB.INI in the ÖWINDOWS directory. Here is an example showing

what the Installable ISAM section in VB.INI should look like:

ÄInstallable ISAMsÅ

Btrieve=C:ÖWINDOWSÖSYSTEMÖbtrv110.dll

FoxPro 2.0=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

FoxPro 2.5=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

dBASE III=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

dBASE IV=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

Paradox 3.X=C:ÖWINDOWSÖSYSTEMÖpdx110.dll

List of Possible Reasons for Error (Couldn't find Installable ISAM)

-------------------------------------------------------------------

1. An entry in the ÄInstallable ISAMÅ section in VB.INI or

   <APPNAME>.INI is incorrect. For example, this error occurs if

   you're accessing a Paradox external table, and the Paradox entry

   of the APP.INI file points to a nonexistent directory.

   To correct this problem, exit Visual Basic. Then make necessary

   corrections in VB.INI or <APPNAME>.INI by using Microsoft Windows

   Notepad or another text editor. Then restart Visual Basic, and

   try the operation again.

2. One of the entries in the ÄInstallable ISAMÅ section in VB.INI

   points to a network drive, and that drive isn't connected.  Check

   to make sure the network is available and the correct drive letter

   is established. Then try the operation again.

3. The APP.INI file isn't in the Windows directory.

4. The APP.INI file doesn't have the same name as the .EXE file.

5. The path to the IISAM specified in the .INI file is incorrect.

6. There are extraneous spaces in the APP.INI file.

7. The APP.INI file doesn't contain the same IISAM syntax as in the

   VB.INI for each database that uses the drivers.

8. The connect string should be 'Paradox 3.X;' NOT 'Paradox;' this is

   a documentation error in the manual.

9. Another possibility is that if you installed Microsoft Access after

   installing Visual Basic, an older driver may have replaced a newer

   Visual Basic driver. Check to ensure that the following files are

   all dated 4-28-93 (the Visual Basic version 3.0 file date stamp):

      MSAES110.DLL

      MSAJT110.DLL

      VBDB300.DLL

10. The error can also occur when the Connect property of Tabledef

    is not filled with the exact characters needed.

    The Connect property is analogous to the connect portion of

    the OpenDatabase method, so the parser looks for semicolons after

    every entry -- other than the null entry in the case of a native

    Microsoft Access database. In the case of an attached table,

    Visual Basic syntax requires an entry in the Connect property.

    There needs to be a leading semicolon before any optional

    parameters in the Connect property, if the source database of the

    attached table is Microsoft Access. If it is omitted, the error

    occurs.

    In other words, the leading semicolon is needed when attaching

    a native Microsoft Access table. If it is omitted, the first

    parameter placed in the Connect property is seen as the database

    type. The error occurs because the parser tries to find an entry

    in the .INI file that corresponds to the first entry in the

    Connect property, but it doesn't exist. In the first example,

    the parser looks for a match for "database=" and fails to find it.

11. Providing an extra space between dBASE and IV, as in dBASE  IV,

    prevents the Microsoft Access engine from finding the entry

    in the .INI file, so the error occurs.

12. Another possible reason for this error message is that the ISAM driver

    can't be loaded because the file is corrupt or not decompressed. You

    can verify this by attempting to force the DLL to load using the

    WPS.EXE program (available in the Professional Edition only), which you

    will find in the CDK subdirectory. If WPS can't load the DLL, you

    should reinstall and expand the DLL by using Setup /Z.

13. If you create a program that uses the ISAM drivers, your APPNAME.INI

    file should contain the entire ÄInstallable ISAMsÅ section. If you

    don't do this the follow scenario could occur: A customer may have a

    program that uses the paradox driver and it works fine with the

    following APPNAME.INI:

    ÄInstallable ISAMsÅ

    Paradox 3.X=C:ÖWINDOWSÖSYSTEMÖpdx110.dll

    Then a second program that uses a Btrieve driver works fine with the

    following APPNAME.INI:

    ÄInstallable ISAMsÅ

    Btrieve=C:ÖWINDOWSÖSYSTEMÖbtrv110.dll

    But if you run the two programs together, the second will have the

    error "Can't Find Installable ISAM."

    NOTE: the order of execution doesn't play a factor.

    To prevent this problem, include the entire ÄInstallable ISAMsÅ section

    in your APPNAME.INI files. For example, it might be similar to this:

    ÄInstallable ISAMsÅ

    Btrieve=C:ÖWINDOWSÖSYSTEMÖbtrv110.dll

    FoxPro 2.0=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

    FoxPro 2.5=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

    dBASE III=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

    dBASE IV=C:ÖWINDOWSÖSYSTEMÖxbs110.dll

    Paradox 3.X=C:ÖWINDOWSÖSYSTEMÖpdx110.dll


Acc: modifying db

LUOKKA: Access

Date: 08/29/94 (13:17)              Number: 17702 of 17760 (Refer# NONE)

From: SBRENNER@EFN.ORG

Subj: Data manager won`t allow

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 8/27/94, andrew.gross@moondog.com wrote to ALL: *****>>

aa>  will *not* allow the modification of a table.  The table (but not the

aa>  db) has to be deleted instead of modifying a field.  I could always

aa>  purchase Access, but that feels like a rip-off.  Is there a shareware

aa>  alternative to Acess for just simple modifications of Access MDBS?

I had the same need. The Data Manager that comes with VB is a bit pathetic.

Several days into writing one for myself, I realized that I already had two

shareware applications.

DDL Manager, MM Technology, 136 Pershing Ave., Ridgewood NJ 07450

   This is a fairly simple application. You can add and delete fields, but

 the only field change you can make is to change the field name.

Charlie Database Design Aid, Monte Carlo Software, Domaine de Boistell,

   83560 Rians - France tel +33 9480 3940 fax 9480 3993

   This is a little more advanced, allowing one to change the field type.

I found these both on one of the EMS cdroms for Visual Basic.

--------------------

Stephen A. Brenner - Visions in America - Internet: Sbrenner@efn.org


Acc: multiusers?

LUOKKA: Access

1321 (2+)  ebbe@dbm.fi  10.01.95  11:05

Ebbe Jonsson: "Re: VB 3.0 Pro/Jet 2.0 and heavy multiuser environment"

Tom Niemi (niemi@innopoli.fi) wrote:

> Does somebody have experience about using application made in VB 3.0

>Pro that uses Jet Engine 2.0 (or perhaps 2.5) in multiuser environment

>where is large amount of users and 'quite' a lot of data? Tell us something

> about the mess!

Avoid this. Jet is not a client/server engine, and you'll quite likely

run into a lot of network traffic and possible locking problems if

your concurrent user count exceeds, say, 10.

--

Ebbe Jonsson, Systems Mangler                            ebbe@dbm.fi

DBM Database Marketing Oy, Helsinki, FINLAND    " Q: What is the opposite

Tel: +358 0 605 900, Fax: +358 0 605 991         of information? "


Acc: no DataControl

LUOKKA: Access

1286 (34+)  graham.irons@eagle.asstdc.com.au  09.01.95  20:49

Graham Irons: "Data Control does not appear in Toolbox - revisited"

LK>I posted an article a few weeks back about the data control

LK>no longer appearing in my toolbox.

LK>Well, I've gotten several responses, but no definitive answers.

LK>All I can say is that I'm not the only one with this problem.

LK>It looks like the most likely culprit is the compatibility layer.

LK>The only solution that seems to work is reinstalling VB.  I'm

LK>going to hold off on that for now.

Make sure the following 2 lines appear in your VB.INI in the ŽVisual Basic�

section.

ReportDesign=1

DataAccess=1

Regards, Graham.

CIS# 100033,3647

FidoNet @3:712/704

INTERNET:girons@ozemail.com.au

INTERNET:graham.irons@eagle.asstdc.com.au


Acc: opening db

LUOKKA: Access

Date: 04/12/94 (10:05)              Number: 3224 of 3272 (Refer# NONE)

 From: MTHOMPSO@FOX.NSTN.NS.CA

Subj: Some sample code for opening data files

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On Thu,  7 Apr 1994 23:02:03 -0400 (EDT),

Trevor Tompkins  <tt17+@andrew.cmu.edu> wrote:

>I would love to get some code samples!!  I don't have access to

>compuserve, nor do I have the MSJ issues.  I should be getting the

>Visual Basic periodical soon though.  Thanks so much for your help.

Trevor-They're attached in the file VBSRC.TXT-about 188 lines.

Comments/critique will be welcome.

These are code fragments from a very simple inventory tracking

system--data controls were not used.

Queries were stored in the parts database.

I've probably gone overboard in the length and descriptiveness

of variable names.

If this was being distributed, I'd also need another method of

determining where the data  files are, rather than hard coding them.

The program asa whole needs a really good initialization routine, one that

looks for the datafile, using cmdlg, then, once found, stores it to the

program.ini file. But there wasn't the budget.

'Global variable declarations

Global CompanyName$

Global DataPathAndName

Global CurrDynaSet As String

'Database tables

Global dbBusiness As Database

'Dynasets

Global dsInventory As Dynaset, dsSales As Dynaset

Global dsBuyParts As Dynaset, dsPartsSold As Dynaset

Global dsCustomers As Dynaset, dsSuppliers As Dynaset

Global dsBusinessData As Dynaset

'Queries

Global qdInventory As Querydef, qdWhichParts As Querydef

Global qdPartsSold As Querydef, qdFindSale As Querydef

Global qdCustomerName As Querydef, qdSupplierName As Querydef

Global qdWhichCustomer As Querydef

Global qdBusinessData As Querydef

'Tables

Global dtsource As Table

'============ END DECLARATIONS =============

Sub Main ()

  EMPTY_SET_MSG = "Data file is empty. You must add a record."

  CompanyName$ = "P. A. Yeoman Marine"

  Initialize_Databases

  MasterInvForm.Show

End Sub

Sub Initialize_Databases ()

  'Opens required database and datatables

  'DataPathandName will be retrieved from a previously stored file

  On Error GoTo InitializeError

  DataPathAndName = "C:ÖPAYEOMARÖDATAÖBUSINESS.MDB"

  Set dbBusiness = OpenDatabase(DataPathAndName)

  'Establish the Inventory dynaset

  Set qdInventory = dbBusiness.OpenQueryDef("AllPartNumbersQry")

  Set dsInventory = qdInventory.CreateDynaset()

  'Establish the Customers dynaset

  Set qdCustomerName = dbBusiness.OpenQueryDef("AllCustomerQry")

  Set dsCustomers = qdCustomerName.CreateDynaset()

  'Establish the Suppliers dynaset

  Set qdSupplierName = dbBusiness.OpenQueryDef("SupplierNameQry")

  Set dsSuppliers = qdSupplierName.CreateDynaset()

  'Establish the PartsSold dynaset

  Set qdPartsSold = dbBusiness.OpenQueryDef("LastPartSoldQry")

  Set dsPartsSold = qdPartsSold.CreateDynaset()

'Establish theBusinessData dynaset

  Set qdBusinessData = dbBusiness.OpenQueryDef("BusinessData")

  Set dsBusinessData = qdBusinessData.CreateDynaset()

  GoTo InitializeEnd

InitializeError:

  ShowError

  Resume InitializeEnd

InitializeEnd:

End Sub

Form_load is from the purchase.frm--there is probably a

redundant declaration in it where I clone the inventory

Sub Form_Load ()

  PurchaseForm.Caption = CompanyName$ & " Inventory Purchases"

  'Clone the Inventory

  Set dsBuyParts = dsInventory.Clone()

  'Make ready for for display - whether empty ds or not

  '****TREVOR this is the tst for an EMPTY dynaset--DON't TRY To MOVE.

  If dsBuyParts.BOF And dsBuyParts.EOF Then  'Empty Dataset

    'Show the form

    PurchaseForm.Show

    MsgBox "Data File is Empty. You must add a Record", 64, "Purchase Form

Load"        'Tell user no records

    StopMoves                   'Disable movement controls

    cmdTxCtrl_Click 1           'For a new form ***TREVOR-Code is below)

  Else

    FileToForm

    CheckMoveTo dsBuyParts

  End If    'Empty dataset

  'Load the combo box with suppliers

  dsSuppliers.MoveFirst

  Do Until dsSuppliers.EOF  'if empty, this avoids error

    cboSupplier.AddItem dsSuppliers!Supplier

    dsSuppliers.MoveNext

  Loop

  'Show the form

  PurchaseForm.Show

End Sub

Sub cmdTxCtrl_Click (Index As Integer)

  '

  Select Case Index

    Case 0    'Delete button

      'Yes/No box with No as default(256); test for Yes (6)

      If MsgBox("Are you sure?", 4 + 256, "Delete this Record") = 6 Then

        dsBuyParts.Delete

        dsBuyParts.MoveNext

          If dsBuyParts.EOF Then

            'refresh the data set

            Set dsBuyParts = qdInventory.CreateDynaset()

            If dsBuyParts.BOF And dsBuyParts.EOF Then  'Empty Dataset

              'Show the form

              MsgBox "Data File is Empty. You must add a Record", 64,

purchase

Form Load"        'Tell user no records

              StopMoves                   'Disable movement controls

              cmdTxCtrl_Click 1           'For a new form

            End If 'Empty file after delete

          Else

            FileToForm    'load form

          End If  'End of File

      End If    'User is certain deletion is wanted

      CheckMoveTo dsBuyParts

    Case 1      'New Button

      StopMoves            'Disable movement buttons

      BlankForm            'Load form with blanks

      NewRecord = True     'Set new record flag

      'Deactivate all transaction control buttons

      'except Save and Cancel

      cmdtxCtrl(0).Enabled = False   'Buy More

      cmdtxCtrl(1).Enabled = False   'New Card

      cmdtxCtrl(2).Enabled = False   'Finished

      cmdtxCtrl(5).Enabled = False   'Lookup

      'Enable the Save andCancel buttons

      cmdtxCtrl(3).Enabled = True    'Save

      cmdtxCtrl(4).Enabled = True    'Cancel

    Case 2

      Form_Unload True

    Case 3      'Save Button

      FormToFile                'save data to file

      CheckMoveTo dsBuyParts    'enable movement

      'Make all transaction controls active

      'Except Save and Cancel

      cmdtxCtrl(0).Enabled = True   'Buy More

      cmdtxCtrl(1).Enabled = True   'New Card

      cmdtxCtrl(2).Enabled = True   'Finished

      cmdtxCtrl(5).Enabled = True   'Lookup

      'Disable Save and Cancel buttons

      cmdtxCtrl(3).Enabled = True  'Save

      cmdtxCtrl(4).Enabled = True  'Cancel

    Case 4    'Cancel Button

      'Make certain there is a valid record

      'Finish up if not, otherwise rewrite form from file

      If dsBuyParts.BOF And dsBuyParts.EOF Then   'empty dataset

        cmdtxCtrl(2).Value = True   'Click Finished

      Else

        NewRecord = False

        FileToForm

        CheckMoveTo dsBuyParts

        For i% = 0 To 4

            cmdtxCtrl(i%).Enabled = True

        Next

      End If

    Case 5    'Lookup Button

      'Ask fora Part Number

      strPartToFind = InputBox$("Please enter a Part Number:", "Lookup

Parts")

      If Len(strPartToFind) > 0 Then

        CurrRec = dsBuyParts.Bookmark

        dsBuyParts.FindFirst "PartNumber = '" & strPartToFind & "'"

        If dsBuyParts.NoMatch Then

          dsBuyParts.Bookmark = CurrRec

          MsgBox "That Part was Not Found", 48, "Lookup Parts"

        End If      'NoMatch

        FileToForm    'Search successful

        CheckMoveTo dsBuyParts  'Reset movement controls

      End If

    Case Else

      MsgBox "Not Yet Implemented", 64, "Purchase Form"

  End Select

End Sub

Sub StopMoves ()

  For i% = 0 To 3

    cmdMoveTo(i%).Enabled = False

  Next

End Sub

Sub CheckMoveTo (dataset As Dynaset)

  'Checks location in dataset and sets movement controls accordingly

  'Note that CheckMoveTo will reposition if BOf or EOF

  '****TREVOR-This could have been done with CASE statement.

  'I generally prefer them, especially here as I have lots of

  '"Exit Sub" statements.

  If dataset.BOF = True And dataset.EOF = True Then   'empty dataset

    StopMoves

    Exit Sub

  End If

  If dataset.BOF = True Then               'beginning of file

    dataset.MoveNext                'need a currentrecord, so go back one

    cmdMoveTo(0).Enabled = False    'cannot move up

    cmdMoveTo(1).Enabled = False

    cmdMoveTo(2).Enabled = True     'can move down

    cmdMoveTo(3).Enabled = True

    Exit Sub

  End If

  If dataset.EOF = True Then

    dataset.MovePrevious  'no current record so go back one

    cmdMoveTo(0).Enabled = True      'end of file

    cmdMoveTo(1).Enabled = True      'can move up

    cmdMoveTo(2).Enabled = False     'but not down

    cmdMoveTo(3).Enabled = False

    Exit Sub

  End If

  If dataset.BOF = False And dataset.EOF = False Then  'somewhere in the

middle

    For i% = 0 To 3

      cmdMoveTo(i%).Enabled = True    'can move in any direction

    Next

    Exit Sub

  End If

End Sub

Coments on this code would be welcomed.

Would that Visual Basic had commands like "scatter memvar",

"scatter memvar blank", "gather";

and a feature like Clippers ragged array:to be able to put a

whole variety of controls in an array would be GRAND!!! Then I

wouldn't miss the scattter/gather so badly.

 mthompso@fox.nstn.ns.ca

 --

 Miles Thompson

 mthompso@fox.nstn.ns.ca


Acc: pass table vars

LUOKKA: Access

7631 (6+)  Christopher_Dodds@lehman.com  24.07.95  15:20

Christopher Dodds: "Re: VB: Pass a Table Object Variables out of a

function?"

P_B_E@Delphi.com (Chad Z. Hower) wrote:

>Subject: Re: VB: Pass a Table Object Variables out of a function?

>Function CreateTable (dbDatabase as Database, tblTable as Table)

>    Set tblTable = dbDatabase.OpenTable("Test")

>End Function

Try this and then sit back and enjoy the  ...

"Cannot set formal parameter " error message

You can get round this by declaring your table object as an array and

passing it as such to your routine ie

Function CreateTable (dbDatabase as Database, tblTable() as Table)

    Set tblTable(0) = dbDatabase.OpenTable("Test")

End Function

A bit kludgy  but it works.


Acc: rec.no aft.seek

LUOKKA: Access

Date: 10/19/94 (23:26)              Number: 23679 of 23771 (Refer# NONE)

From: 90621442S@SGCL1.UNISG.CH

Subj: Re: Record number after Access seek?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

To find out the relative Position in a Dynaset I wrote this piece of code.

It uses internals of the bookmark-property, so I don't know, if it works

in later versions of the access-engine.

On a fast 386, it takes about 1 ms for 100 records.

Ralf Sturzenegger

Function GetRelativeDSPosition (DS_Input As Dynaset) As Integer

Dim Counter As Integer

Dim Offset As String

Dim OldMark As String

'Store current

Counter = 0

Do While Not DS_Input.BOF

  Offset = CStr(DS_Input.Bookmark)

  'Offset

  Counter = Counter + Asc(Mid(Offset, 1, 1)) + 1

  'Go to start of current Page

  DS_Input.Bookmark = Chr$(0) + Mid(Offset, 2, 1) + Chr$(0) + Chr$(0)

  'Go to end of the previous Page

  DS_Input.MovePrevious

Loop

'Restore old Position

DS_Input.Bookmark = OldMark

GetRelativeDSPosition = Counter


Acc: res.errors

LUOKKA: Access

14.I'm getting error message "Reserved Error Ä-nnnnÅ ("There is no message

   for this error")" from Jet Engine 2.0. Huh?

   See the Knowledge Base article Q117900 "Reserved Error Numbers

Returned by the Jet 2.0 Engine" for a complete list of the new error

messages.

   Extract:

   "Jet_Error/Message_String

      -1010 Invalid database ID.

      -1016 Can't have more than 10 fields in an index.

      -1029 Database engine hasn't been initialized.

      -1030 Database engine has already been initialized.

      -1034 Query support unavailable."

    Ayn Shipley (ashipley@hookup.net)


Acc: sep.data/query

LUOKKA: Access

==============================================================

Date:         Thu, 20 Oct 1994 09:14:26 -0400

From:         Ian Ornstein <IORNSTEI@WPO.HCC.COM>

Subject:      VB and Access -Reply

>>>>>>>>>>>>>>>

Many moons ago I read some articles on VB and Access that said that when

creating a program that uses an Access database, that you should make one

file that holds the data and one that holds the queries and just link them.

Okay this makes a lot of sense. That way I can just modify the query

database and it does not mess, or I don't need to modify the original

database.

I did that. The problem is, that Access saves the path of the link. Which

means that if I develop the program on a network drive, S:, then when the

user  installs the program on their C: drive, the query database can't find the

data database.

How do I get around this major problem???

David McCarter

Cycledata david@eagle.psycho.com

<<<<<<<<<<<<<<<

The attachment path is in the MSysObjects table. You need to test the

attachement by attempting to open the table if it fails, bring up an open file

common dialog box so the user can give you the location of the file at run

time.

Take the location and update the row in MSysObjects. It is extra code... but

necessary.


Acc: sep.query/data

LUOKKA: Access

Date: 10/15/94 (10:57)              Number: 23079 of 23204 (Refer# NONE)

From: SCREAMIN@ERI.ERINET.COM

Subj: Re: separating queries from data

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: Here's the situation.  I am developing a VB database application.  At any

: one session the user will be accessing a set of data (stored in a .mdb

: file), although there may be many data sets with the same structure (each

: in separate .mdb files) - like one set of data for each year.  Since there

: are queries that go with that data, I'd like to put all those in one

: database file and allow the user to pick which set of data (i.e., which

: .mdb file) to apply the queries to.  Here are some of the approaches I

: considered:

: 1.  Put all queries in one database file, for instance query.mdb.  The

: queries would use the 'select * from <table> in <database>' syntax, but

: since I cannot change the <database> name from VB (or can I?), I'll have to

: copy the data set .mdb to a known, hard-coded location at the beginning of

: the user session.

: 2.  Put all queries in one database file, and from VB dynamically attach

: the data tables from the data .mdb file selected by the user.

: 3.  Store the queries with each data set.

: 4.  Use SQL statements from the VB source code.

: I'm leaning toward option 2 at this point.  Option 1 and 3 seem clumsy, and

: with option 3, if we update the app with modified queries, those will have

: to be copied into all the data sets.  Option 4 would probably solve my

: problems, but from what I've read that would eliminate any sort of query

: optimization from being performed.  One of the problems with option 2, is

: that the application might become MDI, so you might want two data sets :

open at one to copy from one to the other.  Attaching the tables would :

make this difficult to manage.

: Now I know I've read that its a rather common technique to separate the

: queries, reports, etc. from the data by making two databases, so I'm hoping

: someone out there has some insight to this problem.  Any suggestions are

: welcome.

: Jim O'Neil

It can be a good idea to keep your application (queries etc.) in a separate

mdb file and attach the data tables from a data mdb file.  This is mostly due

to the fact you can update the program objects without disturbing the data.

This is especially useful on networks with users accesiing a common dataset.

 My question to you is why are you creating a seperate mdb file for each

year?  Can't you create a duplicate table structure for each year inside a

single mdb?

<screamin@erinet.com>


Acc: set db to nothing

LUOKKA: Access

7196  P_B_E@Delphi.com  11.07.95  18:35

Chad Z. Hower: "Re: Set db = Nothing. Is it necessary?"

>I've heard a couple of times in this newsgroup about setting an object

>as database or dynaset to Nothing after closing.

>Is it really necessary? If yes why? The manuals suggest only

>closing so what will happen to applications that don't do that?

     Setting it to nothing frees the memory.  Close does not.


Acc: tips

LUOKKA: Access

8. Tips for VB database programming:

   a. Use Access and QBE. Once it's "working" (even if the parameters are

      hardcoded), then open up View.SQL and copy the stuff from the SQL

      window into your VB code. If you need to insert VB variables, try

      testing this under Access by using parameters instead. They're then

      nice & easy to spot when it comes to converting into VB - I always

      call my parameters "PR_xxxx", so I can just search my VB code for

      this to find any instances that I've missed.

   b. It never works first time. So put an error handler into your VB code

      that copies the contents of SQLStr onto the clipboard, should the

      query fail. Now it's quick & easy to switch back to Access, find a

      scratch query and paste the erroneous SQL into that. It's *much*

      easier to debug a SQL query in Access, after the variables have been

      merged in, than it is to do it blind from VB.

   c. Use carriage returns to break up your SQL. One before each reserved

      word is sensible. They're not significant in SQL. I assume you're not

      stupid enough to put them in the middle of field names -

      unfortunately Debug.Print is!

   d. When merging in the contents of a variable (building a SQL query in a

      VB string), it should *always* be surrounded by an ampersand and 3

      double quotes, or an ampersand and 2 mixed quotes, depending on your

      local conventions:

        SQLStr = SQLStr & "WHERE Username <= """ & Username$ """ "

        or

        SQLStr = SQLStr & "WHERE Username <= '" & Username$ "' "

   e. If you're using dates, then it will *always* be one quote, a hash and

      an ampersand:

        SQLStr = SQLStr & "WHERE Start_Date <= #" &

        öFormat$(CutOffDate,"Long Date") & "# "

   f. Another tip with dates is to format them with the long date format,

      not the short date. This is then safe against the transatlantic

      reversal of month & day position.

   g. If you're merging in a field/table name, enclose it in square

      brackets. That way the SQL will still be valid if the variable

      contains spaces:

        SQLStr = "SELECT * FROM Ä" & TableName$ "Å ;"

      When building SQL strings in VB, then you'll often do this on several

      lines, concatenating SQLStr with the new string. If you leave a space

      at the end of every string, then you can guarantee you won't have

      problems with the text from successive lines running into each other.

   h. If you're using Access 1, you'll keep running into the 1024 character

      limit on the length of a SQL string. Keep the table & field names

      short, especially if many JOINs are concerned. Using underscores in

      names is shorter than spaces, as you don't need the extra 2

      characters for the square brackets around them. If your SQL is

      slightly too long, then you'll probably see a "Missing semicolon"

      error, even though the semicolon is obviously there (To you,

      anyway!).

   i. Making a QueryDef is a complicated process that is often slower than

      executing the query ! Don't mess with the .SQL property, as that is

      equally slow (Access needs to do a lot of work to turn SQL into its

      internal query format). Two ways around this: Use ready-built

      queries, written with Access. If you need to merge in values from

      variables, then use a query with parameters. Setting parameter values

      is quick to execute.

   j. If you really need to build SQL on the fly -- you need to build an ad

      hoc query, or to supply table or field names (which can't be done

      with query parameters), then try using:

        database.Execute SQLStr

      As this doesn't build a QueryDef, then it's quick.

      ÄTips a to j by Andy Dingley(dingbat@codesmth.demon.co.uk)Å

   k. Make sure all Tables, Dynasets, Snapshots, Databases, and other data

      access objects are properly closed before ending the program. As near

      as I can tell, the pointers to these objects are not destroyed if

      your VB program doesn't Close them (including when a program

      crashes). A Microsoft guy did say he can't find anything that

      confirms that they close, but (of course) he wouldn't say for certain

      that they aren't closed. Based on resources after serious crashes

      (that I couldn't walk the program out of by hand), I don't think

      they're automatically closed.

      John McGuire (jmcguire@jax.jaxnet.com)


Accelerator key

LUOKKA: ComboBox

============================================================

Date:         Thu, 22 Sep 1994 09:51:19 EST

From:         michael mccarthy <michael_mccarthy@SMTP.CSOF.COM>

Subject:      Accelerator Trapping

--quote--

     I have a drop-down combo that I want to be able to access from the

     keyboard with an accelerator (in this case ALT-C). The user has to

     know about this, so I put a label above it with the text set to "&C.....".

     Then, in the Click event for the label, I call SetFocus for the drop-

     down. It doesn't work when I press ALT-C, but it does when I click on

     the label with the mouse.

     Any suggestions? I can't set an accelerator for the drop-down directly

     because the drop-down has no caption property. Setting it for the

     label doesn't work. Do I have to muck around with form-level keystroke

     trapping, or is there an easier way?

--quote--

     Chris you should be able to do this without any code.  When you press

     alt-c Windows is trying to set focus to the Label, since it can't do

     that it will setfocus to the next control in the tab sequence.  Just

     make sure that the Combo box is directly after the label in the tab

     order and your problems will be solved.

     Hope this helps

     Mike McCarthy


Accelerator key

LUOKKA: TextBox

25.How do I implement an accelerator key for a text box?  **

   You want to use a label caption to identify a text box and to act

   as if it were the text box caption:

   Example:

   &Label1   text1

   How should I do to set the focus to text1, by typing <ALT>L

   Make sure that the TabIndex property for the text box is 1 greater

   than the

   label's TabIndex. Since a label can't have the focus, the focus

   will go to the next item in the tab order, which would be the text

   box.

   Here's any easy way to set the TabIndex for a busy form. Select the

   object that should be last in the tab order and then select the

   TabIndex property. Press 0 (zero), click on the next to last

   object, press 0, click on the  the next object back, press 0, etc.

   When you're done, all of the TabIndexes  will be in order, because

   VB increments all of the higher TabIndexes when you put in a lower

   number.

   Many thanks to Jonathan Kinnick and Gary Weinfurther that provided

   the answer

   on the FIDO net echo VISUAL_BASIC.

    Tiago Leal (Tiago.Leal@p25.f1.n283.z2.gds.nl)


Acrobat PDF

LUOKKA: printing

Date: 07-04-95 (05:23)              Number: 378351 of 379246 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Here's how to print Acrobat PDF files from VB using OLE

From: Sonny Diaz <diazs@SEMATECH.ORG>

Here's how I was able to print Adobe Acrobat PDF files from VB using OLE

automation (error handling left out to shorten post):

Requires Adobe Acrobat Exchange ver 2.0

Sub pdf_print_process()

Call start_exchange()

Call open_pdfdoc()

Call print_pdfdoc()

Call close_pdfdoc()

Call end_exchange()

End Sub

Sub start_exchange()

'launch Acrobat Exchange

aeApp = CreateObject("AcroExch.App")

aeAVDoc = CreateObject("AcroExch.AVDoc")

aePDDoc = CreateObject("AcroExch.PDDoc")

End Sub

Sub open_pdfdoc()

Dim iRetVal%

iRetVal = aePDDoc.Open(ÄPDFDocNameÅ)

End Sub

Sub print_pdfdoc()

Dim iRetVal%

iRetVal = aeAVDoc.PrintPages(ÄfirstpageÅ, ÄlastpageÅ, 1, True, False)

End Sub

Sub close_pdfdoc()

Dim iRetVal%

iRetVal = aeApp.CloseAllDocs

End Sub

Sub end_exchange()

'exit Acrobat Exchange

Dim iRetVal%

iRetVal = aeApp.exit

End Sub

Note:  Acrobat Exchange is never shown to the user and does not appear in

the Windows Task List.  The user only sees the "Printing" dialog as the

document is being printed.

-------------------------------------------

Sonny.Diaz@SEMATECH.ORG


Age compute

LUOKKA: VBgen

2507 (215+)  arjen@shear.iaf.nl  04.01.95  01:10

"Arjen Broeze": "Re: How to Compute Age?"

> How would you compute someone's age given their date of birth?

> I'd like to do something like take now() - db_member.recordset("dob") /

>something and get the number of days between two dates and divide by 365

>but that won't work because some years are leap years (and some aren't - I

>believe 2000 is not). Also, year(now()) - year(db_member.recordset("dob"))

>won't work either cause it doesn't take into account the month...

> So - is there an easy way?

Short answer: nope, there's no easy way.

Something like this will do the trick:

    Dim iAge as integer

    Dim iDiff As Integer

    ' This only hold if db_member already celebrated his birthday this year

    iAge = Year(Now) - Year(db_member.recordset("dob"))

    ' Calculate difference in months

    iDiff = Month(Now) - Month(db_member.recordset("dob"))

    Select Case iDiff

        Case Is >0: ' Current month is bigger than 'birthmonth'

                    ' so, db_member did not have his/her birthday this year

                    iAge = iAge-1

        Case Is 0 : ' Months are equal, check for the day

                    iDiff = Day(Now) - Day(db_member.recordset("dob"))

                    Select Case iDiff

                        Case Is >0:

                            ' Same reason as with month

                            iAge = iAge-1

                        Case Is 0:

                            ' Hey, he/she has his/her birthdayu today

                    End Select

    End Select

Arjen

--

Arjen Broeze                                   Telephone: (+31)53-338666

arjen@shear.iaf.nl                             Address:   Gronausevoetpad 104


Age compute

LUOKKA: VBgen

2520 (202+)  herderb@consl670uc.cim-uc  05.01.95  16:08

Brad Herder: "Re: How to Compute Age?"

Thanks for everyone's advice.  I succeeded by getting the difference

between the two dates in years using datediff, then getting the

day of the year for each date, using datepart and if we haven't

reached the person's birthday yet, subtract 1.  From memory, here's

about what I did:

dim age                 as integer

dim current_day_of_year as integer

dim birth_day_of_year   as integer

age = DateDiff("yyyy",Now(),db_member.recordset("DOB"))

current_day_of_year = DatePart(now(),"y")

birth_day_of_year   = DatePart(db_member.recordset("DOB"),"y")

if ( birth_day_of_year < current_day_of_year ) then

   age = age - 1

endif

I'm not sure about leap years ... will have to check that out.

Of course - to make my program less readable I didn't create the

*_day_of_year variables, just made an ugly if statement....  :-)

Thanks again,

Brad Herder.


Allways on top

LUOKKA: API

Date: 07/02/94 (11:32)              Number: 11016 of 11050 (Refer# NONE)

From: I-PATRD@MICROSOFT.COM

Subj: Re: How to make an application always on top?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Const Swp_Nosize = &H1

Const SWP_Nomove = &H2

Const Swp_NoActivate = &H10

Const Swp_ShowWindow = &H40

Const Hwnd_TopMost = -1

Const Hwnd_NoTopMost = -2

Declare Sub SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal

hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx

As Integer, ByVal cy As Integer, ByVal wFlags As Integer)

Sub OnTop (Handle%, OnTop%)

'  Handle% Window Handle

'  OnTop% - True/False TopMost

  wFlags = SWP_Nomove Or Swp_Nosize Or Swp_ShowWindow Or

Swp_NoActivate

  Select Case OnTop%

     Case True

        PosFlag = Hwnd_TopMost

     Case False

         PosFlag = Hwnd_NoTopMost

     End Select

  SetWindowPos Handle%, PosFlag, 0, 0, 0, 0, wFlags

End Sub


Allways on top

LUOKKA: API

Date:         Mon, 8 Aug 1994 17:03:39 -0500

From:         "Mark D. Richards" <MDR@HYDROSPHERE.COM>

Organization: Hydrosphere Resource Consultants, Boulder, Colorado

Subject:      On Top  XE "On Top"

Here's a little procedure I wrote a couple years ago.  Use it all you

want.  Just pass it the form name and TRUE to make a windows "float", or

FALSE to stop it from floating.

'   Stay On Top                                                              '

'                                                                            '

'   Call this function with the HW of a form, and if the OnTop parameter is'

'   true, it will cause the form to "Float" on top of all other forms.  If   '

'   the OnTop parameter is False, it will "Sink" the form off of the top.    '

'                                                                            '

'   Written By: Mark Richards                                                '

'               Hydrosphere Resource Consultants                             '

'               Boulder, CO 80302                                            '

'               1-303-443-7839                                               '

'   Many Thanks To On-Line Technology, Inc.                                  '

'                                                                            '

Sub StayOnTop (HW As Integer, OnTop As Integer)

    If OnTop Then

        wFlags% = SWP_NOMOVE Or SWP_NOSIZE

        Call SetWindowPos(HW, HWND_TOPMOST, 0, 0, 0, 0, wFlags%)

    Else

        T% = GetNumTasks()

        wFlags% = SWP_NOMOVE Or SWP_NOSIZE 'Or SWP_SHOWWINDOW

        Call SetWindowPos(HW, HWND_NOTOPMOST, 0, 0, 0, 0, wFlags%)

    End If

End Sub


Allways on top

LUOKKA: API

Date: 01/14/95 (07:29)              Number: 32448 of 32470 (Refer# NONE)

From: BLINDPEW@AOL.COM

Subj: Re: Help with SetWindowPo

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

From the Knowledge Base:

(note: make sure SetWindowPos call is in both form's load and resize

procedures).

How to Create a Topmost or Floating Window in Visual Basic

Article ID: Q84251

----------------------------------------------------------------------

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0

- Microsoft Visual Basic programming system for Windows, version 1.0

----------------------------------------------------------------------

SUMMARY

=======

You can create a "floating" window such as that used for the Microsoft

Windows version 3.1 Clock by using the SetWindowPos Windows API call.

MORE INFORMATION

================

A floating (or Topmost) window is a window that remains constantly

above all other windows, even when it is not active. Examples of

floating windows are the Find dialog box in WRITE.EXE, and CLOCK.EXE

(when Always on Top is selected from the Control menu).

For more information on this topic, please see the following article in

the

Microsoft Knowledge Base:

ARTICLE-ID: Q81137

TITLE     : INF: How to Create a Topmost Window

NOTE: Visual Basic forms that are TopMost Windows when they are in either

Normal or Maximized positions will lose the Topmost setting when the

Visual

Basic program is Minimized. Visual Basic destroys the old window and

creates a new one with the Icon in the Window. Therefore, in order for

TopMost to stay in effect, the user needs to reset TopMost in the Resize

event.

There are two methods to produce windows that "hover" or "float," one

of which is possible in Visual Basic for Windows. This method is

described below:

Call SetWindowPos, specifying an existing non-topmost window and

HWND_TOPMOST as the value for the second parameter (hwndInsertAfter):

Use the following declarations:

Declare Function SetWindowPos Lib "user" (ByVal h%, ByVal hb%,

        ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer

' The above Declare statement must appear on one line.

Global Const SWP_NOMOVE = 2

Global Const SWP_NOSIZE = 1

Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Global Const HWND_TOPMOST = -1

Global Const HWND_NOTOPMOST = -2

To set the form XXXX to TOPMOST, use the following code:

success% = SetWindowPos (XXXX.hWnd, HWND_TOPMOST, 0, 0, 0, 0,

FLAGS)

REM success% <> 0 When Successful

To reset the form XXXX to NON-TOPMOST, use the following code:

success% = SetWindowPos (XXXX.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,

FLAGS)

REM success% <> 0 When Successful

NOTE: This attribute was introduced in Windows, version 3.1, so

remember to make a GetVersion() API call to determine whether the

application is running under Windows, version 3.1.

Reference(s):

"Page 892 of Microsoft Windows 3.1 Programmer's Reference, Volume 2,

 Functions,"

Additional reference words: top most Win31 Float Topmost Notopmost

Setwindowpos

KBCategory: kbprg

KBSubcategory: APrgWindow

Copyright 1993 Microsoft Corporation. All rights reserved.


Allways on top

LUOKKA: forms

Date: 12/01/94 (15:52)              Number: 28556 of 28565 (Refer# NONE)

From: DBRODIE@NBNET.NB.CA

Subj: Re: HELP:Always on top.

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

To make form1 always ontop use the following call:

Ontop True,form1

Sub Ontop (ByVal Cond As Integer, frmWnd As Form)

If Cond Then

   'This will make the window always visible!

   SetWindowPos frmWnd.hWnd, -1, 0, 0, 0, 0, &H50

Else

   'This will put "Always Visible" off!

   SetWindowPos frmWnd.hWnd, -2, 0, 0, 0, 0, &H50

End If

End Sub


Allways on top

LUOKKA: on top

17.How do I get my application on top?

   To force a form to the front of the screen, do the following

   command:

     Form1.ZOrder

   To make the application *stay* on top, put the Zorder command in a

   Timer event repeatedly called, say, every 1000 msecs. This makes a

   "softer" on-top than other methods, and allows the user to make a

   short peek below the form.

   There are two different "Zorder"'s of forms in Windows, both

   implemented internally as linked lists. One is for "normal"

   windows, the other for real "topmost" windows (like the Clock

   application which is distributed with MS Windows). The Zorder

   command above simply moves your window to the top of the "normal"

   window stack. To make your window truly topmost, use the

   SetWindowPos API call like this:

     'Make these declares:

     Declare Function SetWindowPos Lib "user" (ByVal h%,

     "ByVal hb%, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%,

     "ByVal f%) As Integer

     Global Const SWP_NOMOVE = 2

     Global Const SWP_NOSIZE = 1

     Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE

     Global Const HWND_TOPMOST = -1

     Global Const HWND_NOTOPMOST = -2

     'To set Form1 as a TopMost form, do the following:

     res% = SetWindowPos (Form1.hWnd, HWND_TOPMOST, 0, 0,

     "0, 0, FLAGS)

     'if res%=0, there is an error

     'To turn off topmost (make the form act normal again):

     res% = SetWindowPos (Form1.hWnd, HWND_NOTOPMOST, 0, 0,

     "0, 0, FLAGS)


AnsiToOem

LUOKKA: API

Date: 08/23/94 (01:40)              Number: 16642 of 16734 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: HELP:AnsiToOemBuff call

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Eino Kukkonen (eino.kukkonen@compart.fi) wrote:

:      dim ans as string

:      dim oem as string

:      ans="KEEk"

:      AnsiToOem ans, oem, len(ans)

: The result is a GPF. There must be something wrong in my code. Perhaps

: passing the arguments. Please, help!

You need to make some room in the oem string.  Try

oem = Space$(len(ans)+1)

gt


AnsiToOem

LUOKKA: API

Date: 08/23/94 (07:40)              Number: 16655 of 16734 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: HELP:AnsiToOemBuff call

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

eino.kukkonen@compart.fi (Eino Kukkonen) writes:

>Hello there!

>I haven't used much Windows API-calls from VB, so obviously I do

>something wrong.

>I have declared sub AnsiToOemBuff (copied from the API-help).

>I have:

>     dim ans as string

>     dim oem as string

>     ans="KEEk"

>     AnsiToOem ans, oem, len(ans)

>The result is a GPF. There must be something wrong in my code. Perhaps

>passing the arguments. Please, help!

You need to ensure that the target string is sufficiently long to hold

the resultant string. Do this either by saying...

oem = Space$(50)

or defining the string as fixed length. Otherwise the API call will throw

up all over your nice clean data segment 8^)

--

Luke Webber


API

LUOKKA: VBgen

Date: 02-09-95    Time: 09:58p     Number: 157

     From: Dg@nbbs.demon.co.uk           Refer:

       To: ALL                        Board ID: COMPART         Recvd: No

  Subject: All ByVal users READ This         0: comp.lang.ba   Status: Public

There are a number of hazards that we all face when we call the Windows

API from any language and VB is certainly no exception. This article attempts

to point out some of the more troubling problems that the VB programmer is

likely to encounter. Much of the content of this article can also be gleaned

from chapter 24 of the VB3 Programmer's Guide, but it seems that many

programmers are still confused on the subject, so a slightly more detailed look

might be useful..

Let the ByVal'er Beware:

The manual is fairly clear on the subject of the use of ByVal, but it is a

modifier which will continues to trip up the unwary. For the record, the main

rules are as follows...

Applied to non-string variables, ByVal will cause the value of the variable to

be passed, rather than a long pointer to the memory area containing the

value

Applied to string variables, ByVal will cause the VB runtime to pass the

address of a null-terminated (C-style) string. Without the ByVal, VB will pass

the handle of the VB string.

A DLL written specifically to support calls from VB might possibly support

passing of VB strings without the ByVal keyword, but IN ALL OTHER CASES,

VB strings should be passed ByVal.

User-defined types cannot be passed ByVal, they must always be passed by

reference (that is, by address). In fact, user-defined types are the only data

types which are routinely passed to the API without the ByVal keyword.

In almost all cases, numeric values such as integers and longs will be passed

ByVal and, of course, user-defined types will be passed by reference, there

being no choice in the matter.

By now, many will be wondering what concern it is of the programmer whether

an API argument is passed ByVal or not. After all, the Win 3.1 API help file

and WIN30API.TXT and WIN31EXT.TXT all provide declarations for most of

the Windows API functions, so surely the VB programmer need not bother

with such low-level concerns. This is true enough in most cases, but by no

means all. To find out why, read on.

While most of the standard, off-the-shelf API declarations provided in the box

with VB will do the job just fine without much real attention from the VB

programmer, there exist a significant number of exceptions. These exceptions

are those which declare one or more arguments As Any.

The Any data type was created in order to allow calls to API functions which

can accept references to a number of different types of data in one catch-all

argument reference. The upshot of this is that the VB programmer must

always be alert to the possibility that a declaration might use the Any

keyword, so as to provide the correct call syntax.

To take the simplest (and by far the most common) case of this, a number of

functions have been designed to accept a long pointer to a string (LPSTR, or

ByVal String), except where the argument is not required, in which case a

null pointer should be passed. For example, the GetProfileString function can

accept an optional lpKeyName argument. If lpKeyName is provided, only the

value for the specified entry is returned. If it is a null pointer, a list of all keys

is returned, delimited by the null character (Chr$(0)).

To allow for this functionality in a single declaration, the VB architects

fastened upon the Any data type, declaring GetProfileString as follows...

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String,

lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As

String, ByVal nSize As Integer) As Integer

You will note that lpKeyName is declared As Any.

What this means to the programmer is that in calling GetProfileString (and

many other functions), the ByVal has to be explicitly provided in the function

call. For example...

RetVal% = GetProfileString("windows", "spooler", "Bog off", Result$,

Len(Result$)) ' Wrong!... will return the rather snotty default string "Bog off",

rather than "yes" or "no". This is because the API function never sees the

string "spooler", instead it sees the handle to the VB string, which it treats as

a string pointer to alphabet soup.

Instead of the above, we require the function call in this form...

RetVal% = GetProfileString("windows", ByVal "spooler", "Bog off", Result$,

Len(Result$)) ' Right!

In this case, the ByVal refers to a string value, which converts our string to a

long pointer to a C-style null-terminated string. This frequently causes

programmers to conclude that the API declaration is wrong and to "fix" it by

replacing the As Any with a type declaration compatible with their immediate

requirements.

Alternatively, in the case where we wish to return all keys in the [windows]

section, we would call thus...

RetVal% = GetProfileString("windows", ByVal 0&, "Bog off", Result$,

Len(Result$)) ' Right!

Note that we have been forced to specify the ByVal in the function call and,

further, to declare the type of the numeric value we are passing. If we leave

off the ampersand type character we will get a "Bad DLL calling convention"

error, number 49. This is because Any doesn't really mean any old Any, but

specifically a 4-byte Any. Of course, if we were passing a numeric variable

instead of a constant, the ampersand would not be necessary, so long as the

variable was declared Long.

An alternative to use of the Any keyword might be to provide multiple

declarations for functions which support multiple data types. For example, we

could declare GetProfileString twice, as follows...

Declare Function GetProfileSection Lib "Kernel" Alias "GetProfileString"

(ByVal lpAppName As String, ByVal lpKeyName As Long, ByVal lpDefault As

String, ByVal lpReturnedString As String, ByVal nSize As Integer) As Integer

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String,

ByVal lpKeyName As String, ByVal lpDefault As String, ByVal

lpReturnedString As String, ByVal nSize As Integer) As Integer

The above declarations would give us all of the flexibility of the Any

declaration with none of the headaches. To retrieve all key names in a

section, we'd call GetProfileSection, passing zero for the lpKeyName

argument, and to retrieve the value of a specific section, we'd call

GetProfileString with the section name. In neither case would we need to

specify the ByVal statement.

Unfortunately, this workaround is also far from perfect. For one thing, the VB

programmer needs to be aware that there are now two separate declarations

for this function, among many others, invalidating much of the standard SDK

documentation. For another thing, there are some noteable cases where the

data being passed can be quite literally any data type. Take for example

those ubiquitous catch-all functions SendMessage and PostMessage

What does it all mean

Put simply, VB programmers calling API functions must be sure to read any

declarations before coding the calling statements, to check if the occasional

ByVal may be required. It is not enough simply to cut and paste function

declarations and then call by rote, because Any demands that you think

before you call. If an API call fails to perform as expected, you should

immediately suspect that you have left out a ByVal in the function call.

As a further caution, it is always a good idea to ensure that you save your

project before running it if you have made any changes to API function

declarations or added or modified any calling statements. If you disregard this

advice, you stand to lose all program modifications since your last project

save when the VB design environment aborts with a GPF. This is a very good

time to consider the "Save project before run" environment option.

Reservations required

One final warning. Many API functions require the caller to provide the

address of a memory buffer to be used to return data. For the VB programmer,

this usually means passing a string ByVal (although the ByVal may be already

provided in the function declaration).

The thing to watch in these cases is that the string is pre-initialised to a

sufficient size to accept the maximum amount of data that may be returned,

or General Protection Faults will result.

To allocate space to a string, you may either dimension it as a fixed length

string or use a simple assignment statement, such as...

MyBuf$ = Space$(MaxSize%)

Contributed by Luke Webber. Internet webber@werple.mira.net.au

Copyright 1995 Luke Webber Consulting Services; ALL RIGHTS RESERVED

--

Name : Daniel Grealy

Email: dg@nbbs.demon.co.uk


API

LUOKKA: WinHelp

Date: 05/15/94 (09:40)              Number: 6254 of 6294 (Refer# NONE)

From: ZBEM04@CAL.AMOCO.COM

Subj: Re: Starting Help from menu, not F1

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Global Const HELP_CONTENTS = &H3 'this is in constant.txt

Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal

lpHelpFile As

String, ByVal wCommand As Integer, dwData As Any) As Integer

Put this in the menu option you want help displayed:

rc% = WinHelp(Me.hWnd, HelpPath & "yourhelp.hlp", HELP_CONTENTS,

CLng(0))

where HelpPath is the full path to your help file.

Hope this helps - see the  SDK help that comes with VB for more info


API title of open Wnd

LUOKKA: API

Date: 08/24/94 (19:07)              Number: 16856 of 16870 (Refer# NONE)

From: DANNEMILLER@DANN4.WISC.EDU

Subj: Re: Which API function to call?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <scott.25.0014AAD2@mjt.com>, <scott@mjt.com> writes:

> Can someone give me the function prototype of the Windows API function

> to get the title of an open window?

Declare Function GetWindowText Lib "User" (ByVal hWnd As Integer, ByVal

  lpString As String, ByVal aint As Integer) As Integer


API writing data back

LUOKKA: API

Date: 04/28/94 (10:07)              Number: 4403 of 4446 (Refer# NONE)

From: NOSACKK@BONES.ET.BYU.EDU

Subj: Re: Weird VB behavior and GPFs - solved!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1994Apr27.130542.26@actew> dgingram@actew.oz.au (Dougal

Ingram) writes:

>Are any of these VB string variables being passed as parameters to API

>function calls ? If so, it may pay to check the following:

>1. With the exception of DLL's written specifically for use with VB, String

>variables should be passed to a function using the ByVal keyword. This

ensures conversion to a C style null terminated string.

>2. You may need to preassign a VB string to a specific length to ensure

>enough memory is allocated for the string being returned by the API call.

>Chapter 3 of Appleman's book explains this in much more detail (and with

>much better accuracy) than my memory allows.

Sure enough, it was an API call that writes it's data back to a string in

memory that was the problem!  I had not preassigned the length of the string

and the API call was corrupting the memory location(s) which follow the

string location.

The API call that was causing the problem was GetPrivateProfileString (used

to read data from an .INI file).  I have one subroutine in one of my .bas

modules that handles most of the .INI file reading, but because I needed

to read some .INI data *before* the read .INI subroutine was called, I had

to use the GetPrivateProfileString call in another subroutine.  So when I

copied and pasted the code, I forgot to bring along the statement that

formats the string for the returned data to a set length.  You can do this one

of two ways:

Dim IniString as String

IniString = String(255, 0)  'A string length of 255 is just an example.

                            'The string could be any length.

Dim IniString as String * 255

In my opinion it is safer to use the second method because all the

work is done in one line which makes it harder to make a mistake (i.e.

you forget to copy the "IniString = String(255, 0)" line when you copy

the code from one subroutine to another).

Also, my use of the GetPrivateProfileString call used the Len statement

to tell this call how long the string is.  I still think this is a good idea (as

opposed to hard-coding a length into the call), since it compliments the

preassignment of the string length discussed above. Here's what my FIXED

and WORKING call looks like (if my memory is working good this morning!):

Dim IniString as String * 255

Dim Retval as Integer

RetVal = GetPrivateProfileString("Settings", "SaveOnExit", "Yes", IniString,

         "Len(IniString), <crap, isn't there another parameter here?>)

Well, other than I can't remember if there is one last parameter in this

particular call, that is how I'm doing this API call.

Anyway, thanks to all those who replied!  Your comments at got me

thinking about the most likely areas where I should be looking.  It looks

like if you can't trace a GPF or other weird error to the bugs documented

in the Knowledge Base, it's best to REALLY study any API calls you are

using in your program.  ESPECIALLY if they are the kind that write their

return data directly to the memory location of your return variable!

Thanks all!

Kris Nosack

Brigham Young University, Provo, Utah, U.S.A.

kris_nosack@byu.edu


API?

LUOKKA: API

1. What is the Windows API?

   The Windows API (Application Program Interface) is a collection of

   Dynamic-Link Libraries (DLLs) that do most of the common things in

   Windows. Calls to the Windows API gives you access to routines that

   do things like drawing menu bars, manipulating bitmaps, playing

   sound files, and pretty much every other function of Windows.


Appl. title heading

LUOKKA: coding

28359 (128+)  rcw@netcom.com  31.07.95  02:36

Robert Woodcock: "How do you get an .EXE's module description name?"

I need to get the module description name of a program that's not running.

You know, the text that you enter in the Application Title text box in the

Make EXE dialog box? I'd like something similar to what Control Panel's

Desktop applet does when it loads the list of available screensavers,

except without scanning for or chopping off the "SCRNSAVE:" prefix.

Does anybody have any methods for getting the offset and length of this

string in the .EXE? (It's gotta have an offset locator in the NE header

somewhere, but where?)

_________________________________________________________

Robert Woodcock

rcw@netcom.com

28402 (86+)  ratloaf@sirius.com  31.07.95  08:11

Rat Loaf: "Re: How do you get an .EXE's module description name?"

Here's a function that will retreive the Application Title header, but

it'll only work with 16bit executables, not 32 bit, since the file format

has changed.  If you're able to modify this function so that it'll work

for both 16 and 32 bit, PLEASE, let me know.

Function GetFileDesc (file$)

  Dim ff&

  Dim filesignature As String * 2

  Dim winheaderpos%

  Dim nonrestablepos&

  Dim lendesc%, desc$

  On Error GoTo BadRecord

  ff& = FreeFile

  Open file$ For Binary Access Read As ff&

  'VB reads binary file byte 00h as byte #1 so 1 byte

  'is added to each Get recordnumber

  'get the Windows Header pos. at byte 3Ch

  Get ff&, &H3D, winheaderpos%

  'make sure it's a valid Windows module, "NE"

  '(New Executable) should be the 1st 2 bytes of the header

  Get ff&, winheaderpos% + 1, filesignature$

  'invoke bad record # error

  If filesignature$ <> "NE" Then Error 63

  'get the nonresident name table pos, it's 2Ch bytes

  'from the beginning of the Windows header

  Get ff&, winheaderpos% + &H2D, nonrestablepos&

  'the 1st byte of the nonresident name table is the

  'length of 1st entry, which is the file description

  Get ff&, nonrestablepos&, lendesc%

  'get the high byte of the integer

  lendesc% = lendesc% / 256

  'initialize the description string variable

  desc$ = Space$(lendesc%)

  '& the description..

  Get ff&, , desc$

  'ta da!

  GetFileDesc = desc$

  Close ff&

  Exit Function

BadRecord:

  If Err = 63 Then

    GetFileDesc = "Not a valid Windows module"

    Close ff&

    Exit Function

  End If

End Function

=====================================

   http://www.sirius.com/~ratloaf


Autodesk animating

LUOKKA: VBgen

Date: 06-18-95 (11:52)              Number: 366422 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: AAPLAY.DLL problems

On Wed, 14 Jun 1995 19:35:34 -0700 Jeff W. said:

>I'm using the Autodesk Animation .DLL to try to play a FLC in my VB for

>windows program.  It says to call the following procedures as follows:

>

>aaOpen(void)

>aaClose(void)

>aaLoad(lpzFileName,hWnd,wMode,x,y,cx,cy,orgx,orgy)

>aaPlay(hAa)

>aaStop(hAa)

>

>I tried typing the following in my module :

>declare sub aaOpen lib "AAPLAY.DLL"

>declare sub aaClose lib "AAPLAY.DLL"

>declare function aaLoad lib "AAPLAY.DLL" (ByVal lpzFileName, byval

>hWnd, byval

>   wMode, byval x, byval y, byval cx, byval cy, byval orgx, byval orgy)

>declare function aaPlay lib "AAPLAY.DLL" (byval hAa)

>declare function aaStop lib "AAPLAY.DLL" (byval hAa)

>

>but it never works!  I get the message "Bad DLL calling convention" or

>something like that.  If anyone has used this .DLL how do I set up the

>above

>functions, and how would I call them in my program?

 The correct declaration for those functions are as follows:

Declare Function aaOpen Lib "aaplay.dll" () As Integer

Declare Sub aaClose Lib "aaplay.dll" ()

Declare Function aaLoad Lib "aaplay.dll" (ByVal lpzFileName$, ByVal

hWnd%, ByVal wMode%, ByVal x%, ByVal y%, ByVal wid%, ByVal hght%,

ByVal orgx%, ByVal orgy%) As Integer

Declare Function aaPlay Lib "aaplay.dll" (ByVal hAa%) As Integer

Declare Function aaStop Lib "aaplay.dll" (ByVal hAa%) As Integer

 Hope this helps...

=========================================================

                Jalal Muhtadi

  College of Computer and Information Science,

  King Saud Univ. (KSU), Riyadh, Saudi Arabia

  E-Mail Address  : F60P029@SAKSU00.BITNET


AVI play

LUOKKA: VBgen

Date: 06-22-95 (03:42)              Number: 369655 of 370426 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: SUMMARY: Playing AVI file

From: Dhawant@AOL.COM

For all those interested in the responses to my earlier query  regarding

playing AVI files over 256 color bitmaps, here is what has worked for me

(thanks to all the responses).

1.  Switch your video driver to 65K or 16.8M colors...virtually guaranteeing

(definitely misspelled) an absence of a palette shift.

or

2.  Make sure the bitmaps are under 256 colors.

I have put #1 into place and it works!

Tej Dhawan


AVI play

LUOKKA: VBgen

Date: 06-16-95 (13:32)              Number: 365247 of 365577 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Playing AVI files through code

I use the following for my avi file running.  It eliminates my dependance on

the dump VBXs and lets me talk directly to the DLL that the VBX talks to

anyway.  I chose this over MCI.VBX, MCIHWNDX.VBX and similar VBXs from

Mediaknife because all of them seemed to be doing them same thing and

their magic VBX code was less than an hour's work to recreate.

Add'l documentation for the code is available from Microsoft.

Create a form with a picture box called picture2.

Declare the following: (each declare on a single line of course)

Declare Function mciSendString Lib "mmsystem" (ByVal lpstrCommand$,

ByVal lpstrReturnStr As String, ByVal wReturnLen%, ByVal hCallBack%) As

Long Declare Function mciGetErrorString Lib "mmsystem" (ByVal dwError&,

ByVal lpstrReturnStr As Any, ByVal wReturnLen%) As Long

Global Const WS_CHILD = &H40000000

Call the following procedure with the avi filename

Sub Showvideo (sAviFile)

    Dim sRet$

   '*** This will open the AVIVideo and create a child window on the

   '*** form where the video will display. Animation is the device_id.

    ErrorStr = Space(255)

    retstr = Space(255)

    On Error GoTo closeavi

    picture1.Visible = False

    CmdStr = ("open " & sAviFile & " type AVIVideo alias Animation parent " +

LTrim$(Str$(Picture2.hWnd)) + " style " +  Trim$(Str$(WS_CHILD)))

    ret = mciSendString(CmdStr, retstr, 0, 0)

    If ret > 0 Then

        ret = mciGetErrorString(ret, ErrorStr, 255)

        MsgBox ErrorStr

    End If

    ret = mciSendString("put Animation window at 0 0 321 242", retstr, 0, 0)

    If ret > 0 Then

        ret = mciGetErrorString(ret, ErrorStr, 255)

        MsgBox ErrorStr

    End If

    ret = mciSendString("play Animation wait ", retstr, 0, 0)

    If ret > 0 Then

        ret = mciGetErrorString(ret, ErrorStr, 255)

        MsgBox ErrorStr

    End If

closeavi:

    MsgBox Str$(Err) & " - " & Error$(Err)

    ret = mciSendString("close Animation", retstr, 0, 0)

    If ret > 0 Then

        ret = mciGetErrorString(ret, ErrorStr, 255)

        MsgBox ErrorStr

    End If

End Sub

Tej Dhawan

Dhawan Computer Consulting, Inc.


Background paint

LUOKKA: forms

Date: 06/10/94 (01:23)              Number: 8534 of 8618 (Refer# NONE)

From: POZAR@ECS.UMASS.EDU

Subj: RE: Background for Setup

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The shaded blue blackground can be done very easily with straightforward

VB code.  Simply modify the DrawBackground routine in SETUP as follows:

Sub DrawBackground()

 setup1.ScaleMode=3

 setup1.DrawStyle=6

 setup1.DrawWidth=2

 setup1.AutoRedraw=True

 For i%=1 to 64

  shadeval%=255-(i%*4-1)

  shadecol&=RGB(0,0,shadeval%)

  y1=setup1.ScaleHeight*(i%-1)/64

  x2=setup1.ScaleWidth

  y2=setup1.ScaleHeight*i%/64

  setup1.Line (0,y1)-(x2,y2),shadecol&,BF

 Next i%

 setup1.Refresh

 setup1.Forecolor=QBColor(15)

 setup1.CurrentX=5

 setup1.CurrentY=5

 Print APPNAME+" Setup"

End Sub

I modified this from another routine that seemed overly complicated.  It

seems to run instantly on my machine (486).


Background paint

LUOKKA: forms

Painting A Forms Background

------------------------------------------

The following code when put in the Form load event of a Form will paint the

Background of the form with a wash of black to blue:

Sub Form_Load()

   Form1.AutoRedraw = TRUE

   Form1.DrawStyle = 6

   Form1.DrawMode = 13

   Form1.DrawWidth = 2

   Form1.ScaleMode = 3

   Form1.ScaleHeight = (256 * 2)

   For i = 0 To 255

      Form1.Line (0, Y)-(Form1.Width, Y + 2), RGB(0, 0, i), BF

      Y = Y + 2

   Next i

End Sub

Tips By:  Karl M. Garand


Background paint

LUOKKA: forms

Date: 12/11/94 (04:32)              Number: 29469 of 29531 (Refer# NONE)

From: SALIB@CYBERCOM.COM

Subj: Re: Backdrop Form

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Does anyone know where I can get a VB routine that creates the "faded in"

>dark blue backdrop that many Microsoft setup programs use?I'd appreciate

>any suggestions.

I made a routine that should do the same thing...only problem is that it

you only get 3 shades of blue unless you set set the palette of the

PicBox you're drawing to. According to the VB programmer's Guide (p.375)

anyone with MS's MDK can do that using BitEdit/PalEdit. If someone who

has the MDK would like to create a 1 pixel bitmap using a 256-color all

blue palette and post it, I would very much appreciate it. Here's the

code sample:

Sub Form_Paint

    Dim I As Long, ColorFactor As Single, Obj As Control

    Set Obj = Picture1

    ColorFactor = 255 / Obj.Height

    For I = 0 To Obj.Height

        Obj.Line (0, I)-(Obj.Width, I), RGB(0, 0, Int((ColorFactor * I) + .5))

    Next I

End Sub

Make sure you have a PicBox named Picure1 and that the form's and

picture box's Scalemode property is set to 3 (pixel). Hope this helps!


Background shaded

LUOKKA: forms

Date: 10/01/94 (12:31)              Number: 21415 of 21416 (Refer# NONE)

From: R.RASANEN%P1.F73.N369.Z1@TECHLAND.COM, r rasanen

Subj: Shaded Forms

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here's a short example, from the latest MS Devnet newspaper

for doing shaded backgrounds in forms.

'shaded.bas

Global Const INSIDE_SOLID = 6

Global Const COPY_PEN = 13

Global Const PIXELS = 3

'shaded.frm

VERSION 2.00

Begin Form Form1

   Caption         =   "Form1"

   ClientHeight    =   1944

   ClientLeft      =   1740

   ClientTop       =   2196

   ClientWidth     =   2268

   Height          =   2436

   Left            =   1656

   LinkTopic       =   "Form1"

   ScaleHeight     =   1944

   ScaleWidth      =   2268

   Top             =   1788

   Width           =   2436

End

Sub Form_Paint ()

 Me.WindowState = 2

 Show

 drawstyle = INSIDE_SOLID

 drawmode = COPY_PEN

 drawwidth = 2 'dithering

 scalemode = PIXELS

 scaleheight = 256

Dim i As Integer

For i = 0 To 255

 Line (0, i)-(Me.Width, i + 1), RGB(0, 0, 255 - i), B

Next i

End Sub


Background to MDI

LUOKKA: graphics

Date: 07/20/94 (02:52)              Number: 12529 of 12618 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Graphic (bitmap) as backg

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>As the subject says... does anyone know how to put a bitmap`

>as the background to a MDI parent window (aka Application

>background)

Use the BitBlt API function.

Declare Function BitBlt% Lib "GDI" (ByVal hDestDC%, ByVal X%, ByVal Y%,

  ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

YSrc%,  ByVal dwRop&)

__________

                          Bradley S. Murray

 Princeton Computer Consulting, Inc.     Phone: (609) 799-5300

 P.O. Box 7345                             Fax: (609) 275-5651

 Princeton, NJ 08543-7345              Internet: bmurray@pluto.njcc.com


Barcodes

LUOKKA: VBgen

Date: 06-28-95 (17:16)              Number: 374303 of 374318 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: FYI: Barcode Codes

From: Andrew Dowswell <Dowswea@AA.WL.COM>

I believe there are some truetype barcode fonts on CICA.  I looked at

barcod39.zip before, and it looked pretty good.  There appears to be a

3of9.zip out there also that you might want to look at.

(If you can't get to CICA you can look at ftp.cdrom.com under

pub/cica/fonts/truetype)

Andy


Beta tester for MS??

LUOKKA: misc

26190 (129+)  74774.305@CompuServe.COM  19.07.95  07:34

Robert Scoble: "Re: How can I become a beta tester of VB 4.0 ?"

It is very difficult at this date to become a tester for VB4,

since the beta is rumored to be in its final stages.

However, for all Microsoft betas, the "official way" is to send a

message to betareq@microsoft.com. Include any information you can

about your software, hardware, and what you'll be using the beta

for. That said, I've never gotten on a beta by sending info to

this address.

I've gotten on dozens of betas, by hanging out in the forums on

CompuServe, and any time I saw a Microsoft face, I'd ask "Can I

get on your beta?"

Also, I notice that hundreds of people get added in the Microsoft

booths at Comdex, VBITS, Tech*Ed, and more.

Another way to get on, is to volunteer in our forums on

CompuServe, but even then, I don't think I can get you on the 4.0

beta.

Coming up in the next year will be Windows 96 (code name

Nashville); Windows NT 4.0 (Cairo or maybe something else); Office

96 (already in development) and more. Robert--VBPJ


Bit manipulaatio

LUOKKA: numbers

Area: Ohjelmointi

From: Matti Kohtala  To: Rauno Laukkarinen

Date: 03 Feb 95  00:56:39

Subj: bitti-operaattorit VB:llä

 RL> Tietääkö kukaan kuinka c-kielen biteittäin- operaattorit

 RL> saadaan muodostettua Visual Basicilla

 RL> Vasen siirto <<

  tulos = luku * (2^siirros)

 RL> Oikea siirto >>

  tulos = luku \ (2^siirros)

 RL> biteittäinen negaatio ~

  tulos = NOT luku

 RL> biteittäinen JA &

  tulos = luku1 AND luku2

 RL> biteittäinen TAI ö

  tulos = luku1 OR luku2

 RL> biteittäinen pois sulkeva TAI ^

  tulos = luku1 XOR luku2


Bit manipulation

LUOKKA: numbers

Date: 01/04/95 (13:47)              Number: 31568 of 31612 (Refer# NONE)

From: WEBBER@WERPLE.MIRA.NET.AU

Subj: Re: ??? Why does this Overflow ???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

lapaso@enuxsa.eas.asu.edu (Anthony F. LaPaso) writes:

>I'm *trying* to write a function that takes a

>long value (4 bytes) as input and returns the

>integer portion contained in the low-order

>word (2 bytes).  Here's the function:

>   Function LoWord (Arg As Long) As Integer

>      LoWord = Arg And &HFFFF&

>   End Function

I get it. VB tries to assign a number > 32767 to LoWord, and then over

flows. Try this...

 Function LoWord (Arg as Long) As Integer

 Dim ix%

 ix = Arg And &H7FFF&

 If (Arg ™ &H8000&) Mod 2 Then

  ix = ix - 32768

 EndIf

 LoWord = ix

 End Function

Note that the division is *integer* division ("™", not "/")

--

Whoops, I just reread this post and realised I didn't fully answer the

question. It goes like this...

>   Function LoWord (Arg As Long) As Integer

>      LoWord = Arg And &HFFFF&

>   End Function

The above won't work for values with bit 15 set, because VB will see that

as an attempt to assign a value > 32767 to an integer.

>  HiWord = (Arg And &HFFFF0000) / 65536  ' Works fine!

This will work just fine, because a Long with bit 31 set is *negative*,

so dividing it by 65536 just moves bits 16 through 30 16 bits to the

right, keeping the sign bit where it is. No overflow, just nice, neat,

negative integers.

--

Luke Webber


Bit manipulation

LUOKKA: numbers

Date: 02-10-95    Time: 03:54a     Number: 216

     From: ajm@geac.co.nz                Refer:

  Subject: Snippet                           0: comp.lang.ba   Status: Public

If you want to convert two 16 bit integers to a 32 bit long or vice-versa -

particularly useful when you are unpacking the lparam from a message or

building one, then the easiest way I've found is this:-

'integer/long coercion types

Type longword

    value As Long

End Type

Type ints

    loword As Integer

    hiword As Integer

End Type

Now, to convert,

dim ints as ints

dim longword as longword

dim hiword as integer

dim loword as integer

dim longword as long

'two ints (hiword,loword) to a long (longword)

ints.hiword = hiword

ints.loword = loword

LSet longword = ints

longword = longword.value

'long (longword) to two ints (hiword,loword)

longword.value = longword

lset ints = longword

hiword = ints.hiword

loword = ints.loword

This is much simpler than dividing - besides which, &h8000 is a difficult

value to process when dividing, most likely you'll get an overflow error.

The ability of lset to copy differing structures is most useful but not

exactly well known, though the help text does mention it.


Bit manipulation

LUOKKA: VBgen

Date: 10/18/94 (23:25)              Number: 23484 of 23637 (Refer# NONE)

From: COTTONI@JMBPO1.BAH.COM

Subj: Re: Bitwise operators in VBWin

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Visual Basic also provides the necessary logical operators: AND to extract

desired bits and XOR to set them. E.G., (Variable AND 15) extracts the

rightmost 4 bits.

(15 = 2^0 + 2^1 + 2^2 + 2^3).


Bit manipulation

LUOKKA: VBgen

Date: 12/17/94 (07:19)              Number: 29974 of 30023 (Refer# NONE)

From: SUSSMAN@ENVMSA.EAS.ASU.EDU, Mike Sussman

Subj: Re: Logic Operators

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>

>if (Bit_Field_1 and &H01) and (Bit_Field_2 and &H02) then

>Now, both sub-expressions are used to pull out (check) one bit from

>a bit field.  The first expression is checking bit #1, the second

>is checking bit #2.  If both sub-expressions return TRUE, I'd WANT

>the if statement to act as TRUE, but since the middle and will be

>treated as a bitwise and as well, and since the two bits don't match,

>it will result in a false.

I usually just write a function that returns TRUE (-1) or FALSE (0) for me,

given the bit field and the bit mask (flags to be tested):

--------------------------------------------------------------------------

Function test_flags (bit_field%, flags%) as Integer

  test_flags = ((bit_field% And flags%) <> 0)

End Function

--------------------------------------------------------------------------

I set up my flags to be constants pertaining to unique bits in an integer

value, e.g.

 'Status flags

 Const GUARDING = 1   '2^0

 Const ATTACKING = 2  '2^1

 Const FLEEING = 4    '2^2

 Const HIDING = 8     '2^3

To set the flags in an integer that contains the "status," just use:

 status% = status% Or FLEEING

and to clear the flags, use:

 status% = status% And (Not FLEEING)

Multiple flags can be set or cleared (or tested) together by simply summing

them up:

 status% = status% Or (GUARDING + ATTACKING)

 status% = status% And (Not (FLEEING + HIDING))

 is_a_wimp% = test_flags(status%, (FLEEING + HIDING))

Using bit manipulation is great for saving memory, since you can store up

to 16 flags in one integer (2 bytes), instead of having to use 16 integers

to keep track of 16 flags (32 bytes).


BitBlt

LUOKKA: printing

Date: 04/28/94 (12:22)              Number: 4614 of 4664 (Refer# NONE)

From: GINS@SUNSPOT.COM

Subj: Re: How do I BitBlt to the Printer?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sub PrintPicture (SourcePicture As Control, rpLeft, rpTop)

    Dim APIError%, hMemoryDC%, hOldBitMap%

    Dim oldscalemode1%, oldscalemode2%

    Dim xFactor%, YFactor%

    ' Assume API funtions are Declared

    'Declare Function StretchBlt% Lib "GDI" (ByVal hDC%, ByVal x%, ByVal

y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

YSrc%, ByVal nSrcWidth%, ByVal nSrcHeight%, ByVal dwRop&)

    'Declare Function CreateCompatibleDC Lib "GDI" (ByVal hDC As Integer)

     As Integer

    'Declare Function SelectObject Lib "GDI" (ByVal hDC As Integer, ByVal

       hObject As Integer) As Integer

    'Declare Function DeleteDC Lib "GDI" (ByVal hDC As Integer) As Integer

    SourcePicture.Picture = SourcePicture.Image

    ' Local constants

    Const SRCCOPY = &HCC0020

    Const PIXEL = 3

    ' StretchBlt requires pixel coordinates.

    oldscalemode1% = SourcePicture.ScaleMode

    oldscalemode2% = printer.ScaleMode

    SourcePicture.ScaleMode = PIXEL

    printer.ScaleMode = PIXEL

    ' Calculate target proporitions

    xFactor = Screen.TwipsPerPixelX / printer.TwipsPerPixelX

    YFactor = Screen.TwipsPerPixelY / printer.TwipsPerPixelY

    hMemoryDC% = CreateCompatibleDC(SourcePicture.hDC)

    hOldBitMap% = SelectObject(hMemoryDC%, SourcePicture.Picture)

    ' The following should all appear on one line

    APIError% = StretchBlt(printer.hDC, rpLeft, rpTop * YFactor,

SourcePicture.ScaleWidth * xFactor, SourcePicture.ScaleHeight * YFactor,

hMemoryDC%, 0, 0, SourcePicture.ScaleWidth, SourcePicture.ScaleHeight,

SRCCOPY)

    hOldBitMap% = SelectObject(hMemoryDC%, hOldBitMap%)

    APIError% = DeleteDC(hMemoryDC%)

    ' Reset ScaleMode

    SourcePicture.ScaleMode = oldscalemode1%

    printer.ScaleMode = oldscalemode1%

End Sub


BitBlt flicker-free

LUOKKA: graphics

Date: 08/23/94 (07:40)              Number: 16656 of 16734 (Refer# NONE)

From: GALENR@GR.HP.COM

Subj: Re: Flicker-Free Sprite Animation

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

OProsser (oprosser@aol.com) wrote:

: Does anyone have a routine for fast, flicker-free sprite animation?  The

: one I'm using at the moment produces flicker-free results only when run at

: a fairly slow speed. It's more or less as follows (using BitBlt):

BitBlt to a memory context, then BitBlt from the memory context to your

form/image/picture control...

- Galen -

galenr@hpgrla.gr.hp.com


BitBlt kuvan kopioin

LUOKKA: graphics

Date: 20.02.95 (12:25)              Number: 781 of 788 (Refer# 772)

From: AULIS KARHUNEN

Subj: Re: Visual Basic kuvankopiointi

Conf: PC-Ohjelmointi (8)         Read Type: GENERAL (A) (+)

> -> En nyt ole ihan varma minkätyyppisiä kuvia haluat tehdä tai siirrel

> -> jos ikonikoko riittää, niin niitähän voi animoida ja siirrellä ruud

> -> helposti. Ikoneitahan voi tietysti käsitellä myös ryhmittäin, mikä

> -> vaikutelman suuremmasta kuvasta.

>

> Teen semmoista peliä jossa maasto koostuu kuvista jotka pitäisi yhdist

> kuvaan. Tämä siksi että 100 picturen/imagen päivitys on huomattavasti

> hitaanpaa, ja ne 100 kuvaa vie aika paljon muistia.

Homma hoituu Windowsin komenolla BitBlt (nopeasti!!!):

Tehdään kuva jossa on kolme maastopalaa vierekkäin (tässä koko 25x25),

ladataan se pictureboxiin (autoredraw = true). Ohjelma kopioi tarvit-

tavan palasen pictureboxista formin (autoredraw = false) tiettyyn

kohtaan.

' Yhdelle riville:

Declare Function BitBlt Lib "GDI" (ByVal ThDC%, ByVal Tx%, ByVal Ty%,

 ByVal w%, ByVal h%, ByVal ShDC%, ByVal Sx%, ByVal Sy%, ByVal rop&)

 As Integer

' ThDC%      = kohteen hDC, esim. picture1.hDC

' Tx% ja Ty% = kohteen koordinaatit (pixels)

' w% ja h%   = kopioitava kuva leveys ja korkeus (pixels)

' ShDC%      = alkuperäisen kuvan hDC

' Sx% ja Sy% = alkuperäisen kuvan koordinaatit (pixels)

' Rop%       = Copy   &HCC0020

'              Invert &H660066

'              Erase  &H440328

'              AND    &H8800C6

Dim Kartta(1 to 10) As String * 10

Sub Draw()

   For j = 0 To 9

      For i = 0 To 9

         Pala = Asc(Mid$(Kartta(j + 1), i + 1, 1)) - 65

   ' Yhdelle riville:

         a% = BitBlt(hDC, i * 25, j * 25, 25, 25, picture1.hDC, Pala *

         25, 0, &HCC0020)

      Next i

   Next j

End Sub

Sub Form_Activate()

   Kartta(1) = "AAAAAAAAAA"

   Kartta(2) = "ABBBBBBBBA"

   Kartta(3) = "ABCCCCCCBA"

   Kartta(4) = "ABCBBBBCBA"

   Kartta(5) = "ABCBAABCBA"

   Kartta(6) = "ABCBAABCBA"

   Kartta(7) = "ABCBBBBCBA"

   Kartta(8) = "ABCCCCCCBA"

   Kartta(9) = "ABBBBBBBBA"

  Kartta(10) = "AAAAAAAAAA"

   Draw

End Sub


BitBlt overflow

LUOKKA: graphics

Date: 05/25/94 (23:08)              Number: 7086 of 7091 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Source Code for BitBlt Overflow

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: >Sub DrawFlag (index%)

: >  Dim rc%, x%, y%

: >  x% = (screen.width - frmflags.picflag(index%).width) Ö 2

: >  y% = (screen.height - frmflags.picflag(index%).height) Ö 2

: >  rc% = BitBlt%(frmain.hDC, x%, y%, frmflags.picflag(index%).width, -->

: >      frmflags.picflag(index%).height, frmflags.picflag(index%).hDC, -->

: >      0, 0, SRCCOPY)

: >End Sub

: >

: >This is as far as it gets, and then it bombs.  The Error MsgBox only

: >says "Overflow".  All Autoredraw and ClipControls properties are set

I can see a few problems:

1. You're getting twips mixed up in there- at least from the Screen object

and maybe the picflag?

2. You could conceivably end up with neg. x or y.  Also, they could

possibly end up overflow cuz Ö can return a long as well as an int.

3. It's not a bad idea, whenever you have trouble with API calls to assign

control var values to temp vars and put them in the actual call.  Among

other things, you'll catch type mismatches easier.

hope this gets you started

gt


BitBlt transparency

LUOKKA: graphics

Date: 07/07/94 (00:21)              Number: 11394 of 11683 (Refer# NONE)

From: GALENR@GR.HP.COM

Subj: Re: Transparency in games

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

sarash@vision.vsrc.uab.edu wrote:

: Problem: There is a form containing a Picture that acts as a background.

: (like most game's background ) There is also an image that moves on top of

: this background. ( like a hero). The image contains an unwanted color

: region which makes the underlying background opaque.

: ( When the image moves, a square moves rather than the

:  the subject on that square )

: Q: How can I get rid of this unwanted color. i.e. How can I make the

: unwanted color region to become transparent?

snip

: I remember sometime ago a knowledgeable expert was recommending a VB.

: Game book covering this topic either here or in another group.!

Hmm, must've been me :-) I've recommended this book a couple of times...

It is "Programming Games for Beginners, Visual Basic for Fun and Profit"

by Chris Howard - Sam's Publishing, ISBN 0-672-30313-2  Good book, covers

just this sort of thing and don't let the title fool ya, there's good stuff

in there for more advanced VB programmers too.

As an answer to your question, the Image control supports transparency with

"transparent ink" but the Picture control does not. However a picture control

can be made "transparent" with clever application of an api function called

"BitBlt". Using the Image control is much easier BUT you must have an image

or icon editor that supports "transparent ink" as an ink type. The Whitewater

Resource toolkit is one such editor. I think the example icon editor

application that comes with VB also supports "transparent ink" (can't ever

remember the name of this thing but it IS SOMEWHERE in the VB directory).

By using transparent ink in an icon or bitmap loaded into an Image control,

the background form simply shows thru the Image control wherever the

transparent ink was used.

Using the BitBlt api function on a Picture control is a good deal more

complicated. The best examples of how to use it are described in the book I

just recommended or also in The Waite Group's book "VB How-to"

(ISBN 1-878739-09-3). Another (poorly explained) example is given in a VB

Knowledge Base article (which is also in your VB directory!). I'd post

example code, but I haven't the time to try to explain how to make it work

(which is the HARD part with the BitBlt api call...). If someone were to BEG

me really nicely though, who knows....

- Galen -


BitBlt using

LUOKKA: graphics

Date: 11/23/94 (22:29)              Number: 27803 of 27896 (Refer# NONE)

From: GARHOW@HPUBMAA.ESR.HP.COM

Subj: Re: BitBlt

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

"> I don't understand how to use BitBlt.. Can someonw show me.. Thanks

This is an example program that will blt a bitmap from one device

context to another, for example from a PictureBox to a Form. It uses

a SUB DrawBitMap that is a Visual Basic implementation of the C function in

Petzold's Programming Windows 3.1. It is on page 631. This example

calls a function (agGetAddressForObject) in the DLL Apiguide.dll, included

with the book Visual Basic Programmer's Guide to The Windows API. You

can't use it without that. If you don't have that book, you probably shouldn't

be messing around with the API anyway.

To use it, create a Visual Basic app with a form, Form1, containing a

PictureBox, Picture1 and assign a bitmap to the Picture1.Picture property.

Make the Picture1.Visible property = false.

---------------------------------------------------------------------

Add a button to Form1 with the following code:

Button1_Click ()

  Dim di%, hDC As Integer, hBitmap As Integer

  hDC = Form1.hDC

  hBitmap = Form1.Picture2

  'You can't pass the device context and bitmap handle directly

  DrawBitMap hDC, hBitmap, 0, 0

end sub

In the General Declarations section of Form1.bas include the following API

declarations:

--------------------------------------------------------------------

Option Explicit

  Type POINTAPI  '4 Bytes - Synonymous with LONG

        x As Integer

        y As Integer

  End Type

  '  Bitmap Header Definition

  Type BITMAP '14 bytes

        bmType As Integer

        bmWidth As Integer

        bmHeight As Integer

        bmWidthBytes As Integer

        bmPlanes As String * 1

        bmBitsPixel As String * 1

        bmBits As Long

  End Type

  Declare Function CreateCompatibleDC% Lib "GDI" (ByVal hDC%)

  Declare Function SelectObject% Lib "GDI" (ByVal hDC%, ByVal hObject%)

  Declare Function SetMapMode% Lib "GDI" (ByVal hDC%, ByVal

nMapMode%)

  Declare Function GetObjectAPI% Lib "GDI" Alias "GetObject" (ByVal

hObject%,  ByVal nCount%, ByVal lpObject&)

  Declare Function agGetAddressForObject& Lib "Apiguide.dll" (object As

Any)

  Declare Function DPtoLP% Lib "GDI" (ByVal hDC%, lpPoints As POINTAPI,

    ByVal nCount%)

  Declare Function BitBlt% Lib "GDI" (ByVal hDestDC%, ByVal x%, ByVal y%,

   ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

YSrc%,     ByVal dwRop&)

  Declare Function DeleteDC% Lib "GDI" (ByVal hDC%)

  Declare Function GetMapMode% Lib "GDI" (ByVal hDC%)

  '' Raster-ops (Ternary)

  Global Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

------------------------------------------------------------------------

Also in the General section, include the following sub:

------------------------------------------------------------------------

Sub DrawBitMap (hDC As Integer, hBitmap As Integer, xstart As Single, yStart

  As Single)

  Dim bm As BITMAP, hdcMem As Integer

  Dim ptSize As POINTAPI, ptOrg As POINTAPI

  Dim di As Integer

  'Create memory device context compatible with destination

  hdcMem = CreateCompatibleDC(hDC)

  'Select the bitmap into the memory device context

  di = SelectObject(hdcMem, hBitmap)

  'Set mapping mode same as destination device context

  di = SetMapMode(hdcMem, GetMapMode(hDC))

  'Get dimensions of the bitmap

  di = GetObjectAPI(hBitmap, 10, agGetAddressForObject&(bm))

  ptSize.x = bm.bmWidth

  ptSize.y = bm.bmHeight

  'Convert point to logical coordinates

  di = DPtoLP(hDC, ptSize, 1)

  ptOrg.x = 0

  ptOrg.y = 0

  di = DPtoLP(hdcMem, ptOrg, 1)

  'Blit the bitmap onto the destination

  di = BitBlt(hDC, xstart, yStart, ptSize.x, ptSize.y, hdcMem, ptOrg.x, ptOrg.y,

    SRCCOPY)

  'Destroy the memory device context

  di = DeleteDC(hdcMem)

End Sub

----------------------------------------------------------------------

When you click on the button, the picture from Picture1 should be

displayed in the upper left corner of the form. Experiment by changing

the coordinates.

--

Garry Howard                          Hewlett-Packard Company

Technical Consultant                  29 Burlington Mall Road

Professional Services Organization    Burlington, MA 01803 USA

garhow@hpubmaa.esr.hp.com


Bitmap 256 palet

LUOKKA: graphics

==============================================================

Date:         Sun, 16 Oct 1994 23:17:35 EDT

From:         "Terry E. Harris" <harris@POND.COM>

Subject:      Bitmaps 256 color palette

>From: Keith Baugher

>My question - Is there a way to force the system to use the

>palette from a bitmap on my form, and restore the system palette when my

>program is through?

I had this very problem. First, if you are using a display driver that

supports 256 colors, you will only actually be able to use 236. Windows

reserves 20 palette locations for system colors (the ones you set in Control

Panel). To get your form or picture box container to support your own

palette, you should follow these steps:

1) Get PALEDIT (part of the Windows SDK) to create a BMP file that

contains a single pixel and your entire palette.

2) Use this code to force the palette into your app:

        'Load a special palette (by hook or crook)

        Clipboard.SetData LoadPicture(app.Path + "\PALETTE.BMP"),

CF_PALETTE

        picPicture.Picture = Clipboard.GetData(CF_PALETTE)

        Me.Picture = Clipboard.GetData(CF_PALETTE)

Unfortunately, this method will only work with controls that have a picture

property. Forms and Picture Boxes have this property, and controls that are

"palette-aware" can be placed on them and utilize the palette. There's the

rub, many (if not most) 3rd party controls are not palette-aware. What you

get then is an annoying palette-shift as WIndows places colors into the

system palette in an attempt to satisfy your request for color. If the color

does not exist in the system palette, you get the annoying dithering problem.

I am looking deeper into the Windows SDK to see if I can fix these problems

for myself. If I can, I will post here.


Bitmap animate BMP

LUOKKA: graphics

Date: 08/12/94 (11:01)              Number: 15277 of 15372 (Refer# NONE)

From: OPROSSER@AOL.COM

Subj: Re: Animate a BMP across the screen?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1994Aug11.185531.22087@news.vanderbilt.edu>,

westberg@vuse.vanderbilt.edu (Edward Eric Westberg) writes:

>I want to move a BMP file across the screen (animate) 1 pixel at a time

>so it will be smooth.  Using the .Move x,y method works OK but is still

>slow (P5-90) (well actually it is just not as smooth as it should be).

>My question:  How can you animate a BMP across the screen (via API

>in an elegant manner?  I have tried to use BitBlt but it requires using

>2 picture boxes.  I couldn't get scrollwindow to work at all.  The

>problem with 2 picture boxes is that they will be positioned right next

>to each other, and I forsee problems in smootheness.

Using BitBlt is the best method.  Set the source  picture box as

AutoRefresh = True, AutoSize = True, Visible = False, ScaleMode = PIXEL ,

and Form1 as Scalemode = PIXEL, then use somthing like the following:

Form_Click()

Const SRCCOPY = &HCC0020

X = 0

While X < 640

X = X + 1

BitBlt(form1.hDC,  X,  0,  Picture1.Scalewidth,  Picture1.ScaleHeight,

  picture1.hDC, 0, 0, SRCCOPY)

Wend

End Sub

That should move the bitmap in Picture1 from left to right accross the top

of the screen.

-- John Nichols


Bitmap hot-spots

LUOKKA: graphics

Date: 06/24/94 (08:45)              Number: 10339 of 10373 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Hot-spots on bitmaps?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 06-24-94 LSS3016@FESTIVAL.ED.AC.UK  wrote:

L>Does anybody know how to put hot-spots on a bitmap?

L>We've tried putting invisible buttons on top of the bitmap, but it

L>doesn't work. We can't think of any other way! If anybody has any

L>ideas could you please tell us.

Try it with empty Image controls instead.  Almost no resources are used,

and they don't have to be invisible or disabled.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Bitmap hot-spots

LUOKKA: graphics

Date: 06/27/94 (17:45)              Number: 10787 of 10897 (Refer# NONE)

From: FS@USCEAST.CS.SCAROLINA.EDU, Faisal Siddiqi

Subj: Re: Hot-spots on bitmaps?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Rami.Rasanen@f73.n369.z1.fidonet.org writes:

>To: lss3016@festival.ed.ac.uk (K Speirs)

>Subject: Hot-spots on bitmaps?

>L>Does anybody know how to put hot-spots on a bitmap?

> The Visual Basic How-To 2nd Edition from Waite Group has one such

> example, the other is to buy a custom control that comes with

> Crescent QuickPak Pro, called something like VBINVIS.VBX which

> appears as a picture at development time, but when you run your

> app it changes the cursor image (when passing above the defined

> area).

You can also use VB's image controls for implementing hot-spots. Put a

picture box control on the form, specify its picture property, then put

smaller image controls on top of the picture box control, and leave

their picture properties blank. In the click event of the image

controls, add the code you want to execute. Don't forget to set the

borderstyle property of the image control to None.

Gunhan Tatman (Gunhan_Tatman@columbia.usconnect.com)

803-935-1100


Bitmap Load & cursor

LUOKKA: graphics

Date: 09/22/94 (03:55)              Number: 20319 of 20381 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: PushButton.Picture = LoadBitmap(DLLIns, ID) problem?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> I have a library that I load using "LoadLibrary" successfuly.

> It has two cursors and one bitmap. I can load the two cursors

> using "LoadCursor" and use them using "SetClassword". But

> When I load the bitmap it return a value<>"0" this mean success

> as the VB help said. But I got error message

>  "Not approperiate Property value?" Why? Please help.

 snip

>  i = LoadBitmap(...)

>  j = LoadBitmap(same bitmap)

> I found i <> j Why?

I think what you need to do is to assign the return value from LoadBitmap

to an integer, then BitBlt from it to the hDC property of the control.

The Picture control can be assigned from the LoadPicture or GetData

functions, or from another control's Picture, Image, Icon and DragIcon

properties, but not directly via the API.

Because LoadBitmap will copy the bitmap into a global memory object, so

two loads gives two objects.

--

Luke Webber


Bitmap PICCLIP

LUOKKA: graphics

Date: 07/12/94 (10:35)              Number: 11816 of 11852 (Refer# NONE)

From: KKARVONE@CC.OULU.FI

Subj: Re: How to use PICCLIP control??

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Jon Arnold (harris.jarnold@ic1d.harris.com) wrote:

: Using VB for Win Pro v3.0 and can't seem to figure out how to use the

: PICCLIP control?  I've got a pile of "icons" (ok, they're really small

: graphic files, about 120x120 pixels each), and it SEEMS like PICCLIP would

: be a nice way to handle them in the program.  But according to what I read

: in the manual, I've got to create a single BMP file with all these files

: included in it, so that PICCLIP can use it.

: There MUST be a better way?!  I've been playing with PhotoPaint and a

: couple others to try to get all these graphic files lined up perfectly

: into a new single BMP file, and it gives a whole new meaning to the word

: "tedious".

: Any advice/suggestions/inputs on using PICCLIP would be appreciated.  If

: this is really the way Microsoft intended for PICCLIP to be used, I don't

: know why they even included this virtually useless control in the VB

: distribution...

: harris.jarnold@ic1d.harris.com

If your pictures are in BMP -format, you can use Windows Paintbrush to do

one BMP -file and load it into the PICCLIP. First count the total area needed

for you pictures if placed all in one BMP -file. Then start a new picture in

Paintbrush with correct picture height and width, you can set these in Image

Attributes (from the Options -menu). When the new drawing area is made by

Paintbrush, draw a "help-grid": this have to be square since the

PICCLIP can only use square pictures. If you have black-and-white pictures

draw the grid with some color (it's easy to erase after you have pasted your

pictures in to it). Then simply paste your pictures from file (Edit -menu) one

by one to this bigger picture. Erase the "help-grid" using the color eraser,

save the big picture and load it into the PICCLIP -control when in VB.

This big picture can have your smaller pictures in several lines and colums

(you have to set these right in the PICCLIP's properties -window).

I think there are two ways to tell to the PICCLIP which picture to load (I

don't recall these but you can easily find them from manuals or from online

help, you call the pictures by their number in the picclip's picture: picture

in the upper left corner is numbered 0, next one in first line 1 and so on).

This works fine but it can slow down your program since this one big

graphics file is load into memory (I once had about 50 BW -pictures sized

200x200 pixs. and my 486/8MB -computer was very slow to start the program

which included all these in one pictureclip, I solwed this by making a

database of the pictures).

Look at the redtop -sample program that comes with VB 3 Prof. version (if you

installed the sample files, it is in /vb/samples/picclip/redtop.mak. It also

has a great sample of how to make a animated icon for the program!)

Keijo Karvonen


Bitmap PICCLIP

LUOKKA: graphics

Date: 07/13/94 (13:13)              Number: 11924 of 12069 (Refer# NONE)

From: ASSA@NETWORK.CC.JYU.FI

Subj: Re: How to use PICCLIP control??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <harris.jarnold.227.2E217A23@ic1d.harris.com>,

Jon Arnold <harris.jarnold@ic1d.harris.com> wrote:

>There MUST be a better way?!  I've been playing with PhotoPaint and a

>couple others to try to get all these graphic files lined up perfectly into a

>new single BMP file, and it gives a whole new meaning to the word

>"tedious".

You can write your own aligning procedures. I wrote for my own use

(both for the PICCLIP and for animations using CANIMATE.VBX) a small

utility which takes several bitmaps (of equal sizes) and arranges

them in one line or one column (for creating a grid I first create several

lines and them a column of lines - resulting in grid). Using this approach

assures prfect aligning and spacing. The whole thing took less than an

hour to code (including some extras like changing the order of the line,

mirroring etc.)

Hope this helps,

  Yoav Assa


Bitmap PICCLIP

LUOKKA: graphics

Date: 07/15/94 (13:12)              Number: 12151 of 12223 (Refer# NONE)

From: ASSA@NETWORK.CC.JYU.FI

Subj: Combining bitmaps (for PICCLIP etc.)

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Some people asked me to post the code I have for combining some

(equally sized) bitmaps into one (for PICCLIP etc.). I post here

the code for creating a line - i.e. a long bitmap comprised of

several smaller bitmaps. For this to run as is, it is supposed

that you have 4 bitmaps, called d:ÖbitmapsÖitem0.bmp

                                d:ÖbitmapsÖitem1.bmp

                                d:ÖbitmapsÖitem2.bmp

                                d:ÖbitmapsÖitem3.bmp

and the result will be put in   d:ÖbitmapsÖline0.bmp

(if you want to change the number of the bitmaps or the file names,

change the code of MakeLine_click accordingly or write a nice user

interface...)

***********************************************************************

'put the following in a code module:

Type bitmap

  bmType As Integer

  bmwidth As Integer

  bmHeight As Integer

  bmWidthBytes As Integer

  bmPlanes As String * 1

  bmBitsPixel As String * 1

  bmBits As Long

End Type

'put each of the declarations in one line

'note that some of these are not required by the code fragment posted here,

'I just copied all the declarations from my program

Declare Function BitBlt Lib "GDI" (ByVal hDestDC As Integer, ByVal x As

   Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As

   Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer, ByVal YSrc As

   Integer, ByVal dwRop As Long) As Integer

Declare Function StretchBlt% Lib "GDI" (ByVal hDC%, ByVal x%, ByVal y%,

   ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

YSrc%,

   ByVal nSrcWidth%, ByVal nSrcHeight%, ByVal dwRop&)

Declare Function SetBkColor Lib "GDI" (ByVal hDC As Integer, ByVal cColor

   As Long) As Long

Declare Function CreateCompatibleDC Lib "GDI" (ByVal hDC As Integer) As

   Integer

Declare Function DeleteDC Lib "GDI" (ByVal hDC As Integer) As Integer

Declare Function CreateBitmap Lib "GDI" (ByVal nWidth As Integer, ByVal

   nHeight As Integer, ByVal cbPlanes As Integer, ByVal cbBits As Integer,

   lpvBits As Any) As Integer

Declare Function CreateCompatibleBitmap Lib "GDI" (ByVal hDC As Integer,

   ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer

Declare Function SelectObject Lib "GDI" (ByVal hDC As Integer, ByVal

   hObject As Integer) As Integer

Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As

   Integer

Declare Function GetObj Lib "GDI" Alias "GetObject" (ByVal hObject As

   Integer, ByVal nCount As Integer, bmp As Any) As Integer

Const SRCCOPY = &HCC0020

Const SRCAND = &H8800C6

Const SRCPAINT = &HEE0086

Const NOTSRCCOPY = &H330008

  'put the following Sub declaration in one line

Sub bmp_copy (dest As PictureBox, ByVal srcBmp As Integer,

              ByVal x As Integer, ByVal y As Integer)

  Dim srcDC As Integer

  Dim bmp As bitmap

  Dim hPrevBmp As Integer

  Dim hSrcPrevBmp As Integer

  Dim Success As Integer

  Success = GetObj(srcBmp, Len(bmp), bmp)

  srcDC = CreateCompatibleDC(dest.hDC)

  hSrcPrevBmp = SelectObject(srcDC, srcBmp)

  'put the following in one line

  Success = BitBlt(dest.hDC, x, y, bmp.bmwidth, bmp.bmHeight, srcDC,

                   0, 0, SRCCOPY)

  dest.Picture = dest.Image

  hPrevBmp = SelectObject(srcDC, hSrcPrevBmp)

  Success = DeleteDC(srcDC)

End Sub

'Create a form containing two picture controls with their scalemode

'properties set to PIXEL, and a command button named MakeLine

Sub MakeLine_Click ()

  Dim src As String

  Dim dest As String

  Dim cells As Integer

  Dim i As Integer

  'change here to fit your requirements

  src = "d:ÖbitmapsÖitem"

  dest = "d:ÖbitmapsÖline0.bmp"

  cells = 4

  picture2.picture = LoadPicture(src & "0.bmp")

  picture1.Height = picture2.Height

  picture1.Width = picture2.Width * cells

  DoEvents

  For i = 0 To cells - 1

    picture2.picture = LoadPicture(src & i & ".bmp")

    Call bmp_copy(picture1, picture2.picture, i * picture2.ScaleWidth, 0)

  Next i

  DoEvents

  SavePicture picture1.Image, dest

End Sub

***************************************************************************

Making a column of several bitmaps is similar -  make another command

button, and replace the call to bmp_copy to read:

   Call bmp_copy(picture1, picture2.picture, 0 , i * picture2.ScaleHeight)

Note that you can first make several lines and then a column of them to

create a matrix.

Please use freely and enjoy!

  Yoav Assa

LISÄYS:

In the original post I wrote:

>'Create a form containing two picture controls with their scalemode

>'properties set to PIXEL, and a command button named MakeLine

Please add:

 Picture1 should have AutoSize set to False

 Picture2 should have AutoSize set to True

Sorry for forgetting it the first time,

  Yoav Assa


Bitmap PICCLIP

LUOKKA: graphics

Date: 07/19/94 (15:41)              Number: 12471 of 12479 (Refer# NONE)

From: DAEDULUS@ESKIMO.COM

Subj: Re: How to use PICCLIP control??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

HA> There MUST be a better way?!  I've been playing with PhotoPaint and a

HA> couple others to try to get all these graphic files lined up perfectly into a

HA> new  single BMP file, and it gives a whole new meaning to

HA> the word "tedious".

You don't have to use the picclip control. You can make a control array

of image controls and load one icon into each control.  In your code you

reference the image array in much the same way as the PicClip control:

    formMain.icon = imageIconArray(wFrameNo).picture

You wouldn't have to convert your icons to BMPs either. Of course, you

can get pretty good at positioning graphic squares in PaintBrush with a

little practice but its not for everyone.

-Erik Hermansen


Bitmap PICCLIP

LUOKKA: graphics

Date: 08/04/94 (19:20)              Number: 14394 of 14404 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: Smooth display of bitmaps (many in sequence)

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <31mve0$34u@info.curtin.edu.au> rlangbp@cc.curtin.edu.au

(Bradley Lang) writes:

>When each new picture is loaded the current pic flashes slightly before the

>nex pic is shown.

You might try using the picclip.vbx (comes with VB 3.0) if you don't have too

many images (or they aren't too big). I animated 16 images (200 x 200 pixel x

256 color) of the Jupiter comet impact and it worked fine (no flicker).


Bitmap smooth display

LUOKKA: graphics

Date: 08/03/94 (10:41)              Number: 14227 of 14279 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Smooth display of bitmaps (many in sequence)

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Bradley Lang (rlangbp@cc.curtin.edu.au) wrote:

: If BitBlt is the way to go, how do I read an image from disc into

: a device context in memory?

: Is there a simpler way? Stick a DoEvents somewhere?

I just logged on to take a break from bitblting in memory DCs to avoid

flickers.  There's an article on the MSDN CD if you have it.  Search on

"screen-flicker" or "flicker screen" or some such.

The first (easiest) thing you might try is just loading the bmp into an

invisible pic box, then bitblting across.  I don't think you need to mess

with the mem dcs unless your doing alot of drawing on top of the bmp and

want that to "pop" on instead of draw on.

The other thing to do is put a debug.print "in paint" line in the paint

event of your PB.  Under some circumstances, I was getting four paint

events on loading a bmp.  Even more if a resize was involved.

gt


Bitmap vs. ICO

LUOKKA: graphics

Date: 02-10-95    Time: 10:53a     Number: 76

From: cstuart@metronet.com          Refer:

  Subject: BMP .vs. ICO                      0: comp.lang.ba   Status: Public

>Anyone have an opinion as to the most "efficient" (read

>smallest resource hog) picture format to use when placing

>pictures on buttons or on menu bars?  Are .ICO files faster,

>cheaper, smaller, etc. than .BMP?  Are there other considerations?

Placing bitmaps in 3dpushbuttos and putting the buttons on image boxes is

the

best.


Bitmaps

LUOKKA: printing

Date: 05/14/94 (22:32)              Number: 6000 of 6068 (Refer# NONE)

From: XRYSTA@MCODE.AMDAHL.COM

Subj: Re: Printing Bitmaps

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I am enclosing a listing of a program that is reported to solve your problem.

I haven't used it myself but others have.

-------- Cut here -----------

Printbmp.BAS

'******************************************************************************

'*

'* File:          PrintBMP - Declarations

'* Created:       93.07.17

'* Author:        Magnus Hoglund, mho@t.hfb.se

'*

'* Description:   Contains all necessary declarations for PrintBMP

'*

'******************************************************************************

'

Type BITMAPFILEHEADER_Type

   bfType As Integer

   bfSize As Long

   bfReserved1 As Integer

   bfReserved2 As Integer

   bfOffBits As Long

End Type

Type BITMAPINFOHEADER_Type

    biSize As Long

    biWidth As Long

    biHeight As Long

    biPlanes As Integer

    biBitCount As Integer

    biCompression As Long

    biSizeImage As Long

    biXPelsPerMeter As Long

    biYPelsPerMeter As Long

    biClrUsed As Long

    biClrImportant As Long

End Type

Type BITMAPINFO_Type

    bmiColors As String * 1024

End Type

' File handling related API

Declare Function lopen Lib "Kernel" Alias "_lopen" (ByVal lpPathName As

String,

 ByVal iReadWrite As Integer) As Integer

Declare Function lclose Lib "Kernel" Alias "_lclose" (ByVal hFile As Integer)

As

 Integer

Declare Function hread Lib "Kernel" Alias "_hread" (ByVal hFile As Integer,

 ByVal pBuffer As Long, ByVal lBytes As Long) As Long

Declare Function llseek Lib "Kernel" Alias "_llseek" (ByVal hFile As Integer,

 ByVal lOffset As Long, ByVal iOrigin As Integer) As Long

' Memory allocation related API

Declare Function GlobalAlloc Lib "kernel" (ByVal wFlags, ByVal lMem&)

Declare Function GlobalLock Lib "kernel" (ByVal hMem) As Long

Declare Function GlobalUnlock Lib "kernel" (ByVal hMem)

Declare Function GlobalFree Lib "kernel" (ByVal hMem)

' Graphics related API

Declare Function StretchDIBits Lib "gdi" (ByVal hDC, ByVal DestX, ByVal

DestY,

 ByVal wDestWidth, ByVal wDestHeight, ByVal SrcX, ByVal SrcY, ByVal

wSrcWidth,

 ByVal wSrcHeight, ByVal lpBits&, BitsInfo As BITMAPINFO_Type, ByVal

wUsage,

 ByVal dwROP&)

' Constants used

Global Const OF_SHARE_EXCLUSIVE = &H10

Global Const GMEM_MOVEABLE = 2

Global Const SRCCOPY = &HCC0020

'******************************************************************************

'*

'* Procedure:     PrintBMP

'* Created:       93.07.17

'* Author:        Magnus Hoglund, mho@t.hfb.se

'*

'* Description:   Loads a bitmap and sends it to the printer.

'*

'******************************************************************************

Sub PrintBMP (Filename, X, Y, PicWidth, PicHeight)

Dim bmfHeader As BITMAPFILEHEADER_Type

Dim bmInfo As BITMAPINFO_Type

' First we check if the given filename exists.

If Dir$(Filename) <> "" Then

   SM_save = Printer.ScaleMode   'Save printers ScaleMode.

   ' Calculate the scales to give us pixels/cm.

   Printer.ScaleMode = 7

   PSX_cm = Printer.ScaleWidth

   PSY_cm = Printer.ScaleHeight

   Printer.ScaleMode = 3

   PSX_pixel = Printer.ScaleWidth

   PSY_pixel = Printer.ScaleHeight

   ScaleX = PSX_pixel / PSX_cm

   ScaleY = PSY_pixel / PSY_cm

   ' Convert parameters from cm to pixels.

   X = X * ScaleX

   Y = Y * ScaleY

   PicWidth = PicWidth * ScaleX

   PicHeight = PicHeight * ScaleY

   ' Open the bmp-file and get information about it.

   Open Filename For Binary Access Read As #1

   Get #1, , bmfHeader

   Get #1, , bmInfo

   Close #1

   ' Check if PicHeight or PicWidth is set to 0 and

   ' calculate new values for them if they are.

   PicHWRatio = bmInfo.BitmapInfoHeader.biWidth /

 bmInfo.BitmapInfoHeader.biHeight

   If PicWidth = 0 And PicHeight = 0 Then

      PicWidth = Printer.ScaleWidth

      PicHeight = Int(PicWidth / PicHWRatio)

   ElseIf PicWidth = 0 Then

      PicWidth = Int(PicHeight * PicHWRatio)

   ElseIf PicHeight = 0 Then

      PicHeight = Int(PicWidth / PicHWRatio)

   End If

   ' Now we're getting real close to the kernel ;-)

   ' Open file and move pointer to beginning of the bitmap data

   hFile = lopen(Filename, OF_SHARE_EXCLUSIVE)

   rc% = llseek(hFile, bmfHeader.bfOffBits, 0)

   'Calculate size and allocate memory for the bitmap data

   DibSize& = bmfHeader.bfSize - bmfHeader.bfOffBits

   hDib = GlobalAlloc(GMEM_MOVEABLE, DibSize&)

   pDib& = GlobalLock(hDib)

   ' Read the bitmap data into memory.

   BytesRead& = hread(hFile, pDib&, DibSize&)

   If BytesRead& <> DibSize& Then GoTo ReadErr ' Did we get all data?

   'Send the bitmap to the printer.

    r3 = StretchDIBits(Printer.hDC, X, Y, PicWidth, PicHeight, 0, 0,

 bmInfo.BitmapInfoHeader.biWidth, bmInfo.BitmapInfoHeader.biHeight,

pDib&,

 bmInfo, DIB_RGB_COLORS, SRCCOPY)

   'Clean up and exit

   Printer.ScaleMode = SM_save

   rc% = GlobalUnlock(hDib)

   rc% = GlobalFree(hDib)

   rc% = lclose(hFile)

Else

   ' The file does not exist

   MsgBox "File " & Filename & " does not exist.", 48, "PrintBMP Error"

End If

Exit Sub

ReadErr:

   rc% = GlobalUnlock(hDib)

   rc% = GlobalFree(hDib)

   MsgBox "hread failed", 48, "PrintBMP Error"

   rc% = lclose(hFile)

End Sub

-----------------------------------------------------------------------

Morris Myers     Standard Disclaimer

Email: xrysta@eng.amdahl.com or:   morris@xrysta.sbay.org


Bitmaps

LUOKKA: printing

Date: 12/02/94 (11:19)              Number: 28597 of 28627 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re: Printing bitmaps

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

GF>I am trying to print a bitmap. So I added a picture

GF>box control to my form (called it Picture1), put a (fairly large)

GF>bitmap there, and then, in order to print it I was using the

GF>following piece of code I got from MSDN article titled "How to print

GF>a VB Picture Control Using Windows API functions" :

GF>   Const SRCCOPY = &HCC0020

GF>   Const NEWFRAME = 1

GF>   Const PIXEL = 3

GF>      '* Display hour glass.

GF>      MousePointer = 11

GF>      Picture1.Picture = Picture1.Image

GF>      '* StretchBlt requires pixel coordinates.

GF>      Picture1.ScaleMode = PIXEL

GF>      Printer.ScaleMode = PIXEL

GF>      Printer.Print " "

GF>      hMemoryDC% = CreateCompatibleDC(Picture1.hDC)

GF>      hOldBitMap% = SelectObject(hMemoryDC%, Picture1.Picture)

GF>      ApiError% = BitBlt(Printer.hDC, 0, 0,

GF>   Picture1.ScaleWidth, Picture1.ScaleHeight,

GF>   hMemoryDC%, Picture1.ScaleLeft, Picture1.ScaleTop,

GF>   SRCCOPY)

GF>      hOldBitMap% = SelectObject(hMemoryDC%, hOldBitMap%)

GF>      ApiError% = DeleteDC(hMemoryDC%)

GF>      Result% = Escape(Printer.hDC, NEWFRAME, 0, 0&, 0&)

GF>      Printer.EndDoc

GF>      MousePointer = 1

GF>Now, everything is fine, except the picture comes out REAAALLLLYY

GF>small, you can hardly see it. Not like the original bitmap at all.

GF>Seems to be some sort of a problem with scaling....

GF>Any ideas?

Yes. Replace BitBlt() with StretchBlt() and then try it.

Regards,  Email: ian.carter@almac.co.uk

                 ian.carter@nildram.com

Ian C.    CIS: 100435,3040   Tel/Fax: (+44)(0)1909-773689


Bmp storing

LUOKKA: VBgen

1439 (34+)  ACP@mindlink.bc.ca  31.01.95  00:39

Jason Kaczor: "Re: Storing BMPs"

> : Hello- I'm a novice VB/Win 3.0 programmer and I have an application that

> : requires 20 or 30 bitmaps.  Embedding these bitmaps into forms makes a

> : prohibitively large executable, but the drawings are proprietary so I

> : can't include all the files and just have the drawings load at run-time.

> : I read somewhere that any number of bitmaps can be made into a DLL > >

:file. if so, how is this done?  I do have Borland C++/Win 3.1 if this must be

> : written in C.

Another method I have seen, and have used, is a "trick .DLL" method.

Basically you open the Bitmaps using binary I/O, and write them all

to a single file (Ie, at the begining of the file you would have a

header which would tell you the first bitmaps size, then after that

bitmap had been read, the next bitmap would be preceded with another

header, and so forth, until all your bitmaps are stored in the file).

Then at run-time, you would just do the opposite of the above, into

say a "temp" filename, and then use load picture.  Not necessarily

the best way, but it could be done (I believe credit for this one goes

to a VBPJ author at some point in history).

I myself use Borland's Resource Workshop to embed 'em into .DLLs

ttyl

Jason


Bmp vs. RLE

LUOKKA: graphics

Date: 09/20/94 (17:52)              Number: 20115 of 20148 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re: Best graphic format?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can use .RLE files in place of .BMP files.

RLE (Run Length Encoded) files are a form of compressed bitmap.

Depending on the complexity of the bitmap, you can get reductions in

size of 2:1 to 10:1 typically.

You will need to get yourself a graphics converter program to generate

the RLE files from BMP files.

Regards,     Email:   ian.carter@almac.co.uk

Ian C.       Tel/Fax: (+44)(0)1909-773689


Bmps and DB

LUOKKA: Access

11.How do I get a bitmap picture in a field in an Access database?

   See p.466 of the Visual Basic (3.0) Programmer's Guide. It contains

   a section called "Using Bound Picture Box and Image Controls".

   Basically you have to bind the VB PictureBox to a field in the

   Access DB, set the .Picture property in the PictureBox, and then

   move to the next record or something. VB will then store your

   picture in Access in a form in which it can be retrieved by VB in

   the future.

   If you store the pictures in Access directly (using Access), VB

   won't be able to read them (using VB 3.0 and Access 1.1).

   You can also store the picture's filename as a text field in the

   database and use LoadPicture() to load that file into the VB

   PictureBox.

    Tim Shea (shea@marcam.com)


Bmps etc.

LUOKKA: graphics

Date: 12/01/94 (15:08)              Number: 28546 of 28565 (Refer# NONE)

From: JOEO@ZIMMER.CSUFRESNO.EDU

Subj: Re: Loading Bitmaps for VB applications from a DLL

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

This program shows how to use bitmaps, cursors, and icons from a DLL

with VB.  This example assumes you have a DLL named "bitmaps.dll" with

bitmaps, cursors, and icons in it.  You can modify this program to use

the stock windows bitmaps and icons by using 0 as the hInstance in any

of the Load functions.

You need a form with a picture box and four command buttons.

Be careful to destroy the cursors and icons and close the library at

the right time.

Option Explicit

DefInt A-Z

Dim DLL, curhndl, icohndl, OldCur, OldIco, Ret

Declare Function BitBlt% Lib "GDI" (ByVal hDestDC%, ByVal X%, ByVal

  Y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

  YSrc%, ByVal dwRop&)

Declare Function CreateCompatibleDC% Lib "GDI" (ByVal hDC%)

Declare Function DeleteDC% Lib "GDI" (ByVal hDC%)

Declare Function DeleteObject% Lib "GDI" (ByVal hObject%)

Declare Function DestroyCursor% Lib "User" (ByVal hCursor%)

Declare Function DestroyIcon% Lib "User" (ByVal hIcon%)

Declare Function DrawIcon% Lib "User" (ByVal hDC%, ByVal X%, ByVal Y%,

  ByVal hIcon%)

Declare Sub FreeLibrary Lib "Kernel" (ByVal hLibModule%)

Declare Function LoadBitmap% Lib "User" (ByVal hInstance%, ByVal

  lpBitmapName As Any)

Declare Function LoadCursor% Lib "User" (ByVal hInstance%, ByVal

  lpCursorName As Any)

Declare Function LoadIcon% Lib "User" (ByVal hInstance%, ByVal

  lpIconName As Any)

Declare Function LoadLibrary% Lib "Kernel" (ByVal lpLibFileName$)

Declare Function SelectObject% Lib "GDI" (ByVal hDC%, ByVal hObject%)

Declare Function SetClassWord Lib "User" (ByVal hWnd%, ByVal nIndex%,

  ByVal wNewWord%)

Const GCW_HCURSOR = (-12)

Const GCW_HICON = (-14)

Const SRCCOPY = &HCC0020

Sub Cmd_Bitmap_Click ()

    Dim bmphndl, TempDC, hDCPrev

    bmphndl = LoadBitmap(DLL, "balloon")

    TempDC = CreateCompatibleDC(Picture1.hDC)

    hDCPrev = SelectObject(TempDC, bmphndl)

    Ret = BitBlt(Picture1.hDC, 0, 0, Picture1.Width, Picture1.Height,

TempDC, 0, 0, SRCCOPY)

    Ret = SelectObject(TempDC, hDCPrev)

    Ret = DeleteDC(TempDC)

    Ret = DeleteObject(bmphndl)

    Picture1.Refresh

End Sub

Sub Cmd_Chng_Icon_Click ()

    icohndl = LoadIcon(DLL, "arrow")

    OldIco = Form1.Icon

    Form1.Icon = LoadPicture("")

    Ret = SetClassWord(Form1.hWnd, GCW_HICON, icohndl)

End Sub

Sub Cmd_Cursor_Click ()

    curhndl = LoadCursor(DLL, "eraser")

    OldCur = SetClassWord(Form1.hWnd, GCW_HCURSOR, curhndl)

End Sub

Sub Cmd_Icon_Click ()

    icohndl = LoadIcon(DLL, "arrow")

    Ret = DrawIcon(Picture1.hDC, 0, 0, icohndl)

    Picture1.Refresh

End Sub

Sub Form_Load ()

    DLL = LoadLibrary("bitmaps.DLL")

End Sub

Sub Form_Unload (Cancel As Integer)

    If OldCur <> 0 Then Ret = SetClassWord(Form1.hWnd, GCW_HCURSOR,

     OldCur)

    If OldIco <> 0 Then Ret = SetClassWord(Form1.hWnd, GCW_HICON,

OldIco)

    If icohndl <> 0 Then Ret = DestroyIcon(icohndl)

    If curhndl <> 0 Then Ret = DestroyCursor(curhndl)

    FreeLibrary(DLL)

End Sub


Book multimedia

LUOKKA: VBgen

22034 (68+)  jtabor@ix.netcom.com  22.06.95  04:33

John Tabor: "Re: Q: MMSYSTEM.DLL Reference?"

In <jswanDAG3JD.Bvy@netcom.com> jswan@netcom.com (Jeff Swanson)

writes:

>The references I've been able to dig up on the MMSYSTEM.DLL API

>functions are pretty lax -- even the "Visual Basic Programmer's_

>Guide to the Windows API" has only a few pages on it, and a couple

>of files on the disk that are of limited help.

>

>Is there a full guide to ALL the functions and parameters and

>etc. of this .DLL available anywhere?

I'm not sure if it is as extensive as you want it to be, but I've found

an excellent VB multimedia "manual".

"Visual basic Multimedia Adventure Set"

Scott Jarol

1994, The Coriolis Group

ISBN: 1-883577-01-2

US$39.95

What you get:

*   Companion CD-ROM

*   Video for Windows Developer's Kit

*   Microsoft's Wave Mixer

*   Complete VB Hypermedia Engine (code included)

*   Interactive hotspot editor (code included)

*   VB MIDI piano

*   Winjammer MIDI sequencer

*   Custom controls for animation, sound and VB programming

*   Video clips, sound files and music

It's actually pretty good and describes most of the MMSYSTEM.DLL's

functions.

To show how versatile VB really is, I just found out today that Best

Buy's (the warehouse store) multimedia information kiosks were

developed internally using VB.  Impressive, IMHO.

John


Book multimedia

LUOKKA: VBgen

Date: 02-16-95    Time: 01:57p     Number: 50

     From: iowajeff@ins.infonet.net      Refer:

  Subject: VB Multimedia Adventure S         0: comp.lang.ba   Status: Public

Well I can HIGHLY recommend the following book:

'Visual Basic Multimedia Adventure Set' by Scott Jarol.  It is published by

Coriolis Group Book (ISBN # 1-883577-01-2).  Distributed by IDG Books.

Price: $39.95 Includes a CD-ROM disc *FULL* of examples, commerical

demos,

Royalty free music, etc. I got my copy at Walden Books at my local Mall.

Why do I recommend this?

Because it give Visual Basic the commands (via API calls) to do all those

neatthings you've always wanted to do, without the need to go out & buy the

Pro-Edition or expensive add-on VBX libraries.  You can play .WAV files,

MIDI files, Video For Windows animations. You can do live video capture,

color palette cycling anims, hyper-text apps, do digital special effects,

disolves, etc. Real time audio effects are possible as is better animation with

flicker free sprites. It has examples of controling hardware such as your  CD

(comes with SmartCD Player example code to take advantage of the MCI

commands.)  And it gives you ideas on creating databases and tying in

Access as well.  The only question I have is on the MCI commands. I think

the VBPro edition comes with a MCI Control where the Standard edition does

not. I use Standard, and I seem to recall I can get the MCI commands to

work ok strickly using API calls as outlined in the book.

Overall the book and examples are easy to use. It has pleanty of good

pictures and illustrations and is easy to understand the theory behind all the

neat new features it is teaching you.  Also you are free to sell or distribute

any programs you make using the code examples.  Until I got this book I thot

VB was a kinda brain-dead, slow data-base only app. Now I know I can really

use it to make neat multimedia projects, games and the like!

Hope this mini-book review helps someone else struggling with VB and

multimedia and/or game programming projects.


Books

LUOKKA: VBgen

Appendix for FAQ POST #1

      ========================

      BOOK LIST for VB/Win

      ========================

      ---From: ian@monty.demon.co.uk (Ian Piper)

          Here, in descending order of usefulness (in my own personal

          opinion) are the VB books I use the most:

          1. Visual Basic Programmers guide to the Windows API, by

          Daniel Appleman. ISBN1-56276-073-4. If you only want to get

          one book on VB, this is the one. It covers the ground from

          simple to advanced programming very well.

          2. The Waite Group's VB How-To, several authors, ISBN

          1-878739-09-3. This is the ISBN number for version 1 - I

          think it's been updated by now. Lots of examples to

          demonstrate each point. This is a close second.

          3. Visual Basic Utilities, by Paul Bonner, ISBN

          1-56276-106-4. This has some excellent learning stuff in it

          and also some advanced stuff, including how to write your own

          DLLs (!) using GFA-BASIC.

          4. Fun programming with VB, several authors, ISBN

          1-56529-106-9. This uses a half-dozen or so projects to

          illustrate how various programmers designed and built apps

          using VB.

          5. Windows 3.1 programming for mere mortals, by Woody

          Leonhard, ISBN 0-201-60832-4. This covers VB and WordBasic.

          Some very neat examples.

      ---From: tivadar@interaccess.com (John Quarto-vonTivadar)

          I found the following VERY useful, to the point that I don't

          even use the manuals anymore:

          6. The Visual Guide to Visual Basic for Windows, by Richard

          Mansfield, published by Ventura Press. This is a encyclopedia

          of the language itself. It supposes that you DO know how to

          program so basically (if you pardon the pun) it's a guide to

          VB's slang. I use this for referencing the grammar when i get

          a bug.

      ---From: idavidson@csu.edu.au (Ian Davidson)

          7. Visual Basic How-To, Robert Arnson, Daniel Rosen, Mitch

          Waite &  Jonathon Zuck: The Waite Group, 1992.  ISBN

          1-878739-09-3.  Includes  disk.  Many practical examples &

          some sample custom controls.Introduces & expands on the use

          of API's.  An excellent book suitable for Beginners thru

          Advanced - one of my most-often-used  references.

          8. Learn Programming and Visual Basic with John Socha, John

          Socha:  Sybex, 1992.  ISBN 0-7821-1057-6.  Includes disk.  A

          useful introduction for absolute beginner programmers thru

          intermediate.

      -- From Gary Cornell:

          There's a new version of my book - it's been enlarged and

          updated. It's now called the Visual Basic 3 For Windows

          Handbook.

              Author   : Cornell, Gary

              Title    : Visual Basic 3 For Windows Handbook

              ISBN     : 0078819318 Dewey #  : 005.10

              Publisher: Osborne McGraw Hill

              Date Pub : 01/93

      --from Wallace Wang: 72662,1711 (Compuserve)

          Here's the information you requested. Thanks for including my

          book in your listing:

          Publisher name: IDG Books Publisher

          address: 155 Bovet Road, Suite 310

                   San Mateo, CA 94402

          Phone number: (415) 312-0650

          Fax number: (415) 358-1260

          Book name: Visual Basic 3 For Dummies

          Author name: Wallace Wang

          When released: March 1994

          50-word description: This book takes readers,

               step-by-step, to understanding, learning, and writing

               Visual Basic programs. Explains how to use the most

               common features of Visual Basic for creating user

               interfaces and writing BASIC code. Includes a friendly

               dose of humor and easy to read explanations, this book

               also includes suggestions for finding additional

               information about Visual Basic. Intended audience:

          Beginners Price: $19.95

          Disk of examples: No.

      ---From Christian Wolkersdorfer

          Here are several German specific books for VB. They are from

          a database query of the ELIS-database Erlangen / Nuernberg /

          Germany.

Autor            : Craig, John C.

Titel            : The Microsoft Visual Basic workshop

Schlagwort       : VisualBASIC

Impressum        : Redmond Microsoft Press 1991

ISBN/ISSN        : ISBN 1-55615-386-4

Kollationsvermerk: XIV, 302 S. : graph. Darst. 1 Diskette

zus. Verf.       : John Clark Craig

--------

      ---From EDITOR:

          The following books were those I found using a keyword

          search of 'VISUAL' at the internet site BOOKS.COM. This

          site can be used to purchase books via credit card or

          you can use their database of books to find information

          as I have done.

          Author   : Nelson, Ross

          Title    : The Microsoft VB for Windows Primer

          ISBN     : 1556154771          Dewey #  : 005.10

          Publisher: Microsoft Pr        Date Pub : 11/92

          Author   : Orvis, William

          Title    : Do It Yourself Visual Basic for Windows

          ISBN     : 0672302594          Dewey #  : 005.10

          Publisher: Sams          Date Pub : 11/92

          Author   : Craig, John Clark

          Title    : Microsoft VB Workshop/Book and Disk

          ISBN     : 1556153864          Dewey #  :   5.26

          Publisher: Microsoft Pr        Date Pub : 09/91

          Author   : Murray, William H./Pappas, Chris H.

          Title    : Using VB : Writing Windows Apps

          ISBN     : 0201581450          Dewey #  :   5.43

          Publisher: Addison Wesley Pub. Co.

          Date Pub : 01/92


Bugs

LUOKKA: Outline

Date: 08/18/94 (00:58)              Number: 16050 of 16174 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Outline Crashes @ 1280x10

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 08-16-94 JBURNES@CRL.COM  wrote:

J>Has anyone tried to design a form with an outline control using a

J>video  resolution of 1280x1024??  I have seen several controls that

J>blow up at  this resolution and I don't know why.  Maybe its the video

J>driver  itself.  We are using the Viper and I've heard comments in

J>magazine that  Diamonds drivers are sometimes buggy.

The outline control is not one of MS' best.  Try using it in an

environment with color depth > 8-bit and you'll get "Out of memory"

error messages.  It doesn't surprise me that high res does it as well.

Not to mention that the drivers you mention have a bad rep.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                                m_rubin@tatertot.com


Byte & bit

LUOKKA: VBgen

Date: 10/20/94 (12:37)              Number: 23699 of 23771 (Refer# NONE)

From: IJOHNSON@METZ.UNE.EDU.AU

Subj: bit-coded integers

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I am trying to look at bit-coded integers, bit by bit.  The only way

I have managed to do it is as follows.

  if x and y = y

by setting y to the decimal eqivalent of the binary number with the bit

I'm interested in will work.  eg, y = 8 is equivalent to 1000 in binary.

This seems very clumsy and I suspect there are better ways.  Any help

will be much appreciated.

ijohnson@metz.une.edu.au


Byte & hex

LUOKKA: VBgen

Date: 10/03/94 (13:36)              Number: 21559 of 21728 (Refer# NONE)

From: RGELB@CSULB.EDU

Subj: Re: need single byte manipulation routines

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: i need to manipulate single BYTEs of raw hex data and perform bitmasks.

 Just use the AND & OR operators provided with basic.

 x = x AND 128  'checks the first bit from the left


Byte & hex

LUOKKA: VBgen

Date: 10/04/94 (00:57)              Number: 21659 of 21728 (Refer# NONE)

From: HARRISMA@TEXACO.COM

Subj: Re: need single byte manipulation routines

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

i_bit = 1 'search of bit 1

l_stat_wd = Val(pc_alarms)'convert string to long

....

'Find value of bit at position i_bit

'i_target_bit will be 1 or 0

i_target_bit = Int(Int(l_stat_wd) / 2 ^ i_bit) And Int(1)

********************

Function chg_to_binary (pc_raw As String, pc_bin As String)

    Dim i As Long, x As Long, bin As String

    Const maxpower = 30   ' Maximum number of binary digits supported.

    x = Val(pc_raw) 'Convert decimal string in text1 to long integer

    If x < 0 Then bin = bin + "1" Else bin = bin + "0"

    For i = maxpower To 0 Step -1

        If x And (2 ^ i) Then   ' Use the logical "AND" operator.

            bin = bin + "1"

        Else

            bin = bin + "0"

        End If

    Next

    pc_bin = bin   ' The bin string contains the binary number.

End Function


Byte & hex

LUOKKA: VBgen

Date: 10/11/94 (01:08)              Number: 22546 of 22612 (Refer# NONE)

From: JHUMMEL@ICS.UCI.EDU

Subj: Re: Bitwise operators in VBWin

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

James Sally <james@seas.gwu.edu> wrote:

>In a project I have just started, I need to extract values from an 8bit

>integer value, (ie., the first 4 bits, and the second 4 bits).  This is

>because each of these quantities are a certain value from the file format

>that I'm reading in.

VB's bitwise operators are And and Or, and these will work given the

proper "mask" value.  Suppose you had a VB integer X (which is 16-bits),

and you want the 4 least-significant bits.  The following will give you

those 4 bits in Y:

       Dim x as integer, y as integer

       ...

       y = x And 15

Suppose you want bits 4 .. 7, then do:

       y = x And 240

Notice that 240 is 2^4 + 2^5 + 2^6 + 2^7.

--

Joe Hummel

ICS Graduate Student, UC Irvine

Internet: jhummel@ics.uci.edu


ByVal

LUOKKA: API

Date: 02-09-95    Time: 09:58p     Number: 157

From: Dg@nbbs.demon.co.uk           Refer:

Subject: All ByVal users READ This         0: comp.lang.ba   Status: Public

There are a number of hazards that we all face when we call the Windows

API from any language and VB is certainly no exception. This article attempts

to point out some of the more troubling problems that the VB programmer is

likely to encounter. Much of the content of this article can also be gleaned

from chapter 24 of the VB3 Programmer's Guide, but it seems that many

programmers

are still confused on the subject, so a slightly more detailed look might be

useful..

Let the ByVal'er Beware:

The manual is fairly clear on the subject of the use of ByVal, but it is a

modifier which will continues to trip up the unwary. For the record, the main

rules are as follows...

Applied to non-string variables, ByVal will cause the value of the variable to

be passed, rather than a long pointer to the memory area containing the

value

Applied to string variables, ByVal will cause the VB runtime to pass the

address of a  null-terminated (C-style) string. Without the ByVal, VB will pass

the handle of the VB string.

A DLL written specifically to support calls from VB might possibly support

passing of VB strings without the ByVal keyword, but IN ALL OTHER CASES,

VB strings should be passed ByVal.

User-defined types cannot be passed ByVal, they must always be passed by

reference (that is, by address). In fact, user-defined types are the only data

types which are routinely passed to the API without the ByVal keyword.

In almost all cases, numeric values such as integers and longs will be passed

ByVal and, of course, user-defined types will be passed by reference, there

being no choice in the matter.

By now, many will be wondering what concern it is of the programmer whether

an API argument is passed ByVal or not. After all, the Win 3.1 API help file

and WIN30API.TXT and WIN31EXT.TXT all provide declarations for most of

the Windows API functions, so surely the VB programmer need not bother

with such low-level concerns. This is true enough in most cases, but by no

means all. To

find out why, read on.

Any" Just Cause

While most of the standard, off-the-shelf API declarations provided in the box

with VB will do the job just fine without much real attention from the VB

programmer, there exist a significant number of exceptions. These exceptions

are those which declare one or more arguments As Any.

The Any data type was created in order to allow calls to API functions which

can accept references to a number of different types of data in one catch-all

argument reference. The upshot of this is that the VB programmer must

always be alert to the possibility that a declaration might use the Any

keyword, so as to provide the correct call syntax.

To take the simplest (and by far the most common) case of this, a number of

functions have been designed to accept a long pointer to a string (LPSTR, or

ByVal String), except where the argument is not required, in which case a

null pointer should be passed. For example, the GetProfileString function can

accept an optional lpKeyName argument. If lpKeyName is provided, only the

value for

the specified entry is returned. If it is a null pointer, a list of all keys is

returned, delimited by the null character (Chr$(0)).

To allow for this functionality in a single declaration, the VB architects

fastened upon the Any data type, declaring GetProfileString as follows...

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String,

lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As

String, ByVal nSize As Integer) As Integer

You will note that lpKeyName is declared As Any.

What this means to the programmer is that in calling GetProfileString (and

many other functions), the ByVal has to be explicitly provided in the function

call. For example...

RetVal% = GetProfileString("windows", "spooler", "Bog off", Result$,

Len(Result$)) ' Wrong!... will return the rather snotty default string "Bog off",

rather than "yes" or "no". This is because the API function never sees the

string "spooler", instead it sees the handle to the VB string, which it treats as

a string pointer to alphabet soup.

Instead of the above, we require the function call in this form...

RetVal% = GetProfileString("windows", ByVal "spooler", "Bog off", Result$,

Len(Result$)) ' Right!

In this case, the ByVal refers to a string value, which converts our string to a

long pointer to a C-style null-terminated string. This frequently causes

programmers to conclude that the API declaration is wrong and to "fix" it by

replacing the As Any with a type declaration compatible with their immediate

requirements.

Alternatively, in the case where we wish to return all keys in the [windows]

section, we would call thus...

RetVal% = GetProfileString("windows", ByVal 0&, "Bog off", Result$,

Len(Result$)) ' Right!

Note that we have been forced to specify the ByVal in the function call and,

further, to declare the type of the numeric value we are passing. If we leave

off the ampersand type character we will get a "Bad DLL calling convention"

error, number 49. This is because Any doesn't really mean any old Any, but

specifically a 4-byte Any. Of course, if we were passing a numeric variable

instead of a constant, the ampersand would not be necessary, so long as the

variable was declared Long.

An alternative to use of the Any keyword might be to provide multiple

declarations for functions which support multiple data types. For example, we

could declare GetProfileString twice, as follows...

Declare Function GetProfileSection Lib "Kernel" Alias "GetProfileString"

(ByVal lpAppName As String, ByVal lpKeyName As Long, ByVal lpDefault As

String, ByVal lpReturnedString As String, ByVal nSize As Integer) As Integer

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String,

ByVal lpKeyName As String, ByVal lpDefault As String, ByVal

lpReturnedString As String, ByVal nSize As Integer) As Integer

The above declarations would give us all of the flexibility of the Any

declaration with none of the headaches. To retrieve all key names in a

section, we'd call GetProfileSection, passing zero for the lpKeyName

argument, and to retrieve the value of a specific section, we'd call

GetProfileString with the section name. In neither case would we need to

specify the ByVal statement.

Unfortunately, this workaround is also far from perfect. For one thing, the VB

programmer needs to be aware that there are now two separate declarations

for this function, among many others, invalidating much of the standard SDK

documentation. For another thing, there are some noteable cases where the

data being passed can be quite literally any data type. Take for example

those

ubiquitous catch-all functions SendMessage and PostMessage

What does it all mean

Put simply, VB programmers calling API functions must be sure to read any

declarations before coding the calling statements, to check if the occasional

ByVal may be required. It is not enough simply to cut and paste function

declarations and then call by rote, because Any demands that you think

before you call. If an API call fails to perform as expected, you should

immediately suspect that you have left out a ByVal in the function call.

As a further caution, it is always a good idea to ensure that you save your

project before running it if you have made any changes to API function

declarations or added or modified any calling statements. If you disregard this

advice, you stand to lose all program modifications since your last project

save when the VB design environment aborts with a GPF. This is a very good

time to

consider the "Save project before run" environment option.

Reservations required

One final warning. Many API functions require the caller to provide the

address of a memory buffer to be used to return data. For the VB programmer,

this usually means passing a string ByVal (although the ByVal may be already

provided in the function declaration).

The thing to watch in these cases is that the string is pre-initialised to a

sufficient size to accept the maximum amount of data that may be returned,

or General Protection Faults will result.

To allocate space to a string, you may either dimension it as a fixed length

string or use a simple assignment statement, such as...

MyBuf$ = Space$(MaxSize%)

Contributed by Luke Webber. Internet webber@werple.mira.net.au

Copyright 1995 Luke Webber Consulting Services; ALL RIGHTS RESERVED

--

[ Name : Daniel Grealy              ]

[ Email: dg@nbbs.demon.co.uk        ]


ByVal

LUOKKA: VBgen

---------------------------------------------------------------

Daniel Grealy: "All ByVal users READ This"

----------------------------------------------------------------

There are a number of hazards that we all face when we call the Windows

API from any language and  VB is certainly no exception. This article

attempts to point out some of the more troubling problems that the VB

programmer is likely to encounter. Much of the content of this article can

also be gleaned from chapter 24 of the VB3 Programmer's Guide, but it seems

that many programmers are still confused on the subject, so a slightly more

detailed look might be useful..

Let the ByVal'er Beware:

The manual is fairly clear on the subject of the use of ByVal, but it is a

modifier which will continues to trip up the unwary. For the record, the main

rules are as follows...

Applied to non-string variables, ByVal will cause the value of the variable to

be passed, rather than a long pointer to the memory area

containing the value

Applied to string variables, ByVal will cause the VB runtime to pass the

address of a null-terminated (C-style) string. Without the ByVal, VB will pass

the handle of the VB string.

A DLL written specifically to support calls from VB might possibly support

passing of VB strings without the ByVal keyword, but IN ALL OTHER CASES,

VB strings should be passed ByVal.

User-defined types cannot be passed ByVal, they must always be passed by

reference (that is, by address). In fact, user-defined types are the only data

types which are routinely passed to the API without the ByVal keyword.

In almost all cases, numeric values such as integers and longs will be passed

ByVal and, of course, user-defined types will be passed by reference, there

being no choice in the matter.

By now, many will be wondering what concern it is of the programmer whether

an API argument is passed ByVal or not. After all, the Win 3.1 API help file

and WIN30API.TXT and WIN31EXT.TXT all provide declarations for most of

the Windows API functions, so surely the VB programmer need not bother

with such low-level concerns. This is true enough in most cases, but by no

means all. To find out why, read on.

Any" Just Cause

While most of the standard, off-the-shelf API declarations provided in the box

with VB will do the job just fine without much real attention from the VB

programmer, there exist a significant number of exceptions. These exceptions

are those which declare one or more arguments As Any.

The Any data type was created in order to allow calls to API functions which

can accept references to a number of different types of data in one catch-all

argument reference. The upshot of this is that the VB programmer must

always be alert to the possibility that a declaration might use the Any

keyword, so as to provide the correct call syntax.

To take the simplest (and by far the most common) case of this, a number of

functions have been designed to accept a long pointer to a string (LPSTR, or

ByVal String), except where the argument is not required, in which case a

null pointer should be passed. For example, the GetProfileString function can

accept an optional lpKeyName argument. If lpKeyName is provided, only the

value for the specified entry is returned. If it is a null pointer, a list of all keys

is returned, delimited by the null character (Chr$(0)).

To allow for this functionality in a single declaration, the VB architects

fastened upon the Any data type, declaring GetProfileString as follows...

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String,

lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As

String, ByVal nSize As Integer) As Integer

You will note that lpKeyName is declared As Any.

What this means to the programmer is that in calling GetProfileString (and

many other functions),

the ByVal has to be explicitly provided in the function call. For example...

RetVal% = GetProfileString("windows", "spooler", "Bog off", Result$,

Len(Result$)) ' Wrong!... will return the rather snotty default string "Bog off",

rather than "yes" or "no". This is because the API function never sees the

string "spooler", instead it sees the handle to the VB string, which it

treats as a string pointer to alphabet soup.

Instead of the above, we require the function call in this form...

RetVal% = GetProfileString("windows", ByVal "spooler", "Bog off", Result$,

Len(Result$)) ' Right!

In this case, the ByVal refers to a string value, which converts our string to a

long pointer to a C-style null-terminated string. This frequently causes

programmers to conclude that the API declaration is wrong and to "fix" it by

replacing the As Any with a type declaration compatible with their immediate

requirements.

Alternatively, in the case where we wish to return all keys in the Žwindows�

section, we would call thus...

RetVal% = GetProfileString("windows", ByVal 0&, "Bog off", Result$,

Len(Result$)) ' Right!

Note that we have been forced to specify the ByVal in the function call and,

further, to declare the type of the numeric value we are passing. If we leave

off the ampersand type character we will get a "Bad DLL calling convention"

error, number 49. This is because Any doesn't really mean any old Any, but

specifically a 4-byte Any. Of course, if we were passing a numeric variable

instead of a constant, the ampersand would not be necessary, so long as the

variable was declared Long.

An alternative to use of the Any keyword might be to provide multiple

declarations for functions which support multiple data types. For example, we

could declare GetProfileString twice, as follows...

Declare Function GetProfileSection Lib "Kernel" Alias "GetProfileString"

(ByVal lpAppName As String, ByVal lpKeyName As Long, ByVal lpDefault As

String, ByVal lpReturnedString As String, ByVal nSize As Integer) As Integer

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String,

ByVal lpKeyName As String, ByVal lpDefault As String, ByVal pReturnedString

As String, ByVal nSize As Integer) As Integer

The above declarations would give us all of the flexibility of the Any

declaration with none of the headaches. To retrieve all key names in a

section, we'd call GetProfileSection, passing zero for the lpKeyName

argument, and to retrieve the value of a specific section, we'd call

GetProfileString with the section name. In neither case would we need to

specify the ByVal statement.

Unfortunately, this workaround is also far from perfect. For one thing, the VB

programmer needs to be aware that there are now two separate declarations

for this function, among many others, invalidating much of the standard SDK

documentation. For another thing, there are some noteable cases where the

data being passed can be quite literally any data type. Take for example

those ubiquitous catch-all functions SendMessage and PostMessage

What does it all mean

Put simply, VB programmers calling API functions must be sure to read any

declarations before coding the calling statements, to check if the occasional

ByVal may be required. It is not enough simply to cut and paste function

declarations and then call by rote, because Any demands that you think

before you call. If an API call fails to perform as expected, you should

immediately suspect that you have left out a ByVal in the function call.

As a further caution, it is always a good idea to ensure that you save your

project before running it if you have made any changes to API function

declarations or added or modified any calling statements. If you disregard this

advice, you stand to lose all program modifications since your last project

save when the VB design environment aborts with a GPF. This is a very good

time to consider the "Save project before run" environment option.

Reservations required

One final warning. Many API functions require the caller to provide the

address of a memory buffer to be used to return data. For the VB programmer,

this usually means passing a string ByVal (although the ByVal may be already

provided in the function declaration).

The thing to watch in these cases is that the string is pre-initialised to a

sufficient size to accept the maximum amount of data that may be returned,

or General Protection Faults will result.

To allocate space to a string, you may either dimension it as a fixed length

string or use a simple assignment statement, such as...

MyBuf$ = Space$(MaxSize%)

Contributed by Luke Webber. Internet webber@werple.mira.net.au

Copyright 1995 Luke Webber Consulting Services; ALL RIGHTS RESERVED

--

Ž Name : Daniel Grealy              �

Ž Email: dg@nbbs.demon.co.uk        �


Caller-ID

LUOKKA: VBgen

Date: 03-27-95 (20:08)              Number: 272930 of 277779 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Caller-ID

I have an application I wrote for my personal use which picks up the

caller-id info from my Supra 14.4 modem and looks up the number in my

database.  It's basically a PIM like program.

The command on Supra modems to enable caller-id feedback is 'AT#CID=1'.

This will cause my modem to send information like the following through the

serial port:

  RING

  DATE = 1205

  TIME = 1301

  NMBR = 3142345678

  NAME = SWBT

  RING

Notice that the information gets sent between the first and second rings.

Basically, all you need to have to do this is a Caller-ID capable device

(like my Supra modem) and use the MSCOMM.VBX.  For the MSCOMM.VBX, I

look for the caller-id information when a "ring" event occurs.  In the

OnComm event you might have something like this:

Select Case comm.CommEvent

    Case MSCOMM_EV_RING ' Change in the Ring Indicator.

        LV_Ring_Elapsed_Time = MhReadTimer&(0)   'this requires MH Muscle

        If LV_Ring_Elapsed_Time > 125 Then 'new call

            MV_Ring_Number = 1

            LV_Receive_Buff = ""

        Else

            MV_Ring_Number = MV_Ring_Number + 1

        End If

        Call MhStartTimer(0)

        .

    Case MSCOMM_EV_RECEIVE  ' Received RThreshold # of chars.

        LV_Ring_Elapsed_Time = MhReadTimer&(0)

        If LV_Ring_Elapsed_Time > 125 Then

        'no rings for a while, so this is not a call (could be due to dialing

        'out), set MV_Ring_Number = 0

            LV_Receive_Buff = ""

            MV_Ring_Number = 0

        End If

        ' Retrieve all available data.

        comm.InputLen = 0

        ' Check for data.

        If comm.InBufferCount Then

            ' Read data.

            LV_Receive_String = comm.Input

            LV_Receive_Buff = LV_Receive_Buff + LV_Receive_String

            If MV_Ring_Number >= 1 Then

            'check for caller id info after first ring

                If InStr(1, LV_Receive_Buff, "NMBR =") <> 0 Then

                'get caller id info

                    If InStr(1, LV_Receive_Buff, "NMBR =") <> 0 Then

                    'get caller id info

                        LV_Number_Pos = InStr(1,LV_Receive_Buff, "NMBR =")+7

                        If InStr(1, LV_Receive_Buff, "NMBR = O") <> 0 Then

                        'no caller-id info picked up, so show "unknown" caller

                            MV_CID_Number = "0000000000"

                            LV_MESG_Pos = InStr(1, LV_Receive_Buff, "MESG =")

                    If LV_MESG_Pos <> 0 Then 'check value

                                LV_TempMid$(LV_Receive_Buff,LV_MESG_Pos+7,6)

                                If LV_Temp = "08014F" Then 'Out of Area

                                    LBL_CallerID_Num_Name = "Out of area"

                                Else

                                    LBL_CallerID_Num_Name = "MESG = " + LV_Temp

                                End If

                            End If

                        ElseIf LV_Number_Pos + 9 > Len(LV_Receive_Buff) Then

                        'not all of the caller id info has been received yet,

                        'so don't get it

                            exit sub

                        Else 'normal caller-id info

MV_CID_Number=Mid$(LV_Receive_Buff,LV_Number_Pos,10)

                         LBL_CallerID_Num_Name = MV_CID_Number

                         LV_Name_Pos = InStr(1, LV_Receive_Buff, "NAME =")

                         If LV_Name_Pos <> 0 Then 'check value

LV_End_Pos=InStr(LV_Name_Pos+7,LV_Receive_Buff,chr$(1

3))

                          If LV_End_Pos <> 0 Then

                           LV_Temp = Trim$(Mid$(LV_Receive_Buff, LV_Name_Pos

+

7, LV_End_Pos - LV_Name_Pos - 7))

                           If LV_Temp = "NAME UNAVAILABL" Then

                           'name not available

                           else 'normal name found

                           .

Notes:  I have both Caller-ID name and number.  I am using the Microhelp

Muscle timer to determine if a ring is a new call or another ring of the same

call.  You might not even need to do this.  The format of the caller-id

information might be different for other modems.  I know my Supra can also

display the caller-id info in a hex format.

  Brian

bl7385@isoa.sbc.com


Capital. firstname

LUOKKA: VBgen

Date: 06-21-95 (00:12)              Number: 368528 of 370426 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Capitalizing firstnam

From: owner-visbas-l

To: Multiple recipients of list VISBAS-L

Subject: Capitalizing firstname

Date: Tuesday, June 20, 1995 9:15AM

I am making a program where a person enters in their information.  What I am

trying to do is make it so that once they enter in their firstname, the

first letter automatically is capitalized.  If they have two different words

in the text box, both words are capitalized.  Could someone please help me

with this?  thanx!

------------------------------------------------------------

This is some sample code from a Microsoft KB article Q109220.  You will not

be able to place this in the Change event.  If your control is bound to a

data control you will have to use two controls.  One hidden and bound - the

other visible and not bound.  The user will type in the unbound control, it

will be modified in the LostFocus, then have it write to the bound control.

Good luck.

MLJOY

   Sub Text1_LostFocus ()

      Dim t As String

      t = Text1.Text  ' Put contents of text box into a string variable.

      If t <> "" Then

         Mid$(t, 1, 1) = UCase$(Mid$(t, 1, 1))

         For i = 1 To Len(t) - 1

            If Mid$(t, i, 2) = Chr$(13) + Chr$(10) Then

               ' Capitalize words preceded by carriage return plus

               ' linefeed combination. This only applies when the

               ' text box's MultiLine property is set to True:

               Mid$(t, i + 2, 1) = UCase$(Mid$(t, i + 2, 1))

            End If

            If Mid$(t, i, 1) = " " Then

               ' Capitalize words preceded by a space:

               Mid$(t, i + 1, 1) = UCase$(Mid$(t, i + 1, 1))

            End If

         Next

         Text1.Text = t

      End If

   End Sub

 ----------

 - Adam


Caption bar small

LUOKKA: API

Date: 05/31/94 (20:25)              Number: 7530 of 7791 (Refer# NONE)

From: RAMI.RASANEN@P1.F73.N369.Z1.FIDONET.ORG

Subj: sample SMALLCAP

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here's the example code of "how to make a small msgbox or form

caption bar on top using msgblast.vbx"

'smallcap.mak

SMALLCAP.FRM

SMALLCAP.BAS

C: WINDOWS SYSTEM MSGBLAST.VBX

ProjWinSize=240,401,396,215

ProjWinShow=2

IconForm="frmMain"

Title="MemMan"

ExeName="SMALLCAP.EXE"

'Path="enter your path here"

'smallcap.bas

Type RECT

  left As Integer

  top As Integer

  right As Integer

  bottom As Integer

End Type

'smallcap.frm

VERSION 2.00

Begin Form frmMain

   BorderStyle     =   1  'Fixed Single

   ClientHeight    =   1212

   ClientLeft      =   1308

   ClientTop       =   2472

   ClientWidth     =   2520

   ClipControls    =   0   'False

   ControlBox      =   0   'False

   Height          =   1608

   Icon            =   0

   KeyPreview      =   -1  'True

   Left            =   1272

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   1212

   ScaleWidth      =   2520

   Top             =   2112

   Width           =   2592

   Begin MsgBlaster MsgBlaster1

      Prop8           =   "Click on ""..."" for the About Box ---->"

   End

End

Const COLOR_ACTIVECAPTION = 2

Const COLOR_INACTIVECAPTION = 3

Declare Function GetSysColor Lib "User" (ByVal nIndex As Integer) As Long

Declare Function CreatePopupMenu Lib "User" () As Integer

Declare Function AppendMenu Lib "User" (ByVal hMenu As Integer, ByVal

wFlags

As

Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As Any) As Integer

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg As

Integer, ByVal wParam As Integer, lParam As Any) As Long

Declare Function TrackPopupMenu Lib "User" (ByVal hMenu As Integer,

ByVal

wFlags As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nReserved

As

Integer, ByVal hWnd As Integer, lpReserved As Any) As Integer

Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

Integer

'Virtual Key values

Const VK_ESCAPE = &H1B

'System Metrics Constants

Const SM_CYMENU = 15

'SysCommand, wParam values

Const SC_MOVE = &HF010

Const SC_CLOSE = &HF060

'Menu Function values

Const MF_SEPARATOR = &H800

Const MF_ENABLED = 0

Const MF_STRING = 0

Const MF_BYPOSITION = 400

'Menu ID's

Const IDM_SYSMOVE = 101

Const IDM_SYSCLOSE = 102

Const IDM_ABOUT = 103

'Window's messages

Const WM_NCHITTEST = &H84

Const WM_NCACTIVATE = &H86

Const WM_CLOSE = &H10

Const WM_NCLBUTTONDBLCLK = &HA3

Const WM_NCLBUTTONDOWN = &HA1

Const WM_COMMAND = &H111

Const WM_SYSCOMMAND = &H112

Const WM_EXITMENULOOP = &H212

'MsgBlaster property values

Const PREPROCESS = -1

Const EATMESSAGE = 0

Const POSTPROCESS = 1

'WM_NCHITTEST return values

Const HTCLIENT = 1

Const HTCAPTION = 2

Const HTSYSMENU = 3

Dim FormTop%

Dim FormLeft%

Dim xPos%

Dim yPos%

Dim CaptionColor&

Dim hSysMenu As Long

Dim ScreenRect As RECT

Dim InSysMenu As Integer

Sub Form_Activate ()

    Print "how do you like it?"

End Sub

Sub Form_KeyUp (KeyCode As Integer, Shift As Integer)

    If (KeyCode = 115) And (Shift = 4) Then End

    If (KeyCode = 18) And (Shift = 0) Then ShowSysMenu

    If (KeyCode = 27) And (Shift = 0) Then InSysMenu = False

End Sub

Sub Form_Load ()

    ScaleMode = 3

    CaptionColor& = GetSysColor(COLOR_ACTIVECAPTION) And &HFFFFFF

    MsgBlaster1.hWndTarget = hWnd

    MsgBlaster1.MsgList(0) = WM_NCHITTEST

    MsgBlaster1.MsgPassage(0) = EATMESSAGE

    MsgBlaster1.MsgList(1) = WM_CLOSE

    MsgBlaster1.MsgList(2) = WM_NCACTIVATE

    MsgBlaster1.MsgList(3) = WM_NCLBUTTONDBLCLK

    MsgBlaster1.MsgPassage(3) = EATMESSAGE

    MsgBlaster1.MsgList(4) = WM_NCLBUTTONDOWN

    MsgBlaster1.MsgList(5) = WM_COMMAND

    MsgBlaster1.MsgPassage(5) = PREPROCESS

    hSysMenu = CreatePopupMenu()

    rc% = AppendMenu(hSysMenu, MF_ENABLED Or MF_STRING,

IDM_SYSMOVE, "&Move")

    rc% = AppendMenu(hSysMenu, MF_ENABLED Or MF_STRING,

IDM_SYSCLOSE, "&Close

Alt+F4")

    rc% = AppendMenu(hSysMenu, MF_SEPARATOR, 0, "")

    rc% = AppendMenu(hSysMenu, MF_ENABLED Or MF_STRING,

IDM_ABOUT, "&About")

    ScreenRect.left = 0

    ScreenRect.right = Screen.Width / Screen.TwipsPerPixelX

    ScreenRect.top = 0

    ScreenRect.bottom = Screen.Height / Screen.TwipsPerPixelY

End Sub

Sub Form_Paint ()

    'Paint caption background

    Line (0, -1)-Step(Width, 9), CaptionColor&, BF

    'Horizontal line under caption

    Line (0, 8)-Step(ScaleWidth, 0), QBColor(0)

    'Vertical line beteen control menu and caption

    Line (10, 0)-Step(0, 8), QBColor(0)

    'Background for control menu

    Line (0, 0)-Step(9, 7), QBColor(7), BF

    'Box for bar in control menu

    Line (2, 2)-Step(5, 2), QBColor(0), B

    'Line inside bar in control menu

    Line (3, 3)-Step(4, 0), QBColor(15)

    'Vertical shadow on bar in control menu

    Line (8, 3)-Step(0, 3), QBColor(8)

    'Horizontal shadow on bar in control menu

    Line (3, 5)-Step(5, 0), QBColor(8)

End Sub

Sub MsgBlaster1_Message (MsgVal As Integer, wParam As Integer, lParam

As Long,

lRetVal As Long)

    Select Case MsgVal

        Case WM_NCACTIVATE

            If wParam Then

                CaptionColor& = GetSysColor(COLOR_ACTIVECAPTION) And

&HFFFFFF

            Else

                CaptionColor& = GetSysColor(COLOR_INACTIVECAPTION) And

&HFFFFFF

            End If

            Refresh

        Case WM_CLOSE

            End

        Case WM_NCHITTEST

            xPos% = (lParam And &HFFFF&)

            yPos% = (lParam / 65536)

            FormTop% = top / Screen.TwipsPerPixelY

            FormLeft% = left / Screen.TwipsPerPixelX

            If (yPos% - FormTop% < 10) And (xPos% - FormLeft% > 10) Then

                lRetVal = HTCAPTION

                InSysMenu = False

            ElseIf (yPos% - FormTop% < 10) And (xPos% - FormLeft% < 10) Then

                lRetVal = HTSYSMENU

            Else

                lRetVal = HTCLIENT

                InSysMenu = False

            End If

        Case WM_NCLBUTTONDBLCLK

            If wParam = HTSYSMENU Then End

        Case WM_NCLBUTTONDOWN

            If wParam = HTSYSMENU Then

                If InSysMenu Then

                    InSysMenu = False

                    Exit Sub

                    Else

                    ShowSysMenu

                End If

            End If

        Case WM_COMMAND

            Select Case wParam

                Case IDM_SYSMOVE

                    tc& = SendMessage(hWnd, WM_SYSCOMMAND, SC_MOVE, 0)

                Case IDM_SYSCLOSE

                    End

                Case IDM_ABOUT

                    MsgBox "About Small Cap"

            End Select

    End Select

End Sub

Sub ShowSysMenu ()

    InPixels = ScaleWidth

    ScaleMode = 1

    IX = (left)   (ScaleWidth   InPixels)

    IY = (9 * Screen.TwipsPerPixelY + (top + (Height - ScaleHeight - (Width -

ScaleWidth))))   (ScaleWidth   InPixels)

    ScaleMode = 3

    If (IY + (3 * GetSystemMetrics(SM_CYMENU))) > (Screen.Height /

Screen.TwipsPerPixelY) Then

        rc% = TrackPopupMenu(hSysMenu, 0, IX, IY - (3 *

GetSystemMetrics(SM_CYMENU)) - 9, 0, hWnd, ScreenRect)

    Else

        rc% = TrackPopupMenu(hSysMenu, 0, IX, IY, 0, hWnd, ScreenRect)

    End If

    InSysMenu = True

End Sub


Cards DLL

LUOKKA: misc

=============================================================

Date:         Fri, 7 Oct 1994 15:03:26 EDT

From:         James Parr

<James_Parr%COUNTRYWIDE@NOTES.WORLDCOM.COM>

Subject:      Cards.Dll

I don't remember where I got this...

Option Explicit

'Action taken by CDTDraw and CDTDrawExt

Global Const DRAW_FACES = 0

Global Const DRAW_BACKS = 1

Global Const DRAW_INVERT = 2

'Constants for card back bitmaps

Global Const BK_CROSSHATCH = 53

Global Const BK_PLAID = 54

Global Const BK_WEAVE = 55

Global Const BK_ROBOT = 56

Global Const BK_ROSES = 57

Global Const BK_IVY_BLACK = 58

Global Const BK_IVY_BLUE = 59

Global Const BK_FISH_CYAN = 60

Global Const BK_FISH_BLUE = 61

Global Const BK_SHELL = 62

Global Const BK_CASTLE = 63

Global Const BK_BEACH = 64

Global Const BK_CARD_HAND = 65

Global Const BK_UNUSED = 66

Global Const BK_X = 67

Global Const BK_O = 68

'Constants for suit offsets

Global Const CLUBS = 0

Global Const DIAMONDS = 1

Global Const HEARTS = 2

Global Const SPADES = 3

'Constants for face cards

Global Const Ace = 1

Global Const Jack = 11

Global Const Queen = 12

Global Const King = 13

Type DeckType

  Card(52) As Integer

End Type

Global CardHeight As Integer

Global CardWidth As Integer

Dim CardsOK As Integer

Global Deck As DeckType

Global CardBack As Integer

'Initilizes CARDS.DLL, called once at program execution

Declare Function CDTInit% Lib "CARDS.DLL" (nWidth%, nHeight%)

'Used to draw a card

Declare Function CDTDrawExt% Lib "CARDS.DLL" (ByVal hDC%, ByVal

xOrg%, ByVal yOrg%, ByVal nHeight%, ByVal nWidth%, ByVal nCard%, ByVal

 nDraw%, ByVal Color&)

'Draws a card with default card size

Declare Function CDTDraw% Lib "CARDS.DLL" (ByVal hDC%, ByVal xOrg%,

 ByVal yOrg%, ByVal nCard%, ByVal nDraw%, ByVal Color&)

'Used to animates a card back

Declare Function CDTAnimate% Lib "CARDS.DLL" (ByVal hDC%, ByVal

nCardBack%, ByVal xOrg%, ByVal yOrg%, ByVal nState%)

'Used to terminate CARDS.DLL.  Called once at program exit.

Declare Function CDTTerm% Lib "CARDS.DLL" ()

Function CardSuit (CardNum As Integer) As Integer

  CardSuit = (CardNum Mod 4)

End Function

Function DrawCard (x%, Y%, FaceCard%, CardSuit%) As Integer

Dim CardNum As Integer

  CardNum = (FaceCard - 1) * 4 + CardSuit

  DrawCard = CDTDraw(Form1.hDC, x, Y, CardNum, DRAW_FACES, 0)

End Function

Function FaceValue (CardNum As Integer) As Integer

  ' Ace is 1, Jack is 11

  FaceValue = (CardNum \ 4) + 1

End Function

Function InitCards () As Integer

  CardsOK = CDTInit(CardWidth, CardHeight) <> 0

  CardBack = 54

  InitCards = CardsOK

End Function

Sub KillCards ()

Dim Dummy As Integer

  If CardsOK Then

    Dummy = CDTTerm()

  End If

End Sub

Sub ShuffleCards ()

Dim I As Integer

Dim TempCard As Integer

  Randomize

  For I = 0 To 51

    Deck.Card(I) = -1

  Next I

  For I = 0 To 51

    Do

      TempCard = CInt(Rnd * 52)

    Loop Until Deck.Card(TempCard) = -1

    Deck.Card(TempCard) = I

  Next I

End Sub


Carrier detect

LUOKKA: VBgen

21226 (137+)  abutler@ariel.demon.co.uk  15.06.95  22:03

Tony Butler: "Re: checking for communications via serial port with vb3"

In article: <3rntu9$sc5@news.rz.uni-duesseldorf.de>

Gerald.Koerperich@uni-duesseldorf.de (Gerald Koerperich) writes:

> How can I use this DLL from VB3 (after getting it ) ?

From the author of the DLL, Keith Pickup here is an explanation of

the status register & an example VB program using it:-

-------------------------Cut here--------------------------

The Modem Status Register is composed of:

128   64  32   16   8   4   2   1

 D    R   D    C    D   R   D   C

 C    I   S    T    C   I   S   T

 D        R    S    D       R   S

 +++++++++++++++    +++++++++++++

  Signal Hi/Lo      Signal Change

where for example the byte value returned has to be And'ed with 128 to get

the bit value for DCD or And'ed with 32 for DSR etc.

The Modem Status Register is at the serial port address + 6 bytes, so it's at

02FE for COM2.

The actual byte returned will fluctuate by value because things such as CTS

may be used for flow control.

VB Declarations are...

'declarations for INPOUT.DLL

'handles Byte, Word and Long values

'INP/OUT converts the Integer/Word value to a Byte within the DLL

Declare Function INP% Lib "INPOUT.DLL" (ByVal PortNum%)

Declare Sub OUT Lib "INPOUT.DLL" (ByVal PortNum%, ByVal Value%)

Declare Function INPWORD% Lib "INPOUT.DLL" (ByVal PortNum%)

Declare Sub OUTWORD Lib "INPOUT.DLL" (ByVal PortNum%, ByVal Value%)

Declare Function INPLONG& Lib "INPOUT.DLL" (ByVal PortNum%)

Declare Sub OUTLONG Lib "INPOUT.DLL" (ByVal PortNum%, ByVal Value&)

'This sample monitors the Carrier Detect signal on COM2

VERSION 2.00

Begin Form Form1

   Caption         =   "Form1"

   ClientHeight    =   705

   ClientLeft      =   1095

   ClientTop       =   1485

   ClientWidth     =   3315

   Height          =   1110

   Left            =   1035

   LinkTopic       =   "Form1"

   ScaleHeight     =   705

   ScaleWidth      =   3315

   Top             =   1140

   Width           =   3435

   Begin Timer Timer1

      Interval        =   500

      Left            =   2760

      Top             =   120

   End

   Begin TextBox Text1

      Height          =   435

      Left            =   120

      TabIndex        =   0

      Top             =   120

      Width           =   2415

   End

End

Sub Timer1_Timer ()

  'monitor the carrier detect on COM2

  Status% = INP(&H2FE)

  If Status% And 128 Then

    Text1.Text = "CD HIGH"

  Else

    Text1.Text = "CD LOW"

  End If

End Sub

-------------------------Cut here--------------------------

 abutler@ariel.demon.co.uk


CD

LUOKKA: VBgen

Date: 09.02.95 (13:31)              Number: 620 of 687 (Refer# 603)

  To: KIMMO WEISTR"M

From: MATTI SAARNELA

Subj: Kellonajat Selville VisualBasicilla

Conf: PC-Ohjelmointi (8)         Read Type: GENERAL (A) (+)

KW>        Kuinka on mahdolista saada selville tavallisesta ääniCD-Kieko

KW>kappaleen pituus ja soitettu aika tunteina,minuutteina ja sekuntteina

KW> VisualBasic on versiota 3.0 Pro. Kappaleen (Track) numeron kyl

Vaikka käyttämällä täta funkkaria:

Function changetime$ (Track)

Track = Int(Track / 1000)

hours = Int(Track / 3600)

Track = Track - (hours * 3600)

mins = Int(Track / 60)

Track = Track - (mins * 60)

sec = Track

res$ = Str$(hours) + ":" + Str$(mins) + ":" + Str$(sec)

changetime$ = res$

Exit Function

End Function

-----------------------------------------

ja tätä koodia:

    timeused = mmcontrol1.Position

    res$ = changetime$(timeused)

    panel3d4.Caption = Format(res$, "hh:mm:ss")

Matti

Saarnela


CD lengths

LUOKKA: sounds

27841 (57+)  stu@cuyahoga.demon.co.uk  27.07.95  05:34

Stu Churchill: "Re: Splitting Bytes?"

In article: <3v5epu$q5f@server1.ctc.com>  Rob Tanzola

<Tanzolar@ndcee.ctc.com> writes:

> 	I am writing a Visual Basic CD player and the MCI controls report

> position data in 4 byte integers with each representing a different

> value for time, track, etc.  How can I separate these reported values

> into individual values to report them?

For the total length of the CD, use;

    cd_len& = MMControl1.Length

    mins% = cd_len& And &HFF&

    secs% = (cd_len& And &HFF00&) / &H100&

For the length of the current track, use;

    track_len& = MMControl1.TrackLength

    mins% = track_len& And &HFF&

    secs% = (track_len& And &HFF00&) / &H100&

-------------------------------------------------------------------------

27889 (10+)  jwehry@ix.netcom.com  28.07.95  03:43

J. R. Wehry: "Re: Splitting Bytes?"

Rob Tanzola <Tanzolar@ndcee.ctc.com> wrote:

>	I am writing a Visual Basic CD player and the MCI controls report

>position data in 4 byte integers with each representing a different

>value for time, track, etc.  How can I separate these reported values

>into individual values to report them?

'Example of how to get all 4 bytes from a 4 byte

integer

    Byteall = MMControl1.TrackLength

    byte1 = (Byteall And &HFF&)

    Byte2 = (Byteall And &HFF00&) ™ &H100

    Byte3 = (Byteall And &HFF0000) ™ &H10000

    Byte4 = (Byteall And &H7F000000) ™ &H1000000

__

Joe Wehry    Brandon, Florida

  Jwehry@ix.netcom.com


Checkbox modifying

LUOKKA: checkbox

===========================================================

Date:         Wed, 21 Sep 1994 11:47:12 EDT

From:         Preston Werntz

<Preston_Werntz@TRG.CCMAIL.COMPUSERVE.COM>

Subject:      Modifying a checkbox.

If you want to "modify" the checkbox character, the easiest work

around is to cheat and use an image box (e.g. imgCheckbox)

instead, with a label. Place what would be the checkbox caption

on the label, and put two other invisible image boxes on the form

in a control array. imgHidden(0) might be an empty box and

imgHidden(1) might be the same box with a big red check mark in

it. Place code in imgCheckbox_click to rotate the bitmaps and

update the status of whatever variable imgCheckbox controls.


Class inheritance

LUOKKA: coding

Date: 06-18-95 (09:02)              Number: 366379 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Class Inheritance

Michael follows the same approach I use in VB3. ÄOh types have been

around since Quick Basic -- I seem to recall that they were in Integer

Basic and Applesoft Basic (remember? From the days when Bill was a

coder... -- but Strings were FIXED LENGTH always back thenÅ.

I use the term "Developer protected Classes" -- instead of Compiler

Protected Classes. Consider the following code:

        Sub ChildObject_Init(MyUDT as ChildUDT)

                ParentObject_Init(ChildUDT.ParentUDT)

                'Do over rides now and new properties

                .....

        End Sub

        Sub ChildObject_Methodx(MyUDT as ChildUDT)

                ParentObject_Methodx MyUDT.ParentUDT

                'Do over rides now and new properties

                .....

        ENd Sub

There is a lot of code writing 'replication' that C++ does --> but if

you write a simple VB Utility and keep all objects in separate Modules,

then to create the subclass module is nothing more than pointing to the

parent and having all the >>public << procedures slammed into a new

module file with the above template(easy to do in VB, just Line Input

looking for Sub or Function.......). I even use 'Developer Protected Friends' .

        .... and once you adjusted to the approach -- you get the advantages

(and the ability to cheat when you need to....) of C++.  Besides, if

you talk Object Programming --> I say, "Great News... Another Simula

programmer! What do you think about the latest release.... ÄC++ types

get confused! and then addÅ ... C++ is NOT Object programming -- SImula

is, with Smalltalk being the VB cousin..... "  Well what do you expect

from an old B-Programmer (Yes, I programmed in B before they came up with

C).

        Ken


CLBV-digest

LUOKKA: internet

Date: 04-09-95    Time: 02:33p     Number: 516

From: clbv-digest-editor@apexsc     Refer:

Subject: CLBV-DIGEST                       4: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

Note, though, that the FTP version of CLBV Digest should be available

today, at ftp.apexsc.com:/pub/cgvb/clbv-digest/clbv9503.zip ..

Yours sincerely,

Jakob Faarvang

Editor, CLBV Digest

clbv-digest-editor@apexsc.com


Clicking on line ctrl

LUOKKA: misc

Date: 01/18/95 (07:01)              Number: 32845 of 33020 (Refer# NONE)

From: BLS@BLACK_COMIC

Subj: Re: Clicking on a line control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

type VPoint

 x as Integer

 y as Integer

end type

type VSize

 vwidth as Integer

 vheight as Integer

end type

type VRect

 origin as VPoint

 ssize as VSize

end type

' this rountine also accounts for the width of the

' line, and the downhill argument is weather

' you are drawing the line from top to bottom

' or bottom to top,you can probably just hard

' code it in your case

function InLine(x0 As Single, y0 As Single,

             X1 As Single, Y1 As Single, x As Single, y As

Single,downhill as Integer,Single as linewidth)

/*

 * Gets a hit if the point is within HIT_TOLERANCE of the line.

 */

„

    const HIT_TOLERANCE = 6.0

    Dim r as VRect

    Dim p as VPoint

    Dim lineangle as single,pointangle as single

    Dim tolerance as single

    Dim point as VPoint

    Dim bounds as VRect

    point.x = x

    point.y = y

    bounds.origin.x = x0

    bounds.origin.y = y0

    bounds.ssize.vwidth = x1

    bounds.ssize.vheight = y1

    tolerance = HIT_TOLERANCE + linewidth

    r = bounds

    if r.ssize.vwidth < tolerance then

 r.ssize.vwidth = r.ssize.vwidth + tolerance * 2.0

 r.origin.x = r.origin.x - tolerance

    end if

    if r.ssize.vheight < tolerance then

 r.ssize.vheight = r.ssize.vheight + tolerance * 2.0

 r.origin.y = r.origin.y - tolerance

    end if

    p.x = point.x - bounds.origin.x

    p.y = point.y - bounds.origin.y

    ' line is going downHill ?

    if downhill = True  then

 p.y = bounds.ssize.vheight - p.y

    end if

    if p.x && bounds.ssize.vwidth then

 lineangle = atan(bounds.ssize.vheight/bounds.ssize.vwidth)

 pointangle = atan(p.y/p.x)

 distance =

sqr(p.x*p.x+p.y*p.y)*sin(abs(lineangle-pointangle))

    else

 distance = abs(point.x - bounds.origin.x)

    end if

    InLine = ((distance - tolerance) <= linewidth)

End Function


Clipboard format custo

LUOKKA: clipboard

Date: 05/25/94 (18:51)              Number: 6922 of 6934 (Refer# NONE)

From: DEVILBIS@OIENG.MKE.AB.COM

Subj: Re: Custom clipboard format? - An Answer!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Warren DeVilbiss  (2826) (devilbis@oi_100) wrote:

: I'm trying to write custom binary data to the clipboard.  The clipboard

: "object" appears to only accept the handfull of common formats.  Is there

: a way to write a custom binary data image to the clipboard without first

: converting to one of the common formats (e.g. text)?

My thanks to those who responded to my question.  Based on you responses,

and searching through the literature, I came up with the following solution:

------

Declarations ...

    ' Clipboard Manager Functions

    Declare Function OpenClipboard Lib "User" (ByVal hWnd As Integer) As

Integer

    Declare Function CloseClipboard Lib "User" () As Integer

    Declare Function SetClipboardData Lib "User" (ByVal wFormat As Integer,

ByVal hMem As Integer) As Integer

    Declare Function GetClipboardData Lib "User" (ByVal wFormat As Integer)

As

Integer

    Declare Function RegisterClipboardFormat Lib "User" (ByVal lpString As

String) As Integer

    Declare Function CountClipboardFormats Lib "User" () As Integer

    Declare Function EnumClipboardFormats Lib "User" (ByVal wFormat As

Integer)

As Integer

    Declare Function GetClipboardFormatName Lib "User" (ByVal wFormat As

Integer, ByVal lpString As String, ByVal nMaxCount As Integer) As Integer

    Declare Function EmptyClipboard Lib "User" () As Integer

    Declare Function IsClipboardFormatAvailable Lib "User" (ByVal wFormat

As

Integer) As Integer

    Declare Function GetPriorityClipboardFormat Lib "User" (lpPriorityList As

Integer, ByVal nCount As Integer) As Integer

    ' Global Memory Functions and Flags

    Declare Function GlobalAlloc Lib "Kernel" (ByVal wFlags As Integer, ByVal

dwBytes As Long) As Integer

    Declare Function GlobalHandleToSel Lib "toolhelp.dll" (ByVal hMem%) As

Integer

    Declare Function MemoryWrite Lib "toolhelp.dll" (ByVal wSel%, ByVal

dwOffset&, lpvBuf As Any, ByVal dwcb&) As Long

    Declare Function MemoryRead Lib "toolhelp.dll" (ByVal wSel%, ByVal

dwOffset&, lpvBuf As Any, ByVal dwcb&) As Long

    Global Const GMEM_MOVEABLE = &H2

    Global Const GMEM_ZEROINIT = &H40

    Global Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)

In the form load ...

    ' Initialize clipboard format

    intCF_MINE = RegisterClipboardFormat("Format Name Here")

In the copy function ...

    Dim hMem As Integer

    Dim size As Long

    ' Put the text part on the clipboard

    Clipboard.Clear                 ' Clear current

    Clipboard.SetText txtText.SelText

    ' Place the current data in the clipboard

    hMem = GlobalAlloc(GHND, Len(DataList(intIndex)))

    nBytes& = MemoryWrite(GlobalHandleToSel(hMem), 0&, DataList(intIndex),

Len(DataList(intIndex)))

    If OpenClipboard(hWnd) Then

        x% = SetClipboardData(intCF_MINE, hMem)

        x% = CloseClipboard()

    End If

In the paste function ...

    ' Get the text from the clipboard if the focus is in the text box

    If ActiveControl.Tag = "txtText" Then

        txtText.SelText = Clipboard.GetText()

    End If

    ' Get the current data in the clipboard if the focus is in the list box

    If ActiveControl.Tag = "lbList" Then

        ' Open the clipboard and remove the data

        If OpenClipboard(hWnd) Then

            hMem = GetClipboardData(intCF_MINE)

            x% = CloseClipboard()

        End If

        ' If there is the proper format available, then read the data to a temp

variable

        If hMem <> 0 Then

            nBytes& = MemoryRead(GlobalHandleToSel(hMem), 0&, DataTemp,

Len(DataTemp))

        End If

    End If


Clock make

LUOKKA: VBgen

Date: 07-24-95 (09:04)              Number: 394346 of 394700 (Refer# NONE)

From: VISBAS-L@EVA.DC.LSOFT.COM

>2) I'm writing an application that makes use of an animated stopwatch.

>Basically, what I did was import a bitmap picture of a clock (minus the hour

>and minute hands) and then put a Visual Basic line on it.  I'd like the line

to

>spin around like a real clock with one point fixed at the center and the other

>moving in a clockwise pattern.  But I'm stuck on the algorithim.  I haven't

>been able to modify the mathametical circle formula ( x^2+y^2=1 ) to

>properly accomplish this.  Can anyone help me?

I sweated this one out for some time -- I am not a math whiz

by any stretch of the imagination -- then, in the space of two

days, I found the formulas in two completely unrelated sources!

Timing is everything <g>

This is the code I wrote based on the angle formulas I found.

---------------------------------------

Create a form with a textbox named txtAngle and a command button

named cmdAngle in the upper left hand corner of the form.

---------------------------------------

Notes:

   This code allows you to specify a starting XY point,

   the length of the line you want to draw, the angle,

   and an "innerlen" variable that you can make non-

   zero if you need to have the line "rotate" around

   an imaginary "large point".  (I.e., if you want to

   have the hands of your clock not start from dead

   center, but start from a "hub".)

Paste in the following code into the Declarations section:

---------------------------------------

DefInt A-Z

Dim Length As Long

Dim innerlen As Integer

Const Pi = 3.14159265359

---------------------------------------

Sub Form_Resize ()

   Length = Me.Width * .25

   innerlen = Length * .3

End Sub

--------------------------------------

Sub cmdAngle_Click ()

     Me.Cls

     StartY! = Me.Height / 2

     StartX! = (Me.Width / 2) + 400

     angle! = txtAngle

End Sub

---------------------------------------

Sub rotate (ByVal StartX!, ByVal StartY!, ByVal angle!)

Const Pi = 3.14159265359

Dim CosAngle As Double

Dim SinAngle As Double

Dim TickCosAngle As Double

Dim TickSinAngle As Double

Dim EndX As Single

Dim EndY As Single

Dim X1 As Single

Dim Y1 As Single

Dim X2 As Single

Dim Y2 As Single

    StartX = StartX + innerlen * Cos(angle * (Pi / 180))

    StartY = StartY + innerlen * Sin(angle * (Pi / 180))

    CosAngle = Cos(angle * (Pi / 180))

    SinAngle = Sin(angle * (Pi / 180))

    TickCosAngle = Cos((angle + 90) * (Pi / 180))

    TickSinAngle = Sin((angle + 90) * (Pi / 180))

    EndX = StartX + Length * CosAngle

    EndY = StartY + Length * SinAngle

    Line (StartX, StartY)-(EndX, EndY)

End Sub

Date: 07-24-95 (16:42)              Number: 394578 of 394700 (Refer# NONE)

From: Lasse Rantanen <lasse@rantane.pp.fi>

following is a simple clock program showing one approach to things you have

to consider.

-----------

In form's general section add following declarations

Option Explicit

Dim XCen As Single, YCen As Single, Radius As Single

Dim Pi

Then add following subs

Sub DrawClockFace ()

   Dim i As Integer, Angle

   Dim XStart As Single, YStart As Single, XEnd As Single, YEnd As Single

   Me.FillColor = QBColor(14)

   Me.FillStyle = 0

   Me.Circle (XCen, YCen), Radius

   Me.FillColor = QBColor(7)

   Me.FillStyle = 0

   Me.Circle (XCen, YCen), .92 * Radius

   For i = 0 To 59

      Angle = Pi * (1 - 2 * i / 60)

      If i Mod 5 = 0 Then

         Me.DrawWidth = 2

         XStart = XCen + .93 * Radius * Sin(Angle)

         YStart = YCen + .93 * Radius * Cos(Angle)

      Else

         Me.DrawWidth = 1

         XStart = XCen + .97 * Radius * Sin(Angle)

         YStart = YCen + .97 * Radius * Cos(Angle)

      End If

      XEnd = XCen + .99 * Radius * Sin(Angle)

      YEnd = YCen + .99 * Radius * Cos(Angle)

      Me.Line (XStart, YStart)-(XEnd, YEnd)

   Next i

End Sub

Sub Form_Load ()

   Pi = 4 * Atn(1)

   XCen = Me.ScaleWidth / 2

   YCen = Me.ScaleHeight / 2

   Radius = Me.ScaleWidth / 3

   Me.Show

   DrawClockFace

End Sub

Sub Timer1_Timer ()

   Dim Hours As Integer, Minutes As Integer, Seconds As Integer

   Dim HourAngle, MinAngle, SecAngle, Instant

   Dim OldDrawMode As Integer

   Dim XEnd As Single, YEnd As Single

   Static XSecOld As Single, YSecOld As Single

   Static XMinOld As Single, YMinOld As Single

   Static XHourOld As Single, YHourOld As Single

   ' Get current time

   Instant = Now

   Hours = Hour(Instant)

   Minutes = Minute(Instant)

   Seconds = Second(Instant)

   ' Calculate angles for hands

   HourAngle = Pi * (1 - 2 * (Hours + Minutes / 60) / 12)

   MinAngle = Pi * (1 - 2 * (Minutes + Seconds / 60) / 60)

   SecAngle = Pi * (1 - 2 * Seconds / 60)

   OldDrawMode = Me.DrawMode

   Me.DrawMode = 7

   ' Erase currently drawn hands

   If XSecOld <> 0 Then

      Me.DrawWidth = 1

      Me.Line (XCen, YCen)-(XSecOld, YSecOld), QBColor(11)

      Me.DrawWidth = 2

      Me.Line (XCen, YCen)-(XMinOld, YMinOld), QBColor(15)

      Me.Line (XCen, YCen)-(XHourOld, YHourOld), QBColor(15)

   End If

   ' Draw seconds hand

   Me.DrawWidth = 1

   YEnd = YCen + .95 * Radius * Cos(SecAngle)

   XEnd = XCen + .95 * Radius * Sin(SecAngle)

   Me.Line (XCen, YCen)-(XEnd, YEnd), QBColor(11)

   XSecOld = XEnd

   YSecOld = YEnd

   ' Draw minutes hand

   Me.DrawWidth = 2

   YEnd = YCen + .9 * Radius * Cos(MinAngle)

   XEnd = XCen + .9 * Radius * Sin(MinAngle)

   Me.Line (XCen, YCen)-(XEnd, YEnd), QBColor(15)

   XMinOld = XEnd

   YMinOld = YEnd

   ' Draw hours hand

   YEnd = YCen + .8 * Radius * Cos(HourAngle)

   XEnd = XCen + .8 * Radius * Sin(HourAngle)

   Me.Line (XCen, YCen)-(XEnd, YEnd), QBColor(15)

   XHourOld = XEnd

   YHourOld = YEnd

   Me.DrawMode = OldDrawMode

End Sub


CmdBtn w/Picture

LUOKKA: CmdButton

Date: 05-03-95 (13:17)              Number: 314023 of 316438 (Refer# NONE)

Subj: Re: Command Button w/Picture

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

I am looking for a way to add a picture to a command button as seen in most

Windows apps.  Is there an easy way to program this in VB (while maintaining

the 3D command button look) or do I require a 3rd party VBX?  I know

Sheridan's 3-D Widgets has this capability.  Can you recommend any other

freeware/shareware/commercial VBXs that have this capability?  Thanks in

advance.

Terry

kytet@tc.gc.ca

-------------------------------------------

     Create a picture box picBackGrd and a SSCommand cmd3D,

cmd3D.Caption =   "".

Sub BuildButton()

    'Load bitmap on picBackGrd

    picBackGrd.Picture = LoadPicture("c:ÖwindowsÖarches.bmp")

    'Print caption on picBackGrd

    picBackGrd.FontName = "MS Sans Serif"

    picBackGrd.FontSize = 18

    picBackGrd.FontTransparent = True

    picBackGrd.ForeColor = &HFF&

    picBackGrd.CurrentX = 200

    picBackGrd.CurrentY = 800

    picBackGrd.Print "Caption"

    'Give it to cmd3d

    cmd3d.AutoSize = 2

    cmd3d.Picture = picBackGrd.Image

    cmd3d.AutoSize = 0

End Sub

Sub DestroyButton()

    picBackGrd.Picture = LoadPicture("")

    cmd3d.Picture = picBackGrd.Image

End Sub

Sub EraseButtonCaption()

    picBackGrd.Cls

    cmd3d.Picture = picBackGrd.Image

End Sub


CmdBtn w/Picture

LUOKKA: CmdButton

Date: 05-12-95 (16:05)              Number: 326274 of 329412 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: problem with 3D command button..

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>     I want to put a graphic button in my application. I have done this by

>using a 3D command button that came with VB Professonal edition. What

>the problem for me is I want to use a graphic as well as text in that

>command button. In the command button it is always giving the picture and

>text in centre, consequently they are mixing up. Is there a way like in

>Animated Button to display the text to left, right or On the picture. How to

>do this easily and effectively,

1. Load the same picture you want to be on the 3D command button (cmd3d)

onto a picture box (picBackGrd).

2. Print the text you want to be on cmd3d on picBackGrd at the exact

location you want.

3. Transfer the image on picBackGrd to the cmd3d.

picBackGrd.Picture = LoadPicture("c:ÖwindowsÖarches.bmp") 'any picture

picBackGrd.FontName = "MS Sans Serif" 'or any other font

picBackGrd.FontSize = 18

picBackGrd.FontTransparent = True

picBackGrd.ForeColor = &HFF&          'or any other color

picBackGrd.CurrentX = 200

picBackGrd.CurrentY = 800

picBackGrd.Print "Caption"            'any text

cmd3d.AutoSize = 2

cmd3d.Picture = picBackGrd.Image

cmd3d.AutoSize = 0


CmdButn free

LUOKKA: internet

4494 (30+)  evansj@cadvision.com  25.05.95  23:04

Jeff Evans: "Re: VB add-ons"

ghauser@usit.net (Gary E. Hauser) wrote:

>Can anyone tell me where I can get the commercial or shareware VB add-on

>that automatically creates those command buttons with the green "check"

>for Yes or OK, the red "X" for No or Cancel, the blue script "i" for info msg

>boxes, etc? Thanks.

A package called dbstuff.zip at

ftp.cica.indiana.edu/pub/pc/win3/programr/vbasic is a set of four freeware

controls. One is a button control that comes with pre-defined button

styles that include the check and the 'x'.

Jeff.


CmdButton 2 lines

LUOKKA: CmdButton

Date: 06/05/94 (09:22)              Number: 8007 of 8074 (Refer# NONE)

From: MAURICE1@DELPHI.COM

Subj: Re: Double line Caption i

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Michael Rubin <michael.rubin@pcgfx.com> writes:

>On 06-02-94 DEVILBIS@OIENG.MKE.AB.COM  wrote:

>D>: >>as the subject says, my Question is:

>D>: >>Is it possible to have a button with a two line caption like

>D>: >>-----------

>D>: >>   Print

>D>: >> Envelope

>D>: >>-----------

     Here is a simple attempt at a solution. There will be a slight flicker.

This should not be a problem unless you are placing a great deal of text on

the button.

VERSION 2.00

Begin Form frmCapTest

   BackColor       =   &H00C0C0C0&

   BorderStyle     =   3  'Fixed Double

   Caption         =   "Test"

   ClientHeight    =   1932

   ClientLeft      =   1296

   ClientTop       =   2076

   ClientWidth     =   4212

   ClipControls    =   0   'False

   Height          =   2352

   Icon            =   0

   Left            =   1248

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   ScaleHeight     =   1932

   ScaleWidth      =   4212

   Top             =   1704

   Width           =   4308

   Begin PictureBox picCapBox

      BackColor       =   &H00C0C0C0&

      BorderStyle     =   0  'None

      ClipControls    =   0   'False

      Enabled         =   0   'False

      Height          =   612

      Left            =   240

      ScaleHeight     =   612

      ScaleWidth      =   1812

      TabIndex        =   0

      Top             =   2000

      Width           =   1812

      Begin Label lblCapText

         Alignment       =   2  'Center

         BackColor       =   &H00C0C0C0&

         BackStyle       =   0  'Transparent

         Caption         =   "This is a test of a multi-line caption on a Command

Button."

         Height          =   612

         Left            =   0

         TabIndex        =   2

         Top             =   0

         Width           =   1812

      End

   End

   Begin CommandButton cmdButton1

      Height          =   852

      Left            =   1080

      TabIndex        =   1

      Top             =   840

      Width           =   2052

   End

   Begin Label lblHeadline

      Alignment       =   2  'Center

      BackStyle       =   0  'Transparent

      Caption         =   "Click Button below for a demo of a multi-line

caption Command Button.  -  Maurice"

      ForeColor       =   &H000000FF&

      Height          =   372

      Left            =   240

      TabIndex        =   3

      Top             =   240

      Width           =   3732

   End

End

Option Explicit

Declare Function SetParent% Lib "User" (ByVal hWndChild%, ByVal

hWndNewParent%)

Dim STX As Integer

Dim Child_hWnd As Integer

Sub cmdButton1_GotFocus ()

    lblCapText.Refresh

End Sub

Sub cmdButton1_LostFocus ()

    lblCapText.Refresh

End Sub

Sub cmdButton1_MouseDown (Button As Integer, Shift As Integer, X As

Single, Y As Single)

    If Button <> 1 Then Exit Sub

    picCapBox.Left = picCapBox.Left + STX

    picCapBox.Top = picCapBox.Top + STX

    lblCapText.Refresh

End Sub

Sub cmdButton1_MouseUp (Button As Integer, Shift As Integer, X As Single,

Y As Single)

    If Button <> 1 Then Exit Sub

    picCapBox.Top = (cmdButton1.Height - picCapBox.Height) / 2

    picCapBox.Left = (cmdButton1.Width - picCapBox.Width) / 2

    lblCapText.Refresh

End Sub

Sub Form_Load ()

    STX = Screen.TwipsPerPixelX

    Child_hWnd = SetParent(picCapBox.hWnd, cmdButton1.hWnd)

    picCapBox.Top = (cmdButton1.Height - picCapBox.Height) / 2

    picCapBox.Left = (cmdButton1.Width - picCapBox.Width) / 2

End Sub

-------------------------------------------------------------------------------

  Maurice1@delphi.com


CmdButton 2 lines

LUOKKA: CmdButton

Date: 06/23/94 (01:25)              Number: 10064 of 10157 (Refer# NONE)

From: GRTORLBA@BACH.SEATTLEU.EDU, George R. Torralba

Subj: Re: Multiline button capt

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Actually, Micheal, you only need one picture box as your "scratch pad".

I'm not sure, now that I think about it, how it works but it does.  That

is, the previous bitmaps you've assigned to other 3d command buttons

doesn't change.  From the documentation in the CDK, a picture property is

supposed to be "shared" when assigned to or derived from another control.

So anyone who can explain why the above works please jump in.  I'm quite

sure it works 'coz that's how I used to do it in Launch Pad (You know

Mike. Can I call you Mike?).  That is, I'd simulate a button using an

Image control and draw the button bevel, borders, and picture/icon on a

hidden picture box and then assign it to the Image controls.  Maybe a 3d

command button acts differently no?

George

In article <e7.10858.2073.0NE72917@pcgfx.com>,

Michael Rubin <michael.rubin@pcgfx.com> wrote:

: On 06-22-94 ANDREW@GEAC.CO.NZ  wrote:

: A>The trick is to put the text into a picture box. You set the

: A>AutoRedraw property of the picture box to True (you can make the box

: A>invisible if you want).

: A>Then print the text to the picture box. One print statement = 1 line.

: A>Thus:-

: A>picture1.print "first line"

: A>picture1.print "second line"

:

: A>Then, using a 3d command button with no caption, simply set the

: A>picture property of the 3d command button to the image property of the

: A>picture box. Voila, multiline captions.

:

: This works, but don't do it too many times - it's a pretty heavy

: resource eater (a picturebox AND a 3D command button for every

: instance)!

:

: ------------------------------------------------------

: Michael Rubin   Internet: michael.rubin@pcgfx.com

:                           m_rubin@tatertot.com


CmdButton set color

LUOKKA: CmdButton

Date: 08/30/94 (23:01)              Number: 17914 of 18053 (Refer# NONE)

From: WOLFS@TIGER.DIALIX.OZ.AU

Subj: Re: Colored Buttons...is there a way

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <CvD7oD.rHM@ief.itg.ti.com>, Robert Wallace

(robertw@ief.itg.ti.com) writes:

>Richard D. Mancuso (rmancuso@gagme.wwa.com) wrote:

>: How can I have colored buttons with vb 3.0?  No matter what color I pick

>: in the properties list, they turn out grey with black foreground. I'm I

>: doing something really stupid?

>No.  Not really.  The standard button in VB uses the system button colors

>as defined in the windows "Colors" control panel applet.

>You could change them there, but then all your button colors would change

>and any user of your app would see whatever *they* have defined on their

>machine.

>

>One way around this is to "fake" a button using another type of control

>that you *can* change.  This takes a bit of effort, but does work.

>

>Another option is to get one of the various VBX's that have buttons

>with a working color property.

Sorry - I just saw this posting today ( you know we live at

the other end of the world and sometimes mail doesn't

arrive early enough ). Setting button colors should be

possible when using the CTRL3DV2.DLL - Why? Hmmm I've had

a closer look and there seems to be a function that does

this. - Maybe I am mistaken but I'll give it a shot. Here

is a full listing of all functions found in the

CTRL3DV2.DLL . I only know a few and how to call them.

Maybe some other whizz can fill the missing functions in.

If needed I have the .DLL actually in .LIB format if that

helps:

BTNWNDPROC3D        .............. ?

COMBOWNDPROC3D      .............. ?

CTL3DAUTOSUBCLASS   ..........CTL3DAutoSubClass(hInstance)

                    called with the Modulehandle immediately

                    after the call to CTL3DREGISTER

CTL3DCOLORCHANGE    .............. ?

CTL3DCTLCOLOR       .............. ?

CTL3DCTLCOLOREX     .............. ?

CTL3DDLGFRAMEPAINT  .............. ?

CTL3DDLGPROC        .............. ?

CTL3DENABLED        .............. ?

CTL3DGETVER         .............. ?

CTL3DREGISTER       .......  CTL3DRegister(hInstance) called

                    with application instance ( Module

                    handle ) handle BEFORE any  other

                    functions of this DLL

CTL3DSETSTYLE       .............. ?

CTL3DSUBCLASSCTL    .............. ?

CTL3DSUBCLASSDLG    .............. ?

CTL3DSUBCLASSDLGEX  .............. ?

CTL3DUNREGISTER     ........CTL3DUnRegister(hInstance)

                    must be called with the Module handle

                    prior ENDING the program ( even when

                    debugging in VB and ending somewhere or

                    you crash your program - and VB )

CTL3DWININICHANGE   .............. ?

EDITWNDPROC3D       .............. ?

LISTWNDPROC3D       .............. ?

STATICWNDPROC3D     .............. ?

I guess the function names themselves tell what they do...

but how do you call them. If anyone has got an idea or was

successful - may fill the missing bits in and post it to

the net for the benefit of all.

BTW: CTR3D.DLL and CTR3DV2.DLL don't differ in the number

or name of functions.

 -------------------------- ------------------------------------

"    Wolfgang A.Steinert   " Insanity is hereditary             "

"                          " You get it from your kids ...      "

" wolfs@tiger.DIALix.oz.au "


CmdButton toggle

LUOKKA: CmdButton

16.How do I mimic a toggle button?

   The only "fix" we know for this problem is to use a picture control to

   mimic the action of a button or button3d control. You need two bitmaps,

   one for buttonup and one for buttondown (and perhaps one more for

   inactive state). This is a kluge, we know. Look at the button bar used

   in the MDINOTE sample program supplied with VB for an example of this.

   (Note: You can't use an image control since it doesn't take click

   events)


CmdButton using Mouse

LUOKKA: mouse

7.4.11.  Right mouse clicks on command buttons

----------------------------------------------

  Visual Basic command buttons do not process right mouse clicks, nor mouse

  up or down events.  To use the right mouse button with a command button,

  replace the command button with a picture control (use two bitmaps, one for

  "up" and the other for "down"), which does process these events.


CmnDlg

LUOKKA: VBgen

Date: 02-07-95    Time: 03:20p     Number: 187

     From: Butterfld@aol.com             Refer:

       To: ALL                        Board ID: COMPART         Recvd: No

  Subject: Problems with common              0: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

> 1)  Using the common dialog and Action = 5 (Print) the DialogTitle

> property is ignored.  The title always seems to be "Print".

>

> 2) Using the common dialog and Action = 2 (Save As) a bunch of flaky

things

> happen.  The most prominent happens when you type in more than 8 chars

with >no extension, the FileName returns the first 9 chars plus the extension

with no

> period.

> Ex.

> DefaultExt = ".txt"

> User types in "abcdefghi"

> FileName returns the path and "abcdefghitxt" instead of what I think it

should

> return, "abcdefgh.txt".

>

> I have no idea what's going on?  Am I using the correct dll and vbx?

> CMDIALOG.VBX    18688    3/24/94   9:00:00 PM

> COMMDLG.DLL    97936    11/1/93    3:11:00 AM

My cmddialog.vbx is 2/11/94 18688. The dll is the same.  Here is a code

snippet that works, hope you find it helpful. (BTW I had problems

getting print to work at all once a save as had been done.  The

flags must be set (or reset).

  '*********************************************************

  '* This routine allows the user to save the contents of

  '* the list box to a file.  (Saving the decoded log or

  '* portion thereof).

  '*********************************************************

  CMDialog1.CancelError = True

  CMDialog1.DialogTitle = "Save Actual Results"

  CMDialog1.Filter = "Compare Files    *.TXT | *.TXT"

  CMDialog1.Flags = 0

  On Error GoTo SActErrHand

  CMDialog1.Action = 2

'^^^^^^^^^^^^^^^^^^^^^^End of common dialog ^^^^^^^^^^^^^^^

  index = 0

  Length1 = ActualList.ListCount

  Length2 = ExpectedList.ListCount

  If Length1 = 1 And Length2 = 1 Then

    MsgBox "Cannot save a blank file (or headers only)."

    Close 14

    GoTo SActErrHand

  End If

  Open (CMDialog1.Filename) For Output As #14

  For I = index To Length1

    Print #14, ActualList.List(I)

  Next I

  Close 14


CmnDlg

LUOKKA: WinHelp

Date: 07/07/94 (15:12)              Number: 11452 of 11683 (Refer# NONE)

From: LRP.ADMIN@MHS.UNC.EDU

Subj: Re: Calling Help Search Dialog Box in VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The common dialog provides the easiest way to access your help system:

Sub CallHelp (Index As Integer)

  AlLogOn.cmDialog.HelpFile = App.HelpFile

  Select Case Index

    Case 0

      AlLogOn.cmDialog.HelpCommand = HELP_CONTENTS

    Case 1

      AlLogOn.cmDialog.HelpCommand = HELP_PARTIALKEY

    Case 2

      AlLogOn.cmDialog.HelpCommand = HELP_HELPONHELP

  End Select

  AlLogOn.cmDialog.Action = DLG_HELP

End Sub

My help menu is a control array consisting of Contents, Search and Using

Help options.  This subroutine is called anytime the user selects one of the

help menu options.  Case 1 provides access to the search dialog box.  The

constants are defined in the text files that come with VB.  Hope this helps.

Ray Porter


Code placement

LUOKKA: coding

Date: 05-05-95 (17:26)              Number: 320613 of 322287 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Code placement

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>         Got a question about code placement. Should all event code

> be moved from the forms code events to a bas module. This technique is

> advocated  in a VB book that I am currently reading as a way of minimizing

> Windows heap and gdi memory usage by keeping forms pretty lean on

code.

>

>         example:( in form1.frm)

>                 Sub cmdButton_CLick()

>                         Call cmdButtonClick

>                 End Sub

>

>                 (in module1.bas)

>                 Sub cmdButtonClick

>                         ...code here...

>                 End Sub

>

> I have tried this but don't REALLY know if helps or hurts.My

> forms' event code is no more than 5 subroutine or function calls. Also the

use of Globals was not required, now using only Dim's.

> Robert Thomas

As a VB form is a variable and variables live on the stack, I would think that

code placed into a form rather than a module would be placed onto the stack

at run time.  As for a BAS module, I have been told that is stored in memory

from the heap.  I may be wrong but I think you are well advised to remove

functions/subroutines from forms and place them into a common (BAS)

module.

*                               Jeff King                               *

*                          kingjs@iinet.com.au                          *

*       Visual Basic Consultant - Dynamic Business Resources Pty Ltd    *

*                        Perth, Western Australia


Coding standards

LUOKKA: coding

Date: 07/20/94 (03:25)              Number: 12539 of 12618 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: re-usable code

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Be *rigorously* consistent with your naming conventions. No matter what you

do, there will be a lot of block copying of code. If you have to maintain the

stuff afterwards, then get it right before you start cloning it everywhere.

Get the first one working right, then copy it. Don't try to write six at

once, or you'll spend all day keeping them synchronised.

If you need to make a big change to something that is already established

over a number of forms, then it's often easier to remove the extra files

(commenting out the calls that show them) while you just work on one at a

time.

Polymorphism *can* be done by replacing form events with procedures in a

shared code module. If you pass the form around as Form parameter, then

you can refer to its controls by name. This is a bizarre idea to an OOP

programmer, as the parameter type is that of an abstract form that doesn't

have *any* controls. VB manages it by a strange form of run-time name

binding (with some restrictions at compile (sic) time). This allows most simple

operations to be shared between forms, as each form event only needs an

identical single line call.

You can't refer to form variables from outside the form module. Consider

using text controls (maybe invisible) instead.

Give each form a unique ID number, and store it (during Form_Load) in a

hidden control. This way your magic procedures can tell what they're looking

at, should they need to.

Don't test the magic ID number unless you really need to. Truly generic code

that works for all of them is better.

If you're accessing the fields of a recordset, do it generically. Referring

to fields by name is good, if you can *guarantee* that the names will exist

(be consistent in naming conventions). This is good for stuff that's project

specific, rather than a library of toolbox things that you'll carry from

project to project.

If you can't rely on field names, do it by looping from 0 to

recordset.Fields.Count. Use the .FieldType property when you need to check

the appropriateness of an action.

If you want to use field names, but can't rely on them, then try referring to

fields by index number, and testing the names yourself. I have some

snapshots which have the first 3 to 6 fields as "row headers", chosen from

about a dozen possible names, then up to 30 or so "data" fields which could

be called anything. I access this by using a function that returns the field

number of the first data field. It discovers this by starting from 0 and counting

upwards, until the field name is *not* one of the dozen possible report

header fields. The report viewer then starts from this field (instead of 0)

and loops for the rest of the record.

You can't create a recordset inside a procedure, and return it as a parameter.

Code like this tends to stay inside a form, and works with a form-level

variable.

I have some code that uses a combo box to select which of a number of text

controls are visible. Things like this don't parameterise well as there are

just too many references to controls and form variables.

--

Andy Dingley     Codesmiths of Newcastle

dingbat@codesmth.demon.co.uk


Color shifts in *.hlp

LUOKKA: graphics

6494 (2+)  btcprdtn@aol.com  21.07.95  02:39

BTCPrdtn: "Re: Anyway to lock down colors in .wmf files in help"

About the color switching: There are TWO scenarios to consider, and they

make a big difference in the solution you apply:

1. If you're displaying the graphics using winhelp 3.1 _without_ using any

third-party DLLs, then here's your problem: The winhelp 3.1 help can

display _only_ the 16 standard Windows colors REGARDLESS of whether

your monitor is set to 16 colors or 256 or millions  of colors. To ensure that

your graphics display correctly, change your monitor setting to 16 colors and

redo your graphics using on the standard 16 Windows colors.

2. If you're using a third-party DLL (such as the one provided by

RoboHelp) to display 256-color graphics on 3.1 WinHelp, then you've got

palette problems. Such problems can be affected (notice I don't say

"caused") by limitations of the DLL's palette management (WinHelp is

essentially out of the picture -- it does no palette management), other

programs that have run beforehand (or that you've switched to), video

driver conflicts, and Window's general lack of color saavy. I'm not familiar

with the utility that others have mentioned, but it sounds like it might work

with bitmapped images instead of object-oriented ones like WMF. In any

case, your best bet is to ensure that all graphics that display one after the

other share the same palette. (All graphics in your project don't have to have

the same palette, just the ones that follow one another in being displayed.

But you can't go wrong with one "super palette" for all images.)

For object-oriented images, your surest course is to use a image-editing

program that can import and export custom palettes. Use a single palette,

and avoid blends, gradients, and other special effects that would alter

colors in the palette.

If that doesn't work, consider trying to break out text and graphics. Use

a table to insert a bitmapped, rather than WMF, image and then overlay

text in another table column.

I find bitmaps easier to work with. You'll find several image-editing

programs that can take a batch of bitmapped images and dither them all

down to a single, shared 256-color palette. I use Debabelizer on the Mac

and then transfer to Windows. Perhaps others can suggest Windows

alternatives.

-------------

Frank Elley


Colors & system colors

LUOKKA: color

Date: 07-27-95 (02:08)              Number: 397187 of 397320 (Refer# NONE)

Subj: Re: Problems with 3D pane

From: "Douglas G. Adams" <dgadams@.sandia.gov>

>I put a 3D panel on my form and set the background to a light gray.

>Then, one some machines, when I run my program, the background color of

>the panel changes to white or dark blue. How can I keep the background

>color of the 3d panel from changing?  Is this a bug in the 3D panel?...or a

>*feature*  :)

Set the background of your panel to a "system color" instead of light grey.

I usually set the backgrounds of my panels to the push button face shade

color (&H8000000F&)  if some other applications is using the "light grey"

palet entry you don't care, since windows reserves 20 "system" colors for

itself and this is one of them.  Be aware that the user can change this

color by setting colors in control panel.

__________________________________

Douglas G. Adams

Sandia National Laboratories

Department 5838 M/S 0780

Albuquerque, NM  87185-0780

(505) 844-1609


Colors 16/256?

LUOKKA: color

Date: 12/28/94 (00:12)              Number: 30980 of 31236 (Refer# NONE)

From: JOEO@ZIMMER.CSUFRESNO.EDU

Subj: Re: 16 or 256 colors?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

To find the number of colors the video supports, use the following code:

Const BITSPIXEL = 12

Const PLANES = 14

Declare Function GetDeviceCaps% Lib "GDI" (ByVal hDC%, ByVal nIndex%)

Ret = GetDeviceCaps(Form1.hDC, PLANES) * GetDeviceCaps(Form1.hDC,

BITSPIXEL)

Ret = 2  Monochrome

Ret = 4  16 Colors

Ret = 8  256 Colors

Ret = 24 True Color


Colors 16/256?

LUOKKA: display

Date: 08/03/94 (22:33)              Number: 14288 of 14404 (Refer# NONE)

From: :VMADAN@U.WASHINGTON.EDU

Subj: BJECT:How to determine display characteristics from inside

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

VM>Is there any function or API call that can help me determine whether

VM>the  user has a 16 color display or a 256 color display or more?

Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC As Integer, ByVal

  nIndex As Integer) As Integer

Global Const SIZEPALETTE = &H68  '  Number of entries in physical palette

Form_Load ()

  If GetDeviceCaps(Picture1.hDC, SIZEPALETTE) < 256 Then

    'do some code

  Else

    'do some other code

  End If

End Sub

Regards,     Email:   ian.carter@almac.co.uk

Ian C.       Tel/Fax: (+44)(0)909-773689


Colors 256

LUOKKA: PictureBox

Date: 07/20/94 (15:55)              Number: 12595 of 12618 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: 256 Color in Picture Box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You need to load a 256 color palette.  The manual explains it clearly.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


Colors 256 colors

LUOKKA: color

Date: 01/17/95 (17:31)              Number: 188859 of 191526 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: LINEDRAW and solid colors

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>To my suprise Visual Basic appears to only support 16-32 solid colors even

>with 256 colors as my setting. I use the color requester for requesting

>the user to select the color, but when drawing a line (using windoze api

>functions) I only get what appears on the solid color section of the

>requester.  This means my legend, which shows the proper color, does not

>correspond properly with the picture. Using Pset would be

>unacceptable, as there may be hundreds of thousands of consecutive pixels

>to be redrawn.

>

---- Text deleted -----------------------------------

>

>------------------------------------------------------------------------------

>          Bryan Nippers

>

>     Email: bnippers@fres2.glfc.forestry.ca

>

You can draw with 256 colors in VB. In my opinion the easiest way to do it

is to use DIB files as "palettes" (examples of such files are

bright.dib,pastel.dib and rainbow.dib in VB directory). That way you don't

have to work programmatically with palettes, you can have several them

ready for your use etc.

I have attached a sample program to demonstrate this. It is maybe a little

bit long for a message, but couldn't describe it otherwise the way I wanted.

guess when you study it, you understand what I mean.

I hope this gives you one idea how to draw with 256 colors. If you have

questions concerning this approach, e-mail me. I'll be glad to to help, if I

can.

Lasse

________________

On your form, put a picture box, a label (caption "Lines only") and a

command button (caption "Change Palette").

In a module add following declarations

-----------------------------------------

' structures for defining DIBs

Type BITMAPFILEHEADER

   bfType As String * 2

   bfSize As Long

   bfReserved1 As Integer

   bfReserved2 As Integer

   bfOffBits As Long

End Type

Type BITMAPINFOHEADER '40 bytes

   biSize As Long

   biWidth As Long

   biHeight As Long

   biPlanes As Integer

   biBitCount As Integer

   biCompression As Long

   biSizeImage As Long

   biXPelsPerMeter As Long

   biYPelsPerMeter As Long

   biClrUsed As Long

   biClrImportant As Long

End Type

Type RGBQUAD

   rgbBlue As String * 1

   rgbGreen As String * 1

   rgbRed As String * 1

   rgbReserved As String * 1

End Type

In forms general section add following declarations

----------------------------------------------------

Dim MyBMFileHeader As BITMAPFILEHEADER

Dim MyBMInfoHeader As BITMAPINFOHEADER

Dim MyColors(256) As RGBQUAD

In command1 event procedures add

----------------------------------------

Sub Command1_Click ()

   Static Pass

   Picture1.DrawWidth = 5

   Select Case Pass

      Case 0

         pName$ = "c:™vb™bright.dib"

         Pass = 1

         Label1 = "Palette is " & pName$

      Case 1

         pName$ = "c:™vb™pastel.dib"

         Pass = 2

         Label1 = "Palette is " & pName$

      Case 2

         pName$ = "c:™vb™rainbow.dib"

         Pass = 0

         Label1 = "Palette is " & pName$

   End Select

   Picture1.Picture = LoadPicture(pName$)

   Open pName$ For Binary As #1

   Get #1, , MyBMFileHeader

   Get #1, , MyBMInfoHeader

   For i = 0 To MyBMInfoHeader.biClrUsed

      Get #1, , MyColors(i)

   Next i

   Close #1

   For i = 0 To 15

      bIndex = i * 15

      For k = 0 To 15

         Index = bIndex + k

         nColor = RGB(Asc(MyColors(Index).rgbRed),

Asc(MyColors(Index).rgbGreen), Asc(MyColors(Index).rgbBlue))

         If Check1.Value = 0 Then

            Picture1.Line (i * Picture1.Width / 16 + 20, k * Picture1.Height

/ 16 + 20)-((i + 1) * Picture1.Width / 16 - 20, (k + 1) * Picture1.Height /

16 - 20), nColor, BF

         End If

         Picture1.Line (i * Picture1.Width / 16 + 20, k * Picture1.Height /

16 + 20)-((i + 1) * Picture1.Width / 16 - 20, (k + 1) * Picture1.Height / 16

- 20), nColor

      Next k

   Next i

End Sub


Colors constants

LUOKKA: color

Date: 06/10/94 (03:49)              Number: 8546 of 8618 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Title Bar Colors

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> Has anyone out there found a way to find out what color the title bar of

> the current window is.  I know that this is changable by the user through

> the control panel, and I would like to make one of my controls on the form

> the same color.  Any ideas?

Following from vb3glob.hlp under System Colors:

 System Colors

Global Const SCROLL_BARS = &H80000000           ' Scroll-bars gray area.

Global Const DESKTOP = &H80000001               ' Desktop.

Global Const ACTIVE_TITLE_BAR = &H80000002      ' Active window

caption.

Global Const INACTIVE_TITLE_BAR = &H80000003    ' Inactive window

caption.

Global Const MENU_BAR = &H80000004              ' Menu background.

Global Const WINDOW_BACKGROUND = &H80000005     ' Window

background.

Global Const WINDOW_FRAME = &H80000006          ' Window frame.

Global Const MENU_TEXT = &H80000007             ' Text in menus.

Global Const WINDOW_TEXT = &H80000008           ' Text in windows.

Global Const TITLE_BAR_TEXT = &H80000009        ' Text in caption, size

box, scroll-bar arrow box..

Global Const ACTIVE_BORDER = &H8000000A         ' Active window border.

Global Const INACTIVE_BORDER = &H8000000B       ' Inactive window

border.

Global Const APPLICATION_WORKSPACE = &H8000000C ' Background

color of multiple document interface (MDI) applications.

Global Const HIGHLIGHT = &H8000000D             ' Items selected item in a

control.

Global Const HIGHLIGHT_TEXT = &H8000000E        ' Text of item selected

in a control.

Global Const BUTTON_FACE = &H8000000F           ' Face shading on

command buttons.

Global Const BUTTON_SHADOW = &H80000010         ' Edge shading on

command buttons.

Global Const GRAY_TEXT = &H80000011             ' Grayed (disabled) text.

This color is set to 0 if the current display driver does not support a

solid gray color.

Global Const BUTTON_TEXT = &H80000012           ' Text on push buttons.

so to make control the same color as eg the active window caption

control.backcolor = &H80000002&

control.forecolor = &H80000009&

michael.cowan@almac.co.uk

nottingham, england & europe


Colors show user

LUOKKA: color

2236 (2+)  cstuart@metronet.com  28.12.94  23:20

Chuck Stuart: "Show user available colors"

Sub Form_Activate ()

   Dim Value As Integer

   Dim Delay As Long

   Do While DoEvents()

      Me.Label1.BackColor = QBColor(Value)

      Delay = Timer + 3

      Do

         DoEvents

      Loop Until Timer > Delay

      Value = (Value + 1) * -(Value <> 15)

   Loop

End Sub

Sub Form_Unload (Cancel As Integer)

   'frmAbout = Nothing

   End

End Sub

Sub Command1_Click ()

   Unload Me

End Sub

------------------------------------------------------------------------

Chuck Stuart

Mesquite TX USA


Comlyr

LUOKKA: Access

Date: 06-20-95 (21:19)              Number: 368339 of 370426 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Read Only Database

PSS ID Number: Q113685

Article last modified on 10-05-1994

PSS database name: VBWIN

3.00

WINDOWS

---------------------------------------------------------------------

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 3.0

---------------------------------------------------------------------

SUMMARY

=======

This article lists all the files that come with the Microsoft Access 2.0/

Visual Basic 3.0 Compatibility Layer (also known as the Microsoft Jet

2.0/Visual Basic 3.0 Compatibility Layer). See the "Background Information"

section at the end of this article for more information about the

Compatibility Layer.

MORE INFORMATION

================

Files Included with the Compatibility Layer

------------------------------------------

The Compatibility Layer consists of the following files:

FileName     Size in bytes    Date     Description

--------------------------------------------------------------------

SETUP.EXE      39856          3/24/94  Application that installs the

                                       compatibility layer.

ACC2COMP.TXT   19513          3/24/94  The readme file.

MSAJT112.DLL   17424          3/24/94  The Microsoft Access 2.0

                                       compatibility layer.

VBDB300.DLL    95200          3/24/94  Microsoft Visual Basic to

                                       Access support DLL.

BTRV200.DLL    110592         3/24/94  Btrieve ISAM driver library.

PDX200.DLL     231888         3/24/94  Paradox ISAM driver library.

XBS200.DLL     295712         3/24/94  Microsoft FoxPro ISAM driver

                                       library.

CRWACC20.EXE   13376          3/24/94  Program that modifies Crystal

                                       reports files to work with

                                       Access 2.0 databases.

PDBJET.DLL     96784          3/24/94  Crystal Reports file.

PDCTJET.DLL    68112          3/24/94  Crystal Reports file.

PDIRJET.DLL    71184          3/24/94  Crystal Reports file.

Background Information

----------------------

Visual Basic version 3.0, released in May of 1993, includes support for the

Microsoft Access version 1.1 database engine. This provides Visual Basic

developers the ability to create and distribute royalty-free applications

with Microsoft Access as the underlying database.

Microsoft Access version 2.0 contains a new file format that Visual Basic

version 3.0 cannot access. To provide this capability, Microsoft created

the Microsoft Access 2.0/Visual Basic 3.0 Compatibility Layer. To install

and use the Compatibility Layer, you must have installed both Microsoft

Access version 2.0 and Visual Basic version 3.0. Then the Compatibility

Layer bridges the gap.

Use of the Compatibility Layer is optional. Microsoft Access version 2.0

reads and writes Microsoft Access version 1.1 databases, so Visual Basic-

based applications that use Microsoft Access version 1.1 databases do not

need to be converted even if users upgrade to Microsoft Access version 2.0.

The setup file does not remove the Microsoft Access version 1.1 files, but

Visual Basic will be using the Microsoft Access version 2.0 files, once

setup is run and the appropriate .INI files are edited to point to the new

IISAM driver libraries. Visual Basic-based applications that use Microsoft

Access version 1.1 format databases will continue to operate because

Microsoft Access version 2.0 reads and writes Microsoft Access version 1.1

format databases. Visual Basic-based applications that create Microsoft

Access version 1.1 format databases can continue to do so through the

Microsoft Access version 2.0 files simply by changing a setting. This is

documented in the ACC2COMP.TXT file that comes with the Compatibility

Layer.

Otherwise, check the OPTIONS for the Access DB and Make Sure in the

MultiUser/ODBC option that the Open mode is SHARED and their no record

locking.


Comlyr

LUOKKA: Access

----------------------------------------------------------------

What files to distrib for access 2.0 .mdb (2)

----------------------------------------------------------------

Gareth Jones <gaj@JOLT.MPX.COM.AU>

Wed, 11 Jan 1995 10:14:47 +1100

I've just got Access 2.0, upgraded do 2.5, and installed the

compatibility layer for VB3.0 PRO.

My question is what dll files do I need to distribute with an app to let

it use 2.0 databases? The comlyr.exe txt files were a bit ambiguous. I've

tried using msajt100.dll, 112.dll and 200.dll

These are the files I tried -

COMMDLG  DL_        54,547 05-04-94  12:00a

DDEML    DL_        23,477 28-04-93  12:00a

MSAFINX  DL_        17,426 28-04-93  12:00a

MSAES110 DL_        18,931 28-04-93  12:00a

MSAJT110 DL_       424,588 20-05-93  12:00a

VBDB300  DL_        59,761 24-03-94  12:00a

CTL3D    DL_        11,986 05-04-94  12:00a

MSAJT112 DL_         9,687 24-03-94  12:00a

VER      DL_         9,696 05-04-94  12:00a

SETUPKIT DL_         3,657 28-04-93  12:00a

VBRUN300 DL_       276,684 06-06-94   1:01a

MSAJT200 DL_       617,768 20-11-94  12:00a

It didn't work.

Anyone know what estra files I need?

Gareth Jones

___________________________________________________________

"Gary A. Ferguson" <garyfe@CYBERSPACE.COM>

Tue, 10 Jan 1995 20:27:25 -0800

>My question is what dll files do I need to distribute with an app to let

>it use 2.0 databases? The comlyr.exe txt files were a bit ambiguous. I've

>tried using msajt100.dll, 112.dll and 200.dll

msajt112.dll msajt200.dll, AND the *NEW* VBDB300.DLL

Note that the COMLYR install replaces the old VBDB300.DLL with a new

one, but SAME NAME. So you have to be sure you are putting the correct

one on the distribution disk.

Gary

garyfe@cyberspace.com


Comlyr

LUOKKA: Access

Date: 05-19-95 (04:27)              Number: 335933 of 336686 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Finding substrings in database fields.

From the COMLYR.EXE Readme file.

Table 2.2  Files Needed to Upgrade Visual Basic 3.0

----------------------------------------------------

File            Description

to----------------------------------------------------

MSAJT200.DLL    Version 2.0 Jet database engine

MSAJT112.DLL    Jet Database Engine 2.0/Visual Basic

                3.0 Compatibility Layer

VBDB300.DLL     Visual Basic to Jet database engine support DLL

BTRV200.DLL     Btrieve ISAM driver library

PDX200.DLL      Paradox ISAM driver library

XBS200.DLL      Microsoft FoxPro ISAM driver library

CRWACC20.EXE    Program that modifies Crystal Reports files

                to work with Microsoft Access 2.0 databases

SETUP.EXE       Application that installs the Compatibility Layer

ACC2COMP.TXT    This file

MSAJT200.DLL doesn't come with VB 3.0 and it doesn't come with

COMLYR.EXE. It comes with Access 2.0.

------------------------------------------------------------------------

Chuck Stuart - Mesquite TX USA

http://www.apexsc.com/vb/ftp/coop/cstuart

ftp.apexsc.com/pub/cgvb/coop/cstuart

------------------------------------------------------------------------


Comlyr Acc2comp.t

LUOKKA: Access

                   A C C 2 C O M P . T X T

             Release Notes for Compatibility Layer

    Microsoft Visual Basic (R) 3.0 -- Microsoft Access (R) 2.0

           (C) Copyright Microsoft Corporation, 1994

This document describes the Microsoft Jet Database Engine version

2.0/Visual Basic version 3.0 Compatibility Layer, which enables

VisualBasic version 3.0 and applications created with Visual Basic

version 3.0 to use data stored in Microsoft Access version 2.0

databases.

------------------------

How To Use This Document

------------------------

To view this document on screen using Microsoft Windows Notepad,

maximize the Notepad window.

To print this document, open it using Windows Write, Microsoft

Word, or another word processor. Then select the entire document

and format the text in 10-point Courier font before printing.

--------

Contents

--------

1.  Summary

2.  Installing the Compatibility Layer

3.  Limitations of the Compatibility Layer

4.  Microsoft Jet Database Engine 1.1 Compatibility Issues

5.  Adapting Your .INI Files

6.  Availability of Version 2.0 Jet Database Engine Features

-----------

1. Summary

-----------

Microsoft Access version 2.0 uses a file format for database

(.MDB) files that is different from the format used by Microsoft

Access versions 1.1 and 1.0. Microsoft Visual Basic version 3.0

cannot use databases in Microsoft Access 2.0 format. If you want

to share .MDB format databases between Microsoft Access 2.0 and

Visual Basic 3.0 applications, you must either:

**  Keep the .MDB files in 1.1 format, which both Microsoft

    Access 2.0 and Visual Basic 3.0 can use.

**  Install the Jet Database Engine 2.0/Visual Basic 3.0

    Compatibility Layer included on this disk.

The rest of this document describes the Compatibility Layer.

The files on this disk enable Visual Basic 3.0 (Standard or

Professional Edition) and applications created with Visual Basic

3.0 to use the version 2.0 Jet database engine to read and write

data stored in Microsoft Access 2.0 databases. If your Visual

Basic 3.0 application doesn't use Microsoft Access 2.0 databases,

you won't significantly benefit from using the Compatibility

Layer. If you access remote data through attached tables in

databases that use the Jet database engine, you will benefit, but

you may need to make minor modifications to the application source

code. If you don't have access to the source code, you may want to

reconsider converting to the version 2.0 Jet database engine.

---------------------------------------

2. Installing the Compatibility Layer

---------------------------------------

Before you begin, make backup copies of the existing Visual Basic

3.0 data access files that will be either replaced or modified.

These include the following files.

Table 2.1  Files That Are Replaced or Modified

           by the Compatibility Layer

---------------------------------------------------

File            Description

---------------------------------------------------

VBDB300.DLL     Visual Basic to Jet database engine

                1.1 interface DLL

PDCTJET.DLL     Run-time DLL for Crystal Reports

PDIRJET.DLL     Run-time DLL for Crystal Reports

PDBJET.DLL      Run-time DLL for Crystal Reports

CRW.EXE         Crystal Report Designer application

VB.INI          Visual Basic initialization file

SETUPWIZ.INI    Setup Wizard initialization file

----------------------------------------------------------

NOTE  You may not have all these files on your system; for

example, CRW.EXE is included only in the Professional

Edition of Visual Basic 3.0.

-----------------------------------------------------------

To upgrade your existing Visual Basic 3.0 Standard or Professional

Edition to support the version 2.0 Jet database engine, you need

the following files.

Table 2.2  Files Needed to Upgrade Visual Basic 3.0

----------------------------------------------------

File            Description

----------------------------------------------------

MSAJT200.DLL    Version 2.0 Jet database engine

MSAJT112.DLL    Jet Database Engine 2.0/Visual Basic

                3.0 Compatibility Layer

VBDB300.DLL     Visual Basic to Jet database engine support DLL

BTRV200.DLL     Btrieve ISAM driver library

PDX200.DLL      Paradox ISAM driver library

XBS200.DLL      Microsoft FoxPro ISAM driver library

CRWACC20.EXE    Program that modifies Crystal Reports files

                to work with Microsoft Access 2.0 databases

SETUP.EXE       Application that installs the Compatibility Layer

ACC2COMP.TXT    This file

>>>To install the Compatibility Layer

-------------------------------------

  1. Insert the Compatibility Layer disk into drive A.

  2. From the File menu in the Windows Program Manager or

     File Manager, choose Run.

  3. Type a:setup

  4. Follow the Setup instructions on screen.

Once Setup is complete, you may not need to do to anything else to

your Visual Basic application, unless you've included code for

creating or compacting databases, or code that specifically refers

to version 1.1 installable ISAM drivers. Details on how to deal

with these and other contingencies are discussed in the following

sections.

CRWACC20.EXE is an MS-DOS-based program that enables Crystal

Reports for Visual Basic to work with the version 2.0 Jet database

engine. It modifies the following files:

**  CRW.EXE

**  PDBJET.DLL

**  PDIRJET.DLL

**  PDCTJET.DLL

The program looks for these files in the current directory or in a

directory passed in as part of the command line when it is run. To

modify these files, you must run this program after running Setup.

Once the program has modified the files it is of no further use.

However, you might reinstall Crystal Reports after you install the

Compatibility Layer, so you may want to run the program again

later.

>>>To run CRWACC20.EXE

----------------------

  * At the command prompt, type CRWACC20 <path to CRW.EXE>

    For example, if CRW.EXE is in a VB subdirectory

    called REPORT, you type this:

    CRWACC20 c:\vb\report

If CRWACC20.EXE finds the files in the specified directory, it

modifies them. If you don't specify a path, it looks in the

current directory. When this program modifies a file, the date for

the file is set to the current date.

After you run Setup, examine your VB.INI file for references to

the Jet database engine 1.1 installable ISAM drivers (BTRV110.DLL,

PDX110.DLL, XBS110.DLL). Replace any references to these drivers

with the new Jet database engine 2.0 driver names (BTRV200.DLL,

PDX200.DLL, XBS200.DLL). If you use the Paradox driver

(PDX200.DLL), you must also add the entry "ParadoxNetStyle=3.x" to

the [Paradox ISAM] section of the VB.INI file. In addition, you

need to modify the .INI files of any executable applications

you've created. For example, if you have an application named

BREAD.EXE, you'd have to modify the BREAD.INI file as well. For an

example of new .INI entries, see Section 5, "Adapting Your .INI

Files," later in this document.

You should also change the entries in SETUPWIZ.INI to specify the

new files used in the Compatibility Layer. SETUPWIZ.INI is used

with the Setup Wizard to create distribution disks for your

application. Once you've installed the Compatibility Layer, any

applications you create that perform data access always use the

version 2.0 Jet database engine, even if you're accessing data in

earlier .MDB formats or other file formats. Therefore, whenever

you distribute an application created in Visual Basic 3.0 that

performs data access, you need to include the files listed

previously in Table 2.2. (You're free to distribute these files

with your application.) For an example of new entries for the

SETUPWIZ.INI file, see Section 5, "Adapting Your .INI Files,"

later in this document.

Setup doesn't remove the version 1.1 Jet database engine files

from your Windows System directory. If you have no other

application using those files (such as Microsoft Access 1.1), you

can delete them. As a precaution, however, you may want to rename

them or move them to another directory for a few days before

deleting them to ensure that no other application uses them.

------------------------------------------

3.  Limitations of the Compatibility Layer

------------------------------------------

Although the Compatibility Layer enables your Visual Basic 3.0

applications to read and write data stored in Microsoft Access 2.0

databases, it doesn't give your applications access to all the new

Jet database engine 2.0 objects and features because the existing

Visual Basic 3.0 language doesn't support programmatic access to

these new features.

When your Visual Basic 3.0 application manipulates data in

Microsoft Access 2.0 databases, you'll encounter the following

limitations:

**  New Jet database engine 2.0 errors, which result from

    new database engine behavior, will be returned as unknown

    errors ("Reserved error <error number.>").  The error

    numbers listed in the error messages are version 2.0

    Jet database engine numbers.  To determine the message

    associated with an error number, search for "error codes"

    in Microsoft Access 2.0 Help.

**  Visual Basic version 3.0 doesn't take advantage of any

    of the new Jet database engine 2.0 properties, objects,

    or methods.  See Section 6, "Availability of Version 2.0

    Jet Database Engine Features," at the end of this document

    for a list of major new features and information about

    their accessibility from Visual Basic 3.0 applications.

**  The version 2.0 Jet database engine supports eight new

    collating orders (Arabic, Russian, Czech, Greek, Hebrew,

    Hungarian, Polish, and Turkish), which are unavailable to

    Visual Basic 3.0.  Databases created in any of these

    languages are available in read-only mode only. Data in

    the languages may not sort correctly when accessed by

    Visual Basic.

**  The version 2.0 Jet database engine allows the entry of

    zero-length strings as well as Null values.  Because of

    this, Null values aren't automatically converted to

    zero-length strings when they're entered into version

    2.0  databases.  This may cause some updates to fail

    because of validation rules that require zero-length

    strings, resulting in a message for an unknown error

    ("Reserved error <error number.>").  To fix the error,

    you have to either use Microsoft Access 2.0 to change

    the rule or not enter Null data into the database.

    For more information, see Section 6, "Availability of

    Version 2.0 Jet Database Engine Features."

**  You can't open a dynaset on a remote database (such as a

    SQL Server database) within a transaction using the version

    2.0 Jet database engine. For example, the following code will

    fail as the dynaset is created:

    Dim MyDB As Database, MyDS As Dynaset

    Set MyDB = OpenDatabase("")   ' Open user-selected external

                                  ' database.

    MyDB.BeginTrans               ' Begin transaction.

    ' Open first table.

    Set MyDS = MyDB.CreateDynaset(MyDB.TableDefs(0))

    However, if you attach tables from the remote database to

    a Microsoft Access database, you can create dynasets on

    those tables within transactions. (Note that access to

    remote data is faster if the tables are attached.)

-----------------------------------------------------------

4.  Microsoft Jet Database Engine 1.1 Compatibility Issues

------------------------------------------------------------

When you use the Compatibility Layer to access data in version 2.0

format, you should keep the following issues in mind:

**  Because the Compatibility Layer is uniquely named

    (MSAJT112.DLL), it shouldn't cause any problems with

    applications (such as Microsoft Access 1.1) that use

    the file MSAJT110.DLL. Jet database engine 1.1

    installable ISAM drivers can't be used by the version

    2.0 database engine. If the version 1.1 drivers are

    listed in the [Installable ISAM] section of your

    .INI file, an error will occur when you attempt to

    use your application to access data in any of these

    database formats.

**  Visual Basic 3.0 applications that use the version

    2.0 Jet database engine may be able to update data

    in situations in which they previously could not (for

    example, the "one" side of a one-to-many relationship).

    However, applications can't update data when the change

    would orphan records on the many side of a recordset.

**  For some new SQL reserved words, you must enclose the

    word in brackets ([ ]) if you want to use it as part

    of an identifier (for example, a table or field name)

    in the context of an SQL string.  For a list of the Jet

    database engine 2.0 SQL reserved words, search Microsoft

    Access 2.0 Help for "SQL."

**  By default, the CreateDatabase function and CompactDatabase

    statement now create databases in Jet database engine 2.0

    format. You can override this default behavior by using

    the DB_VERSION10 constant (in the file DATACONS.TXT).  Using

    this constant creates a version 1.1 database, not a version

    1.0 database.  You can't create version 1.0 databases.

    The following table shows which type of database is created

    when you use CreateDatabase and CompactDatabase with and

    without DB_VERSION10.

-----------------------------------------------------------------

Jet database engine   Creates by default      With DB_VERSION10

-----------------------------------------------------------------

Version 1.1           Version 1.1 database    Version 1.0 database

Version 2.0           Version 2.0 database    Version 1.1 database

------------------------------

5.  Adapting Your .INI Files

------------------------------

Your .INI file is used by the Jet database engine to locate driver

files. When you're designing your application, the VB.INI file

contains entries that point to each of the installable ISAM

drivers your application will need. If you're creating an

executable Visual Basic 3.0 program, you'll need to create an .INI

file for the application that also contains these entries. For

example, if your application is named CAT.EXE, you'll need to

create an .INI file called CAT.INI and add the necessary entries.

Shown below is the default [Installable ISAM] section of the

VB.INI file. Although it includes entries for all the installable

ISAM drivers, the .INI file you create for your application may

need only one of these entries. If you use the Paradox driver

(PDX200.DLL), you also need to add a line to the [Paradox ISAM]

section of your .INI files. You don't need to change any of the

other entries in your .INI files.

Default entries for VB.INI and <appname>.INI

------------------------------------------------------------------

[Installable ISAMs]

Paradox 3.X=C:\VB\PDX200.DLL    ;Path of the Paradox 3.x driver

Paradox 4.X=C:\VB\PDX200.DLL    ;Path of the Paradox 4.x driver

FoxPro 2.0=C:\VB\XBS200.DLL     ;Path of the Microsoft FoxPro 2.0

                                 driver

FoxPro 2.5=C:\VB\XBS200.DLL     ;Path of the Microsoft FoxPro 2.5

                                 driver

dBASE III=C:\VB\XBS200.DLL      ;Path of the dBASE III driver

dBASE IV=C:\VB\XBS200.DLL       ;Path of the dBASE IV driver

Btrieve=C:\VB\BTRV200.DLL       ;Path of the Btrieve driver

[Paradox ISAM]

ParadoxNetStyle=3.x             ;Required to open Paradox

databases

---------------------------------------------------------

NOTE   You don't need new ODBC drivers to use the version

2.0 Jet database engine; it works correctly with the ODBC

drivers that were included with Visual Basic version 3.0.

---------------------------------------------------------

In addition, you can adapt SETUPWIZ.INI to accommodate the new

drivers and additional files. You can remove entries for these

files:

**  MSAJT110.DLL

**  MSAES110.DLL

**  XBS110.DLL

**  PDX110.DLL

**  BTRV110.DLL

These are the new entries for SETUPWIZ.INI.

----------------------------------------------------

[ACCESS]                ; Key used by Setup Wizard

                        ; Jet database engine files

file1=MSABC110.DLL

file2=MSAJT200.DLL

file3=VBDB300.DLL

file4=SHARE.EXE:1       ; Jet database engine DLLs require

                        ;  'SHARE.EXE /L:500' in AUTOEXEC.BAT

file5=MSAJT112.DLL

; Files used by the Crystal Report (*.RPT) files

[PDBJET.DLL]

file1=PDBJET.DLL     ; Jet database engine DLL for Crystal Reports

file2=PDIRJET.DLL    ; Jet database engine DLL for Crystal Reports

file3=PDCTJET.DLL    ; Jet database engine DLL for Crystal Reports

file4=MSABC110.DLL   ; Jet database engine DLL for Crystal Reports

file5=MSAJT200.DLL   ; Jet database engine DLL for Crystal Reports

file6=VBDB300.DLL    ; Visual Basic DLL for Crystal Reports

file7=SHARE.EXE:1    ; Jet database engine DLLs require

                     ;  'SHARE.EXE /L:500' in AUTOEXEC.BAT

file8=MSAJT112.DLL   ; Compatibility Layer

-------------------------------------------------------------

6.  Availability of Version 2.0 Jet Database Engine Features

-------------------------------------------------------------

This section lists new features of the version 2.0 Jet database

engine and indicates whether you can take advantage of them in

Visual Basic 3.0 when you use the Compatibility Layer.

Cascading Updates and Deletes

-----------------------------

In Microsoft Access 2.0, you can specify that updates and/or

deletions in referenced fields can be cascaded to all referencing

tables. In Visual Basic 3.0, however, you can't specify cascading

updates or deletes. Consequently, you must use Microsoft Access

2.0 to set this feature. Note that some errors generated from

cascading updates and deletes are returned as reserved errors.

Whenever possible, these new errors are mapped to existing errors.

Table-Level Validation

----------------------

Field- and record-level validation is now maintained by the Jet

database engine. This includes setting table-level validation

rules as well as default values. In Visual Basic 3.0, you can't

set table-level validation rules or default values. Once these

values are set by Microsoft Access 2.0, applications created in

Visual Basic 3.0 will see the results. Violations of table-level

validation rules generate reserved errors.

Zero-Length Strings

-------------------

In Microsoft Access 2.0 databases, you can enter a zero- length

string ("") to indicate data that is known but doesn't exist. A

zero-length string is a string in a Text field containing no

characters; it's not the same as Null. Visual Basic converts all

zero-length strings to Null. There is no way to enter zero-length

strings in Visual Basic 3.0. When table-level validation rules or

default values have been set by Microsoft Access to enforce the

entry of zero-length strings, Visual Basic 3.0 can't enter Null

data into these fields.


Copy files

LUOKKA: files

Date: 10/12/94 (15:26)              Number: 22712 of 22754 (Refer# NONE)

From: CSTUART@METRONET.COM

Subj: Re: Copying Files: pt 2

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>If anyone has suggestions on how to do this, or easier ways to do it

>(*WITHOUT* calling the DOS Copy command!), please let me know. The

>routine needs to be able to copy any file, regardless of whether it's

>text, and executable, etc, without knowing or caring how it is formatted.

In case you don't VBT&T20.

File Copying With Progress Bar

Below is sample code to do a binary file copy process in VB and show the

user the status of the process.

Option Explicit

Sub VisualFileCopy (SourceFileName As String, TargetFileName As String,

ProgressGuage As Control)

   'This routine will copy any size and type of file giving

   'a visual progress indication to the user.  Simply pass

   'the Source Filename, Target Filename, and name of the

   'control to use as a progress guage.  The code below

   'uses a standard Panel3D1 control from THREED.VBX but

   'any control that gives the desired effect may be used.

   'The progress range is 1 to 100 but can be any range.

   Dim I As Integer

   Dim SourceFileNo As Integer

   Dim TargetFileNo As Integer

   Dim SourceFileSize As Long

   Dim CopyBuffer As String

   On Error GoTo FileCopyErrorRoutine

   SourceFileSize = FileLen(SourceFileName)

   CopyBuffer = Space$(25000)    'AS LARGE AS POSSIBLE UNDER 65,000

'--KILL THE CURRENT TARGET FILE IF IT EXISTS

   If Len(Dir$(TargetFileName)) Then

      Kill TargetFileName

   End If

'--OPEN FILES

   SourceFileNo = FreeFile

   Open SourceFileName For Binary Access Read As SourceFileNo

   TargetFileNo = FreeFile

   Open TargetFileName For Binary Access Write As TargetFileNo

'--COPY SOURCE FILE TO TARGET FILE

   For I = 1 To SourceFileSize Ö Len(CopyBuffer)

      Get #SourceFileNo, , CopyBuffer

      ProgressGuage.FloodPercent = I * Len(CopyBuffer) / SourceFileSize *

     100

'UPDATE PROGRESS GUAGE

      Put #TargetFileNo, , CopyBuffer

      DoEvents

   Next I

'--COPY ANY ODD PORTION OF THE SOURCE FILE REMAINING

   CopyBuffer = Space$(SourceFileSize - Loc(TargetFileNo))

   If Len(CopyBuffer) Then

      Get #SourceFileNo, , CopyBuffer

      Put #TargetFileNo, , CopyBuffer

   End If

   Close SourceFileNo

   Close TargetFileNo

Exit Sub

FileCopyErrorRoutine:

   MsgBox Error$

   Exit Sub

End Sub

------------------------------------------------------------------------

Chuck Stuart


Copy files, gauge

LUOKKA: files

Date: 11/28/94 (11:34)              Number: 138361 of 138777 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Copy files...

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

       I need to copy a database file to a temp file and work with

  it....okay...here's the scenario...

       User click on OPEN and open a database, say A.MDB.  I want to copy

  A.MDB to A.TMP and work with that file.

       If user click SAVE, then copy A.TMP over A.MDB.

       If user click SAVE AS, then get the file name, say B.MDB and copy

  A.TMP to B.MDB.

       How would I do this.....?  I guess I'm just looking for file copy

  command in VB.

       This is just my silly way to implementing OPEN, SAVE, SAVE AS for a

  database file that need to be update at run time, but still want to

  preserve the original copy until SAVE or SAVE AS...  Does anyone have any

  suggestion for a more efficient way?

                                          Thanks.....and Happy Thansgiving

                                          Patrick Pruksapong

                                          dragony@engin.umich.edu

I believe I got this code from the FAQ document associated with this list.

I've not had occassion to use it yet, but it looks nice  ;-)

Ross Lambert, Editor

Inside Basic Magazine

===============

Sub VisualFileCopy (SourceFileName As String, TargetFileName As String,

ProgressGuage As Control)

   'This routine will copy any size and type of file giving

   'a visual progress indication to the user.  Simply pass

   'the Source Filename, Target Filename, and name of the

   'control to use as a progress guage.  The code below

   'uses a standard Panel3D1 control from THREED.VBX but

   'any control that gives the desired effect may be used.

   'The progress range is 1 to 100 but can be any range.

   'Submitted by:

   'Chuck Stuart

   'CIS 75650,51

   'AOL WJ5A

   'WJ5A@AOL.COM

   Dim I As Integer

   Dim SourceFileNo As Integer

   Dim TargetFileNo As Integer

   Dim SourceFileSize As Long

   Dim CopyBuffer As String

   On Error GoTo FileCopyErrorRoutine

   SourceFileSize = FileLen(SourceFileName)

   CopyBuffer = Space$(25000)             'AS LARGE AS POSSIBLE UNDER

65,000

'--KILL THE CURRENT TARGET FILE IF IT EXISTS

   If Len(Dir$(TargetFileName)) Then

      Kill TargetFileName

   End If

'--OPEN FILES

   SourceFileNo = FreeFile

   Open SourceFileName For Binary Access Read As SourceFileNo

   TargetFileNo = FreeFile

   Open TargetFileName For Binary Access Write As TargetFileNo

'--COPY SOURCE FILE TO TARGET FILE

   For I = 1 To SourceFileSize   Len(CopyBuffer)

      Get #SourceFileNo, , CopyBuffer

      ProgressGuage.FloodPercent = I * Len(CopyBuffer) / SourceFileSize *

100

 'UPDATE PROGRESS GUAGE

      Put #TargetFileNo, , CopyBuffer

      DoEvents

   Next I

'--COPY ANY ODD PORTION OF THE SOURCE FILE REMAINING

   CopyBuffer = Space$(SourceFileSize - Loc(TargetFileNo))

   If Len(CopyBuffer) Then

      Get #SourceFileNo, , CopyBuffer

      Put #TargetFileNo, , CopyBuffer

   End If

   Close SourceFileNo

   Close TargetFileNo

Exit Sub

FileCopyErrorRoutine:

   MsgBox Error$

   Exit Sub

End Sub


Copy fr. dir to dir

LUOKKA: files

25048 (143+)  balchen@oslonett.no  13.07.95  04:37

Jens Balchen jr.: "Re: ÄQÅ: How to recursively search directories??"

In article <3u0luv$f27@igthost.bis.adp.com>,

slovesm@pcmail.ga.bis.adp.com (Michael F. Sloves) says:

> >I would like to be able to search through a parent directory and all

> >of its subdirectories...

> >The user is able to enter a path and I'd like my program to search

> >through that directory and all of it's subs...

(This routine will copy all the files from one dir to another, but it's

a nice base for further development)

----- COPY.BAS -----

Option Explicit

Global Const ATTR_DIRECTORY = 16

Function CopyFiles (srcPath As String, dstPath As String, IncludeSubDirs As

Integer, FilePat As String) As Integer

' This routine copies all files matching FilePat from scrPath to dstPath.

' If IncludeSubDirs is set to True, all files in subdirs will be incuded

' (and the subdirs themselves of course), like XCOPY /S

Dim DirOK As Integer, i As Integer

Dim DirReturn As String

ReDim d(100) As String

Dim dCount As Integer

Dim CurrFile$

Dim CurrDir$

Dim dstPathBackup As String

   On Error GoTo DirErr

   CurrDir$ = CurDir$

   ' If Path lacks a "Ö", add one to the end

   If Right$(srcPath, 1) <> "Ö" Then srcPath = srcPath & "Ö"

   srcPath = UCase$(srcPath)

   If Right$(dstPath, 1) <> "Ö" Then dstPath = dstPath & "Ö"

   dstPath = UCase$(dstPath)

   dstPathBackup = dstPath

   ' Initialize var to hold filenames

   DirReturn = Dir(srcPath & FilePat, ATTR_DIRECTORY)

   ' Find all subdirs

   Do While DirReturn <> ""

      ' Make sure we don't do anything with "." and "..", they aren't real

files

      If DirReturn <> "." And DirReturn <> ".." Then

         If (GetAttr(srcPath & DirReturn) And ATTR_DIRECTORY) =

ATTR_DIRECTORY Then

            ' It's a dir. Add it to dirlist

            dCount = dCount + 1

            d(dCount) = srcPath & DirReturn

         Else

            ' It's a file. Copy it

            FileCopy srcPath & DirReturn, dstPath & DirReturn

            Frm_Copy!Lbl_CopyInfo.Caption = "Copying " & srcPath &

DirReturn & " to " & dstPath & DirReturn

            Frm_Copy!Lbl_CopyInfo.Refresh

         End If

      End If

      DirReturn = Dir

   Loop

   ' Now do all subs

   For i = 1 To dCount

      ' Check the 'IncludeSubDirs' value. If it's true, we have to make

      ' a dir called 'd(i)' in dstPath, and then assign dstPath & d(i) as

      ' dstPath

      If IncludeSubDirs Then

         On Error GoTo PathErr

         dstPath = dstPath & Right$(d(i), Len(d(i)) - Len(srcPath))

         ' If the Path exists, then this will work out, if not, an error

         ' will be generated and trapped, and the dir will be made

         ChDir dstPath

         On Error GoTo DirErr

      Else

         ' Since we aren't recoursing, we're done

         CopyFiles = True

         GoTo ExitFunc

      End If

      DirOK = CopyFiles(d(i), dstPath, IncludeSubDirs, FilePat)

      ' Reset dstPath to the value assigned at the argument-line

      dstPath = dstPathBackup

   Next

   CopyFiles = True

ExitFunc:

   ChDir CurrDir$

   Exit Function

DirErr:

   CopyFiles = False

   Resume ExitFunc

PathErr:

   ' Didn't find the Dir'ed path

   If Err = 75 Or Err = 76 Then

      Frm_Copy!Lbl_CopyInfo.Caption = "Making directory " & dstPath

      Frm_Copy!Lbl_CopyInfo.Refresh

      MkDir dstPath

      Resume Next

   End If

   GoTo DirErr

End Function

---- COPY.FRM ----

VERSION 2.00

Begin Form Frm_Copy

   BackColor       =   &H8000000F&

   BorderStyle     =   3  'Fixed Double

   Caption         =   "VB Copy"

   ClientHeight    =   1950

   ClientLeft      =   225

   ClientTop       =   1995

   ClientWidth     =   9015

   Height          =   2355

   Left            =   165

   LinkTopic       =   "Form1"

   ScaleHeight     =   1950

   ScaleWidth      =   9015

   Top             =   1650

   Width           =   9135

   Begin CommandButton Command1

      Caption         =   "Copy"

      Height          =   375

      Left            =   240

      TabIndex        =   0

      Top             =   240

      Width           =   1455

   End

   Begin Label Lbl_CopyInfo

      BackColor       =   &H8000000F&

      FontBold        =   0   'False

      FontItalic      =   0   'False

      FontName        =   "MS Sans Serif"

      FontSize        =   8.25

      FontStrikethru  =   0   'False

      FontUnderline   =   0   'False

      Height          =   735

      Left            =   240

      TabIndex        =   1

      Top             =   840

      Width           =   8535

   End

End

Sub Command1_Click ()

   ' Alter this if you want other directories

   R = CopyFiles("c:Öwindows", "c:ÖwindowsÖtemp", False, "*.*")

   If Not R Then

      MsgBox "Error"

   Else

      Lbl_CopyInfo.Caption = "Done"

   End If

End Sub


Copying arrays

LUOKKA: arrays

Date: 05/25/94 (03:55)              Number: 6852 of 6934 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: copying arrays

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 05-23-94 GAT@CSN.ORG  wrote:

G>Jeff B (jjb132@cs.usask.ca) wrote:

G>: Is there a command in Visual Basic to allow you to copy arrays

G>: without copying them element by element -> for example array1() =

G>: array2(), or something like that (that example doesn't actually work).

G>No.

G>gt

See?  One word, AND a monosyllable, at that!  A clone command would be

nice (MS VB4.0 programmers - listen up!), but it doesn't exist in VB

yet.  There are a few techniques that help, though.  The most bovious is

to load information into TWO arrays at the same time, and modify them

both where you currently only change one:

 Array1(x%) = CurrentValue

 Array2(x%) = CurrentValue

Another method is to create an array of user-defined types, such that

each element is a collection of information.  You can copy an entire

collection very easily:

Type NewType

 FirstStr As String * 20

 SecondStr As String * 20

 ThirdStr As String * 20

 ForthStr.....

 FifthStr.....

End Type

Dim Array(20) As NewType

Now, you can treat each element in Array just as you had treated your

entire array in your example above.  Once it is filled in, Array(1) =

Array(2), for instance, will copy ALL of the strings in the 2nd elemment

(FirstStr, Secondstr, etc.) into the 0 element.

Hope this helps.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Credit card validation

LUOKKA: VBgen

-------------------------------  <9507161640.AA27880@netmail2.microsoft.com>

Date:         Sun, 16 Jul 1995 09:02:10 PDT

From: Kenneth Lassesen <kenl@MICROSOFT.COM>

Subject:      FW: Validating Credit Card Format & Length

Here is a function that is pulled from an app that uses this everyday

to validate credit card numbers. This IsMod10 algorithm is a port from

a standard function found in the source of some software on IBM's

nsAS/400 systems. It supposedly works for ALL credit cards.

Private Function IsMod10(ByVal sModNumber As String) As Boolean

    'Declare internal variables

    Dim nModNumberIndex   As Integer

    Dim nMaxNumberLength  As Integer

    Dim nTempIndex        As Integer

    Dim nProduct          As Integer

    Dim nResult           As Integer

    Dim nTemp             As Integer

    'Initize variables

    nTemp = 0

    nProduct = 0

    nMaxNumberLength = 16

    'If the credit number is not the size of the maximum then pad the

    'front of the number with 0s

    sModNumber = String$((nMaxNumberLength - Len(sModNumber)), "0") &

sModNumber

    'Create mod product for 16 digit number

    For nModNumberIndex = 1 To nMaxNumberLength

        'Determine if indexed number is even

        If nModNumberIndex Mod 2 = 0 Then

            nProduct = nProduct + Val(Mid(sModNumber, nModNumberIndex, 1))

        Else

            nTemp = Val(Mid(sModNumber, nModNumberIndex, 1)) * 2

            For nTempIndex = 1 To Len(CStr(nTemp))

                nProduct = nProduct + Val(Mid(nTemp, nTempIndex, 1))

            Next

        End If 'is even number

    Next 'Calculate the product value

    'Get next highest number ending in 0 based on nProduct (ex.

nProduct = 9 next would be 10)

    nTemp = nProduct

    If nTemp Mod 10 = 0 Then

        nn10

    Else

        Do While nTemp Mod 10 <> 0

            nTemp = nTemp + 1

        Loop

    End If

'If the first number in the nResult is a 1 then MOD 10 is true

    nResuemp - nProduct

    If Val(Mid(nResult, 1, 1)) = 1 Then

        IsMod10 = True

    Else

        IsMod10 = False

    End If

End Function


Ctl3D

LUOKKA: 3d

Date: 08/16/94 (10:11)              Number: 15751 of 15821 (Refer# NONE)

From: BWILCOX@EARTH.EXECPC.COM

Subj: How does one use CTL3D.DLL?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

D>awilk@tuzo.erin (Any Wilk) writes:

D>>       I have heard from a number of people that a file named CTL3D.DLL

D>> can be used to give message boxes and dialogs a "3-D" look. But I

can't

D>> seem to find any instructions on how to implement the DLL using VB (I

D>> have 3.0 pro if that makes a difference). Could someone please tell me

D>> where I can find information about it.

Here is what I use to implement CTL3D.DLL.

It is from VB Programmer's Journal Vol 4, Nr.5.

I modified the code to make it work either in the

VB environment or in the compiled EXE.

Put this code in a .BAS module in your project.

' =========================================================

' The code in this module gives all your dialog boxes a 3-D look.

' Call the Make3D function to activate the 3-D effect.

'     In Form_Load:

'                success& = Make3D()

'  Call the UnMake3D Sub to remove the effect.  (if you don't,

'   your program will CRASH!)

'     In Form_Unload:

'              UnMake3d

' If you distribute your program, be sure to distribute

' CTL3D.DLL with it.

'

' Derived from VB Programmer's Journal Vol 4, Nr.5

' ==========================================================

DefInt A-Z

Declare Function CTL3DRegister Lib "CTL3D.DLL" (ByVal hInstapp)

Declare Function CTL3DUnRegister Lib "CTL3D.DLL" (ByVal hInstapp)

Declare Function CTL3DAutoSubClass Lib "CTL3D.DLL" (ByVal hInstapp)

Declare Function GetModuleHandle Lib "Kernel" (ByVal module$)

Global hInstance

Function Make3D () As Integer

' get the program's Instance

    hInstance = GetModuleHandle("VB")      ' see if in VB environment

    If hInstance = 0 Then                  'if not, get application's handle

        hInstance = GetModuleHandle(App.EXEName & ".EXE")

    End If

    If hInstance Then

    ' register the program with CTL3D.DLL

        success = CTL3DRegister(hInstance)

    ' Make all dialog boxes 3-D

        success = CTL3DAutoSubClass(hInstance)

    End If

    Make3D = success

End Function

Sub UnMake3d ()

    If hInstance Then

        success = CTL3DUnRegister(hInstance)

    End If

End Sub

-Bob Wilcox

bwilcox@execpc.com


Ctl3D

LUOKKA: 3d

Date: 08/24/94 (18:24)              Number: 16844 of 16870 (Refer# NONE)

From: DVANDERR@ORACLE.COM

Subj: Re: How does one use CTL3D.DLL?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <CuHnpx.15y@zimmer.CSUFresno.EDU>

skresal@mondrian.CSUFresno.EDU (Shawn Kresal) writes:

      I always comment out the form's load  and unload

   CTL3D code until I'm going to compile the EXE file, then I have VB

   create the EXE, then I re-comment the ctl3d code and run the EXE

   file so I can see how it looks.  Seems like a lot of trouble but

   its better than a gpf every 3 minutes. (not that I compile that

   often, I'm just illustrating a point)

a much easier way is to just modify the code to check to see if it's

running itself:

   Sub Form_Load ()

           Inst% = GetModuleHandle(app.Path + " " + app.EXEName + ".EXE")

           If Inst > 32 Then

                   ret = Ctl3dRegister(Inst%)

                   ret = Ctl3dAutoSubclass(Inst%)

           End If

   End Sub

   Sub Form_Unload (Cancel As Integer)

           Inst% = GetModuleHandle(app.Path + " " + app.EXEName + ".EXE")

           If Inst > 32 Then

                   ret = Ctl3dUnregister(Inst%)

           End If

   End Sub


Ctl3D

LUOKKA: 3d

Date: 08/27/94 (10:50)              Number: 17394 of 17472 (Refer# NONE)

From: NII@WORLD.STD.COM

Subj: Re: How does one use CTL3D.DL

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <33qgjn$qv9@kantti.Helsinki.FI>,

Tuomas M J Salste <salste@cc.Helsinki.FI> wrote:

>: You can also put code in your program to detect if it's being run in the VB

>Is there a convenient way to detect if it's an EXE? My solution was to

What I use:

-----

' 3D stuff

'

Declare Function GetModuleHandle Lib "Kernel"

                (ByVal lpModuleName As String) As Integer

Declare Function Ctl3dRegister Lib "CTL3DV2.DLL"

                (ByVal hInstance As Integer) As Integer

Declare Function Ctl3dAutoSubClass Lib "CTL3DV2.DLL"

                (ByVal hInstance As Integer) As Integer

Declare Function Ctl3dUnregister Lib "CTL3DV2.DLL"

                (ByVal hInstance As Integer) As Integer

'

Sub Setup3D (onoff As Integer)

    ' 3d-look inits

    ' Find the EXE of this app, if it's running as such; else go away

    '

    Dim inst As Integer

    inst = GetModuleHandle(App.EXEName & ".EXE")

    If inst = 0 Then Exit Sub

    ' Turn on/off the 3d subclassing...

    .

    Dim junk As Integer

    If onoff Then

        junk = Ctl3dRegister(inst)

        junk = Ctl3dAutoSubClass(inst)

    Else

        junk = Ctl3dUnregister(inst)

    End If

End Sub

-----

-scott


Ctl3d

LUOKKA: 3d

Date: 10/31/94 (02:39)              Number: 25236 of 25315 (Refer# NONE)

From: JOHN@J-Q-L.DEMON.CO.UK

Subj: Re: 3D VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I remember a while ago someone was kind enough to post some code

>which would give VB apps a 3D look by running something in the startup

>(THREED or CTRL3D) or something. I remember it wouldn't work in VB

>design mode but would in an ..exe ( they provided some code to check for >

this).

'Place all this code in the .BAS module

Declare Function Ctl3dAutoSubclass Lib "CTL3D.DLL" (ByVal hInst%) as

Integer

Declare Function Ctl3dRegister Lib "CTL3D.DLL" (ByVal hInst%) as Integer

Declare Function Ctl3dUnregister Lib "CTL3D.DLL" (ByVal hInst%) as Integer

Declare Function GetModuleHandle Lib "Kernel" (ByVal ModuleName$) as

Integer

Sub ThreeD_Set ()

'Call this sub to set the 3D effect

'Do NOT declare instance as static or global

Dim ret as Integer, instance as Integer

 instance% = GetModuleHandle("ProgName.exe")

 ret% = Ctl3dRegister(instance%)

 ret% = Ctl3dAutoSubclass(instance%)

End Sub

Sub ThreeD_UnSet ()

'Call this sub to clear the 3D effect

'Do NOT declare instance as static or global

Dim ret as Integer, instance as Integer

 instance% = GetModuleHandle("ProgName.exe")

 ret% = Ctl3dUnregister(instance%)

End Sub

Notes:

CTL3D.DLL works on message boxes and Common Dialog boxes. You should

set the 3D effect before calling the message box and *release* the 3D

effect straight after i.e.

 ThreeD_Set

 MsgBox "This is a Message", MB_ICONINFORMATION

 ThreeD_UnSet

 ...

 or

 ThreeD_Set

 myform.CMDialog1.Action = 1

 ThreeD_UnSet

 ...

if you don't you can get spurious errors and GPFs.

You may also wish to check if the 3D effect is already set before setting

it again.

Also there are various versions of CTL3D.DLL which are *not* compatible

with each other so always ship your version with your program and place

it in the program directory *not* in the SYSTEM directory.

Microsoft have released a new version of CTL3D.DLL called CTL3DV2.DLL

which is at ftp.microsoft.com. This version *must* be placed in the

SYSTEM directory otherwise an error is flagged, but it stops the

incompatibility problem. To use it change the Declarations to

"CTL3DV2.DLL" instead of "CTL3D.DLL"

Hope this helps.

--

John Q. Lavelle              Phone/Fax    :           01900 870833

63 Senhouse Street           International:        +44 1900 870833

Siddick, Cumbria             CompuServe   :             73062,2642

United Kingdom, CA14 1LB     Internet     : John@J-Q-L.demon.co.uk


Ctl3d & Ctl3dv2

LUOKKA: 3d

Date: 07-18-95 (20:43)              Number: 390184 of 391297 (Refer# NONE)

From: Ian Davis <idavis@SWALLOW.COM>

CTL3D.DLL was originally released by Microsoft into the Public Domain to

show developers how 3D effects could be created easily. The developers

then seized upon the source code supplied with the release and modified it to

suit their own needs. Hence hundreds of versions of CTL3D.DLL appeared,

all of them slightly different. Microsoft then released CTL3DV2.DLL and kept

the source code private. CTL3D2.DLL is useful because it is a fixed entity

and can be relied upon to work. Also it must only be installed in one

directory on your PC (usually WINDOWS™SYSTEM). An error message

'CTL3DV2.DLL not installed properly' appears if the DLL is found in the

application direcory and the system directory.


Ctl3D in controls

LUOKKA: 3d

Date: 04-03-95 (20:29)              Number: 282185 of 283554 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: ReŽ4�: Ctl3D in controls?.

Declare Function Ctl3dSubclassCtlEx% Lib "CTL3D.DLL" (ByVal hWnd%,

ByVal   ct%)

' hWnd = text1.hWnd, etc.

' ct = control_types

Const CTL3D_BUTTON_CTL = 0

Const CTL3D_LISTBOX_CTL = 1

Const CTL3D_EDIT_CTL =  2

Const CTL3D_COMBO_CTL = 3

Const CTL3D_STATIC_CTL = 4

---------------------------------------------------------------------

Shiva Shenoy           Aerospace Engineering and Engineering Mechanics

shenoy@iastate.edu                     2019 Black Engineering Building

http://www.public.iastate.edu/~aeem/             Iowa State University

Office:  (515)296-7640                           Ames, Iowa 50011, USA


Ctl3d on forms

LUOKKA: 3d

18401 (40+)  dubuque@max.tiac.net  23.05.95  22:48

Peter Dubuque: "Re: Can I use CTL3D.DLL directly to achieve 3D effects"

Well, that's almost right.  There is no way to use CTL3D.DLL for 3D

controls on forms.  However, while it's not documented in the MS Knowledge

Base, you *can* in fact use CTL3D.DLL for the 3-D look on any form that

has a fixed-double border style.  I don't know who posted this

originally, but I saw it here about three weeks ago or so.

In a code module, enter the following (function declarations all on one

line, natch):

Global Const SWW_HPARENT = -8

Global Const GWW_HINSTANCE = -6

Global Const GWW_HPARENT = -8

Global Const BUTTON_FACE = &H8000000F

Global Const FIXED_DOUBLE = 3

Global Const DS_MODALFRAME = &H80&

Global Const GWL_STYLE = (-16)

Declare Function Ctl3DSubClassDlgEx% Lib "CTL3D.DLL" (ByVal hWnd%,

ByVal Flags&)

Declare Function GetWindowLong& Lib "USER" (ByVal hWnd%, ByVal

nIndex%)

Declare Function SetWindowLong& Lib "USER" (ByVal hWnd%, ByVal

nIndex%, ByVal dwNewLong&)

Sub Ctl3DForm (frm As Form)

    Dim hWnd%, iResult%, lstyle&, Flag1&

    hWnd = frm.hWnd

    Flag1 = 0

    If frm.BorderStyle = FIXED_DOUBLE Then

        frm.BackColor = BUTTON_FACE

        lstyle = GetWindowLong(hWnd, GWL_STYLE)

        lstyle = lstyle Or DS_MODALFRAME

        lstyle = SetWindowLong(hWnd, GWL_STYLE, lstyle)

        iResult = Ctl3DSubClassDlgEx(hWnd, Flag1)

    End If

End Sub

Set the BorderStyle property in any form you want to appear in 3D to

3 - Fixed Double, and set both the MaxButton and MinButton properties to

false.  Then, in the various Form_load subs, insert the line

    Call Ctl3DForm(Me)

That's it.  It works beautifully, and unlike the Ctl3DRegister() and

Ctl3DUnregister() functions used for MsgBox and dialog box 3D effects, won't

cause stack faults left and right.

That being said, you'd get *much* better results from using the

VBCTL3D.VBX

control, and at only $29 it's well worth it.

--

Peter F. Dubuque - dubuque@max.tiac.net - Enemy of Reason(TM)


Ctl3d use it ok!

LUOKKA: 3d

Date: 05/15/94 (11:08)              Number: 6348 of 6460 (Refer# NONE)

From: TAYLOR@SATURN.BROOKS.AF.MIL, William D. Taylor

Subj: Re: 3-D Dialogs

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>>         VBPJ in the Q&A column has information on using CTL3D.DLL

>>         to make your dialog boxes appear with 3-D effects.

>>         I put both lines in my pgm and rem'd out the 2nd one for testing

>>         in design mode.

>Is there any VB system flag which can be tested to do this auotmatically ?

I haven't seen the original code referred to in the post, but the following

code works in both design mode and with the executable:

Global Const GCW_HMODULE = (-16)

Declare Function GetClassWord% Lib "User" (ByVal hWnd%, ByVal nIndex%)

Declare Function Ctl3dAutoSubClass% Lib "Ctl3D.DLL" (ByVal hInst%)

Declare Function Ctl3dRegister% Lib "Ctl3D.DLL" (ByVal hInst%)

Declare Function Ctl3dUnRegister% Lib "Ctl3D.DLL" (ByVal hInst%)

Form_Load()

    Dim Inst%, i

    Inst% = GetClassWord(hWnd, GCW_HMODULE)

    i = Ctl3dRegister(Inst%)

    i = Ctl3dAutoSubClass(Inst%)

End Sub

Form_Unload()

    Dim Inst%, i

    Inst% = GetClassWord(hWnd, GCW_HMODULE)

    i = Ctl3dUnRegister(Inst%)

End Sub

Ätaylor@saturn.brooks.af.milÅ


Ctl3d/Ctl3dv2 lue!

LUOKKA: 3d

Date: 04-02-95 (22:26)              Number: 281095 of 282177 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Using CTL3D.DLL and CTL3DV2.DLL with VB

Actually, it's NOT impossible.  The May issue of "VB Systems Journal"

provides code to accomplish just this.  The code provided below not only

makes the form 3D, but also the controls on the form.  We are providing the

code free of charge in order to demonstrate the types of solutions offered

by "VB Systems Journal."  In the same issue we also provide code for

creating tabbed dialog boxes (without VBXs); an article on how to read the

PC game port (using a provided DLL with full source code) and how to use it

for data acquisition; code for a virtual list box (no 64K limit) for use

with database files; and many other

To use the CTL3D (or CTL3DV2) DLL files with Visual Basic forms, simply add

the code listed at the end of this article to a module and include it in

your VB program. (NOTE: Wrapped lines may have to be edited if carriage

returns are present.)

In order to use the code successfully, the following procedure has to be

followed precisely:

1) In the Form_Load() event of the FIRST form that gets loaded, add the

following code:

         h% = Me.hWnd

         RegisterForm3D h%

         Form3D Me

2) In the Form_Unload() event of the LAST form to get unloaded, add the

following code:

         h% = Me.hWnd

         UnregisterForm3D h%

IT IS VERY IMPORTANT that the UnregisterForm3D sub be called before

your program ends.  Otherwise a General Protection Fault will result.  This

means that if the 'End' item is selected from the 'Run' menu (or from the

toolbar) in the Visual Basic development environment, a GPF will result, since

the Form_Unload() event is not called.  Any other action that terminates the

program abnormally, and prevents the Form_Unload() event from occurring,

will also yield a GPF.  There is nothing abnormal here.  These same rules

apply when using CTL3D.DLL for common dialog boxes.  However, because

of this behavior, it is best to leave the 3D embellishments to last, after the

majority of debugging is out of the way.

3) To make a form 3D, simply add the following code to the Form_Load()

event

of any form you want to appear 3D:

        h% = Me.hWnd

        RegisterForm3D h%

        Form3D Me

Before the controls will appear 3D, the form's AutoRedraw property must be

set to "True".  Since AutoRedraw uses memory to retain a bitmap image of

the form, a more desirable method may be to put the appropriate code in the

form's Paint event.

NOTE: In order to use CTL3DV2.DLL, the appropriate substitutions must be

made where CTL3D.DLL appears in the following code.

---------------------------------------------------------------------------

Global Const DS_MODALFRAME = &H80&

Global Const FIXED_DOUBLE = 3

Global Const GWL_STYLE = -16

Global Const GWW_HINSTANCE = -6

Global Const LIGHTGRAY = &HC0C0C0

Global Const DARKGRAY = &H808080

Global Const BLACK = &H0&

Global Const WHITE = &HFFFFFF

Declare Function GetWindowLong& Lib "User" (ByVal hWnd%, ByVal

nIndex%)

Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal

nIndex%)

Declare Function SetWindowLong& Lib "User" (ByVal hWnd%, ByVal

nIndex%, ByVal dwNewLong&)

Declare Function Ctl3DAutoSubclass% Lib "CTL3D.DLL" (ByVal hInst%)

Declare Function Ctl3DSubclassDlgEx% Lib "CTL3D.DLL" (ByVal hWnd%,

ByVal Flags&)

Declare Function Ctl3DRegister% Lib "CTL3D.DLL" (ByVal hInst%)

Declare Function Ctl3DUnregister% Lib "CTL3D.DLL" (ByVal hInst%)

Sub Form3D (frm As Form)

    Dim h%

    Dim x%

    Dim dwNewLong&

    h% = frm.hWnd

    If frm.BorderStyle = FIXED_DOUBLE Then

        frm.BackColor = LIGHTGRAY

        dwNewLong& = GetWindowLong(h%,L_STYLE)

        dwNewLong& = dwNewLong& Or DS_MODALFRAME

        dwNewLong& = SetWindowLong(h%, GWL_, dwNewLong&)

        x% = Ctl3DSubclassDlgEx(h%, 0)

    Else

        Beep

        MsgBox "BorderStyle must be set to FIXED_DOUBLE (3)", 0, "CTL3D

Error"

        h% = frm.hWnd

        UnregisterForm3D h%

        End

    End If

    For n% = 0 To frm.Controls.Count - 1

        If TypeOf frm.Controls(n%) Is TextBox Then Control3D frm,

frm.Controls(n%)

        If TypeOf frm.Controls(n%) Is ListBox Then Control3D frm,

frm.Controls(n%)

        If TypeOf frm.Controls(n%) Is ComboBox Then Control3D frm,

frm.Controls(n%)

        If TypeOf frm.Controls(n%) Is FileListBox Then Control3D frm,

frm.Controls(n%)

        If TypeOf frm.Controls(n%) Is DriveListBox Then Control3D frm,

frm.Controls(n%)

        If TypeOf frm.Controls(n%) Is DirListBox Then Control3D frm,

frm.Controls(n%)

        If TypeOf frm.Controls(n%) Is HScrollBar Then Control3D frm,

frm.Controls(n%)

        If TypeOf frm.Controls(n%) Is VScrollBar Then Control3D frm,

frm.Controls(n%)

    Next n%

End Sub

Sub Control3D (frm As Form, ctl As Control)

    xp& = Screen.TwipsPerPixelX

    yp& = Screen.TwipsPerPixelY

    frm.ForeColor = DARKGRAY

    frm.Line (ctl.Left - xp&, ctl.Top + ctl.Height - yp&)-(ctl.Left - xp&,

ctl.Top - yp&)

    frm.Line -(ctl.Left + ctl.Width + xp&, ctl.Top - yp&)

    frm.ForeColor = WHITE

    frm.Line (ctl.Left - xp&, ctl.Top + ctl.Height)-(ctl.Left + ctl.Width,

ctl.Top + ctl.Height)

    frm.Line -(ctl.Left + ctl.Width, ctl.Top - yp& * 2)

End Sub

Sub RegisterForm3D (h%)

    Dim hInstance%

    Dim x%

    hInst = GetWindowWord(h%, GWW_HINSTANCE)

    x% = Ctl3DRegister(hInstance%)

    x% = Ctl3DAutoSubclass(hInstance%)

End Sub

Sub UnregisterForm3D (h%)

    Dim hInstance%

    Dim x%

    hInstance% = GetWindowWord(h%, GWW_HINSTANCE)

    x% = Ctl3DUnregister(hInstance%)

End Sub

'---------------------------------------------------------------------------

' SUBSCRIBE TO "VB Systems Journal"

' Only $39.95 U.S. per year (12 feature-packed issues)

' Overseas: Add $15. U.S. for international airmail

' Send cheque or money-order to:

' VB Systems Journal

' 800 Lasalle Blvd

' Suite 105

' Sudbury, ON P3A 4V4

' email: vbsj@mcd.on.ca

'---------------------------------------------------------------------------


Ctrls lining up

LUOKKA: VBgen

Date: 07-26-95 (19:29)              Number: 396789 of 397320 (Refer# NONE)

Subj: Re: ReŽ2�: Have a second?

From: Kenneth Lassesen <kenl@microsoft.com>

Sub LineUpControls (CTL as Control,fReset%, Byval Spacing&)

Static T&,L&,S& '& because of SCALEMODE issues

If fReset% Then

        S&=Spacing&

        T&=Ctl.Top+  Ctl.height + S&

        L&=Ctl.Left

Else

        Ctl.Top=T&

        Ctl.Left=L&

        T&=T&+  Ctl.height + S&

End If

End Sub

Now the code is simple:

        LineUpControls Text1, TRUE, 120

        LineUpControls Text2, False,False

        LineUpControls ListBox1, False,False

Or even simple to line up n labels and text boxes

LineUpControls Text1(0), TRUE, 120

For i%=1 to Text1Limit%

        LineUpControls Text1(i%), False,False

Next i%

LineUpControls Caption1(0),True, 120

For i%=1 to Text1Limit%

        LineUpControls Caption1(i%), False,False

Next i%

        Ken

PS: I almost always fill list box with functions like ....

        Sub MYCUSTOMER_FillLstBox(CTL As Control)

If I need to do it on 4 different forms, I have one procedure only.....


Cursor control

LUOKKA: mouse

1413 (15+)  cstuart@metronet.com  24.01.95  23:05

Chuck Stuart: "Re: How to restrict mouse movement?"

>  I'm looking for a way to restrict the mouse cursor to whatever

>coordinates I need.  Are there api calls or a 3rd party thing I can use

>to accomplish this?  Thanks!

'----REQUIRED TO POSITION MOUSE FROM CODE

     Declare Sub ClipCursor Lib "User" (lpRect As Any)

     Declare Sub SetCursorPos Lib "User" (ByVal X As Integer, ByVal Y As

Integer)

     Type RECT

          Left As Integer

          Top As Integer

          Right As Integer

          Bottom As Integer

     End Type

     Global CursorRectangle As RECT

Sub SetMouseLocation (X, Y)

'----SET CURSOR POSITION

     CursorRectangle.Left = X ™ 15

     CursorRectangle.Right = X ™ 15

     CursorRectangle.Top = Y ™ 15

     CursorRectangle.Bottom = Y ™ 15

     ClipCursor CursorRectangle

     SetCursorPos 0, 0

'----RESTORE MOUSE AREA TO FULL SCREEN

     CursorRectangle.Top = 0

     CursorRectangle.Left = 0

     CursorRectangle.Right = Screen.Width ™ 15

     CursorRectangle.Bottom = Screen.Height ™ 15

     ClipCursor CursorRectangle

End Sub

my note: 15=twipsperpixel

------------------------------------------------------------------------

Chuck Stuart

Mesquite TX USA


Cursor custom

LUOKKA: mouse

Date: 06/27/94 (10:17)              Number: 10724 of 10897 (Refer# NONE)

From: MEDVED@NETCOM.COM

Subj: Re: Custom Cursor

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Option Explicit

' Demo by Pierre Fillion (c) 1993 by Synetics Consultation

' Version 1.1 - 1993/05/10

' (FEEL FREE TO DISTRIBUTE THE ENTIRE ARCHIVE ONLY WITHOUT

MODIFICATIONS)

' I don't ask for any contributions, you may use theses routines freely

' but, it you release a .vbx or shareware routines, it would be nice

' to send me a registred copy.

' %%% Special thanks to David Sainsbury for the main routines

' %%% Very Special thanks to Fred Egger for his help to my color problem

'       Any suggestions ? or improvments ?

'       Please drop me a line on CIS 71162,51

'       or to :

'                Pierre Fillion

'                8460 Perras #1

'                Montreal,Quebec

'                H1E 5C7

'  Thanks a lot.

'------------------------------------------------------------------------

' Follow theses steps...

'------------------------------------------------------------------------

' Simply add the cursor.bas module to your project.

' Create a picture box (32x32 pixel) for the cursor and an inverted

' picture box of the first one. (See the .ico included with this demo)

' -- Use IconWorks that comes with VB or anyother, to create your pictures.

' -- Don't forget to had a light red pixel to define a hotspot in the icon.

' ******************************* NOTICE ********************************

' ******* (The inverted picture is the original one with white color

' *******  changed to screen color and everything else to white)

' ***********************************************************************

' Use the SetCursor to create the cursor,

' Use RestoreCursor to restore it back to what it was.

'------------------------------------------------------------------------

' Function SetCursor (hWnd As Integer, CursorPic As Control,

'                                      CursorPicX As Control) As Integer

' -- hWnd : Handle of the window or control where the cursor will change.

' -- CursorPic  : Name of the control holding the icon previously created.

'                 Ex:(Picture1)

' -- CursorPicX : Name of the control holding the inverted icon of CursorPic.

'                 Ex:(Picture2)

' Return the handle of the new cursor to be used in RemoveCursor.

' (This routine will call the hotspot routine to find the light red pixel

'  position in CursorPic and set the hotspot.)

'------------------------------------------------------------------------

' Sub RestoreCursor (hWnd As Integer, OldCursor As Integer)

' -- hWnd : Handle of the window or control specified in SetCursor

' -- OldCursor : Variable containing the handle returned by SetCursor

'==========================================================

'------------------------------------------------------------------------

'CURSOR.BAS Declarations

'------------------------------------------------------------------------

Declare Function GlobalLock Lib "Kernel" (ByVal hMem As Integer) As Long

Declare Function GlobalUnLock Lib "Kernel" (ByVal hMem As Integer) As

Integer

Declare Function CreateCursor Lib "User" (ByVal hInstance%, ByVal

nXhotspot%, ByVal nYhotspot%, ByVal nWidth%, ByVal nHeight%, ByVal

lpANDbitPlane As Any, ByVal lpXORbitPlane As Any) As Integer

Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal

  nIndex As Integer) As Integer

Declare Function SetClassWord Lib "User" (ByVal hWnd As Integer, ByVal

nIndex As Integer, ByVal nNewWord As Integer) As Integer

Declare Function GetClassWord Lib "User" (ByVal hWnd As Integer, ByVal

nIndex As Integer) As Integer

Declare Function GetBitmapBits Lib "Gdi" (ByVal hBitmap As Integer, ByVal

dwCount As Long, ByVal lpbits As String) As Long

Global Const GCW_HCURSOR = -12

Global Const GWW_HINSTANCE = -6

Sub GetHotSpot (CursorPic As Control, xhs As Integer, yhs As Integer)

    yhs = 14

    xhs = 15

    Exit Sub

    Dim Ret As Long

    Dim lpbits As String * 1024

    Dim bits As Integer

    'Retrieve the cursor bits to check for the hotspot (x,y)

    CursorPic.Visible = True

    CursorPic.Refresh

    bits = Val(CursorPic.Image)

    Ret = GetBitmapBits(bits, 1024, lpbits)

    CursorPic.Visible = False

    yhs = 0

    xhs = 0

    'Find the red pixel x,y position for hotspot location

    For bits = 1 To 1024

        Ret = Asc(Mid$(lpbits, bits, 1))

        If (bits Ö 32) = 13 Then

          bits = bits

        End If

        If Mid$(lpbits, bits, 1) = "¨" Then

            yhs = Int(bits / 32) + 1

            xhs = bits - ((yhs - 1) * 32)

        End If

    Next bits

End Sub

Sub RestoreCursor (hWnd As Integer, OldCursor As Integer)

    Dim Ret As Integer

    Ret = SetClassWord(hWnd, GCW_HCURSOR, OldCursor)

    OldCursor = 0

End Sub

Function SetCursor (hWnd As Integer, CursorPic As Control, CursorPicX As

  Control) As Integer

    Dim ghInstance As Integer

    Dim lpand As Long, lpandx As Long

    Dim Ret As Integer

    Dim hNewCursor As Integer

    Dim hotx As Integer

    Dim hoty As Integer

    'Set the hotspot by retrieving the location of the first

    'picture containing the red pixel

    Call GetHotSpot(CursorPic, hotx, hoty)

    'CursorPic  is a picture box control with a 32x32 pixels mono bitmap

    'CursorPicX is an inverted picture box control of the first CursorPic

    'The First Picture must contain a light red dot for the hotspot position

    '(The CursorPicX is created to allow white & background to be defined ok)

    '(Refer of the .ico files incloded to see how to do it for other cursors)

    'hWnd is the handle of the window or control to apply the new cursor to

    'Retreive window or control instance and pictures adresses

    SetCursor = GetClassWord(hWnd, GCW_HCURSOR)

    ghInstance = GetWindowWord(hWnd, GWW_HINSTANCE)

    lpand = GlobalLock(CursorPic.Picture)

    lpandx = GlobalLock(CursorPicX.Picture)

    'Set the cursor

    hNewCursor = CreateCursor(ghInstance, hotx, hoty, 32, 32, lpand + 12,

      lpandx + 12)

    'Free memory

    Ret = GlobalUnLock(CursorPic.Picture)

    Ret = GlobalUnLock(CursorPicX.Picture)

    'Apply the cursor to the window or control defined by hWnd

    Ret = SetClassWord(hWnd, GCW_HCURSOR, hNewCursor)

End Function


Cursor custom

LUOKKA: mouse

Date: 06/30/94 (23:20)              Number: 10810 of 10897 (Refer# NONE)

From: ANDERS.GIDLXF@ITAB.CT.SE

Subj: Custom Cursor

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

 > From: us321829@mmm.com (Christopher Wetzel)

 >  Is there a way to do custom cursors (one's I draw)?

 >  A book I have says it's not possible but I thought maybe a

 > vbx out there could do it.

I have a message that I've saved from FidoNet.

I haven't tested the code, but here it goes anyway:

Originally by Dan Ugrin to Mark Pruitt in the FidoNet VB-meeting:

 quote mode on

Mark Pruitt asked to see some code to use custom cursors without a

.DLL or .VBX.  Well here goes.

This is not an easy one, but using VB alone, there is a way.  It

involves using icons and some api calls to make VB/Windows accept a

new default cursor for your Form/Control.  The default cursor is the

one used when the .MousePointer property is set to 0.  This method was

documented by Mike Stanley in the Dec 93/Jan 94 issue of the Visual

Basic Programmers Journal and slightly modified by me to make it a

little shorter.  Hope it is still understandable.

You will need to draw two icons for each cursor you want to define.

Most any icon editor will do.  The icon editor sample program that

comes with VB will work.

Icon #1 is the normal image of the cursor.  Remember these cursors are

black and white only, so draw accordingly.  Use the Screen Color of

the icon editor to fill in any areas that are not black or white.  You

may also use the inverse color as part of your cursor.  Save this icon

as cur1.ico.

For icon #2, start with the saved image of icon #1. Turn all the screen

color pixels to black.  Then turn all white or inverse pixels to screen

color. Black stays black. Save this icon as cur1m.ico.  This is the mask

image for the cursor.

If you manage the above you've done the hard part.  Now for some code.

Most of the code goes into a .BAS modual as follows.  Remember all API

defines go on one line.

CURSOR.BAS

Const PIXELS = 3

Const GCW_HCURSOR = -12

Const GWW_HINSTANCE = -6

Const BITS_OFFSET = 12

Type CursorInfo

    hWnd        As Integer

    hOldCursor  As Integer

    hNewCursor  As Integer

End Type

Declare Function GlobalLock& Lib "Kernel" (ByVal hMem%)

Declare Function GlobalUnLock% Lib "Kernel" (ByVal hMem%)

Declare Function CreateCursor% Lib "User" (ByVal hinst%, ByVal xhot%,

        ByVal yhot%, ByVal nwidth%, ByVal nheight%,

        ByVal ANDPlane As Long, ByVal XORPlane As Long)

Declare Function DestroyCursor% Lib "User" (ByVal hcur%)

Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal

nIndex%)

Declare Function SetClassWord% Lib "User" (ByVal hWnd%, ByVal nIndex%,

        ByVal NewWord%)

Function ChangeCursor (ByVal hWnd As Integer, hCursor As Integer)

    ChangeCursor = SetClassWord(hWnd, GCW_HCURSOR, hCursor)

End Function

Sub MakeCursor (ByVal hWnd As Integer, picCursor As Control,

                picMask As Control, ciCursor As CursorInfo,

                x As Integer, y As Integer)   'All on one line

    picCursor.AutoRedraw = True

    picCursor.ScaleMode = PIXELS

    ciCursor.hWnd = hWnd

    ciCursor.hNewCursor = CreateCursor(GetWindowWord(hWnd,

                          GWW_HINSTANCE), x, y, picCursor.ScaleWidth,

                          picCursor.ScaleHeight,

                          GlobalLock(picCursor.Picture) + BITS_OFFSET,

                          GlobalLock(picMask.Picture) + BITS_OFFSET)

                          'All the above on one line!

    ciCursor.hOldCursor = ChangeCursor(hWnd, ciCursor.hNewCursor)

    z% = GlobalUnLock(picCursor.Picture)

    z% = GlobalUnLock(picMask.Picture)

End Sub

Sub RestoreCursor (ciCursor As CursorInfo)

    z% = ChangeCursor(ciCursor.hWnd, ciCursor.hOldCursor)

    z% = DestroyCursor(ciCursor.hNewCursor)

End Sub

Okay now to use all the above here's a little demo.  Let's say you want

the cursor to change to a pointing hand whenever it is over your pro-

grams command buttons.  Were going to change the default pointer for

the command buttons.

Put two picture controls on your form (out of the way somewhere) and

load Picture1.Picture with cur1.ico and Picture2.Picture with cur1m.ico.

Sorry, you gotta draw them yerself. :)  Put one or two command buttons

on the form to test things.  For the form's code...  In the general

declarations put:

    Dim ciComBtn As CursorInfo

In form load put:

    Show

    MakeCursor Command1.hWnd, Picture1, Picture2, ciComBtn, 13, 1

Note the last two arguments are the x,y coordinates for the hot spot

of your cursor (in this case the end of the index finger)

To undue everything put the following in form_unload:

    RestoreCursor ciComBtn

Hope I didn't forget anything. :)  Oh yes!  When you run the demo,

DON'T use the VB Stop button to exit the demo.  Use the Close option

of the Demo's system menu.  This will allow the forms unload event to

fire, restoring the cursors properly.

Dan

   Origin: The Target Range (310) 634-8993 (1:102/420.0)

 quote mode off

Hope it helps you out, but *remember* that it's not tested!!

Rgds Anders

agf@itab.ct.se


Cursor custom

LUOKKA: mouse

Date:         Fri, 26 Aug 1994 12:21:47 -0500

From:         "Mark D. Richards" <MDR@HYDROSPHERE.COM>

Organization: Hydrosphere Resource Consultants, Boulder, Colorado

Subject:      Custom Mouse Pointers  XE "Custom Mouse Pointers"

> Does anyone know how to load a custom mouse pointer into a VB app?

> I wish to implement context-sensitive help in my program and would like

> to display a mouse pointer that has both a pointer and question mark.

> Thanks in advance.

Here is segments of code I used in a project for the local library.  The

hardest part was that I had to create a .DLL (CCURSOR.DLL) with a cursor

as one of it's resources.

Anyways, here is the code:

=========================================================

Global Curs1Handle As Integer

Global Curs2Handle As Integer

Global SysCursHandle As Integer

Declare Function LoadLibrary Lib "Kernel" (ByVal lpLibFileName As String) As

 Integer

Declare Function LoadCursor Lib "User" (ByVal hInstance As Integer, ByVal

 lpCursorName As String) As

Declare Function SetClassWord Lib "User" (ByVal hWnd As Integer, ByVal

nIndex As

 Integer, ByVal wNew

Declare Function DestroyCursor Lib "User" (ByVal hCursor As Integer) As

Integer

Global Const GCW_HCURSOR = -12

===========================================================

'In My Form_Load

    DLLInstance = LoadLibrary("CCURSOR.DLL")

    Curs1Handle = LoadCursor(DLLInstance, "ZOOMIN")

    Curs2Handle = LoadCursor(DLLInstance, "ZOOMIN2")

    SysCursHandle = SetClassWord(LOST.hWnd, GCW_HCURSOR,

Curs1Handle)

    LastCursor = SetClassWord(LOST.hWnd, GCW_HCURSOR,

SysCursHandle)

===========================================================

'In my Mouse_Move

    'To set cursor to custom cursor, do the following:

    LastCursor = SetClassWord(LOST.hWnd, GCW_HCURSOR, Curs2Handle)

    'To set cursor back to system cursor, do the following:

    LastCursor = SetClassWord(LOST.hWnd, GCW_HCURSOR,

SysCursHandle)

===========================================================

'In my Form_Unload

    Dim LastCursor As Integer

    LastCursor = SetClassWord(LOST.hWnd, GCW_HCURSOR,

SysCursHandle)

    'I think I need to do a destroyCursor here, but since this app exits

    'Windows, I don't really care.

______________________________________________

Mark D. Richards

Windows Software Engineer

Hydrosphere Resource Consultants, Inc.

Hydrosphere Data Products, Inc.

1002 Walnut Suite 200, Boulder, CO 80302


Cursor custom

LUOKKA: mouse

Date: 03-14-95 (19:25)              Number: 257482 of 262621 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Putting on my own icon for MousePointer

VBPJ dec/Jan 1993/94 had an article "Custom Cursors in VB".  This was

done strickly in VB by Mike Stanley (mikestanly.aol.com, 74632,2227).


Cursor GetCursorPos

LUOKKA: mouse

Date: 09/09/94 (23:52)              Number: 18919 of 18922 (Refer# NONE)

From: Q3034232@BONSAI.FERNUNI-HAGEN.DE, Meik Stoll

Subj: Re: How do I Find MouseX & MouseY?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try the GetCursorPos function of the windows api:

Type mypoint

  x As Integer

  y As Integer

End Type

Declare Sub GetCursorPos Lib "user" (myp As mypoint)

dim myxy as mypoint

Usage: GetCursorPos myxy

------------------------------------------------------------------------------

                            Meik Stoll Seelbachstr. 8

                        D-35708 Haiger Germany

                             fax/phone +49 (0)2773-72822

                              Internet q3034232@bonsai.fernuni-hagen.de


Cursor GetCursorPos1

LUOKKA: mouse

Date: 08/25/94 (08:29)              Number: 16945 of 17020 (Refer# NONE)

From: PWERNTZ@AOL.COM

Subj: Re: Help w/GetCursorPos API

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I monkeyed around with this awhile back.. what I needed was to know when

the cursor had moved off of my app and onto the desktop, this is my sub

(more or less):

Sub CheckMouse()

    Call GetCursorPos(ptCursor)

    hWndOver = WindowFromPoint(ptCursor)

    If hWndOver <> me.hWnd Then

        ' do something

        End If

    End If

End Sub


Cursor hide

LUOKKA: mouse

Date: 07/17/94 (17:51)              Number: 12229 of 12384 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Disappearing mouse

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You need the ShowCursor API function...

 ShowCursor(False) To turn off cursor

 ShowCursor(True) To turn it back on

--

Luke Webber


Cursor hide

LUOKKA: mouse

==============================================================

Date:         Fri, 23 Sep 1994 13:25:04 EST

From:         David J Gurney <gurneyd@CCMAIL.SSD.RAY.COM>

Subject:          Mouse Pointer

        When you answered the question about hiding the mouse pointer

        while it was in a picture box, you said:

                "When you call the API with false it decrements

                 the cursor count by 1.  When the cursor count

                 gets to -1 it will be hidden."

     I put the following code in a test project and it seems to work:

     Declare Function ShowCursor Lib "User" (ByVal bShow As Integer) As

       Integer

     Sub Picture1_GotFocus ()

         Dim i%

         i = ShowCursor(False)  'Hides cursor

     End Sub

     Sub Picture1_LostFocus ()

         Dim i%

         i = ShowCursor(True)   'Shows cursor

     End Sub


Cursor hide

LUOKKA: mouse

2167 (70+)  elijah@bga.com  28.12.94  06:01

Elijah Dean Meeker: "Re: Hide mouse cursor"

Peter Neuendorffer (peter.neuendorffer@channel1.com) wrote:

: My screen saver is coming along famously, except for one thing:

: How can I hide the mouse cursor? (forgive me if this was just answered)

Declare Function ShowCursor% Lib "USER" (ByVal bShow%)

'to hide:

g = ShowCursor(False)

If g > -1 Then

  For h = 0 To g

   j = ShowCursor(False)

  Next h

  End If

'to show:

 r = ShowCursor(True)

    For s = 0 To Abs(r)

   t = ShowCursor(True)

   Next s

sorry for the silly var choices that's how it's stored in my code library.

Write the show code first in a seperate apps keypress event (make an

exe) then alt-tab to it when your app crashes w/o hitting your

unload sequence.


Cursor hide

LUOKKA: mouse

Date: 01/13/95 (20:29)              Number: 32401 of 32470 (Refer# NONE)

From: KPICKUP@OZEMAIL.COM.AU

Subj: Create and use your own cursors in VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

'Sample VB code to create and use your own cursor

' if you don't Restore, then your new cursor stays even in design mode

' don't forget to delete the created cursor.

' Pressing the Change button will create the sample cursor

' Pressing the Restore button will put the original cursor back

'API's required

Declare Function CreateCursor% Lib "User" (ByVal hInstance%, ByVal

nXhotspot%,

ByVal nYhotspot%, ByVal nWidth%, ByVal nHeight%, lpANDbitPlane%,

lpXORbitPlane%)

Declare Function SetClassWord% Lib "User" (ByVal hWnd%, ByVal nIndex%,

ByVal

wNewWord%)

Declare Function GetClassWord% Lib "User" (ByVal hWnd%, ByVal nIndex%)

Declare Function DeleteObject% Lib "GDI" (ByVal hObject%)

Declare Function GetModuleHandle% Lib "Kernel" (ByVal lpModuleName$)

Declare Function SetCursor% Lib "User" (ByVal hCursor%)

Sub Change_Click ()

ReDim ANDbitPlane%(100), XORbitPlane%(100)  'make some space

For C% = 0 To 100

  ANDbitPlane%(C%) = 63  'set up for sample

  XORbitPlane%(C%) = 255 ' ditto

Next C%

nWidth% = 32            'cursor width

nHeight% = 32           'cursor height

hInstance% = GetModuleHandle%("VB.EXE")       'get our Instance

hCursor% = CreateCursor%(hInstance%, 0, 0, nWidth%, nHeight%,

ANDbitPlane%(0),

XORbitPlane%(0)) 'create the cursor

hOldCursor% = GetClassWord%(Form1.hWnd, -12)  'save the old one

X% = SetClassWord%(Form1.hWnd, -12, hCursor%) 'set our test one

End Sub

Sub Restore_Click ()

  X% = SetClassWord%(Form1.hWnd, -12, hOldCursor%)  'put old cursor back

  Dummy% = DeleteObject(hCursor%)                   'delete the cursor created

End Sub

Have fun

Keith Pickup

SOFTERM (Australia)

kpickup@oz-email.com.au


Cursor move

LUOKKA: misc

Placing The Cursor On The Button That Has Focus

-------------------------------------------------------------------------

In a Visual Basic application, it is a good idea to place the focus on the

button that the user will most logically press for the next command.  This can

be done by making the default property for the button True, or by using the

SetFocus method. Wouldn't it be nice if you could also place the mouse

cursor over that button?  Unfortunately, Visual Basic does not have a built-in

method to accomplish this. I have found that it is possible to move the mouse

cursor by using a Windows API (Application Programmer's Interface) call.

The instructions below illustrate how to use this method.

Start a new project which includes one form.  Place two buttons on the form.

 Add a new module to the project (File, New Module).  In the General,

Declarations section of the module, place the following code, all on one line:

Declare Sub SetCursorPos Lib "User" (ByVal X As Integer, ByVal Y As

Integer)

In the Click event for Command1, place the following code:

 x% = (Form1.Left + Command2.Left + Command2.Width / 2 + 60) /

Screen.TwipsPerPixelX

 y% = (Form1.Top + Command2.Top + Command2.Height / 2 + 360) /

Screen.TwipsPerPixelY

 SetCursorPos x%, y%

Press F5 to run the program.  When you click on Command1 the mouse

cursor will be placed approximately on the center of the Command2 button.

The calculation of the x and y coordinates for the SetCursorPos routine could

use some explanation.

SetCursorPos expects these to be the pixel locations.  In a 640 by 480

(standard VGA) screen, the command SetCursorPos 320, 240 would place the

cursor in the center of the screen.  Visual Basic, however, normally uses

"twips" instead of pixels.  The ratio of twips to pixels can vary depending on

the screen mode. Fortunately, Visual Basic includes the TwipsPerPixelX and

wipsPerPixelY properties so that we can easily convert VB's twips to

Windows pixels.

In our example we calculate the x coordinate by taking the left property of

our form, adding the left property of Command2 and half of the width of the

button to get the center of the button.  The "60" that we added is to

compensate for the form's border.  The y coordinate is calculated in the same

manner.  The "360" is to compensate for the form's border and the form's title

bar.

Tip Submitted By: Robert Wilcox


Cursor move

LUOKKA: mouse

Date: 07/16/94 (09:36)              Number: 12222 of 12223 (Refer# NONE)

From: EXE01940@CHAR2.VNET.NET

Subj: Controling Mouse Position

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Use:

Declare Sub SetCursorPos Lib "User" (ByVal X As Integer, ByVal Y As

Integer)

Calculate X% and Y% where you want to place the mouse pointer.

Remember that pixel location is required and if you have a value

in twips you have to convert using Screen.TwipsPerPixelX and

Screen.TwipsPerPixelY.

Then just

        SetCursor X%, Y%


Cursor move

LUOKKA: mouse

Date: 10/05/94 (01:44)              Number: 21778 of 21852 (Refer# NONE)

From: CSTUART@METRONET.COM

Subj: Re: Forced MouseMove?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

'----REQUIRED TO POSITION MOUSE FROM CODE

     Declare Sub ClipCursor Lib "User" (lpRect As Any)

     Declare Sub SetCursorPos Lib "User" (ByVal X As Integer, ByVal Y As

       Integer)

     Type RECT

          Left As Integer

          Top As Integer

          Right As Integer

          Bottom As Integer

     End Type

     Global CursorRectangle As RECT

     Global ScreenHeight As Integer

     Global ScreenWidth As Integer

Sub SetMouseLocation (X, Y)

'----SET CURSOR POSITION

     CursorRectangle.Left = X Ö 15

     CursorRectangle.Right = X Ö 15

     CursorRectangle.Top = Y Ö 15

     CursorRectangle.Bottom = Y Ö 15

     ClipCursor CursorRectangle

     SetCursorPos 0, 0

'----RESTORE MOUSE AREA TO FULL SCREEN

     CursorRectangle.Top = 0

     CursorRectangle.Left = 0

     CursorRectangle.Right = Screen.Width Ö 15

     CursorRectangle.Bottom = Screen.Height Ö 15

     ClipCursor CursorRectangle

End Sub

Also search on twipsperpixel.

Chuck

Mesquite TX


Cursor move

LUOKKA: mouse

Date: 01/14/95 (15:46)              Number: 185358 of 187649 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Changing Coordinates of Mouse Pointer

>Is it possible to change X & Y Coordinates of the Mouse Pointer within a

>VB program.  If so, could you tell me how it would be ?

Place following declarations in the general section of your form.

Declare Sub SetCursorPos Lib "User" (ByVal x As Integer, ByVal y As

Integer)

Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

Integer

Declare Function GetMenu Lib "User" (ByVal hWnd As Integer) As Integer

Const SM_CYMENU = 15

Const SM_CYCAPTION = 4

I used as an example following sub, which centers the cursor in a picture

box when user clicks the form. The main things to remember are

* the parameters of SetCursorPos are relative to the screen

* screen coordinates in VB are TWIPS and in API call they are pixels.

* inside form you have to allow for borders, title bar and menu bar.

Sub Form_Click ()

   PicScModeOld = Picture1.ScaleMode

   FormScModeOld = Form1.ScaleMode

   Form1.ScaleMode = 1

   If Form1.BorderStyle < 3 Then

      xDisp = Form1.BorderStyle

      yDisp = Form1.BorderStyle

   Else

      xDisp = 5

      yDisp = 5

   End If

   If GetMenu(Form1.hWnd) Then

      If xDisp <> 2 Then xDisp = 1

      If yDisp <> 2 Then yDisp = 1

      yDisp = yDisp + GetSystemMetrics(SM_CYCAPTION) +

GetSystemMetrics(SM_CYMENU)

   Else

      yDisp = yDisp + GetSystemMetrics(SM_CYCAPTION)

   End If

   x = Int((Form1.Left + Picture1.Left + Picture1.Width / 2) /

Screen.TwipsPerPixelX) + xDisp

   y = Int((Form1.Top + Picture1.Top + Picture1.Height / 2) /

Screen.TwipsPerPixelY) + yDisp

   SetCursorPos x, y

   Form1.ScaleMode = FormScModeOld

   Picture1.ScaleMode = PicScModeOld

End Sub

I haven't checked that I really covered all possible combinations of border

widths, caption and menu bars. But this should get you started.


Cursor move

LUOKKA: mouse

Date: 02/02/95 (00:18)              Number: 209060 of 210048 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Moving the Mouse

one solution is following:

Place following declarations in the general section of your form.

Declare Sub SetCursorPos Lib "User" (ByVal x As Integer, ByVal y As

Integer)

Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

Integer

Declare Function GetMenu Lib "User" (ByVal hWnd As Integer) As Integer

Const SM_CYMENU = 15

Const SM_CYCAPTION = 4

I used as an example following sub, which centers the cursor in a picture

box when user clicks the form. The main things to remember are

* the parameters of SetCursorPos are relative to the screen

* screen coordinates in VB are TWIPS and in API call they are pixels.

* inside form you have to allow for borders, title bar and menu bar.

Sub Form_Click ()

   PicScModeOld = Picture1.ScaleMode

   FormScModeOld = Form1.ScaleMode

   Form1.ScaleMode = 1

   If Form1.BorderStyle < 3 Then

      xDisp = Form1.BorderStyle

      yDisp = Form1.BorderStyle

   Else

      xDisp = 5

      yDisp = 5

   End If

   If GetMenu(Form1.hWnd) Then

      If xDisp <> 2 Then xDisp = 1

      If yDisp <> 2 Then yDisp = 1

      yDisp = yDisp + GetSystemMetrics(SM_CYCAPTION) +

GetSystemMetrics(SM_CYMENU)

   Else

      yDisp = yDisp + GetSystemMetrics(SM_CYCAPTION)

   End If

   x = Int((Form1.Left + Picture1.Left + Picture1.Width / 2) /

Screen.TwipsPerPixelX) + xDisp

   y = Int((Form1.Top + Picture1.Top + Picture1.Height / 2) /

Screen.TwipsPerPixelY) + yDisp

   SetCursorPos x, y

   Form1.ScaleMode = FormScModeOld

   Picture1.ScaleMode = PicScModeOld

End Sub

I haven't checked that I really covered all possible combinations of border

widths, caption and menu bars. But this should get you started.

        Lasse


Data types converting

LUOKKA: VBgen

Date: 09/17/94 (19:45)              Number: 19857 of 19876 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: BINARY, INTEGER, LONG

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

larsj@powertech.no (Lars Jacobsen) writes:

>I'm working on an application which is communicating with an DDE-server

>(which is attached to a PLC - Programmable Logical Controller). Well, my

>problem is that I'm fetching data from the PLC which is - in the PLC - a 16

>bit value. This value I want to extract to 2 ascii-characters. But when the

>hi-byte is in the extended characterset the 16 bit value gets negative in my

>app. I've connected the DDE-link to text-fields and can't find out how to

>make those fields accept long integers. So a value which originally was

>36567 becomes -28967 when it is above 32767 (highest integer). What I'm

>looking for is a routine which can regenerate the original value. I'm sure

>somebody have done it before!

Can't you get the data into a Long rather than in integer? If not, you'll

have to convert to Long, since VB doesn't support Unisgned data types

8^(. It goes something like this...

Dim IVal as Integer, LVal as Long

Dim LoByte as String * 1, HiByte as String * 1

 If IVal < 0 then

  LVal = 65536 + IVal

 else

  LVal = IVal

 EndIf

 LoByte = LVal Mod 256

 HiByte = LVal ?  256

--

Luke Webber


Datactrl missing/ide

LUOKKA: VBgen

28.Data Control missing from toolbox when I use VB under NT 3.5. Huh?

   Open the VB.INI file and add these lines under the ÄVisual BasicÅ

   heading:

   ReportDesign=1

   DataAccess=1

   Danny Ames (dames@pic.net)


Date of file

LUOKKA: files

Date: 02-23-95 (08:16)              Number: 232134 of 234156 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Updating the File Date of a File

> Anybody have a quick and dirty way of updating the file date of a file?

>

> If I do an open for append and then close it, it does not change the

> date/time.  If I open it for output and then close it, it updates the file

> date, but also empties it (leaving a zero byte file).  I don't want to

> modify the contents of the file.

-------------------------------------------

even if I don't believe getting a VBX everytime you have a problem, here I

suggest one (because it is FREE). Get VBIO.ZIP from CICA, it will let you do

all kind of things with files, e.g. get and set dates.

        Lasse

-------------------------------------------

Open it for Binary mode, Get 1 byte, save it to a variable, write a different

byte

at that position, then write the original byte back. Close the file.

Voila!

Here's the little example I tried to test my theory.

a$ = " "

b$ = "A"

ff = FreeFile

Open "c:™autoexec.bat" For Binary As ff Len = 1

Get #ff, 1, a$

Put #ff, 1, b$

Put #ff, 1, a$

Close ff

Brad Thomas

Senior Systems Officer

State Library of NSW

Sydney, NSW, Australia

bradt@slnsw.gov.au


Dates

LUOKKA: Access

1283 (37+)  ashipley@hookup.net  08.01.95  23:57

Ayn Shipley: "Re: Help with FindFirst"

>>I have defined an Access table using the Data Manager tool

>>supplied, with a date/time field on it. I then tried to produce the

>>necessary code to retrieve rows matching a given date using the

>>Findfirst function but nowhere can I find what the format of the

>>criteria string should be - if I put "Date >= 03/03/95" it returns

>>all the records regardless, if I put "Date >= '03/03/95'" it gives

>>a Type Mismatch error.

>A date must be set off as #01/01/95#.

Specifically, (for those non-US people out there... :-)), it must be in US

date format: mm/dd/yy ie #12/31/95#.

__________

Ayn Shipley, Toronto, Ontario     Prevent computer viruses...

internet: ashipley@hookup.net     ...practice safe sigs


Dates

LUOKKA: Access

5626 (2+)  joe@bftsi0.UUCP  24.05.95  23:10

Joe Foster of Borg: "Re: DB_DATE - Please Help!!"

In article <3pv0bb$7jo@hermes.is.co.za>, mst@apollo.is.co.za (Martindale)

writes:

> I've created an Access database with VB3.0, and every table has a date

> field whose type property is DB_DATE. However, after my VB app has

> created the database, and populated it with records, every value in the

> date field of every table looks something like '1995-05-24 00:00:00.000'.

> I really don't like this, I want the format of the dates in my database

> to be '5/24/95', rather than the above. How do I fix it?

This is a formatting thing. VB stores dates and times internally

as the number of days since 12/30/1899. For example, today

(5/24/95) would be represented internally as 34843. Time

information is stored as a number between 0 and 1. For example,

midnight is 0 and noon is 0.5, so high noon on 5/24/95 would be

34843.5. This makes calculations easy, but it also means that VB

can't tell whether you're storing just a date or a date/time

where the time happens to be exactly midnight. The only thing you

can do it to adjust the formatting in whetever it is you're using

to display the dates.

--

Joe Foster (joe@bftsi0.UUCP or joe%bftsi0.uucp@uunet.uu.net)


Dates

LUOKKA: dates

12.How should dates be implemented so they work with other language

   and country formats?

   If you use ie. MM/DD/YY format dates in a program, you will get

   either a runtime-error (ie. month>12) or the wrong date (ie. March

   12 instead of December 3) when your program is used in Europe. And

   vice versa, of course. Even Microsoft's own example programs (like

   the MAPI sample) make this stupid mistake and fail miserably. Use

   the Format command to make sure you get the date you want. For

   example:

     strTodaysDate = Format $ (Now, "Short Date")

   As a side note, Microsoft has taken much heat on the newsgroup for

   VB's bad support for internationalization! Just try to make a date

   literal in source code that works everywhere as a little exercise.

   Answer elsewhere in this document. No prizes  :-)


Dates

LUOKKA: SQL

Date: 06/03/94 (10:13)              Number: 7730 of 7791 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: VB+ using DATE in SQL que

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

dates must be embedded between # signs so:

"SELECT * FROM blah WHERE start < #" & DATE$ & "#"

this assumes first that start is a literal:  if it is field reference then

"SELECT * FROM blah WHERE #" & start & "# < #" & DATE$ & "#" and

secondly,

that Date$ is the name of a date field.  If either start or date$ are text

fields then you will need to convert them to dates as

"SELECT * FROM blah WHERE #" & CVDate(start) & "# < #" &

CVDate(DATE$) &"#"

michael.cowan@almac.co.uk

nottingham, england & europe


Dates comparing

LUOKKA: dates

Date: 01/08/95 (15:05)              Number: 32029 of 32049 (Refer# 31868)

From: PATRIK SCHROEDER

Subj: Comparing Dates

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

JJ> I need to compare a date stored in a database with the current date

JJ> to determine if the database date is equal to or less than the

JJ> current date. I am basically trying to have an alarm come up on or

JJ> after a certain date. I have tried something like, Date1 <= Date 2,

JJ> but this does not work.  I have not been able to find anything the

JJ> VB documentation telling how to do this.

    The CVDate() function is useful to ensure that a varaiable is treated

    as a date.

        If CVDate(MyTable!MyDate) <= Now Then...

    should work.

         ---------------------------------------------------

         Patrik Schroeder    Helsinki, Finland

         Internet:           patrik.schroeder@pcb.compart.fi


Dates day of week

LUOKKA: dates

==============================================================

Date:         Tue, 11 Oct 1994 09:35:17 +0200

From:         giora drachsler <giora@SHUM.CC.HUJI.AC.IL>

Subject:      CACM (day of week)

Ed> Do anybody have a copy of or access to a copy of the Collected

Algorithms of

Ed> the ACM? I need the formula for calcing the day of the week. (yes, I

know

Ed> there is a function in vb, but I still need the algorithm behind it).

Ed> Thanks ... Ed

        What you need is to convert the date to Julian day number.

        It is an astronomical convention that allows dates to be

        stored as a single, large integer.  The difference of two

        Julian numbers will give the exact number of days between

        any two dates.  The day of week is the modulo 7 of this

        number.

        The calculations are usually accurate for dates from 1583

        to the indefinite future. Some errors might occur for dates

        between 1953 and 1599.

        Julian day number calc:

        a& = 146097& * (year%  \  100) \ 4

        b& =   1461& * (year% mod 100) \ 4

        c& = (153 * month% + 2) \ 5 + day% + 1721119

        JulianDay& = a& + b& + c&

        DayOfTheWeek% = JulianDay& mod 7

        (Mon=0, Tue=1, Wed=2, ... Sun=6)

                                Giora Drachsler

                                Hebrew University

                                Jerusalem, Israel

                                Giora@SHUM.cc.huji.ac.il


Dates formatting

LUOKKA: dates

Date: 09/08/94 (01:37)              Number: 18604 of 18922 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Formating Text Box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

M>Chris Molnar (molnarc@dfw.net) wrote:

M>: Is it possible to format at text box so that every time the user

M>: enters  something into it it will format it into a date string?

M>: ie>.. User enters 08.12.94  format to 08/12/94  or in the same box a

M>: user  enters   08-12-94 and it will format it into 08/12/94?

M>: The purpose here is to be compatable with some database apps.

This one really should be in the FAQ.  The solution involves IsDate,

CvDate and Format$.

1.  Test the string with IsDate to verify that it is recognizable as a

date

2.  Convert it to a date using CvDate

3.  Format it however you like using Format$

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                                m_rubin@tatertot.com


Dates in listbox

LUOKKA: dates

Date: 03-03-95 (13:38)              Number: 239736 of 244354 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Dates in a List Box

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>I have designed a program that will take the date and a text field,

>combine them and put it in a List Box.  Now, when I double click on an

>entry, I want to find that entry.  Having a few difficulties.  I want to

>search on the date which is the

>

>        Left(list1.text,8)

>

>The field in my database is a (Date/Time) field.  Now, when I search I

>get a Type Mismatch error.

>

>I have also tried this...

>

>        DateValue(Left(list1.text,8))

>

>But to no avail.  I need to search on that field as that is the only

>field that is non-duplicate.

>

   ' Extract date as string

   Temp$ = Trim$(Text1.Text) ' Just in case

   spcPos = InStr(Temp$, " ")

   DateStr$ = Left$(Temp$, spcPos)

   ' Convert to double

   DueDate= CDbl(DateValue(DateStr$))

   ' Build search criteria

   MyCriteria = "ŽDateDue� =" & DueDate

I hope this helps

        Lasse


Dates internationaliz

LUOKKA: dates

Date: 12/05/94 (07:15)              Number: 28860 of 28886 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: HELP with DB.EXECUTE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> Delete from marine where stormnam ='GORDON' AND date = '11/17/94'

AND

> time = '22:00'

You need a different delimiter for dates. Try this:

 Delete from marine where stormnam ='GORDON' AND date =#11/17/94#

AND

 time = #22:00#

I also prefer to format my dates with Format$(XXX,"d mmmm yyyy")

This avoids potential internationalisation problems.

--

Andy Dingley                             dingbat@codesmth.demon.co.uk


Dates internationaliz

LUOKKA: dates

4301 (10+)  bemiller@amoco.com  31.01.95  18:16

Blake Miller: "Re: Date functions and WIN.INI settings give inconsistent

results"

>I understand that VB's date functions are dependent on the date/time

>setting of the International section of the Control Panel.

>But it seems that Format() and some date functions like DateAdd() don't

>work properly depending on the date/time setting.

>For example, if the Control Panel date/time setting is YYYY-MM-DD and I try

>a simple DateAdd("m", 1, "01-JAN-95") it will give me a "Type Mismatch"

>error.

>However, DateAdd("m", 1, "95-JAN-01") will work.

>Anyone know why the inconsistencies and if there are workarounds or code

>snippets to alleviate the problem?

If you are consistent in your program as to how the user can enter a date

(e.x., always yyyy-mm-dd), then you can convert the date to the shortdate

format defined in the win.ini to do the built-in date functions on.

You might find the following code snippets helpful:

'Given a date of format yyyy-mm-dd, this function will re-format

'it according to the shortdate definition in win.ini.

'A valid date is returned, otherwise an empty string is

'returned.

Function Format_Date (InputDte As String) As String

Dim mm$, dd$, yy$, IniFormat$, DateFormat$

  yy = Mid$(InputDte, 3, 2)

  mm = Mid$(InputDte, 6, 2)

  dd = Mid$(InputDte, 9, 2)

  Call GetIni("Win.ini", "intl", "sShortDate", DateFormat)

  Select Case UCase$(Left$(DateFormat, 1))

  Case "Y" 'internal date is YY/MM/DD

    IniFormat = yy & "-" & mm & "-" & dd

  Case "M" 'internal date is MM/DD/YY

    IniFormat = mm & "-" & dd & "-" & yy

  Case "D" 'internal date is DD/MM/YY

    IniFormat = dd & "-" & mm & "-" & yy

  Case Else

    MsgBox "Could not get date format from win.ini", MB_ICONEXCLAMATION

    Format_Date = ""

    Exit Function

  End Select

  If IsDate(IniFormat) Then

    Format_Date = IniFormat

  Else

    Format_Date = ""

  End If

End Function

'stick this declaration in a module all on one line:

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpAppName As

String, ByVal

lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As

String, ByVal nSize

As Integer, ByVal lpFileName As String) As Integer

Sub GetIni (IniFile As String, IniSection As String, IniKeyWord As String,

NewValue As String)

Dim IniValue As String * 255

Dim lenIniValue As Integer

  'Read specified record from ini file

  lenIniValue = GetPrivateProfileString(IniSection, IniKeyWord, "", IniValue$,

255, IniFile)

  If lenIniValue = 0 Then

    NewValue = ""

  Else

    NewValue = Left$(IniValue$, lenIniValue)

  End If

End Sub


Dates Julian convert

LUOKKA: dates

Date: 08/28/94 (17:41)              Number: 17569 of 17592 (Refer# NONE)

From: MCOLEMAN@TELERAMA.LM.COM

Subj: Re: Help! Julian Date Conversion

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <33qj7e$sfj@search01.news.aol.com>, sthorson@aol.com

(SThorson) wrote:

> I am looking for code to convert a julian date to a date string.  Any

> assistance is appreciated.

I haven't ran this but it MIGHT work...

function JDatetoString(byVal theJDate as integer) as String

 DIM DatevalofJan1 as Variant

 DateValofJa1 = DateValue("1/1/1994")

 JdatetoString= Format(DatevalofJan1-1+theJDate,"mm/dd/yy")

end function

--

Mike Coleman              "The secret of success in business is

Allegheny R&D, Inc.       sincerity.  As soon as I learn to fake

Pittsburgh, PA            sincerity, I'll have it made."


Dates leap year etc.

LUOKKA: dates

Date: 01/16/95 (02:18)              Number: 32641 of 32710 (Refer# NONE)

From: JOE@BFTSI0.UUCP

Subj: Re: Dates/Years...

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> Ok, question for you VB knowledgable people: I am coding

> a calander program in VBH 3.0 Pro. I want a system that can

> calculate which days fall on which days of the week in which

> years (i.e. that Jan 1 1996 is a thursday, etc) and leap

> years, etc. Some code, ideas, control, tip, trick, info, etc

> would be great. Thanks!

RTFM under DateSerial, WeekDay, and the other date functions.

Also, here's a way to find out if VB thinks a year is leap or

not:

Function IsLeapYear(ByVal Yr As Integer) As Integer

    IsLeapYear = (Day(DateSerial(Yr, 3, 1) - 1) = 29)

End Function

--

Joe Foster (joe@bftsi0.UUCP or joe%bftsi0.uucp@uunet.uu.net)

Systems Mangledr/Head Geek/Top Jolt Addict, BFTSI


Dates no of weekdays

LUOKKA: dates

Date: 11/02/94 (17:57)              Number: 25589 of 25696 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: HELP: Printing output - Please....!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>3. I must start to annoy you by now, I'm sorry, but I'm really hopeless.

>   Is there a way for us (a function or so...) to get the number of days

>   in a specific month. I mean like how many Mondays are there in June, >

1992.

Anyhoo, as far as your question regarding the number of occurrences of a

specified weekday in a given month, there isn't any such built-in

function, but the following *should* do the trick.

It takes the day of the week (1=Sunday, 7=Saturday), the month and the

year, and returns the count. Calling it with arguments of 2, 6, 1992

returns 4, which I hope is the number of Mondays in June 1992.

========

Function DayCount (D As Integer, M As Integer, Y As Integer) As Integer

'

' Count the number of occurrences of a specified weekday D

' in month M of year Y.

'

Dim FirstDay As Long, NoDays As Integer

Dim FirstOccurrence As Integer

    ' First find out the first day in the month.

    FirstDay = DateSerial(Y, M, 1)

    ' Now find first occurrence of weekday D in month

    FirstOccurrence = (D + 7 - Weekday(FirstDay)) Mod 7

    ' Now we'll re-use the FirstDay vbl and make it the date of the

    ' first weekday D in the month.

    FirstDay = FirstDay + FirstOccurrence

    ' Now find out how many days remaining in the month by subtracting

    ' the date of the first occurrence from the date serial of the

    ' first day in the next month.

    If M = 12 Then

        NoDays = DateSerial(Y + 1, 1, 1) - FirstDay - 1

    Else

        NoDays = DateSerial(Y, M + 1, 1) - FirstDay - 1

    End If

    '

    'From that number we now get the total count of the specified day.

    '

    DayCount = (NoDays   7) + 1

End Function

--

Luke Webber


Dates number of day

LUOKKA: dates

==============================================================

Date:         Tue, 11 Oct 1994 01:56:35 EDT

From:         MR DAVID W PARVIN <EAHM64A@PRODIGY.COM>

Subject:      CACM

The following is a couple of functions that I wrote a long time ago, I

don't know if this is how the ACM does it but it seems to work for me.

There are probably better ways of doing this but I works and I haven't

felt like improving them.

FUNCTION DayVal (SysDate$)

    'returns a number of 0 to 6 Representing the day of the week

    Dim MonthValue as Integer, DayValue as Integer, YearValue as

      Integer

    Dim LeapYear as Integer, WeekOfYear as Single, DayOfWeek as Integer

    MonthValue = VAL(LEFT$(SysDate$, 2)) ' Pulls Month

    DayValue = VAL(MID$(SysDate$, 4, 2)) ' Pulls day

    YearValue = VAL(RIGHT$(SysDate$, 4)) ' pulls Year

    LeapYear = INT(YearValue / 4)

    YearValue = YearValue - 1900

    Juls = VAL(RIGHT$(Jul$(SysDate$), 3))

    WeekOfYear = (YearValue + LeapYear + Juls) / 7

    DayOfWeek = INT((WeekOfYear - INT(WeekOfYear)) * 7 + .5)

    DayVal = DayOfWeek

END FUNCTION

FUNCTION Jul$ (SysDate$)

    ' Converts the inputed [02-01-1991] system date into a Julian Date

[1032]

    ' The first character of the string is the year and the last three

     is the

    ' number of days from January 1st.

    DIM Accumulator AS INTEGER, Date AS INTEGER, Date1 AS INTEGER,

      Date2 AS INTEGER

    Date1 = VAL(LEFT$(SysDate$, 2))

    Date2 = VAL(MID$(SysDate$, 4, 2))

    da$ = RIGHT$(SysDate$, 4)

    Accumulator = 1

    Date = 0

    DO WHILE Accumulator < Date1

        Date = Date + LastDay(Accumulator, VAL(da$))

        Accumulator = Accumulator + 1

    LOOP

    Date = Date + Date2

    da$ = RIGHT$(da$, 1) + RIGHT$("000" + MID$(STR$(Date), 2), 3)

    Jul$ = da$

END FUNCTION

FUNCTION LastDay (Month AS INTEGER, Year AS INTEGER)

    ' figure out the last day of a specific month from the inputs of a

    ' Specific Month and Year

    SELECT CASE Month

        CASE 1, 3, 5, 7, 8, 10, 12

            Days = 31

        CASE 4, 6, 9, 11

            Days = 30

        CASE 2

            IF Year / 4 = INT(Year / 4) THEN

                Days = 29

                    ELSE

                        Days = 28

            END IF

    END SELECT

    LastDay = Days

END FUNCTION


Dates US & UK ??

LUOKKA: dates

Date: 06/25/94 (12:31)              Number: 10485 of 10514 (Refer# NONE)

From: PHILLIP@SFE.COM.AU

Subj: Re: How to resolve US & UK date formats conflicts?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

weijin@panix.com (wjm) writes:

> A user of my program in UK encounter a type mismatch error when

>the program tries to format$(Now, "mm-dd-yyyy"). I later found out

>other VB programmers also encounter this problem. The VB FAQ doesn't

>provide a solution. Could anyone share the solution?

Check out the langauge reference for Format$().  You can do things like

  Format$(Now, "Long Date")

  Format$(Now, "Short Time")

and the like.  These 'descriptive' formats use the international settings

from the control panel, thus overcoming any UK Vs US problems.

If this isn't good enough, you can always read WIN.INI to find out what date

and time format your user has selected and then code your program to check

what format is required before using Now.

Phillip Thomas

Sydney Futures Exchange

phillip@sfe.com.au


Dates US & UK ??

LUOKKA: dates

Date: 07/01/94 (01:24)              Number: 10819 of 10897 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: How to resolve US & UK da

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

use format$(Now, "Short Date") - it uses the users international setting

michael.cowan@almac.co.uk

nottingham, england


Dates US & UK??

LUOKKA: dates

Date: 07/03/94 (23:19)              Number: 11169 of 11217 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Problem with date format

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 4/7/94, Irvine Short wrote to ALL: *****>>

IS>I have the following problem with Visual Basic with an Access

IS>Database.  I need to use the British (DD/MM/YYYY) date format as

opposed

IS>to the American (MM/DD/YYYY) date format. With my windows

international

IS>date format set accordingly, the Visual Basic isdate function correctly

IS>returns 'True' for 30/12/1994 and 'False' for 12/30/1994, and vice-versa

IS>when I set the International Date format to MM/DD/YYYY.

IS>However, when I want to perform the following on records:

IS>

IS>"ACDATE >= #1/1/94# AND ACDATE <= #30/12/95#"

IS>(I made ACDATE type DB_DATE)

IS>It blows up in my face with anything but American format dates.  When I

IS>am writing data to the Database with the International Date Format set to

IS>DD/MM/YYYY it correctly throws 12/30/1994 out.  It seems that Visual

IS>Basic correctly listens to my WIN.INI, but not the SQL part of Access

IS>Queries.  Any help would be much appreciated. I'm really tearing my hair

IS>out here!

"CVDate(ACDATE) >= #1/1/94# AND CVDate(ACDATE) <= #30/12/95#"

CVDate() coverts accoring to the current international setting

michael.cowan@almac.co.uk nottingham, england


Dates USA/Europe

LUOKKA: Access

Date: 10/28/94 (00:47)              Number: 24806 of 24888 (Refer# NONE)

From: TOM=VAN=BUGGENHOUT%SOZ%RECHTEN@CC3.KULEUVEN.AC.BE

Subj: Dates in data access

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (-)

When I use the ISDATE-function on a variant, VB seems to use the

national-date-format (Belgian format is DD/MM/YYYY) as I had defined in

the Control Panel of Windows.

But when I use a date-element in the filter-property of a dynaset, it seems

that VB does not use the national-date-format, but the American Standard

(MM/DD/YYYY).

tom.vanbuggenhout@law.kuleuven.ac.be


Dates USA/Europe

LUOKKA: Access

Date: 10/20/94 (19:41)              Number: 24170 of 24188 (Refer# NONE)

From: PETER BAECKGREN

Subj: SQL dates solved, thanx

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

        Thanx to everyone that replied to my question about

        SQL dates. Though no one came up with a specific answer I at

        least got the guidelines to work with. After a series of

        annoying tries I finally stumbled across the answer.

        SELECT * FROM MHREPORT WHERE PCDATE > #09/10/94# AND

        PCDATE < #10/16/94#

        For some strange unknown reason it seems the dates must be in US

        format. I was told Access (or VB) would automatically convert

        the dates when using #'s, which is why I never got it to work.

        International dates are a real dog in VB anyway.

                                                T.Eskimo


Debug.print leave!

LUOKKA: coding

Date: 11/01/94 (16:50)              Number: 25458 of 25466 (Refer# NONE)

From: JOE@BFTSI0.UUCP

Subj: CONFIRMED: Debug.Print is evaluated in EXE's! (Was: Re: Debu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> I wonder if those Debug.Print statements actually get *evaluated*

> in the executable and the results thrown away by the Debug object

> at run-time. I should test for this when I go to work. If anyone

> has VB handy, see if this pops a message box in a VB executable:

> Sub Main

>     Debug.Print MsgBox("Debug.Print's are evaluated in EXE's!", 49, "Hi

there!")

> End Sub

> If this program does pop a message box when compiled, we will all

> need to be much more careful about leaving Debug.Print's in our

> executables due to possible side-effects or speed penalties.

I just tested this, and it's true, Debug.Print's are not only

present in compiled EXE's, they are actually evaluated. (Although

the result is thrown away) I double-checked by Debug.Printing the

results of a couple of functions with side effects, and the side

effects occured in every case after I compiled the project,

exited VB altogether, and ran the EXE.

It appears that, instead of stripping out Debug.Print's when

compiling, VB merely arranges for the result to be discarded. So,

before compiling your apps for deployment, be sure to comment out

all Debug.Print's, especially if they have side effects or

involve routines that do significant processing. On the other

hand, this could be a good way to run a function and discard the

result, a la casting the result of a function call to (void) in

C... Naah, too prone to getting nuked when you strip out the

'real' Debug.Print's...

--

Joe Foster (joe@bftsi0.UUCP or joe%bftsi0.uucp@uunet.uu.net)

Systems Mangler/Head Geek/Top Jolt Addict, BFTSI


Decompiler *.hlp

LUOKKA: WinHelp

6356 (21+)  kittyba@netcom.com  12.07.95  16:11

The Kitty: "Winhelp Decompiler from Wextech"

I'll repost for those who missed it. I have the Wextech freeware

Winhelp decompiler on my ftp site at ftp.netcom.com in directory

/pub/ki/kittyba in file PAPER.ZIP.  Please no mail requests.

It works well - It handled some nasty files ok but I think the

footnotes, etc are not in the rtf file.


Decompiler *.hlp

LUOKKA: WinHelp

6404 (1+)  kittyba@netcom.com  16.07.95  17:42

The Kitty: "Re: Winhelp Decompiler from W"

MICHAEL MALCOLM (mma@dkb.dk) wrote:

: Hi Mike et al,

snip

: Indeed!  I'd just like to add that it works equally well on Multimedia

: Viewer files.  Just remember to explicitly specify the .MVB extension,

: as it defaults to .HLP.

: This should also come in handy for the person who wanted to print out

: the msoff43.mvb file from MS Office.

Everyone has been "talking" about the implications of using the Paper

Trails decompiler but few have talked about how well it works & keeps

formatting.  I still need to check it out.

I guess the ideal situation would be like the other product (spacing

which one) that decompiles to RTF, pics, HPJ file, & baggage...

-----------------

(PS decompiler still available from ftp://ftp.netcom.com/pub/ki/kittyba/

PAPER.ZIP).


Decompiler *.hlp

LUOKKA: WinHelp

6436 (8+)  stefan@olson.manawatu.gen.nz  18.07.95  08:10

Stefan Olson: "Re: .hlp file format & .hlp patching"

In <DBu9rv.K3B@news.cis.umn.edu> volo0002@maroon.tc.umn.edu (Ted

Volk) writes:

>As I did not find a FAQ for this group, let me ask...

>Are there .hlp file patchers around. I need to substitute some literals in

>.hlp's, and I don't have their source files.  The structure is very complicated

>so I avoid using decompiler products as I would have hard time puting the

>whole >thing back in order.

Actually if you use a "real" decompiler, such as the one included in HWA you

can import the help file, make your changes and recompile.  EVERYTHING is

preserved - context strings, keywords, browse sequences, text, graphics,

formatting, links etc!

Patching a help file would be a complicated if not impossible task.

------------------------------------------------------------------------

   Stefan Olson               Internet Mail: stefan@olson.manawatu.gen.nz

   Olson Software                Compuserve: 100352,1315

   Ask about Help Writer's Assistant for Windows - the visual

   and easy way to *edit* Windows Help files.

   (ftp://gmutant.wrlc.org/pub/incoming/hwa20.zip)

   Also ask about the Olson Software Help Tools (OSHTLS13.ZIP) - buttons,

   256 color bitmaps, button bars in secondary windows and much more!

------------------------------------------------------------------------


Decompiler VB

LUOKKA: coding

27134 (263+)  oliver.ebert@uni-konstanz.de  24.07.95  19:32

Oliver Ebert: "VB DISCOMPILER !!!!"

> There is a VB decompiler, I picked it up somewhere in Denmark or Finland

>or somewhere. It does not do to well on DB apps yet though....

> This I gotta see! :) Could you uuencode it to me? Put it on an FTP site?

> post it to the group? Put a link in a WWW page?

Are you foolish ?!! :-((((

This tool is a threatening attack to all VB-Programmers -

know-how, ressources and code could be revealed,

even - and maybe first of all - shareware-restrictions

are easy to remove...

This is the reason for me to give absolutely

NO INFORMATION about the tool,nor it's name nor the author

- and I hope, that those, who already know about, do the same way.

I've got a well working demo-version of this dsicompiler and it extracts both

.bas, .frm and variable types; even the tabs of the sourcecode - maybe

there'll anybody go to court against MICROSOFT, because they left the

p-code in this - easy recoverable way - and didn't inform about this fact... Or

could anybody tell me the sense of tokens, representing tabs in source code

? Or of tokens, identifying whether variables were declared by type-identifer (

a%, b$) or not (dim a as integer) ?? I suppose, that the tool I've got is not the

only existing one... Ask Microsoft about this topic...

Don't forget - you're on digging your own grave...

As already mentioned - I DO NOT GIVE any informations about !

Oliver


Decompiler VB

LUOKKA: coding

28096 (90+)  weigand@stimpy.eecis.udel.edu  29.07.95  03:34

Steven Weigand: "Re: VB DISCOMPILER !!!!"

There seems to be a lot of confusion as to whether or not something

like this can exist.  Someone says it is possible,  so that means that

others are going to look into it to try to hack it themselves.  That

of course made me curious,  so I did a very simple Hex Edit on a compiled

VB EXE file.  I looked through the mess,  and found that my variable

names were all there, dudes!!  All a good programmer/hacker would need

is to learn the EXE file format and that P-code that VB uses,  and that'd

probably be enough to go back to the source code.  The fact that all

the variable names are there intact is just scary.

Off hand,  I can think of no way of preventing a decompiler from being

able to get the source code back.  In other words,  VB programmers

have good reason to be worried.

  - Steve Weigand

    (weigand@udel.edu)


Delay

LUOKKA: timer

Date: 07/20/94 (17:57)              Number: 12614 of 12618 (Refer# NONE)

From: ROBBIJE@UNCVX1.OIT.UNC.EDU

Subj: Re: !!! Wait (a minute) routine needed !!!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <gsk.192.224A3BA0@idx.com>, gsk@idx.com (George Kaczowka)

writes:

>>Try this:

>>Dim t0, t1

>>t0 = Timer

>>Do Until Timer > t0 + some_time_in_seconds

>>        DoEvents

>>Loop

>

> What I have done in the past was to set up a timer which kept firing every

> 30 seconds or so. This seemed to be the best since this needs to work

> even when days wrap the Timer value... Due to processing activity, this >

may actually delay slightly LONGER than the requested time..

.....

  If you're worried about the day change confusing your "short" delay

routine then use the GetTickCount API function.  You can declare it as:

Declare Function GetTickCount Lib "User" () As Long

  You can call this and it will return the number of milliseconds that have

elapsed since Windows was started.  You can still run into trouble if

Windows has been running for 49 days on your machine, but this isn't that

likely :).  The other addvantage is that you can specify wait times down

to a thousandth of a second instead of just to the second.  In the code

above just replace "Timer" with "GetTickCount" and declare t0 as Long

(which is really needs to be anyway since Timer can return up to 86,400

seconds elapsed since midnight, and integers can only handle up to 32,767.

Jim


Delay

LUOKKA: timer

Date: 07/30/94 (21:26)              Number: 13895 of 14165 (Refer# NONE)

From: GSBELL@AMOCO.COM

Subj: Re: !!! Wait (a minute) routine needed !!!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1994Jul20.101806.1@uncvx1.oit.unc.edu>

robbije@uncvx1.oit.unc.edu writes:

> In article <49435@mindlink.bc.ca> Cezar_Mart@mindlink.bc.ca (Cezar

Mart) writes:>>

>Dim t0, t1

>t0 = Timer

>Do Until Timer > t0 + some_time_in_seconds

>        DoEvents

>Loop

> What I have done in the past was to set up a timer which kept firing every

> seconds or so. This seemed to be the best since this needs to work even

> days wrap the Timer value... Due to processing activity, this may actually

> delay slightly LONGER than the requested time..

What you really need to do is take a slightly different approach...

This code will work in Access as well as VB.

Function WaitASec(ByVal pstrWaitSeconds As Long)

    Dim lngStartTime As Long

    lngStartTime = Now

    Do

        DoEvents

    Loop Until DateDiff("s", lngStartTime, Now) >= plngWaitSeconds

End Function

Then call the function with the number of seconds to wait, like

varRet = WaitASec(5)

 Gordon Scott Bell


Delay

LUOKKA: timer

Date: 08/16/94 (10:06)              Number: 15748 of 15821 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re:Pause

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try this (I'm doing this from memory, so may be a little off):

Set the Timer's Eanbled prop to False, and the Interval prop to 2000.

Generate a string array of bitmaps called Bitmap$().  When you want to

display your bitmap, presumably in pict1, turn the timer on from

whichever event you're in at the time:

 Timer1.Enabled = True

Sub Timer1_Timer

    Static x%

    DoEvents

    pict1.Visible = True

    pict1.Picture = LoadPicture(Bitmaps$(x%))

    if x% = UBound(Bitmaps$, 1) then

        Timer1.Enabled = False

        pict1.Visible = False

        x% = 0

    Else

        x% = x% + 1

    End If

End Sub

This will cycle the bitmaps through pict1 until there aren't any more,

then it will turn off the engine.  You need to initialize the array.

Your app will be able to do aother things while the bitmaps are cycling.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


Delay

LUOKKA: timer

Date: 09/16/94 (10:15)              Number: 19531 of 19727 (Refer# NONE)

From: REID@LVLD.HP.COM

Subj: Re: How do I do a sleep()?  I need to pause my program!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

This works for me.  Just put an otherwise unused timer control on a form that

will be active when you want to "sleep".  Set its default "Enabled" state to

FALSE via the properties menu.  Not sure what the max value for

msDelayTime should be but since Interval is an Integer, I'd guess 32,000.

In the timer event for this timer, put 1 line:

Sub Timer2_Timer ()

   MainMenu!Timer2.Enabled = False

End Sub

On my 486/66 there seems to be about 20-30 ms overhead just getting to the

Sub, setting things up and returning so don't count on accurate small

delays.  100's of ms seems to work pretty well though.

Sub timed_wait (msDelayTime As Integer)

   MainMenu!Timer2.Interval = msDelayTime       ' setup for X mSec wait

   MainMenu!Timer2.Enabled = True

   Do While MainMenu!Timer2.Enabled = True

      X = DoEvents()                            ' won't work without this!

   Loop

End Sub

Reid


Delay

LUOKKA: timer

Date: 09/16/94 (14:52)              Number: 19642 of 19727 (Refer# NONE)

From: LGAINOUS@IX.NETCOM.COM

Subj: Re: How do I do a sleep()?  I need to pause my program!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try this subroutine.  It's set up for whole seconds, but you can

modify it to handle milliseconds or clock ticks.

Sub sleep (ByVal iSecs As Integer)

'// Will 'suspend' execution of the program until the elapsed number

'// of seconds.  This number of seconds, is passed in thru iSecs.

'//

'// Les Gainous 05/05/94

=================

Dim dtOrigDate, dtOrigTime As Variant

If IsNull(iSecs) Then iSecs = 1

dtOrigDate = DateValue(Now)

dtOrigTime = TimeValue(Now)

While Abs((Second(Now) - Second(dtOrigTime))) < iSecs

Wend

End Sub


Delay

LUOKKA: timer

Date: 09/18/94 (18:23)              Number: 19939 of 20037 (Refer# NONE)

  To: ALL

From: PP000458@INTERRAMP.COM

Subj: Re: How do I do a sleep()?  I need to pause my program!

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Declare Function GetTickCount Lib "User" () As Long

>Sub My_Pause (Delay As Integer)

>Dim entered As Long

>Dim right_now As Long

>entered = GetTickCount()

>Do While right_now - entered > Delay

>    DoDoEvents

>    right_now = GetTickCount()

>Loop

>End Sub

OOPS! that was wrong. Here's the correct code if anyone cares:

Sub my_pause (delay As Integer)

Dim entered As Long

Dim right_now As Long

entered = GetTickCount()

right_now = entered

Do While right_now - entered < delay

    DoDoEvents

    right_now = GetTickCount()

Loop

End Sub


Delay

LUOKKA: timer

Date: 05/02/94 (09:27)              Number: 5053 of 5181 (Refer# NONE)

From: ATREHAN@CSTP.UMKC.EDU

Subj: Re: Where is the DELAY function?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <Coz5LG.8tF@edb.tih.no>, jornj@edb.tih.no (Joern Jensen) writes:

>Hannes Hogni Vilhjalmsson (hhv@rhi.hi.is) wrote:

>: How can a cause my program to pause for exactly 300 ms ?  Currently

>This method is perhaps a little ugly, but it should do the work:

>I suppose you have a timer-object, Timer1, and a global variable 'flag'

>that can be True or False.

>sub delay(ms as Long)

> Timer1.Delay=300

> Timer1.Enabled=True

> flag=False

> while not flag

> loop

>end sub

>

>sub Timer1_Timer()

> flag=True

>end sub

The above will never work unless you add the   dummy=DOevents()   call

inside the loop.   Also as timer events have LOW priority, the delay IS

UNPREDICTABLE !!

Implement it using the System Time (Time$, Now) etc instead

or use the Windows SYSTEM timer tick. Or a counter in a loop !!!

-Tony


Delay

LUOKKA: timing

Date: 11/30/94 (09:48)              Number: 28426 of 28427 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Pause / Wait

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Sub WaitSecs (secs)

>  Dim start!, Temp%

>  start! = Timer

>  While Timer < start! + secs +1

>      Temp% = DoEvents()

>  Wend

>End Sub

Erk! Not *this* one again. It shows up about every month!

Do *not* use Timer for this, use Now and encode your delay as secs /

86400 (double precision). Using Timer, this loop will hang forever over

midnight.

And what's with the "<" and the "+1". Ever hear of the "<=" operator?

--

Luke Webber


Delay ok 1

LUOKKA: timer

Date: 05/02/94 (15:36)              Number: 5115 of 5181 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Where is the DELAY function?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Gamaliel (gamaliel@aol.com) wrote:

:   ' Get the current seconds since midnight

:   Start! = Timer

:   ' Wait for seconds to elapse

:   While (Timer < (Start! + secs!))

:     ' Let other things run while we wait

:     DoEvents

:   Wend

: End Sub

Hmmm- might want to be just a tad careful when firing this puppy up at

23:59:59.98.

gt


Delay ok 2

LUOKKA: timer

Date: 05/02/94 (15:47)              Number: 5123 of 5181 (Refer# NONE)

From: CZ_HOWER@DELPHI.COM

Subj: Re: Where is the DELAY function?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sub pause (ia)

'Pauses for ia seconds

Dim t As Variant

    t = Now

    While DateDiff("s", t, Now) < ia

        DoEvents

    Wend

End Sub


Delay ok 3/1

LUOKKA: timer

Date: 05/10/94 (10:38)              Number: 5281 of 5348 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Where is the DELAY function?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sub Delay(fSeconds As Single)

Dim fCurTime As Single

    fCurtime = Timer

    Do

        DoEvents

    Loop Until Timer-fCurTime >= fSeconds

End Sub

No midnight problems, no need to include msafinx.dll.


Delay ok 3/2

LUOKKA: timer

Date: 05/11/94 (11:33)              Number: 5367 of 5645 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Where is the DELAY function?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

"Arjen Broeze" <arjen@shear.iaf.nl> writes:

>On Sat, 7 May 94 06:06:58 -0500 Chad Hower <cz_hower@delphi.com>

wrote:

>> Try:

>> Sub pause (ia)

>> 'Pauses for ia seconds

>> Dim t As Variant

>>     t = Now

>>     While DateDiff("s", t, Now) < ia

>>         DoEvents

>>     Wend

>> End Sub

>Why so complicated:

>Sub Delay(fSeconds As Single)

>Dim fCurTime As Single

>    fCurtime = Timer

>    Do

>        DoEvents

>    Loop Until Timer-fCurTime >= fSeconds

>End Sub

I hate to tell you this, but this *does* have a midnight problem. Timer

does not include the date.

If you don't like using DateDiff, try taking the following...

Dim EndTime as single

 EndTime = Now + (ia / 86400)

 Do While Now < EndTime

  DoEvents

 Loop

This has the advantage of being able to delay for sub-second periods.

Why 86400? The number of seconds in a day.

Have fun,

Luke Webber


Delay ok 4

LUOKKA: timer

Date: 05/10/94 (10:45)              Number: 5288 of 5348 (Refer# NONE)

From: DAVE.WATERSON@ALMAC.CO.UK

Subj: Where is the DELAY f

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 7/5/94, Gamaliel wrote to ALL: *****>>

GG>>Hmmm- might want to be just a tad careful when firing this puppy up at

GG>23:59:59.98.

GG>Yeah your'e right, I should have mentioned that if you fire it up in that

GG>period between 11:59 and 59/60ths of a second PM. That there could a

GG>problem because it is keyed to the time of day. But I thought I'd post it

GG>because of it's simplicity. I has served me well.

here is the function that I use

in global.bas or whatever

Declare Function GetCurrentTime Lib "User" () As Long

Declare Function GetTimerResolution Lib "User" () As Long

Function Delay (dur As Single) as single

    elapsed! = 0

    start! = GetCurrentTime() / GetTimerResolution()

    Do Until elapsed! > dur OR elapsed! < 0

        elapsed! = (GetCurrentTime() / GetTimerResolution()) - start!

        r = DoEvents()

    Loop

    delay = elapsed!

End Sub

this give a timer loop that will be ok until windows has been running for

around 49 days (it sez in Appleman!) the elapsed!>0 makes the routine end

the wait when the rollover occurs rather than waitforever. It returns the

elapsed time so you would use it as.

x!=delay 23.456

if x!<0 then the rollover will have invalidated the period

This may be of more use to some people rather than the VB datediff("s",a,b)

function as if you use that you have to distribute MSAFINX.DLL with your

app. This routine could be extended to cope with the 49day rollover better

but as I never have windows running uninterrupted for anywhere near that

length of time this is fine for me.

if anyone 'fixes' this PLEASE forward me a copy of the routine

/============================  /==========================

" Dave Waterson               " dave.waterson@almac.co.uk "

" Energy Action Grants Agency " dave@eaga.demon.co.uk     "


Delay ok 5

LUOKKA: timer

Date: 05/12/94 (12:55)              Number: 5605 of 5645 (Refer# NONE)

From: GINS@SUNSPOT.COM

Subj: Re: Where is the DELAY f

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here's one more option. No midnight problem. Also in millisecs.

Declare Function GetTickCount Lib "User" () As Long

Sub delay (millisecs&)

    Dim start&

    start& = GetTickCount()

    Do Until GetTickCount() > start& + millisecs&

        DoEvents

    Loop

End Sub


Delay ok_not

LUOKKA: timer

Date: 05/02/94 (15:06)              Number: 5110 of 5181 (Refer# NONE)

From: GAMALIEL@AOL.COM

Subj: Re: Where is the DELAY function?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Hannes Hogni Vilhjalmsson (hhv@rhi.hi.is) wrote:

>: How can a cause my program to pause for exactly 300 ms ?

Here is a simple method for delaying.

Just use Delay.  seconds or fraction of a second

  ' Wait, for effect

  Delay .75   ( 3/4 second delay )

************************************

     >  IN .BAS MODULE <

' This procedure delays the given number of seconds, which can be

fractional.

'

Sub Delay (secs!)

  Dim Start!

  ' Get the current seconds since midnight

  Start! = Timer

  ' Wait for seconds to elapse

  While (Timer < (Start! + secs!))

    ' Let other things run while we wait

    DoEvents

  Wend

End Sub

Gamaliel@aol.com


Delphi

LUOKKA: misc

21658 (154+)  ACP@mindlink.bc.ca  19.06.95  18:50

Ashton Computer Professionals: "Re: VB vs. Delphi ?"

ChrisRowley@omb.co.mo.md.us (Chris Rowley) wrote:

>

> 1. Database support really blows. Instead of a few DLLs, you have to

> use the Borland Database Engine which means no 1-floppy created

> programs. BDE is two disks to itself, and often requires end-user

> interaction. It is a true mess and because of this I could never write

> a DB app and consciosly subject someone to the BDE. Abandon this

> Borland, and why can Microsoft access Paradox and dBASE direct, but

> with BDE I can only access Access 2.0 through ODBC. The BDE is the

> single main reason I won't be using Delphi much.

Can't say I haven't touched it yet, that's not how I intend on using

Delphi yet...

> 2. Strings. Bogus 255-character Pascal strings which can't be used

> with the API. Borland should have scrapped this and gone with one type

> of string, not one for Pascal and one for the API which require a lot

> of headache to translate around.

Borland added the Pascal String, because in previous editions of TP for

Windows, there was ONLY the PChar...Now, exactly how would you enjoy

setting

a simple text caption, using PChars....?

> 3. The big argument with Delphi is speed and size of code. As far as

> speed, it is a nice fast language, but on 66DX2 machines, today's

> "low-end" the kind of multimedia and database apps I write every day

> see no real increase in speed with Delphi. For size, Delphi is huge.

> With no "p-code" interpreter DLL (which is in fact just the most

> common routines of VB as a language), Delphi must bind lots of stuff

> to your executable. This may be no big deal with commercial software,

> but in house? That fabulous VBRUN300.DLL is only needed once, and

then

> the executable are 20K, 50K, etc., versus a minimum 160K per

> executable with Delphi. Just a "Hello world" example is huge. That DLL

> may seem like an anchor to many, but it's an easy way for quick,

> effecient, and usefull apps to be written and distributed.

Tis a problem, but not if the app is one that is in use all day....

If it's a utility app that loads, and unloads, I can see using VB...

But if it is the core interface to your business practices, it is worth

the size...

Look at commercial apps which users spend all day working with...They are

anything but small, yet they are very robust...

> 4. What you get is nuts. For your $200 (at my time or purchase, the

> first day of release), you don't get the language syntax. You have to

> buy that book, along with the VCL source (the basic structures like

> list boxes, etc in Delphi are thankfully fully written in Delphi so

> you can learn from example the intricacies of basic Windows

> application design) in a Bonus Pak type thing. No, no, this is a

> LANGUAGE, please define that LANGUAGE. Then, they want $2000 for

> Client/Server. Look, why not a $300 version with Delphi, the language

> books and the VCL source. Some of us don't need glued-on tools like

> version control and team design.

I agree with the lack of syntax, however, I for one do NOT need the source

VCL code yet, maybe in 6 monthes, or so, when I'm more comfortable with

Object Pascal I'll need it...Beats paying $500 all at once...

> Delphi is fast and fun and a much better language than VB. But if

> databasing is your game, you need a lot of custom controls, or you're

> only buying it because you THINK it will be faster, stay with VB. It

> is still so easy to get jobs done.

I plan on using for certain database apps...But I have the specs for dBASE

III+

files, and plan on writing a simple unit to dump data to one....

That way I have litte overhead, no "engine" to ship, and yet, I still

have a robust app, where users can get to the data if they need it...

I wouldn't use it in every circumstance, but depending on the project,

it is worth it...

>      Chris

ttyl

Jason


Delphi documentation

LUOKKA: misc

Date: 07-18-95 (03:47)              Number: 389593 of 390073 (Refer# NONE)

From: R.CZERWONKA@COWAN.EDU.AU

Subj: Re: delphi question - documentation

---you can download delphi-documentation (object pascal).....

ftp.borland.com

www.borland.com


Developm. enviroment?

LUOKKA: coding

Date: 11/28/94 (11:37)              Number: 138523 of 138777 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Development-Enviromen

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

WM> I would like to supress some functions of my application

WM> when it is not running in the development enviroment.

WM>

WM> Can anybody help me to find out wether my program runs in

WM> the IDE or as stand-alone exe-file?

        Try the following code:

Declare Function GetModuleHandle Lib "Kernel" (ByVal lpModuleName As

String) As  Integer

Function DebugPrg% (Dum)    ' sub will detect if prog runs in debug mode

'Last rev. 7 May 94 by Giora Drachsler

    EXE$ = "vb.exe"         ' see if dev sys is running

    hModule% = GetModuleHandle(EXE$)

    Dim HBuffer As String * 255

    L% = GetModuleFileName(hModule%, HBuffer, Len(HBuffer))

    'ProgDir$ = Left$(HBuffer, L%)

    DebugPrg% = (hModule% <> 0)     ' set ret val

End Function


DIM/%

LUOKKA: VBgen

1. Multiple identifiers after the DIM statement can be confusing

   Some programmers with background from Pascal can try the following

     Dim iA, iB, iC as Integer

   and think that all these 3 variables end up as Integer. In fact,

   the first two end up as default data type, normally Variant.

   Instead you should do

     Dim iA as Integer

     Dim iB as Integer

     Dim iC as Integer

   which takes up more space, but gives you room to comment your

   variables (hint, hint); *or*

     Dim iA%, iB%, iC%

   which does the whole job.


Disable ALT+TAB

LUOKKA: VBgen

Date: 06-22-95 (11:49)              Number: 369947 of 370426 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: (none)

From: Nicholas Williams <gbbs65c6@IBMMAIL.COM>

           RE: Disabling ALT-TAB

           In the Windows section of WIN.INI is a line CoolSwitch=x.

           CoolSwitch=1 enables ALT-TAB and CoolSwitch=0 disables it. By

           modifying this from your VB program you can set this as you wish.

           N Williams.


Disable ALT+TAB

LUOKKA: VBgen

1117 (5+)  Sanyal@cris.com  02.12.94  01:17

Arjun Sanyal: "Re: How to disable ALT+TAB?"

I need to know the same thing... I'm writing a GUI launcher for my school's

library  compter system, but I don't want some woulb be hacker getting

around my forms.I got this from the MS Knoledge Base, but I need the form to

be visiable... HELP PLEASE!

--------------------snip!----------------------------------------------------------------

DOCUMENT:Q114776  03-OCT-1994   VBWIN

TITLE   :How to Hide a VB App from the Task List and ALT+TAB Order

PRODUCT :Microsoft Visual Basic for Windows

PROD/VER:2.00 3.00

OPER/SYS:WINDOWS

KEYWORDS:kbprg kbcode

---------------------------------------------------------------------

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0

---------------------------------------------------------------------

SUMMARY

=======

This article demonstrates how to create an application that is invisible

to the Windows Task List and to the fast ALT+TAB switching order.

MORE INFORMATION

================

All Visual Basic applications have a background window that handles all

messages for the application and all calls to the VBRUN300.DLL. This

background window is also the owner and parent of all non-MDI child forms.

You can use the GetWindow and ShowWindow Windows API functions to

hide

this background window.

To be eligible for removal from the ALT+TAB order, an application cannot

have any visible forms. The background window is visible, but you can

use GetWindow to return the background or owner window's handle, and

then

use the handle and ShowWindow to make the window invisible.

Step-by-Step Example

--------------------

This example hides itself from the Windows Task List and ALT+TAB order.

1. Start a New Project in Visual Basic. Form1 is created by default.

2. Add a timer control (Timer1) to the form.

3. Add the following declarations to the general declarations section:

   ' Enter each of the following Declare statements as one, single line:

   Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer,

      ByVal nCmdShow As Integer) As Integer

   Declare Function GetWindow Lib "User" (ByVal hWnd As Integer,

      ByVal wCmd As Integer) As Integer

   Const SW_HIDE = 0

   Const GW_OWNER = 4

4. Add the following code to the load event of Form1:

   Sub Form_Load ()

      Dim OwnerhWnd As Integer

      Dim ret As Integer

      ' Make sure the form is invisible:

      form1.Visible = False

      ' Set interval for timer for 5 seconds, and make sure it is enabled:

      timer1.Interval = 5000

      timer1.Enabled = True

      ' Grab the background or owner window:

      OwnerhWnd = GetWindow(Me.hWnd, GW_OWNER)

      ' Hide from task list:

      ret = ShowWindow(OwnerhWnd, SW_HIDE)

   End Sub

5. Add the following code to the Timer event of the Timer1 control to

   verify that the program is running and to allow you to exit the program:

   Sub Timer1_Timer ()

      Dim ret As Integer

      ' Display a message box:

    ret = MsgBox("Visible by Alt+Tab. Cancel to Quit", 1, "Invisible Form")

      ' If cancel clicked, end the program:

      If ret = 2 Then

         timer1.Enabled = False

         Unload Me

         End

      End If

   End Sub

6. Save the project as INVIS.MAK and create an executable entitled

   INVIS.EXE.

7. Run the program by double-clicking INVIS.EXE in File Manager or by using

   the Run option in Program Manager. When you run the program, there

   should be no visible forms and the program title should not appear in

   the Task List or in the ALT+TAB order. After five seconds, the

   application should display the message box. Then the program should be

   visible to the ALT+TAB order, but not the Task List. Click the Cancel

   button to exit the application, or click OK to allow it to continue to

   run.

Additional reference words: 2.00 3.00 hide invisable

KBCategory: kbprg kbcode

KBSubcategory: APrgOther


Disable close

LUOKKA: menus

Date: 05/26/94 (20:55)              Number: 7217 of 7221 (Refer# NONE)

From: GRTORLBA@BACH.SEATTLEU.EDU, George R. Torralba

Subj: Re: How do I disable "close" in control menu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <CqF9C8.2BM@ilx.com>, John Wu <johnwu@ILX.Com> wrote:

: How do I disable/enable the "close" function in control menu?

This should be in one of the VB sources (FAQ, KB) but anyway, you can do;

  Dim hmenu%

  hmenu = GetSystemMenu(form.hwnd, FALSE)

  EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND Or

(MF_DISABLED/MF_ENABLED))

George


Disable close

LUOKKA: menus

Date: 05/28/94 (12:03)              Number: 7306 of 7311 (Refer# NONE)

From: FARSHADV@TELEPORT.COM

Subj: Re: How do I disable "close" in control menu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In <CqF9C8.2BM@ilx.com> johnwu@ILX.Com (John Wu) writes:

>How do I disable/enable the "close" function in

>control menu?

Declare Function GetSystemMenu Lib "User"

  (ByVal hWnd As Integer, ByVal bRevert As Integer) As Integer

Declare Sub ModifyMenu Lib "User"

  (ByVal hMenu As Integer, ByVal nPosition As Integer,

   ByVal wFlags As Integer, ByVal wIDNewItem As Integer,

   ByVal loString As Any)

Const MF_BYPOSITION = &H400

Const MF_GRAYED = &H1

Sub Form_Load()

  hMenu=GetSystemMenu(Form1.hWnd,False)    ' Get System menu Handle

  ClosePosition=6                          ' Usually This is where Close is

  Flags = MF_BYPOSITION OR MF_GRAYED

  St$="&Close" & Chr$(9) & "Alt+F4"        ' This needs to match the menu

  Call ModifyMenu(hMenu, ClosePosition, Flags, 0, St$)

End Sub

See Visual Basic Progarmmers Journal, April/May 94, Vol 4, No 3, Page 78

--

farshadv@teleport.COM  Public Access User --- Not affiliated with

TECHbooks

Public Access UNIX and Internet at (503) 220-1016 (2400-14400, N81)


Disable user input

LUOKKA: forms

Date: 08/26/94 (17:25)              Number: 17159 of 17164 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Help! Disallowing use

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 8/25/94 5:08 PM ac993@FreeNet.Carleton.CA (David Kent) wrote:

>When a report or something similar is being produced (i.e. output is being

>directed to the printer using PRINTER.PRINT in a loop), how do I clear the

>user input buffer so that the mouse clicks will not be acted upon after

>the report has completed?

Set the form.Enabled = False.

__________

                           Bradley S. Murray


Disable user input

LUOKKA: forms

Date: 08/28/94 (20:06)              Number: 17603 of 17628 (Refer# NONE)

From: LOGIN_NAME@HOOKUP.NET

Subj: Re: Help! Disallowing user input

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

For example, when a user clicks a button on a form to produce a report,

>how do I disable any further mouse clicks on the form until the report has

>completed?

I use the following code fragment to disable user input when needed:

Declare Function EnableHardwareInput Lib "User" (ByVal bEnableInput As

Integer) As Integer

Dim i As Integer

'turn off all input

i = EnableHardwareInput(False)

'turn input back on

i = EnableHardwareInput(True)


Disable user input

LUOKKA: forms

Date: 01/17/95 (19:01)              Number: 189010 of 191526 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Disabling/Enabling Keybd and Mouse ? -Reply

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>Look into the .Enabled property of the form that you wish to disable

>keyboard and mouse input to. This will NOT disable it for all of windows,

>just the application you are programming.

If you want disable inputs totally, not only to one form, try following.

Declare Function EnableHardwareInput Lib "User" (ByVal bEnableInput As

Integer) As Integer

Sub Form_Load ()

   Timer1.Interval = 10000

   Label1 = "Enabled"

End Sub

Sub Timer1_Timer ()

   Static Pass

   If Pass = 0 Then

      retVal = EnableHardwareInput(False)

      Label1 = "Input Disabled"

      Pass = Pass + 1

   Else

      retVal = EnableHardwareInput(True)

      Label1 = "Input Enabled"

      Timer1.Enabled = False

   End If

End Sub

But don't blame me if you end up locking all input to system.

Lasse


Discompiler VB!

LUOKKA: VBgen

28096 (90+)  weigand@stimpy.eecis.udel.edu  29.07.95  03:34

Steven Weigand: "Re: VB DISCOMPILER !!!!"

>o Someone has announced to the world the existance of a program

>that can reconstruct VB source from executables.

There seems to be a lot of confusion as to whether or not something

like this can exist.  Someone says it is possible,  so that means that

others are going to look into it to try to hack it themselves.  That

of course made me curious,  so I did a very simple Hex Edit on a compiled

VB EXE file.  I looked through the mess,  and found that my variable

names were all there, dudes!!  All a good programmer/hacker would need

is to learn the EXE file format and that P-code that VB uses,  and that'd

probably be enough to go back to the source code.  The fact that all

the variable names are there intact is just scary.

Off hand,  I can think of no way of preventing a decompiler from being

able to get the source code back.  In other words,  VB programmers

have good reason to be worried.

  - Steve Weigand

    (weigand@udel.edu)


Disk free space

LUOKKA: API

Date: 04/04/94 (17:04)              Number: 2649 of 2673 (Refer# NONE)

  To: ALL

From: RICK.ESTERLING@MSFC.NASA.GOV, Rick Esterling

Subj: Re: Getting Disk Free Space from VB?

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

For those who do not know C or cannot write their own DLLs:

The SETUPKIT.DLL that comes with VB also has a function that returns

the disk space available on the current drive.  It is declared as follows:

Declare Function DiskSpaceFree Lib "setupkit.dll" () As Long

Usage:

      Dim bytesAvail as Long

      bytesAvail& = DiskSpaceFree()

        -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                               Rick Esterling

                          rick.esterling@msfc.nasa.gov

                               CIS: 73322,702


Disk free space

LUOKKA: API

Date: 03/28/94 (19:34)              Number: 2225 of 2518 (Refer# NONE)

From: TARRJ@CCMAIL.US.DELL.COM

Subj: Re: Getting Disk Free Space from VB?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (+)

There is a function in the Setup sample code that comes with VB3.0.

See below:

Declare Function DiskSpaceFree Lib "SETUPKIT.DLL" () As Long

'------------------------------------------------

' Get the disk space free for the current drive

'------------------------------------------------

Function GetDiskSpaceFree (drive As String) As Long

    ChDrive drive

    GetDiskSpaceFree = DiskSpaceFree()

End Function


Disk label reading

LUOKKA: misc

===========

Date:         Wed, 14 Sep 1994 22:56:05 CEST

From:         Nicola Brion <MC1920@MCLINK.IT>

Subject:      reading a disc label fro

>> Anybody know how to read a disc label in VB?

Try

my_label$=dir$("c:\",ATTR_VOLUME)


Disk serial number

LUOKKA: VBgen

Date: 08/25/94 (00:38)              Number: 16920 of 17020 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Getting a disk's serial number

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sub Form_Load ()

   Dim I As Integer

   Dim FileNo As Integer

   Dim DataString As String

   Dim SerialNumber As String

   On Error Resume Next

   I = Shell(Environ$("COMSPEC") + " /C DIR *.NON > TempFile.txt", 6)

   If I <> 0 Then

      FileNo = FreeFile

      Do

         Open "TempFile.txt" For Input As FileNo

         DoEvents

      Loop Until Not Err

      Do

         Line Input #FileNo, DataString

         I = InStr(1, DataString, "Serial Number Is ", 1)

         DoEvents

      Loop Until I > 0 Or EOF(FileNo)

      Close FileNo

      If I > 0 Then

         SerialNumber = Mid$(DataString, I + 17)

      End If

   End If

   End

End Sub

Chuck

Mesquite TX


Disk serial number

LUOKKA: VBgen

Date: 12/07/94 (12:46)              Number: 146619 of 146922 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: ReŽ5�: Reading a disk serial number

From: David Musgrove <dwm@DLD.DIRCON.CO.UK>

>One thing you can do is to SHELL to the LABEL command. If there is a

serial

>number there it will display it in the dialog. (You may have to redirect a

>carrige return as input to skip the actual label step if you care.) I am

>not sure how to get the output of the SHELL. I would guess that at the

>least you could redirect it to a specific file name. This sounds kind of

>kludgy. Let's hope you get a better answer.

I do something like this at the moment - my reason for posting the question

initially was that it is unbelievably kludgy, and I'm amazed there's no

automatic way to do it. This is the function I use at present (it works with

floppy and hard drives, if formatted by DOS 4.0 or higher (as someone has

already pointed out). The function takes the drive letter as a parameter (or

a path name - it strips it down to the first character anyway), and returns

the serial number as a nine character string ("XXXX-XXXX").

Kludgy, but it works - feel free to nick the code if it's any use. I'm still

looking for something better, though.

Function DiskSerialNumber$ (Drive$)

    Dim TempFileName$

    Dim intReturn$

    Dim fh%

    Dim DirLine$

    Dim CommandString$

    If Len(Drive$) > 1 Then Drive$ = Left(Drive$, 1)

    TempFileName = Space(144)

    On Error GoTo NotReady

    DirLine = Dir$(Drive & ":™*.*", 8)

    fh = FreeFile

    Open "C:™DIRA.BAT" For Output As fh

    Print #fh, "@echo off"

    Print #fh, "dir " & Drive & ": > c:™dira.txt"

    Close fh

    intReturn = Shell("C:™DIRA.BAT", 2)

    While GetModuleUsage(ByVal intReturn) > 0

        DoEvents

    Wend

    fh = FreeFile

    Open "C:™DIRA.TXT" For Input As fh

    Line Input #fh, DirLine

    Line Input #fh, DirLine

    Line Input #fh, DirLine

    DiskSerialNumber = Mid(DirLine, 26, 9)

    Close fh

    Kill "C:™DIRA.BAT"

    Kill "C:™DIRA.TXT"

    Exit Function

NotReady:

    DiskSerialNumber = "Disk not ready"

    Exit Function

End Function

====================================================

David Musgrove

Telephone: +44 171 229 1449    Fax: +44 171 727 0281


Disk serial number

LUOKKA: VBgen

Date: 01/25/95 (10:23)              Number: 199372 of 201095 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Disk Serial number

In order to get the disk serial number, you can use the MS-DOS INT 21h

function 440D subfunction 66h (GetMediaID).

However it requires writing a DLL to call the function for you since you

can't call MS-DOS functions from VB directly. You'll need a C compiler with

an inline assembler (like Visual C++ 1.5 or Borland C++ 4.0), or if you're

into pain, an assembler like MASM 5.1 or 6.0.

Here's some information from the MS-DOS programmer's reference (from

MSDN).

To help distinguish one removable disk or tape from another, the format

command creates a unique identifier for each volume (for example, each disk

or tape) as it formats the volume. Programs can also create their own unique

identifiers by using Set Media ID (Interrupt 21h Function 440Dh Minor Code

46h) to set the volume label, volume serial number, and file-system type. A

program can retrieve this information by using Get Media ID (Interrupt 21h

Function 440Dh Minor Code 66h). (A volume label consists of up to 11

characters of the same type used in filenames.)

Function 440Dh Minor Code 66h  Get Media ID

mov     bx, Drive            ;0 = default, 1 = A, 2 = B, etc.

mov     ch, 08h              ;device category (must be 08h)

mov     cl, 66h              ;Get Media ID

mov     dx, seg MediaID

mov     ds, dx

mov     dx, offset MediaID   ;ds:dx points to MID structure

mov     ax, 440Dh            ;IOCTL for Block Device

int     21h

jc      error_handler        ;carry set means error

Get Media ID (Function 440Dh Minor Code 66h) returns the volume label,

serial number and file system for the specified drive.

Parameters

Drive

Specifies the drive for which information is to be returned (0 = default

drive, 1 = A, 2 = B, etc.).

MediaID

Points to a MID structure that receives information that uniquely identifies

a disk or other storage medium. The MID structure has the following form:

MID STRUC

    midInfoLevel   dw  0           ;information level

    midSerialNum   dd  ?           ;serial number

    midVolLabel    db  11 dup (?)  ;ASCII volume label

    midFileSysType db  8 dup (?)   ;file system type

MID ENDS

For a full description of the MID structure, see Chapter 3,  File System.

Return Value

If the function is successful, the carry flag is clear, and the parameter

block is filled in with information about the disk. Otherwise, the carry flag

is set and the AX register contains an error value, which may be one of the

following:

Value   Name

0001h   ERROR_INVALID_FUNCTION

0002h   ERROR_FILE_NOT_FOUND

0005h   ERROR_ACCESS_DENIED

Comments

Get Media ID returns 0002h (ERROR_FILE_NOT_FOUND) if the specified

drive

number is invalid.

See Also

Function 440Dh Minor Code 46h  Set Media ID

Eric Lee Steadle

PS if you want me to do it for you (write the DLL that is) send me a direct

email: STEADLE@AOL.COM


Display form

LUOKKA: forms

Date: 05/25/94 (03:55)              Number: 6855 of 6934 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Can't Display Form in

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 05-23-94 GAT@CSN.ORG  wrote:

G>m.   roshan (mroshan@julian.uwo.ca) wrote:

G>: rest of the form pops up. How would I tell Windows to , 'Hey, finsih

G>: what you started!'

G>DoEvents

Do TWO Events (there small! <g>)

And set your form's .ClipControl and .AutoRedraw properties to False.

And cut George a little slack - he likes to give one-word (preferrably

monosyllabic) answers whenever he thinks he can get away with it!

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Display form 2

LUOKKA: forms

Date: 05/25/94 (13:56)              Number: 7024 of 7084 (Refer# NONE)

From: LWALTERS@OZEMAIL.COM.AU

Subj: Re: Can't Display Form in time

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I disagree with the DoEvents in this case because it releases time to

Windows. For the problem you are experiencing, use a Me.Refresh or

<form>.Refresh immediately after the show command. This will only work if

the Show is MODELESS.

For a MODAL show, place the Me.Refresh inside the Form_Load event.

------------

Lawrence Walters   Phone  : 61+ 2-831-7729

Senior Consultant   Fax : 61+ 2-831-8050

Baseware Australia Pty Ltd  EMail :

LWALTERS@ozemail.com.au


Display form faster

LUOKKA: forms

Date: 05/29/94 (09:38)              Number: 7348 of 7455 (Refer# NONE)

From: GSBRANDE@ACS.UCALGARY.CA

Subj: Re: Faster Form Displaying?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can do it fairly easily, but you have to use the API.

Set frm = New Form1

frm.Refresh

' Turn off repaints with API.

' Populate controls.

' Turn on repaints with API.

' Repaint form with API.

--

Sean Brandenburg         " "Come, Abis Mal, we have other lives to ruin."

gsbrande@acs.ucalgary.ca "        -- Jafar


Display port.problems

LUOKKA: display

Date: 05/02/94 (20:43)              Number: 4912 of 4992 (Refer# NONE)

From: LROGERS@BORIS.WEBO.DG.COM

Subj: VB 3.0 is NOT PORTABLE!!!!!!!!!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I have been using VB for two weeks now and have found what I consider

to be a MAJOR bug already.  The bug has to do with scaling of objects

on video configurations with different twips per pixel settings.

Bottom line is that a twip is not what it is defined to be.  A twip is

supposed to be 1/1440 of an inch.  However, an inch is not an inch on

displays, but some magical measurement only Microsoft can figure out,

so scaling occurs.  This scaling is supposedly controlled by the

ScaleMode property, but stay tuned, this cannot work in a portable

way.

First, bitmaps are defined in pixel coordinates, so they port fine to

all systems.  However, I noticed the problem when I had a bitmap I did

not want scaled placed as the background for a dialog.  A button that

was supposed to appear to the right of the image appeared smaller and

over the image on another display, essentially shrunk and shifted left

and up.  To my surprise, the Left, Top, Width and Height had changed.

But my pixmap remained the same and looked just fine.  However, the

pixmaps Left and Top coordinates had changed.

I spoke with Microsoft and the workarounds they gave me are bogus.

The first one says to make everything a child of a form.  Never use

containers because they have no scale property, so they always store

their contained objects' coordinates in twips.  If a twip is not a

consistent measurement on all displays, which it is not, these objects

will scale.  If you want the effect of placing an object in a

container you can just place it over it.  However, objects such as

labels cannot be raised to appear in front of objects with windows, so

you have to use only window based objects.

This solution sounds good at first.  When you look at the coordinates

of the objects, they are in pixels.  Lovely.  But when I ported the

app to the other display, it still scaled and the coordinates still

were changed in exactly the same way, but they were in pixels

(although, some were in fractions on the other display.  C'mon what is

.3 pixels anyway?).  After getting aggravated and trying a couple more

things I looked in the .frm file for the form.  The bozos are storing

the coordinates in twips anyway, even though you have selected pixels

as the scale mode.  Bottom line, it doesn't matter.  They will scale

anyway to the different definition of what a twip is.  Workaround 1

provided by Microsoft is a smoke screen that cannot and does not work.

The other solution is even more bogus.  It is to define bitmaps which

are in pixels and position all your objects relative to the bitmaps.

Man, just what I want to do with 100 dialogs in my applications.  What

a completely idiotic solution!!

I have a solution, but do not like it.  Each dialog I write that

visually has a portability problem I write a SaveCoords and SetCoords

routine for.  I run savecoords when the object is loaded on my

development system and turn it off on delivered product.  It writes

the coordinates in pixels.  SetCoords reads the file associated with

the dialog and restores the coordinates of all objects in pixels.

The fact that my solution works tells me that Microsoft hasn't a clue

about this problem.  Their workarounds are bogus and the it took five

support engineers just to find the problem and provide me the bogus

workarounds.  The workaround proves that if they had just had the

intelligence to save the coordinates in pixels, then everything would

be portable and all would be well.  But the twip that thought up the

magical twip measurement has embedded it into the guts of the program.

Bottom line,

NO APPLICATION DEVELOPED IN VISUAL BASIC IS PORTABLE to displays

other than the one developed on and other displays with the coincident

number of twips per pixel.  The only way to guarantee portability is

to position ALL OBJECTS at run time in pixel coordinates.


Display port.solution

LUOKKA: display

Date: 05/13/94 (10:34)              Number: 5752 of 5763 (Refer# NONE)

From: LROGERS@BORIS.WEBO.DG.COM

Subj: Re: VB 3.0 is NOT PORTABLE!!!!!!!!!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <HARRYK.42.002429DD@avs.kent.edu> HARRYK@avs.kent.edu

(Harry Kamens) writes:

>Larry Rogers (lrogers@boris.webo.dg.com) wrote:

>: I have been using VB for two weeks now and have found what I

>consider : to be a MAJOR bug already.  The bug has to do with scaling

>of objects : on video configurations with different twips per pixel

>settings.

  ....  ....

There is an easier way to deal with the problem.  Set up a constant in

your VB program telling your app what the twips per pixel is on the

development system.  When the form loads, undo the scaling by

multiplying Left, Top, Width and Height of each object and the form's

width and height by

Screen.TwipsPerPixel/TWIPSPERPIXELDEVELOPMENTSYSTEM.

This undoes the stupid inconsistent scaling that Microsoft does.  Note

that this is not a Microsoft workaround.  It is too simple.  They would have

you create a bitmap and position everything relative to it doing all kinds of

bogus math.  The above solution works because you undo what Microsoft

Basic does when it scales.  Then, fonts and bitmaps which are defined in

pixel dimensions fit perfectly.  No resizing, no nothing.  The only drawback is

that it is possible that large windows will exceed the screen size.  In those

cases, you are on your own.

Larry


Display speed up

LUOKKA: speed

Date: 08/27/94 (22:41)              Number: 17470 of 17472 (Refer# NONE)

From: GUY@TCTLTD.DEMON.CO.UK

Subj: Re: Multiple form program

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<Little SNIP>

>I am writing an application with approximately 7 full screen forms. These will

>be displayed in no particular order. It's 800x600, so it takes a while to draw

>just one form.

<MUCH SNIP>

*******************************************************************************

Hmmm...

Well, I can think of another method, but it would require merging all forms in

to one form...  This may not be feasible for what you are doing, but if it

is...

* Make a single form.

* Create several frames on that form (eg. Frame3D), one for each of your

forms.

* Put all of the controls from each of your forms on to the corresponding

 frame.

You can now have one form loaded and use the Visible property to show and

hide forms.

This may initially sound like the same thing as you are doing already but in

a different way, but...

The advantage is that if you have a common 'thing' on two or more of your

forms then rather than have it duplicated on those forms you can have just

one occurance instead.

Basically, you can reduce the total number of controls in your application and

therefore speed it up...

This is probably useless, but I've found it to be very effective in speeding

up some of my applications.

Other methods:

**************

Set ClipControls = FALSE and AutoRedraw = FALSE - this should speed up a

complex form.

Disable things that you are updating - this also speeds some things up.

Blagg the user:

If the forms are only slow when first loading, display a nice intro screen

for the user to read while they are being created so that the user doesn't

notice the time delay as much.  Also, you could try and have another

application in the bacground using VBRUN?00.DLL so VBRUN?00 is already

loaded.

Hide controls when you move them then redisplay them.

----------

Guy Fraser


DLL and strings

LUOKKA: DLL

Date: 04-01-95 (20:34)              Number: 280290 of 280746 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: DLL's and Strings

I had multiple request for information and a sample of the code for a DLL and

the VB declaration and calling or it for modifiying a string in a DLL so here it

is:

TEST.C

/*

Date         Author        Rev     Program Name  Description

11/29/94     Mike Strange  1.0     TEST          Test DLL

*/

#include <stdlib.h>

#include <string.h>

#include <stdio.h>

#include <windows.h>

#include <dos.h>

#include "c:™vb™cdk™vbapi.h"

#define teststr "This is a test"

// Global Variables

int CALLBACK LibMain (HANDLE hInstance, WORD wDataSeg, WORD

wHeapSize, LPSTR lpszCmdLine)

        if(wHeapSize > 0)

          UnlockData (0);  //Unlocks the data segment of the library

        return 1;

/* This is the code to change the string*/

/* The rest of this module is the needed shell for a DLL in Visual C++*/

void _export CALLBACK strstuff(char straryŽ�)

/*This will just copy a fixed string into the string passed to the DLL*/

    strcpy(&straryŽ0�, teststr);

********************************************************************

This is the definition file for the DLL used by Visual C++

TEST.DEF

LIBRARY   test

EXETYPE   WINDOWS

CODE      PRELOAD MOVEABLE DISCARDABLE

DATA      PRELOAD MOVEABLE SINGLE

HEAPSIZE  1024

EXPORTS

          strstuff @1

          WEP PRIVATE

; To implement your own Windows Exit Procedure add the following

; function to your application (referring to it in the .def file is

; not required.)  The extern "C" is only required if module is C++.

; extern "C" int FAR PASCAL _WEP(int)

;

;       /* Your WEP functionality goes here */

;  return 1;

;

*******************************************************************

TEST.FRM

(general)

Declare Sub strstuff Lib "test.dll" (ByVal sendstr As String)

'Note: test.dll must be in the Windows™system directory

********************************************************************

TEST.FRM

Command1

Sub Command1_Click ()

Dim tempstr As String * 20

Call strstuff(tempstr)

Text1.Text = tempstr

End Sub

********************************************************************

In VB the project is a single form (TEST.FRM) with one text box (Text1)

and one command button (Command1).  When the button is clicked it calls

the function in the DLL with a string of length 20.  The DLL then puts a

hard coded value ("This is a test") into the string and then VB puts the

string into the text box for display.  This is very basic but shows how to

pass a string to a DLL and change the string in the DLL then use the

changed value in VB.

HTH

Mike Strange

Lead Systems Analyst


DLL Borland<->MS

LUOKKA: DLL

Päivä: 01-25-95 (13:53)             Numero: 300 / 301 (Vast. nro EI OLE)

Knltä: SAMI PITKO

 Aihe: Msoft DLL <> Borland DLL

 Kok.: Ohjelmointi (23)           Lukumalli: Yleinen (A) (+)

Sattuipa silmiini seuraava artikkeli Visual Basic Programmer's

Journalista.

---

Borland DLLs are NOT THE SAME as Microsoft DLLs.

The problem occurs if a DLL exports a function that returns float or

double. Any attempt to call this function from a Borland-generated DLL

results in an "Incompatible calling convention" error message from

Visual Basic.

The same function can be called from a DLL created with Visual C++

without problems. The reason is a different calling convention: In

Visual C++ the result is stored on the processor stack; in Borland the

result is stored on the coprocessor stack.

There is a simple fix: use var parameters instead of returning a value.

---

Jos jollekin vaikka sattuu tulemaan tuo "Incompatible calling

convention" virheilmoitus DLL:n kanssa leikkiessä.

Spitco


DLL browsing DLL

LUOKKA: DLL

Date: 11/06/94 (17:41)              Number: 25996 of 26127 (Refer# NONE)

From: CSTUART@METRONET.COM

Subj: Re: Browsing DLL

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>There seems to be quite a few intresting DLL hanging around my

>windows area. How can I browse through the function calls they

>provide.

There is a new shareware program called VersionView which will tell the

owners, etc.

------------------------------------------------------------------------

Chuck Stuart

Mesquite TX USA


DLL callback

LUOKKA: DLL

3. What about DLL calls that require callbacks?

   VB does not support callbacks, but various extensions can help.

   Dan Appleman's "Visual Basic Programmer's Guide to the Windows API"

   comes with a floppy disk which code samples and tools. It also

   includes a VBX which supports the callbacks which many API calls

   require. Dan is also founder and president of Desaware which sells

   more extensive tools, including SpyWorks, for VB developers.

    Walter Hill (whill@netcom.com)


DLL calling

LUOKKA: DLL

Date: 05/15/94 (13:28)              Number: 6192 of 6231 (Refer# NONE)

From: MARTINB@CAM.ORG

Subj: Re: Question about calling DLL

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Lim Teck Soon (tslim@solomon.technet.sg) wrote:

: Another question I have is about passing strings in user defined structures.

: If I have a structure

:         Type Structure

:                 Data As String * 60

:         End Type

: which I want to pass to a dll, I will assign the string like this:

:         Structure.Data = "Data Item" & Chr$(0)

: The Chr$(0) is crucial, right?  The reason why I'm asking is because I've

: seen listings in VBPJ that doesn't use the Chr$(0) character.

Actually, the Visual Basic manuals say to use Byval with a standard ,

unaltered VB string, and VB will automatically add the ' 0' at the end of

the string when passing it to a DLL function. It works for me!

Also things get a bit trickier if you want the DLL to return a string,

for instance if you use GetProfileString to read a string value from the

WIN.INI file. In this case, you start by initialising the string to a

decent length:

 MyString = String$( MAX_LEN, CHR$(0))

Then you pass it to the DLL, with the argument declared as a ByVal string.

In order to retrieve it, you must get rid of the excess zeros.

First use Trim$to get rid of all but one trailing 0:

 TrimString = Trim$(MyString)

As I said, for some reason Trim will leave a 0 in the string, so we get

rid of that with Left$:

 FinalString = Left$(TrimString, Len(TrimString)-1)

Be aware that 90% of the trick is declaring your DLL calls correctly, in

particular, a simple solution is to always use ByVal in front of all

parameters to a DLL to avoid forgetting one... (although not really

necessary for integers and such).

Good luck!

Martin Bechard


DLL calling

LUOKKA: DLL

Date: 07/05/94 (08:25)              Number: 11191 of 11217 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Dll Calling Convention - Incorrect in VB Manuals ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

zaphod@diku.dk (Ole D. M. Lennert) writes:

>gat@csn.org (George Tatge) writes:

>>You don't mention the param types in question.  If string- then "ByVal"

>>does NOT mean "ByVal".  It means "By reference and tack a null on the

end

>>of the string."  See the manual for details.

>Sorry, it slipped my mind. I've seen the manuals, and yes, ByVal converts a

>VB string to a null-terminated string. But what if it's an int? I'm doing

>something with this int in a function in the DLL, and want the "new" value

>returned to VB, together with the return value of the function.

No problem there, just pass it without ByVal, and in your DLL, define the

argument as a far pointer to int, then use it as such. Of course, if you

want to pass an oyster to a subroutine or DLL function, you need to use

the undocumented BiValve keyword. (ouch!)


DLL calling

LUOKKA: DLL

Date: 09/11/94 (12:08)              Number: 19041 of 19086 (Refer# NONE)

From: WOLFS@TIGER.DIALIX.OZ.AU

Subj: Re: Calling 'C' routine from visual BAsic

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1994Sep9.171833.3385@csx.cciw.ca>, Kevin Hopkins

(u183@csx.cciw.ca) writes:

>In article <34pvm4$rn6@barnacle.iol.ie> depaoli@iol.ie (Bruno de Paoli)

>>writes: How can I call a 'C' routine ( that I have generated ) from Visual

>>Basic. Presumably I have to declare the function before I call it but what

>>do I use as the Lib parameter in the Declare statement?

>The lib parameter in the declare is the .DLL name.

Yup, also dont forget ( as already mentioned ) the 'C' routine needs to be

compiled and generated explicitely as a DLL and NOT as a LIB.

In a .BAS file declaration section write something like:

Declare Function CTL3DRegister Lib "CTL3DV2.DLL" (ByVal hInstapp)

                                    VVVVVVVVVVV

                             substitute this with YOUR .DLL

This gives GLOBAL availability to your function.

------

 Regards ... Wol


DLL calling

LUOKKA: DLL

2. How do I call a DLL?

   Basically, you declare a DLL procedure which you can call in your

   VB program which in turn passes data to and/or retrieves data from

   the DLL. You should read the section of the VB manual that talks

   about calling DLLs ("Chapter 24  Calling Procedures in DLLs" in the

   VB 3.0 Programmer's Guide). This chapter covers the basics of using

   the Windows API DLLs and calling DLLs in general. Beyond that you

   may want to find a good book on this subject since it is too large

   to cover here (see the Book Listing in the Appendix of the General

   FAQ - Part 1). Don't be too intimidated!  Using DLLs (especially

   many of the Windows API functions) is quite easy, once you learn

   how to call them. In fact, many of the newer DLLs include VB-

   compatible modules!


DLL calling

LUOKKA: DLL

4. Tips for calling DLLs (such as the Windows API)

   a. Using the BYVAL keyword is critical. Using it when you're

      supposed to call by reference and (more common) not using it

      when you are to give a value to the external function are the

      single most common mistakes. Wrong calling convention can often

      result in a General Protection Fault (GPF) or, even worse,

      corruption of another applications' data.

   b. Check return and parameter types. For return types, a C function

      declared as "void" means you use a Sub not a Function.

   c. Initialize strings by padding it to the necessary length! If you

      pass a string that is too short to the API it will happily write

      past the end of the string and possibly corrupt data.

   d. Use Option Explicit. A typing error that results in a bug in the

      VB source will occasionally cause a GPF when you call external

      code.

   e. It's a jungle out there! Check parameter values as there is no

      type checking outside VB. If you make a mistake, you'll often

      get a GPF.

   f. Save before you run! You may even need to restart Windows after

      a GPF, since DLL's often aren't unloaded properly. As a second

      option you can check out WPS (Windows Process Status) which is

      distributed with VB/Pro and placed in the CDK directory. This

      utility allows you to kick out any module (EXE, DLL) from memory

      (shooting yourself in the foot if you want to. WPS is a nice way

      to find out what DLLs are actually used, but save your work

      first!).


DLL calling & strings

LUOKKA: DLL

Date: 10/14/94 (23:07)              Number: 23031 of 23204 (Refer# NONE)

From: RICK@ECO.TWG.COM

Subj: VB string variables and DLLs

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<quote>

I can't help you with the Pascal problem, but I can elaborate on the "weird

proprietary format" of VB strings and how they can be used with DLLs

despite this shortcoming.  Considering a lot of people here might be

writing DLLs for use with VB applications, I figure the following excerpt

from the docs for a VB DLL I wrote for generating DOS interrupts might be

of interest to a few people.

It is very important to realize that Visual Basic handles string variables

in a very unique way.  In languages like assembly and C/C++, the

programmer has to do quite a bit of work just to allocate, maintain, and

deallocate string variables, particularly under Windows.  To make string

variables easier for the programmer to manipulate in Visual Basic, a unique

internal string-handling routine was devised that is, unfortunately,

incompatible with functions written in any other language.  As such, special

consideration has to be made to pass string variables between Visual Basic

programs and functions in DLLs that were written in other languages (which

is performed automatically by the VB kernel, VBRUNx00.DLL).

First of all, VB itself has two types of string variables: fixed-length and

variable-length.  Each type is passed from a VB app to a non-VB specific

DLL is quite a different manner.  An example of a fixed-length VB character

string:

   Dim myString As String * 100 ' Creates a fixed-length VB

                                ' string of 100 chars

A variable-length VB string, on the other hand, is declared (and buffered)

as follows:

     Dim myString As String

(or) Dim myString$

     myString$ = String$(100, 0)  ' Buffers the character string with

                                  ' 100 ASCII 0's

Regardless of which type of string is being passed to a DLL, if the DLL was

not specifically written to accept VB-proprietary strings (as most aren't)

then the VB declaration for the function that you're calling must have the

character strings passed "ByVal".  Consider this example:

This declaration will only work with a DLL that was written explicitly to

work with VB-proprietary strings (and that's not very many!):

   Declare Function MyFunc lib "MyDll" ( myString As String )

If the DLL is a "regular" dll, then the same function must be declared as

follows in order to work with VB:

   Declare Function MyFunc lib "MyDll" ( ByVal myString as String )

The "ByVal" keyword lets the VB kernel know that this string variable must

be converted to a C/PASCAL compatible string variable when passed to the

DLL.

So, what's the difference between fixed- and variable-length VB strings?

Quite simply, this: when a VB application passes a FIXED-LENGTH string to a

DLL, the VB kernel actually creates a completely new C/PASCAL compatible

string variable, copies the contents of the VB string variable into this

temporary buffer and then passes it (by reference) to the DLL function.

When the DLL function exits, the VB kernel copies whatever the DLL put in

that temporary variable back into the VB string and then the temporary

string is deallocated and relinquished to the system's memory pool.  On the

contrary, when a VARIABLE-LENGTH character string is passed to a regular

DLL, the VB kernel still mediates, but this time it passes to the DLL a

pointer to the *actual* buffer area of the VB string (not just a temporary

buffer created for use by the DLL).  Obviously, this seemingly subtle

difference can be extremely important if your DLL is designed to get the

"real" address of a string.

Furthermore, as you already suggested, VB does *not* NULL terminate the

strings for you as they are passed back and forth between VB and DLL

functions.  While this only matters if the DLL is going to "read" the

string, it's accomplished quite easily:

   myString = "This is a test" & Chr$(0) ' Appends a NULL character to the

                                         ' end of the string

Finally, it's important to remember that once you get your string _back_

from a DLL, VB does *not* know that the ASCII 0 means anything special.

So, it's up to you to find the ASCII 0 and use everything up to that point.

For example,

   GetMyName( myString$ )   ' Sends myString$ to DLL to

                            ' be filled up with data

   ' The next line only prints up to, but not including, the ASCII 0

   Print Left$( myString$, InStr%( myString$, Chr$(0)) - 1)

Failing to do it this way will result in ASCII 0's being printed much in

the same way ASCII 13's and 10's are printed as block characters in a

single-line edit box.

Sorry if this was too long-winded, but I hope it helps someone,

<unquote>

------------------------------------------------------------------------

 Rick Esterling, Senior Software Engineer

 The Wollongong Group, Inc.

 2010 Corporate Ridge Drive, Suite 550

 McLean, VA  22102

 (703) 847-4500

 email: rick@.twg.com        Compuserve: 74764,2056


DLL create in Borland

LUOKKA: DLL

Date: 06/06/94 (18:53)              Number: 8219 of 8514 (Refer# NONE)

From: HAYDENL@BLDRDOC.GOV

Subj: Re: Q. How to make DLLs in C++ that work with VB?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <nosackk.269.2DF36A12@bones.et.byu.edu>

nosackk@bones.et.byu.edu (Kris Nosack) writes:

>My brother is working on a program for a Computer Science class he is

>taking in which they have to make a small Blackjack game.  He is planning

>on using VB for the front-end and C++ to build a DLL that handles all the

>real work and logic of the game and its rules.  (They have to use C++

>as part of the conditions of the assignment - so don't flame me on this!)

>They have most of the VB interface done and it looks great, but they are

>stuck on how to correctly define, link, compile, etc. their C++ stuff so

>it makes a DLL that can be called from VB (and pass info back and forth,

>of course).  They are using Borland's C++ 4.0.  Any help and guidelines

>would be *greatly* appreciated!

DLL Creation in Borland C/C++

The item below is based on some hints I got off Compuserve (I think) several

years ago that helped me to get through it all  (sorry, I don't know who was

the original author). I have added some comments that hopefully clarify things

somewhat. This info was based on earlier versions of the Borland C++

compiler

(v.3.0,3.1) so be forewarned of differences.

***

Perhaps some experts can suggest updates or changes to this outline, I

would be glad to compile them and post a summary.

***

-Leonard

**** Here's the quick and dirty guide to "instant" DLLs:****

1.  Use Borland C++ 3.0 (just write in C, don't mess with the C++ stuff).

   Borland's compiler is lightyears ahead of MS when it comes to Windows

   (ironically).  There's very little to know, the compiler does it all

   for you.  This comment may be a bit dated!

2.  Use the large model and don't bother worrying about near and far

   pointers.  Borland's large model works great in DLLs.  If people tell

   you not to use large model ... don't listen.

3.  Take your regular C code and add a LibMain() to it.  Just copy the one

   in the Borland sample code.  Don't bother with WEP ... you don't need

   it with BCC.  file is Borlandc/examples/win30/dllshell.cpp

4.  You shouldn't have to make ANY SDK calls at all, believe it or not.

   Don't use GlobalAlloc or any of that, just use malloc(), free(), etc.

   Declare all the functions you wish to use in VB with the pascal and

   _export keywords.  Use Borland's linker.

5.  Don't expect to support multiple instances.  That means you will only

   be able to use your DLL with one application at a time.  If you need

   multiple instances, then you'll have to fiddle with memory management

   and may have to get involved in the SDK.

6.  Learn to use TDW (Turbo Debugger for Windows).  You'll have bugs, and

   you'll never find them without TDW, since you can't display any debugging

   output with printf() or the like.  Not only that, TDW will zero in on

   those feared UAEs with precision.  I haven't had to step up to this yet

7.  If you want to support real mode, forget steps 1-6 and go get a beer.

    Real mode requires too much work and it won't be around for long.

   Fortunately Real mode is now a thing of the past

Set Options-Compiler-Entry/Exit code to Windows-DLL explicit functions

exported and check the C calling convention selection.

Declare exportable functions using:

extern "C" void far _export pascal functionname(function args)

Beware of name mangling! The extern "C" part of the declaration is needed

to prevent the name of the function from being made something

unrecognizable.

Anything Else?

-----------------------------------------------------------

Leonard Hayden                  haydenl@bldrdoc.gov

Microwave Metrology Group       (303) 497-3400

National Institute of Standards and Technology

325 Broadway, MC-813.06

Boulder, CO 80303  Fax:(303) 497-3970


DLL create in Borland

LUOKKA: DLL

Date: 04/07/94 (22:15)              Number: 2893 of 2921 (Refer# NONE)

  To: ALL

From: HAYDENL@BLDRDOC.GOV

Subj: Re: ** Dll's Creation in Borland & Call from VB **

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

DLL Creation in Borland C/C++

The first item below is some hints I got off Compuserve (I think) several

years ago that helped me to get through it all. I have added some comments

that hopefully clarify things somewhat.

The example code follows and includes the dllshell which you should have in

your win30 examples directory, and c code for an fft routine taken from the

book  Numerical Recipes in C. If the fft function is unfamiliar to you don't

worry, just look at the function declaration. You should be able to compile

the code to DLL by loading the code (two files) and setting the compiler

options to what I have indicated in my comments after the hints. My code is

c rather than c++ but it shouldn't make a difference since other parts of my

code uses some c++ pieces (operator overloading for complex numbers).

After the example code I have included the VB declaration for the function.

Good Luck! Let me know how it goes.

-Leonard

**** Here's the quick and dirty guide to "instant" DLLs:****

1.  Use Borland C++ 3.0 (just write in C, don't mess with the C++ stuff).

   Borland's compiler is lightyears ahead of MS when it comes to Windows

   (ironically).  There's very little to know, the compiler does it all

   for you.  This comment may be a bit dated!

2.  Use the large model and don't bother worrying about near and far

   pointers.  Borland's large model works great in DLLs.  If people tell

   you not to use large model ... don't listen.

3.  Take your regular C code and add a LibMain() to it.  Just copy the one

   in the Borland sample code.  Don't bother with WEP ... you don't need

   it with BCC.  file is Borlandc/examples/win30/dllshell.cpp

4.  You shouldn't have to make ANY SDK calls at all, believe it or not.

   Don't use GlobalAlloc or any of that, just use malloc(), free(), etc.

   Declare all the functions you wish to use in VB with the pascal and

   _export keywords.  Use Borland's linker.

5.  Don't expect to support multiple instances.  That means you will only

   be able to use your DLL with one application at a time.  If you need

   multiple instances, then you'll have to fiddle with memory management

   and may have to get involved in the SDK.

6.  Learn to use TDW (Turbo Debugger for Windows).  You'll have bugs, and

   you'll never find them without TDW, since you can't display any debugging

   output with printf() or the like.  Not only that, TDW will zero in on

   those feared UAEs with precision.  I haven't had to step up to this yet

7.  If you want to support real mode, forget steps 1-6 and go get a beer.

   Real mode requires too much work and it won't be around for long.

 Fortunately Real mode is now a thing of the past

Set Options-Compiler-Entry/Exit code to Windows-DLL explicit functions

exported and check the C calling convention selection.

Declare exportable functions using:

extern "C" void far _export pascal functionname(function args)

Beware of name mangling! The extern "C" part of the declaration is needed

to prevent the name of the function from being made something

unrecognizable.

**** dllshell.cpp ****

// Borland C++ - (C) Copyright 1991, 1992 by Borland International

// Example program used to demonstrate DLL's. This file one of the

// files used to build BITMAP.DLL which is used in the DLLDEMO program.

#define  STRICT

#include <windows.h>

// Turn off warning: Parameter '' is never used

#pragma argsused

// Every DLL has an entry point LibMain and an exit point WEP.

int FAR PASCAL LibMain( HINSTANCE hInstance, WORD wDataSegment,

                                   WORD wHeapSize, LPSTR lpszCmdLine )

    // The startup code for the DLL initializes the local heap (if there is

one)

    // with a call to LocalInit which locks the data segment.

    if ( wHeapSize != 0 )

        UnlockData( 0 );

    return 1;   // Indicate that the DLL was initialized successfully.

// Turn off warning: Parameter '' is never used

#pragma argsused

int FAR PASCAL WEP ( int bSystemExit )

    return 1;

**** fft.c ****

# include <complex.h>

# define PI 3.14159265358979323846264338328

# define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr

extern "C" void far _export pascal four1(double data  ,int nn,int isign)

int n,mmax,m,j,istep,i;

double wtemp,wr,wpr,wpi,wi,theta;

double tempr,tempi;

n=nn << 1;

j=1;

for(i=1;i<n;i+=2)

  if (j>i)

    SWAP(data j ,data i );

    SWAP(data j+1 ,data i+1 );

  m=n >> 1;

  while (m>=2 && j>m)

    j-=m;

    m >>=1;

  j+=m;

mmax=2;

while (n>mmax)

  istep=2*mmax;

  theta=6.28318530717959/(isign*mmax);

  wtemp=sin(0.5*theta);

  wpr= -2.0*wtemp*wtemp;

  wpi=sin(theta);

  wr=1.0;

  wi=0.0;

  for (m=1;m<mmax;m+=2)

    for (i=m;i<=n;i+=istep)

      j=i+mmax;

      tempr=wr*data j -wi*data j+1 ;

      tempi=wr*data j+1 +wi*data j ;

      data j =data i -tempr;

      data j+1 =data i+1 -tempi;

      data i  += tempr;

      data i+1  += tempi;

    wr=(wtemp=wr)*wpr-wi*wpi+wr;

    wi=wi*wpr+wtemp*wpi+wi;

    mmax=istep;

**** VB function declaration ****

Declare Sub four1 Lib "tdnadll.dll" (vect As Double, ByVal nn%, ByVal isign%)

-----------------------------------------------------------

Leonard Hayden                  haydenl@bldrdoc.gov


DLL create with VB

LUOKKA: DLL

Date: 04-09-95    Time: 09:50a     Number: 339

From: simply@netcom.com             Refer:

Subject: Create DLL's with Visual          1: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

Traditionally, Visual Basic programmers have been able to create EXE

program files, but they could not create DLL program files because Visual

Basic does not provide the facilities for creating dynamic-link libraries. Since

Visual Basic does not provide the facilities for libraries, large Visual Basic

projects could not be broken apart into smaller components as C programmers

are so used to doing to minimize code compilation time and encapsulate

functionality.  In addition, since programmers could not create DLL's with

Visual Basic, they could not create certain type of extensions such as Control

Panel applets', File Manager extension DLL's and many other third-party

defined interfaces.

Simply Solutions Visual DLL addresses all of these issues and provides a

seamless interface for creating DLL's with Visual Basic.  This is a boon to the

Visual Basic programming base.  No longer are Visual Basic programmers

limited to only creating EXE files.  True DLL's can be created with Visual

Basic.  The DLL's created still use Visual Basic p-code interpreter, so Visual

Basic code is guaranteed to function identically.  Visual Basic's built-in event

firing mechanism is used to trigger function calls from incoming DLL function

entries.  The DLL files use VBRUN300.DLL and any other VBX's used in the

DLL project.  The DLL itself is a single file which contains the DLL interface

code, the internal  program executable and all function exports. To the

outside world -- to external applications -- the DLL file is just like any DLL

created with traditional tools such as C, Fortran or Pascal.  The DLL is not

dependent on a proprietary interface, but the interface expected by

third-party software, including user defined function export names,

stack-based argument passing, C or PASCAL calling convention, String,

Integer and Floating point data types for parameters and return-values, etc.

The DLL's can be configured to have multiple function exports with multiple

parameters and types for each function, just like a true DLL.  All of this is

configured using a point-and-click user interface.  Windows DLL creation

has never been easier in any programming environment.

The Visual DLL demo may be downloaded from ftp.netcom.com.  The demo is

located in /pub/si/simply in the file vdllinfo.zip.  It is also available for

download from the Simply Solutions Forum on CompuServe (GO SIMSOL).

Simply Solutions, 3337 South Bristol, Suite 143, Santa Ana, CA  92704

(800) 355-2405 or (310) 575-5047     CompuServe: 74777,3221  or GO

SIMSOL

Fax (714) 863-1546                           Internet: simply@netcom.com

----------------------------------------------------------

Date: 06-22-95 (03:42)              Number: 369639 of 370426 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Simply Solutions Visual DLL

The product does not create stand alone DLLs, but instead makes a DLL that

calls VB routines. It requires VBRUN300.DLL. It just wraps your code-only VB

EXE files in a DLL header.

Therefore, it doesn't add any speed benefit, because it just adds another

layer. All its really useful for is code pointers.


DLL from Delphi

LUOKKA: DLL

18847 (10+)  robin@reimari.uwasa.fi  27.05.95  13:45

Jarto Tarpio: "Solved: How to return a String from Delphi-DLL to VB"

This article describes how you can create and return a VB-string from a

Delphi-DLL. It's done exactly the same way in C and Borland-pascal, but the

file to call VB- functions was/is missing from Delphi.

First of all... You need the bpvbx.zip-archive from ftp.borland.com. The exact

path is pub/techinfo/techdocs/language/delphi/vbx/bpvbx.zip

bpvbx.zip contains bpvbx1..5.zip-files. bpvbx1.zip has the file wee need:

VBAPI.PAS

VBAPI.PAS contains the function definitions to call VBAPI.DLL (which is

inside VBRUN?00.DLL)

You have to change it a bit in Delphi: add MESSAGES to the uses-clause in

VBAPI_.PAS

To return a string from a DLL to Visual Basic you create a temporary Hlstr

and pass it's handle back as the result. VB frees the string automatically

itself. There are some more useful functions and procedures for

string-handling. Check them out and read the VBAPI.HLP-file in Visual

Basic's VBÖCDK-dir.

Here's a working example that takes a null-terminated string as an argument

from Visual Basic and returns it to Visual Basic.

function ReturnString(InString: pchar):HLStr;

var InLength: Integer;

Begin

  InLength:=StrLen(InString);

  ReturnString:=vbCreateTempHlstr(InString,InLength);

End;

In Visual Basic:

Declare Function ReturnString (ByVal InString$) as String

debug.print ReturnString("This is a test")

Jarto Tarpio               robin@vipunen.hut.fi

StarSoft Ky

Karkkimalantie 654         IRC: rbn

FIN-66420 Ruto

Finland


DLL function searcher

LUOKKA: DLL

28440 (50+)  tomw@tsys.demon.co.uk  31.07.95  15:51

Tom Wheeley: "Re: Is there a DLL function searcher?"

> The British mag, PCPlus said in their August issue that they'd  be publishing

> an application that retrieved and displayed API  calls from DLLs next >

month. If this is published, and if the copyright lets me, I'll post the code

PC-PLUS arrived this morning, and I'm afraid the program just has a list of

API calls in an Access Database. However, it does have progressive

searching routines like in Windows Help and seems a better version of the

APICONS program which comes on the Appleman book.

Yes, it is freeware.


DLL help to create

LUOKKA: DLL

Date: 06/08/94 (21:37)              Number: 8354 of 8514 (Refer# NONE)

From: GRTORLBA@BACH.SEATTLEU.EDU, George R. Torralba

Subj: Re: Help with DLL in C from VB

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Two things.  The first may not have anything to do with.

  o Your declaration (char *fs) is different than your function definition

    (char far *)

  o Dim D, r as double - unless you didn't specify defint a-z, D would be

    and integer.  I think VB's default type is single so I think you still

    must do a;  Dim D as double, r as double.

George

In article <Cr1C1C.7B9@bcsaic.boeing.com>,

Lawrence P Lowry <lowrylp@bcsaic.boeing.com> wrote:

: I need some help in a short C function in a Windows DLL to

: be called from Visual Basic.  The DLL compiles and links

: fine but when called the result is not what we expected.

: It appears that we cannot get floating point math to work.

: We have stripped the program to the following to illustrate

: the problem. We are compiling with MS Visual C/C++ ver 1.0.

: Any suggestions would be appreciated.

:

: DLL Code:

: =========

: #include <windows.h>

: #include <stdlib.h>

: #include <stdio.h>

: #include <string.h>

: #include <float.h>

: #include <math.h>

:

: double  FAR PASCAL DblTo10   (char *fs, double dbl);

: int     FAR PASCAL WEP       (int bSystemExit);

:

: int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD

wHeapSize,

LPSTR lpszCmdLine)

:

:     return 1;

:

: double  FAR PASCAL DblTo10 (char far *fs, double dbl)

:

:      double d;

:      strcpy(fs,"High Larry");

:

:      d = dbl;

:      d = d * 10.0;

:

:      MessageBox(NULL, fs, "DLL Message", MB_OK);

:      return d;

:

: int  FAR PASCAL WEP (int bSystemExit)

:

:      return (1);

:

: Visual Basic Define:

: ====================

: Declare Function DblTo10 Lib "C: dlltest lucky.dll" (ByVal S As String,

ByVal a As Double) As Double

:

: Visual Basic Call:

: ==================

: Sub Command1_Click ()

: Dim D, r As Double

: Dim S As String * 20

: Dim i As Integer

:

: D = 123.12

:

: form1.Print "Double "; D

: form1.Print "Execute DLL"

:

: r = DblTo10(S, D)

:

: form1.Print "After DLL, rc "; r

: End Sub

:

: Visual Basic Results:

: =====================

: Double 123.12

: Execute DLL

: After DLL, rc 1.71219433372264E-307


DLL help to create

LUOKKA: DLL

Date: 06/22/94 (18:02)              Number: 9870 of 9875 (Refer# NONE)

From: DAVIDR@SEARCHTECH.COM

Subj: Borland C++ 3.1 DLL / VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

As a follow-up to my earlier post about getting a Borland 3.1 C++

DLL to work with VB, I would like to extend my thanks to RD Mackoy

and to Timothy L. Nali for pointing out that I can use extern "C"

in front of my DLL function declarations in order to prevent the

function names from being mangled in the DLL, e.g.:

// In the header file:

extern "C" long FAR PASCAL MyDLLFunc(int nSomeInteger);

Then I don't have to use IMPDEF, and don't have to use the "alias"

option in the VB declaration of the DLL function:

Declare Sub MyDLLFunc Lib "C: MyDir MyDLLName.DLL" (ByVal nCommand

As Integer)


DLL long

LUOKKA: DLL

Date: 12/30/94 (15:54)              Number: 31225 of 31236 (Refer# NONE)

From: BLINDPEW@AOL.COM

Subj: Re: How do I write PROPER C DLL's for VB use?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

From the Knowledge Base:

How to Write C DLLs and Call Them from Visual Basic

Article ID: Q106553

---------------------------------------------------------------------

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic

  for Windows, version 3.0

---------------------------------------------------------------------

SUMMARY

=======

This article outlines how to use DLLs with Visual Basic. It covers the

following issues:

Section A

---------

1.0 What Is a DLL

1.1 Why Use a DLL

1.2 Anatomy of a DLL

1.3 DLL Memory Management Issues

1.4 Building a DLL Using Visual C++

1.5 Example C DLL

Section B

---------

2.0 Calling DLLs from Visual Basic

2.1 DLL Parameters

2.2 Trouble Shooting

2.3 Example Visual Basic Calling Program

MORE INFORMATION

==================

SECTION A

---------

1.0 What Is a DLL

-----------------

DLLs (Dynamic Link Libraries) are an important aspect of Windows. A DLL

contains functions that your executable program can call during execution.

In other words, a DLL is a library of functions that your program can link

with dynamically.

A link can be static or dynamic. Static links don't change. All the

address information needed by your program to access the library function is

fixed when the executable file is created and remains unchanged during

execution.

Dynamic links are created as needed. When your program needs a function

that is not in the executable file, Windows loads the dynamic link library

(the DLL), making all of its functions available to your application. At

that time, Windows resolves the address of each function and dynamically

links it to your application.

All Custom controls used in Visual Basic are DLLs. The only difference is

that they require special handling in terms of messages received from

Visual Basic.

1.1 Why Use DLLs

----------------

Here are four reasons why you might want to use a DLL:

 - Access to C Run-Time Functions:

   The C run-time library has many useful functions that would not be

   available to Visual Basic programmers were it not for DLLs. For

   example,    the _dos_getdiskfree function allows you to calculate the total

  amount  of disk space and the free disk space available on a drive.

 - Access to Windows API (Application Programming Interface) Functions

   that Require Callback Routines:

   Some Windows API functions require a callback function. A callback

   function is a function that Windows will call while executing the API

   call. An example of this sort of function is EnumTaskWindows, which

   will give the handle of all windows that are owned by a particular

   task.

 - Speed:

   C is a fully compiled language that works at a level that is fairly

   close to native machine code. This means that the execution of programs

   that are well written in C will be fast.

 - Load on Use:

   Code and data from a DLL are loaded only when needed. A DLL can be

   organized such that only required parts are loaded as opposed to the

   entire DLL. This reduces the amount of memory required and the time

   taken to load.

1.2 Anatomy of a DLL

--------------------

Every DLL must contain a LibMain function and should contain a Windows

Exit

Procedure (WEP) in addition to the exported functions that can be called

by

an executable program.

 - LibMain:

   A DLL must contain the LibMain function. The LibMain function is called

   by the system to initialize the DLL. LibMain is called only once --

when

   the first program that requires the DLL is loaded. The following are

the

   parameters passed to LibMain:

    - HANDLE : Handle to the instance of the DLL.

    - WORD   : Library's data segment.

    - WORD   : Heap size.

    - LPSTR  : Command line parameters.

 - WEP:

   The WEP (Windows Exit Procedure) performs cleanup for a DLL before the

   library is unloaded. Although a WEP function was required for every DLL

   in previous versions of the Windows operating system, for version 3.1

it

   is optional. A WEP should be included in the module definition file

   (.DEF) in Visual C, for example:

   EXPORTS

      WEP

 - Exported Functions:

   These are the functions you want to call from your DLL. They are

denoted

   by _export. _export is used for backward compatibility. All the

   functions you want to call must also be listed in the (.DEF) file of

   your DLL.

1.3 DLL Memory management issues

----------------------------------------------

Use the large memory model.

C stores all variables defined as static or global (defined outside of a

function) in the program's heap space, and C stores all other variables on

the stack.

In the small and medium model, all pointers are near by default. This

means

that the data is accessed by 16-bit offsets to either the data segment

(DS)

register, or the stack segment (SS) register. Unfortunately, the compiler

has no way of knowing whether the offset is from the DS or the SS. In most

programs this would not be a problem because the DS and SS point to the

same segment. A DLL, however, is a special case.

A DLL has its own data segment but shares its stack with the calling

program. This means that the DS and the SS do not point to the same

location. The easiest solution to this problem is to build the DLL in the

large memory model where all variables are referenced by a 32-bit value.

Why Allocate Memory Dynamically?

--------------------------------

Allocating memory dynamically is a Windows-friendly technique. Declaring

large arrays of data takes up space in either your program's stack, which

is limited to 64K, or you program's Data Segment, which wastes disk space

and Windows memory. It is better to ask  Windows for the memory when you

need it, and then free it when you have finished.

Allocating Memory

-----------------

In Windows, you can dynamically allocate two types of memory, local and

global. Local memory is limited to 64K, and in the case of a DLL, local

memory is shared with the program that called the DLL. Global memory is

all of the memory available to Windows after it has loaded.

Local memory is allocated and managed using the LocalAlloc, LocalLock

LocalUnlock, and LocalFree functions -- as in this example:

   char* pszBuffer;

   ....

   pszBuffer = (char *) LocalAlloc (LPTR, 20);

   ...

   LocalFree (pszBuffer);

It is faster to allocate local memory than it is to allocate global

memory.

But allocations from the local heap are limited to 64K, which must be

shared amongst all programs that are calling the DLL. It is best to use

local memory when small, short lived blocks of memory are required.

Global memory is allocated and managed using the GlobalAlloc, GlobalLock

GlobalUnlock, and GlobalFree functions -- as in this example:

   HGLOBAL hglb;

   char* pszBuffer;

   hglb = GlobalAlloc (GHND, 2048);

      // GHND allocates the memory as moveable and

      // initialized to 0

      // 2048 is the amount of memory to be allocated...

   pszBuffer = GlobalLock (hglb);

   ...

   GlobalUnlock (hglb);

   GlobalFree (hglb);

The GlobalAlloc function allocates memory in multiples of 4K.

If you want to share memory allocated in the DLL with other programs, you

should allocate it using the GMEM_SHARED flag. If you want to share the

memory through DDE, you must allocate it by using the GMEM_DDESHARE

flag.

Be Careful When Storing Data in Static Variables

------------------------------------------------

If you try to store data in a DLL using global or static variables, don't

be surprised if these values have changed when you next call your DLL. The

data stored in this way will be common to all applications that access

this

DLL. No matter how many applications use a DLL, there is only one instance

of the DLL. The best way to get around this is to return structures from

the DLL and pass them in again when they are needed.

File Handles

------------

It is not possible to share file handles between applications or DLLs.

Each

application has its own file-handle table. For two applications to use the

same file using a DLL, they must both open the file individually.

1.4 Building a DLL Using Visual C++

-----------------------------------

Here are the steps necessary to build a DLL using Visual C++:

1. Start Visual C++.

2. Create a new project by choosing New from the Project menu. Select the

   following options:

    - Set the Project Type to "Windows dynamic-link library (.DLL)"

    - Clear the "Use Microsoft Foundation Classes" check box.

   You can also set or view these options later by choosing Project from

   the Options menu.

3. Add your existing .C and .DEF files to the project by using the dialog

   box that comes up when you choose Edit from the Project menu. Or enter

   your code directly in the Visual C++ editing window. (See the .C and

   .DEF example code listed below.)

4. From the Project menu, choose the Build <yourname>.DLL option.

1.5 Example C DLL

-----------------

The following DLL contains the GetDiskInfo function, which can be called

from Visual Basic. It will return the disk space available, the current

drive name and the volume name.

C Code Example, DISKINFO.C:

#include <windows.h>

#include <dos.h>

int CALLBACK LibMain (HANDLE hInstance, WORD wDataSeg, WORD

wHeapSize,

LPSTR lpszCmdLine)

// The following is required only under Windows version 3.1

// Win32 does not require or support UnlockData()

„

   if (wHeapSize > 0)

      UnlockData (0);  //Unlocks the data segment of the library.

   return 1;

†

void __export CALLBACK GetDiskInfo (char *cDrive, char *szVolumeName,

unsigned long *ulFreeSpace)

„

   unsigned drive;

   struct _diskfree_t driveinfo;

   struct _find_t c_file;

   _dos_getdrive (&drive);

   _dos_getdiskfree( drive, &driveinfo );

   if (!_dos_findfirst( "*.*", _A_VOLID, &c_file ))

      wsprintf( szVolumeName, "%s", c_file.name);

   else

      wsprintf ( szVolumeName, "NO LABEL");

   *cDrive = drive + 'A' -1;

   *ulFreeSpace = (unsigned long) driveinfo.avail_clusters * (unsigned

      long) driveinfo.sectors_per_cluster * (unsigned long)

      driveinfo.bytes_per_sector;

†

Use the following DISKINFO.DEF file in Visual C++:

   LIBRARY  diskinfo

   DESCRIPTION 'GetDiskInfo Can be called from Visual Basic'

   EXETYPE WINDOWS 3.1

   CODE PRELOAD MOVEABLE DISCARDABLE

   DATA PRELOAD MOVEABLE SINGLE

   HEAPSIZE    4096

   EXPORTS

      GetDiskInfo @1

NOTE: The LIBRARY name in the .DEF file must be the same as the DLL file

name, or else Visual Basic will give you "Error in loading DLL." For

example, create the file DISKINFO.DLL using the LIBRARY DISKINFO

statement

in the .DEF file above.

SECTION B

---------

2.0 Calling DLLs from Visual Basic

----------------------------------

In Visual Basic, all functions, including DLL functions, that you want to

call must first be declared by using the Declare statement. You can

declare

your functions in the declarations section of a Form or a Module. If you

declare a DLL procedure or function in a Form, it is private to that Form.

To make it public, you must declare it in a Module. The following is an

example Declare statement:

   Declare Sub getdiskinfo Lib "c:™somepath™diskinfo.dll"

      (ByVal mydrive As String, ByVal myvolume As String, free As Long)

You must enter the entire Declare statement as one, single line. This

particular Declare statement declares the user-defined procedure

GETDISKINFO located in user-created DISKINFO.DLL file.

Once you declare the function, you can call and use the function just as

you would call and use a Visual Basic function.

2.1 DLL Parameters

------------------

Because DLLs are typically written in C, DLLs can use a wide variety of

parameters not directly supported by Visual Basic. As a result, when

passing parameters, he programmer has to find the appropriate data type to

pass.

Passing Arguments by Value or by Reference

------------------------------------------

By default, Visual Basic passes all arguments by reference. (When passing

by reference, Visual Basic supplies a 32-bit far address.) However, many

DLL functions expect an argument to be passed by value. This can be

achieved by placing the ByVal keyword in front of the argument

declaration.

The following sections show you how to convert parameters to Visual Basic.

8- to 16-Bit Numeric Parameters

-------------------------------

Pass 8- to 16-bit numeric parameters (int, short, unsigned int, unsigned

short, BOOL, and WORD) as Integer.

32-bit Numeric Parameters

-------------------------

Pass 32-bit numeric parameters (long, unsigned long, and DWORD) as LONG.

Object Handles

--------------

All handles are unique 16-bit integer values associated with a Window and

are passed by value, so pass these parameters as Integer.

Strings

-------

Strings include the LPSTR and LPBYTE data types (pointer to characters or

pointer to unsigned characters). Pass these parameters as (ByVal paramname

As String). DLL functions cannot return Visual Basic strings. They do

sometimes return LPSTRs, which can be copied into Visual Basic strings

by using API functions.

To pass Visual Basic strings directly, pass them as (param As String).

NOTE: Visual Basic strings require special handling, so don't pass strings

directly unless the DLL explicitly requires it.

Pointers to Numeric Values

--------------------------

Pass pointers to numeric values by simply not using the ByVal keyword.

Structures

----------

If the Visual Basic user-defined type matches the structure expected by

the

DLL, the structure can be passed by reference.

NOTE: Structures cannot be passed by value.

Pointers to Arrays

------------------

Pass the first element of the array by reference.

Pointers to functions

---------------------

Visual Basic does not support callback functions, so DLL functions that

have pointers to functions cannot be used with Visual Basic.

Null Pointers

-------------

If a DLL expects a Null pointer, pass it as (ByVal paramname As Any). You

can use &0 or &0H as the value of paramname.

2.2 Trouble Shooting

--------------------

Below are solutions to some problems you may encounter.

System Resources Keep Getting Lower After the DLL Is Called

-----------------------------------------------------------

If your DLL is using GDI objects, you must remember to free them after

using them. This may not be obvious in Visual Basic, but when using the

Windows SDK (software development kit) if you create a GDI object (for

example, CreateBrushIndirect), you must delete it by using DeleteObject

later on.

Bad DLL Calling Convention Error

--------------------------------

This error is often caused by incorrectly omitting or including the ByVal

keyword from the Declare statement. This error can also be caused if the

wrong parameters are passed.

Error in loading DLL

--------------------

This error occurs when you call a dynamic-link library procedure and the

file specified in the procedure's Declare statement cannot be loaded. You

can use the Microsoft Windows API function LoadLibrary to find out more

specific information about why a DLL fails to load.

General Protection (GP) Fault

-----------------------------

GP faults occur when your program writes to a block of memory that doesn't

belong to it. The two most likely reasons for this are:

 - You overstepped an array boundary. C does not check that the array

   subscript you are writing to is valid. Therefore, you can easily write

   to memory you don't own.

 - You are using a pointer to a memory location that you have freed. The

   best option is to assign NULL to all pointers after you free their

   memory.

A GP fault can also occur when an incorrect variable type is passed to the

DLL function.

2.3 Example Visual Basic Calling Program

----------------------------------------

There are two parts to calling a DLL in a Visual Basic program. First you

declare the function, and then you use it in event code.

Here is an example of a Declare statement. The Declare statement should be

put in a module or in a form's General Declarations section.

   ' Enter the following Declare as one, single line:

   Declare Sub getdiskinfo Lib "c:™dllartic™diskinfo.dll"

      (ByVal mydrive As String, ByVal myvolume As String, free As Long)

Specify ByVal statements exactly as shown, or else a GP fault may occur.

Once the function is declared, you can use it in event code. The following

example uses a function from the DLL in the Command1 Click event code:

Sub Command1_Click ()

   Dim drive As String * 1

   Dim volume As String * 20

   Dim free As Long

   Call getdiskinfo(drive, volume, free)

   Text1.Text = drive

   Text2.Text = volume

   Text3.Text = Str$(free)

End Sub

Additional reference words: 3.00 DLL

KBCategory: kbprg kbcode

KBSubCategory: APrgOther

Copyright 1993 Microsoft Corporation. All rights reserved.


DLL passing strings

LUOKKA: API

Date: 08/27/94 (15:02)              Number: 17402 of 17472 (Refer# NONE)

From: GBZA51@UDCF.GLA.AC.UK

Subj: Re: Passing strings to DLLs

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In <33lb9f$kqq@kantti.Helsinki.FI> salste@cc.Helsinki.FI (Tuomas M J

Salste) writes:

>I've succeeded in building some (Borland) Pascal DLLs and called them

>from VB. The problem is, I can't pass or return string from the DLL to

>VB. How should I declare the functions?

I did a small test DLL to try this out a couple of weeks ago. It's

important to remember that VB assumes DLLs use C type strings so you

have to use pstr rather than string in your function definitions. My

DLL also includes demo of how to fill a text box by passing it's hWnd

to the DLL.

VB declarations ...

Declare Function SetString Lib "StrDLL.dll" (ByVal a_string As String) As

  Integer

Declare Function GetString Lib "StrDLL.dll" (ByVal a_string As String) As

  Integer

Declare Function FillTextBox Lib "StrDLL.dll" (ByVal the_handle As Integer)

 As Integer

Pascal source code ...

library TestDLL;

uses WinTypes,WinProcs;

var TheStr : string 255 ;

function SetString(instr : PStr) : integer; export;

var n1 : integer;

  begin

    TheStr := '';

    n1 := 0;

    while ((instr n1  <> Chr(0)) and (n1 < 255)) do

      begin

        TheStr := TheStr+instr n1 ;

        inc(n1);

      end;

    TheStr := TheStr+chr(0);

    SetString := n1;

  end;

function GetString(outstr :PStr) : integer; export;

var n1 : integer;

  begin

    for n1 := 1 to length(TheStr) do

      outstr n1-1 :=TheStr n1 ;

    outstr length(TheStr)  := chr(0);

    GetString := length(TheStr);

  end;

function FillTextBox(Box : HWnd) : integer; export;

var str : PStr;

    ID : integer;

    Parent : HWnd;

begin

  ID := GetDlgCtrlID(Box);

  Parent := GetParent(Box);

  str := 'Hi There!';

  SetDlgItemText(Parent,ID,str);

  FillTextBox := 1;

end;

procedure LibExit; far;

begin

  if ExitCode = wep_System_Exit then

  begin

     system shutdown

  end

  else

  begin

     DLL is being unloaded

  end;

  ExitProc := SaveExit;

end;

exports

  SetString index 1,

  GetString index 2,

  FillTextBox index 3;

begin

   initialization

  SaveExit := ExitProc;   Save old exitproc pointer

  ExitProc := @LibExit;   Set new pointer

end.


DLL's left in memory

LUOKKA: DLL

Date: 11/01/94 (11:20)              Number: 25396 of 25466 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re: DLL left in memory wh

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

NT>I have a DLL which I call from my VB app, just a simple

NT> Declare SomeFunc ...

NT> ...

NT> rc = SomeFunc ...

NT>I notice that when my app exits, the DLL is always left dangling

NT>with a reference count of 1, as reported by WPS.EXE.  It is not

NT>just my DLL, I also experience it using other DLLS such as Oracle

NT>Glue's ORAGLUE.DLL, among others.

NT>Is it something I'm doing wrong?

No, but it IS some you're not doing that you should be.

In your main form's Unload event, for each .DLL, put the following code:-

  hDll% = GetModuleHandle("???????.dll")

  If hDll% >= 32 Then Call FreeLibrary(hDll%)

Obviously, replace ???????.dll with the library's name.

Regards,  Email: ian.carter@almac.co.uk  CIS: 100435,3040

Ian C.    Tel/Fax: (+44)(0)1909-773689


DLL's left in memory

LUOKKA: DLL

Date: 11/08/94 (18:29)              Number: 26238 of 26376 (Refer# NONE)

From: BGLOVER@NETCOM.COM

Subj: Re: DLL left in memory when VB app exits

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Nicholas Tan Chee Hiang (nicholas@iti.gov.sg) wrote:

: I have a DLL which I call from my VB app, just a simple

:  Declare SomeFunc ...

:  ...

:  rc = SomeFunc ...

: I notice that when my app exits, the DLL is always left dangling

: with a reference count of 1, as reported by WPS.EXE.  It is not

: just my DLL, I also experience it using other DLLS such as Oracle

: Glue's ORAGLUE.DLL, among others.

: Is it something I'm doing wrong?

If it is a true dll, not a vbx, the correct way to load it is with

an API call LoadLibrary('lib name goes here'), then when you are

done with it call the API UnloadLibrary('lib name goes here').

This way the use count is incremented and decremented properly,

and when it hits zero, the dll will be unloaded. VBXs work the same

way, but it is automatic.

WPS forces an unload library, regardless of wether there is a

use count non-zero or not. This could cause other apps to crash

if they are still using the dll.

Bill

======================================================

bglover@netcom.com,  KK6PW,  Compuserve 71220.2750

Weimar Software, San Jose CA


DLL/VBX list loaded

LUOKKA: VBgen

Date: 05/21/94 (21:27)              Number: 6531 of 6590 (Refer# NONE)

From: CHI@NETCOM.COM

Subj: Re: List of loaded .DLLs/.VBXs

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

There is an indispensible utility that shipped with VBWin 3.0

called WPS.EXE.  It lists all currently loaded tasks and modules.

It gives the full path to where the task or module was loaded from.

If there is a version resource in that file, it gives the version

number as well.

Finally, something indispensible for DLL/VBX developers: it allows

you to force a task or module to unload.

--

Curt Hagenlocher

chi@netcom.com


DLLs un/reloading

LUOKKA: VBgen

25640 (34+)  andy@axiomati.demon.co.uk  16.07.95  14:57

Andrew Cheshire: "Re: How to reload/unload a .DLL??"

In article: <3ua9qm$4hq@ronneby.hk-r.se>  Tore Nestenius

<dt93tn@pt.hk-r.se> writes:

> i would like to know how i can force windows to reload a .DLL??

> I am working on my own .DLL and most times when i recompile it the

> changed .DLL is not automaticaly updated in VB.

You need to unload the .DLL from memory to force Windows to reload it from

disc.

Create a project which consists solely of a .BAS file containing the following

======

Option Explicit

Declare Function GetModuleHandle Lib "Kernel" (ByVal path As String) As

Integer Declare Function Freemodule Lib "Kernel" (ByVal hInst As Integer) As

Integer

Sub Main ()

    Dim hInst As Integer

    hInst = GetModuleHandle(Command)

    Do While Freemodule(hInst)

    Loop

End Sub

======

Then set the project to start on Sub Main.  Compile it to a .EXE (called, say,

FREEDLL) and put an entry into Program Manager (or whatever) which calls

the .EXE and passes as parameter the name of the DLL you want to free.

For example :-

C:™MYAPPS™FREEDLL.EXE MYDLL

This code is provided "as is" and I accept no responsibility for any problems

or damage which may arise from its use.

----------------------------------------------

Andrew Cheshire      andy@axiomati.demon.co.uk

Axiomatic Software   CIS: 100273,154


DoEv avoid long loops

LUOKKA: VBgen

Date: 11/29/94 (12:39)              Number: 28324 of 28326 (Refer# NONE)

From: ERS3@NS1.CC.LEHIGH.EDU

Subj: Re: Pause / Wait

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Sub WaitSecs (secs)

>  Dim start!, Temp%

>  start! = Timer

>  While Timer < start! + secs +1

>      Temp% = DoEvents()

>  Wend

>End Sub

>

>

>

    Doing DoEvents in a long loop may cause stack overflow.


DoEvents better!

LUOKKA: VBgen

Date: 07-26-95 (20:33)              Number: 396886 of 397320 (Refer# NONE)

Subj: Re: Stopping combo box flicker

From: Malcolm Michael <mm@triad.com>

-------- REPLY, Original message follows --------

> If I put a DoEvents in the loop so I can detect if a key has been pressed

> the combo box is repainted after every addition, resulting in flicker.

> How do I get around this

-------- REPLY, End of original message --------

Here's a friendlier version of DoEvents that seems to work pretty well. It

only calls DoEvents if there is something to do!

        If GetQueueStatus(QS_INPUT) Then DoEvents

GetQueueStatus is an API call with these declarations:

Declare Function GetQueueStatus Lib "User" (ByVal fuFlags As Integer) As

Long

' Queue Status Constants

Global Const QS_KEY = &H1

Global Const QS_MOUSEMOVE = &H2

Global Const QS_MOUSEBUTTON = &H4

Global Const QS_MOUSE = QS_MOUSEMOVE + QS_MOUSEBUTTON

Global Const QS_POSTMESSAGE = &H8

Global Const QS_TIMER = &H10

Global Const QS_PAINT = &H20

Global Const QS_SENDMESSAGE = &H40

Global Const QS_INPUT = &H7F


Drag & drop

LUOKKA: ListBox

Date:         Wed, 17 Aug 1994 18:20:52 -0400

From:         Susie Moffat <pbm.admin@MHS.UNC.EDU>

Organization: UNC

Subject:      Listbox drag-drop

In this example the user can click an item in the list, then click on the

cmdSelect button to make a selection, or,  the user can drag a list item

to the text box.

 Leave DragMode =0.

Sub LstName_MouseDown (Button As Integer, Shift As Integer, X As Single,

  Y As Single)

If LstName.ListCount > 0 Then

    If LstName.ListIndex >= 0 Then

        LstName.Drag

    End If

End If

End Sub

Sub LstName_DragOver (Source As Control, X As Single, Y As Single, State

  As Integer)

    If State = Enter Then LstName.DragIcon = Image1.Picture

    If State = Leave Then LstName.DragIcon = Image1.Picture

End Sub

Sub TxtDelName_DragDrop (Source As Control, X As Single, Y As Single)

    If LstName.ListCount > 0 Then

         TxtDelName.Text =  lstName.List(LstName.ListIndex)

   End if

End Sub

Sub TxtDelName_DragOver (Source As Control, X As Single, Y As Single,

  State As Integer)

    If State = Enter Then LstName.DragIcon = Image2.Picture

    If State = Over Then LstName.DragIcon = Image2.Picture

    If State = Leave Then LstName.DragIcon = Image3.Picture

End Sub

Sub CmdSelect_Click ()

    If LstName.ListCount > 0 Then

         TxtDelName.Text =  lstName.List(LstName.ListIndex)

   End if

 End Sub


Drag & drop

LUOKKA: ListBox

Date: 03-19-95 (02:23)              Number: 263171 of 263470 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Drag&drop item within list box

you might want to try the following code. It isn't actually drag'n'drop but

emulates it quite well. When you click a list item with the right mouse

button, it is picked up into the variable DropText and removed from the

list. When you click a second time with the right button, DropText is

inserted before the list entry you clicked except when you click on the last

entry. Then it is inserted after the last entry (design decision which you

can change).

To test the code insert a list box on your form and keep the default name.

'Put this into the general section of the form code

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

ByVal wParam%, lParam As Any)

Const LB_GETTOPINDEX = &H400 + 15

Sub Form_Load ()

   Dim i As Integer

   Me.Show

   For i = 1 To 20

      List1.AddItem "Item " & i

   Next i

End Sub

Sub List1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As

Single)

   Static SecondClick As Integer

   Static DropText As String

   Dim RowHeight As Single

   Dim TopI As Integer, InsertI As Single

   TopI = SendMessage(List1.hWnd, LB_GETTOPINDEX, 0&, 0&)

   RowHeight = TextHeight("X")

   InsertI = Y ™ RowHeight

   If Button = 2 And DropText = "" And SecondClick = False Then

      List1.ListIndex = InsertI + TopI

      DropText = List1.Text

      MousePointer = 10

      SecondClick = True

      List1.RemoveItem InsertI + TopI

   ElseIf Button = 2 And Len(DropText) > 2 And SecondClick = True Then

      If InsertI + TopI < List1.ListCount - 1 Then

         List1.AddItem DropText, InsertI + TopI

      Else

         List1.AddItem DropText, InsertI + TopI + 1

      End If

      DropText = ""

      SecondClick = False

      MousePointer = 0

   End If

End Sub


Drag & drop

LUOKKA: VBgen

Date: 09/24/94 (12:18)              Number: 20586 of 20621 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Help on Drag and Drop

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Can anybody tell me how to drag files from the File Manager onto my VB app

>so that my VB app receives the path and filename of the file dropped?

(Declarations)

'Drag and drop from file manager---------------

Type POINTAPI

    x As Integer

 y As Integer

End Type

Type Msg

    hWnd As Integer

    message As Integer

    wParam As Integer

    lParam As Long

    time As Long

    pt As POINTAPI

End Type

Global Const PM_REMOVE = &H1

Global Const PM_NOYIELD = &H2

Global Const WM_DROPFILES = 563

Declare Sub DragAcceptFiles Lib "Shell" (ByVal hWnd%, ByVal faccept%)

Declare Function DragQueryFile% Lib "Shell" (ByVal hDrop%, ByVal iFile%,

ByVal

lpszFile$, ByVal cb%)

Declare Sub DragFinish Lib "Shell" (ByVal hDrop%)

Declare Function PeekMessage% Lib "User" (lpMsg As Msg, ByVal hWnd%,

ByVal

wMsgFilterMin%, ByVal wMsgFilterMax%, ByVal wRemoveMsg%)

In your Form_Load put:

'This will set your form to take the file drop message

    DragAcceptFiles Me.hWnd, True

    tmrFileDrop.Enabled = True

In tmrFileDrop put:

'This will constantly check the message queue for a file drop message

Sub tmrFileDrop_Timer ()

Static DropMessage As Msg

Static intCountFile%, iRet%

Static strDroppedFileName As String * 128

    'Turn off timer so that it doesn't try to run again

    tmrFileDrop.Enabled = False

    Do

 'Check for drop event

      If PeekMessage(DropMessage, 0, WM_DROPFILES, WM_DROPFILES,

        PM_REMOVE Or PM_NOYIELD) Then

     'get the number of files and loop

     For intCountFile = 1 To DragQueryFile(DropMessage.wParam, -1,

          strDroppedFileName, 127)

            'get File Manager to pass the file name(s) to Form1

            iRet% = DragQueryFile(DropMessage.wParam, intCountFile - 1,

              strDroppedFileName, 127)

            'Restore the window if it was an icon

            If Me.WindowState = MINIMIZED Then Me.WindowState = NORMAL

            'Open the file here or do whatever with it

            Open strDroppedFileName

            strDroppedFileName = ""

     Next intCountFile

     'dispose of the hdrop% structure

     DragFinish (DropMessage.wParam)

      End If

      DoEvents

    Loop

End Sub

__________

                           Bradley S. Murray


Draw flow charts

LUOKKA: graphics

Date: 02/13/95 (18:35)              Number: 226737 of 227119 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Flow Chart

>I need to develop a flow chart-like application, consisting of multiple

>bitmaps connected by lines. The connecting lines must follow along when

the >user repositions a bitmap. Does anyone have an idea on how to

accomplish >this?

I have included some sample code (very simplistic) and hope it gets you

started. With this code you add new objects, connect them with lines and

drag the objects around keeping the connections. The main simplifications

are that every line starts from the center of the object, all the lines go

straight from object to object (no polylines), all the diagram is refreshed when

an object is dropped and diagram elements can't be removed.

You add new images by clicking on form when SHIFT is down. You draw lines

between images by clicking on start and end images. You drag an image

when SHIFT is down.

        Lasse

___________________Sample Code

**** In a module add following type declaration ****

Type LineData

   xStart As Single

   yStart As Single

   xEnd As Single

   yEnd As Single

   StartElem As Integer

   EndElem As Integer

End Type

**** In form's general section add ****

Dim NOfImages As Integer

Dim NOfLines As Integer

Dim Drawing As Integer

Dim StartX As Single

Dim StartY As Single

Dim StartElem As Integer

Dim EndElem As Integer

Dim Lines() As LineData

Sub DrawLines ()

   Cls

   For i = 0 To NOfLines - 1

      Line (Lines(i).xStart, Lines(i).yStart)-(Lines(i).xEnd, Lines(i).yEnd)

   Next i

' Refreshing is done so that images appear on top of lines

   For i = 0 To NOfImages - 1

      Image1(i).Refresh

   Next i

End Sub

**** and then appropriate control events add ****

Sub Form_Load ()

   Drawing = False

   NOfImages = 1

   NOfLines = 0

   Image1(NOfImages - 1).Picture =

LoadPicture("c:™vb™icons™flags™ctrusa.ico")

End Sub

Sub Form_DragDrop (Source As Control, x As Single, y As Single)

   Source.Left = x - Source.Width / 2

   Source.Top = y - Source.Height / 2

   For i = 0 To NOfLines - 1

      If Lines(i).StartElem = Source.Index Then

         Lines(i).xStart = x

         Lines(i).yStart = y

      ElseIf Lines(i).EndElem = Source.Index Then

         Lines(i).xEnd = x

         Lines(i).yEnd = y

      End If

   Next i

   DrawLines

End Sub

Sub Form_MouseDown (Button As Integer, Shift As Integer, x As Single, y As

Single)

   If Button = 1 And (Shift And 1) > 0 Then

      Load Image1(NOfImages)

      Image1(NOfImages).Picture = LoadPicture("c:™vb™icons™flags™ctrusa.ico")

      Image1(NOfImages).Left = x - Image1(NOfImages).Width / 2

      Image1(NOfImages).Top = y - Image1(NOfImages).Height / 2

      Image1(NOfImages).Visible = True

      NOfImages = NOfImages + 1

      Exit Sub

   End If

   If Drawing Then

      Drawing = False

      Form1.MousePointer = 0

   End If

End Sub

Sub Image1_MouseDown (Index As Integer, Button As Integer, Shift As

Integer,

x As Single, y As Single)

' If SHIFT down when clicked with left button, start dragging

   If Button = 1 And (Shift And 1) > 0 Then

      Image1(Index).Drag 1

      Exit Sub

   End If

' If clicked with left button and drawing flag is false, pick object for

line start

   If Button = 1 And Drawing = False Then

      Drawing = True

      StartX = Image1(Index).Left + Image1(Index).Width / 2

      StartY = Image1(Index).Top + Image1(Index).Height / 2

      StartElem = Index

      Form1.MousePointer = 10

' If clicked with left button and drawing flag is true, pick object for line

end

' and draw the line

   ElseIf Button = 1 And Drawing = True Then

      EndX = Image1(Index).Left + Image1(Index).Width / 2

      EndY = Image1(Index).Top + Image1(Index).Height / 2

      Line (StartX, StartY)-(EndX, EndY)

      EndElem = Index

      Drawing = False

      Form1.MousePointer = 0

      ReDim Preserve Lines(NOfLines)

      Lines(NOfLines).xStart = StartX

      Lines(NOfLines).yStart = StartY

      Lines(NOfLines).xEnd = EndX

      Lines(NOfLines).yEnd = EndY

      Lines(NOfLines).StartElem = StartElem

      Lines(NOfLines).EndElem = EndElem

      NOfLines = NOfLines + 1

      Image1(Lines(NOfLines - 1).StartElem).Refresh

      Image1(Lines(NOfLines - 1).EndElem).Refresh

   Else

      Drawing = False

      Form1.MousePointer = 0

   End If

End Sub


Drive type iden

LUOKKA: VBgen

Date: 06-16-95 (12:02)              Number: 365180 of 365577 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Drive Type Identifier

It is a *freeware* VBX called VBIO in file VBIO.ZIP at CICA in directory

/pub/pc/win3/programr/vbasic. With it you can get (almost) all the info you

need about disks (and it is free).

Features include:

- Get and set disk serial-number (number and string)

- Get and set disk volumelabel

- Get drive type (floppy, harddisk, cd-rom, network drive)

- Get drive fat-type (filesystem type)

- Get free diskspace and total diskspace

- Get sectors per cluster, bytes per sector for a drive, free clusters and

total   clusters

- Get and set file-attributes (even hides or unhides subdirectories)

- Get and set file-date, file-time

- Get a file's size

- Determine if a drive or file exists

- Errors are reported by the Error and ErrorMessage properties and/or as a

trappable run-time error (you decide).

    Lasse


DriveListBox

LUOKKA: ListBox

Date: 09/16/94 (16:55)              Number: 19696 of 19727 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re:  Q  How do I alter drivebox behaviour?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 14 Sep 1994 15:34:53 GMT John Sharp <a908793@asic.sc.ti.com>

wrote:

> How to I modify the drivelistbox to show only floppy drives

> and not hard/network drives.  The application requires the

> user to select from a list of available floppy drives only.

> Thanks in advance

As far as I know you can't. You can, however, create a combo-box

that lists all floppy drives:

Create a drop-down list style combo-box. Walk all drives (A-Z) and call

the API function GetDriveType(). This returns DRIVE_REMOVABLE for

floppies.

Add all these to the combo-box.

Declare Function GetDriveType Lib "Kernel" (ByVal nDrive As Integer) As

Integer

Const DRIVE_REMOVABLE = 2

Sub FillComboWithFloppieDrives(cbmCombo As ComboBox)

Dim I As Integer

    cmbCombo.Clear

    For I=0 to 25

        If GetDriveType(I)=DRIVE_REMOVABLE Then

            cbmCombo.AddItem Chr$(I+65) + ":"

        End If

    Next I

End Sub

Arjen


Dynamic ctrls

LUOKKA: dyn.controls

Date: 04/12/94 (12:05)              Number: 3237 of 3272 (Refer# NONE)

From: RSCHWARZ@EDCEN.EHHS.CMICH.EDU, Ron Schwarz

Subj: Re: Dynamic Controls

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In a previous article, rgswaim@ec.b30.ingr.com (Glen Swaim) says:

>Is there a way in VB 3.0 Prof. or through the use of a DLL to dynamically

>create a Command Button?  I have an application in which I need to create

>Command Buttons and Command_Click functionality.  Anyone have

>eperience with this?

You can place one on your form, with .visible = false, and then

load new instances as you need them.  It should be a control array,

and your click event testing will then have an Index parameter, which

you use as a subscript, to determine which control you are answering

to at any time.

Ron


Dynamic ctrls

LUOKKA: dyn.controls

22.How do I create controls dynamically (at run-time)?

   Search of VBKB_FT on "control* near array*" finds a number of articles,

   including Article ID: Q79029 "Creating Nested Control Arrays in Visual

   Basic" This is THE article to read to understand control arrays (plus a

   number of other neat concepts). In particular, look at the procedure

   "loadall_click".

   The key is that you need to create the first instance of your_control

   (ie. your_control(0)) at design time.

   Ayn Shipley (ashipley@hookup.net)


Dynamic forms

LUOKKA: forms

24383 (133+)  ajm@geac.co.nz  10.07.95  00:19

Andrew Mayo: "A trick with SetParent that might be useful."

In playing around, I have found that you *can* use the SetParent API to

change the parent/child relationship of a control such that it is the

child of another form. In fact, using this, you can place controls on

another form that were never there at design time.

The control continues to report events back to its design-time parent, so

it would be necessary to handle that; also, it does not appear in its new

parent's controls collection.

I haven't checked this yet but I suspect when its new parent is unloaded

the control reverts back to its original parent and is not destroyed.

This trick could be useful - if you're building dynamic forms at runtime

you'll be aware of the annoying limitation that you must have one

instance of each control on the base form at design time. This trick

might let you put 'luxury' controls on a separate form, bringing them in

to the runtime form by changing their parent. That way you don't have a

whole bunch of useless child windows on every form, 90% of which are

invisible on most forms.

I can't vouch for whether there are nasty side-effects; I didn't crash VB

in my tests but there could be problems, caveat emptor, as they say. I

did try dynamically cloning new controls from their base form and moving

them to new forms and then unloading those forms and I didn't have any

problem with that, but, who knows. Just thought I'd share it with you,

might be useful.


EMS CDROM 59.50$

LUOKKA: commercial

Date: 02-13-95    Time: 02:52a     Number: 316

     From: eric.engelmann@wdn.com        Refer:

  Subject: Feb'95 VB Shareware CDROM         4: comp.lang.ba   Status:

Public

EMS Professional Shareware is now shipping the 14th (Feb'95) edition of its

Visual Basic shareware CD-ROM, with 1118 PD/Shareware/Free ZIP files

and a database describing these and over 384 commercial add-ons for Visual

Basic programmers. The $59.50 list price includes 3 CD-ROMs with a free

copy

of the 205,000 record PC products database.

4505 Buckhurst Ct.

Olney MD 20832-1830

Voice:301-924-3594

Fax:301-963-2708

email: eengelmann@worldbank.org

http://www.xmission.com/~wwwads/ems/ems.html


Encrypting

LUOKKA: misc

Date: 11/29/94 (12:39)              Number: 28324 of 28326 (Refer# NONE)

From: ERS3@NS1.CC.LEHIGH.EDU

Grant Abernethy: "Re: Encrypted Password"

>I would like to place an encrypted password in the ini file of my app. I

>can encrypt the word but WritePrivateProfileString() won't place the

>encryption in the ini, it leaves a blank.

The following is a modified form of an example I got off the internet to do

encryt stuff. The original took into account being able to write to an ascii

file by converting the result to a HEX STRING.

I changed it to be different every time (for the same original string) and also

to work with or without a userr supplied KEY.

'Returns the DE/ENcrypted String or NULL if an error occured

'

'Command Line

'Strg$ is the String to be DE/ENcrypted

'EnDe$ = "decrypt" or "encrypt" or anything else to not use the ASCII to

HEX-String conversions

'   (see note #1 below)

'Key$ is an OPTIONAL 'KEY' used to encrypt the string and must be the same

when decrypting as it

was

'   during encrpting.  You dont need to supply a key.

'

 'Based on code obtained from 'Internet'

    'Here's a small example, while no "enigma machine", yet provides a simple

    'way of storing a password with encryption. The password is first

encrypted

    'then converted to Hex. The reverse process will first convert to ascii

    'then decrypt. Thanks to Matt Hart for the code with some modifications

    'and changes.

'

'Modified and extensively enhanced by G.Abernethy 18/11/94

' Even using the same KEY and STRING the code will produce unique results

every time.

'

Function Crypt (ByVal Stringg$, EnDe$, ByVal Key$) As Variant

Dim i&, J$, H$, Key2$, a&, B&, s1%, s2%, Complete%, Temp$

On Error GoTo CryptERRORHANDLER

If LCase$(EnDe$) = "encrypt" Then

    For i = 1 To 4

        '---- Randomly Generate the 2nd Key component

        Randomize

        Key2$ = Key2$ & Chr$(Int(((255 - 0) + 1) * Rnd + 0))

    Next

ElseIf LCase$(EnDe$) = "decrypt" Then

    Temp$ = ""

    '---- Convert from Hex string to Ascii prior to decryption

    For i = 1 To Len(Stringg$) Step 2

       J$ = Mid$(Stringg$, i, 2)

       Temp$ = Temp$ & Chr$(Val("&H" + J$))

    Next

    Stringg$ = Mid$(Temp$, 5)          'Get the string (remove the 4Char 'Key2'

at the start of it)

    Key2$ = Left$(Temp$, 4)                        'Get the 2nd part of the key

    'Strg$ would then contain the encrypted string, which you can now

    'decrypt.

End If

'-----------------------------------------------------------------------

'---- Perform the encryption/de-encryption

'-----------------------------------------------------------------------

'---- Construct the full key

'If Key$ = "" Then Key$ = "Sesame"  'Default Key if none given

Temp$ = ""

If Key$ <> "" Then      '---- Interlace the two components of the encryption

KEY

    s1% = 1

    s2% = 1

    Do

        Temp$ = Temp$ & Mid$(Key2$, s2, 1)

        Temp$ = Temp$ & Mid$(Key$, s1, 1)

        If s1% = Len(Key$) Then

            s1% = 1

            Complete% = Complete% Or 1

        Else

            s1% = s1% + 1

        End If

        If s2% = Len(Key2$) Then

            s2% = 1

            Complete% = Complete% Or 2

        Else

            s2% = s2% + 1

        End If

     Loop Until Complete% = 3

    Key$ = Temp$

Else

    Key$ = Key2$

End If

a = 1

For i = 1 To Len(Stringg$)

    B = Asc(Mid$(Key$, a, 1))

   ' a = IIf(a = Len(Key$), 1, a + 1)

    a = a + 1

    If a > Len(Key$) Then a = 1

    Mid$(Stringg$, i, 1) = Chr$(Asc(Mid$(Stringg$, i, 1)) Xor B)

Next

'-----------------------------------------------------------------------

'---- Convert from Ascii to HEX String after encryption

'-----------------------------------------------------------------------

If LCase$(EnDe$) = "encrypt" Then

'note #1

    'When writing an encrypted password to a sequential access file like the

    'INI files, you need to convert the resultant encrypted file to hex data.

    'This is because you can end up with an encrypted password that contains

    'characters which cannot be properly read using sequential access.  So,

    'before saving your encrypted password, use this routine:

    'This will create a string like "0EF31105" or some such.  Save that to

    'the INI file.

    'Store the 2nd part of the KEY with the encrypted string

    Stringg$ = Key2$ & Stringg$

    H$ = ""

    For i = 1 To Len(Stringg$)

       J$ = Hex$(Asc(Mid$(Stringg$, i, 1)))

       If Len(J$) = 1 Then J$ = "0" + J$            'Pad to 2 characters if needed

       H$ = H$ + J$

    Next

    Stringg$ = H$

End If

'-----------------------------------------------------------------------

Crypt = Stringg$

Exit Function

CryptERRORHANDLER:

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%

%%%%%%%%%%%%%%%%

    Crypt = Null

    'Resume

    Exit Function

End Function


END

LUOKKA: VBgen

3. Multiple END statements can be dangerous; or, The program that

   refused to terminate.

   Suggestion: put the END statement used to exit your program *only*

   in the Form_Unload event of the main form. Whenever you want to end

   the program, just tell the main form to unload.

   Some have reported that after their program have (supposedly)

   terminated, it still appears in the task list. This can happen if

   you only hide secondary forms and forget to unload them when you

   end/unload the main form.

   Also note that the Stop-button on the button-bar of the integrated

   development environment doesn't really unload anything. It *nukes*

   the program, which generally is a good idea since it could be a bug

   in it that caused it to be stuck in an eternal loop or something.


Energy saving monitor

LUOKKA: VBgen

28083 (101+)  rcw@netcom.com  28.07.95  22:31

Robert Woodcock: "Re: ??? Energy Star monitor ???"

According to Appleman, you're looking for the WM_POWER (&H48) message,

which should be sent to all top-level windows (HWND_BROADCAST or -1).

Here's the wParam constants:

PWR_SUSPENDREQUEST = 1	Request power-conservation mode.

PWR_FAIL = -1	Sent in response to PWR_SUSPENDREQUEST

to keep

the system from entering power-saving mode.

PWR_OK = 1	Same as PWR_FAIL, but OK's the

power-saving.

PWR_SUSPENDRESUME = 2	To enter normal operation.

PWR_CRITICALRESUME = 3  Resuming operation, but

PWR_SUSPENDREQUEST wasn't sent.

--------------------------------------------------------

Robert Woodcock

rcw@netcom.com


Energy Star monitor

LUOKKA: VBgen

28083 (101+)  rcw@netcom.com  28.07.95  22:31

Robert Woodcock: "Re: ??? Energy Star monitor ???"

Rat Loaf (ratloaf@sirius.com) composed eloquently:

>Does anyone knows how to write the code or where to find the info on

>applying to an Energy Star monitor inorder to shut it down and power it

>back up using VB.

According to Appleman, you're looking for the WM_POWER (&H48) message,

which should be sent to all top-level windows (HWND_BROADCAST or -1).

Here's the wParam constants:

PWR_SUSPENDREQUEST = 1	Request power-conservation mode.

PWR_FAIL = -1	Sent in response to PWR_SUSPENDREQUEST

to keep

the system from entering power-saving mode.

PWR_OK = 1	Same as PWR_FAIL, but OK's the

power-saving.

PWR_SUSPENDRESUME = 2	To enter normal operation.

PWR_CRITICALRESUME = 3  Resuming operation, but

PWR_SUSPENDREQUEST wasn't sent.

I don't have an Energy Star system, so I'm not too sure how these are

supposed to work. :/

--

Robert Woodcock

rcw@netcom.com


Enter

LUOKKA: input

7.4.12.  Using Enter to move to the next input field

-----------------------------------------------------

  If you wish to use the Return key to move to the next field (against the

  Windows user interface guidelines, but expected by many users), you simply

  need to trap the keys in each control.  For example, if you have an array

  of eight edit controls called InputField, you should define a routine like

  this:

     InputField_KeyPress(Index as Integer, KeyAscii as Integer)

     If (KeyAscii = 13) Then

         If (Index = 7) Then

             InputField(0).SetFocus

         Else

             InputField(Index + 1).SetFocus

         End If

         KeyAscii = 0

     End If

     End Sub


Enter

LUOKKA: TextBox

5. How do I make a text box not beep but do something else when I hit

   the Enter key?

   Put "something else" in your _KeyPress event, depending on what you

   really want. This code example makes *nothing* happen, for an

   extended period of time:

     Sub Text1_KeyPress (KeyAscii As Integer)

         If KeyAscii = 13 Then   '13 is Key_Return

            KeyAscii = 0

         End If

     End Sub

   This might not be a very nice thing to do, since your users usually

   have some intention when they press Enter. Often they will want to

   jump to the next control, like the Tab key does. To have the Enter

   key emulate the Tab key action, you will need to add the line

   'SendKeys " tab "' above 'KeyAscii=0' in the example above (Yes, I

   thought KeyAscii=9 works but it doesn't! Tab is obviously handled

   by Windows on a lower level).

   By the way, you'll also find this in the Microsoft VB Knowledge

   Base (see KB Q78305 and Q85562).

   Note: If MultiLine=True you will *not* want to disable the normal

   behaviour of the Enter key.


Error 3043

LUOKKA: Access

Date: 04-21-95 (04:39)              Number: 297616 of 301771 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: error 3043

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Could someone pls explain me why, with VB and MS-Access, after a 3043

error (Database not correctly closed), I have to exit and then reenter on

Windows for recover this kind of error?

Does exist some alternative way to recover it?

     If an application opens a global or module-level data access object on a

     database, and does not specifically close the object with the Close

     method, then a reference to that object can remain in memory even after

     the application is closed.

     The next application that attempts to access the same database will at

     times see this type of error.

     Assuming you are running your application, then exiting, then having

     difficulty the next time you run it - look through all your .FRM and .BAS

     modules' General Declarations sections.  If you define data access

     objects in these sections, then for .FRM objects do the following in the

     Form_Unload event:

          On Error Resume Next

          object1.Close

          object2.Close

          etc....

          On Error Goto 0

     For objects defined in .BAS modules, before your application exits

     completely make sure you specifically close those objects.

     kevin_albert@smtpgate.mitchell.com


Error codes Acc 2.0 ?

LUOKKA: Access

1269 (51+)  nsmart@internet-eireann.ie  08.01.95  17:09

Niall Smart: "Re: trapping jet database engine errors"

>Is there somebody here who knows how to trap errors that could occur from

>the database engine ?

>For instance when I try to create a record with a duplicate value for a field

>which doesn't allow duplicates, a reserved error appears. I'd like to know in

>which event I could trap it.

I would guess that you are using the Access 2.0 or 2.5 compatability layer. If

this is the case then the Access DB engine is encountering an error deleteing

the records. However the problem is that the compatability layer cannot

upgrade internal VB error codes. Therefore when it encounters an error it

triggers VB error number 3000. There is a workaround though. If you examinr

Error$ at the time of the error you will see a string like:

Reserved Error(-8194). There is no message for this error.

MS have published a list of Jet 2.0 errors that appear between the brackets

in the above message so you can use InStr to trap the error.. See the

example below:

Const DB_ERR_NOSUCHTABLE = "-8266"

Const DB_ERR_RESERVED = 3000

On Error Goto ErrHandler

DB.OpenTable("X Table")

.....

Exit Sub

ErrHandler:

Beep

Select Case Err

    Case DB_ERR_RESERVED

        If Instr(Error$, DB_ERR_NOSUCHTABLE) Then

             'We have tried to open a non existant table

             ...

        ElseIf

        ....

        ....

        End If

    ...

End Select

....

This should ive the general idea. Note that DB_ERR_NOSUCHTABLE is a

string value and DB_ERR_RESERVED is numeric. You can find the list of

Access 2.0 error codes in KB article Q117900. Cya

Niall Smart

nsmart@internet-eireann.ie


Error codes Acc. 2.0

LUOKKA: Access

7759 (29+)  jfarr@xstacy.enet.dec.com  27.07.95  12:37

"Re: VB Error - (-8261)"

I'v enclosed a complete list of these stupid error codes. Hope

this helps.

Joe.

SUMMARY

=======

The following is a list of reserved error codes that may be returned by the

new Microsoft Access version 2.0 Jet engine that Visual Basic can now use

if you have installed the Jet 2.0/Visual Basic 3.0 Compatibility Layer.

The reserved error numbers listed here are not Visual Basic error codes.

They are unmapped Jet 2.0 errors that are exposed only as "Reserved

Errors" in Visual Basic. In a future version of Visual Basic, many of these Jet

2.0 errors will be mapped to Visual Basic error codes.

Because these reserved error numbers are subject to change, developers

should not rely on them being the same and should be ready to update the

error-trapping routines when the next version of Visual Basic is released.

With each of the Jet version 2.0 error numbers listed below, you'll find a

brief error string that appears when the error is viewed in Microsoft

Access version 2.0. Only the message "Reserved Error" appears when the

same error appears in Visual Basic.

NOTE: There are pipe characters () throughout these strings that act as

placeholders for context information such as column names, table names, and

so forth that would be filled in at the time of the error.

In the Microsoft Access Online Help file, use the following steps to find

more detailed information about each of the error strings and what they

mean when applied to Microsoft Access:

1. Choose Help from the Microsoft Access main menu.

2. Choose Search, and search for this topic:

   error messages: reference

3. Select that topic.

Now you can search for specific error strings alphabetically.

MORE INFORMATION

================

Jet_Error/Message_String

------------------------

  -1010 Invalid database ID.

  -1016 Can't have more than 10 fields in an index.

  -1029 Database engine hasn't been initialized.

  -1030 Database engine has already been initialized.

  -1034 Query support unavailable.

  -1046 Can't delete a field that is part of an index.

  -1051 Can't delete this index.  It is either the current index

           or is used in a relationship.

  -1062 Can't create database; Invalid locale.

  -1066 Can't create a relationship.

  -1068 Invalid referential integrity constraint.

  -1209 The Jet database engine has encountered a problem in your

           database.  To correct the problem, you must repair and

           compact the database.

  -1308 Can't define field or index in a table that contains

           data.

  -1309 Can't modify table structure.  Another user has the table

           open.

  -1315 Can't change a rule while the rules for this table are in

           use.

  -1316 Object is invalid for operation.

  -1402 Primary key already exists.

  -1403 Index already exists.

  -1406 Invalid index definition.

  -1513 Can't create index on Memo field or OLE Object field.

  -1519 Can't delete this field.  It's part of one or more

           relationships.

  -1523 Zero-length string is valid only in a text or Memo field.

  -1601 The key was not found. (JET_errRecordNotFound)

  -1802 Can't open 9 system database (typically SYSTEM.MDA).

  -1910 You must enter a personal identifier (PID) consisting of

           at least four and no more than 20 characters and digits.

  -1911 Account name already exists.

  -2030 There are several tables with that name. Please specify

           owner in the format 'owner.table'.

  -2031 Invalid connection string in pass-through query.

  -2032 Single-row update/delete affected more than one row of a

           remote table.  Index specified as unique contains

           duplicate values.

  -2033 The server's MSysConf table exists, but is in an

           incorrect format.  Contact your system administrator.

  -2034 You cannot use ODBC to attach an external Microsoft

           Access or ISAM database table to your database.

  -3028 Can't have action query as an input.

  -3031 Query does not return records.

  -3059 This query is not a properly formed data-definition

           query.

  -3060 No database specified in connection string or IN clause.

  -3063 At most one field can be returned from a subquery that

           doesn't use the EXISTS keyword.

  -3064 The number of columns in the two selected tables or

           queries of a union query don't match.

  -3066 Execute method must be used on action or data-definition

           queries.

  -3069 Pass-through query with ReturnsRecords property set to

           True did not return any records.

  -3070 At most one record can be returned by this subquery."

  -3071 Query is too complex.

  -3072 Unions not allowed in a subquery.

  -3073 Can't perform join, group, or sort. Combined fields are

           too long.

  -3077 Too many FastFind Sessions were invoked.

  -3520 Number  of query values and destination fields aren't the

           same.

  -3530 Join expression not supported.

  -3531 Can be present only in version 1.0 format.

  -3532 Syntax error in union query.

  -3535 Pass-through query must contain at least one character.

  -3550 Syntax error in CONSTRAINT clause.

  -3551 Syntax error in CREATE TABLE statement.

  -3552 Syntax error in CREATE INDEX statement.

  -3553 Syntax error in field definition.

  -3554 Syntax error in ALTER TABLE statement.

  -3555 Syntax error in DROP INDEX statement.

  -3556 Syntax error in DROP TABLE statement.

  -3560 Relationship must be on the same number of fields with

           the same data types.

  -3561 Can't find field in index definition.

  -3601 Property setting can't be larger than 2 KB.

  -3602 This property isn't supported for external data sources

           or for databases created in a previous version of 9.

  -3603 Property specified already exists.

  -3604 DeleteOnly called with non-zero cbData.

  -3605 An error has occurred.  Properties were not saved.

  -3606 Can't save property; property is a schema property.

  -3700 Validation rules and default values can't be placed on

           system or attached tables.

  -3704 Can't place this validation expression on this field.

  -3708 Syntax error in default value.

  -5015 External table isn't in the expected format.

  -5016 Unexpected error from external database driver ().

  -5017 Numeric field overflow.

  -5020 Paradox index is not primary.

  -5029 Can't open ''.  Another user has the table open using a

           different network control file or locking style.

  -5030 Can't open this Paradox 4.x table because ParadoxNetStyle

           is set to 3.x in 8.

  -5112 Format of memo file doesn't match specified external

           database format.

  -5210 Btrieve: Invalid IndexDDF option in 8.

  -5211 Invalid DataCodePage option in 8.

  -5212 Btrieve: Xtrieve options aren't correct in 8.

  -5213 Btrieve: Can't find file FIELD.DDF.

  -5214 Btrieve: Invalid IndexDeleteRenumber option in 8.

  -8056 No destination field name in INSERT statement ().

  -8172 Top not allowed in delete queries.

  -8175 Crosstab query contains one or more invalid fixed column

           headings.

  -8176 Query '' is corrupt.

  -8177 Invalid TOP argument in select query.

  -8178 This Recordset is not updatable.

  -8179 Field '' is based on an expression and can't be edited.

  -8180 Table '2' is read-only.

  -8181 Record in table '' was deleted by another user.

  -8182 Record in table '' is locked by another user.

  -8183 To make changes to this field, first save the record.

  -8184 Can't enter value into blank field on 'one' side of outer

           join.

  -8185 Records in table '' would have no record on the 'one'

           side.

  -8186 Current field must match join key '' on 'one' side of

           outer join.

  -8187 Invalid Memo or OLE object in subquery ''.

  -8188 Unrecognized database format ''.

  -8189 ORDER BY expression () uses non-output fields.

  -8190 Unknown or invalid reference '1' in validation

           expression or default value in table '2'.

  -8191 Unknown or invalid field reference ''.

  -8192 Can't add record(s); primary key for table '' not in

           recordset.

  -8193 Can't add record(s); join key of table '' not in

           recordset.

  -8194 The database is opened by user '2' on machine '1'.  You

           can't open this database exclusively.

  -8195 Record(s) can't be added; no corresponding record on the

           'one' side.

  -8196 Can't use Memo or OLE object field '' in SELECT

           clause of a union query.

  -8197 Unknown function '2' in validation expression or default

           value on '1'.

  -8220 Can't modify the design of table ''.  It's in a

           read-only database.

  -8221 Can't find table or constraint.

  -8222 No such index '2' on table '1'.

  -8223 Can't create relationship.  Referenced table '' doesn't

           have a primary key.

  -8224 The specified fields are not uniquely indexed in table

           ''.

  -8225 Table '1' already has an index named '2'

  -8226 Table '' doesn't exist.

  -8227 No such relationship '2' on table '1'.

  -8228 There is already a relationship named '' in the current

           database.

  -8229 Can't create relationships to enforce referential

           integrity.  Existing data in table '2' violates

           referential integrity rules with related table '1'.

  -8230 Field '2' already exists in table '1'.

  -8231 There is no field named '2' in table '1'.

  -8232 Field '' size must be 1 to 255.

  -8233 Can't delete field ''.  It's part of one or more

           relationships.

  -8234 There is no primary key in table ''.

  -8235 Invalid field name '' in definition of index or

           relationship.

  -8260  in table-level validation expression.

  -8261 Field '' can't contain a null value.

  -8262 Field '' can't be a zero-length string.

  -8263 This validation rule must be met.

  -8264 Can't perform cascading operation.  Since related records

           exist in table '', referential integrity rules would be violated.

  -8265 Can't perform cascading operation.  There must be a

           related record in table ''.

  -8266 Can't perform cascading operation.  It would result in a

           null key in table ''.

  -8267 Can't perform cascading operation.  It would result in a

           duplicate key in table ''.

  -8268 Can't perform cascading operation.  It would result

           in two updates on field '2' in table '1'.

  -8269 Can't perform cascading operation.  It would cause field

           '' to become null, which is not allowed.

  -8270 Can't perform cascading operation.  It would cause field

           '' to become a zero-length string, which is not allowed.

  -8271 Can't perform cascading operation:  ''

  -8272 Invalid entry.  Can't perform cascading operation

           specified in table '1' because value entered is too big

           for field '2'.

  -8273

  -8274 Can't perform cascading update on table '' because it is

           currently in use.

  -20000 Can't open this database for update.

  -30001 No fields defined - cannot append table.

  -30002 Name not found in this collection.

  -30003 Can't append.  Field is part of a TableDefs collection.

  -30004 Property can be set only when the field is part of a Recordset

             object's Fields collection.

  -30005 Can't set this property once the object is part of a collection.

  -30006 Can't append.  Index is part of a TableDefs collection.

  -30007 Property not found.

  -30008 Invalid property value.

  -30009 Object isn't a collection.

  -30010 Method not applicable for this object.

  -30011 Can't set this property for remote objects.

  -30012 Can't append a relation with no fields defined.

  -30013 Can't append.  Object already in collection.

  -30014 Can't delete a built-in property.

  -30015 Property '' must be set before using this method.

  -30016 User-defined properties don't support a Null value.

  -30017 Object is no longer valid.

  -30018 This method or property is not currently available on

             this Recordset.

  -30019 The action was canceled by an associated object.

  -30020 Error in DAO automation.

  -30021 Data type conversion error.

  -32020 Can't import table or query.  No records found, or all

             records contain errors.


Error general

LUOKKA: error

Date: 06-20-95 (10:56)              Number: 367832 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Generic Error Handler

>I would like to ask if anybody has made a generic error handler, one which

>will be used by an entire VB program, so I won't have error handling routines

>scattered all over my forms and modules.

>

I imagine such an error handler is possible, but would it really be useful?

You could write a rather large routine to handle all possible (trappable)

errors in VB, but because of the way that error handling routines work, it

probably would not behave as hoped.  As you stated, when an error occurs,

control passes to the "closest" active error handling routine.  However, if

that error handling routine is not in the procedure where the error occurs,

then any efforts to correct the error and return to the place where the error

occurred would not be possible.

A short illustration might be helpful.

Sub Main()

        On Error Goto ErrorHandler

        Call Procedure1( )

        Call Procedure2( )

ErrorHandler:

        '

'       code to correct the error

        Resume Next

End Sub

Now, if an error where to occur in Procedure1, then control would be passed

to the line label ErrorHandler: in the Main Subroutine.  When the error

handling routine is completed and the "Resume Next" statement is executed,

control passes to the beginning of Procedure2.  Your "place" in Procedure1

is lost, so the error correction probably didnt do any good.  Moreover,  any

code that was to be executed in Procedure1 after the line where the error

occured is skipped over!

Now, it the sole purpose of an error handling routine in one's program was to

merely identify what error occured and to make some note of it (ie. a

message box or writing to a log file), then a "Global" error handler might be of

some use.

In my opinion,  the way to handle errors is to identify sections in which an

error might occur and which errors might occur,  then write a simple error

handling routine in that procedure to correct.  Often times, but not always : (,

 it is usually easy to identify what errors might occur (such as

file access errors when executing an OPEN statement).

You generally don't need a routine to handle every possible error.

Larry


Error global errhandl

LUOKKA: error

Date: 12/05/94 (18:46)              Number: 144756 of 144885 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Global Error Handler -Reply

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>Unfortunately, this approach will not allow me to trap the error that occurs

 >when I loose the ODBC connection to Oracle.

>- IanO -

>>> Stephen Lenz <slenz@RISD.EDU> 2 December 1994  1:46 pm >>>

What I do is, instead of having a global error handler, I write (for instance)

a global module to open a file, close a file, or whatever, and have the

errorhandler in that module. Then you can call OpenFile(filename)...

Steve Lenz slenz@risd.edu


Error handling

LUOKKA: error

Date: 06-20-95 (11:54)              Number: 367945 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Generic Error Handler

I just finished an app where i had to build error recovery routines in. To my

knowledge, there is no way to create a general purpose error routine in VB.

You can though create a function that handles the error messages and the

possible replies.

What i did was create such a function call HandleError(Errcode,

Functionname) that was called from every Sub of Function. This function

displays the error message and returns 1 (for end),

2 (retry), 3 (ignore). The program was a realtime data retrieval system so a

retry had to be possible. Then i handled the returnvalue in every sub or

function. This was implemented in a later stage. In these situations, i can

be  lazy and do not want to type more than i have to.

So i made a backup of my project,saved all my forms and .bas files to text

files and created an VB application that scan's the vb text files for every

Function, Sub, End Sub, Exit Sub/Function, End Function. I placed before

every End Sub and End Function the label and call to HandleError and some

code to handle the returnvalues. The Goto label for the On Error was

constructed from the Sub of Function name by adding _error to the function

name.

It doesn't work for all situations (so i made it possible to skip a sub or

function) but it saved me a lot of typing work.

This vb application is not right available for distribution but i'm working

it to make to "fool" proof :). What i wanted to know if there if someone

is interested in this vb tool. It will be free-ware.

Let's hope that VB 4.0 will give us global error routines.

Checkout my homepages : http://www.xs4all.nl/~treffers with vb information

Email Address : treffers@xs4all.nl


Error Local error

LUOKKA: error

Date: 09/16/94 (10:33)              Number: 19536 of 19727 (Refer# NONE)

From: EXUIAN@EXU.ERICSSON.SE

Subj: Re: How can I KILL files without checking

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

VB windows supports the ON ERROR ... syntax,  and also ON LOCAL

ERROR ..., but this is not documented anywhere. However I believe it is

documented in VB-DOS, and if I recall it is used to distinguish between the

Quick Basic global "ON ERROR" and the a new type of local error trapping

for VB-DOS event procedures. As I understand it, it is equivalent to ON

ERROR ... in VB windows, since it is not possible to have global error

handling in VB windows. If anyone knows better, please correct me !

/Ian

PS : The reason I use "LOCAL" is because I like to have each subroutine

deal with its own errors, rather than jump to a label and call a subroutine - so

I like the "LOCAL" since it makes it clear to others that error handling is local

- I also let the subroutine execute completely, and then check for errors

before exit sub. This way I can be sure the program will not terminate if a run

time error occurs, and I can display a message to the user telling them the

module and subroutine that caused the fault, which makes it easy to solve

any run time faults - and it doesn't add a huge amount of code to the finished

EXE. Obviously if a subroutine is likely to cause errors e.g disk accesss etc,

then you have to handle those errors in a different way rather than as a run

time error.

e.g.

SUB QUICKSORT (.....)

IF globalHandleRunTimeError = True then ON LOCAL ERROR RESUME

NEXT

'globalHandleRunTimeError is a global flag that turns on this

'per subroutine error trapping.

.... code that may cause unanticipated experrors

....

IF ERR>0 THEN

  CALL DISPLAYERROR( Modulename, SubroutineName, ERR)

  ERR=0 ' Avoid cascading errors in nested subroutines

END IF

END SUB

This is most useful during BETA testing of a new program.

Once the program has been in the field for a long time and most errors

have been found, you can remove this code, or just set

globalHandleRunTimeError to false and recompile.


Error placement of Er

LUOKKA: error

Date: 08/16/94 (21:55)              Number: 15838 of 15901 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Optimum Placement of Erro

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I can only speak for myself.  I place "Exit Sub" at the bottom of the

sub (just before "End Sub"), then continue from that point with my error

handler.  The last line of the error handler is "Resume Next".  This

way, any errorhandling is done within the sub that causes the problem,

and it's always in the same location.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                                m_rubin@tatertot.com


Errorcodes vb 3.0

LUOKKA: error

VB 3.0 Trappable Errors

----------------------------------

  3 Return without GoSub

   5 Illegal function call

   6 Overflow

   7 Out of memory

   9 Subscript out of range

  10 Duplicate definition

  11 Division by zero

  13 Type mismatch

  14 Out of string space

  16 String formula too complex

  17 Can't continue

  19 No Resume

  20 Resume without error

  28 Out of stack space

  35 Sub or Function not defined

  48 Error in loading DLL

  49 Bad DLL calling convention

  51 Internal error

  52 Bad file name or number

  53 File not found

  54 Bad file mode

  55 File already open

  57 Device I/O error

  58 File already exists

  59 Bad record length

  61 Disk full

  62 Input past end of file

  63 Bad record number

  64 Bad file name

  67 Too many files

  68 Device unavailable

  70 Permission denied

  71 Disk not ready

  74 Can't rename with different drive

  75 Path/File access error

  76 Path not found

  91 Object variable not Set

  92 For loop not initialized

  93 Invalid pattern string

  94 Invalid use of Null

  95 Cannot destroy active form instance

 260 No timer available

 280 DDE channel not fully closed; awaiting response from foreign

application

 281 No More DDE channels

 282 No foreign application responded to a DDE initiate

 283 Multiple applications responded to a DDE initiate

 284 DDE channel locked

 285 Foreign application won't perform DDE method or operation

 286 Timeout while waiting for DDE response

 287 User pressed Escape key during DDE operation

 288 Destination is busy

 289 Data not provided in DDE operation

 290 Data in wrong format

 291 Foreign application quit

 292 DDE conversation closed or changed

 293 DDE Method invoked with no channel open

 294 Invalid DDE Link format

 295 Message queue filled; DDE message lost

 296 PasteLink already performed on this control

 297 Can't set LinkMode; invalid LinkTopic

 298 DDE requires ddeml.dll

 320 Can't use character device names in file names: ' '

 321 Invalid file format

 340 Control array element ' ' doesn't exist

 341 Invalid control array index

 342 Not enough room to allocate control array ' '

 343 Object not an array

 344 Must specify index for object array

 345 Reached limit: cannot create any more controls for this form

 360 Object already loaded

 361 Can't load or unload this object

 362 Can't unload controls created at design time

 363 Custom control ' ' not found

 364 Object was unloaded

 365 Unable to unload within this context

 366 No MDI Form available to load

 380 Invalid property value

 381 Invalid property array index

 382 ' ' property cannot be set at run time

 383 ' ' property is read-only

 384 A form can't be moved or sized while minimized or maximized

 385 Must specify index when using property array

 386 ' ' property not available at run time

 387 ' ' property can't be set on this control

 388 Can't set Visible property from a parent menu

 389 Invalid key

 390 No Defined Value

 391 Name not available

 392 MDI child forms cannot be hidden

 393 ' ' property cannot be read at run time

 394 ' ' property is write-only

 395 Can't use separator bar as menu name

 400 Form already displayed; can't show modally

 401 Can't show non-modal form when modal form is displayed

 402 Must close or hide topmost modal form first

 403 MDI forms cannot be shown modally

 404 MDI child forms cannot be shown modally

 420 Invalid object reference

 421 Method not applicable for this object

 422 Property ' ' not found

 423 Property or control ' ' not found

 424 Object required

 425 Invalid object use

 426 Only one MDI Form allowed

 427 Invalid object type; Menu control required

 428 Popup menu must have at least one submenu

 429 OLE Automation server cannot create object

 430 Class does not support OLE Automation

 431 OLE Automation server cannot load file

 432 OLE Automation file or object name syntax error

 433 OLE Automation object does not exist

 434 Access to OLE Automation object denied

 435 OLE initialization error

 436 OLE Automation method returned unsupported type

 437 OLE Automation method did not return a value

 438 OLE Automation no such property or method

 439 OLE Automation argument type mismatch

 440 OLE Automation error.

 441 Error loading VBOA300.DLL

 442 OLE Automation Lbound or Ubound on non Array value

 443 OLE Automation Object does not have a default value

 444 Method not applicable in this context

 460 Invalid Clipboard format

 461 Specified format doesn't match format of data

 480 Can't create AutoRedraw image

 481 Invalid picture

 482 Printer error

 520 Can't empty Clipboard

 521 Can't open Clipboard

 600 Set value not allowed on collections

 601 Get value not allowed on collections

 602 General ODBC error: ' '

 603 ODBC - SQLAllocEnv failure

 604 ODBC - SQLAllocConnect failure

 605 OpenDatabase - invalid connect string

 606 ODBC - SQLConnect failure ' '

 607 Access attempted on unopened DataBase

 608 ODBC - SQLFreeConnect error

 609 ODBC - GetDriverFunctions failure

 610 ODBC - SQLAllocStmt failure

 611 ODBC - SQLTables (TableDefs.Refresh) failure: ' '

 612 ODBC - SQLBindCol failure

 613 ODBC - SQLFetch failure: ' '

 614 ODBC - SQLColumns (Fields.Refresh) failure: ' '

 615 ODBC - SQLStatistics (Indexes.Refresh) failure: ' '

 616 Table exists - append not allowed

 617 No fields defined - cannot append table

 618 ODBC - SQLNumResultCols (CreateDynaset) failure: ' '

 619 ODBC - SQLDescibeCol (CreateDynaset) failure: ' '

 620 Dynaset is open - CreateDynaset method not allowed

 621 Row-returning SQL is illegal in ExecuteSQL method

 622 CommitTrans/Rollback illegal - Transactions not support

 623 Name not found in this collection

 624 Unable to Build Data Type Table

 625 Data type of field ' ' not supported by target database

 626 Attempt to Move past EOF

 627 Dynaset is not updatable or Edit method has not been invoked

 628 ' ' Dynaset method illegal - no scrollable cursor support

 629 Warning:   (ODBC - SQLSetConnectOption failure)

 630 Property is read-only

 631 Zero rows affected by Update method

 632 Update illegal without previous Edit or AddNew method

 633 Append illegal - Field is part of a TableDefs collection

 634 Property value only valid when Field is part of a Dynaset

 635 Cannot set the property of an object which is part of a Database object

 636 Set field value illegal without previous Edit or AddNew method

 637 Append illegal - Index is part of a TableDefs collection

 638 Access attempted on unopened Dynaset

 639 Field type is illegal

 640 Field size illegal for specified Field Type

 641   illegal - no current record

 642 Reserved parameter must be FALSE

 643 Property Not Found

 644 ODBC - SQLConfigDataSource error ' '

 645 ODBC Driver does not support exclusive access to Dynasets

 646 GetChunk: Offset/Size argument combination illegal

 647 Delete method requires a name argument

 648 Data access objects require VBDB300.DLL

2420 Syntax error in number

2421 Syntax error in date

2422 Syntax error in string

2423 Invalid use of '.', '!', or '()'.

2424 Unknown name

2425 Unknown function name

2426 Function isn't available in expressions

2427 Object has no value

2428 Invalid arguments used with domain function

2429 In operator without ()

2430 Between operator without And

2431 Syntax error

2432 Syntax error

2433 Syntax error

2434 Syntax error

2435 Extra )

2436 Missing ), ], or

2437 Invalid use of vertical bars

2438 Syntax error

2439 Wrong number of arguments used with function

2440 IIF function without ()

2442 Invalid use of parentheses

2443 Invalid use of Is operator

2445 Expression too complex

2446 Out of memory during calculation

2447 Invalid use of '.', '!', or '()'.

2448 Can't set value.

2449 Invalid method in expression.

2450 Invalid reference to form ' '.

2451 Invalid reference to report ' '.

2452 Invalid reference to Parent property.

2453 Invalid reference to control ' '.

2454 Invalid reference to '! '.

2455 Invalid reference to property ' '.

2456 Invalid form number reference.

2457 Invalid report number reference.

2458 Invalid control number reference.

2459 Can't refer to Parent property in Design view.

2460 Can't refer to Dynaset property in Design view.

2461 Invalid section reference.

2462 Invalid section number reference.

2463 Invalid group level reference.

2464 Invalid group level number reference.

2465 Invalid reference to field ' '.

2466 Invalid reference to Dynaset property.

2467 Object referred to in expression no longer exists.

2468 Invalid argument used with DatePart, DateAdd or DateDiff function.

2469  1 in validation rule: '|2'.

2470   in validation rule.

2471   in query.

2472   in linked master field.

2473  1 in '|2' expression.

2474 No control is active.

2475 No form is active.

2476 No report is active.

2477 Invalid subclass ' ' referred to in TypeOf function.

3000 Reserved error ( ); there is no message for this error.

3001 Invalid argument.

3002 Couldn't start session.

3003 Couldn't start transaction; too many transactions already nested.

3004 Couldn't find database ' '.

3005 ' ' isn't a valid database name.

3006 Database ' ' is exclusively locked.

3007 Couldn't open database ' '.

3008 Table ' ' is exclusively locked.

3009 Couldn't lock table ' '; currently in use.

3010 Table ' ' already exists.

3011 Couldn't find object ' '.

3012 Object ' ' already exists.

3013 Couldn't rename installable ISAM file.

3014 Can't open any more tables.

3015 ' ' isn't an index in this table.

3016 Field won't fit in record.

3017 Field length is too long.

3018 Couldn't find field ' '.

3019 Operation invalid without a current index.

3020 Update without AddNew or Edit.

3021 No current record.

3022 Can't have duplicate key; index changes were unsuccessful.

3023 AddNew or Edit already used.

3024 Couldn't find file ' '.

3025 Can't open any more files.

3026 Not enough space on disk.

3027 Couldn't update; database is read-only.

3028 Couldn't initialize data access because file 'SYSTEM.MDA' couldn't be

opened.

3029 Not a valid account name or password.

3030 ' ' isn't a valid account name.

3031 Not a valid password.

3032 Can't delete account.

3033 No permission for ' '.

3034 Commit or Rollback without BeginTrans.

3035 Out of memory.

3036 Database has reached maximum size.

3037 Can't open any more tables or queries.

3038 Out of memory.

3039 Couldn't create index; too many indexes already defined.

3040 Disk I/O error during read.

3041 Incompatible database version.

3042 Out of MS-DOS file handles.

3043 Disk or network error.

3044 ' ' isn't a valid path.

3045 Couldn't use ' '; file already in use.

3046 Couldn't save; currently locked by another user.

3047 Record is too large.

3048 Can't open any more databases.

3049 ' ' is corrupted or isn't a Microsoft Access database.

3050 Couldn't lock file; SHARE.EXE hasn't been loaded.

3051 Couldn't open file ' '.

3052 MS-DOS file sharing lock count exceeded.  You need to increase the

number of locks installed with SHARE.EXE.

3053 Too many client tasks.

3054 Too many Memo or Long Binary fields.

3055 Not a valid file name.

3056 Couldn't repair this database.

3057 Operation not supported on attached tables.

3058 Can't have Null value in index.

3059 Operation canceled by user.

3060 Wrong data type for parameter ' '.

3061  1 parameters were expected, but only |2 were supplied.

3062 Duplicate output alias ' '.

3063 Duplicate output destination ' '.

3064 Can't open action query ' '.

3065 Can't execute a non-action query.

3066 Query must have at least one output field.

3067 Query input must contain at least one table or query.

3068 Not a valid alias name.

3069 Can't have action query ' ' as an input.

3070 Can't bind name ' '.

3071 Can't evaluate expression.

3073 Operation must use an updatable query.

3074 Can't repeat table name ' ' in FROM clause.

3075  1 in query expression '|2'.

3076   in criteria expression.

3077   in expression.

3078 Couldn't find input table or query ' '.

3079 Ambiguous field reference ' '.

3080 Joined table ' ' not listed in FROM clause.

3081 Can't join more than one table with the same name ( ).

3082 JOIN operation ' ' refers to a non-joined table.

3083 Can't use internal report query.

3084 Can't insert into action query.

3085 Undefined function ' ' in expression.

3086 Couldn't delete from specified tables.

3087 Too many expressions in GROUP BY clause.

3088 Too many expressions in ORDER BY clause.

3089 Too many expressions in DISTINCT output.

3090 Resultant table may not have more than one Counter field.

3091 HAVING clause ( ) without grouping or aggregation.

3092 Can't use HAVING clause in TRANSFORM statement.

3093 ORDER BY clause ( ) conflicts with DISTINCT.

3094 ORDER BY clause ( ) conflicts with GROUP BY clause.

3095 Can't have aggregate function in expression ( ).

3096 Can't have aggregate function in WHERE clause ( ).

3097 Can't have aggregate function in ORDER BY clause ( ).

3098 Can't have aggregate function in GROUP BY clause ( ).

3099 Can't have aggregate function in JOIN operation ( ).

3100 Can't set field ' ' in join key to Null.

3101 Join is broken by value(s) in fields ' '.

3102 Circular reference caused by ' '.

3103 Circular reference caused by alias ' ' in query definition's SELECT list.

3104 Can't specify Fixed Column Heading ' ' in a crosstab query more than

once.

3105 Missing destination field name in SELECT INTO statement ( ).

3106 Missing destination field name in UPDATE statement ( ).

3107 Couldn't insert; no insert permission for table or query ' '.

3108 Couldn't replace; no replace permission for table or query ' '.

3109 Couldn't delete; no delete permission for table or query ' '.

3110 Couldn't read definitions; no read definitions permission for table or

query ' '.

3111 Couldn't create; no create permission for table or query ' '.

3112 Couldn't read; no read permission for table or query ' '.

3113 Can't update ' '; field not updatable.

3114 Can't include Memo or Long Binary when you select unique values ( ).

3115 Can't have Memo or Long Binary in aggregate argument ( ).

3116 Can't have Memo or Long Binary in criteria ( ) for aggregate function.

3117 Can't sort on Memo or Long Binary ( ).

3118 Can't join on Memo or Long Binary ( ).

3119 Can't group on Memo or Long Binary ( ).

3120 Can't group on fields selected with '*' ( ).

3121 Can't group on fields selected with '*'.

3122 ' ' not part of aggregate function or grouping.

3123 Can't use '*' in crosstab query.

3124 Can't input from internal report query ( ).

3125 ' ' isn't a valid name.

3126 Invalid bracketing of name ' '.

3127 INSERT INTO statement contains unknown field name ' '.

3128 Must specify tables to delete from.

3129 Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE',

'SELECT', or 'UPDATE'.

3130 Syntax error in DELETE statement.

3131 Syntax error in FROM clause.

3132 Syntax error in GROUP BY clause.

3133 Syntax error in HAVING clause.

3134 Syntax error in INSERT statement.

3135 Syntax error in JOIN operation.

3136 Syntax error in LEVEL clause.

3137 Missing semicolon (;) at end of SQL statement.

3138 Syntax error in ORDER BY clause.

3139 Syntax error in PARAMETER clause.

3140 Syntax error in PROCEDURE clause.

3141 Syntax error in SELECT statement.

3142 Characters found after end of SQL statement.

3143 Syntax error in TRANSFORM statement.

3144 Syntax error in UPDATE statement.

3145 Syntax error in WHERE clause.

3146 ODBC--call failed.

3147 ODBC--data buffer overflow.

3148 ODBC--connection failed.

3149 ODBC--incorrect DLL.

3150 ODBC--missing DLL.

3151 ODBC--connection to ' ' failed.

3152 ODBC--incorrect driver version ' 1'; expected version '|2'.

3153 ODBC--incorrect server version ' 1'; expected version '|2'.

3154 ODBC--couldn't find DLL ' '.

3155 ODBC--insert failed.

3156 ODBC--delete failed.

3157 ODBC--update failed.

3158 Couldn't save record; currently locked by another user.

3159 Not a valid bookmark.

3160 Table isn't open.

3161 Couldn't decrypt file.

3162 Null is invalid.

3163 Couldn't insert or paste; data too long for field.

3164 Couldn't update field.

3165 Couldn't open .INF file.

3166 Missing memo file.

3167 Record is deleted.

3168 Invalid .INF file.

3169 Illegal type in expression.

3170 Couldn't find installable ISAM.

3171 Couldn't find net path or user name.

3172 Couldn't open PARADOX.NET.

3173 Couldn't open table 'MSysAccounts' in SYSTEM.MDA.

3174 Couldn't open table 'MSysGroups' in SYSTEM.MDA.

3175 Date is out of range or is in an invalid format.

3176 Couldn't open file ' '.

3177 Not a valid table name.

3178 Out of memory.

3179 Encountered unexpected end of file.

3180 Couldn't write to file ' '.

3181 Invalid range.

3182 Invalid file format.

3183 Not enough space on temporary disk.

3184 Couldn't execute query; couldn't find linked table.

3185 SELECT INTO remote database tried to produce too many fields.

3186 Couldn't save; currently locked by user ' 2' on machine '|1'.

3187 Couldn't read; currently locked by user ' 2' on machine '|1'.

3188 Couldn't update; currently locked by another session on this machine.

3189 Table ' 1' is exclusively locked by user '|3' on machine '|2'.

3190 Too many fields defined.

3191 Can't define field more than once.

3192 Couldn't find output table ' '.

3193 (unknown)

3194 (unknown)

3195 (expression)

3196 Couldn't use ' '; database already in use.

3197 Data has changed; operation stopped.

3198 Couldn't start session.  Too many sessions already active.

3199 Couldn't find reference.

3200 Can't delete or change record. Since related records exist in table ' ',

referential integrity rules would be violated.

3201 Can't add or change record.  Referential integrity rules require a related

record in table ' '.

3202 Couldn't save; currently locked by another user.

3203 Can't specify subquery in expression ( ).

3204 Database already exists.

3205 Too many crosstab column headers ( ).

3206 Can't create a relationship between a field and itself.

3207 Operation not supported on Paradox table with no primary key.

3208 Invalid Deleted entry in [dBASE ISAM] section in INI file.

3209 Invalid Stats entry in [dBASE ISAM] section in INI file.

3210 Connect string too long.

3211 Couldn't lock table ' '; currently in use.

3212 Couldn't lock table ' 1'; currently in use by user '|3' on machine '|2'.

3213 Invalid Date entry in [dBASE ISAM] section in INI file.

3214 Invalid Mark entry in [dBASE ISAM] section in INI file.

3215 Too many Btrieve tasks.

3216 Parameter ' ' specified where a table name is required.

3217 Parameter ' ' specified where a database name is required.

3218 Couldn't update; currently locked.

3219 Can't perform operation; it is illegal.

3220 Wrong Paradox sort sequence.

3221 Invalid entries in [Btrieve ISAM] section in WIN.INI.

3222 Query can't contain a Database parameter.

3223 ' ' isn't a valid parameter name.

3224 Btrieve--data dictionary is corrupted.

3225 Encountered record locking deadlock while performing Btrieve

operation.

3226 Errors encountered while using the Btrieve DLL.

3227 Invalid Century entry in [dBASE ISAM] section in INI file.

3228 Invalid CollatingSequence entry in [Paradox ISAM] section in INI file.

3229 Btrieve--can't change field.

3230 Out-of-date Paradox lock file.

3231 ODBC--field would be too long; data truncated.

3232 ODBC--couldn't create table.

3233 ODBC--incorrect driver version.

3234 ODBC--remote query timeout expired.

3235 ODBC--data type not supported on server.

3236 ODBC--encountered unexpected Null value.

3237 ODBC--unexpected type.

3238 ODBC--data out of range.

3239 Too many active users.

3240 Btrieve--missing WBTRCALL.DLL.

3241 Btrieve--out of resources.

3242 Invalid reference in SELECT statement.

3243 None of the import field names match fields in the appended table.

3244 Can't import password-protected spreadsheet.

3245 Couldn't parse field names from first row of import table.

3246 Operation not supported in transactions.

3247 ODBC--linked table definition has changed.

3248 Invalid NetworkAccess entry in INI file.

3249 Invalid PageTimeout entry in INI file.

3250 Couldn't build key.

3251 Feature not available.

3252 Illegal reentrancy during query execution.

3254 ODBC--Can't lock all records.

3255 ODBC--Can't change connect string parameter.

3256 Index file not found.

3257 Syntax error in WITH OWNERACCESS OPTION declaration.

3258 Query contains ambiguous (outer) joins.

3259 Invalid field data type.

3260 Couldn't update; currently locked by user ' 2' on machine '|1'.

3261

3262

3263 Invalid database object.

3264 No fields defined - cannot append table.

3265 Name not found in this collection.

3266 Append illegal - Field is part of a TableDefs collection.

3267 Property value only valid when Field is part of a recordset.

3268 Cannot set the property of an object which is part of a Database object.

3269 Append illegal - Index is part of a TableDefs collection.

3270 Property not found.

3271 Invalid property value.

3272 Object is not an array.

3273 Method not applicable for this object.

3274 External table isn't in the expected format.

3275 Unexpected error from external database driver ( ).

3276 Invalid database ID.

3277 Can't have more than 10 fields in an index.

3278 Database engine has not been initialized.

3279 Database engine has already been initialized.

3280 Can't delete a field that is part of an index.

3281 Can't delete an index that is used in a relationship.

3282 Can't perform operation on a nontable.

3283 Primary key already exists.

3284 Index already exists.

3285 Invalid index definition.

3286 Invalid type for Memo field.

3287 Can't create index on Memo field or Long Binary field.

3288 Invalid ODBC driver.

3289 Paradox: No primary index.

3290 Syntax error.

3291 Syntax error in CREATE TABLE statement.

3292 Syntax error in CREATE INDEX statement.

3293 Syntax error in column definition.

3294 Syntax error in ALTER TABLE statement.

3295 Syntax error in DROP INDEX statement.

3296 Syntax error in DROP statement.

3297 Operation not supported in version 1.1

3298 Couldn't import. No records found or all records contained errors.

3299 Several tables exist with that name; please specify owner, as in

'owner.table'.


Exe limit

LUOKKA: coding

Date: 10/16/94 (09:18)              Number: 23152 of 23204 (Refer# NONE)

From: BMOROZE@WORLD.STD.COM

Subj: Re: Really BIG VB project

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: When is a project getting 'too big for VB' ? - I'm talking about the

: number of forms, compiled .EXE size, module size, God knows what other

: hidden limitations.

: How do you go about splitting the project into separate EXEs and what's

: the way to integrate them in the final product ?

: We have about 50 forms and 25 code modules, there is about as much to

: come and we fear we might soon reach VB's limits. We have a lot of MDI

: children as well, which I understand can cause problems in splitting the

: project.

The biggest problem I have found in working on large business analysis/

database applications in VB is the global symbol table 64K limit.  In my

experience, when the EXE reaches about 2.5 MB you are probably nearing

this limitation, given a reasonable length for constants and functions/subs.

I have a fairly fast application that reads a VB project file-by-file (as long it's

all saved as text!) and spits out a good approximation (within a few hundred

bytes) of the global symbol table space used, taking into account the fact

that duplicate names only count once, etc.  Exactly what goes into the global

symbol table isn't precisely defined, as you realize if you've ever played with

projects right near the edge of the boundary.  Let me know if you'd like this

app.

    Ben Moroze (bmoroze@world.std.com)


Exe making

LUOKKA: coding

2. "Clean up" your project before final EXE compilation.

   When you are ready to compile your VB project into your 'finished'

   EXE, be sure to save the project files, exit VB, restart Windows,

   run VB, load your project and go straight to compiling. Otherwise,

   your EXE may be larger in file size than necessary due to 'garbage'

   getting included in the EXE. For some reason, VB does not fully

   clean up all of the previously used variables or objects that you

   may have been playing with while developing your program so these

   get included in your EXE even though they aren't used. Other VB

   users have even advocated saving all the project files as ASCII,

   then loading the ASCII files before compiling to further "clean up"

   the resulting EXE file.


Exe size

LUOKKA: coding

Date: 05-17-95 (16:27)              Number: 333828 of 334332 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: How to keep a VB program SMALL ?

     Here's a great tip that applies if you are using a video driver that

     supports more than 16 colors:  switch to a 16 color video driver and

     redo any pictures/bitmaps (including those on buttons) in your app,

     then recompile (and I use the term loosely) your EXE.  This is due to

     the fact that even if your bitmap only has 16 colors in it, it will be

     saved as if it contains the highest number of colors you driver will

     support. I've seen this chop large percentages off of an EXE's size

     (and of course load time, etc).

 Rick_Treese@resgate.rch.gs.com


Exe size

LUOKKA: speed

Date: 11/10/94 (10:02)              Number: 26545 of 26597 (Refer# NONE)

From: BRAHENE@MAPLE.CIRCA.UFL.EDU

Subj: Should I break up a large *.exe VB app?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I have a large VB 3.0 app, about 900k. In trying to improve performance,

I broke off a large module, about 200k, so that now I have 2 *.exe file.

One is 730k and the other is 200k. When needed, the first one would

shell out to the 2nd one, but making the 2nd one modal to it so that

the user is fooled into thinking that there is one unified app running.

After doing this, I found that the performance when running the 1st

app alone improved by about 20%. The improvement is found not just when

loading the app, but also running it.

My question is: Why is there an improvement?

 Suppose I did not break up the file, and thus have one 900k file.

If in the course of running my app, I do not make use of any functions

found in the last 200k and that this 200k is modular, ie. the code is

in *.frms and *.bas which are never touched at all. Then shouldn't

Windows swap this 200k to disk until it is needed. If so, wouldn't this

have the same effect as breaking up the file into 2 pieces and shelling

out.

By breaking it up, I am basically forcing Windows to leave the 200k

of code out of memory until I explicitly call for it. However, I

thought that by making my code modular, Windows would do this for

me. By "modular" I mean that the forms are not loaded and the subs and

functions in the *.bas files are never called. When they are called,

they are likely to be called altogether.

I was following the advice given in the knowledge base, but the imprvmnt

I got from breaking up the file seem to contradict that advice.

I would greatly appreciate any advice/explanation.

TDH


Exe/ide

LUOKKA: coding

Date: 10/19/94 (03:03)              Number: 23532 of 23637 (Refer# NONE)

From: PJS@IPAEDIN.WIN-UK.NET

Subj: Re: Two quick questions

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>1.  Is there anyway from within a VB app to tell that it is running

>    in the development environment (as opposed to running as an EXE)?

Paul Bonner in Visual Basic Utilities has a test for this:

Use GetModuleFileName and find out if it returns VB.EXE. If so then

you are in the VB DevEnv. The code is as follows:

VBEnv%=FindWindow("wndclass_desked_gsk", 0&)

If VBEnv% Then

  GW% = GetWindowWord(WinHand%, GWW_HINSTANCE)

  MF% = GetModuleFileName(GW%, OldText, 72)

  If InStr(OldText, "VB.EXE") Then OldParent% = VBEnv%

EndIf

Buy the book for more goodies like this!

--

Peter J Smith

Internet: pjs@ipaedin.win-uk.net


Exe/ide

LUOKKA: coding

Date: 11/29/94 (00:49)              Number: 139030 of 139045 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Development-Environment

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>> I would like to suppress some functions of my application

>> when it is not running in the development environment.

>> Can anybody help me to find out wether my program runs in

>> the IDE or as stand-alone exe-file?

>        Try the following code:

>Declare Function GetModuleHandle Lib "Kernel" (ByVal lpModuleName As

String)

>As Integer

>

>Function DebugPrg% (Dum)    ' sub will detect if prog runs in debug mode

>'Last rev. 7 May 94 by Giora Drachsler

>

>   EXE$ = "vb.exe"         ' see if dev sys is running

>    hModule% = GetModuleHandle(EXE$)

>

>    DebugPrg% = (hModule% <> 0)     ' set ret val

>

>End Function

Neat solution! But we have a couple of VB programs where we run the EXE

at

the same time as we are running the development environment too. So when

one of these programs sees the vb.exe running it thinks its in development

mode when it isn't. This might cause fun and games if a VB developer was

using your program and suddenly all these developer features became

available.

So based on the above code I think it would be better to check whether your

program is running as an exe

EXE$= app.EXEName & ".exe"

hModule% = GetModuleHandle(EXE$)

DebugPrg% = (hModule% =  0)

So thats the theory - if it doesn't work can someone let me know.....

Andy

ADUNN@farnboro01.datasci.co.uk


Exe/ide

LUOKKA: coding

Detecting If Your Program Is Running In The Integrated Developme

-----------------------------------------------------------------------------------------

It is often useful for a programmer to know if the program is running in the

Integrated Development Environment (IDE) instead of as a compiled

executable. This way, an error handling routine can stop the program if an

error occurs, rather than handling it, as would be necessary in the EXE

version.

This routine takes advantage of a pecularity of Visual Basic.  All Windows

programs must declare a window class for every window.  In VB, the window

class of all forms is always "ThunderForm".  However, the window class for

the hidden parent window is different if the program is in the IDE or if it is

compiled.

In the IDE, the class of the parent's window is "ThunderForm," just like all

other VB windows.  However, in the EXE, the class of the parent's window is

"ThunderRTForm." Therefore, this routine will get the window class of the

hidden parent window, and look for the string "RT" (which stands for

RunTime).  If found, the program is running as an EXE.

To declare the routines needed by InIDE(), place the following lines in the

declarations section of the module or form where you put InIDE:

Declare Function GetClassName% Lib "User" (ByVal hWnd%, ByVal

lpClassName$, ByVal nMaxCount%)

Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal

nIndex%)

' get window word constants

 Const GWW_HWNDPARENT = (-8)

Since there is some overhead with using InIDE, it may be a good idea to call

it once and set a global variable to the result.  Then have your program

check the global variable in the error handlers.  If you are opposed to the

use of globals, simply call InIDE() directly (the overhead is not great).

Sub Form_Load()

   ' note: declare gDebugMode in any module --> Global gDebugMode as

Integer

   gDebugMode = InIDE(Hwnd)

   If gDebugMode then

      debug.print "IDE detected"

   End If

End Sub

' ------------------------------------------------------------------------------------

'  ROUTINE: InIDE:BOOL,    Params( inhwnd InputOnly )

'  Purpose: to determine if the program is running in the Integrated

Development Environment

'  Description: Uses the class of the hidden parent window to determine if the

     program

'     is running in the IDE or is compiled into an EXE.

'  INPUT: inhwnd -- the window handle of the calling window

'  OUTPUT: return code is True if the program is running in the IDE, False if it

is      an EXE

' ------------------------------------------------------------------------------------

Function InIDE (ByVal inhwnd As Integer) As Integer

    Dim parent%, pclass$, nlen%

    parent% = GetWindowWord(inhwnd, GWW_HWNDPARENT)

    pclass$ = Space$(32)

    nlen% = GetClassName(parent%, pclass$, 31)

    pclass$ = Left$(pclass$, nlen%)

    If InStr(pclass$, "RT") Then

        InIDE = False

    Else

        InIDE = True

    End If

End Function

Tip Submitted By: A. Nicklas Malik


Exists

LUOKKA: files

Date: 07/01/94 (10:34)              Number: 10845 of 10897 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: File Exists command

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Arjen Broeze (arjen@shear.iaf.nl) wrote:

: Function FileExists(sFileName As String) As Integer

: Dim sResult As String

:     On Local Error Resume Next

:     sResult = Dir$(sFileName)

:     If Err Then

:         FileExists = False

Better still:

Take care of the case where Err <> 0 coming in because of an uncleared

error from a call routine which has an On Error Resume Next "trap."

gt


Exists

LUOKKA: files

Date: 07/28/94 (02:26)              Number: 13534 of 13548 (Refer# NONE)

From: HOAG@CPS.MSU.EDU

Subj: Re: How do I test whether a file exists??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Roger Nixon (rog@praxis.co.uk) wrote:

: A simple question.... I thought.

: Is it possible to test whether a file with a known name exists in a

: specified directory, without having to resort to opening the file and

: trapping an error if it's not there??

  i've always tested for the existance of a file

  using the DIR and DIR$ functions.

  for example:

 let found$ = DIR$ ("c:ÖmypathÖmyfile.abc")

 IF found$ = "" THEN 'the file was not found

    msgbox "File not found"

 ELSE 'the file was found

   msgbox "File found"

 END IF

  search for DIR or DIR$ under help for more info


Exists

LUOKKA: files

Date: 07/28/94 (13:24)              Number: 13591 of 13893 (Refer# NONE)

From: SKRESAL@MONDRIAN.CSUFRESNO.EDU, Shawn Kresal

Subj: Re: How do I test whether a file exists??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try using this "boolean" function to test whether a file exists.

Returns true if the file exists otherwise false.

So your code could call it as such:

 If FileExists("c: autoexec.bat") then msgbox "The file exists."

=============

Function FileExists (path$) As Integer

    x = FreeFile

    On Error Resume Next

    Open path$ For Input As x

    If Err = 0 Then

        FileExists = True

    Else

        FileExists = False

    End If

    Close x

End Function


Exists

LUOKKA: files

Date: 07/28/94 (18:39)              Number: 13615 of 13893 (Refer# NONE)

From: GR00+@ANDREW.CMU.EDU

Subj: Re: How do I test whether a file exists??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

This should do the trick if I recall correctly.  Read about Dir $  in the

Language Reference.

If Dir$(filePath$) = "" Then

 File Doesn't Exist

Else

 File Does Exist

End If

-----------------------------------------------------------------

Gavin M. Rush    Phone: (412) 268-6408


Exists

LUOKKA: files

Date: 08/02/94 (10:06)              Number: 14087 of 14165 (Refer# NONE)

From: GSBELL@AMOCO.COM

Subj: Re: All I want to do is find a file

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <CtMH5v.AFL@ucdavis.edu> piker@cs.ucdavis.edu (Scott Thomas

Piker) writes:

>I would like to simply check for the existence of a file

>in a specified directory as a part of a *very simple* network daemon.

>My problem is that if I use the open() command or other similar

>methods to detect whether the file is there or not, VB decides to

>directly notify the user if the file is not there!  It is necessary

>for me to catch the response before VB gives its error message to the

>user.  Any ideas how I do this?

Insert the following procedure into a VB module.

    Function FileExists(ByVal pstrFile As String) As Integer

        On Error Resume Next

        FileExists = (FileLen(pstrFile) > 0)

    End Function

And call it like this:

    If FileExists("C: AUTOEXEC.BAT") Then

        'code here

    End If

This could have been written as:

    Function FileExists(ByVal pstrFile As String) As Integer

        On Error Resume Next

        FileExists = Dir(pstrFile) <> "")

    End Function

But, if the calling procedure was, in turn, looping thru Dir entries, this

would reset the Dir() function.  You would have to use the second procedure

in Accces, cuz Access doesn't _currently_ support the FileLen function.

 Gordon Scott Bell


Exists

LUOKKA: files

Date: 08/08/94 (09:36)              Number: 14881 of 15159 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Check if file exists

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

To: plxtb@pln1.nott.ac.uk (Tim Brailsford)

>In article <31r2e7$k75@pluto.njcc.com> khansen@pluto.njcc.com (Ken

Hansen) writes:

>>: How do I go about checking for existence of a file?

>>I was wondering the same thing - From my reading of the Access

>>manuals, it seems that if you attempt to open a file for input

>>and it does not exist an error is generated - how do you trap

>>that error though...

>The following function works OK for me!

>Function FileExists (fname As String) As Integer

>    On Error Resume Next

>    fnum = FreeFile

>    Open fname For Input As fnum

>    Close fnum

>    If Err = 53 Then FileExists = False Else FileExists = True

>End Function

Another options is:

Function FileExists% (ByVal strFileName$)

On Error GoTo ErrHand

  If strFileName = "" Then

      FileExists = False

  Else

      FileExists = Dir$(strFileName) <> ""

  End If

  Exit Function

  ErrHand:

      FileExists = False

      Resume Next

End Function

__________

                           Bradley S. Murray


Exists

LUOKKA: files

Date: 08/21/94 (11:56)              Number: 16476 of 16483 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Overwriting existing

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 08-19-94 ADDAM@AOL.COM  wrote:

A>Yes, the LEN(DIR$(FileName)) check is a good way to do it. Thanks a

A>lot!

Warning:  This method will fail if the file is open!

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                                m_rubin@tatertot.com


Exists

LUOKKA: files

Date: 09/25/94 (22:27)              Number: 20710 of 20785 (Refer# NONE)

From: ZONDAG@XS1.XS4ALL.NL

Subj: Re: Test for file exist??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Write a function FileIsThere

which attempts to OPEN the file f for READ access.

Function FileIsThere( Byval f : String) : Integer

 Dim fnum as integer    ' need this variable

 fnum=FreeFile()     ' find a free filenum.

 On Error Goto ThisWentWrong   ' set error handler

 OPEN f For Input as fnum   ' the key statement

 ' if the program gets here, the file exists.

 CLOSE fnum     ' close the file

 FileIsThere=True    ' assign result

 Exit Function     ' that's it

ThisWentWrong:      ' error handler

 On Error Goto 0     ' cancel error handler

 FileIsThere = False    ' assign result

 Exit Function     ' that's all

End Function      ' end statement

You will have to refine the error conditions somewhat (e.g. an error also

occurs if the file DOES exist but is already open, etc) but I hope you

got the general picture.

-------------

Met vriendelijke groet (Dutch form of greeting)

Jan-Evert Zondag

email: zondag@xs4all.nl


Exists

LUOKKA: files

Date: 09/26/94 (18:37)              Number: 20795 of 20918 (Refer# NONE)

From: BUD@GARNET.MSEN.COM

Subj: Re: Test for file exist??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Function FileExists (Filename As String)

    Dim DateTime$

    'Set Default

    FileExists = True

    'Set up error handler

    On Error Resume Next

    'Attempt to grab date and time

    DateTime$ = FileDateTime(Filename)

    'Process errors

    Select Case Err

       Case 53     'File Does Not Exist

         FileExists = False

         Err = 0

       Case Else

         If Err <> 0 Then

               MsgBox "Error Number: " & Err & Chr$(10) & Chr$(13) & " "

                                   & Error, MB_OK, "Error"

               End

         End If

      End Select

End Function


Exists

LUOKKA: files

Date: 09/26/94 (21:03)              Number: 20811 of 20918 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Test for file exist??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Write a function FileIsThere

>which attempts to OPEN the file f for READ access.

>Function FileIsThere( Byval f : String) : Integer

> Dim fnum as integer    ' need this variable

> fnum=FreeFile()     ' find a free filenum.

> On Error Goto ThisWentWrong   ' set error handler

> OPEN f For Input as fnum   ' the key statement

> ' if the program gets here, the file exists.

> CLOSE fnum     ' close the file

> FileIsThere=True    ' assign result

> Exit Function     ' that's it

>ThisWentWrong:      ' error handler

> On Error Goto 0     ' cancel error handler

> FileIsThere = False    ' assign result

> Exit Function     ' that's all

>End Function      ' end statement

>

>You will have to refine the error conditions somewhat (e.g. an error also

>occurs if the file DOES exist but is already open, etc) but I hope you

>got the general picture.

That is why you should use the Dir$() function.

Function FileExists% (ByVal strFileName$)

On Local Error GoTo ErrHand

    If strFileName = "" Then

        FileExists = False

    Else

        FileExists = Dir$(strFileName) <> ""

    End If

    Exit Function

ErrHand:

    FileExists = False

    Resume Next

End Function

_________

                           Bradley S. Murray


FAQs

LUOKKA: internet

21690 (122+)  rcrauch@hobbes.cca.rockwell.com  19.06.95  20:08

"Richard C. Rauch": "Re: FAQ - please point me to it"

TXT and .HLP files are available...

..on the Web,

     http://www.apexsc.com/vb/ftp/vbfaq/

..or, via anonymous ftp:

     ftp://ftp.apexsc.com/pub/cgvb/vbfaq/

Hope this helps,

Rich


Files > 64kB

LUOKKA: files

Date: 11/24/94 (13:43)              Number: 135884 of 136670 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Files >64K, how do I read them?!?!

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

How to Read a Large File into Memory by Calling API Functions

Article ID: Q100513

 ---------------------------------------------------------------------

The information in this article applies to:

 - The Visual Basic programming system for Windows, versions 2.0 and 3.0

 - Microsoft Windows, version 3.1 or higher

 ---------------------------------------------------------------------

SUMMARY

=======

This article demonstrates how to call Windows API functions to read a file

of any size (including a huge file such as a bitmap) into memory and how

to write a block of memory (including a huge memory block) out to a file.

The information in this article applies only to Windows version 3.1 or

higher because it uses Windows API functions introduced in Windows

version 3.1.

MORE INFORMATION

================

Perform the following steps to create a sample program that demonstrates

how to read a large file into memory and write that memory back out to

a file:

1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)

   if Visual Basic is already running. Form1 is created by default.

2. From the File menu, choose New Module (ALT, F, M). Module1 is created.

3. Add the following code to the general-declarations section of Module1:

   ' OpenFile() Structure

   Type OFSTRUCT

      cBytes As String * 1

      fFixedDisk As String * 1

      nErrCode As Integer

      reserved As String * 4

      szPathName As String * 128

   End Type

   ' OpenFile() Flags

   Global Const OF_READ = &H0

   Global Const OF_WRITE = &H1

   Global Const OF_READWRITE = &H2

   Global Const OF_SHARE_COMPAT = &H0

   Global Const OF_SHARE_EXCLUSIVE = &H10

   Global Const OF_SHARE_DENY_WRITE = &H20

   Global Const OF_SHARE_DENY_READ = &H30

   Global Const OF_SHARE_DENY_NONE = &H40

   Global Const OF_PARSE = &H100

   Global Const OF_DELETE = &H200

   Global Const OF_VERIFY = &H400

   Global Const OF_CANCEL = &H800

   Global Const OF_CREATE = &H1000

   Global Const OF_PROMPT = &H2000

   Global Const OF_EXIST = &H4000

   Global Const OF_REOPEN = &H8000

   ' Enter each of the following Declare statements on one, single line:

   Declare Function OpenFile Lib "Kernel" (ByVal lpFilename As

      String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Integer) As

Integer

   Declare Function hRead Lib "kernel" Alias "_hread" (ByVal hFile As

      Integer, lpMem As Any, ByVal lSize As Long) As Long

   Declare Function hWrite Lib "Kernel" Alias "_hwrite" (ByVal hFile

      As Integer, lpMem As Any, ByVal lSize As Long) As Long

   Declare Function lClose Lib "kernel" Alias "_lclose" (ByVal hFile

      As Integer) As Integer

   ' Global Memory Flags

   Global Const GMEM_FIXED = &H0

   Global Const GMEM_MOVEABLE = &H2

   Global Const GMEM_NOCOMPACT = &H10

   Global Const GMEM_NODISCARD = &H20

   Global Const GMEM_ZEROINIT = &H40

   Global Const GMEM_MODIFY = &H80

   Global Const GMEM_DISCARDABLE = &H100

   Global Const GMEM_NOT_BANKED = &H1000

   Global Const GMEM_SHARE = &H2000

   Global Const GMEM_DDESHARE = &H2000

   Global Const GMEM_NOTIFY = &H4000

   Global Const GMEM_LOWER = GMEM_NOT_BANKED

   Global Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)

   Global Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)

   ' Enter each of the following Declare statements on one, single line:

   Declare Function GlobalAlloc Lib "Kernel" (ByVal wFlags As

       Integer, ByVal dwBytes As Long) As Integer

   Declare Function GlobalLock Lib "Kernel" (ByVal hMem As Integer)

       As Long

   Declare Function GlobalUnlock Lib "Kernel" (ByVal hMem As Integer)

       As Integer

   Declare Function GlobalFree Lib "Kernel" (ByVal hMem As Integer)

       As Integer

4. Add the following code to the Form_Load event procedure of Form1:

   Sub Form_Load ()

      Dim InpFile As String

      Dim OutFile As String

      Dim hFile As Integer

      Dim fileStruct As OFSTRUCT

      Dim FSize As Long

      Dim BytesRead As Long

      Dim BytesWritten As Long

      Dim hMem As Integer

      Dim lpMem As Long

      Dim r As Integer

      Me.Show

      'Insert the name of a bitmap or file that is greater than 64K.

      '256COLOR.BMP is less than 5K in size, however, the routine

      'below still demonstrates how to read and write a file of any

      'size

      InpFile = "C: WINDOWS 256COLOR.BMP"

      OutFile = "C: WINDOWS TEST.BMP"

      'Get the size of the file to be read

      FSize = FileLen(InpFile)

      If FSize > 0 Then

         'Allocate a block of memory equal to the size of the input file.

         hMem = GlobalAlloc(GPTR, FSize)

         If hMem <> 0 Then

            lpMem = GlobalLock(hMem)

            'Read the file into memory

            hFile = OpenFile(InpFile, fileStruct, OF_READ Or

                             OF_SHARE_DENY_NONE)

            BytesRead = hRead(hFile, ByVal lpMem, FSize)

            MsgBox Format(BytesRead) & " bytes read into memory"

            r = lClose(hFile)

            'Write the file back to disk to verify the file was

            'read correctly

            hFile = OpenFile(OutFile, fileStruct, OF_CREATE Or

                             OF_WRITE Or OF_SHARE_DENY_NONE)

            BytesWritten = hWrite(hFile, ByVal lpMem, FSize)

            MsgBox Format(BytesWritten) & " bytes written to output file"

            r = lClose(hFile)

            'Free resources

            r = GlobalUnlock(hMem)

            r = GlobalFree(hMem)

         Else

             MsgBox "Not enough memory to store file"

         End If

      Else

         MsgBox "Input file is zero bytes in length"

      End If

      End

   End Sub

5. From the Run menu, choose Start (ALT, R, S) or press F5 to run the

   program. Form1 will be displayed and the program will end.

6. Use PaintBrush or some other bitmap editor to open C: WINDOWS

TEST.BMP

   to verify that it is the same bitmap as C: WINDOWS 256COLOR.BMP.

Additional reference words: 2.00 3.00

KBCategory: kbprg kbcode

KBSubcategory: APrgWindow

Copyright 1993 Microsoft Corporation. All rights reserved.


Files associating

LUOKKA: files

Date: 04-21-95 (11:43)              Number: 299751 of 301771 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Associating a file to its app

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Bill Smith (bilsmith@uoguelph.ca) wrote:

:    I have created an app where the user can save his session to

: disk, and retrieve it later for further editing etc.  I would like the

: user to be able to invoke the app just by dblclicking on the file's icon,

: and the file will automatically be loaded, bypassing the main menu, just

: like Word, Excel, VB etc.

: Does anyone know how to implement this?  I assume there are API's

: to associate a file to an application, I just need to know what they

PSS ID Number: Q119281

Article last modified on 10-03-1994

1.00 2.00 3.00

WINDOWS

----------------------------------------------------------------------

The information in this article applies to:

 - Standard and Professional Editions of Microsoft Visual Basic for

   Windows, versions 2.0 and 3.0

 - Microsoft Visual Basic Programming System for Windows, version 1.0

----------------------------------------------------------------------

SUMMARY

=======

If your application makes use of data files and processes command-line

arguments, you may want to associate the extension of your application's

data file with your executable program name by modifying the REG.DAT file.

MORE INFORMATION

================

You can make modifications to the REG.DAT file by calling the

RegCreateKey&

and RegSetValue& application programming interface (API) functions.

Step-by-Step Example

--------------------

1. Start Visual Basic for Windows. If Visual Basic is already running,

   choose New Project from the File menu (ALT+F, N). Form1 is created by

   default.

2. Add the following code to the general declarations section of Form1,

   taking care to enter each Declare statement on one single line:

   Declare Function RegCreateKey& Lib "SHELL.DLL" (ByVal hKey&, ByVal

   lpszSubKey$, lphKey&)

   Declare Function RegSetValue& Lib "SHELL.DLL" (ByVal hKey&, ByVal

   lpszSubKey$, ByVal fdwType&, ByVal lpszValue$, ByVal dwLength&)

   ' Return codes from Registration functions.

   Const ERROR_SUCCESS = 0&

   Const ERROR_BADDB = 1&

   Const ERROR_BADKEY = 2&

   Const ERROR_CANTOPEN = 3&

   Const ERROR_CANTREAD = 4&

   Const ERROR_CANTWRITE = 5&

   Const ERROR_OUTOFMEMORY = 6&

   Const ERROR_INVALID_PARAMETER = 7&

   Const ERROR_ACCESS_DENIED = 8&

   Const HKEY_CLASSES_ROOT = 1

   Const MAX_PATH = 256&

   Const REG_SZ = 1

3. Place the following code in the Form_Click event of Form1:

   Sub Form_Click ()

     Dim sKeyName As String   'Holds Key Name in registry.

     Dim sKeyValue As String  'Holds Key Value in registry.

     Dim ret&                 'Holds error status if any from API calls.

     Dim lphKey&              'Holds created key handle from RegCreateKey.

     'This creates a Root entry called "FooApp".

     sKeyName = "FooApp"

     sKeyValue = "Foo Bar Application"

     ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)

     ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)

     'This creates a Root entry called .BAR associated with "FooApp".

     sKeyName = ".bar"

     sKeyValue = "FooApp"

     ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)

     ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)

     'This sets the command line for "FooApp".

     sKeyName = "FooApp"

     sKeyValue = "c:ÖfoodirÖfoobar.exe %1"

     ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)

     ret& = RegSetValue&(lphKey&, "shellÖopenÖcommand", REG_SZ,

sKeyValue,

    MAX_PATH)

   End Sub

4. Press ALT+F, V to save the project. Then press F5 to run the

   program. Click once on the form and exit the application.

5. If you are running Windows version 3.1 or Windows for Workgroups,

choose

   Run from the File menu (Alt+F, R) in Program Manager and then type

   "REGEDIT /V" (without the quotes) to run the registration database

   editor. When examining the REG.DAT, you will see the following entries:

      .bar = FooApp

      FooApp = Foo Bar Application

        ö

         -- Shell

              ö

               -- open

                    ö

                     -- command = c:ÖfoodirÖfoobar.exe %1

   If you are running Windows NT, choose File Run (Alt+F, R) on the Program

   Manager and type "REGEDT32". This will run the registration database

   editor for Windows NT. The .BAR and FooApp entries can be found under

   the HKEY_CLASSES_ROOT on your local machine.

Additional reference words: 1.00 2.00 3.00

KBCategory: kbprg kbcode

KBSubcategory: PrgOther


Files binary

LUOKKA: files

Date: 06/25/94 (12:27)              Number: 10481 of 10514 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Read/Write Binary files in VB?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

"Andrew Mayo" <andrew@geac.co.nz> writes:

>Rather than flame off about the merits of ascii vs binary files, I decided

>to do a little research. I was surprised to find that VB didn't seem to

>store binary files like you'd think. At all. I tried this little test program:-

>Sub Command1_Click ()

>Dim x, y, z As Integer

Well you've already made the same mistake as the original poster, so I'll

get out the scissors...

 snip

>and I found that the resulting file, instead of being 6 bytes long as you

>might think, was actually 10 bytes long and looked like this:-

>02 00 01 00 02 00 02 00-03 00

Just what I expected! The x and y _variants_ are prefixed by their

two-byte type indicator (02 00 = 2 = Integer), after which comes the

value (x = 01 00 = 1, y = 02 00 = 2), then comes the _integer_ z value

(03 00 = 3). What's alarming about that?

Admittedly the notation of the Dim statement is a little tricky in this

area, but that doesn't make it a bug. Read on...

>(courtesy of that wonderful DOS utility, DEBUG).

>However, x y and z are retrieved correctly from the file.

>Intrigued, I then changed the DIM statement to define x,y,z as long.

>The file was still recorded strangely.

No. You changed z to long, and left x and y as _variant_.

>I then changed the type definition to be explicit for each variable i.e x&,y&

>and z& and the file was then recorded correctly at 12 bytes.

Hooray! Clever lad! We knew you could do it.

>I changed them to x%,y% and z% and lo!, the file was also recorded

>correctly i.e 6 bytes.

>So, your problem stems from what appears to be a stupid bug in VB. Of

>course,

There. He said it!

>I assume your binary file was created by a DOS C program. If it was created

>under Unix, then an int is probably 4 bytes i.e a VB long. Also the byte-

>ordering may differ if the creating platform was non-DOS.

Not necessarily. That depends very much on the architecture of the

machine, the phase of the moon, and the developers biorhythms.

>I might also mention C structure alignment issues i.e padding but you most

>likely know about all these things.

Well, that at least makes sense.

>So if you change your type declarations to be explicit, I'd say your program

>will work.

Which is just what most of the rest of us said.

>A comment to those people who reply to requests for help with things like '

>boy I'm glad I'm not... etc'. In the real world we have to handle these

>problems. It doesn't imply we think its necessarily good design but if you

>already have a binary file it doesn't help to hear that sort of thing. Also,

>binary files are *very* efficient. They are not necessarily an evil thing.

Well said, apart from the bit about 'problems'. Who was it that first said

"There are no problems, merely insurmountable opportunities"?

--

Luke Webber


Files binary in C

LUOKKA: files

Date: 06/25/94 (17:18)              Number: 10511 of 10514 (Refer# NONE)

From: FBUNN@NETCOM.COM

Subj: Re: Read/Write Binary files in VB?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

        *** Monday June 27 1994, 15:14 in Ft Lauderdale, FL ***

reynen william edward (reynen@ux1.cso.uiuc.edu) wrote:

: In VB I'm trying to read a binary file I created from a C program.  The C

: program writes the data in the following way:

:            struct st

:                int x;

:                char buf 30 ;

:                int y,z;

Try this:

Type IntermediateType

   x_msb as string*1

   x_lsb as string*1

   buf as string*30

   y_msb as string*1

   y_lsb as string*1

   z_msb as string*1

   z_lsb as string*1

End Type

Type MyType

   x as Integer

   buf as string*30

   y as Integer

   z as Integer

End Type

Dim t1 as IntermediateType

Dim Dest as MyType

Get #1,,t1

Dest.x = asc(t1.x_msb)*256 + asc(t1.x_lsb) 'Convert to VB integer

Dest.y = asc(t1.y_msb)*256 + asc(t1.y_lsb)

Dest.z = asc(t1.z_msb)*256 + asc(t1.z_lsb)

Dest.buf = Trim$(t1.buf)

Basically, the idea is to treat *everyting* as fixed length strings,

since this is the only sigle byte data structure available in

VB.

Next concept is to create an "intermediate" VB structure to hold the data

in a format that is easily accessed one byte at a time. Defining this

structure also has the side benefit of making the 'C' to 'VB' changes

easy to track should the 'C' structure format change.

-Fred

P.S. I haven't tested this. The msb and lsb values above may need to be

     swapped!


Files create temp

LUOKKA: files

Date: 11/28/94 (18:03)              Number: 28239 of 28251 (Refer# NONE)

From: GETJ@PHOENIX.NET

Subj: Re: What is a good method for creating a .tmp filename?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Hi, the subject says it, I see these wonderfully mysterious .tmp files

>like ~hs2637v.tmp , aside from using the date or time, is there some elegant

>way to create these?

One way is to use the GetTempFileName function in Windows.

Here's the definition from the VB Windows API stuff:

Declare Function GetTempFileName Lib "Kernel"

 (ByVal cDriveLetter as Integer,

 ByVal lpPrefixString As String,

 ByVal wUnique As Integer,

 ByVal lpTempFileName As String) As Integer

Note that it all has to be on one line.


Files howto kill

LUOKKA: files

Date: 09/16/94 (17:32)              Number: 19705 of 19727 (Refer# NONE)

From: MIKE@CHARNOCK.DEMON.CO.UK

Subj: Re: How can I KILL files without checking to see if they exi

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>How can I tell VB to ignore the file not found error and just go on deleting

>the rest of the files in my list??

Try

ON ERROR RESUME NEXT

KILL <filespec>

ON ERROR GOTO 0


Files open w/o ch.dat

LUOKKA: files

Date: 04-07-95 (03:12)              Number: 286984 of 287834 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Open a file w/o changing date

Check the file date before you open the file using eDateTime, set the

system date and time to match that date just before closing the file, then

set the back to the correct date.

------------------------------------------------------------------------

Chuck Stuart - Mesquite TX USA


Files random access

LUOKKA: files

23837 (56+)  royfran@statcan.ca  05.07.95  12:52

Francois Roy: "Re: Random access files"

STEVE HALL (steve.hall@almac.co.uk) wrote:

: This works fine for files containing a small number or records, but how

: do you locate one record in a large file without processing all other

: records? I can't find any information relating to this. In my experience

: with COBOL random access files work in a different manner to my

: understanding of Visual Basic. An indexed file can have an element

: within it that is a unique key, a field can be set to the desired key

: (for example, a person's name) and a read command will locate the record

: that has a key field matching the field without any reference to the

: other record on the file; there is no need to access any other records

: on the file.

 Short of using the database features, you could do what I do in one of

my apps: define a key field in your RANDOM file, make sure the file is

sorted on that field, and use a binary search to locate your record.  It

takes only a second or two for my program to locate a record in a file

of 500,000+ records.  I'm able to do this because the "database" is

distributed on CD-Rom (i.e. it doesn't continuously change and users

only need to retrieve, not modify, the records).

 A binary search works as follows:

 * Retrieve the record that is at the mid-point of the file

 * Check the key field.  If greater, then retrieve the record half-way

   between the record you just got and the end of the file, otherwise

   retrieve the record half-way between the beginning and mid-point.

 * Keep doing this, halving the "search area" each time, until you

   either find the record with the key you want, or you only have a

   couple of records left (which you check for a match to determine

   if the record you want exists at all)


Files reading a Byte

LUOKKA: files

Date: 08/03/94 (00:29)              Number: 14175 of 14279 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: Reading a Byte from a Binary File

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

 dim Byte as String * 1

 Get #1,,Byte

 debug.Print "Byte value is"; Asc(Byte)

Of course, reading a binary file a single byte at a time is not very

efficient.  but if you wanted to read a structure...

 Type MyStruct

  Byte as String * 1

  Others as ...

 End Type

 dim MyVar as MyStruct

 Get #1, , MyVar

will work.

Stephen Johnston


Files sarjaportista

LUOKKA: files

(300/315)

Area: Ohjelmointi

From: Matti Kohtala  To: Jarmo Vaitinen

Date: 27 Mar 95  13:14:20

Subj: VB3 tiedoston siirto

 -=> Quoting Jarmo Vaitinen to All <=-

 JV> Onko kellään tietoa valmiista palikasta joka voisi lukea

 JV> sarjaportista ascii dataa jonka pituus on > 100k.Tiedosto(data) on

 JV> tarkoitus tallentaa levylle  vasta kun se on kokonaisuudessaan luettu.

 JV> Neuvo miten voisi vb:llä lukea esim. suoraan muistiin, auttaisi myös

 Tässä on yksi esimerkki VB:llä API:a hyödyntäen. Sillä saa 386:ssa max.

 16MB miinus 64kB ja 286:ssa 1MB miinus 16kB:n bufferin.

Type OFSTRUCT

  cBytes As String * 1

  fFixedDisk As String * 1

  nErrCode As Integer

  reserved As String * 4

  szPathName As String * 128

End Type

'Declaret tietty kokonaan samalle riville

Declare Function GlobalCompact& Lib "Kernel" (ByVal dwMinFree&)

Declare Function GlobalSize& Lib "Kernel" (ByVal hMem%)

Declare Function GlobalAlloc% Lib "Kernel" (ByVal wFlags%, ByVal

dwBytes&)

Declare Function GlobalFree% Lib "Kernel" (ByVal hMem%)

Declare Function GlobalLock& Lib "Kernel" (ByVal hMem%)

Declare Function GlobalUnLock% Lib "Kernel" (ByVal hMem%)

Declare Function OpenFile% Lib "Kernel" (ByVal lpFilename$,

   lpReOpenBuff As OFSTRUCT, ByVal wStyle%)

Declare Function hWrite& Lib "Kernel" Alias "_hwrite" (ByVal hFile%,

   ByVal lpMem As Any, ByVal lSize&)

Declare Function lClose% Lib "kernel" Alias "_lclose" (ByVal hFile%)

Declare Sub hmemcpy Lib "Kernel" (ByVal hpvDest As Any,

   ByVal hpvSource As Any, ByVal cbCopy&)

Global Const GMEM_FIXED = &H0

Global Const GMEM_ZEROINIT = &H40

Global Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)

Global Const OF_WRITE = &H1

Global Const OF_SHARE_DENY_NONE = &H40

Global Const OF_CREATE = &H1000

Global BufSize As Long              'Bufferiin tallennettujen tavujen määrä

Global BufInitSize As Long          'Bufferille varattu muistimäärä

Dim hglb As Integer                 'Bufferin handle

Dim lpvBufStart As Long             'Osoite bufferin alkuun

Dim lpvBufEnd As Long               'Osoite ekaan vapaaseen muistipaikkaan

Function BufAdd (chrs$) As Integer

  BufAdd = 0

  chrsLen& = Len(chrs$)

  If (BufSize + chrsLen&) > BufInitSize Then

    If BufSize = BufInitSize Then Exit Function

    chrsLen& = BufInitSize - BufSize

  End If

  hmemcpy lpvBufEnd, chrs$, chrsLen&

  kerroin%=((lpvBufEnd And &HFFFF&) + chrsLen&) > &HFFFF&

  lpvBufEnd = lpvBufEnd -  kerroin% * &H80000

  lpvBufEnd = (lpvBufEnd And &HFFFF0000) + ((lpvBufEnd + chrsLen&) And

&HFFFF&)

  BufSize = BufSize + chrsLen&

  BufAdd = chrsLen&

End Function

Sub BufFree ()

  ret% = GlobalUnLock(hglb)

  ret% = GlobalFree(hglb)

End Sub

Sub BufInit (cbAlloc&)

  If GlobalCompact(cbAlloc&) < cbAlloc& Then Exit Sub

  hglb = GlobalAlloc(GPTR, cbAlloc&)

  lpvBufStart = GlobalLock(hglb)

  BufInitSize = GlobalSize(hglb)

  lpvBufEnd = lpvBufStart

  BufSize = 0

End Sub

Function BufSave (fname$) As Long

  Dim fileStruct As OFSTRUCT

  MousePointer = 11

  OpenFlags% = OF_CREATE Or OF_WRITE Or OF_SHARE_DENY_NONE

  hFile% = OpenFile(fname$, fileStruct, OpenFlags%)

  BufSave = hWrite(hFile%, lpvBufStart&, BufSize)

  ret% = lClose(hFile%)

  MousePointer = 0

End Function

  BufInit:n jälkeen voi tarkistaa muuttujasta BufInitSize onnistuiko

  halutun kokoisen bufferin luonti. Funktio BufAdd:n paluuarvo on

  bufferiin lisättyjen tavujen määrä. BufSave:n paluuarvo on tiedostoon

  tallennettujen tavujen määrä.

  Bufferiin lisäys kannattaa tehdä useamman tavun mittaisina stringeinä,

  mikäli mahdollista, niin funktiokutsut vähenevät ja homma nopeutuu.

  Tätä ei sitten ole paljoa testailtu, mutta tuntuisi toimivan hyvin

  ainakin "normaali tilanteissa".

___ Blue Wave/QWK v2.12

(Ohjelmointi: 300)   Replies: 301

(301/315)

Area: Ohjelmointi

From: Matti Kohtala  To: Matti Kohtala

Date: 27 Mar 95  14:41:39

Subj: VB3 tiedoston siirto

 -=> Quoting Matti Kohtala to Jarmo Vaitinen <=-

 Pari pientä korjausta tuohon tuli heti mieleen:

    - Vakiot eivät tarvitse olla globaaleja, ellei tarvi niitä muualla

    - BufInit:ssä rivi "BufSize = 0" ensimmäiseksi riviksi

___ Blue Wave/QWK v2.12

(Ohjelmointi: 301)   Replies: 306

(307/315)

Area: Ohjelmointi

From: Matti Kohtala  To: Jarmo Vaitinen

Date: 02 Apr 95  00:20:46

Subj: Re: VB3 tiedoston siirto

 -=> Quoting Jarmo Vaitinen to Matti Kohtala <=-

 JV> Kiitoksia, tarttee kokeilla mien toimii.

 Tutkailin tuota systeemiä tässä vielä lisää ja en ainakaan havainnut

 mitään suurempia bugeja, mutta BufFree aliohjelmaan on syytä lisätä

 muuttujien nollaus ettei muistin vapautuksen jälkeen väitetä bufferin

 koon olevan jotain muuta kuin nolla tai ettei "osoittimet" osoita jo

 vapautettuun muistialueeseen.

 Eli BufFree aliohjelman tulisi olla esim. näin:

 Sub BufFree ()

   BufInitSize = 0&

   BufSize = 0&

   lpvBufEnd = 0&

   lpvBufStart = 0&

   ret% = GlobalUnLock(hglb)

   ret% = GlobalFree(hglb)

   hglb = 0

 End Sub

___ Blue Wave/QWK v2.12

(Ohjelmointi: 307)


Files subdirs

LUOKKA: files

Date: 07/30/94 (17:17)              Number: 13883 of 13893 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: Problem with "Dir$" command?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The code below works. I took it from the Windows Help but tweaked it a

bit because it returned files and dirs. The source of the problem

turned out to be the position of the brackets in the line

If (GetAttr(Path$ & DirName$) And ATTR_DIRECTORY) = ATTR_DIRECTORY

Then

The AND comparison wasn't working properly as a result. Anyway, here

goes:

'Put this in your declarations:

Const ATTR_DIRECTORY = 16

'Now make this sub:

Sub FindSubDirs (Path$)

    Dim Count, D(), I, DirName$  ' Declare variables.

    DirName$ = Dir$(Path$, ATTR_DIRECTORY) ' Get first directory name.

    frmScanMain!Label3.Caption = "Now scanning " & Path$

    'Iterate through PATH, caching all subdirectories in D()

    Do While DirName$ <> ""

        If DirName$ <> "." And DirName$ <> ".." Then

            If (GetAttr(Path$ & DirName$) And ATTR_DIRECTORY) =

                  ATTR_DIRECTORY Then

                If (Count Mod 10) = 0 Then

                    ReDim Preserve D(Count + 10)    ' Resize the array.

                End If

                Count = Count + 1   ' Increment counter.

                D(Count) = DirName$

            End If

        End If

        DirName$ = Dir   ' Get another directory name.

    Loop

    ' Now recursively iterate through each cached subdirectory.

    For I = 1 To Count

        frmScanMain!lstFileNames.AddItem Path & D(I)   ' Put name in list box.

        DoEvents

        FindSubDirs Path & D(I) & " "

    Next I

End Sub

'Call it from anywhere like this (the "C: " is just an example)

FindSubDirs "C: "

Ian Piper


Files Txt import

LUOKKA: files

Date: 09/09/94 (03:18)              Number: 18791 of 18922 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: HELP:Text File Import TOO Slow!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If you open the file for input or binary you can also try this:

    hFile = FreeFile

    Open "SOMEFILE.TXT" For Binary As #hFile

    Ds.AppendChunk(Input$(LOF(hFile), hFile))

    Close hFile

I haven't tried it so I don't really know if it works. It ought to work

and is much faster than reading the file line by line.

--

Arjen Broeze                                   Telephone: (+31)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13

                                                          7533 VR Enschede, NL


Find app.title

LUOKKA: VBgen

Date: 11/20/94 (11:11)              Number: 132882 of 132997 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Reading Win App TitleBar

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>     I have WordPerfect running in the background and I need to either read

>     the title bar so I can issue the APPACTIVATE function or get VB to set

>     the focus so WP will be the active application.  I don't know how to

>     do either. I have looked the WIN API help file and can't find anything

>     that looks relevant.

What you have to do is search for a substring of the title. The below code

is intended to find a child window of an application by name, but I think if

you pass it the Windows Desktop window handle, (GetDesktopWindow)  it

will work for finding WP. The Windows API are declared as described in

Appleman.

Gary

====

Function FindChildWindow (hParent As Integer, Wtitle As String, matchtype

As

  Integer) As Integer

' FindWindow() returns an hWnd to a child window of the

' given hWnd. The child window is designated by it's

' window title. The routine can match either the exact

' title, or the first part of the title, or a substring

' of the title.

Dim hWnd As Integer

hWnd = GetWindow(hParent, GW_CHILD)    ' Get the first window

Select Case matchtype

    Case EXACTSTR

        Do

            If Wtitle = GetWindowTitle(hWnd) Then

                FindChildWindow = hWnd

                Exit Function

            End If

            hWnd = GetWindow(hWnd, GW_HWNDNEXT)

        Loop While hWnd <> 0

    Case BEGINSTR

        Do

            If Wtitle = Left$(GetWindowTitle(hWnd), Len(Wtitle)) Then

                FindChildWindow = hWnd

                Exit Function

            End If

            hWnd = GetWindow(hWnd, GW_HWNDNEXT)

        Loop While hWnd <> 0

    Case SUBSTR

        Do

            If InStr(1, GetWindowTitle(hWnd), Wtitle, 1) <> 0 Then

                FindChildWindow = hWnd

                Exit Function

            End If

            hWnd = GetWindow(hWnd, GW_HWNDNEXT)

        Loop While hWnd <> 0

    Case Else

        FindChildWindow = 0

End Select

FindChildWindow = 0     ' Oops, no window found

End Function

Function GetWindowTitle (hWnd As Integer) As String

' This function accepts a window handle and returns

' a VB string containing the title of the window.

Dim tbuf As String

Dim tlen As Integer

Const TBUFLEN = 255

tbuf = String$(TBUFLEN + 1, 0)

tlen = GetWindowText(hWnd, tbuf, TBUFLEN)

tbuf = Left$(tbuf, tlen)

GetWindowTitle = tbuf

End Function

garyfe@cyberspace.com


Find strings

LUOKKA: ListBox

Date: 07/23/94 (22:12)              Number: 12985 of 12986 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: finding item in sorted list box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here is the code I use:

Declare Function OSSendMessage Lib "User" Alias "SendMessage" (ByVal

hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam

As String) As Long

Const WM_USER = &H400

Const LB_FINDSTRINGEXACT = (WM_USER + 35) ' finds exact matching

item in a list box - not case sensitive

Const CB_FINDSTRINGEXACT = (WM_USER + 24)

Function SearchComboBox (Combo As ComboBox, ByVal Item As String) As

Integer

    ' returns the position of an item in a Combo box, returns

    ' -1 if the item is not present.  Not case sensitive.

    SearchComboBox = OSSendMessage(Combo.hWnd,

LB_FINDSTRINGEXACT, 0, ByVal Item)

End Function

Function SearchListBox (List As ListBox, ByVal Item As String) As Integer

    ' returns the position of an item in a list box, returns

    ' -1 if the item is not present.  Not case sensitive.

    SearchListBox = OSSendMessage(List.hWnd, LB_FINDSTRINGEXACT, 0,

       ByVal Item)

End Function

That should be fairly self explanatory...

Stephen


Find strings

LUOKKA: ListBox

Date: 07/26/94 (00:52)              Number: 13148 of 13258 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: member of list box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Once again I will say use the functions provided in the Kernel to do searches

in list boxes.  There fast, they're already written, and they are very easy

to use.  Look at previous posts on how to do this, or search the Win 3.1 API

help files for "SendMessage" and "LB_FINDSTRINGEXACT" for more

information.

You're wasting your time writing your own routines to do searches.  Who

knows, and who cares how the Win 3.1 functions work internally, but you

can almost gaurantee that they will run faster than interpreted p-code even if

you implement an amazingly efficent binary tree search or some sort of hash

search function.

Stephen Johnston

P.S. Using SendMessage(...LB_FINDSTRINGEXACT) is waaaay faster than

the basic forward search code in Bill's earlier post.


Find strings CboBox

LUOKKA: ListBox

Date: 09/09/94 (17:52)              Number: 18868 of 18922 (Refer# NONE)

From: BALDRICK@QUAY.IE

Subj: Re: Searching a combo box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

to find the string,

iRes=sendmessagebystring(combo1.hwnd,CB_FINDSTRING,-1,SearchStr)

where sendmessagebystring is declared as an alias of sendmessage

Declare Function sendmessagebystring& Lib "User" Alias "SendMessage"

(ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam$)

Declare Function sendmessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

ByVal wParam%, lParam As Any)

iRes will have the posn at which the searchstr lies or -1 if it can't find

it in the combo and then select it combo1.listindex=iRes

or

you could replace the CB_FINGSTRING with CB_SELECTSTRING which will

search and select the string if found I think.

You should check the winapi help that comes with vb for more info on the

above, or you might have a look at vbtips available from cica which has info

on this and other bits of useful code

--

Ger O'Rourke


Find strings CboBox

LUOKKA: ListBox

Date: 09/09/94 (21:49)              Number: 18899 of 18922 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Searching a combo box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Use the API - it's much faster.

Global Const WM_USER = &H400

Global Const LB_SELECTSTRING = WM_USER + 13

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

    ByVal wParam%, lParam As Any)

Sub cLstSet (lstBox As Control, ByVal strNewText$)

'Sets a list box to the given text if it is in the list

'If not it un-sets the list box

Static lRet&

    lRet = SendMessage(lstBox.hWnd, LB_SELECTSTRING, -1&, strNewText)

End Sub

__________

                           Bradley S. Murray


Find window

LUOKKA: VBgen

Date: 01/19/95 (14:33)              Number: 191293 of 191526 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Solution: Activate other appl. not knowing caption

     Several months ago I posted a question like 'how can I set focus to an

     application when I don't know the exact caption in its window'.

     I found the solution using gopher on MS KB and based on the

     information I wrote the function below which solved this problem.

     IT IS BASED ON DOCUMENT Q113475 IN Microsoft's Knowledge Base.

     The example there browses through all windows that are open (also child

     windows of childres) recursively.

     Function FindWinLike (WinText As String, ClassName As String) As

     Integer

     'Before: WinText is a window's caption and may include wildcards

     '        that are supported by the LIKE operator in VB

     '        ClassName is the excact application's class name.

     'After:  Returns a handle to the first window found that matches the

     '        search defined by WinText and ClassName.

     '        Returns 0 if no window was found.

     'Note:   You can use SetFocus() API function to set the focus to the

     '        returned window handle.

     Dim hwnd As Integer, sWindowText As String, sClassName As String

     Dim r As Integer

         'Handle to the desktop

         hwnd = GetDeskTopWindow()

         'Get first child of desktop

         hwnd = GetWindow(hwnd, GW_CHILD)

         Do Until hwnd = 0

             'Get the window text and class name:

             sWindowText = Space(255)

             r = GetWindowText(hwnd, sWindowText, 255)

             sWindowText = Left(sWindowText, r)

             sClassName = Space(255)

             r = GetClassName(hwnd, sClassName, 255)

             sClassName = Left(sClassName, r)

             'Check if the window matches the search parameters:

             If sWindowText Like WindowText And sClassName = Classname

Then

     'you could have Like also for the classname comparison

                 FindWindowLike = hwnd

                 Exit Function

             End If

             'Check next child of the desktop

             hwnd = GetWindow(hwnd, GW_HWNDNEXT)

        Loop

        FindWindowLike = 0

     End Function

        - Gudmundur Johannesson (gummi@tmh.is)


Find window

LUOKKA: VBgen

4348 (2+)  johnmc@blkbox.com  21.05.95  23:03

John McKnight: "Re: chaning app Title Bar problem"

In article <ve7mxg.34.000A3365@wimsey.com>, ve7mxg@wimsey.com says...

>I am trying to launch Netscape with a different URL (like buttons

>on a menu system) each time either using the vb shell() function or the

>AppActivate command.

>The problem is that the Title Bar of Netscape changes according to the

>"home page" that it's currently on.  Therefore, I can't use AppActivate

>to send commands to Netscape because I cannot predict what the Title Bar

>is going to be.

>

>I noticed that I can launch Netscape only once and I can't trap for the

>error by using "PrevInstance".

>

>1.  Is there a way of identifying that Netscape is already running and

>activating it even though you don't know what the Title Bar is?

>2.  Is there a way of automatically shutting down Netscape once you've

>found out that it's running in the background?

This is some sample code from the Microsoft Developers Network CD.  It

accepts wild cards when searching for an application by its caption.  I

have not seen Netscape, but if the word Netscape (or any other word) is

always in the caption bar, you can find it by calling the function

provided with a command like "Netscape*" or "*Netscape*", etc.  It

returns an array of matches.  Hope this helps.

PSS ID Number: Q113475

Article last modified on 04-27-1994

1.00 2.00 3.00

WINDOWS

---------------------------------------------------------------------

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows Programming Systems, versions 2.0 and 3.0

- Microsoft Visual Basic for Windows Programming System, version 1.0

---------------------------------------------------------------------

SUMMARY

=======

The Visual Basic AppActivate command can only activate a window if you

know the exact window title. Similarly, the Windows FindWindow function

can only find a window handle if you know the exact window title.

This article demonstrates how to search for a window that has a title that

is like the title you specify -- but not an exact match. The sample code

searches through the available windows, comparing the window titles to a

pattern by using the Visual Basic Like operator. You can also use the

sample code to find a window based on its class name or ID. This can be

extremely helpful when you need to send keystrokes to other Applications.

MORE INFORMATION

================

FindWindowLike Function

-----------------------

The sample code provides a find window function named FindWindowLike.

FindWindowLike does a recursive search for windows matching the

description you give it. After completing the search, FindWindow returns the

number of windows it found that match your description. It also returns then

window handles in an array that you pass to it. Once you have a window

handle, you can call many Windows API functions to manipulate it. For

example, you could set the focus to it, or move it. The example in this article

shows how to set the focus. Parameters Passed to FindWindowLike Function

--------------------------------------------

The FindWindowLike function searches for windows based on the four

parameters you pass it:

 - The hWndStart parameter specifies the handle of the window you want to

   search under. For example, if you gave the handle to a Visual Basic

   form, FindWindowLike would search through all the controls on that form.

   If you pass 0 for hWndStart, FindWindowLike searches through all

   available windows.

 - The WindowText parameter specifies the pattern used to compare window

   text. The Title property of a Visual Basic Form is the same as the

   window text. The pattern is any string following the guidelines for

   the Visual Basic Like operator.

 - The ClassName parameter specifies a pattern used to compare a window

   class name. A window's class name identifies the type of window. You

  can find out a window's class name by using the utility SPY.EXE that comes

   with Microsoft Visual C/C++, or you can use the example given in the

   following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q112649

   TITLE     : How to Get a Window's Class Name and Other Attributes

   FindWindowLike uses the Visual Basic Like operator to when comparing

   class names.

 - The ID parameter specifies a specific child ID. This parameter is very

   useful for finding specific controls in a window. A window's ID can

  also be found by using SPY.EXE or the technique described in the following

   article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q112649

   TITLE     : How to Get a Window's Class Name and Other Attributes

   The ID parameter can be a decimal number or a hexadecimal string. If

  you use a hexadecimal string, prefix the hexadecimal number with &H. If

   you don't want to search for a specific ID, specify Null for the ID

   parameter. FindWindowLike Examples and Their Results

-----------------------------------------

Here are several example calls to FindWindowLike and the results it

should return:

1. r = FindWindowLike(hWnds(), 0, "*", "*", Null)

   Returns: All the available windows.

2. r = FindWindowLike(hWnds(), 0, "*Excel*", "*", Null)

   Returns: All the windows with "Excel" in the window text.

3. r = FindWindowLike(hWnds(), 0, "Microsoft Excel*", "XLMAIN", Null)

   Returns: All the windows having window text that begins with

"Microsoft

   Excel" and that contains class name "XLMAIN"

4. r = FindWindowLike(hWnds(), Form1.Hwnd, "*", "*", "&HA1")

   Returns: The child window of the Form1 window that has an ID of

   hexadecimal A1.

5. r = FindWindowLike(hWnds(), Form1.Hwnd, "*", "*", 2)

   Returns: The child window of the Form1 window that has an ID of 2.

Uses for FindWindowLike

-----------------------

The FindWindowLike function can be especially powerful when used in a

series of searches. For example, you can search once to find an open

instance of the PIF Editor that comes with Microsoft Windows. Then once

you have the handle to the PIF Editor window, you can search again for a

specific control's window handle by using the PIF Editor's window handle

and the ID of the control's window. Here is an example:

   r = FindWindowLike(hWnds(), 0, "PIF Editor*", "Pif", Null)

   ' Assuming the previous returned at least one handle

   r = FindWindowLike(hWnds(), hWnds(1), "*", "*", 103)

After you have the control's window handle, you can give it the focus and

send it keystrokes. In addition, there are a lot of other things you can

do once you have a window's handle.

The Sample Code

---------------

The sample code listed in the example below uses several Windows API

functions to accomplish what was described above. Here are the key ones

including descriptions of their uses:

 - GetDeskTopWindow gets the handle to the DeskTop window when 0 (zero)

   is passed as the hWndStart, so you can use it as a starting point for

   the recursive search.

 - GetWindow gets a window handle based on a relationship to another

   window handle, so you can use it to get child windows and their siblings.

 - GetWindowText gets the text of a window for comparison to the passed

   WindowText.

 - GetClassName gets a window's class name, which you can compare to the

   passed ClassName.

 - GetWindowWord gets information about a window. The sample code uses it

   to get the ID number of a window for comparison with the passed ID.

Step-by-Step Example

--------------------

1. Start a new Visual Basic project. Form1 is created by default.

2. Add three Text boxes (Text1, Text2, and Text3) to Form1.

3. Put the following code in the Form1 click event:

   Sub Form_Click ()

      ' Used to return window handles.

      Static hWnds() As Integer

      ' Find window with title "Form1":

      r = FindWindowLike(hWnds(), 0, "Form1", "*", Null)

      If r = 1 Then

         Print "Found "; Hex(hWnds(1))

         ' Find a child window of "Form1" with ID=2:

         ' Notice that the handle from the first search is used.

         r = FindWindowLike(hWnds(), hWnds(1), "*", "*", "&H2")

         If r = 1 Then

            Print "Found child "; Hex(hWnds(1))

            Print "Setting focus to child ..."

            ' Set the focus to the child window with ID=2:

            r = SetFocusAPI(hWnds(1))

         ElseIf r > 1 Then

            ' This should not happen.

            Print "Found more than one child ID=2"

         Else

            Print "Did not find child ID=2"

         End If

      ElseIf r > 1 Then

         Print "Found "; r; " Windows"

      End If

   End Sub

4. Add a new module to the project.

5. Put the following code in the new module:

   Option Explicit

   ' The following Declares and constants were taken from WIN30API.TXT

   ' that ships with the Visual Basic Professional Edition.

   ' Enter each of the following Declare statements on one, single line:

   Declare Function SetFocusAPI Lib "User" Alias "SetFocus"

      (ByVal hwnd As Integer) As Integer

   Declare Function GetDeskTopWindow Lib "User" () As Integer

   Declare Function GetWindow Lib "User" (ByVal hwnd As Integer,

      ByVal wCmd As Integer) As Integer

   Declare Function GetWindowText Lib "User" (ByVal hwnd As Integer,

      ByVal lpString As String, ByVal aint As Integer) As Integer

   Declare Function GetClassName Lib "User" (ByVal hwnd As Integer,

      ByVal lpClassName As String, ByVal nMaxCount As Integer) As Integer

   Declare Function GetParent Lib "User" (ByVal hwnd As Integer) As

Integer

   Declare Function GetWindowWord Lib "User" (ByVal hwnd As Integer,

      ByVal nIndex As Integer) As Integer

   Global Const GW_HWNDNEXT = 2

   Global Const GW_CHILD = 5

   Global Const GWW_ID = (-12)

'-----------------------------------------------------------------------

   'FindWindowLike

   ' - Finds the window handles of the windows matching the specified

   '   parameters

   '

   'hwndArray()

   ' - An integer array used to return the window handles

   '

   'hWndStart

   ' - The handle of the window to search under.

   ' - The routine searches through all of this window's children and

their

   '   children recursively.

   ' - If hWndStart = 0 then the routine searches through all windows.

   '

   'WindowText

   ' - The pattern used with the Like operator to compare window's text.

   '

   'ClassName

   ' - The pattern used with the Like operator to compare window's class

   '   name.

   '

   'ID

   ' - A child ID number used to identify a window.

   ' - Can be a decimal number or a hex string.

   ' - Prefix hex strings with "&H" or an error will occur.

   ' - To ignore the ID pass the Visual Basic Null function.

   '

   'Returns

   ' - The number of windows that matched the parameters.

   ' - Also returns the window handles in hWndArray()

   '

'----------------------------------------------------------------------

   ' Enter the following two lines as one, single line:

   Function FindWindowLike (hWndArray() As Integer, ByVal hWndStart As

      Integer, WindowText As String, Classname As String, ID) As Integer

   Dim hwnd As Integer

   Dim sWindowText As String

   Dim sClassname As String

   Dim sID

   Dim r As Integer

   ' Hold the level of recursion:

   Static level As Integer

   ' Hold the number of matching windows:

   Static iFound As Integer

   ' Initialize if necessary:

   If level = 0 Then

      iFound = 0

      ReDim hWndArray(0 To 0)

      If hWndStart = 0 Then hWndStart = GetDeskTopWindow()

   End If

   ' Increase recursion counter:

   level = level + 1

   ' Get first child window:

   hwnd = GetWindow(hWndStart, GW_CHILD)

   Do Until hwnd = 0

      DoEvents ' Not necessary

      ' Search children by recursion:

      r = FindWindowLike(hWndArray(), hwnd, WindowText, Classname, ID)

      ' Get the window text and class name:

      sWindowText = Space(255)

      r = GetWindowText(hwnd, sWindowText, 255)

      sWindowText = Left(sWindowText, r)

      sClassname = Space(255)

      r = GetClassName(hwnd, sClassname, 255)

      sClassname = Left(sClassname, r)

      ' If window is a child get the ID:

      If GetParent(hwnd) <> 0 Then

         r = GetWindowWord(hwnd, GWW_ID)

         sID = CLng("&H" & Hex)

      Else

         sID = Null

      End If

      ' Check that window matches the search parameters:

      If sWindowText Like WindowText And sClassname Like Classname Then

         If IsNull(ID) Then

            ' If find a match, increment counter and add handle to array:

            iFound = iFound + 1

            ReDim Preserve hWndArray(0 To iFound)

            hWndArray(iFound) = hwnd

         ElseIf Not IsNull(sID) Then

            If sID = CLng(ID) Then

               ' If find a match increment counter and add handle to

array:

               iFound = iFound + 1

               ReDim Preserve hWndArray(0 To iFound)

               hWndArray(iFound) = hwnd

            End If

         End If

      End If

      ' Get next child window:

      hwnd = GetWindow(hwnd, GW_HWNDNEXT)

   Loop

   ' Decrement recursion counter:

   level = level - 1

   ' Return the number of windows found:

   FindWindowLike = iFound

   End Function

6. Save the Project.

7. Run the code, and click the form.

First, the program searches for Form1. If Form1 is found, the program

searches Form1 for a control with an ID of 2. It should find one because

Visual Basic numbers the IDs as you add controls. With three text boxes

on Form1, one should have an ID of 2. After finding the control, the code

sets the focus to the window by calling SetFocusAPI.

If you set the focus to one of your controls before clicking the Form,

you

should see the focus shift, always to the same control, when you click

the

form.

REFERENCES

==========

Microsoft Knowledge Base articles Q72918, Q78001, and Q112649

The Windows SDK Help file that shipped with the Professional Editions of

Microsoft Visual Basic versions 2.O and 3.0 for Windows.

"Microsoft Windows Software Development Kit: Programmer's Reference"

"Programming Windows 3.1: The Microsoft Guide to Writing Applications for

Windows 3.1," Charles Petzold, Microsoft Press, 1992

"Visual Basic Programmer's Guide to the Windows API," Daniel Appleman,

Ziff-Davis Press, 1993

Additional reference words: 1.00 2.00 3.00

KBCategory:

KBSubcategory: APrgWindow


FindWindow

LUOKKA: API

Date: 10/19/94 (19:41)              Number: 23640 of 23771 (Refer# NONE)

From: PERL@DWRSUN4.UUCP

Subj: Re: SendKeys: How can I tell when app is responsive? (SUMMAR

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can use the FindWindow API function to see if there is a window with a

specific title:

Do

    If FindWindow(0&, WinText) Then Exit Do

    x% = DoEvents()

Loop

where WinText contains the title bar text to find.  You could check for the

main window's title and loop until you find it.

You could also check for the title of the "title window" that initially gets

displayed.  You could loop until that title was no longer available.

--------------------------------------------------

This is exactly what I needed and it is working perfectly.  In case you

want to use this concept, please note that the first argument to

FindWindow in the above example is a ZERO, not a letter "O".  I made

that mistake at first and had to write back to Kerry for

clarification.  Here is the declaration for the function:

    Declare Function FindWindow Lib "User" (ByVal lpClassName As Any,

 ByVal lpWindowName As Any) As Integer

Robert Perlberg

Dean Witter Reynolds Inc., New York

dwrsun4!perl@murphy.com -or- perl%dwrsun4@philabs.com


Flash eliminate

LUOKKA: forms

Date: 07/20/94 (22:32)              Number: 12638 of 12767 (Refer# NONE)

From: KEEPER@NETCOM.COM

Subj: Re: How to eliminate flash when want to show maximized form?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Put the 'WindowState=2' in the form's Load method.  Load gets called

before the form is displayed.

--

                                The Keeper

                             keeper@netcom.com


Font sizes

LUOKKA: ListBox

Date: 07/29/94 (00:32)              Number: 13670 of 13893 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Matching up font sizes...

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 28/7/94, Andrew Davison wrote to ALL: *****>>

AD>I'm trying to set up an app where there are two linked listboxes,

AD>One containing text, and one using the wingdings font for symbols.

AD>Unfortunately the only fonts size where I can get the two boxes to

AD>allign correctly is 6 point - just a little small for the application.

x% = SendMessage(list.hwnd, &H400 + 33, 0, 60)

where the last entry (60 in the example) is the height you want in pixels -

experiment

you will need a declaration in the general section of the form or in a bas code

module

Declare Function SendMessage Lib "USER" (ByVal hWnd%, ByVal wMsg%,

  ByVal wParam%, ByVal lParam As Any) As Integer

michael.cowan@almac.co.uk nottingham, england


Fonts detect size

LUOKKA: VBgen

Date: 04-17-95    Time: 02:14p     Number: 223

From: cstuart@metronet.com          Refer:

Subject: How to detect large f             0: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

In article <3mu32t$2dqb@acs4.acs.ucalgary.ca> weyer@acs.ucalgary.ca (K.

Udo Weyer) writes:

>  A program I'm working on needs to be able to detect whether

>Windows is using a large fonts or a small fonts driver.  I've

>already got some code in there that looks for "large font" in the

>display.drv part of boot.description in the system.ini file.

>This worked great with some drivers, but I've found that in some

>cases, "large font" is not written to system.ini when the

>graphics driver is changed.  Is there a fool-proof way of

>querying the system to find out if large fonts are being used?

Screen.TwipsPerPixelX = 12  'Large Font

Screen.TwipsPerPixelX = 15  'Small Font

------------------------------------------------------------------------

Chuck Stuart - Mesquite TX USA

http://www.apexsc.com/vb/ftp/coop/cstuart

ftp.apexsc.com/pub/cgvb/coop/cstuart


Fonts faster reading

LUOKKA: VBgen

Date: 12/30/94 (07:00)              Number: 31194 of 31236 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Q: Fast Reading of fontnames

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> > for a new application of mine, I have to read all available TrueType

> > fontnames in a VB list box.

> >

> > Some help would be welcome.

>

> I don't think there is a faster way. For a multi-media w/s that I run

> has about 250 fonts and the faster way seems to be using the command-

> dialog-box action property of 4 instead of the Printer.Fonts() collection.

There IS a faster way, but you can't do it from VB. There is an API call

called EnumFonts and EnumFaces that enumerate the fontnames and sizes.

These functions require a callback functions however that handle the

fontnames and sizes. The performance of these functions in a C-program is

very good.

If don't know what the performance would be if you put these functions in

a VBX or DLL and make them available to VB this way. If you're interested,

I could create a small VBX that handles these enumerations (something like

set the Action property to ENUM_FONTS and the VBX issues an event for

each fontname present). I don't know if this will be much quicker than using

the Screen.Fonts or Printer.Fonts collection, but I could give it a try.

Arjen

--

Arjen Broeze                                   Telephone: (+31)53-338666

arjen@shear.iaf.nl                             Address:   Gronausevoetpad 104


Fonts print samples

LUOKKA: VBgen

24982 (208+)  trevanion@servelan.co.uk  13.07.95  07:52

"Re: Can you extract font name from fontfile ?"

> 	I would appreciate any code that will show me how to

> extract the name of the font from the .ttf file into some string

> variable that I can then work with. It would be an additional

> plus if I could separately extract the font family name and the font name.

You have to learn how to unravel the ttf file itself - I beleive the

specification is on the net somewhere.

The following is an extract from a program I wrote in VB to print samples of

fonts without explicitly installing them. (It does temporarily install them

behind the scenes, but that's how Windows works). This extract shows

reading bits of the style data (bold, italic etc) and if you want to get other

items such as family name, font name, copyright data, etc, then the same

principles apply. The really tedious bit is working out how to do byte

swapping as the ttf format using the 'wrong' one!

Function GetStyle (S As String, ST1 As StyleData) As Integer

    Dim T1 As OffsetTable

    Dim i As Integer

    Dim D1 As DirectoryEntry

    Dim deHead As DirectoryEntry

    Dim deOS As DirectoryEntry

    Dim deName As DirectoryEntry

    Dim foundHead As Integer

    Dim foundOS As Integer

    Dim foundName As Integer

    Dim NT1 As NamingTable

    Dim numNames As Integer

    Dim NR1 As NameRecord

    Dim FullFontName As String

    Dim p As Long

    Dim HD1 As Header

    Dim OSData As OS2

    Open S For Binary Access Read As 1

    Get #1, 1, T1

    foundHead = False

    foundOS = False

    For i = 1 To SWAPW(T1.numOffsets)

        Get #1, , D1

        If D1.tag = tagHeadTable Then

            deHead = D1

            foundHead = True

        ElseIf D1.tag = tagOS2 Then

            deOS = D1

            foundOS = True

        ElseIf D1.tag = tagNamingTable Then

            deName = D1

            foundName = True

        End If

    Next

    If (Not foundHead) Or (Not foundOS) Or (Not foundName) Then

        Close #1

        MsgBox "Cannot find Tables"

        GetStyle = False

        Exit Function

    End If

    Get #1, SWAPL(deHead.offset) + 1, HD1

    ST1.stMac = SWAPW(HD1.macStyle)

    Get #1, SWAPL(deOS.offset) + 1, OSData

    ST1.stWt = SWAPW(OSData.usWeightClass)

    Get #1, SWAPL(deName.offset) + 1, NT1

    numNames = SWAPW(NT1.ntCount)

    For i = 1 To numNames

        Get #1, , NR1

        If (SWAPW(NR1.platformID) = 1) And (SWAPW(NR1.nameID) = 2) Then

            p = SWAPW(NR1.offset) + SWAPW(NT1.ntStringOffset)

            p = p + SWAPL(deName.offset) + 1

            Seek #1, p

            ST1.stSubFamily = Input$(SWAPW(NR1.length), #1)

            Exit For

        End If

    Next

    Close #1

    GetStyle = True

End Function


Fonts reading fonts

LUOKKA: VBgen

Date: 01/14/95 (06:53)              Number: 183746 of 184414 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: ReŽ2�: Screen Fonts

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Thanks for those who answered my questions, I've written a DLL to retrieve

all the fontnames and it is lightning fast now! ... just about 500-1000

times faster than the method I've previously described. VB gotta be doing

something very wrong in their own routine.....

Here is the code fragment that VB is extremely slow:

For i = 1 to Screen.Fontcount

        Form1.Fontname = Screen.Fonts(i)

Next

or

For i = 1 to Screen.Fontcount

        Form1.Fontname = anyfontname

Next

So the problem lies with assigning a fontname to a Form itself. However,

many times we need a hDC to call any APIs (e.g. GetTextMetrics,

EnumFontFamilies...) and we need a form to be the middle man. If you're

still using a Form as the middle man, get rid of it. The FORM is the

CULPRIT! Try something like this:

Dim tm As TEXTMETRIC

hDesktopWnd% = GetDesktopWindows()

hDesktopDC% = GetDC(hDesktopWnd%)

GetTextMetrics(hDesktopDC%, tm)

Dummy% = ReleaseDC(hDesktopWnd%, hDesktopDC%)

....

-

     /- Bok Nan Lo ------------------------- IA Corporation -----™

      1900 Powell Street, Suite 600        Tel: 510-4506871

      Emeryville, CA 94608-1840            Fax: 510-4507099

      CompuServe: 73523,2502               Internet: lo@lia.com


Fonts smaller

LUOKKA: VBgen

Date: 10/07/94 (01:23)              Number: 22097 of 22191 (Refer# NONE)

From: IAIN@TRACEFIN.DEMON.CO.UK

Subj: Re: Font size

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Could someone PLEASE tell me how to get font sizes below VB's 8.25 point

>size?

Change the font to SmallFonts. This allows point sizes down way beyond

readable!

--

Iain Cadman


Fonts TT

LUOKKA: VBgen

Date: 12/10/94 (20:27)              Number: 29425 of 29531 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re: Fonts

GS>Does anyone know how, in VB, to detect if "TrueType fonts only" has

GS>been selected in the Windows control panel?

- TrueType -

TTEnable=1

TTOnly=1   <<========

Use GetProfileInt(...) to read this. E.g.

Dim iTTOnly%, iTTEnable%

iTTOnly% = GetProfileInt("TrueType", "TTOnly", 0)

iTTEnable% = GetProfileInt("TrueType", "TTEnable", 0)

If (iTTEnable% > 0) And (iTTOnly% > 0) Then

  Debug.Print "Only TT fonts are enabled"

ElseIf iTTEnable% > 0 Then

  Debug.Print "No TT fonts enabled"

Else

  Debug.Print "All fonts are available"

End If

You can get the declare for GetProfileInt from the Win API Help file.

-----------------------------------------------------------------------

Regards,  Email: ian.carter@almac.co.uk

                 ian.carter@nildram.com

Ian C.    CIS: 100435,3040   Tel/Fax: (+44)(0)1909-773689


Form height?

LUOKKA: graphics

Date: 10/20/94 (16:44)              Number: 23756 of 23771 (Refer# NONE)

From: PAUL.DIRKS@CORPSOFT.COM

Subj: Re: Form Height?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

BW>> How many pixels is the title bar and menu? Since they are

BW>included in the > Height property, and not just the client area.

Theres an API call

Declare Sub GetWindowRect Lib "User" (ByVal Hwnd As Integer, lpRect As

RECT) with

Type RECT

    left As Integer

    top As Integer

    right As Integer

    bottom As Integer

End Type

      will work around this problem.

note.. return values are pixels...not twips.


Formatting a floppy

LUOKKA: VBgen

Date: 09/16/94 (11:33)              Number: 19559 of 19727 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Re: Formatting a floppy - any ideas?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Formatting A Floppy Disk

Below is code on how to format a floppy disk from Visual Basic for

Windows.

Type Rect

    Left As Integer

    Top As Integer

    Right As Integer

    Bottom As Integer

End Type

Declare Sub SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal

hWndInsertAfter As Integer, ByVal x As Integer, ByVal Y As Integer, ByVal

cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)

Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, lpRect As

Rect)

Declare Function IsWindow Lib "User" (ByVal hWnd As Integer) As Integer

Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String, ByVal

nCmdShow As Integer) As Integer

Declare Function SetActiveWindow Lib "User" (ByVal hWnd As Integer) As

Integer Declare Function GetActiveWindow Lib "User" () As Integer

Declare Function LockWindowUpdate Lib "User" (ByVal hwndLock As

Integer)

As Integer

Declare Function GetDesktopWindow Lib "User" () As Integer

Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal

lpWindowName As Any) As Integer

Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg

As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Integer

Const WM_COMMAND = &H111

Const WM_CLOSE = &H10

Dim wFlag%

Dim lpDlgRect As Rect

Dim lpDskRect As Rect

Const SWP_NOSIZE = &H1

Const SWP_NOZORDER = &H4

Sub CenterDialog (WinText As String)

   Do

    If FindWindow(0&, WinText) Then Exit Do

    x% = DoEvents()

   Loop

 wnd% = GetActiveWindow()

 Call GetWindowRect(wnd%, lpDlgRect)

 wdth% = lpDlgRect.Right - lpDlgRect.Left

 hght% = lpDlgRect.Bottom - lpDlgRect.Top

 Call GetWindowRect(GetDesktopWindow(), lpDskRect)

 Scrwdth% = lpDskRect.Right - lpDskRect.Left

 Scrhght% = lpDskRect.Bottom - lpDskRect.Top

 x% = (Scrwdth% - wdth%) / 2

 Y% = (Scrhght% - hght%) / 2

 Call SetWindowPos(wnd%, 0, x%, Y%, 0, 0, SWP_NOZORDER Or

SWP_NOSIZE)

End Sub

Sub FMFormat (F As Form)

    FMhWnd = FindWindow("WFS_Frame", 0&)

    If FMhWnd = 0 Then

    i% = WinExec("Winfile", 0)

    FMhWnd = FindWindow("WFS_Frame", 0&)

       If FMhWnd = 0 Then

           MsgBox "FileMan ain't home"

           Exit Sub

       End If

    wFlag = 1

    End If

    i% = LockWindowUpdate(GetDesktopWindow())

    i% = PostMessage(FMhWnd, WM_COMMAND, &HCB, 0)

    Call CenterDialog("Format Disk")

    i% = LockWindowUpdate(0)

    wnd% = GetActiveWindow()

    While IsWindow(wnd%)

    x = DoEvents()

    Wend

    x = DoEvents()

    If wFlag Then

    wFlag = 0

    i% = PostMessage(FMhWnd, WM_CLOSE, 0, 0)

    End If

    i% = SetActiveWindow(F.hWnd)

End Sub

Tip By: Woody Pewitt

Chuck

Mesquite TX


Forms

LUOKKA: printing

Date: 08/14/94 (18:41)              Number: 15560 of 15669 (Refer# NONE)

From: BKMA@CONNECTED.COM

Subj: Re: Print Form?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I've used the following since VB1 to speed up performance and appearance.

This is an outline:

For i=0 to Me.Controls.Count-1

     If Me.Controls(i).visible then

          If TypeOf(Me.Controls(i)) is TextBox Then

               Printer.CurrentX=Me.Controls(i).Left

               Printer.CurrentY=Me.Controls(i).Left

               Printer.FontName=Me.Controls(i).Fontname

               etc....

               If Me.Controls(i).BorderStyle Then

                    Printer_DrawBox(Me.Controls(i))

               Endif

              Printer.Print Me.Controls(i).Text

          Else If .... 'Different handling for different controls

          etc

          Endif

     Endif

Next i

Don't pixel your twips -- i.e. wathc out for SCALE.


Forms arrays of

LUOKKA: forms

Date: 05/08/94 (09:56)              Number: 5171 of 5181 (Refer# NONE)

From: GINS@SUNSPOT.COM

Subj: Re: Arrays of non-MDI forms?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Suppose a person wanted to have a program that had windows similar to

>visual basic's environment, but w/o using MDI.

>Is it possible to create an "array" of forms?  ie:

>Global Image(1 to 20) as New frmImage

>Then

>Image(1).Caption = "Some caption".

>This fails with:

>"Must specify index for Object array".

You've almost got it. You need to "Set" the instances of your global image

array. Try this"

Global Image(1 to 20) as form

Sub setforms ()

    For i = LBound(image) To UBound(image)

        Set image(i) = New frmImage

        image(i).Caption = "This is form # " & i

        image(i).Visible = False

    Next i

End Sub


Forms call 2. proc.

LUOKKA: forms

Date: 07/20/94 (02:18)              Number: 12525 of 12618 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Help! Questions on P

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 19/7/94, Mac@corhp1.demon.co.uk wrote to ALL: *****>>

MM>_@SUBJECT:Re: Help! Questions on Procedures!

MM>> Trying to call one form's procedure from another form. Is this possible?

On the original question.  Yes it can be done though it may depend on

exactly what you want to do.  But here are two possibilities (and from

previous echoes I'm sure there are others).

First, on form2 create a sub such as

Sub PopMessage (F$)

    MsgBox F$, 0, "Done!"

End Sub

and add a (hidden) label1.  In the change event put

Sub Label1_Change ()

    PopMessage (Label1)

End Sub

That's form 2

On form1 (the startup form) put a text box (text1) and a command button and

in the button's click event put

Sub Command1_Click ()

    form2.Label1 = text1

End Sub

Ok now run it and type something into the text box and then clcik the

command button.  Got it?

Secondly, use SendMessage to send a message triggering the procedure in

the other form eg

in form1:

Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)

if Keycode < 8 then

ReplyMessage 1

Select case keycode

Case 1: fire the procedure in this form

Case 2: fire another procedure in this form

etc

End Select

End Sub

then in the other form when you want to fire event 2

x%=SendMessage(form1.hwnd, &H100, 2, 0&)

Note that its ok to piggyback on KeyDown like this because there are no

keycodes below 8 that can triggered from the keyboard (I think!  8 is

backspace)

You will also need a couple of API declarations in a bas code module for

ReplyMessage (without which you will just hang and have to reboot) and

SendMessage.

michael.cowan@almac.co.uk nottingham, england


Forms create runtime

LUOKKA: forms

Date: 03-08-95 (21:42)              Number: 250244 of 251087 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Creating Forms as runtime

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

use following code to create new form at run time:

dim newformName as FORM

set newformName as New FORM1

FORM1 is an existing form you may have.

jim Chen


Forms drag from FileM

LUOKKA: forms

Date: 08/25/94 (19:05)              Number: 17024 of 17029 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Drag from File Manage

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 8/24/94 4:13 PM aaalavi@ingr.com (Ahmad Alavi) wrote:

>Is it possible to drag file(s) from File Manager and drop it on a

>VB form or control? I could not find any reference to this in

>VB manuals. Do you I need to obtain/develope VBX/DLL to do this?

(Declarations)

Type POINTAPI

    x As Integer

    y As Integer

End Type

Type Msg

    hWnd As Integer

    message As Integer

    wParam As Integer

    lParam As Long

    time As Long

    pt As POINTAPI

End Type

Global Const PM_REMOVE = &H1

Global Const PM_NOYIELD = &H2

Global Const WM_DROPFILES = 563

Declare Sub DragAcceptFiles Lib "shell" (ByVal hWnd%, ByVal faccept%)

Declare Function DragQueryFile% Lib "shell" (ByVal hDrop%, ByVal iFile%,

ByVal lpszFile$, ByVal cb%)

Declare Sub DragFinish Lib "shell" (ByVal hDrop%)

Declare Function PeekMessage% Lib "user" (lpMsg As Msg, ByVal hWnd%,

ByVal wMsgFilterMin%, ByVal wMsgFilterMax%, ByVal wRemoveMsg%)

Sub Form_Load

'Make a timer called tmrFileDrop that will run to catch the message

    DragAcceptFiles Me.hWnd, True

    tmrFileDrop.Enabled = True

End Sub

Sub tmrFileDrop_Timer ()

Static DropMessage As Msg

Static intCountFile%, iRet%

Static strDroppedFileName As String * 128

    'Turn off timer so that it doesn't try to run again

    tmrFileDrop.Enabled = False

    Do

        'Listen for drop event

        If PeekMessage(DropMessage, 0, WM_DROPFILES, WM_DROPFILES,

           PM_REMOVE Or PM_NOYIELD) Then

            'Get the number of files dropped and loop

            For intCountFile = 1 To DragQueryFile(DropMessage.wParam, -1,

               strDroppedFileName, Len(strDroppedFileName) - 1)

                'Get file name intCount-1 from File Manager

                iRet = DragQueryFile(DropMessage.wParam, intCountFile - 1,

                   strDroppedFileName, Len(strDroppedFileName) - 1)

                'Restore the window if it was an icon

                If Me.WindowState = 1 Then Me.WindowState = 0

                 'Here is where you put your code to open the file or do

                                        whatever with it

                'OpenFile strDroppedFileName

                strDroppedFileName = ""

            Next intCountFile

            'Finish the drag message

            DragFinish (DropMessage.wParam)

        End If

        DoEvents

    Loop While frmEdit.Visible

End Sub

__________

                           Bradley S. Murray


Forms frm within othe

LUOKKA: forms

Date: 03-27-95 (19:31)              Number: 272845 of 277779 (Refer# NONE)

 From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Q Can I make one form be another form's container ?

     Hi, fellows.  Can I use one form to act as another form's container w/

     using MDI form? All I need is to be able to put a smaller form inside

     of a normal, larger form, when I move the larger form, the smaller

     form would appear to stay inside and on top of the larger form and

     move with it.

--------------------------------------------------

     Well, the answer is a yes and a no.

     Using the SetParent function, you can set a form to be a parent of

     another form.  When you do this, all seems pretty cool, you can even

     move and resize the child form within the main form.  Controls of the

     child form behave normally.

     The problem occurs when your program ends, however, as it will produce

     a GPF every time.  One way around this is when your program ends, make

     sure you reset the child form's parent to NULL (i.e. the screen) with:

        r= SetParent(ChildForm.hWnd,0)

     Shouldn't we create a list for VBisms (strange, mysterious things VB

     does when you wouldn't expect it to)

        -- Rehan --


Forms hiding

LUOKKA: MDI

Date: 06/23/94 (01:32)              Number: 10067 of 10157 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: What's the trick to MDI???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

It is true that you can't hide MDI child forms in VB. (You also can't

show them modally.) But here is a kluge/hack which will allow you

to do what (I think) you want. (Hold your nose. After reading this

you may decide it's not THAT important after all...)

1. Create all your forms as non-MDI children. Group all controls in a

PictureBox (or something with an HWnd) on each form (so that the

"guts" of the form can be moved as a group). Load all these forms

ahead of time but keep them invisible.

2. Define an MDI parent form and an "empty" MDI child. Load the MDI

parent only. You now have an MDI parent, and several invisible non-MDI

forms loaded.

3. When you want to show one of your invisible, non-MDI forms as an MDI

child, load one of your blank MDI child forms. Then use the Windows API call

SetParent() to reparent the PictureBox from its original non-MDI form to the

empty MDI child. This is almost instantaneous. You will now have an MDI

child with all your controls in it.

4. All the VB event handling will work fine. You will have to think a little

about how you will deal with menus. You will probably want to find a

way to associate the MDI form with its non-MDI counterpart, so that you

can do step 5 (below):

5. When you unload the MDI child, remember to re-parent the PictureBox

back to the original form which owned it. If you simply destry the MDI

child without transferring its contents back to the original owner (or if

your unload the original owner) bad things can happen. So return the

world to the state in which you found it before destroying stuff.

This is a kluge. It's ugly.  It will add code and complexity to your project.

But it is the only way I know of to accomplish what you want. Hope this

helps.

Tim

--------------------------------------------------------------------

Tim Shea    Internet: shea@marcam.com    Phone (USA): (617) 965-0220


Forms hiding

LUOKKA: MDI

Date: 06/24/94 (00:05)              Number: 10182 of 10249 (Refer# NONE)

From: RDHALL@KOPTSS03.DELCOELECT.COM, Rakesh Dhall

Subj: Re: What's the trick to MDI???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If your MDI form is not going to cover the screen completely, you

could create all your child forms to reside in an area outside the MDI

viewing area.  You could also make the child forms small and make them

sit one on top of the other.

When you need a particular form, all you do is give it the right

values for top, left, height and width and it should appear in the

MDI viewing area.  When you are done with the form, return it back to

its smaller size and location.

I had to do something similar in one of my programs.  I had to display

up to 64 different forms in an MDI window.  I just resized every form

and adjusted its location when it was required, otherwise the forms

were hidden outside the viewing area.

This is not a very elegant solution but it works.

---

Rakesh Dhall 1-5489(8-322)              rdhall@koptss03.delcoelect.com

Engineering Systems Engineer            Electronic Data Systems

Powertrain Test Development Support     Delco Electronics Account


Forms hiding

LUOKKA: MDI

Date: 06/25/94 (19:03)              Number: 10516 of 10664 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: How to Hide MDI Children (was VB, or "What's the Point?")

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I while back someone posted a question asking how to hide

MDI children in VB. (This is not possible in VB.) I replied with

a long answer that described how to get around it by creating

an empty MDI child window, another invisible non-MDI window,

and reparenting the controls between the two.

Since then I realized there is a much more straightforward

way to do this (I did it once as part of a prototype I wrote).

I include the relevant code below. I lost track of the original

poster, so if you are him, please let me know if you get this.

Sub MDIChildHide (F As Form)

    Dim p As WINDOWPLACEMENT

    p.length = 22

    Dim success As Integer

    success = GetWindowPlacement(F.hWnd, p)

    p.ShowCmd = SW_HIDE

    success = SetWindowPlacement(F.hWnd, p)

End Sub

--------------------------------------------------------------------

Tim Shea    Internet: shea@marcam.com    Phone (USA): (617) 965-0220


Forms hiding

LUOKKA: MDI

Date: 09/25/94 (17:05)              Number: 20700 of 20702 (Refer# NONE)

From: SHENOY@IASTATE.EDU

Subj: Re: Hide MDI Child Window

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try this....move the child form out of the screen, remove scrollbars on the

MDI form, move it back to where you want to unhide it.

I haven't done this myself...Give it a shot and let us know if it works.


Forms hiding

LUOKKA: MDI

Date: 12/22/94 (00:45)              Number: 160027 of 163156 (Refer# NONE)

Subj: Re: VB: MDI childs

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

There was an article in VBPJ about this once. It essentialy involves

creating a big, borderless, mdi child that looks just like your mdiparent

background and using z-order to put the "hidden" form behind this one. You

have to resize the big form in your mdiform's resize event. The cute bit

was that you could use this method to create a "wallpaper" background for

your mdiform. I think I still have the issue if you need more info.

Scott Anderson


Forms hiding

LUOKKA: MDI

Date: 12/24/94 (06:23)              Number: 162563 of 163156 (Refer# NONE)

Subj: (none)

From: "Rob J. Welsby" <gblolrjw@IBMMAIL.COM>

     >The real problem is that MDI childs can't have their visible property

     >set to FALSE. I have tried many work arounds, for example sending

     >a WM_SETREDRAW to the MDI parent form before loading the

     >child and then use ZOrder to move it away. That didn't work.

     You can hide an MDI Child using the ShowWindow API call

     Global Const SW_HIDE = 0

     Global Const SW_MINIMIZE = 6

     Global Const SW_RESTORE = 9

     Global Const SW_SHOW = 5

     Global Const SW_SHOWMAXIMIZED = 3

     Global Const SW_SHOWMINNOACTIVE = 7

     Global Const SW_SHOWMINIMIZED = 2

     Global Const SW_SHOWNA = 8

     Global Const SW_SHOWNOACTIVE = 4

     Global Const SW_SHOWNORMAL = 1

     Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal

       nCmdShow As Integer) As Integer

     '~ to hide

     R = ShowWindow(FormtoHide.hWnd, SW_HIDE)

     '~ and to show (suprisingly)

     R = ShowWindow(FormtoHide.hWnd, SW_HIDE)

     Since this works so well, I can't understand why MDI child forms don't

     have a Visible property

     Rob Welsby

     Lloyd's of London

     gblolrjw@ibmmail.com


Forms limiting size

LUOKKA: forms

Date: 08/29/94 (11:16)              Number: 17681 of 17760 (Refer# NONE)

From: TAYLOR@SATURN.BROOKS.AF.MIL, William D. Taylor

Subj: Re: Limiting the size of a form?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can do it elegantly with MSGBLAST.VBX.  It's on ftp.microsoft.com and a

new and improved version is on cica (I think).  Here's some code (which took

me a great many hours to figure out, btw...)  The TYPE declarations must be

in a module, of course.  Thanx to Ed Staffin for the MessageBlaster VBX

which makes all of this (an a lot more) possible.  This code has been tested

with V1.0 and V2.1 of the VBX.

btw, you will use the MinTrackSize parameter for your needs.  Values are in

pixels.

The hard part (which turned out not to be so hard after all) was modifying the

structure that the MINMAXINFO message returns.  The secret is a

combination of lstrcpy, which returns a pointer to a variable when passed the

same variable as both parameters, and hmemcpy which just copies the VB

structure to where the API wants it.  Or something close to that, anyway.

If this was added to VBTips or the FAQ, it might save someone a lot of time,

as the method would be applicable to other API calls as well.  The CopyData

function (which is an artifact of other methods I tried) could easily be

eliminated to shorten the code.

-WDT

Type POINTAPI

    x As Integer

    y As Integer

End Type

Type MINMAXINFO

    Reserved As POINTAPI

    MaxSize As POINTAPI

    MaxPosition As POINTAPI

    MinTrackSize As POINTAPI

    MaxTrackSize As POINTAPI

End Type

Const WM_GETMINMAXINFO = &H24

Declare Function lstrcpy Lib "Kernel" (lpString1 As Any, lpString2 As Any) As

  Long

Declare Sub hmemcpy Lib "Kernel" (ByVal lpszString1 As Long, ByVal

lpszString2 As Long, ByVal cChars As Long)

Sub CopyData (ByVal ptrSrc As Long, ByVal ptrDest As Long, iSize As

Integer)

    hmemcpy ptrDest, ptrSrc, iSize

End Sub

Sub Form_Load ()

    MsgBlaster1.hWndTarget = Form1.hWnd

    MsgBlaster1.MsgList(0) = WM_GETMINMAXINFO

End Sub

Sub MsgBlaster1_Message (MsgVal As Integer, wParam As Integer, lParam

As Long, ReturnVal As Long)

    If MsgVal = WM_GETMINMAXINFO Then

        Dim mm As MINMAXINFO

        CopyData lParam, lstrcpy(mm, mm), Len(mm)

        mm.MaxTrackSize.X = 320

        mm.MaxTrackSize.Y = 200

        CopyData lstrcpy(mm, mm), lParam, Len(mm)

        ReturnVal = 0

   End If

End Sub


Forms loaded?

LUOKKA: forms

Date: 07-13-95 (21:46)              Number: 386792 of 388565 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Is MYFORM loaded ?

From: Blas Fernando Magaqa Gonzalez <bmagana@CID.INFOSEL.COM.MX>

Function IsLoaded(Caption$) As Integer

Dim I%, Found%

   For I =3D 0 To Forms.Count - 1

        If Forms(I).Caption =3D Caption$ Then Found% =3D True

   Next I

   IsLoaded=3D Found%

End Sub

  * Email: bmagana@cid.INFOSEL.com.mx  *


Forms move minimized

LUOKKA: forms

4211 (96+)  jsimmons@cs.sunysb.edu  31.01.95  02:15

Jason Simmons: "Re: Help:Moving Forms"

> Is there any possible way to move a minimized app. to a new location,

>other than the one Windows assigns it?

The API function SetWindowPlacement can change the location where a

minimized window is placed.  Get a copy of the window's current

WINDOWPLACEMENT structure, set ptMinPosition to the coordinates

where you want the window to be when it is minimized, and call

SetWindowPlacement.

Declarations for the WINDOWPLACEMENT structure can be found in the

win31api.txt file.

Dim wpl As WINDOWPLACEMENT

Dim i%

wpl.length = 22

i% = GetWindowPlacement(Form1.hWnd, wpl)

wpl.flags = WPF_SETMINPOSITION

wpl.ptMinPosition.x = 200

wpl.ptMinPosition.y = 300

i% = SetWindowPlacement(Form1.hWnd, wpl)

Jason Simmons

jsimmons@cs.sunysb.edu


Forms resizing, good!

LUOKKA: forms

26485 (113+)  WXHH42A@prodigy.com  20.07.95  18:43

Dennis Hining: "Re: Help  -  Resizing forms and their objects"

I use a general routine that I've written that upon loading, a form is

resized by the routine.  Initially all of my forms are programmed in the

VGA 640 x 480 size.  Next, I set a global variable to the ratio of the

screen sizes, i.e.,

VRvga = (Screen.Height/Screen.TwipsPerPixelY)/480

HRvga = (Screen.Width/Screen.TwipsPerPixelX)/640

Upon the loading of a form, I call the sizing routine, i.e.,

Set_Form ME

Note that the fonts are scaled by the routine Set_Fonts listed after

Set_Form.  The scaling of fonts is a bit tricky to get the length and

width sized properly to fit controls such as buttons.  However, the font

sizes listed in the Set_Fonts routine seem to fit pretty well.

Also, if you use any positioning of controls in your routines after they

are loaded, just include the multiplyer's VRvga and HRvga and the scaling

will match OK.

Good Luck!

The Set_Form routine is as follows:

Static Sub Set_Form (fme As Form)

Dim tl%, i%, j%, a$, s!

If ScreenType = 1 Then

  For i = 0 To fme.Controls.Count - 1

   If TypeOf fme.Controls(i) Is SSPanel Then

    If fme.Controls(i).BackColor <> spBackPanelColor Then fme.Controls(i).

BackColor = BackPanelColor

   End If

  Next i

  Exit Sub

End If

If fme.Width <> Screen.Width Then

   fme.Width = fme.Width * HRvga

   fme.Height = fme.Height * VRvga

   fme.Top = fme.Top * VRvga

   fme.Left = fme.Left * HRvga

End If

For i = 0 To fme.Controls.Count - 1

   j = 0

   If TypeOf fme.Controls(i) Is ComboBox Then

      j = 1

      fme.Controls(i).Top = fme.Controls(i).Top * VRvga

      fme.Controls(i).Left = fme.Controls(i).Left * HRvga

      fme.Controls(i).Width = fme.Controls(i).Width * HRvga

      If fme.Controls(i).Style <> 0 And fme.Controls(i).Style <> 2 Then

         fme.Controls(i).Width = fme.Controls(i).Width * HRvga

         fme.Controls(i).Height = fme.Controls(i).Height * VRvga

      End If

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is ListBox Then

      j = 2

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is Shape Then

      j = 3

      GoSub setformcontroldimensions

   ElseIf TypeOf fme.Controls(i) Is Line Then

      j = 4

      fme.Controls(i).X1 = fme.Controls(i).X1 * HRvga

      fme.Controls(i).X2 = fme.Controls(i).X2 * HRvga

      fme.Controls(i).Y1 = fme.Controls(i).Y1 * VRvga

      fme.Controls(i).Y2 = fme.Controls(i).Y2 * VRvga

   ElseIf TypeOf fme.Controls(i) Is SSPanel Then

      j = 5

      GoSub setformcontroldimensions

      If fme.Controls(i).BackColor <> spBackPanelColor Then .......

      fme.Controls(i).BackColor = BackPanelColor

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is SSCommand Then

      j = 6

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is CommandButton Then

      j = 7

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is SSCheck Then

      j = 8

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is TextBox Then

      j = 9

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is Label Then

      j = 10

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is PictureBox Then

      j = 11

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is Grid Then

      j = 12

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is DirListBox Then

      j = 13

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is FileListBox Then

      j = 14

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is DriveListBox Then

      j = 15

      fme.Controls(i).Top = fme.Controls(i).Top * VRvga

      fme.Controls(i).Left = fme.Controls(i).Left * HRvga

      fme.Controls(i).Width = fme.Controls(i).Width * HRvga

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is SSFrame Then

      j = 16

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is Frame Then

      j = 17

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   ElseIf TypeOf fme.Controls(i) Is VScrollBar Then

      j = 18

      GoSub setformcontroldimensions

   ElseIf TypeOf fme.Controls(i) Is SSOption Then

      j = 19

      GoSub setformcontroldimensions

      s = fme.Controls(i).FontSize

      Set_FontSize_ScaleControl fme.Controls(i), s

   Else

   End If

Next i

Exit Sub

setformcontroldimensions:

fme.Controls(i).Width = fme.Controls(i).Width * HRvga

fme.Controls(i).Height = fme.Controls(i).Height * VRvga

fme.Controls(i).Top = fme.Controls(i).Top * VRvga

fme.Controls(i).Left = fme.Controls(i).Left * HRvga

Return

End Sub

'Note that This sub scales the fonts according to font size

Sub Set_FontSize_ScaleControl (Ctrl As Control, Sz As Variant)

Select Case ScreenType

  Case 1  'Screen 640 x 480

    Ctrl.FontSize = Sz

  Case 2  'Screen 800 x 600

    If Sz = 8.25 Then

      Ctrl.FontSize = 9.75

    ElseIf Sz = 9 Then

      Ctrl.FontSize = 10.5

    ElseIf Sz = 9.75 Then

      Ctrl.FontSize = 12

    ElseIf Sz = 10.5 Then

      Ctrl.FontSize = 13.5

    ElseIf Sz = 12 Then

      Ctrl.FontSize = 15.75

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 18

    ElseIf Sz = 18 Then

      Ctrl.FontSize = 19.5

    End If

  Case 3  'Screen 1024 x 768

    If Sz = 8.25 Then

      Ctrl.FontSize = 12

    ElseIf Sz = 9 Then

      Ctrl.FontSize = 12.75

    ElseIf Sz = 9.75 Then

      Ctrl.FontSize = 13.5

    ElseIf Sz = 10.5 Then

      Ctrl.FontSize = 15.75

    ElseIf Sz = 12 Then

      Ctrl.FontSize = 16.5

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 19.5

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 24

    End If

  Case 4  'Screen 1152 x 864

    If Sz = 8.25 Then

      Ctrl.FontSize = 13.5

    ElseIf Sz = 9 Then

      Ctrl.FontSize = 15.75

    ElseIf Sz = 9.75 Then

      Ctrl.FontSize = 16.5

    ElseIf Sz = 10.5 Then

      Ctrl.FontSize = 16.5

    ElseIf Sz = 12 Then

      Ctrl.FontSize = 18

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 24

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 27

    End If

  Case 5  'Screen 1600 x 1200

    If Sz = 8.25 Then

      Ctrl.FontSize = 18

    ElseIf Sz = 9 Then

      Ctrl.FontSize = 19.5

    ElseIf Sz = 9.75 Then

      Ctrl.FontSize = 24

    ElseIf Sz = 10.5 Then

      Ctrl.FontSize = 24

    ElseIf Sz = 12 Then

      Ctrl.FontSize = 24

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 27

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 29.25

    End If

  Case 6    'Screen 1280 x 1024

    If Sz = 8.25 Then

      Ctrl.FontSize = 13.5

    ElseIf Sz = 9 Then

      Ctrl.FontSize = 15.75

    ElseIf Sz = 9.75 Then

      Ctrl.FontSize = 16.5

    ElseIf Sz = 10.5 Then

      Ctrl.FontSize = 16.5

    ElseIf Sz = 12 Then

      Ctrl.FontSize = 18

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 24

    ElseIf Sz = 16 Then

      Ctrl.FontSize = 27

    End If

  Case Else

End Select

End Sub

____________________________________________________

"Keep an Open Mind and People will throw in Garbage"

DENNIS HINING  WXHH42A@prodigy.com


Forms save as image

LUOKKA: forms

Date: 07-28-95 (17:18)              Number: 398666 of 398859 (Refer# NONE)

Subj: FW: Saveing form as an image -revisited-

From: "by way of oliorn@itn.is Olafur Orn Jonsson" <oliorn@kerfi.is>

>One more time...  saving the contents of a form to an image...

>I know that print screen works but (this is the killer but) I need the

>application to do this its self. Keep in mind i dont just want the form.picture

>but also the labels ontop of that picture.. Basically im looking for a way to

>use a graphic as a template change a few text on run time by looking at the

>file then save back to an image with no user input. (txt files for the text)

Here is a module I wrote.  I used it to save memory. I have a huge form that I

need to load several instances of and to save memory I take a picture of the

form and show thath picture on another form that has NO controls on it and

NO code in it. This func takes 2 parameters.

1. is the form to take picture of

2. is the form to put the picture in the picture property

it makes the second form visible and on the same place as the first form.

Option Explicit

'Type RECT

'  Left As Integer

'  Top As Integer

'  Right As Integer

'  Bottom As Integer

'End Type

Declare Function GetDesktopWindow Lib "user" () As Integer

Declare Function GetDC Lib "user" (ByVal hWnd%) As Integer

Declare Function BitBlt Lib "GDI" (ByVal hDestDC%, ByVal x%, ByVal y%,

ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

YSrc%, ByVal dwRop&) As Integer

Declare Function ReleaseDC Lib "User" (ByVal hWnd As Integer, ByVal hDC

As Integer) As Integer

Declare Sub GetWindowRect Lib "User" (ByVal hWnd%, lpRect As RECT)

Declare Function GetWindow Lib "User" (ByVal hWnd As Integer, ByVal

wCmd As Integer) As Integer

Declare Function GetParent Lib "User" (ByVal hWnd As Integer) As Integer

'Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

Integer

Const SM_CXFRAME = 32

Const SM_CYFRAME = 33

Const SRCCOPY = &HCC0020

Declare Function GetFocus Lib "User" () As Integer

Declare Sub HideCaret Lib "User" (ByVal hWnd As Integer)

Declare Sub ShowCaret Lib "User" (ByVal hWnd As Integer)

Function AfritaSkjamynd (frm_From As Form, frm_To As Form) As Integer

  Dim WinSize       As RECT

  Dim DeskTop_hWnd  As Integer

  Dim DeskTop_hDC   As Integer

  Dim From_X        As Integer

  Dim From_Y        As Integer

  Dim Ctrl_Focus    As Integer

  Dim Gekk          As Integer

  Dim tmp           As Integer

  DeskTop_hWnd = GetDesktopWindow()

  DeskTop_hDC = GetDC(DeskTop_hWnd)

  Call GetWindowRect(frm_From.hWnd, WinSize)

  From_X = -(frm_From.Left / screen.TwipsPerPixelX) -

GetSystemMetrics(SM_CXFRAME)

  From_Y = -(frm_From.Top / screen.TwipsPerPixelY) -

GetSystemMetrics(SM_CYFRAME)

  Ctrl_Focus = GetFocus()

  Load frm

  frm.Move screen.Width, screen.Height

  frm.Show

  Gekk = BitBlt(frm_To.hDC, From_X, From_Y, WinSize.Right,

WinSize.Bottom,

DeskTop_hDC, 0, 0, SRCCOPY)

  Unload frm

  tmp = ReleaseDC(DeskTop_hWnd, DeskTop_hDC)

  AfritaSkjamynd = Gekk

  frm_To.Move frm_From.Left, frm_From.Top, frm_From.Width,

frm_From.Height

End Function


Forms sizing

LUOKKA: forms

Date: 06/27/94 (13:13)              Number: 10760 of 10897 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: API Question: Setting min

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

This is a very simple thing to write code for:

in the Form_Load event:

 OriginalWidth% = Me.Width

 OriginalHeight% = Me.Height

in the Form_Resize event:

 Me.Height = OriginalHeight% 'allows width to change, but not

     'height

 If Me.Width < OriginalWidth% Then Me.Width = OriginalWidth%

     'prevents width from becoming

     'less than OriginalWidth%

This isn't the cleanest LOOKING solution, due to form resizing and

repainting all over the place.  You could probably fuss with the Class

bits or eat a few messages to prevent the form from drawing at all when

you need such an effect.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Forms sizing

LUOKKA: forms

Date: 07/01/94 (10:31)              Number: 10954 of 11050 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: API Question: Setting min and max dimensions for a form

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article: <Cs8IDD.24B@world.std.com>  sgirotti@world.std.com (stephen e

girotti) writes:

> are you sure this works?? i remember getting 'out of memory' errors

> changing the height or width in the resize event. because the h or w

> has been changed, it fires the resize event which changes the h or w

> which fires the resize event which..... etc etc. recursive loop which

> will eventually cause your stack space to run out.

Sir,

If you do it like this it will work.

First, for your form set AutoRedraw to False. Then, in your

Form_Resize event, have something like this:

Sub Form_Resize ()

'Make sure the form isn't minimised

    If Me.WindowState = 1 Then

        Exit Sub

    Else

'Redraw all of the objects on the form

        RedrawForm

    End If

End Sub

The RedrawForm subroutine looks like this (I've abbreviated it so as

not to send you all to sleep):

Sub RedrawForm ()

'Establish minimum sizes

    If frmFTMain.Width < 7500 Then frmFTMain.Width = 7500

    If frmFTMain.Height < 5000 Then frmFTMain.Height = 5000

'size and position of listbox

    lbTitles.Height = frmFTMain.Height - (pnlTop.Height + pnlBottom.Height +

pnlCursor.Height + 900)

    lbTitles.Width = lbTitles.Left + CursorPos

'size and position of textbox

    txtMain.Left = lbTitles.Left + lbTitles.Width + 50

    txtMain.Width = frmFTMain.Width - (txtMain.Left + 200)

    txtMain.Height = lbTitles.Height

'size of CursorBar

    pnlCursor.Left = lbTitles.Left

    pnlCursor.Width = lbTitles.Width + 50 + txtMain.Width

    picCursorBar.Left = 10 'lbTitles.Left

    picCursorBar.Width = pnlCursor.Width - 50 'lbTitles.Width + 50 +

txtMain.Width

    picture3.Left = picCursorBar.Left + picCursorBar.Width - (picture3.Width +

30)

'position of Exit Button

    btnExit.Left = frmFTMain.Width - 1400

End Sub

This all works OK for me. Hope it helps.

Ian Piper


Forms speed up

LUOKKA: speed

Date: 07-28-95 (17:18)              Number: 398666 of 398859 (Refer# NONE)

From: "by way of oliorn@itn.is Olafur Orn Jonsson" <oliorn@kerfi.is>

Subject:      FW: Saveing form as an image -revisited-

>One more time...  saving the contents of a form to an image...

>I know that print screen works but (this is the killer but) I need the

>application to do this its self. Keep in mind i dont just want the form.picture

>but also the labels ontop of that picture.. Basically im looking for a way to

>use a graphic as a template change a few text on run time by looking at the

>file then save back to an image with no user input. (txt files for the text)

Here is a module I wrote.  I used it to save memory. I have a huge form that I

need to load several instances of and to save memory I take a picture of the

form and show thath picture on another form that has NO controls on it and

NO code in it. This func takes 2 parameters.

1. is the form to take picture of

2. is the form to put the picture in the picture property it makes the second

form visible and on the same place as the first form.

Option Explicit

'Type RECT

'  Left As Integer

'  Top As Integer

'  Right As Integer

'  Bottom As Integer

'End Type

Declare Function GetDesktopWindow Lib "user" () As Integer

Declare Function GetDC Lib "user" (ByVal hWnd%) As Integer

Declare Function BitBlt Lib "GDI" (ByVal hDestDC%, ByVal x%, ByVal y%,

ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

YSrc%, ByVal dwRop&) As Integer

Declare Function ReleaseDC Lib "User" (ByVal hWnd As Integer, ByVal hDC

As Integer) As Integer

Declare Sub GetWindowRect Lib "User" (ByVal hWnd%, lpRect As RECT)

Declare Function GetWindow Lib "User" (ByVal hWnd As Integer, ByVal

wCmd As Integer) As Integer

Declare Function GetParent Lib "User" (ByVal hWnd As Integer) As Integer

'Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

Integer

Const SM_CXFRAME = 32

Const SM_CYFRAME = 33

Const SRCCOPY = &HCC0020

Declare Function GetFocus Lib "User" () As Integer

Declare Sub HideCaret Lib "User" (ByVal hWnd As Integer)

Declare Sub ShowCaret Lib "User" (ByVal hWnd As Integer)

Function AfritaSkjamynd (frm_From As Form, frm_To As Form) As Integer

  Dim WinSize       As RECT

  Dim DeskTop_hWnd  As Integer

  Dim DeskTop_hDC   As Integer

  Dim From_X        As Integer

  Dim From_Y        As Integer

  Dim Ctrl_Focus    As Integer

  Dim Gekk          As Integer

  Dim tmp           As Integer

  DeskTop_hWnd = GetDesktopWindow()

  DeskTop_hDC = GetDC(DeskTop_hWnd)

  Call GetWindowRect(frm_From.hWnd, WinSize)

  From_X = -(frm_From.Left / screen.TwipsPerPixelX) -

GetSystemMetrics(SM_CXFRAME)

  From_Y = -(frm_From.Top / screen.TwipsPerPixelY) -

GetSystemMetrics(SM_CYFRAME)

  Ctrl_Focus = GetFocus()

  Load frm

  frm.Move screen.Width, screen.Height

  frm.Show

  Gekk = BitBlt(frm_To.hDC, From_X, From_Y, WinSize.Right,

WinSize.Bottom,

DeskTop_hDC, 0, 0, SRCCOPY)

  Unload frm

  tmp = ReleaseDC(DeskTop_hWnd, DeskTop_hDC)

  AfritaSkjamynd = Gekk

  frm_To.Move frm_From.Left, frm_From.Top, frm_From.Width,

frm_From.Height

End Function


Forms true size of

LUOKKA: forms

Date: 09/23/94 (01:47)              Number: 20426 of 20621 (Refer# NONE)

From: HPD@AKGUH.UUCP

Subj: Re: How can I get the TRUE size of a form.

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You need the GetSystemMetrics API call.

'***************************************************************

'* Windows API Functions Used Retrieve System Information

'***************************************************************

Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

  Integer

Global Const SM_CYCAPTION = 4   'Height of caption

Global Const SM_CXDLGFRAME = 7  'Width of frame when window has

WS_DLGFRAME

Global Const SM_CYDLGFRAME = 8  'Height of frame when window has

WS_DLGFRAME

Global Const SM_CXVSCROLL = 2    'Width of arrow bitmap on a vertical

scroll bar.

Global Const SM_CXFULLSCREEN = 16    'Width of window client area for a

  full-screen window.

Global Const SM_CXFRAME = 32    'Width of window frame that can be

sized.

Global Const SM_CYFRAME = 33    'Height of window frame that can be

sized.

Global Const SM_CYMENU = 15  'Height of single-line menu bar. This is the

  menu height minus the height of the window frame

Global Const SM_CYCURSOR = 14

Global Const SM_CXCURSOR = 13

'Example Finding Usable Area of Form.

FormAreaWidth% = Form.Width - Screen.TwipsPerPixelX * (2 *

GetSystemMetrics(SM_CYFRAME))

FormAreaHeight% = Form.Height - Screen.TwipsPerPixelY

*(GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU) + 2

*

GetSystemMetrics(SM_CYFRAME))

Paul Debban

hpd@akgua.att.com


Forms unloading

LUOKKA: forms

Date: 09/06/94 (13:24)              Number: 18411 of 18426 (Refer# NONE)

From: WEIKKO.IKOLA@CSC.FI

Subj: Re: Determing if Form1.frm is Loaded

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <347cha$lmt@Isis.MsState.Edu> jdz1@Ra.MsState.Edu (John D.

Zitterkopf) writes:

>In Visual Basic 3.0, How does one determine if a FORM has been loaded?

>I'd like to do this with a built-in command rather than setting up VARs to

>keep track of the windows I want to later Unload.

You don't necessarily have to. Unloading an unloaded or non-loaded form

doesn't produce an error.

Greetings,

Wende (weikko.ikola@csc.fi)


Forms which called?

LUOKKA: forms

Date: 07-10-95 (05:53)              Number: 383198 of 383617 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Which Form called???

From: Stan Mitranic <mitranic@FREENET.CALGARY.AB.CA>

Couple days ago somone asked how to know which form loaded another form

which is supposed to do all the processing.  Well, I needed the same

thing so know that I know how to do it I'll share it with everybody who

needs it.

In .BAS file in Declarations put the following:

Declare ActiveForm As Form

And then Just before loading the form put the following line:

Set CallingForm = Me

Now in the Main Form (The one that is called and that is doing all the

work) CallingForm will be the form that called it, so if you want to move

that form to top-left corner just use the following command:

CallingForm.Move 0,0

----------------------------------------------------------------

Stan Mitranic

mitranic@freenet.calgary.ab.ca


Forms which is loaded

LUOKKA: forms

Date: 06/23/94 (11:12)              Number: 10099 of 10157 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Finding if Form1 is loaded from Form2?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Paul (e01jjymo@tuzo.erin) wrote:

: I am trying to find out if form1 is loaded (visible) from form2(that is

: I want to know this from form2).

No real way to do this.  Might as well just set up your own little book

keeping system.

You can find out how many (Forms.Count) but not who.  Now, if you want to

store some id info in the tag prop, you can then use that to find out.

for i% = 0 to forms.count -1

 if forms(i%).tag = "Form1" then

  'yes, it's loaded

 endif

next

gt


Frames copying btns

LUOKKA: frames

Date: 07/02/94 (11:28)              Number: 11013 of 11050 (Refer# NONE)

From: WHM@PLAZA.DS.ADP.COM

Subj: Re: Help on option arrays

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Luke Webber (webber@werple.apana.org.au) wrote:

: I remember one time I found problems grouping radio buttons on a frame,

: because I wanted to take a button that I'd modifies and clone it via

: Ctrl-Insert (Copy) and Shift-Insert (Paste). Unfortunately, the resultant

: button comes back as a child of the form, not the frame. I would have

: liked VB to be smart enough to assign the same parent.

   True, but if you 1) copy, 2) select the frame, and 3) paste, it will

   be a child of the frame.  Took me a while to discover that too.

_________

   Bill Morrison                                whm@plaza.ds.adp.com


Frames option groups

LUOKKA: frames

Date: 04-21-95 (06:15)              Number: 298030 of 301771 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Option Button Groups

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>     I am trying to create two independent groups of option buttons on a

>     form.  VB Help says if I place a frame on the form first and then

>     place option buttons in the frame, they will act as a group,

>    independent from another group created the same way, and I can have a

>     True button in each group.

>

>     I have done this, but all the option buttons on the form act as one

>     group; that is, when I make one option button True, it makes all the

>     others on the form false, even if they're in a different frame/group.

>     What am I doing wrong, please?

David, you are probably making a very common mistake.  If you place the

options on the form and then draw the frame around them, they are going to

be linked to the form.  If you FIRST place the frame on the form and then

add the option buttons to the frame, then they will be linked to the frame

and NOT to the form.  There is a trick, though!  You cannot double-click a

tool and then move it onto the frame because double-clicking a tool will

link it to the form...you must actually select the option button, then DRAW

the option button onto the frame.  This will make the right link.  You can

also cut (or copy) it from somewhere else and then select the frame and

paste it in, and THEN move it around inside the frame.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

                       Ottis L. Airhart, Jr.

                        Oairhart@revnet.com


Frames putting labels

LUOKKA: frames

Date: 07/23/94 (13:26)              Number: 12931 of 12942 (Refer# NONE)

From: COSMO@HALCYON.COM

Subj: Re: Frame and Label

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <30p6q7$eu2@panix3.panix.com> scibp6p@panix.com (Boris Pitel)

writes:

>  I wanted a frame control to be on my form and inside of this form control

>a couple of text controls with labels. The problem : every time I put a label

>inside of the Frame the label becomes unvisible. Everything else being put

>inside of the Frame behaves normal, but the label doesn't - the label

>becomes unvisible.

The label is UNDER the frame,  Press <Shift>-DEL to cut the label to the

clipboard, and then select the frame with the mouse.  Press <Shift>-Ins to

paste the label onto the frame control.  *Poof*

Jay Stewar


Free space

LUOKKA: VBgen

27.How do I get the number of free bytes on a disk?

   See Article Q113590 (or Q106553) in Microsoft's VB KnowledgeBase. A

   short extract follows:

   Declare Function DiskSpaceFree Lib "SETUPKIT.DLL" () As Long

   Dim free_space& ' Holds number of bytes returned from DiskSpaceFree().

   ChDrive "c:"    ' Change to the drive you want to test.

   free_space& = DiskSpaceFree()

   ÄGeir Tutturen(itfgt@nlh10.nlh.no)Å


FreeFile???

LUOKKA: files

Date: 07/14/94 (02:47)              Number: 12000 of 12069 (Refer# NONE)

From: JROBERTS@INTERACCESS.COM

Subj: If it hurts dont do it.

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

To save every some head scratching I submit the following code fragment. It

will fail.

dim F1 as integer, F2 as integer

F1 = FreeFile

F2 = FreeFile

open 'file1' for input as F1

open 'file2' for output as F2

This fails because FreeFile does no house keeping

if this is run, F1 and F2 both return the same number you must FreeFile open

FreeFile open to get things right.

Not a biggie just one of those little things that could drive you crazy

----------------------------------------------------------------------

Jim Roberts                      jroberts@interaccess.com

James Roberts Computer Consulting            708/658-9409


FRX extension

LUOKKA: forms

Date: 09/10/94 (17:45)              Number: 18970 of 19086 (Refer# NONE)

From: DVANDERR@ORACLE.COM

Subj: Re: What means the FRX extension?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <al163388.779164706@academ01>

al163388@academ01.mty.itesm.mx (Mario Luna Arroyo) writes:

     I see that there are some files with an extension named FRX, and i would

   like to know what its this? Why this files are created?

when you save your Forms as text, and they have any embedded bitmaps

or icons, this binary data is saved in an accompanying FRX file.  the

FRX file is referenced from the text FRM file (you can look at it with

a text editor and see).


FTP site

LUOKKA: VBgen

Date: 12/25/94 (00:24)              Number: 30763 of 30906 (Refer# NONE)

From: EJV@IX.NETCOM.COM

Subj: Re: VB FTP site Creation....

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In <3df7pt$ote@metro.atlanta.com> DonL@donl.lq.ga.net (Yep that is me at

Donnet.com!!!) writes:

>My site is LQ.COMP.COM..

>Log in as anonymous then

>place the files in the Incomming

>directory.

>

>Don K Lindsay, LQ Computer Consultants

I would support your site, if you would be willing to download some of

the most used VB files from ftp.microsoft.com and other sites.  Examples

would be the compatibility layer, the bi-monthly FAQ's, etc.

Let me know when things get going!

Earl Vincent :-)f


FTP site WWW

LUOKKA: VBgen

32  gary@apexepa.apexsc.com  09.01.95  16:41

Gary Wisniewski: "WWW: clvb archives at C&G Home Page"

Announcements from Carl 'n Gary's Visual Basic HomePage:

We have just added begun archiving the complete contents of all

VB-related newsgroups for WWW/Mosaic users.  Not only do we archive

the full newsgroup contents, but have also developed an interactive

form-based search engine so that you can search by subject to

locate items of interest.  The archives are only about a week

old, but useful even now, and will become more significant

as time goes on.

We have also made a significant number of changes to the page,

including new, updated hotlinks and the addition of an

FTP site where we will accept contributions and make files

available to the public.

Of interest is our "What's New" mailing list, which allows you

to place your e-mail address on a list which we send homepage

changes to automatically.  This saves you the time of checking

periodically.

Reactions so far to the page have been great.  But, we're always

looking for ideas and *especially* contributions.

If you are on the Web, you can check out the VB home page:

http://www.apexsc.com/vb/

Send any e-mail inquiries to:

vb-admin@apexsc.com

--

Gary Wisniewski

Apex Software Corporation    gary@apexsc.com          Phone: (412) 681-4343


FTP-site

LUOKKA: internet

Date:         Fri, 5 Aug 1994 11:55:33 EDT

From:         Matt Griffith <GRIFFITH@STOCKUS1.MHS.COMPUSERVE.COM>

Subject:      New Visual Basic FTP Site...  XE "New Visual Basic FTP Site..."

Towards the end of the August, or the first of September, there will

be a new VB FTP Site on the Internet.  I have included the

information below...

--------------------------------------------------------------------------

LOGIX.GRAPHIX.COM

/GRAPHIX/programr/vbwin

     Visual Basic Directory

/GRAPHIX/programr/vcpp

     Visual C++

/GRAPHIX/programr/bcpp

     Borland C++

/GRAPHIX/programr/vbwin/VBX

     Custom Controls

/GRAPHIX/programr/vbwin/DLL

     DLL's

/GRAPHIX/programr/vbwin/SOURCE

     Source code/examples

/GRAPHIX/programr/vbwin/text

     Text documents, help files, online magazines, knowledge base,

     digests, etc.

/GRAPHIX/programr/vbwin/ads

     Advertisements, Want Ad's, Classified, product ad's, etc.

/GRAPHIX/programr/vbwin/demos

     Demo's of VB products, add-ons, etc.

/GRAPHIX/programr/vbwin/misc

     The stuff that can't be categorized

/GRAPHIX/programr/vbwin/uploads

     Where you upload your files

     Please include a text document of some sort explaining

     your upload, type (freeware, shareware, demoware, etc.),

     description, etc.  This site will soon support MOSAIC and

     this will become a text file available for viewing.

     Please use PKZIP 2.04g to compress your uploads.

     If you do not have PKZIP 2.04g, it is available in

     /GRAPHIX/tools

--------------------------------------------------------------------------------

Matthew Griffith

Stockhausen, Inc.

(910) 333-7590


Full-text search

LUOKKA: WinHelp

Date: 05/20/94 (16:21)              Number: 6380 of 6460 (Refer# NONE)

From: MCV@INTER.NL.NET

Subj: Re: How to produce 'free text search' .hlp files?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <6031@rhino.qpsx.oz.au>, Manuel Mall <mmall@qpsx.oz.au> wrote:

>I recently downloaded from the Microsoft ftp server the fully indexed VB

>knowledge base help files which come with the 'free text search engine'

>(FTENGINE.DLL, FTUI.DLL). The simple question is if anyone out there

>knows how to prepare a .HLP file so it can be used with that engine. Are

>there any tools, conversionprograms, etc.?

To actually make a full-text index (*.IND), you need three DOS-based

utilities: FORAGE(P).EXE, W_SCAN.EXE and INDEX.EXE.  They extract the

words from a .HLP file and create an index.  The two DLLs you mentioned

use the index file to put up the full-text-search dialog  (BTW, you'll

also need MVAPI.DLL).  Unfortunately, these tools were available only

on the Multimedia Viewer 1.0 MDK, which I believe has been dicontinued.

Viewer 2 uses a different set of DLLs, and the indexers are integrated

with the viewer compiler WMVC.EXE.  The nice thing about the Viewer 1

full-text search was that it also worked on plain HLP files (although

Microsoft wasn't telling anybody).

*However* I recall having seen the 3 proggies somewhere else...

I think it was the Windows NT SDK, but I'm just not sure.

Miguel Carrasquer

Amsterdam

mcv@inter.NL.net


Full-text search

LUOKKA: WinHelp

5969 (3+)  tokind@netcom.com  20.06.95  18:16

Tom Kindig: "Re: Full Text search across Multiple Winhelp files"

Art Smoot (aesmoot@aescon.com) wrote:

: Last year I built a fairly large Winhelp application, the

: Colorado Revised Statutes, which consisted of 1106 help files

: containing 40 megabytes of data.  For an alphabetic index we

: put in 26 full text search indexes for the statutes title search.

: We are planning on doing this again, for the yearly update.

: Does anyone have any suggestions for implementing a full

: text search across the entire set of Winhelp files?

ftskit.zip at ftp.netcon.com /pub/no/noring/winhelp

If you have several helpfiles for which you want to create a single index,

first create the .HLP files (using HC or HCP), then make the index with a

batchfile like this:

getmlt bag.ini;

forage /m bag.ini BAG.MLT w_scan

MYPRJ.ANS,,GENERIC.STP,GENERIC.FLD,BAG.MLT,MYPRJ.LST;

index MYPRJ,,MYPRJ,GENERIC.STP,GENERIC.FLD,MYPRJ.MAP;  rem clean

up the

directory

GETMLT.EXE is a very clever program that reads a bag.ini file

and produces the following output (given the bag.ini file above):

My Project I

MYPRJ1.HLP

My Project II

MYPRJ2.HLP

It needs two arguments (name of bag.ini and name of output .MLT file), but

will only accept one (hey! let's make it interactive!).  If I didn't have

a program to generate all of this FTSearch stuff automatically, I'd even

prefer to make the .MLT file by hand!

!!Quoted from old Winhelp Faq!! It works... good luck!

--

Tom Kindig                                        ö Reality,

Principal                                         ö  is a creative act.

LeftJustified Publiks                           . ö .

4875 Beryl Street, Las Cruces, NM. 88012-9446

=== tokind@aol.com == tokind@netcom.net ===


Full-text search

LUOKKA: WinHelp

5342 (6+)  the@adv.magwien.gv.at  15.05.95  11:06

Erwin Thaler: "Re: Full-text searching"

I found in FAQ's of  this group following article about FULL-TEXT-SEARCH:

Ä6-1-2Å Using the Full-Text Search Engines in WinHelp

Q: Can I add full-text search capabilities to my Windows Help file?

A: Yes.  The problem is finding the tools to do it with.

The full-text search engine of the Multimedia Viewer 1.0 is completely

compatible with WinHelp.  To create an index file from your help file,

you'll need:

FORAGE.EXE

(FORAGEP.EXE)

W_SCAN.EXE

INDEX.EXE

(GETMLT.EXE)

The run-time support is in the following DLLs:

FTUI.DLL

FTENGINE.DLL

MVAPI.DLL

These were all available in the MDK (Multimedia Developer's Kit), now

superseded by the Multimedia Viewer Publishing Toolkit (Viewer 2.0).

Viewer 2 also supports full-text searching, but the indexing is handled

by the integrated Viewer compiler: no separate .IND file is created.

The runtime DLLs are also different (MVFS2.DLL, MVFSTUI2.DLL,

MVAPI2.DLL).

The Indexing programs (FORAGE, W_SCAN and INDEX) are now available in

the Windows NT SDK (MSTOOLSÖHLPINDEX directory), as included in the

MS Developer's Library Level II CD sets.  They are identical to the original

Viewer 1 tools.

However, WinNT does *not* include the required 16-bit run-time DLLs, but

comes instead with new 32-bit versions (FTUI32.DLL, FTENG32.DLL,

MVAPI32.DLL).

The 16 bit DLLs are available from ftp.microsoft.com in some of the

KnowledgeBase helpfiles (e.g. Softlib/MSLFILES/WFWG.EXE).  They should

also be found with any Multimedia Viewer 1.0 product (like my 1991 MS

Boookshelf for Windows).

Q: Suppose I have laid my hands upon the EXEs and DLLs required.  What

must I do next?

A: Say you have a Windows Help project called MYPRJ.  First you must tell

WinHelp where to find the full-text search routines.  In MYPRJ.HPJ, add

these lines to the ÄCONFIGÅ section:

ÄCONFIGÅ

; FULL-TEXT-SEARCH:

; initialize DLLs

; RR("ftengine", "LoadFTEngine", "U") ; MMA: Not actually needed!

; LoadFTEngine(0) ; MMA: Not actually needed!

RR("ftui", "InitRoutines", "SU")

InitRoutines(qchPath, 1)

; declare the main routines

RR("ftui", "ExecFullTextSearch", "USSS") ; MMA: Missing a double quote!

RR("ftui", "SwitchToTopicsFound", "U")

; provide ways to use them: suit to your own taste

AddAccelerator(0x46,2,"SwitchToTopicsFound(hwndApp)")

CreateButton("btn_fts","&Textsuche","ExecFullTextSearch(hwndApp,qchPat

h,`',`')")

Add the following line to the ÄBAGGAGEÅ section

ÄBAGGAGEÅ

bag.ini

ä Editor's Note: "bag.ini" must be all lower case. Baggage files are case

sensitive. Not making it all lower case will produce errors.             å

Save MYPRJ.HPJ.

"bag.ini" is a simple text file, that tells the full-text search engine the

name of the index file, and whether several different help-files share one

single index.  The simple case is one .HLP file, one .IND file.  bag.ini

should look like this:

Äbag.iniÅ

groupcount=1

group1=MYPRJ

ÄMYPRJÅ

Title=My Project

Indexfile=MYPRJ.IND

If you have two helpfiles that share an index:

Äbag.iniÅ

groupcount=2

group1=MYPRJ1

group2=MYPRJ2

ÄMYPRJ1Å

Title=My Project I

Indexfile=MYPRJ.IND

ÄMYPRJ2Å

Title=My Project II

Indexfile=MYPRJ.IND

All the Indexfile= lines should be the same.  You can have up to 15 groups.

The same bag.ini file should be included in the baggage of all the help

files.

Next you'll need a field-description file.  It comes with the Viewer 1

and NT Helpindex tools (as GENERIC.FLD).  If you don't have it, it's

a simple textfile containing the following text:

topic Äinline, search, stopÅ

filename Äcatalog, stringÅ

address Äcatalog, fixed(4)Å

length Äcatalog, fixed(4)Å

topicTitle Äcatalog, trunc(32)Å

topicNSR Äinline, search, stopÅ

Finally there's the stop-words file.  This is a text file containing words

that need not be indexed, each on a separate line.  Viewer 1 and NT come

with GENERIC.STP, which contains a list of English words:

a

an

and

the

.

If your text is in a different language, you should provide your own .STP

file.  Viewer 2 comes with ready-made French and German .STP files.

Since we're talking internationalization, one drawback of the Viewer 1

FTUI.DLL (solved in Viewer 2) is that the Full-Text Search dialog box

is English only.  Borland's Resource Workshop barfed on the dialog resource

in the DLL (Did MS do this on purpose?).

OK, all is set now to create the full-text index.  Viewer1 and the NT SDK

come with ready-to-run batchfiles, that in turn invoke a makefile that

creates the actual index.  In order the explain what's going on,  we'll

ignore the compexities of the makefile provided by MS.

For the simple case of one helpfile with one indexfile, you can create

(or generate) a batchfile, to invoke the Help Compiler and the Indexing

programs:

@ECHO OFF

hcp MYPRJ

echo.

getmlt bag.ini;

forage /w MYPRJ.HLP

w_scan

MYPRJ.ANS,MYPRJ.WRS,GENERIC.STP,GENERIC.FLD,BAG.MLT,MYPRJ.L

ST;

index MYPRJ,,MYPRJ,GENERIC.STP,GENERIC.FLD,MYPRJ.MAP;

rem produced by FORAGE

del MYPRJ.ANS

rem produced by W_SCAN

del MYPRJ.CFG

del MYPRJ.LST

del MYPRJ.OCA

del MYPRJ.WRS

del MYPRJ.ZON

del MYPRJ.ZOS

rem produced by INDEX

del MYPRJ.MAP

rem think that covers all the garbage generated

If you have several helpfiles for which you want to create a single index,

first create the .HLP files (using HC or HCP), then make the index with

a batchfile like this:

getmlt bag.ini;

forage /m BAG.MLT

w_scan MYPRJ.ANS,,GENERIC.STP,GENERIC.FLD,BAG.MLT,MYPRJ.LST;

index MYPRJ,,MYPRJ,GENERIC.STP,GENERIC.FLD,MYPRJ.MAP;

rem clean up the directory

GETMLT.EXE is a very clever program that reads a bag.ini file and produces

the following output (given the bag.ini file above):

My Project I

MYPRJ1.HLP

My Project II

MYPRJ2.HLP

It needs two arguments (name of bag.ini and name of output .MLT file),

but will only accept one (hey! let's make it interactive!).  If I didn't

have a program to generate all of this FTSearch stuff automatically, I'd

even prefer to make the .MLT file by hand!

That's it.  You should now have a file MYPRJ.IND to go with your

help file(s).  When you distribute the help file(s), just make sure that

you include the .IND file, *and* the FTUI, FTENGINE and MVAPI DLLs.

---

Erwin Thaler; MD-ADV; Rathausstr.1; A-1082 Vienna; Austria

phone:	+43-1-4000/91087

fax:	+43-1-4000/7141

eMail:	the@magwien.gv.at

-----------------------------------------------------------------------

6541 (7+)  grahammatt@aol.com  25.07.95  08:56

GrahamMatt: "Re: HELP with FTSKIT"

A very kind soul answered my question.....

The hang-up was in my bag.ini file.

The line which references my HPJ file had the .hpj extension.....IT SHOULD

NOT!!


Full-text search

LUOKKA: WinHelp

Etsin Ohjelmointi (23) Kokous Päivä: 05-27-95 (20:18)             Numero: 471 /

471 (Vast. nro EI OLE)

Knlle: ALL

Knltä: MATTI HARJU

Aihe: Full Text Search helppi-fileisiin

Luettu: (n/a)                         Tila: Julkinen viesti

Kok.: Ohjelmointi (23)           Lukumalli: Yleinen (-)

  --------------------------------------------------------

  Tiedoksi:

  ftp.netcom.com

  hakemisto pub/no/noring/WinHelp

  on

  ftskit.zip file kooltaan 259kiloa.

  Sisältää välineet, jolla omiin helppifileisiin

  lisää muutamassa minuutissa fulltextsearchin malliin

  Encarta/Cinemania/MS:n Knowledge Baset.

  Tarvittavien DLL:ien ja EXE:ien levittämisen laillisuudesta

  ei ole tietoa. Ainakaan itsestään selvästi se ei ole

  laitonta (osa fileistä on suoraan imettävissä Microsoftilta).

  Samat tiedostot sisältyivät muutaman vuoden takaiseen versioon

  Multimedia Viewer 1.0 (kaupallinen). Tdstot olivat/ovat myös

  MSDN cd-rompuilla ainakin level 2:ssa.

  (Microsoft Development Network: level 1 maksaa 195$/v:

   sisältää käsittääkseni online-helppinä kaikkien MS:n

   ohjelmien käsikirjat yms....)

  -----------------------------------------------------------


Full-text search

LUOKKA: WinHelp

WINHELP FULL-TEXT SEARCH INTERFACE FOR WINDOWS 95 AND

WINDOWS NT 3.51

ftp://ftp.microsoft.com/developr/drg/WinHelp/ftsrch.zip

The WinHelp system of Window 95 and Windows NT 3.51 provides full-text

indexing and searching. Whenever you go to the "Find" tab, you invoke

that engine. If the HLP file(s) which you're using haven't been indexed,

a "Find Wizard" will create indexes for you. If you'd like to index other

text files, you can call the full-text APIs directly. You'll find an

overview description of how to use the full-text engine (FTSrch.dll) in

the file FTSAPI.rtf. Then you can use the header file FTSIFace.h to write

code to drive FTSrch. You can use LoadLibrary and GetProcAddress to

connect to the FTSrch APIs, or you can use the FTSRCH.def file to construct

a LIB file and staticly bind to the FTSRCH APIs.

FTSRCH.ZIP contains three files. FTSAPI.RTF is an overview of the FTSrch

interfaces and documentation for each API. FTSIFace.h is a C language

header file for FTSrch, which ships as part of the Windows NT 3.51 SDK.

FTSrch.def is a list of exported functions, which is useful for building

a LIB file which matches the FTSrch.dll.

Richard Macher


Full-text search

LUOKKA: WinHelp

Date: 02/05/95 (00:34)              Number: 212409 of 213362 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Full Text Search in Knowledge Base

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>I am relly impressed with the full text search capability of the  VB

>Knowledge Base.  I see that there are several DLLs that are used to

>link the KB help file with it's keyword index file, namely FTENGINE.DLL

>and FTGUI.DLL.

>

>Does anyone out there know how Microsoft generates the index file?

>I have not seen any mention of it anywhere, and I am interested in

>being able to make a similar index file from a very big text file.

>

>Looking at the two DLLs, I see that they are Microsoft products and

>are for multimedia applications.

The Full Text Search help files are generated with MS Multimedia Viewer

(version 1) which was an extension of WinHelp 3.1.  As I understand, it

is no longer available. But rumour has it that the full text search

capability will be included with WinHelp 4.0 which will be a part of

Windows 95(6?).  For further info, follow the WinHelp newsgroup:

comp.os.ms-windows.programmer.winhelp

---

Bruce.McKibben@fi.uib.no

     Fysisk Institutt, Universitetet i Bergen, Norway

     phone:    47/55212884 voice      47/55318334 fax


Full-text search

LUOKKA: WinHelp

Date: 02/05/95 (23:50)              Number: 213588 of 215077 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Full Text Search in Knowledge Base

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

These are done by the old Multimedia Viewer 1 (now discontinued?).  =

This product has been replaced with Multimedia Viewer 2, and =

subsequently by MEDIAVIEW -- which is what MSDN uses.  The MSDN =

Platform (Level II), FTP.Microsoft.Com and CIS has the complete kit  on it.

IT COMES WITH A DEMO APPLICATION done in VB.

"Welcome to the MediaView Software and Title Development Kit help. This =

help provides information on how to use the tools and libraries in the kit.

You can use the kit=92s authoring tools to create a multimedia title. A =

multimedia title is an on line document that includes media such as =

text, pictures, movies, sounds, and interactive controls for viewing the me=

dia.

You can use the MediaView libraries that come with this kit to develop =

a Windows-based application that can play your multimedia title through =

media views. A media view is essentially a window programmed to display =

multimedia using the MediaView libraries.

A MediaView title and title player built with MediaView can:

*       Display topics containing richly formatted text, pictures, video, =

audio, and other media.

*       Quickly move from topic to topic at a stroke of the keyboard or a =

click of the mouse.

*       Select text for copying or for looking up in an index.

*       Change the way text looks while playing the title

*       Print a single topic or a number of topics.

*       Display an index to the title=92s topics.

*       Perform a search for any word in the title.

The kit includes an example multimedia title and an example title =

player application to help get you started."

Support: WINMM forum on CompuServe

Ken

PS: This is the best kept PUBLIC secret that Microsoft has... a tool =

better than a host of 3rd party tools - you'll marvel over it -- and =

the price .... read the licensing terms...


Full-text search

LUOKKA: WinHelp

Date: 02/06/95 (11:20)              Number: 214192 of 215077 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Full Text Search in Knowledge Base

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

The MediaView package can be found at ftp.microsoft.com in the directory

developr\drg\multimedia\MediaView\mv12kit.exe

Final installation requires 30 MEGS.

It ships with a reader (built in C++) fro the online docs, a VB sample

project and C++ sample - ALL ARE NOTICEABLY THAN WINHELP OR

VIEWER. Even without compression. However, with work, a hotspot can do

anything!

MediaView is the basis for BookShelf, Dinosaurs, and (I believe) the

newest versions of MSDN. You have to build the entire interface yourself

or use the sample projects.

The bottomline is: Lots of really cool things are possible using VB

(including making online help a fully integrated part of your

application) but the docs are minimal - particularly in relation to VB.

Tod

================

Tod R. Massa                                            tmassa@willamette.edu

Asst. Registrar for Institutional Research              Willamette University

                                   www: http://www.willamette.edu:80/~tmassa/


Full-text search

LUOKKA: WinHelp

Date: 02/07/95 (17:53)              Number: 216066 of 216424 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Full Text Search in Knowledge Base

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>> These are done by the old Multimedia Viewer 1 (now discontinued?).  =

>> This product has been replaced with Multimedia Viewer 2, and =

>> subsequently by MEDIAVIEW -- which is what MSDN uses.  The MSDN =

>> Platform (Level II), FTP.Microsoft.Com and CIS has the complete kit  on it.

>

>Well, I downloaded the MV12KIT.ZIP (8Mb!) and took a good look at it.

>The problem is that it does NOT provide a mechanism to do a full text

>search of the multimedia text; it WILL allow a full text search of the

>multimedia TOPICS only.  The MV12 does not contain the FTENGINE or

>FTGUI DLLs which are used by the VB Knowledge Base to link the KB with

>the previously prepared KB index file.

That's true.  MediaView, MMViewer2 and MMViewer 1 are different products.

MMV1 contains the FTxxx.DLLs and produces the indexes which can be

used with WinHelp 3 files.  MMV2 used a slightly different format, which

(as I understand) is not compatible with WinHelp.  MMV1 is discontinued,

though it is unclear to me whether or not it is still obtainable or what their

position on it is.  Clearly they are still using it to generate FT KBs.

Rumour has it that FT search will be a part of WinHelp 4 (to be released

with Win95(6).  Microsoft's answer may just be that you have to wait

until then.

Žsnip�

This subject is discussed in comp.os.ms-windows.programmer.winhelp

---

Bruce.McKibben@fi.uib.no

     Fysisk Institutt, Universitetet i Bergen, Norway

     phone:    47/55212884 voice      47/55318334 fax


Full-text search

LUOKKA: WinHelp

Date: 02/07/95 (20:51)              Number: 216260 of 216424 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Full Text Search in Knowledge Base

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

On Thu, 9 Feb 1995, Daniel A. DeVries wrote:

> Well, I downloaded the MV12KIT.ZIP (8Mb!) and took a good look at it.

> The problem is that it does NOT provide a mechanism to do a full text

> search of the multimedia text; it WILL allow a full text search of the

> multimedia TOPICS only.  The MV12 does not contain the FTENGINE or

>FTGUI

> DLLs which are used by the VB Knowledge Base to link the KB with the

> previously prepared KB index file.

This is incorrect. MediaView *does* provide full-text search. It uses a

method similar to Viewer 2.0 and builds the index into the title file -

not a separate file as Viewer 1.0 does. MediaView also provides for

highlighting search hits.

It is easy to be confused by MediaView. The documentation is minimal, the

sample viewers are minimal but straightforward, but if you start digging

around it only seems to have one major weakness - the inability to get

the contextId of the current topic (not the TopicID/TopicNo). Apparently

this doesn't seem to bother anyone but me and is common across WinHelp

and Viewer as well.

================

Tod R. Massa                                            tmassa@willamette.edu

Asst. Registrar for Institutional Research              Willamette University

                                   www: http://www.willamette.edu:80/~tmassa/


Full-text search

LUOKKA: WinHelp

Date: 02/08/95 (08:50)              Number: 217146 of 217725 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Full Text Search in Knowledge Base

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

On Thu, 9 Feb 1995, Daniel A. DeVries wrote:

Stuff deleted...

> > interface, users can quickly find information in even the largest title.

>                                                                     ^^^^^

> > Full-text search frees authors from having to determine each way users

> > might try to access information.

>

> Tod, I guess I am a little confused on this.  By "title", are they referring

> to the entire article?  If so, than that is what I am looking for.

Right. "Title" refers to the entire file. Essentially, as with Viewer 1.0

files that are handled separately and the Viewer 2.0 index which is

integrated, the MediaVIew compiler indexes every word in the text of the

file. However, as I believe it was Kenneth from MS pointed out, it does

not index the 'text' in .wav or .avi files but those can be matched to

aliases which are included in the index.

>

> What's causing the confusion for me is that many Help files have a search,

>but it only covers the Topics in the help file, not the actual text in the file.

Right again. However, it's the language that changes. Search in WinHelp

refers to a search of the keywords that the help author chose and entered

for each topic. The same thing is available in Viewer but it is called

the "Index" and "Search" refers to the full-text index. In MediaView, the

choice is up to you because you have to build the entire interface.

> In conclusion, if the documentation refers to the entire document as a

>"title", then I guess MediaView is what I need!

Now, watch that ' title$ ' stuff. The dollar-sign footnote is used to

define the title for the topic, not the "multimedia title."

Confusing, ain't it?

MediaView represents a truly great opportunity for integrated development

in VB. The api is pretty open, the possibilities are endless (even in

VB), and it is just plain cool. HOWEVER, to be used fully and take make

up for the loss of macros and other WinHElp and Viewer features, it

requires a new paradigm for development. I've been working with a couple

other people in the northern hemisphere who are trying to develop VB

based interfaces and we have made some progress. The conventions I've

developed are fairly simple and highly structured and seem to allow just

about anything.

>                                      ---------------------------

>                                      "  Daniel A. DeVries, PE  "

>                                      "  Electronics Engineer   "

>                                      "  dadevri@afic01.af.mil  "

>                                      ---------------------------

If you have any other questions, let me know.

Tod

================

Tod R. Massa                                            tmassa@willamette.edu

Asst. Registrar for Institutional Research              Willamette University

                                   www: http://www.willamette.edu:80/~tmassa/


Full-text search

LUOKKA: WinHelp

5509 (34+)  jacobsjo@.bel.alcatel.be  24.05.95  15:05

Johan Jacobs Alcatel: "Re: Full Text Search"

The Full Text Search programs (forage.exe, w_scan.exe, index.exe and

getmlt.exe) can be found at ftp.netcom.com in the subdir

/pub/no/noring/WinHelp and the filename is ftskit.zip. The run-time dll's are

there also but I don't know if they are the most recent because they date

from 19/09/91 and I've seen them from 8/7/92. I have just downloaded them

but not yet tried them.

Johan Jacobs

  jacobsjo@bsg.bel.alcatel.be

 de Villermontstraat 38  Phone:

 2550 Kontich            (32) 3 450 3241

  BELL Telephone   Belgium Fax: (32) 3 450 3579

~


Gauge

LUOKKA: VBgen

26855 (97+)  balchen@oslonett.no  22.07.95  03:39

Jens Balchen jr.: "Re: Progress indicators or status bars. Hints?"

If you don't know the End, just use the Flood meter in another way:

   ' Don't show Percent value (that'll just confuse)

   Panel3D1.FloodShowPct = False

   ' Your loop

   Do

      ' Update Flood

      Panel3D1.FloodPercent = Panel3D1.FloodPercent + 1

      ' If the Percent = 100, change direction

      If Panel3D1.FloodPercent = 100 And Panel3D1.FloodType = 1 Then

         Panel3D1.FloodType = 2

         Panel3D1.FloodPercent = 0

      ElseIf Panel3D1.FloodPercent = 100 And Panel3D1.FloodType = 2 Then

         Panel3D1.FloodType = 1

         Panel3D1.floodPercent = 0

      End IF

   Loop

That may give a cool way to display action...

Jens


Gauge

LUOKKA: VBgen

Date:         Thu, 4 Aug 1994 10:13:00 CET

From:         Titov Pavel <titov@NEPO1.IAEA.OR.AT>

Subject:      CANCEL...  XE "CANCEL..."

this form just displays progress indicator and provides user with Cancel

feature. See text after this source and you will get the idea.

 -------------------------------

VERSION 2.00

Begin Form frmProc

   BackColor       =   &H00C0C0C0&

   BorderStyle     =   1  'Fixed Single

   Caption         =   "Load in Progress"

   ClientHeight    =   1080

   ClientLeft      =   1095

   ClientTop       =   1485

   ClientWidth     =   4905

   ControlBox      =   0   'False

   ForeColor       =   &H00000000&

   Height          =   1485

   Left            =   1035

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   1080

   ScaleWidth      =   4905

   Top             =   1140

   Width           =   5025

   Begin CommandButton cmdCancel

      Cancel          =   -1  'True

      Caption         =   "Cancel"

      Height          =   375

      Left            =   1800

      TabIndex        =   1

      Top             =   600

      Width           =   1335

   End

   Begin SSPanel pnlProgress

      AutoSize        =   3  'AutoSize Child To Panel

      BevelOuter      =   1  'Inset

      BevelWidth      =   2

      BorderWidth     =   2

      Caption         =   "Panel3D1"

      FloodType       =   1  'Left To Right

      Font3D          =   3  'Inset w/light shading

      ForeColor       =   &H00000000&

      Height          =   375

      Left            =   120

      TabIndex        =   0

      Top             =   120

      Width           =   4695

   End

End

Option Explicit

Sub cmdCancel_Click ()

    Me.tag = "cancel"

End Sub

 ----------------------

this is sample of using the above

 ---------------------------

Sub mnuOLoad_Click ()

    Dim srvAirs As database, srvPris As database

    Dim recDbase As snapshot, recPris As snapshot

    LogOutLn "Load database START..."

    On Error Resume Next

    Set srvAirs = OpenDatabase("", False, False, "ODBC;DSN=AIRS

          Development")

    If Err <> 0 Then

        LogOutLn "Aborted."

        Exit Sub

    End If

    Set srvPris = OpenDatabase("", False, False, "ODBC;DSN=PRIS")

    If Err <> 0 Then

        LogOutLn "Aborted."

        srvAirs.Close

        Exit Sub

    End If

    On Error GoTo mnuOLoadErrorHandle

    frmProc.Show

    frmProc.Refresh

    Me.MousePointer = 11

    Me.Enabled = False

    ' processing here

    ' perform loading

        recDbase.MoveNext

     ' update progress indicator

        frmProc!pnlProgress.FloodPercent = (nCurRec * 100) \ nRecCount

     ' yield control to windows so other appls can perform

     ' you may want to put additional DoEvents in your processing code above

     ' in order to achieve better reactivity

        DoEvents

        If frmProc.Tag = "cancel" Then

            LogOutLn "Process interrupted by user."

            Exit Do

        End If

    Loop

    recDbase.Close

    ' finish

    ' close connections

    LogOutLn "Load database successfully FINISHED."

    srvAirs.Close

    srvPris.Close

mnuOLoadFinish:

    Unload frmProc

    Me.Enabled = True

    Me.MousePointer = 0

    Exit Sub

mnuOLoadErrorHandle:

    MsgBox Error$, 48

    LogOutLn Error$

    LogOutLn "Report: " + dbNo + dbType

    mnuOLoad.Enabled = False

    'Stop

    GoTo mnuOLoadFinish

End Sub


Gauge

LUOKKA: VBgen

Date: 01/25/95 (03:37)              Number: 198752 of 201095 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Working...

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>I was wondering if anyone knows of a way to display a message such as

>"Working..." when searching a database or even a percentage bar (I am

>going through a list of name (dbase III database) and getting all that

>are in a certain area code and displaying them in a listbox).

>

>I have tried using another form but it doesn't show the text until the

>search is complete.  I also tried an MDI Child and it shows min & max

>buttons...

I attached a small sample program hoping it will help you. In order to run

it add a 3d-panel, a label, a text box and one command button on your form

(keep default names). Set 3d-panel's FloodShowPct property to True and

FloodType to 1 (left to right). In the code, substitute the name and path of

an existing file.

Sub Command1_Click ()

   Dim inp As String * 100

   x = FileLen("c:™povcad™povcad40.exe")          'Substitute your filename

   Open "c:™povcad™povcad40.exe" For Binary As #1 'on these two lines

   Label1 = "Working..."

   Label1.Refresh 'Done to display the message before the code is finished

   i = 0

   While Not EOF(1)

      Get #1, , inp

      i = i + 100

      Panel3D1.FloodPercent = 100 * i / x

      Text1 = inp

   Wend

   Close #1

   Label1 = "Done"

End Sub

There are other ways to do this, but in my opinion this is the simplest

approach. You enhance this simple example many ways, e.g. making the

label

and panel visible only during actual operation etc. etc.

        Lasse


GDI & User resourc

LUOKKA: VBgen

Date: 09/29/94 (13:26)              Number: 21176 of 21392 (Refer# NONE)

From: WEIKKO.IKOLA@CSC.FI

Subj: Re: Checking GDI and USER resources..How?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Const GFSR_SYSTEMRESOURCES% = &H0

Const GFSR_GDIRESOURCES% = &H1

Const GFSR_USERRESOURCES% = &H2

Declare Function GetFreeSystemResources Lib "User"

 (ByVal fuSysResource As Integer) As Integer

Dim gfsr As Integer

gfsr = GetFreeSystemResources(GFSR_SYSTEMRESOURCES)

gfsr = GetFreeSystemResources(GFSR_GDIRESOURCES)

gfsr = GetFreeSystemResources(GFSR_USERRESOURCES)

Greetings,

Wende (weikko.ikola@csc.fi)


GDI & User resourc

LUOKKA: VBgen

Date: 10/20/94 (13:42)              Number: 23718 of 23771 (Refer# NONE)

From: PHILLK@CBR.HHCS.GOV.AU

Subj: Re: Windows system resources?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

To determine the system resources availble in windows use the Windows API

function - GetFreeSystemResources

This function returns the percentage of free space for system resources.

It only has one parameter (integer) which is to specify the type of resource to

be checked.  It can be one of the following:

 0 - Returns the percentage of free space for system resources.

 1 - Returns the percentage of free space for GDI resources.

 2 - Returns the percentage of free space for USER resources.

Copy these declarations from the win31ext.txt file that comes

with visual basic

Declare Function GetFreeSystemResources Lib "User"

(ByVal fuSysResource As Integer) As Integer

Global Const GFSR_SYSTEMRESOURCES = &H0000

Global Const GFSR_GDIRESOURCES = &H0001

Global Const GFSR_USERRESOURCES = &H0002

Then just call it like this

 intGDIFree = GetFreeSystemResources (GFSR_GDIRESOURCES)

TA-DA!!

NOTES:- The amount returned is a percentage.

GFSR_SYSTEMRESOURCES is the lowest of GDI or USER.  If you want the

amount of memory use the GetFreeSpace function.


GDI & User resources

LUOKKA: API

Date: 10/20/94 (14:54)              Number: 23735 of 23771 (Refer# NONE)

From: CSTUART@METRONET.COM

Subj: Re: Space in Disk with VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I'm looking for a way to consult the available space in disk, in the

>windows api, and i didn't found anything.

'--GET FREE GDI AND USR MEMORY

   Declare Function GetFreeSystemResources Lib "User" (ByVal

fuSysResource)

   Global Const GDI = 1

   Global Const USR = 2

'--GET SYSTEM MEMORY

   Declare Function GetFreeSpace Lib "Kernel" (ByVal wFlags) As Long

'--FREE DISK SPACE

   Declare Function DiskSpaceFree Lib "SetupKit.DLL" () As Long

------------------------------------------------------------------------

Chuck Stuart

Mesquite TX USA


GetModuleUsage

LUOKKA: shell

Date: 06/24/94 (09:36)              Number: 10224 of 10249 (Refer# NONE)

From: GR00+@ANDREW.CMU.EDU

Subj: If You Use Shell, You Might Want to Read This

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Excerpts from netnews.comp.lang.basic.visual: 22-Jun-94

GetModuleUsage... Gavin Rush@andrew.cmu.ed (1425)

> Has anyone ever had any problems using the Windows API call

> GetModuleUsage to determine when a program run from a VB app with

> Shell is done executing.  I know this is covered in the FAQ and as far as I

> can tell I'm using it the same way as it it is used there.  I have the

> following code (more or less)

> inthandle = Shell (someprogram.exe) 'I've also tried WinExec

> while GetModuleUsage (inthandle) > 0

>  x% = DoEvents  'or just DoEvents- I've tried both ways

> wend

> rest of program

> I've used this quite a bit and its always worked fine.  But for this one

> program (its a browser for the Computer Select CD in case that has

> anything to do with my troubles) the instance handle immediately goes to

> zero and the rest of my program executes.  As soon as the program is

> loaded this code thinks it is done running and moves on when I really

> need it to wait.  Has anyone ever experienced a program which only

> launches an application and then passes the work off to something else?

> Or becomes idle and appears done?  Can anybody think of any other way >

to accomplish what I want?  Any ideas on this matter would be appreciated.

getr@csesys.csesys.co.at writes:

>is there on error resume next in this procedure

>or in any procedure calling this one ?.

>test the inthandle to be >32 after the shell call

No, it was definitely going to zero.  It thinks the program is done running.

I solved this problem myself (finally), and thought I'd post the answer

for others reference.  I decided my original guess of the initially

launched program passing the work off to something else was right, since

I've never really had any problem with GetModuleUsage.  So I set out

digging through various Windows API function calls to determine what

this apparently new process, task, whatever you want to call it, is and

where its coming from.  This turned out to border on impossible (not to

mention deteriorating my sanity).  I finally broke down and called the

company which makes the program I was shelling to.  It turns out the

lauching program relinquishes control to another program once things are

loaded (its a browser for the Computer Select CD).  So if this type of

thing ever happens to you, the first thing you want to do is call the

company, because odds are, something else is really running, you won't

have any idea what it is, and your chances of creatively finding out are

slim.

Anyway, once you know what's really running, you can monitor that

program.  This only requires the use of one other Win API function.  The

following code worked for me:

handle% = Shell (path of initial program)

While GetModuleUsage (handle%) > 0

 DoEvents

Wend

newhandle% = GetModuleHandle (path of new program)

While GetModuleUsage (newhandle%) > 0

 DoEvents

Wend

Rest of Program

-----------------------------------------------------------------

Gavin M. Rush    Phone: (412) 268-6408

Carnegie Mellon University   Fax    : (412) 268-4987

Computing Services/Special Projects Email: gr00@andrew.cmu.edu


GetModuleUsage

LUOKKA: shell

Date: 07/01/94 (10:31)              Number: 10953 of 11050 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: *****  DETECTING TERMINATION OF A SHELLED PROGRAM *****

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

This is what you need to do. The API call GetModuleUsage records

the existence of another process, and you set up a loop which runs

as long as the shelled process runs.

Declare it like this:

    Declare Function GetModuleUsage Lib "Kernel" (ByVal hwnd As Integer)

       As Integer

Use it like this:

    screen.MousePointer = 11     'hourglass mouse pointer

'shell to your program

    X% = Shell(DOSExeFileName$, DOSViewFlag)

    Y% = 1

'As long as it's running - Y% becomes 0 when the shelled process ends

    While Y% > 0

        Y% = GetModuleUsage(X%)

'Use Doevents to let other processes get a look in

        i% = DoEvents()

    Wend

    screen.MousePointer = 0     'default mouse pointer

Now, without wishing to be rude, this *is* in the FAQ. Actually it's

probably the most common question in this newsgroup. Get yourself a

copy of this (George Tatge does a wonderful job of keeping this up to

date, if you can forgive the excruciating titles of his postings :-)),

and it may save you time in cracking your next problem.

Ian Piper


GetModuleUsage

LUOKKA: shell

Date: 05/21/94 (17:59)              Number: 3597 of 3597 (Refer# NONE)

  To: PAUL E. SMITH

From: JOHN MEADOWS

Subj: VB Shell command

Conf: WINBAS_R (362)             Read Type: GENERAL (A) (+)

Put the following (on one line of course) in the declaration section of

a code module.

Declare Function GetModuleUsage Lib "Kernel" (ByVal hInst As Integer) As

  Integer

Below is the code you'd use in a form.

Sub Example ()

Dim hInst As Integer, RunIt$, X

RunIt$ = your dos app

hInst = Shell(RunIt$, 6) 'the 6 means the app runs minimimized without

                         'focus; you may want something else.

Do

    X = DoEvents()

Loop While GetModuleUsage(hInst) > 0

End Sub

John Meadows in Toronto, Canada

john.meadows@canrem.com


GetModuleUsage

LUOKKA: shell

Date: 08/26/94 (17:25)              Number: 17157 of 17164 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Shell Command - GetMo

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here is a function I use called RunDOSApp.  It shells to the given Command$

and waits for the end of the app:

(Declarations)

'API calls for running DOS Apps

Declare Function WinExec% Lib "Kernel" (ByVal lpCmdLine$, ByVal

nCmdShow%)

Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)

Global Const SW_HIDE = 0

Global Const SW_NORMAL = 1

Global Const SW_MAXIMIZE = 3

Global Const SW_MINIMIZE = 6

Function RunDosApp% (ByVal strCommand$, ByVal intStyle%, ByVal

flgMessage%)

'Shells to a DOS application and waits for it to finish if flgMessage is

'True, it will display messages

Static iRet%

Static strMessage$

    iRet = WinExec("dosprmpt.pif /c " & strCommand, intStyle)

    strMessage = ""

    Select Case iRet

        Case 0

            strMessage = "System was out of memory, executable file was

               corrupt, or relocations were invalid."

        Case 2

            strMessage = "File was not found."

        Case 3

            strMessage = "Path was not found."

        Case 5

            strMessage = "Attempt was made to dynamically link to a task, or

               there was a sharing or network-protection error."

        Case 6

            strMessage = "Library required separate data segments for each

               task."

        Case 8

            strMessage = "There was insufficient memory to start the

               application."

        Case 10

            strMessage = "Windows version was incorrect."

        Case 11

            strMessage = "Executable file was invalid. Either it was not a

               Windows application or there was an error in the .EXE image."

        Case 12

            strMessage = "Application was designed for a different operating

               system."

        Case 13

            strMessage = "Application was designed for MS-DOS 4.0."

        Case 14

            strMessage = "Type of executable file was unknown."

        Case 15

            strMessage = "Attempt was made to load a real-mode application

               (developed for an earlier version of Windows)."

        Case 16

            strMessage = "Attempt was made to load a second instance of an

               executable file containing multiple data segments that were not

               marked read-only."

        Case 19

            strMessage = "Attempt was made to load a compressed executable

               file. The file must be decompressed before it can be loaded."

        Case 20

            strMessage = "Dynamic-link library (DLL) file was invalid. One of

               the DLLs required to run this application was corrupt."

        Case 21

            strMessage = "Application requires Microsoft Windows 32-bit

                extensions."

        Case Else

            While GetModuleUsage(iRet) > 0

                WaitSecond 1

            Wend

    End Select

    If flgMessage And strMessage <> "" Then

        MsgBox strMessage, MB_ICONEXCLAMATION, "Shell Error"

    End If

    RunDosApp = iRet

End Function

__________

                           Bradley S. Murray


GetModuleUsage

LUOKKA: shell

Date: 04/12/94 (10:13)              Number: 3225 of 3272 (Refer# NONE)

From: RSCHWARZ@EDCEN.EHHS.CMICH.EDU, Ron Schwarz

Subj: Re: shell() and return timing ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here is a fragment I am using, it works flawlessly with anything,

including DOS programs.  Btw, there is some stuff in there that

gets a module handle, for cases (like Pagemaker and 123/w) which

have a program that is a loader for the "real" program -- when

the loader terminates, you are finished!  So, you have to track

an alternate program -- if you know its name, it's easy, once

you get its module handle.

Ron

RunIt:

    r% = Shell(ExecDir$ + RTrim$(Item.DosName) + " " +

RTrim$(Item.Parameters), Item.WinMode)

    WatchApp$ = Item.MonitorApp

    WatchApp$ = Trim$(WatchApp$)

    If Item.Relaxed <> "Y" Then

        If Len(WatchApp$) Then

            r% = GetModuleHandle(WatchApp$)     'if we are monitoring other

              than app

        End If

        If GetModuleUsage(r%) = 0 Then

            ErrorAction = ShellFailed(RTrim$(Item.DosName))

            Do

                GoSub ExitHandler

                ErrorAction = ExitFailed()

                If ErrorAction = 0 Then End

            Loop

        End If

    End If


GetModuleUsage

LUOKKA: shell

Date: 06-19-95 (02:27)              Number: 366711 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Output from dos-windo

>Isn't there anybody who knows how to get the output from a dos-window

>into a visual basic application...

>And how to get a running dos-window to be invisible??

Here's an answer from the VB QAID

(http://www.whidbey.net/~mdixon/qaid0001.htm) which was previously

posted to the list by Kevin Albert:

Ä----CUT----Å

I got the following hidden DOS window solution from this list!

We have a .PIF file set up for our application, shell the DOS app into a

hidden window, and after 30 seconds if the DOS app has not completed we

make the DOS window visible to the user.

kevin_albert@smtpgate.mitchell.com

NOTE: GetTickCount(), GetModuleUsage(), WinExec(), FindWindow(),

ShowWindow() are API calls - declares are provided with VB installation in

the ÖWINAPI subdirectory.

     Dim iHnd as Integer

     Dim iHnd2 as Integer

     Dim iRtn as Integer

     Dim lEnd as Long

     Dim lStart as Long

     iHnd = WinExec("MYAPP.PIF", 0)     'shells to a hidden window

     lStart = GetTickCount()

     lEnd = lStart + 30000              'wait 30 seconds

     Do While GetModuleUsage(iHnd) > 0  'Loop until shelled command

concludes

       DoEvents

       If lStart + GetTickCount() > lEnd then Exit Do

     Loop

     If GetModuleUsage(iHnd) > 0 Then

       iHnd2 = FindWindow(0&, "MYAPP")   'This is the title from the .PIF

       If not isnull(iHnd2) Then

         iRtn = ShowWindow(iHnd2, 1)       'Make DOS window visible

         Do While GetModuleUsage(iHnd) > 0 'Loop until DOS app concludes

           DoEvents                        '   or user terminates it

         Loop

       Else

         iRtn = MsgBox("Unexpected Error. FindWindow got a Null handle")

       End If

     End If

  +-+-------------------------------------------------+-+-+-+

  ö&ö    From the Windows 95 Desktop of Mike Dixon    ö_öOöXö

  +-+-------------------------------------------------+-+-+-+

  ö  Windows 95 Question/Answer/Information Database & the  ö

  ö  Visual Basic 95 Question/Answer/Information Database - ö

  ö  http://www.whidbey.net/~mdixon/qaid0001.htm            ö

  ö  mdixon@whidbey.net    My excalibur BBS - (360)675-7683 ö


GetProfileString

LUOKKA: INI

Date: 07/20/94 (22:19)              Number: 12637 of 12767 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: GetProfileString problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

After posting the &H0& answer above, I thought this might

actually be a case where a more long-winded, byte-expanded

explaination was useful for extrapolating to similar problems.

Here's the info from the API help:

LPCSTR lpszEntry; /* address of entry */

**lpszEntry** Points to the null-terminated string containing the entry whose

associated string is to be retrieved. If this value is NULL, all entries in the

section specified by the lpszSection parameter are copied to the buffer

specified by the lpszReturnBuffer parameter. For more information, see the

following Comments section.

-------end clip

1. As usual, it's looking for a pointer to a string.

2. In VB, we have to use ByVal with strings passed to DLLs, NOT to

pass by val but to pass a pointer to a null terminated (C) string.

3. In this case, we need to declare the param As Any to also be

able to pass a NULL pointer.

We can take a good guess at how the underlying API code is working.

First thing it does with this param is say, "hmm, is it a NULL pointer?"

If so, I'll pass back everything.  If not NULL, then I'll deref the

pointer and use the string value at that address.

So, we can immediately rule out passing any kind of string to get what we

want.  Because no matter how null our string is, passing a string will still

result in a nonNULL pointer being passed, so the API code will say, "no, it's

not a NULL pointer, so let's go look at the string out there.  What it finds is

then a null string, which of course is not a match for any field so it just

returns the default value we specified.

That means, we just have to figure out what it will interpret

as a NULL pointer.  In this case, the param is declared as

LPCSTR which means (from the "LP" part) that it wants a long

pointer.  That means 32 bits.

So, if we try passing in a 16 bit 0 (i.e. an int) then we get

a bad DLL calling convention.  Making it a 32 bit 0& solves the

problem.  Now, we pass in the equivalent of a long NULL pointer

so the code gets all zeros, and says, "ah, it's not a valid

pointer, it's a NULL pointer, so we won't try to deref it and

look for a string, we'll just send em back everything.

gt


GetProfileString

LUOKKA: INI

Date: 07/20/94 (23:19)              Number: 12642 of 12767 (Refer# NONE)

From: JOHNC@FC.HP.COM

Subj: Re: GetProfileString problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I was  poking in the  example  programs  that came  with  "Visual  Basic

Programmer's guide to the Windows API" and saw the following line in the

filedemo.mak project:

 .

 di% = GetProfileString("devices", 0&, "", devstring, 4095)

 .

I then re-read the syntax for  GetProfileString  on page 599 and noticed

what I'd missed.  It defines lpKeyName as Any in the declare  statement,

but refers to it's value as either a string or a long.  By  placing  the

ampersand after the number 0, I effectively 'cast' it to type long.


GetProfileString

LUOKKA: INI

Date: 07/21/94 (10:23)              Number: 12686 of 12767 (Refer# NONE)

From: SYSMAS@SHORELINE.CA

Subj: GetProfileString problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

When I first started messing with VB, I discovered the fact that you

cannot use the Printer object on any printer EXCEPT the default printer,

so in order to print on anything else, you had to change the default

printer...  which, in my vaguely humble opinion, is one of the most

ridiculous and stupid things I've ever seen.

So, I set about writing a REAL printer select dialog type thingie.

Naturally, I had to have "Visual Basic Programmers Guide to the Windows

API", and after reading it and sending innumerable email to Daniel

Appleman, finally got the thing to work.

Anyway, the GetProfileString function is essential to doing the printer

select box, and I DID get it to work.  Here's the basics:

Declare Function GetProfileString% Lib "Kernel" (ByVal lpAppName$, ByVal

lpKeyName As Any, ByVal lpDefault$, ByVal lpReturnedString$, ByVal

nSize%)

    def$ = String$(128, 0)

    di% = GetProfileString%("WINDOWS", "DEVICE", "", def$, 127)

    def$ = agGetStringFromLPSTR$(def$)

Note the function agGetStringFromLPSTR$ comes with the VBPGfWA book,

and also with SpyWorks, which I highly recommend, if for no other reason

than to further bless Dan for writing his book.

Anyway, that should pluck your device names out of the WIN.INI file.

Fiddle from there.

---------------------------------------------------------------------------

  R. Campbell

  sysmas@shoreline.ca


Graphics APIs

LUOKKA: graphics

Date: 12/20/94 (12:51)              Number: 30251 of 30737 (Refer# NONE)

From: AA674@FREENET.CARLETON.CA

Subj: Re: cards, or lots of image controls

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> cards. The problem then is to copy just a portion of that control's

> picture to another control. bitblt doesn't work; it only moves bits

> on the screen, not in the control's memory. There must be some

> function similar to bitblt in the Windows API that moves images from

> controls to the screen, or to another control; it would be called by

> the VB statement img1.Picture := img2.Picture. Can anyone tell me what

> that function is?

You can bitblt from memory to screen.  Here is the code I use to load

in bitmaps from a dll.

Declare Function LoadBitmap Lib "User" (ByVal hInstance As Integer,

 ByVal lpBitmapName As Any) As Integer

Declare Function BitBlt Lib "GDI" (ByVal hDestDC As Integer,

ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer,

ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer,

ByVal YSrc As Integer, ByVal dwRop As Long) As Integer

Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As

Integer

Declare Function CreateCompatibleDC Lib "GDI" (ByVal hDC As Integer) As

Integer

Declare Function SelectObject Lib "GDI" (ByVal hDC As Integer, ByVal

Object

As Integer) As Integer

Declare Function ReleaseDC Lib "User" (ByVal hwnd As Integer, ByVal hDC

 As  Integer) As Integer

Declare Function DeleteDC Lib "GDI" (ByVal hDC As Integer) As Integer

Function LoadInBitmap (dest As control, BitmapName$) As Integer

  'this code presumes the dll is loaded with libhandle% as its handle

  Dim worked%

  LoadInDigitsBitmap% = 1 'no problems

  MemHandle% = CreateCompatibleDC(0)

  'grabs the bitmap from the dll

  BitHandle% = LoadBitmap(LibHandle%, BitmapName$)

  MemOldHandle% = SelectObject(MemHandle%, BitHandle%)

  worked% = BitBlt(dest.hDC, 0, 0, 100, 100, MemHandle%, 0, 0, SRCCOPY)

  'this removes all the allocated memory, I hope!

  worked% = SelectObject(MemHandle%, MemOldHandle%)

  worked% = DeleteDC(MemHandle%)

  LoadInDigitsBitmap% = ReleaseDC(hwnd, dest.hDC)

End Function

This code came from one of the help files (Win SDK, search for bitblt).

This code could also be used to read in the cards directly from cards.dll

Good luck,

Md

Martin Darwin, aa674@Freenet.carleton.ca (Ottawa,Ontario,Canada)


Graphics general

LUOKKA: graphics

Date: 12/22/94 (05:10)              Number: 30380 of 30737 (Refer# NONE)

From: AJM@GEAC.CO.NZ

Subj: re: advice on screen paints

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I'd just like to share something that may be useful to someone; it wasn't

obvious to me, anyway.

If you want to force child windows to repaint themselves *before* you do

some stuff in a form paint event, you *could* send a refresh method to

them. But this will unconditionally refresh them, which causes nasty

flickering. You can, however, call UpdateWindow(c.hwnd) and for each

child window hwnd, a WM_PAINT will get sent to the child but *only* if a

portion of the child's client area has been invalidated. This greatly

reduces flicker.

Once you've placated the children this way, you can draw all over their

client areas without them refreshing on you when your paint event

terminates and undoing all your good work.

I originally tried ValidateRect and all sorts of things but for some

reason that doesn't work. Ah well.

Also if you're using the Crescent CSFORM.VBX - a wonderful, amazing

control 'cause it gives you scrolling forms larger than the screen, and

don't we all want those!. I have discovered the trick to smooth

scrolling.

1. Don't ever put a DoEvents in your paint event code, if you're doing

your own graphics methods. It screws up things, even if you don't yield

inside the code doing the actual graphics methods.

2. If you have ClipControls set to false on the form, you may get

graphics methods screwed up if you swing wildly on the scrollbars. The

trick here is

(a) record the hvalue and vvalue of the scroll position whenever you get

a change event from csform i.e scrollbars have been moved. Test this

value against the current values reported by the control; if they are >

one small change (normally 15 twips) then repaint the whole form to tidy

up the mess.

(b) In form paint, keep a note of the current scroll thumb position; if

it exceeds one small change from the position recorded in (a), then

invalidate that recorded position (e.g set it to -1000,-1000 or

something). This will again force a repaint when the thumb is released.

Trick (b) is necessary because otherwise you can click on the thumb,

swing it around and carefully put it back where it was; the screen would

then be corrupted if you didn't check in form paints also.


Graphics grow letters

LUOKKA: graphics

Date: 03-05-95 (16:12)              Number: 246262 of 251087 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: drawing letters using graphics methods

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

it is quite to difficult to get an imperession that text is growing

gradually in size. You will get a small improvement to the looks of the

output if you set the scalemode to points and use a scalable (Truetype)

font. Also it looks a little bit better if the the increase in size is > 1

point.

I think if you try to do it with Pset or drawing with lines, you will just

get a very slow update of your screen.

I have attached some sample code, which also gives the impression that text

grows in size, but this time it looks like every pixel is also growing in size.

'-- Forms general section

Option Explicit

Dim OldW, OldH, OldL, OldT, OldCX, OldCY

Const Msg = "This is a stupid test..."

Sub Pause (ByVal nSecond As Single)

   Dim t0 As Single

   t0 = Timer

   Do While Timer - t0 < nSecond

      Dim dummy As Integer

      dummy = DoEvents()

      ' if we cross midnight, back up one day

      If Timer < t0 Then

         t0 = t0 - 24 * 60 * 60

      End If

   Loop

End Sub

'--- appropriate subs

Sub Form_Load ()

Dim CX, CY ' Declare variables.

   Me.Show

   'Make "bitmap" into picture box

   Picture1.Visible = False

   Picture1.AutoRedraw = True

   Picture1.ScaleMode = 2   ' Set ScaleMode to points.

   Picture1.ForeColor = QBColor(4)  ' Set foreground to red.

   Picture1.FontName = "Arial"

   Picture1.FontSize = 10   ' Set point size.

   CX = Picture1.ScaleWidth / 2 ' Get horizontal center.

   CY = Picture1.ScaleHeight / 2    ' Get vertical center.

   Picture1.CurrentX = CX - Picture1.TextWidth(Msg) / 2  ' Horizontal position.

   Picture1.CurrentY = CY - Picture1.TextHeight(Msg) / 2' Vertical position.

   Picture1.Print Msg

   'Set and save image control's size and position

   Image1.Width = Picture1.Width

   Image1.Height = Picture1.Height

   Image1.Picture = Picture1.Image

   OldW = Image1.Width

   OldH = Image1.Height

   OldL = Image1.Left

   OldT = Image1.Top

   OldCX = OldL + OldW / 2

   OldCY = OldT + OldH / 2

End Sub

Sub Timer1_Timer ()

Dim i

Image1.Visible = False

Image1.Left = OldL

Image1.Top = OldT

Image1.Width = OldW

Image1.Height = OldH

For i = 1 To 30

   Image1.Visible = False

   Image1.Width = Image1.Width + 12 * Screen.TwipsPerPixelX

   Image1.Height = Image1.Height + 4 * Screen.TwipsPerPixelX

   Image1.Left = OldCX - Image1.Width / 2

   Image1.Top = OldCY - Image1.Height / 2

   Image1.Visible = True

   Call Pause(.2)

Next i

End Sub


Graphics new Wing API

LUOKKA: graphics

23403 (99+)  jreynd@rt66.com  02.07.95  17:12

"Re: vb games (sound & graphics) WinG API Declares"

>  >David Kirtley <kirtley@sabecon.vt.com> wrote:

>  >...

>  >> Using this technique I have been working on some animations that are

>  >>just as fast as anything (not WinG, haven't had time) compiled to native

>  >>code.  With a DX66, modest by today's standards, I have to put in a 3

to

>  >>5k time delay loop just to see the animations (using 50x50 pixel BMP).

Äyou should be using a timerÅ

ÄTimer code deletedÅ

>  >

>  >Sorry to go soapbox on you, but a hard loop wastes computer time and

>  >is very very very unreliable.  If you need a more accurate time, you

>  >COULD take out the DoEvents, but I advise against it.

>  Agreed.  I am planning to have multiple animated sprites simultaneously

>  active and the overhead of the multiples will slow me down enough.

That was my point in the original post.  I have over 60 60x60 active sprites,

drawn from 15 bitmaps (using a mask  = 30 bitmaps).  I solved my own

problem.  I used WinG.  On my system it was many times SLOWER using

WinG bitmaps and Wing Block transfers.  On a lark I switched to GDI block

transfers with the WinG bitmaps, and things sped up significantly.  Now it's

faster than it was before, but it's still not as fast as all the HYPE said it was.

>  Just

>  for testing the animations to see how smooth the graphics act it was just

>  easier to drop in a for next to check them.  But the whole point was the

>  fact that until you get lots of stuff active at once, VB can handle the

>  animation quite nicely.

>  By the way, does anyone already have the API declares made for WinG?

>  Just d/l'ed the package from Microsoft and havent had much time to do

>  anything yet.

Here's the API declares.  I found them in two separate magazines, not to

mention the WinG file you downloaded.

---------------  WinG       Declares  ---------------------------------------

Option Explicit

'Win-G Function Declarations

'****************************************************

Global Const NrPalEntries = 256

Global Const BI_RGB = 0&

Global Const GMEM_ZEROINIT = &H40

Global Const GMEM_MOVEABLE = &H2

'WingDC and WinGBitmap

Declare Function WinGCreateDC Lib "WinG.DLL" () As Integer

Declare Function WinGRecommendDIBFormat Lib "WinG.DLL" (pFormat As

BitMapInfo) As Integer

Declare Function WinGCreateBitmap Lib "WinG.DLL" (ByVal WinGDC As

Integer, pHeader As BitMapInfo, ByVal ppBits As Any) As Integer

Declare Sub WinGGetDIBPointer Lib "WinG.DLL" (ByVal WinGBitmap As

Integer, ByVal pHeader As Any)

Declare Function WinGGetDIBColorTable Lib "WinG.DLL" (ByVal WinGDC As

Integer, ByVal StartIndex As Integer, ByVal NumberOfEntries As Integer,

ByVal pColors As Any) As Integer

Declare Function WinGSetDIBColorTable Lib "wing.dll" (ByVal WinGDC As

Integer, ByVal StartIndex As Integer, ByVal NumberOfEntries As Integer,

ByVal pColors As Any) As Integer

Declare Function AnsiNext Lib "User" (ByVal lpString As String) As Long

Declare Function AnsiNextbynum Lib "User" Alias "AnsiNext" (LpNum As

Any) As Long

Declare Function GetObjectApi Lib "GDI" Alias "GetObject" (ByVal hObject

As Integer, ByVal nCount As Integer, ByVal lpObject As Long) As Integer

Declare Function GlobalAlloc% Lib "Kernel" (ByVal wFlags%, ByVal NrBytes&)

Declare Function GlobalLock& Lib "Kernel" (ByVal hMem%)

Declare Function GetDIBits% Lib "GDI" (ByVal aHDC%, ByVal hBitMap%,

ByVal nStartScan%, ByVal nNumScans%, ByVal lpBits$, lpBI As BitMapInfo,

ByVal wUsage%)

Declare Function GetDIBitsByNum% Lib "GDI" Alias "GetDiBits" (ByVal

aHDC%, ByVal hBitMap%, ByVal nStartScan%, ByVal nNumScans%, ByVal

lpBits&, lpBI As BitMapInfo, ByVal wUsage%)

Declare Function GlobalUnlock% Lib "Kernel" (ByVal hMem%)

Declare Function GlobalFree% Lib "Kernel" (ByVal hMem%)

Declare Function GetSystemPaletteEntries% Lib "GDI" (ByVal hDC%, ByVal

wStartIndex%, ByVal wNumEntries%, lpPaletteEntries As PaletteEntry)

Declare Function GetPaletteEntries% Lib "GDI" (ByVal hPalette%, ByVal

wStartIndex%, ByVal wNumEntries%, lpPaletteEntries As PaletteEntry)

Declare Function Rectangle% Lib "GDI" (ByVal hDC%, ByVal X1%, ByVal

y1%, ByVal x2%, ByVal y2%)

Declare Sub hmemcpyBynum Lib "Kernel" Alias "hmemcpy" (ByVal hpvDest&,

ByVal hpvsource&, ByVal cbCopy%)

'Halftoning

Declare Function WinGCreateHalftonePalette Lib "WinG.DLL" () As Integer

Global Const WING_DISPERSED_4X4 = 0

Global Const WING_DISPERSED_8X8 = 1

Global Const WING_CLUSTERED_4X4 = 2

Declare Function WinGCreateHalftoneBrush Lib "WinG.DLL" (ByVal context

As Integer, ByVal crColor As Long, ByVal DitherType As Integer) As Integer

'Blits

Declare Function WinGBitBlt Lib "WinG.DLL" (ByVal hdcDest As Integer,

ByVal nXOriginDest As Integer, ByVal nYOriginDest As Integer, ByVal

nWidthDest As Integer, ByVal nHeightDest As Integer, ByVal

hdcSrc As Integer, ByVal nXOriginSrc As Integer, ByVal nYOriginSrc As

Integer) As Integer

Declare Function WingStretchBlt Lib "WinG.DLL" (ByVal hdcDest As Integer,

ByVal nXOriginDest As Integer, ByVal nYOriginDest As Integer, ByVal

nWidthDest As Integer, ByVal nHeightDest As Integer, ByVal hdcSrc As

Integer, ByVal nXOriginSrc As Integer, ByVal nYOriginSrc As Integer,

ByVal nWidthSrcAs Integer, ByVal nHeightSrc As Integer) As Integer

'Standard Windows API calls

Declare Function LoadBitMap Lib "User" (ByVal Instance As Integer, ByVal

BitmapName As String) As Integer

Declare Function GetActiveWindow% Lib "User" ()

Declare Function SaveDC% Lib "GDI" (ByVal hDC%)

Declare Function RestoreDC% Lib "GDI" (ByVal hDC%, ByVal nSavedDC%)

Declare Function GetParent% Lib "User" (ByVal hwnd%)

------------------- End WinG Declares ------------------------------------


Graphics painting only

LUOKKA: graphics

Date: 12/30/94 (07:00)              Number: 31196 of 31236 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Updating only newly exposed area of a picture box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> I'm asking for some help. I wrote an application that displays

> complicated graphics on a picture box,  with AutoRedraw = False (I have to

> set AutoRedraw to False because I use the PolyLine API function to draw

> directly to the picture box's device context). When a Common Dialog box,

>or a Message box covering the picture box is unloaded, only the part that

>was formerly covered is updated. It doesn't seem that the Paint method is

>invoked.

First of all, yoiu can make the picture persistent by setting AutoRedraw to

True before drawing and AutoRedraw to False when you're finished drawing.

There's no reason to set AutoRedraw to False if you're using API-calls that

use the hDc of the picturebox, because they will draw on the persistent

bitmap when AutoRedraw = True. The image will not be displayed until you

set AutoRedraw to False though...

> However, unloading a form covering part of the picture box triggers a

> Paint event, which replays the entire drawing sequence, and therefore

> reupdates the whole picture box. This process, of course, takes time. Is

>there one way to force reupdating only the newly exposed area of a picture

>box, when

> a form covering the picture box is unloaded, just as it happens with a

>Message Box? Thank you for your answers.

VB doesn't handle Paint events properly. Paint events are only generated

when a VB form or dialog is (re)moved over your form. The best way to deal

with 'real' Paint events (windows sending WM_PAINT) is to trap the

WM_PAINT message yourself with the MessageBlaster custom control for

example. Simply eat all the WM_PAINTS and perform your drawing on a DC

obtained by the BeginPaint function. This will redraw only the uncovered part

of the window. Pseudocode example:

Declare function BeginPaint ....

Declare Function EndPaint ...

Type PAINTSTRUCT

    .....

End Type

Sub MsgBlast1_Message(Msg, wParam, lParam, lReturn)

Dim ps As PAINTSTRUCT

Dim iHDc As Integer

        iHDc = BeginPaint(Picture1.hWnd, ps)

        ' Do all the painting here (on iHDc)

        EndPaint(Picture1.hWnd, ps)

End Sub

Arjen

--

Arjen Broeze                                   Telephone: (+31)53-338666

arjen@shear.iaf.nl                             Address:   Gronausevoetpad 104


Graphics timer & chang

LUOKKA: graphics

Date: 07-12-95 (21:42)              Number: 385894 of 386776 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Automatic redraws with Graph control

From: Lasse Rantanen <lasse@RANTANE.PP.FI>

>I'm writing an application that has a graph control being updated at

>fixed intervals.  The data for the graph is constantly changing, but the

>graph will only show the data state as it was when the control was first

>painted.

>I've tried using the refresh method and the datareset property.  Since

>the graph information is taken from a grid, I've tried updating the graph

>using the Quickdata (=grid1.clip) and graphdata properties.

>I must be missing something basic here. Can anyone render some

>assistance?

>

>Scott Syms

>ssyms@fox.nstn.ca

here's as example a silly little program which changes graphdata with timer.

To run it place a graph control and a timer on your form. Set timer interval

e.g. to 1000.

When setting AutoInc=1 use following

Sub Timer1_Timer ()

   Dim i%

   Graph1.DataReset = 1

   Graph1.AutoInc = 1

   For i% = 1 To (Graph1.NumSets * Graph1.NumPoints)

      Graph1.GraphData = Rnd 'Put here your actual data

   Next i%

   Graph1.DrawMode = 2

End Sub

If you don't use Autoinc then use following

Sub Timer1_Timer ()

   Dim i%, j%

   Graph1.ThisSet = 1

   For i% = 1 To Graph1.NumSets

      Graph1.ThisPoint = 1

      For j% = 1 To Graph1.NumPoints

         Graph1.GraphData = Rnd 'Put here your actual data

      If Graph1.ThisPoint < Graph1.NumPoints Then

         Graph1.ThisPoint = Graph1.ThisPoint + 1

      End If

      Next j%

      If Graph1.ThisSet < Graph1.NumSets Then

         Graph1.ThisSet = Graph1.ThisSet + 1

      End If

   Next i%

   Graph1.DrawMode = 2

End Sub

     Lasse


Graphics transition

LUOKKA: graphics

Date: 01/02/95 (11:25)              Number: 31394 of 31509 (Refer# NONE)

From: JCCOMNI@AOL.COM

Subj: Re: Transition Effects

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>> I need to create some transition effects, or wipes without using a

special vbx.

>> Sometimes the wipe will be for part of the form, other times the whole

thing.

>> Any ideas?

Use a picture box. First use BitBlt to copy the portion of the form for

wich you want the transition effect to take place to an invisible picture

box that has the AutoRedraw set to true. Then place another picture box

over the portion of the form that was copied. Now use BitBlt again to copy

portions of the invisible picture box to the visible picture box. This way

you can simulate the original contents of that portion of the form, yet

use standard drawing methods to code your transitions.

I've used this technique many times. It is fast and efficient. Many people

are surprised by the results I have achieved using it.


Grid alignment

LUOKKA: grid

Date: 03-13-95 (12:26)              Number: 255518 of 256940 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Right alignment from Grid??

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>>format$(format$(mynumbers, "#####"), "@@@@@")

>

>Thanks for your suggestion! I've tried this out, with the

>same result:

>

>Sub Form_Load ()

>

>Show

>format$(format$(1, "#####"), "@@@@@")

>format$(format$(23, "#####"), "@@@@@")

>format$(format$(-123, "#####"), "@@@@@")

>

>end sub

>

>(the same result as with:

>format$(1, "#####")

>format$(23, "#####")

>format$(-123, "#####")   )

>

>The problem is caused by the fact that I use a non-fixed-width

>font (MS Sans Serif). When I change to Courier, everything

>is all right.

>

>So my problem is really:

>

>How to produce a nice "decimal tab"-effect ("right alignment")

>at a given tab position, when using a non-fixed-width font?

>I'd liked to have my columns look like the courier columns

>also when I use MS Sans Serif or Arial, or any other font:

>

>   1

>  23

>-123

>

>and not something like

>

>   1

>  12

> -123

>

you could try following routine. I wrote it to print into a picture box, but

you can modify it to print into printer. Next modification is to make it a

callable Sub supplying X and Y start positions as parameters, I guess. The

routine copies the grid as such (no grodlines), but you can easily modify it

to use different font(size), add tabbing etc. I hope this gives you one

approach to solve your problem.

Sub Command1_Click ()

   Dim prnXPos As Integer

   Dim prnYPos As Integer

   Dim i As Integer, j As Integer

   Picture1.FontName = Grid1.FontName

   Picture1.FontSize = Grid1.FontSize

   Picture1.FontBold = Grid1.FontBold

   Picture1.FontItalic=Grid1.FontItalic

   prnYPos = 0

   For i = 0 To Grid1.Rows - 1

      Grid1.Row = i

      prnYPos = prnYPos + Grid1.RowHeight(i)

      prnXPos = 0

      For j = 0 To Grid1.Cols - 1

         Grid1.Col = j

         If i < Grid1.FixedRows Or j < Grid1.FixedCols Then

            If Grid1.FixedAlignment(j) = 1 Then

               Picture1.CurrentX = prnXPos + Grid1.ColWidth(j) -

Picture1.TextWidth(Grid1.Text)

            ElseIf Grid1.FixedAlignment(j) = 2 Then

               Picture1.CurrentX = prnXPos + Grid1.ColWidth(j) ™ 2 -

Picture1.TextWidth(Grid1.Text) ™ 2

            Else

               Picture1.CurrentX = prnXPos

            End If

         Else

            If Grid1.ColAlignment(j) = 1 Then

               Picture1.CurrentX = prnXPos + Grid1.ColWidth(j) -

Picture1.TextWidth(Grid1.Text)

            ElseIf Grid1.ColAlignment(j) = 2 Then

               Picture1.CurrentX = prnXPos + Grid1.ColWidth(j) ™ 2 -

Picture1.TextWidth(Grid1.Text) ™ 2

            Else

               Picture1.CurrentX = prnXPos

            End If

         End If

         Picture1.CurrentY = prnYPos

         Picture1.Print Grid1.Text

         prnXPos = prnXPos + Grid1.ColWidth(j)

      Next j

   Next i

End Sub


Grid loading

LUOKKA: grid

From: M_MILIS@PAVO.CONCORDIA.CA

Subj: Re: What's fastest way to load up a grid w/ data?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <30mcvs$jf0@bigblue.oit.unc.edu> tihan@gibbs.oit.unc.edu

(Tihan Gabriel Seale) writes:

>I'm trying to fill a grid control with data from a database for a

>browse-like view of the info. So far my best algorithm takes 7 seconds to

>load up 200 records on a 486-33 (rather long to ask an impatient user to

>wait).

>Do Until ds.EOF                         'repeat the loop for all records

>  i = i + 1                             'increment a counter (not vital)

>  For ii = 0 To ds.Fields.Count - 1     'loop for each field in record

>    myGrid.Col = ii                     'moves to available grid cell

>    myGrid.Text = ds.Fields(ii).Value   'puts the data in the cell

>  Next ii

>  ds.MoveNext                           'move to the next dynaset record

>  myGrid.Rows = myGrid.Rows + 1         'adds a blank row to the grid

>  myGrid.Row = myGrid.Row + 1           'moves to that row

>Loop

>This takes about 10 seconds. My better one reads the fields into a

>tab-delineated string variable that gets dumped to the grid every 5

>records via the "clip" method. (increasing it more than 5 seems to slow

>it down).

I beleive the above code will run faster if written like this:

iFldCnt = ds.Fields.Count - 1  'no need to figure this out in the loop

ds.MoveLast

myGrid.Rows = ds.RecordCount   'we do not want to change Rows every loop

ds.MoveFirst

Do Until ds.EOF

  i = i + 1

  For ii = 0 To iFldCnt

    myGrid.Col = ii

    myGrid.Text = ds.Fields(ii).Value

  Next ii

  ds.MoveNext

  myGrid.Row = i               'assuming i was 0 and Row is 1-based in Grid?

Loop

The difference may not be measurable or significant. I do not use Grid, but if

the screen is redrawing while you are adding records, then that is 90% of

your time going there - you must find a way to stop it from doing that (make it

invisible while populating it)

-----------------------------------------------------

Marko Milisavljevic

m_milis@pavo.concordia.ca

Montreal, Canada


Grid placing bitmap

LUOKKA: grid

Date: 12/11/94 (05:48)              Number: 29496 of 29531 (Refer# NONE)

From: ROYFRAN@STATCAN.CA

Subj: Re: "Special" List boxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: Does anyone know of a list box vbx (or code) that allows

: a tiny bitmap to be beside the text, similar to the file list, etc...

 The GRID.VBX that comes with VB3 will let you put both text and a bitmap

in the same cell.  A single-column grid could be used to simulate a list box.


Hex to Dec

LUOKKA: numbers

Date: 11/22/94 (10:01)              Number: 27529 of 27719 (Refer# NONE)

From: SUSSMAN@ENVMSA.EAS.ASU.EDU, Mike Sussman

>Hi, Is there any .DLL  convert Hex value to Decimal Value ?

>Thanks .

---------------------------------------------------------------------------

Function Hex_to_Dec (hexstr$) as String

Dim digit_value%, index%

Dim total&

Dim hex_values$

  hex_values$ = "0123456789ABCDEF"

  total& = 0

  for index% = 1 to Len(hexstr$)

    digit_value% = Instr(hex_values$,Mid$(hexstr$,index%,1),1) - 1

    total& = (total& * 16) + digit_value%

  next index%

  Hex_to_Dec = LTrim$(Str$(total&))

End Function


Hex to Dec

LUOKKA: numbers

3514 (48+)  jeremi@crl.com  21.01.95  11:08

William Jeremiah: "Re: HEX TO DEZ ???"

: Can Anyone tell how to convert hexadezimal values  to dezimal ones?

Function H(Hex_Number as String) as Integer

Dim Index as Integer

Decimal_Number=0

for Index=1 to Len(Hex_Number)

Select Case UpCase$(Mid$(Hex_Number,Index,1))

Case "0": Hex_Equivalent=0

Case "1": Hex_Equivalent=1

Case "2": Hex_Equivalent=2

Case "3": Hex_Equivalent=3

Case "4": Hex_Equivalent=4

Case "5": Hex_Equivalent=5

Case "6": Hex_Equivalent=6

Case "7": Hex_Equivalent=7

Case "8": Hex_Equivalent=8

Case "9": Hex_Equivalent=9

Case "A": Hex_Equivalent=10

Case "B": Hex_Equivalent=11

Case "C": Hex_Equivalent=12

Case "D": Hex_Equivalent=13

Case "E": Hex_Equivalent=14

Case "F": Hex_Equivalent=15

End Select

Decimal_Number=Decimal_Number*16+Hex_Equivalent

Next

What this does is say the string was "1e4f2"

then you would get: (((((0*16+1)*16+14)*16+4)*16+15)*16+2 = 124146

Jerry


Hex to Dec

LUOKKA: string

Date: 05/02/94 (23:36)              Number: 5027 of 5181 (Refer# NONE)

From: EDSTAFF@MCS.COM

Subj: Re: HEX to DECIMAL

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2qbe5d$mqq@kasey.umkc.edu> atrehan@CSTP.UMKC.EDU (Tony

Trehan) writes:

>If I get a STRING that represents a HEX number (without any preceeding

>&H or 0x...) how do I get its DECIMAL value?

Easy,

     CLng("&H" &"FF")

will get you 255.

Later ... Ed


Hinstance to hWnd

LUOKKA: shell

Date: 01/04/95 (09:43)              Number: 31550 of 31612 (Refer# NONE)

From: MZ@IX.NETCOM.COM

Subj: Re: How to convert HINSTANCE to hWnd

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In <3e9851$idg@scapa.cs.ualberta.ca> signorin@falun.cs.ualberta.ca (Kent

Signorini) writes:

>  I have posted a number of postings on killing shelled processes

>(asking for help with this.)  I have now found a number of ways on

>doing this, but they all require that I have the hWnd for the window I

>want to kill.  Since I only have the HINSTANCE for the shelled process,

>I cannot use any of the methods I have found.

>

>  Here is the bottom line question (I hope that someone has the

>answer):

>

>      If I have the HINSTANCE of a window, how do I find its hWnd?

>

>Any help is greatly appreciated,

The simple answer is that there is no simple answer.  The problem is

that there is not necessarily any hWnd associated with a single

hInstance.  However, there are usually several hWnd handles for each

hInstance.

I have two ideas for you.  If I remember the earlier articles, you are

trying to obtain the hWnd of a Shelled application, so that you can use

SendKeys to post an ALT-F4, which you hope will close the shelled

application.  For a variety of reasons, this is not a particularly easy

task.

The simplest way to find the hWnd is with the FindWindow() API call.

You mentioned in an earlier posting that you could not use this because

you did not know the window name.  My first idea is that you would

probably have better luck looking for the window class.  You will

probably have to use a spy utility to determine the window class name,

but the class name usually does not change for a given application.

Here are the class names of some common applications:

  Access                    OMain

  Calculator                SciCalc

  Calendar                  Calendar

  Cardfile                    Cardfile

  Excel                       XLMAIN

  File Manager            WFS_Frame

  MS DOS (OLDAPP)   tty

  MS Mail                   MS Mail Appframe

  MS Office 4.2           MSOfficeWClass

  MS Project 4.0         JWinProj-WhimperMainClass

  MS Word 6.0           OpusApp

  Notepad                  Notepad

  Paintbrush               pbParent

  Power Point             PPApplicationClass

  Program Manager     Progman

  Solitaire                  Solitaire

  Terminal                  Terminal

  Visual BASIC           ThunderForm, ThunderRTMain

  Write                       MSWRITE_MENU

Use hWnd = FindWindow( ByVal <<your class name>>, 0&)

My second idea is to walk the windows heirarchy, looping through

all the top-level windows in the system.  This can be accomplished using

the GetWindow(hWnd, GW_HWNDFIRST and GW_HWNDNEXT) API.  For

each top level window, you can use the GetWindowWord(hWnd,

GWW_HINSTANCE) API to retrieve the instance handle to which that

top-level window belongs. Eventually, you should find a top-level window

which matches the hInst you wish to 'kill'.

Now for the problems.

1) Applications do not always terminate when ALT-F4 is sent.  For

instance, MS DOS program do not respond in this way.

2) In order to kill an application, you may need to send ALT-F4 to one

or more dialogs, MDI Child Windows, etc.

3) In the process of responding to ALT-F4, many applications will pop up

a dialog box (Do you really want to quit?).  You may need to detect

this, and send a ALT-Y, ENTER, whatever.

Subtler problems.

1) If you use the first method, you may find a window that belongs to

another instance of the application you shelled.  It could be an

instance of the application which was independantly started by the user

from Program Manager.

2) A few programs (Lotus Notes, MS-Mail) spawn additional process.

Therefore, the hInst returned from Shell() is not necessarily sufficient

to completely clean up the application.

3) If you use the second method, the first top-level window you find may

not be the window that needs ALT-F4.

4) You will have to be careful of what might happen if the user closes

the shelled application during your processing.

To avoid some of these problems, you might want to investigate use of

the OLE 2.0 control which comes with VB Professional.

Hope this helps

Mike Z.


Hmemcpy copying

LUOKKA: API

Date: 02/13/95 (12:17)              Number: 224891 of 225504 (Refer# NONE)

  To: MATTI HARJU

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: laying down a structure

How to Re-Map in Visual Basic:

Applications programs often have to deal with a situation where a data file

contains records of different type - Header Records, Detail Records, Trailer

Records etc.

In C (or in other flavours of BASIC) you can identify the record type, and

move the entire record to an appropriate work area.

In VB, if you're using structures, the traditional way of doing the move was

to have a battery of statements of type:

Sal_Rec.Sal_No09 Mid$(RecordString,1,2)

Sal_Rec.E_Name09 Mid$(RecordString,3,32)

Sal_Rec.Grade09 Mid$(RecordString,35,4) etc.

There is a neater way of doing this, using the hmemcpy

function in the KERNEL Library.

I am indebted to  Luke Webber <webber@werple.apana.org.au> for helping

me in this.

Here's the example, showing how to copy from structure to structure, and

from

string to/from structure. Load it up, fire it off, click the option buttons,

and read the code.

--------------------------------------------copyx.mak-------------------

COPYX.FRM

COPYX.BAS

ProjWinSize==81,437,200,326

ProjWinShow==2

IconForm=="Form1"

--------------------------------------------copyx.frm----------------=

VERSION 2.00

Begin Form Form1=20

   Caption         ==   "Form1"

   ClientHeight    ==   2340

   ClientLeft      ==   1005

   ClientTop       ==   2055

   ClientWidth     ==   7365

   Height          ==   2745

   Left            ==   945

   LinkTopic       ==   "Form1"

   ScaleHeight     ==   2340

   ScaleWidth      ==   7365

   Top             ==   1710

   Width           ==   7485

   Begin Frame Frame1=20

      Height          ==   1815

      Left            ==   4200

      TabIndex        ==   2

      Top             ==   120

      Width           ==   2775

      Begin OptionButton Option3=20

         Caption         ==   "String to Structure 1"

         Height          ==   300

         Left            ==   100

         TabIndex        ==   5

         Top             ==   1320

         Width           ==   2550

      End

      Begin OptionButton Option2=20

         Caption         ==   "Structure 2 to String"

         Height          ==   300

         Left            ==   100

         TabIndex        ==   4

         Top             ==   720

         Width           ==   2550

      End

      Begin OptionButton Option1=20

         Caption         ==   "Structure 1 to Structure 2"

         Height          ==   300

         Left            ==   100

         TabIndex        ==   3

         Top             ==   240

         Width           ==   2550

      End

   End

   Begin TextBox Text1=20

      Height          ==   1695

      Left            ==   960

      MultiLine       ==   -1  'True

      TabIndex        ==   1

      Top             ==   240

      Width           ==   3135

   End

   Begin CommandButton Command1=20

      Caption         ==   "end"

      Height          ==   615

      Left            ==   240

      TabIndex        ==   0

      Top             ==   240

      Width           ==   615

   End

End

Option Explicit

Declare Function hmemcpy Lib "kernel" (Destination As Any, Source As =

Any, ByVal BytesToCopy As Long) As Long

Dim Test1 As MyType1

Dim Test2 As MyType2

Dim TestString As String * 20

Dim return_status As Long

Dim CRLF As String

Sub Command1_Click ()

    End

End Sub

Sub Form_Load ()

    CRLF == Chr$(13) + Chr$(10)

End Sub

Sub Option1_Click ()

    Test1.Strg1_1 == String(10, "1")

    Test1.Strg1_2 == String(10, "a")

    return_status == hmemcpy(Test2, Test1, 20)

    text1.Text == "Structure 2:" + CRLF + Test2.Strg2_1 + CRLF + Test=

2.Strg2_2

End Sub

Sub Option2_Click ()

    Test2.Strg2_1 == String(5, "2")

    Test2.Strg2_2 == String(15, "b")

    return_status == hmemcpy(ByVal TestString, Test2, 20)=09'NOTE BYV=

AL ON STRING

    text1.Text == "Test String" + CRLF + TestString

End Sub

Sub Option3_Click ()

    TestString == String(20, "S")

    return_status == hmemcpy(Test1, ByVal TestString, 20)=09'NOTE BYV=

AL ON STRING

    text1.Text == "Structure 1:" + CRLF + Test1.Strg1_1 + CRLF + Test=

1.Strg1_2

End Sub

--------------------------------------------copyx.bas----------------=

---------

Option Explicit

Type MyType1

    Strg1_1 As String * 10

    Strg1_2 As String * 10

End Type

Type MyType2

    Strg2_1 As String * 5

    Strg2_2 As String * 15

End Type

---------

note the ByVal on Strings (thanks Luke!)

Eoin Bair=E9ad

e.bairead@decus.ie


Hmemcpy with arrays

LUOKKA: arrays

Date: 10/22/94 (21:28)              Number: 24098 of 24188 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Copying 2D Array to 1D Array

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

dexter@chem.surrey.ac.uk (Matthew Dexter) writes:

>Can anyone suggest a reliable method for doing the following.

>Dimension an array x to be two dimensional.

>                 Dim x(4,10)

>then dimension another array 1 to be one dimensional

>                 Dim y(10)

>Copy one 'column' from array x into array y without copying in each

>individual element. I.e. using some kind of block copy- I want to do

>this for performance reasons.

> I have thought of using the hmemcpy API call but the results which I get

>back are unpredictable. I suspect that the reason for this is that VB

>arrays are stored in a special format. If anyone can  shed any light

>on this problem I will be most grateful.

You've nearly got it. Believe it or not, VB uses Column-major arrays, so

you should be using Dim x(10, 4), then hmemcpy should work just fine.

Dunno why they use column-major when most of the DLLs are in C

(row-major), but it just goes to prove that VB is a Windoze product, I

gues ;^).

--

Luke Webber


Hotkey in menus

LUOKKA: hotkey

Date: 04/11/94 (13:19)              Number: 3163 of 3179 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Pop-up Menus Hot-keys

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 04-10-94 TT17+@ANDREW.CMU.EDU  wrote:

T>I don't know if this is a bug (isn't listed if it is), or if VB just

T>doesn't allow for Hot-keys (or Alt-Key combinations) when the

T>"visible" checkbox is unchecked for a menu.  Since the users of my

T>program want a Hot-Key for the Pop-up menu, I'm trying to implement

T>this for them.  Anyone know about this?

Create a keyhandler on the form and call it from there.  Use the

ALT_MASK constant as follows (look in VB.HLP under "KeyDown"):

 Const ALT_MASK = 4

 AltDown = (Shift And ALT_MASK) > 0

 If AltDown Then ...

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatetot.com


Html->hlp

LUOKKA: WinHelp

6443 (1+)  rloewy@panix.com  18.07.95  16:47

Ron Loewy: "Re: html -> hlp"

Please check the "New and Exciting" link under our home page at

http://www.hyperact.com for the anouncement about our HTML -> WinHelp

conversion tool.

Ron.


hWnd ... to HINSTANCE

LUOKKA: shell

Date: 01/17/95 (23:48)              Number: 32813 of 33020 (Refer# NONE)

From: MORGANJE@STRAUSS.UDEL.EDU

Subj: Re: How to convert HINSTANCE to hWnd

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>>   I have posted a number of postings on killing shelled processes (asking

>>for help with this.)  I have now found a number of ways on doing this, but

>>they all require that I have the hWnd for the window I want to kill.  Since I

>>only have the HINSTANCE for the shelled process, I cannot use any of the

>>methods I have found.

>>

>>   Here is the bottom line question (I hope that someone has the answer):

>>       If I have the HINSTANCE of a window, how do I find its hWnd?

>>

>The only way I found to determine the hwnd of a shelled process, is to wait

>a little (couple of DoEvents calls) and then call the GetActiveWindow API

>which returns the hWnd of the active application.

>

>If anyone has a better method of finding the hWnd of a shelled process, I'd

>be very pleased to hear about that.

>

>Arjen

This routine seems to work. See if it helps.....

Sub WHndFromIHnd (InstanceHandle As Integer)

    Const GW_HWNDNEXT = 2

    Const GWW_HINSTANCE = (-6)

    Const GW_CHILD = 5

Dim counter As Integer

Dim ChildWinHAndle As Integer

Dim CurrentInstance As Integer

Dim CurrentWinHandle As Integer

Dim ErrorCode As Integer

Dim LastWinHandle As Integer

Dim MyText As String * 50

'CBegin Execution

    CurrentInstance = 0

    CurrentWinHandle = GetActiveWindow()

    CurrentInstance = GetWindowWord(CurrentWinHandle,

GWW_HINSTANCE)

    counter = 0

    Do While (CurrentInstance <> InstanceHandle)

        LastWinHandle = CurrentWinHandle

        CurrentWinHandle = GetNextWindow(LastWinHandle,

GW_HWNDNEXT)

        CurrentInstance = GetWindowWord(CurrentWinHandle,

GWW_HINSTANCE)

        ErrorCode = GetWindowText(CurrentWinHandle, MyText, 50)

        MyText = Left$(MyText, ErrorCode)

        MsgBox MyText

        If Trim$(UCase$(MyText)) = "WORLDVIEW" Then

            ChildWinHAndle = GetTopWindow(CurrentWinHandle)

            Do While ChildWinHAndle <> 0

                ErrorCode = GetWindowText(ChildWinHAndle, MyText, 50)

                MsgBox Left$(MyText, ErrorCode)

                ChildWinHAndle = GetWindow(ChildWinHAndle, GW_CHILD)

            Loop

        End If

        counter = counter + 1

        If counter > 100 Then 'give it 1000 tries. If it cannot find it,

its probably a problem !!

            ErrorCode = MsgBox("Cannot Find Window for this

Application"                 End If

    Loop

End Sub

As you notice I had to hardocde the WindowText of the Window I am looking

or, but you could parameterize it. I used this for some debugging, so that's

why there is a message box on the window handle and name.

JEM


Hwnd parent/child

LUOKKA: API

13313 (143+)  jeremi@crl.com  11.04.95  08:04

William Jeremiah: "hWnd tree doesn't work?!"

I am trying to look for a certain hWnd with a known hInst. I got this code

from someone on this group and modified it slightly.  But I have noticed

certain anomolies.  Can someone shed some light on this?

What it does is sometimes child windows show up as a sibling. This is bad

because I need to find the top window with a particular hInst and this

problem makes a chile window show up first sometimes.

Also can anybody tell me whether I should be building the tree by owner

instead of parent (since apparently they are the same thing)

Can someone please tell me how to get the top window with a particular

hInst?

Although I only showed the first bit it happens the same two or three times.

Here is the first bit of output I get:

hWnd:  3724  Parent:  0  Owner:  0

Title:

EXE: C:™WINDOWS™SYSTEM™USER.EXE

hInst:  5862

     hWnd:  3788  Parent:  0  Owner:  0

     Title:

     EXE: C:™WINDOWS™SYSTEM™USER.EXE

     hInst:  5862

     hWnd:  11212  Parent:  0  Owner:  0

     Title: PROJECT1

     EXE: D:™PROJECT1.EXE                         <= this is my program!

     hInst:  9598

     hWnd:  3960  Parent:  5080  Owner:  5080

     Title:

     EXE: C:™WINDOWS™SYSTEM™USER.EXE              <= now how did this

get here

     hInst:  5614                                    It should be down here

     hWnd:  5080  Parent:  0  Owner:  0

     Title: Program Manager

     EXE: C:™WINDOWS™PROGMAN.EXE

     hInst:  5614

                                                  <--------------+

          hWnd:  5196  Parent:  5080  Owner:  0

          Title:

          EXE: C:™WINDOWS™SYSTEM™USER.EXE

          hInst:  5614

               hWnd:  11704  Parent:  5196  Owner:  0

               Title: temp

               EXE:

               hInst:  5614

And here is the code:

Option Explicit

Type RECT

  left As Integer

  top As Integer

  right As Integer

  bottom As Integer

End Type

Type POINTAPI       ' Stores location of cursor

  X As Integer

  Y As Integer

End Type

Type WINDOWPLACEMENT

    length As Integer

    flags As Integer

    showCmd As Integer

    ptMinPosition As POINTAPI

    ptMaxPosition As POINTAPI

    rcNormalPosition As RECT

End Type

Declare Function AppendMenu Lib "User" (ByVal hMenu As Integer, ByVal

wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As Any)

As Integer

Declare Function CheckMenuItem Lib "User" (ByVal hMenu As Integer, ByVal

IDM As Integer, ByVal Check As Integer) As Integer

Declare Function CreatePopupMenu Lib "User" () As Integer

Declare Function DrawIcon Lib "User" (ByVal hDC As Integer, ByVal X As

Integer, ByVal Y As Integer, ByVal hIcon As Integer) As Integer

Declare Function ExtractIcon Lib "SHELL" (ByVal hInst As Integer, ByVal

Filename As String, ByVal hIcon As Integer) As Integer

Declare Function FindWindow Lib "User" (ByVal ClassName As Any, ByVal

TitleText As Any) As Integer

Declare Function FreeResource Lib "Kernel" (ByVal hResData As Integer) As

Integer

Declare Function GetActiveWindow Lib "User" () As Integer

Declare Function GetClassWord Lib "User" (ByVal hWnd As Integer, ByVal

Index As Integer) As Integer

Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)

Declare Function GetDesktopWindow Lib "USER" () As Integer

Declare Function GetModuleFilename Lib "kernel" (ByVal hInst As Integer,

ByVal Filename As String, ByVal FilenameLen As Integer) As Integer

Declare Function GetPrivateProfileInt Lib "kernel" (ByVal Section As String,

ByVal Entry As String, ByVal Default As Integer, ByVal Filename As String) As

Integer

Declare Function GetPrivateProfileString Lib "kernel" (ByVal Section As

String, ByVal Entry As String, ByVal Default As String, ByVal Buffer As String,

ByVal length As Integer, ByVal Filename As String) As Integer

Declare Function GetSysColor Lib "User" (ByVal nIndex As Integer) As Long

Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

Integer

Declare Function GetWindow Lib "User" (ByVal hWnd As Integer, ByVal Cmd

As Integer) As Integer

Declare Function GetWindowPlacement Lib "User" (ByVal hWnd As Integer,

lpwndpl As WINDOWPLACEMENT) As Integer

Declare Function GetWindowText Lib "User" (ByVal hWnd As Integer, ByVal

TextString As String, ByVal length As Integer) As Integer

Declare Function GetWindowTextLength Lib "User" (ByVal hWnd As Integer)

As Integer

Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal

Offset As Integer) As Integer

Declare Function LoadIcon Lib "User" (ByVal hInst As Integer, ByVal

IconResource As Any) As Integer

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Declare Function ShellExecute Lib "shell" (ByVal hWnd As Integer, ByVal

lpszOp As Any, ByVal lpszFile As String, ByVal lpszParams As String, ByVal

lpszDir As String, ByVal fsShowCmd As Integer) As Integer

Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal

nCmdShow As Integer) As Integer

Declare Sub SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal

hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx

As Integer, ByVal cy As Integer, ByVal wFlags As Integer)

Declare Function TrackPopupMenu Lib "User" (ByVal hMenu As Integer,

ByVal wFlags As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal

nReserved As Integer, ByVal hWnd As Integer, lpReserved As Any) As

Integer

Declare Function WindowFromPoint Lib "User" (ByVal lpPointY As Integer,

ByVal lpPointX As Integer) As Integer

'Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String, ByVal

nCmdShow As Integer) As Integer

'Constants for FindResource

Global Const RT_ICON = 3

'Constants for SetWindowPos

Global Const HWND_TOPMOST = -1

Global Const HWND_NOTOPMOST = -2

Global Const SWP_NOSIZE = 1

Global Const SWP_NOMOVE = 2

'Title Bar Colors Constants

Global Const COLOR_ACTIVECAPTION = 2

Global Const COLOR_INACTIVECAPTION = 3

'Used in Getting Window Title Bar Text

Global Const GW_HWNDFIRST = 0

Global Const GW_HWNDLAST = 1

Global Const GW_HWNDNEXT = 2

Global Const GW_HWNDPREV = 2

Global Const GW_OWNER = 4

Global Const GW_CHILD = 5

Global Const GWW_HINSTANCE = (-6)

Global Const GWW_HWNDPARENT = (-8)

Global Const GCW_HMODULE = (-16)

'Windows Messages

Global Const WM_NCACTIVATE = &H86

Global Const WM_CLOSE = &H10

Global Const WM_NCHITTEST = &H84

Global Const WM_NCLBUTTONDBLCLK = &HA3

Global Const WM_NCLBUTTONDOWN = &HA1

Global Const WM_COMMAND = &H111

Global Const WM_SYSCOMMAND = &H112

'System Metrics Constants

Global Const SM_CYMENU = 15

'SysCommand, wParam values

Global Const SC_MOVE = &HF010

Global Const SC_CLOSE = &HF060

'Menu Function values

Global Const MF_SEPARATOR = &H800

Global Const MF_ENABLED = 0

Global Const MF_STRING = 0

'Menu ID's

Global Const IDM_SYSMOVE = 101

Global Const IDM_SYSCLOSE = 102

Global Const IDM_ABOUT = 103

Global Const IDM_ONTOP = 104

'WM_NCHITTEST return values

Global Const HTCLIENT = 1

Global Const HTCAPTION = 2

Global Const HTSYSMENU = 3

'Window Constants

Global Const SW_SHOWNORMAL = 1

Global Const SW_SHOWMINIMIZED = 2

Global Const SW_SHOWMAXIMIZED = 3

Global Const SW_SHOWNOACTIVATE = 4

Sub EnumhWnd ()

    Dim working_hWnd As Integer

    Dim working_parent As Integer

    Dim working_owner As Integer

    Dim working_hInst As Integer

    Dim working_EXE As String

    Dim working_title As String

    Dim Indent As Integer

    Open "d:™windows.dat" For Output As #1

    Indent = 0

    working_hWnd = GetDesktopWindow()

    working_parent = GetWindowWord(working_hWnd,

GWW_HWNDPARENT)

    working_owner = GetWindow(working_hWnd, GW_OWNER)

    working_title = FindTitleByhWnd(working_hWnd)

    working_EXE = FindEXENameByTitle(working_title)

    working_hInst = GetWindowWord(working_hWnd, GWW_HINSTANCE)

    Print #1, Space$(Indent); "hWnd: "; working_hWnd; " Parent: ";

working_parent; " Owner: "; working_owner

    Print #1, Space$(Indent); "Title: "; working_title

    Print #1, Space$(Indent); "EXE: "; working_EXE

    Print #1, Space$(Indent); "hInst: "; working_hInst

    Print #1, ""

    Do

        If (GetWindow(working_hWnd, GW_CHILD) <> 0) Then

            Indent = Indent + 5

            working_hWnd = GetWindow(working_hWnd, GW_CHILD)

            working_parent = GetWindowWord(working_hWnd,

GWW_HWNDPARENT)

            working_owner = GetWindow(working_hWnd, GW_OWNER)

            working_title = FindTitleByhWnd(working_hWnd)

            working_EXE = FindEXENameByTitle(working_title)

            working_hInst = GetWindowWord(working_hWnd,

GWW_HINSTANCE)

            Print #1, Space$(Indent); "hWnd: "; working_hWnd; " Parent: ";

working_parent; " Owner: "; working_owner

            Print #1, Space$(Indent); "Title: "; working_title

            Print #1, Space$(Indent); "EXE: "; working_EXE

            Print #1, Space$(Indent); "hInst: "; working_hInst

            Print #1, ""

        Else

NextWnd:

            If (GetWindow(working_hWnd, GW_HWNDNEXT) <> 0) Then

                working_hWnd = GetWindow(working_hWnd, GW_HWNDNEXT)

                working_parent = GetWindowWord(working_hWnd,

GWW_HWNDPARENT)

                working_owner = GetWindow(working_hWnd, GW_OWNER)

                working_title = FindTitleByhWnd(working_hWnd)

                working_EXE = FindEXENameByTitle(working_title)

                working_hInst = GetWindowWord(working_hWnd,

GWW_HINSTANCE)

                Print #1, Space$(Indent); "hWnd: "; working_hWnd; " Parent: ";

working_parent; " Owner: "; working_owner

                Print #1, Space$(Indent); "Title: "; working_title

                Print #1, Space$(Indent); "EXE: "; working_EXE

                Print #1, Space$(Indent); "hInst: "; working_hInst

                Print #1, ""

            Else

                Print #1, Space$(Indent); " - End - "

                Print #1, ""

                Indent = Indent - 5

                working_hWnd = GetWindowWord(working_hWnd,

GWW_HWNDPARENT)

                'working_parent = GetWindowWord(working_hWnd,

GWW_HWNDPARENT)

                'working_owner = GetWindow(working_hWnd, GW_OWNER)

                'working_title = FindTitleByhWnd(working_hWnd)

                'working_EXE = FindEXENameByTitle(working_title)

                'working_hInst = GetWindowWord(working_hWnd,

GWW_HINSTANCE)

                'Print #1, Space$(Indent); "hWnd: "; working_hWnd; " Parent: ";

working_parent; " Owner: "; working_owner

                'Print #1, Space$(Indent); "Title: "; working_title

                'Print #1, Space$(Indent); "EXE: "; working_EXE

                'Print #1, Space$(Indent); "hInst: "; working_hInst

                'Print #1, ""

                If working_hWnd > 0 Then

                    GoTo NextWnd

                End If

            End If

        End If

    Loop While working_hWnd > 0

    Close #1

End Sub

Function FindEXENameByTitle (Application As String) As String

    Dim EXE_Name As String

    Dim hWnd As Integer

    Dim hInst As Integer

    Dim length As Integer

    'get the handle

    hWnd = FindWindow(0&, Application)

    hInst = GetWindowWord(hWnd, GWW_HINSTANCE)

    'get the filename

    EXE_Name = Space$(80)

    length = GetModuleFilename(hInst, EXE_Name, Len(EXE_Name) - 1)

    FindEXENameByTitle = Left$(EXE_Name, length)

End Function

Function FindTitleByhWnd (working_hWnd As Integer) As String

    Dim length As Integer

    Dim working_title As String

    'get the title length

    length = GetWindowTextLength(working_hWnd)

    'get the title

    working_title = Space$(length + 1)

    length = GetWindowText(working_hWnd, working_title, length + 1)

    FindTitleByhWnd = Left$(working_title, length)

End Function

Sub Main ()

Call EnumhWnd

End

End Sub


hWnd retrieve handle

LUOKKA: API

Date: 07/21/94 (03:54)              Number: 12665 of 12767 (Refer# NONE)

From: A-PATRD@MICROSOFT.COM

Subj: Re: hWnd

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal

lpWindowName As Any) As Integer

FindWindow (2.x)

HWND FindWindow(lpszClassName, lpszWindow)

LPCSTR lpszClassName; /* address of class-name string */

LPCSTR lpszWindow; /* address of window-name string */

The FindWindow function retrieves the handle of the window whose class

name and window name match the specified strings. This function does not

search child windows.

Parameter Description

lpszClassName Points to a null-terminated string that contains the window's

class name. If this parameter is NULL, all class names match.

lpszWindow Points to a null-terminated string that specifies the window name

(the window's title). If this parameter is NULL, all window names match.

Returns

The return value is the handle of the window that has the specified class

name and window name if the function is successful. Otherwise, it is NULL.


Icon animate

LUOKKA: VBgen

8. How do I make an animated icon for my program?

   For an example on how you change the icon for your application as

   it is displayed when it is minimized, see the example REDTOP in the

    samples picclip directory for VB/Win 3 Pro. This demonstrates a

   fancy animated icon.


Icons

LUOKKA: forms

Date: 07/07/94 (15:13)              Number: 11453 of 11683 (Refer# NONE)

From: LRP.ADMIN@MHS.UNC.EDU

Subj: Re: Icon file...

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

IconMaster is a shareware tool that allows you to store icons in a variety of

library formats.  It also will allow you to extract icons directly from .exe

files.  You just open the .exe file in IconMaster and it will display images

of all the icons it finds in the file.  You can then save the icons out to

.ico files.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Ray Porter


Icons 1

LUOKKA: forms

Date: 06/23/94 (21:22)              Number: 10028 of 10157 (Refer# NONE)

From: JOE.STUBER@DAYTONOH.NCR.COM

Subj: Using Windows System Icon

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

All I want to do is load one of the windows system icons (IDI_EXCLAMATION)

onto my visual basic form.  The only way that I have found to do this is via

the LoadIcon and DrawIcon Windows 3.1 APIs.  Thus, I setup a picture

control on my form and then in the paint routine for the form I placed the

following code:

    Dim HIcon As Integer

    Dim RetValue As Integer

    HIcon = LoadIcon(0, IDI_EXCLAMATION)

    RetValue = DrawIcon(Picture1.hDC, 0, 0, HIcon)

Does, anyone know of a better way?  I know that I dont have to load the

icon on every paint message but what I would really like to do is just set

Picture1.Picture = to the IDI_EXCLAMATION icon and be done with it.


Icons 2

LUOKKA: forms

Date: 06/23/94 (21:40)              Number: 10041 of 10157 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Using Windows System Icons

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Joe Stuber (Joe.Stuber@DaytonOH.NCR.COM) wrote:

: Does, anyone know of a better way?  I know that I dont have to load the

: icon: on every paint message but what I would really like to do is just set

: Picture1.Picture = to the IDI_EXCLAMATION icon and be done with it.

Try using any old capture util to just capture the thing as a bmp and then

save that and then just set it during design time "and be done with it."

gt


Icons 3

LUOKKA: forms

Date: 06/23/94 (23:44)              Number: 10051 of 10157 (Refer# NONE)

From: RIENSCHE@BETA.TRICITY.WSU.EDU, Roderick M. Riensche

Subj: Re: Using Windows System Icons

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <Cruu7M.KxD@wtc35a.daytonoh.ncr.com>,

Joe Stuber  <Joe.Stuber@DaytonOH.NCR.COM> wrote:

>All I want to do is load one of the windows system icons

[IDI_EXCLAMATION)

>onto my visual basic form.  The only way that I have found to do this is via

>the LoadIcon and DrawIcon Windows 3.1 APIs.  Thus, I setup a picture

>control on my form and then in the paint routine for the form I placed the

>following code:

>

>    Dim HIcon As Integer

>    Dim RetValue As Integer

>    HIcon = LoadIcon(0, IDI_EXCLAMATION)

>    RetValue = DrawIcon(Picture1.hDC, 0, 0, HIcon)

.........

I would suggest you use that above segment of code one time (actually in

a separate 'temporary' application) and then write the picture to a

bitmap.  Then in your real application you can load the bitmap into the

Picture Box using whatever method you usually employ.   Voila!  Plus,

you've got the picture on file so you can use it in any application you

write...

Rick


Icons fitting on btn

LUOKKA: graphics

Date: 09/09/94 (03:18)              Number: 18789 of 18922 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Shrinking Icons

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On Tue, 6 Sep 1994 09:46:58 David R. Zangger

<drzangger@ccgate.dp.beckman.com> wrote:

>How can I take an icon and shrink it down?

>I need regular size icons to fit on a button the size of the buttons on the

>VB tool bar.

Convert them to bitmaps (load them into IconWorks and copy it in it's

entirety to the clipboard). You can use almost any bitmap modification

application (PaintShop Pro comes to mind) to stretch and shrink the

resulting bitmap and save it.

Or, you can use the following example code to build an automatic conversion

tool (create a form (ScaleMode = 3) with two pictureboxes (picSource

containing an icon, ScaleMode =3, AutoSize = True and picDest (ScaleMode

= 3)) and a command button (cmdConvert)

Paste the following code in the declarations section of your form:

Declare Function SetStretchBltMode Lib "GDI" (ByVal hDC As Integer, ByVal

   nStretchMode As Integer) As Integer

Declare Function StretchBlt% Lib "GDI" (ByVal hDC%, ByVal X%, ByVal Y%,

ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

YSrc%, ByVal nSrcWidth%, ByVal nSrcHeight%, ByVal dwRop&)

Const SRCCOPY = &HCC0020

Const COLORONCOLOR = 3

Sub Form_Load()

    picSource.Picture = LoadPicture("SOMEICON.ICO")

End Sub

Sub cmdConvert_Click ()

Dim R As Integer

    ' Copy bitmap over icon

    picSource.Picture = picSource.Image

    ' Set the size of the destination

    picDest.Width = NeededWidth

    picDest.Height = NeededHeight

    picDest.AutoRedraw = True

    ' COLORONCOLOR mode gives better StretchBlt results

    R = SetStretchBltMode(picDest.hDC, COLORONCOLOR)

    ' Copy the icon in picSource to picDest

    R = StretchBlt(picDest.hDC, 0, 0, picDest.Width, picDest.Height,

      picSource.hDC, 0, 0, picSource.Width, picSource.Height, SRCCOPY)

    picDest.AutoRedraw = False

    ' Save the created picture in picDest

    SavePicture picDest.Image, "SOMEBMP.BMP"

End Sub

--

Arjen Broeze                                   Telephone: (+31)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13

                                                          7533 VR Enschede, NL


Icons how-to

LUOKKA: graphics

Date: 12/01/94 (16:27)              Number: 141579 of 141613 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Saving a picture as an icon

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>>1. I want to draw on an 32x32 picturebox with pset, line...  and then want

>>   to save it as an icon. How can I do this?

>1. I believe an icon is just a 32x32 bitmap with an extension of .ICO. Try

>that.

If only it was that easy.  Icons contain a lot more information than just

the picture of the icon itself. There are 2 masks which are used when the

icon is drawn. This is how you can have icons which are see through or non

rectangular. When you load an icon into a picture box the masks are loaded

with it but VB doesn't provide a way to modify them. In addition it seems to

'forget' that its an icon when you modify it.

Now how to solve your problem - Check out the source code for

ICONWORKS it modifies the picture box using API routines. and then uses

SavePicture to

store the icon back to disk. Everything you need to know is in there

somewhere. For starters look in UpdateIcon in ICONWRKS.BAS - it uses

offsets to long pointers to read and write bits of the picture box data. Good

luck.

Alternativly you could write the .ico file directly. The file format is

documented on MSDN but its a bit long so I won't post it here. Mail me if

you want a look - its very C oriented so will need a little work.

>>2. Can I save icons with more than 16 colors?

>2. Do you really want more than 16 colors or do you just just want to have

>different shades than the standard colors allow? In my WINDOWS directory

>there is a .BMP file called 256COLOR. I can display it as my wallpaper, so

>WINDOWS can handle more colors somehow. Maybe your bitmap editor

can't create them? With the ICONWRKS editor that comes as a sample prog

w/ VB you can set any hues you want to any "color" in the palate, but you

still >only have 16 colors at 1 time, as I see it. Icons can be 2, 8 or 16

colors. Although I think there are shareware

programs that allow program manager to use 256 colour icons.

Ta Ta

Andy

ADUNN@farnboro01.datasci.co.uk


IIF/Msafix.dll

LUOKKA: VBgen

10.I get a "file not found" error on the IIF function when I

   distribute by program. Uh?

   There's a documentation error, since the manual does not tell you

   that the IIF function requires the file MSAFINX.DLL to be

   distributed with your application. No, IIF is not financial (I

   should know, I study finance right now, or at least I should be

   doing that ;-


Image ctrl as button

LUOKKA: graphics

Image Control As A Button

------------------------------------------

One of the easiest techniques for adding graphical effects to your program is

to use an image control as a button. When the image control receives a Click

event, you simply substitute the value of the Picture property. The key to this

technique is to define a pair of invisible image controls with pictures

corresponding to the up and down status of the control.

For example, you could create a button that visually represents a locked and

unlocked state. One advantage of using icon files rather than bitmap files is

that any underlying image shows through the mask area of the icon.

When the form is loaded, the Form_Load event procedure sets the

appropriate image in the image control:

Sub Form_Load()

   Padlock.Picture = LockOpen.Picture

End Sub

The image control responds to the click event by replacing the picture in the

control:

Sub Padlock_Click()

Static LockedFlag As Integer

If LockedFlag Then

   Padlock.Picture = LockOpen.Picture

Else

  Padlock.Picture = LockClosed.Picture

End If

LockedFlag = Not LockedFlag

End Sub

Source: Microsoft Developer Network News, July 1993


Inheritance

LUOKKA: coding

Date: 07/27/94 (20:48)              Number: 13459 of 13548 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: VB inheritance?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <CtLFx3.BI6@teice.es> nacho@teice.es (Nacho Garcia) writes:

>I'am working in my first VB project and I have found a problem that seems

>to me very interesting. I have 20 "objects" with common fields. I have

>stored the common fields in a separate table (The big one) and I have

>created one additional table for each object.

>That works fine because I can make a browser over the big table and

>selects objects in this browser. Now I'am writing a form for each object. In

>this forms I have to put the general data and also the specific object data.

>And that is the problem I have to write 20 times the same code and put the

>some controls. Thinking in maintenance when I add a field to the big table

>I will have to update the 20 forms. Are there any solution to the problem?

OK, so you want to have 20 forms to represent 20 different classes, all

of which share a set of "core" attributes in common. There are a few

things you can do:

1. You can create a common .bas module to implement common functions

   you'll want to perform on all your forms, regardless of their class. (Just

   pass the form in as an argument.)

2. In this module you can also implement common event handlers. For

   example if you want to do something similar for all your classes on the

   FormLoad() event, you can create a single handler, e.g.:

        BaseFormLoad(F as Form)   handler.

   You pass in the form. You can do this with all events for the form, and

   for important controls on it (duplicating the event handler's argument

   list, but adding the form itself as an additional argument). This gives

   you a primitive form of inheritance.

3. Your maintenance problem should be solvable through reparenting.

   For example, create one form with a 3-D panel on it. Put the controls on

   the panel which represent the attributes of your base class. Then

   create a form representing your subclass, with the specific attributes

   you want on it, but leaving space (let's say at the top) for the base

   classes' attributes. When you instantiate the form for the subclass,

   also instantiate an (invisible) copy of the base classes' form. Reparent

   the 3-D panel (and the controls it contains) from the base classes' form

   to the subclasses' form. You now have a form which LOOKS like it

   contains the union of all attributes, but you can maintain the base

   class attributes seperately. This solves your maintenance

   problem. Remember to reparent things back how they were and

   destroy both forms when you are done. I've done this before and it

   works fine. Use the MS-Windows SetParent() call, which is pretty

   simple.

You may need to do some geometry management at form load. And

you can trigger the reparenting back & destruction of the invisible form

at query unload or something. If you utilize common event handlers

(as suggested in step 2, above) then you also only have to write this

code in one place.

I think you'll find that you can achieve a klugy kind of inheritance

in VB using techniques similar to these. Hope this helps.

Tim


Inheritance

LUOKKA: coding

Date: 05-11-95 (13:32)              Number: 324326 of 324835 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: ÄquestionÅ How to inherit objects with VB?

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

It is possible to do "pseudo inheritance" in VB. It is one part of a

series of VB design articles I'm working on that will be on MSDN.  I

never claim "inheritance" because it is not strict inheritance in a C++

sense (which is not strict inheritance in Smalltalk or Simula

senses)...   This is in a 'cheap way':  Create a form and create

multiple instances of the form. All events on form is sent to a class

event handler (in a module), with the form being a parameter. The form

tag is examined, and if it is not the original class tag, then it is

dispatched to the class event handler that the tag suggests....

        Sub CLASS2_Event(Frm as Form,EventID,.....)

        Select case EVentID

                Case K_pbClose 'CLASS2 overrides

                        CLASS2_pbClose

                Case K_pbAdd 'Class2 ADDs..

                        CLASS2_pbADD

                        CLASS1_pbADD 'Class it inheritated from

                Case Else

                        CLASS1_Event(Frm, EVentID,...)

        End Select

        End Sub

If it make sense -- good, if not wait for the article....

There are a lot of careful design issue that must be carefully address

- items most VB developers rarely do when writing code.

                Ken


INI

LUOKKA: INI

13.How do I use GetPrivateProfileString to read from INI files?

   There's a good example of accessing *.INI files in the Knowledge

   Base, but here's the basic idea:

     'You declare these API function as usual:

     Declare Function GetPrivateProfileString Lib "Kernel"

     "(ByVal lpApplicationName As String, ByVal lpKeyName

     "As Any, ByVal lpDefault As String, ByVal

     "lpReturnedString As String, ByVal nSize As Integer,

     "ByVal lpFileName As String) As Integer

     'Then in your code you do like below:

     strIniFile = "WIN.INI"

     strSection = "MyProgram"

     strKey = "Language"

     strDefault = "English"

     iLength = 70

     strReturn = String$(iLength, " ")  'Pad the string first!

     iResult = GetPrivateProfileString(strSection, strKey,

     "strDefault, strReturn, iLength, strIniFile)

   WARNING: Be aware that there was an ERROR in the Windows 3.1 API

   documentation that came with VB. Here's the scoop:

   Knowledge Base article Q110826 (DOCERR: GetPrivateProfileString

   Declaration Incorrect in API) corrects a documentation error for

   the GetPrivateProfileString function call as described in the

   Windows version 3.1 API Reference help file that shipped with

   Microsoft Visual Basic version 3.0 for Windows. The CORRECT

   declaration is as follows:

     Declare Function GetPrivateProfileString Lib "Kernel"

     "(ByVal lpApplicationName As String, ByVal lpKeyName

     "As Any, ByVal lpDefault As String, ByVal

     "lpReturnedString As String, ByVal nSize As Integer,

     "ByVal lpFileName As String) As Integer

   Note that the "ByVal" keyword was omitted from the second parameter

   in the online reference. This means that the function is passing

   the second parameter (lpKeyName) by reference. It needs to be

   passed by value.

   The most common problem that occurs when using the incorrect

   declaration is that when the function is called, it returns a copy

   of "lpdefault" in the "lpReturnedString" parameter instead of the

   actual value referenced by KeyName.


INI and DBs

LUOKKA: Access

2. Why does my compiled VB database app generate an error when it ran

   just fine in the design environment?

   You can thank Microsoft for documenting this topic so poorly. When

   you compile your VB database application, you must also have an INI

   file for it which provides the correct pointers to the appropriate

   database drivers. Therefore, if your application is named

   "INVOICE.EXE", you will need to have a properly configured

   "INVOICE.INI" file in your Windows directory. The file,

   EXTERNAL.TXT, that came with VB should explain all about it.


INI bugs in docs

LUOKKA: INI

Date: 07/01/94 (10:31)              Number: 10951 of 11050 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: Dll Calling Convention - Incorrect in VB Manuals ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article: <1994Jun29.202649.20243@brtph560.bnr.ca>

magic@brtph314.bnr.ca (Randall Mason

P875) writes:

> The VB Manual list the Calling convention for DLL's as

> (i.e. in the case of Writing Profiles)

> Temp = WriteProfileString(AppName, KeyWord, KeyValue)

> This however generates a Bad DLL Calling Convention error

> message. Any Ideas ??

Sir,

Yes, Microsoft got some of these wrong in the docs. Nuisance,

isn't it? I sank *hours* into figuring this out, blithely

assuming that Microsoft surely couldn't have cocked it up...

Below is the correct convention for each of these calls - sorry

about the word wrap, but I assume you can sort that out.

Anyway, using this declaration scheme works for me :-)

For the WIN.INI calls:

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppname$,

  ByVal lpkeyname$, ByVal lpDefault$, ByVal ReturnedString$, ByVal

  nSize%) As Integer

Declare Function WriteProfileString Lib "Kernel" (ByVal

  lpApplicationname$, ByVal lpkeyname$, ByVal lpstring$) As Integer

For Private .INI file calls:

    Declare Function GetPrivateProfileString Lib "Kernel" (ByVal

       lpApplicationName As String, ByVal lpKeyName As String, ByVal

       lpDefault As String, ByVal lpReturnedString As String, ByVal nSize

       As Integer, ByVal lpFileName As String) As Integer

    Declare Function WritePrivateProfileString Lib "Kernel" (ByVal

       lpApplicationName As String, ByVal lpKeyName As String, ByVal

       lpString As String, ByVal lplFileName As String) As Integer

    Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal

       lpApplicationName As String, ByVal lpKeyName As String, ByVal

       nDefault As Integer, ByVal lpFileName As String) As Integer

One other thing. When you Do a GetProfileString or

GetPrivateProfileString, make sure you do it like this (i.e.

assign a string like string(255,0) ), or you will crash and burn...

    Dim ReturnLen%

    Dim spaceholder$

'get integer values

    ReturnLen% = GetPrivateProfileInt("General", "KeepOnTop", 1,

        "QUIKFIRE.INI")

    KeepOnTop% = ReturnLen%

    ReturnLen% = GetPrivateProfileInt("General", "UseWriteOnly",

        0, "QUIKFIRE.INI")

    UseWriteOnly% = ReturnLen%

'get string values

    spaceholder$ = String$(255, 0)

    ReturnLen% = GetPrivateProfileString("RecentFiles", "FilePath1",

        "C:ÖAUTOEXEC.BAT", spaceholder$, 255, "QUIKFIRE.INI")

    FilePath1$ = Left$(spaceholder$, ReturnLen%)

I hope this helps you. Witters on a bit, but there - that's me.

Ian Piper


INI bugs in docs!!

LUOKKA: INI

Date: 07/12/94 (17:11)              Number: 11837 of 11852 (Refer# NONE)

From: DHUNT@INS.INFONET.NET

Subj: Re: App's Ini File

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

By the way, I know this has been said before but I'm going to say it again:

The  WIN 3.1 API Help CONTAINS ERRORS. I wasted a whole day trying to

get .INI data. The problem was in the DECLARE statement:

    lpKeyName as Any   should be ByVal lpKeyName as Any   (maybe Any

should be String but I don't think it causes any problems). Data needs to be

passed by Value-- not by reference. Both GetProfileString and

GetPrivateProfileString are wrong in the WIN 3.1 API Help. I finally

figured it out by using the Example code in the Declare Help. Talk about

hopping mad-- as much at myself as MS. It's not like there hasn't been

umpteen bajillion warnings about ByVal! Still, I think it bears repeating.

Accessing the .INI files really isn't hard at all once you try it with

the correct syntax!

Dave Hunt


INI delete entry

LUOKKA: INI

Date:         Wed, 21 Sep 1994 08:21:07 CEST

From:         Nicola Brion <MC1920@MCLINK.IT>

Subject:      ini file stuff

>> Anyone know how to delete an entry completely from an INI

>> file?

to phisically delete a single item from an ini file(or a whole

section....) you need to send a NULL to the Write API call.

As MS said (Programmer's guide, pag, 502 for the 2.0 manual..) to pass a

NULL pointer you have to indicate it AS ANY on the function declaration..

change your declaration to :

Declare Function WritePrivateProfileString Lib "Kernel" (ByVal

  lpApplicationName As String, lpKeyName As Any, lpString As Any, ByVal

  lplFileName As String) As Integer

to delete a single phisical entry call

a%=writeprivateprofilestring (My_section, byval my_entry, byval 0, byval

  my_ini)

and to delete a whole section do

a%=writeprivateprofilestring (My_section, byval 0, byval 0, byval my_ini)


INI finnish

LUOKKA: INI

(14093/14178)

Area: Kysymykset ja vastaukset

From: Marko Huttunen  To: Eero Lehikoinen

Date: 20 Jun 94  23:34:09

Subj: Taas kysyttävää .INI -tie

Toivottavasti tämä auttaa edes hieman.

Tässä esimerkkinä WIN.INIstä pätkä, johon viittaan esimerkeissä:

[intl]

sLanguage=fin

sCountry=Finland

iCountry=358

GetPrivateProfileInt ja GetPrivateProfileString API-kutsuilla

käsitellään ohjelman omia INI-tiedostoja. Kutsut ilman Private-sanaa on

tarkoitettu WIN.INIn käsittelyyn.

************************************************************************

GetPrivateProfileInt:

LPCSTR lpszSection;         /* address of section        */

LPCSTR lpszEntry;           /* address of entry        */

int default;                /* return value if entry not found        */

LPCSTR lpszFilename;        /* address of initialization filename */

lpszSection = intl

lpszEntry   = iCountry

int default = arvo joka annetaan, jos lpszEntryssä määriteltyä asetusta

              ei löydy.

lpszFIlename= tiedoston nimi

Paluuarvona on haettu arvo tai oletusarvo. Jos haettu arvo ei olekaan

kokonaisluku, funktio palauttaa nollan.

Käytännössä funktion kutsu näyttää seuraavalta :

maakoodi = GetPrivateProfileInt("intl", "iCountry", 100, "WIN.INI")

Jos iCountry-asetusta ei löydy, maakoodi saa arvokseen tässä tapauksessa

100.

GetProfileInt toimii vastaavasti, mutta siinä ei siis määritellä

tiedostoa, vaan se käsitelee aina WIN.INI-tiedostoa.

************************************************************************

GetPrivateProfileString:

LPCSTR lpszSection;        /* address of section */

LPCSTR lpszEntry;          /* address of entry */

LPCSTR lpszDefault;        /* address of default string */

LPSTR lpszReturnBuffer;    /* address of destination buffer */

int cbReturnBuffer;        /* size of destination buffer */

LPCSTR lpszFilename;       /* address of initialization filename */

lpszSection        = intl

lpszEntry          = sCountry

lpszDefault        = arvo, joka palutetaan, jos sCountry-asetusta ei löydy

lpszReturnBuffer   = muuttuja, johon sijoitetaan paluuarvo

int cbReturnBuffer = edellä mainitun muuttujan koko

lpszFilename       = tiedoston nimi

Funktio palauttaa arvona haetun merkkijonon pituuden.

Käytännössä olen todennut seuraavan tavan toimivaksi :

    Dim Arvo, Maa as String

    Arvo = String(255, Chr(0))

    Maa = Left(Arvo, GetPrivateProfileString(Byval "intl",

    Byval "sCountry", "UK", Arvo, Len(Arvo), "WIN.INI")

Jos sCountry-asetusta ei löydy, funktio palauttaa tässä tapauksessa "UK":n.

Kuten edellä, GetProfileString toimii samalla tavalla, ilman tiedoston

nimeä.

Jos GetPrivateProfile... funktioissa ei ole määritelty tiedoston nimen

lisäksi koko polkua, Windows etsii tiedostoa Windows-hakemistosta.

************************************************************************

WritePrivateProfileString:

LPCSTR lpszSection;       /* address of section        */

LPCSTR lpszEntry;         /* address of entry        */

LPCSTR lpszString;        /* address of string to add        */

LPCSTR lpszFilename;      /* address of initialization filename */

Muuten samat kuin edellä, paitsi

lpszString = teksti, joka viedään tiedostoon.

Käytännössä:

Dim Tarkiste as Integer

Tarkiste = WritePrivateProfileString(Byval "Intl", Byval "sCountry",

Byval "UK", "WIN.INI")

Jos tiedostoa, aluetta 'Intl' ja/tai asetusta 'sCountry' ei löydy se/ne

luodaan. Funktio palauttaa arvon nolla, jos tapahtuu virhe.

Oletusarvoisesti INI-tiedosto luodaan Windows-hakemistoon.

WriteProfileString toimii samalla tavalla, mutta ilman tiedoston

nimeä.

Get(Private)ProfileInt-funktiolle ei löydy Write...Int vastinetta, vaan

luvut on kirjoitettava Write...String-funktiolla.

HUOM ! funktio-kutsut on oltava yhdellä rivillä !

************************************************************************

Helpin kutsu :

Kirjoita seuraavanlainen määrittely johonkin ohjelmasi alkuosaan :

App.HelpFile = "apu.hlp"

tai määrittele tiedosto Options/Project-ikkunassa

Tämän jälkeen F1:stä painettaessa tiedosto avautuu.

Jokaiselle elementille voidaan määritellä joko koodissa tai

Properties-ikkunassa HelpContextID. Tämä numero vastaa apu-tiedostossa

määriteltyjä Topic/Otsikko-numeroita. Kun jokin elementti on aktivoitu

ja sille on määritelty HelpContextID, avautuu apu-tiedosto halutusta

kohdasta F1:stä painettaessa.

Tässä lyhyehkösti vastukset kysymyksiisi. Jos (/kun ;) ) jotain jäi

epäselväksi, kysy lisää.

T: Marko


INI internat.settings

LUOKKA: INI

Date: 11/29/94 (18:39)              Number: 28342 of 28357 (Refer# NONE)

From: ROYFRAN@STATCAN.CA

Subj: Re: Determining Control Panel Int'l settings

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: I need to determine how the user has his/her control panel set up for

: dates.  I want to be able to instruct the user as to how to enter a date

: (e.g. "Enter your date in the format MM/DD/YY").  But I do not want to

: restrict the user to any format.  It should follow their international

: settings in the control panel.

 You will have to use the GetProfileString API call to retrieve the value

of sShortDate from WIN.INI.  It returns not only the ordering for MM,DD,YY

but also the way to display them (day & month names vs numbers, 2 vs

4 digit year, ...)


INI manipulating

LUOKKA: INI

Date: 12/01/94 (19:31)              Number: 28569 of 28627 (Refer# NONE)

From: RWS@SIGNAL.DRA.HMG.GB

Subj: Re: <AppName>.INI Questions

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Most INI files are placed in the windows subdirectory.  Is there a way to

>grab the WINDOWS path from in VB3?

>Does the INI file need the locations of the <DataBase>.DLL's?  If so, do

>you create the INI file on the fly the first time the program is run?

The .INI files may be located in a variety of places and your app

can locate it. However polite applications should only create .INI files

in the WINDOWS directory, this is defined as the directory containing

the inastance of WIN.COM which started windows. Some machines may have

more than one configuration by having multiple directories containing

WIN.COM. The following code extract shows how to search for a .INI file

in a number of standard locations and create if required:

-----<GLOBALS>-----------

' Windows API Calls -

Type OFSTRUCT

    cBytes As String * 1

    fFixedDisk As String * 1

    nErrCode As Integer

    reserved As String * 4

    szPathName As String * 128

End Type

' OpenFile() Flags

Global Const OF_READ = &H0

Global Const OF_WRITE = &H1

Global Const OF_READWRITE = &H2

Global Const OF_SHARE_COMPAT = &H0

Global Const OF_SHARE_EXCLUSIVE = &H10

Global Const OF_SHARE_DENY_WRITE = &H20

Global Const OF_SHARE_DENY_READ = &H30

Global Const OF_SHARE_DENY_NONE = &H40

Global Const OF_PARSE = &H100

Global Const OF_DELETE = &H200

Global Const OF_VERIFY = &H400

Global Const OF_CANCEL = &H800

Global Const OF_CREATE = &H1000

Global Const OF_PROMPT = &H2000

Global Const OF_EXIST = &H4000

Global Const OF_REOPEN = &H8000

Global Const HFILE_ERROR = -1

Global Const SWP_NOMOVE = 2            ' Form not movable

Global Const SWP_NOSIZE = 1            ' Form not resize

Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Global Const HWND_TOPMOST = -1

Global Const HWND_NOTOPMOST = -2

Declare Function OpenFile Lib "Kernel" (ByVal lpFileName As String,

        lpReOpenBuff As OFSTRUCT, ByVal wStyle As Integer) As Integer

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal AppName As

String, ByVal KeyName As String, ByVal Default As String,

        ByVal Returned As String, ByVal Size As Integer,

        ByVal FileName As String) As Integer

Declare Function WritePrivateProfileString Lib "Kernel"

        (ByVal AppName As String, ByVal KeyName As String,

        ByVal Text As String, ByVal FileName As String) As Integer

Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal AppName As

String,

        ByVal KeyName As String, ByVal nDefault As Integer,

        ByVal lpFileName As String) As Integer

Global Dim IniFile$

-< Code to locate .INI file >-----

    Dim Buffer As String * 256

    Dim FileHeader As OFSTRUCT

    i = OpenFile("MYAPP.INI", FileHeader, OF_EXIST Or OF_READ)

    If (i = HFILE_ERROR) Then

        IniFile$ = ""

        A$ = "MYAPP.INI not found" + Chr$(13) + "Create one?"

        If (MsgBox(A$, MB_ICONEXCLAMATION + MB_YESNO) = ID_YES)

Then

            IniFile$ = "MYAPP.INI"

        End If

    Else

        IniFile$ = (FileHeader.szPathname)

        i = InStr(IniFile$, Chr$(0))

        IniFile$ = Left$(IniFile$, i)

    End If

-< Code to read/write to ini file >---

    i = GetPrivateProfileString("General", "Username", "",

                Buffer$, Len(Buffer$), IniFile$)

    UserName$ = Left$(Buffer$, i)

    i = WritePrivateProfileString("General", IniItem$, A$, IniFile$)


INI prgm's settings

LUOKKA: INI

Date: 07/10/94 (13:07)              Number: 11654 of 11683 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: How to save program's setting to a file

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can do this easily using the API calls GetPrivateProfileInt,

GetPrivateProfileString and WritePrivateProfileString.

Within your application, monitor the control_click events for the controls

you want to have remembered. Or you can monitor

their state at some other crucial point in the program - e.g. loading

or unloading a form. Whatever way you decide to do it, assign the

control's value to a variable, then at a suitable time point (e.g.

exiting the program) you use WritePrivateProfileString to write those

values out to a private .ini file. Finally, in the startup routine

of your program you put in code using the GetPrivateProfile...

calls to read in that file again and assign the various components to

variables. The values of these variables dictate the values of the controls,

so you've closed the loop.

Here's an example. Please forgive the poor programming style folks.

'**** Declaring the API calls - each has to go on one line

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal

lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault

As String, ByVal lpReturnedString As String, ByVal nSize As Integer,

ByVal lpFileName As String) As Integer

Declare Function WritePrivateProfileString Lib "Kernel" (ByVal

lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString

As String, ByVal lplFileName As String) As Integer

Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal

lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault

As Integer, ByVal lpFileName As String) As Integer

'**** Setting up a few Globals - keep these to the minimum

Global KeepOnTop%

Global FilePath1$, FilePath2$, FilePath3$, FilePath4$, FilePath5$

Global UseWriteOnly%

'**** This routine reads in quikfire.ini and assigns values to the

'Globals I've declared above

'Specifically in this example there is a checkbox and a recent

'files list which the program has to remember.

Sub readINI ()

    Dim ReturnLen%

    Dim spaceholder$

'get integer values - each on one line

    ReturnLen% = GetPrivateProfileInt("General", "UseWriteOnly", 0,

"QUIKFIRE.INI")

    UseWriteOnly% = ReturnLen%

'get string values - again each on one line

    spaceholder$ = String$(255, 0)

    ReturnLen% = GetPrivateProfileString("RecentFiles", "FilePath1",

"C:ÖAUTOEXEC.BAT", spaceholder$, 255, "QUIKFIRE.INI")

    FilePath1$ = Left$(spaceholder$, ReturnLen%)

    ReturnLen% = GetPrivateProfileString("RecentFiles", "FilePath2",

"C:ÖCONFIG.SYS", spaceholder$, 255, "QUIKFIRE.INI")

    FilePath2$ = Left$(spaceholder$, ReturnLen%)

End Sub

'**** This is how you save the values back out again. Use this when you

'finish the program or some other time when you want to save the values.

Sub saveINI ()

    Dim n

    n = WritePrivateProfileString("General", "UseWriteOnly",

Str$(UseWriteOnly%), "QUIKFIRE.INI")

    n = WritePrivateProfileString("RecentFiles", "FilePath1",

FilePath1$, "QUIKFIRE.INI")

    n = WritePrivateProfileString("RecentFiles", "FilePath2",

FilePath2$, "QUIKFIRE.INI")

End Sub

'**** In the Form_Load event

Form_Load

' read in the saved values from quikfire.ini

readINI

'Add the recent file names to the lstFiles listbox

    lstFiles.AddItem FilePath1$

    lstFiles.AddItem FilePath2$

'Confirm whether user wants to use Write for all files

    If UseWriteOnly = 1 Then

        chkUseWrite.Value = 1

    Else

        chkUseWrite.Value = 0

    End If

End Sub

'**** In the Form_Unload event (or wherever)

Form_Unload

'Update the Global variables with the current state of the controls

    If chkUseWrite.Value = 1 Then

        UseWriteOnly = 1

    ElseIf chkUseWrite.Value = 0 Then

        UseWriteOnly = 0

    Else

    End If

'and write the values back out to the .ini file

    saveINI

End Sub

'**** How to monitor changes to a control - in this

'case a checkbox

Sub chkUseWrite_Click ()

'Update the Global variable with the new state of the control

    UseWriteOnly = chkUseWrite.Value

End Sub

I hope this is of some use to you.

Ian Piper


INI read, write etc.

LUOKKA: INI

Date:         Mon, 29 Aug 1994 11:48:09 EDT

From:         "Starsman, Lt Raymond S." <R_STARSMAN@NISE-P.NOSC.MIL>

Subject:      Simpler INI file interface  XE "Simpler INI file interface"

     On the advice of a fellow VB programmer (thanks Dena), I've written a

     small BAS file that provides a simpler 'front-end' to INI file

     interface.  Add this file to your project and it should provide easier

     access to ini files. It consists of the 6 Windows API INI function

     declarations and 6 'mirror' VB functions: GetINIString,

     GetINIInt,WriteINIString for user ini files and GetWinINIString,

     GetWinINIInt, and WriteWinINIString for win.ini.  These functions have

     a simpler interface than the API functions and take care of string

     allocation and trimmming.

    ___________CUT HERE_______________________________

     Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal

     lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault

     As Integer, ByVal lpFileName As String) As Integer

     Declare Function GetPrivateProfileString Lib "Kernel" (ByVal

     lpApplicationName As String, ByVal lpKeyName As String, ByVal

     lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As

     Integer, ByVal lpFileName As String) As Integer

     Declare Function WritePrivateProfileString Lib "Kernel" (ByVal

     lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString

     As String, ByVal lplFileName As String) As Integer

     Declare Function GetProfileInt Lib "Kernel" (ByVal lpApplicationName

     As String, ByVal lpKeyName As String, ByVal nDefault As Integer) As

     Integer

     Declare Function GetProfileString Lib "Kernel" (ByVal

     lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault

     As String, ByVal lpReturnedString As String, ByVal nSize As Integer)

     As Integer

     Declare Function WriteProfileString Lib "Kernel" (ByVal

     lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As

     Any) As Integer

     Function GetINIInt (FileName As String, Section As String, Item As

     String) As Integer

     Dim DefaultValue As Integer

       DefaultValue = 0

       GetINIInt = GetPrivateProfileInt(Section, Item, DefaultValue,

     FileName)

     End Function

     Function GetINIString (FileName As String, Section As String, Item As

     String) As String

     Dim TempString As String

     Dim TempInt As Integer

     Dim DefaultValue As String

       TempString = Space$(255)

       DefaultValue = ""

       TempInt = GetPrivateProfileString(Section, Item, DefaultValue,

     TempString, 255, FileName)

       GetINIString = Left$(TempString, TempInt)

     End Function

     Function GetWinINIInt (Section As String, Item As String) As Integer

     Dim DefaultValue As Integer

       DefaultValue = 0

       GetWinINIInt = GetProfileInt(Section, Item, DefaultValue)

     End Function

     Function GetWinINIString (Section As String, Item As String) As String

     Dim TempString As String

     Dim TempInt As Integer

     Dim DefaultValue As String

       TempString = Space$(255)

       DefaultValue = ""

       TempInt = GetProfileString(Section, Item, DefaultValue, TempString,

     255)

       GetWinINIString = Left$(TempString, TempInt)

     End Function

     Sub WriteINIString (FileName As String, Section As String, Item As

     String, Value As String)

     Dim TempInt As Integer

       TempInt = WritePrivateProfileString(Section, Item, Value, FileName)

       If TempInt = 0 Then MsgBox "Error writing to INI File"

     End Sub

     Sub WriteWinINIString (Section As String, Item As String, Value As

     String)

     Dim TempInt As Integer

       TempInt = WriteProfileString(Section, Item, Value)

       If TempInt = 0 Then MsgBox "Error writing to INI File"

     End Sub


INI read/write

LUOKKA: INI

Date: 09/11/94 (12:45)              Number: 19047 of 19086 (Refer# NONE)

From: JOE@BFTSI0.UUCP

Subj: Re: GetProfileString API example?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Yep. I actually made some wrapper routines that make things a

little easier for me:

----cut here----

'Functions for dealing with INI files

Option Explicit

Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal Section As String,

   ByVal Entry As String, ByVal Default As Integer, ByVal FileName As String)

   As Integer

Declare Function PAWSOFFGetPrivateProfileString Lib "Kernel" Alias

  "GetPrivateProfileString" (ByVal Section As String, ByVal Entry As Any,

ByVal Default As String, ByVal Buffer As String, ByVal BufSize As Integer,

ByVal FileName As String) As Integer

Declare Function PAWSOFFWritePrivateProfileString Lib "Kernel" Alias

  "WritePrivateProfileString" (ByVal Section As Any, ByVal Entry As Any,

ByVal Value As Any, ByVal FileName As String) As Integer

Declare Function GetProfileInt Lib "Kernel" (ByVal Section As String, ByVal

  Entry As String, ByVal Default As Integer) As Integer

Declare Function PAWSOFFGetProfileString Lib "Kernel" Alias

"GetProfileString" (ByVal Section As String, ByVal Entry As Any, ByVal

Default As String, ByVal Buffer As String, ByVal BufSize As Integer) As

Integer

Declare Function PAWSOFFWriteProfileString Lib "Kernel" Alias

  "WriteProfileString" (ByVal Section As Any, ByVal Entry As Any, ByVal

Value As Any) As Integer

Const BufSz = 1024

Const BufSzAll = 4096

'The most recently read profile file is cached in memory. This flushes the

  cache.

Sub FlushPrivateProfile (ByVal FileName As String)

    Dim R As Integer

    R = PAWSOFFWritePrivateProfileString(0&, 0&, 0&, FileName)

End Sub

'WIN.INI is cached in memory. This flushes the cache.

Sub FlushProfile ()

    Dim R As Integer

    R = PAWSOFFWriteProfileString(0&, 0&, 0&)

End Sub

'Like the API call but allows the use of VB's Null in place of a C-style NULL

Function GetPrivateProfileString (ByVal Section As String, ByVal Entry As

  Variant, ByVal Default As String, ByVal FileName As String) As String

    Dim Buffer As String

    Dim R As Integer

    If (IsNull(Entry)) Then

        'Get names of all entries in the named section

        Buffer = String$(BufSzAll, 0)

        R = PAWSOFFGetPrivateProfileString(Section, 0&, Default, Buffer,

           BufSzAll, FileName)

    Else

        'Get the value of the named entry

        Buffer = String$(BufSz, 0)

        R = PAWSOFFGetPrivateProfileString(Section, CStr(Entry), Default,

           Buffer, BufSz, FileName)

    End If

    GetPrivateProfileString = Left$(Buffer, R)

End Function

'Like the API call but allows the use of VB's Null in place of a C-style NULL

Function GetProfileString (ByVal Section As String, ByVal Entry As Variant,

  ByVal Default As String) As String

    Dim Buffer As String

    Dim R As Integer

    If (IsNull(Entry)) Then

        'Get names of all entries in the named section

        Buffer = String$(BufSzAll, 0)

        R = PAWSOFFGetProfileString(Section, 0&, Default, Buffer, BufSzAll)

    Else

        'Get the value of the named entry

        Buffer = String$(BufSz, 0)

        R = PAWSOFFGetProfileString(Section, CStr(Entry), Default, Buffer,

          BufSz)

    End If

    GetProfileString = Left$(Buffer, R)

End Function

'Retrieve an entry from a multi-entry string

Function StrEntry (ByVal S As String, ByVal Which As Integer) As String

    If (Which < 1) Then StrEntry = "": Exit Function

    Dim Pos As Long

    Dim Curr As Integer

    Curr = 1

    Pos = 1

    'Pos = starting character of entry #Curr

    Do Until (Curr = Which)

        Pos = InStr(Pos, S, Chr$(0))

        If (Pos = 0) Then

            StrEntry = ""

            Exit Function

        End If

        Pos = Pos + 1

        Curr = Curr + 1

    Loop

    'Pos = starting character of entry #Which

    'Find end of this line

    Dim LineEnd

    LineEnd = InStr(Pos, S, Chr$(0))

    If (LineEnd = 0) Then

        StrEntry = Right$(S, Len(S) - Pos + 1)

    Else

        StrEntry = Mid$(S, Pos, LineEnd - Pos)

    End If

End Function

'Find the number of NUL separated entries in a string

Function StrNEntries (ByVal S As String) As Integer

    Dim NNuls As Integer

    Dim Pos As Integer

    Pos = 1

    NNuls = 1

    Do While (True)

        Pos = InStr(Pos, S, Chr$(0))

        If (Pos = 0) Then

            StrNEntries = NNuls

            Exit Function

        Else

            Pos = Pos + 1

            NNuls = NNuls + 1

        End If

    Loop

End Function

'Like the API call but allows the use of VB's Null in place of a C-style NULL

Sub WritePrivateProfile (ByVal Section As String, ByVal Entry As Variant,

ByVal Value As Variant, ByVal FileName As String)

    Dim R As Integer

    If (IsNull(Entry)) Then

        'Delete named section

        R = PAWSOFFWritePrivateProfileString(Section, 0&, 0&, FileName)

    ElseIf (IsNull(Value)) Then

        'Delete named entry within the section

        R = PAWSOFFWritePrivateProfileString(Section, CStr(Entry), 0&,

           FileName)

    Else

        'Insert or replace the entry

        R = PAWSOFFWritePrivateProfileString(Section, CStr(Entry),

       CStr(Value), FileName)

    End If

    If (R = 0) Then Err = 32767

End Sub

'Like the API call but allows the use of VB's Null in place of a C-style NULL

Sub WriteProfile (ByVal Section As String, ByVal Entry As Variant, ByVal

Value As Variant)

    Dim R As Integer

    If (IsNull(Entry)) Then

        'Delete named section

        R = PAWSOFFWriteProfileString(Section, 0&, 0&)

    ElseIf (IsNull(Value)) Then

        'Delete named entry within the section

        R = PAWSOFFWriteProfileString(Section, CStr(Entry), 0&)

    Else

        'Insert or replace the entry

        R = PAWSOFFWriteProfileString(Section, CStr(Entry), CStr(Value))

    End If

    If (R = 0) Then Err = 32767

End Sub

----cut here----

--

Joe Foster (joe@bftsi0.UUCP or joe%bftsi0.uucp@uunet.uu.net)

CIO/Head Geek/Top Jolt Addict, BFTSI


INI reading

LUOKKA: INI

Date: 07/07/94 (18:34)              Number: 11472 of 11683 (Refer# NONE)

From: DSTECKEL@SILVER.SDSMT.EDU

Subj: Re: GetPrivateProfileString ???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Don't forget to initialize the string variable to all spaces before you call

GetPrivateProfileString. i.e.:

Dim ProgramPath As String

Dim X As Integer

ProgramPath = String$(30, " ")     'This is what I'm talking about

X = GetPrivateProfileString("Paths", "ProgramPath", "C:Ö", 30,

"MYPROG.INI")


INI summary

LUOKKA: INI

Date: 04/29/94 (20:23)              Number: 4664 of 4664 (Refer# NONE)

From: RDHALL@KOPTSS03.DELCOELECT.COM, Rakesh Dhall

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Thanks to all who replied to my inquiry about reading from the .INI file.

I got some good responses about how to set it up and use it.

--------------

Here is a quick summary:

To set it up in VB:

For getting strings :-

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal

lpApplicationName

As String,

              ByVal lpKeyName As String,

              ByVal lpDefault As String,

              ByVal lpReturnedString As String,

              ByVal nSize As Integer,

              ByVal lpFileName As String) As Integer

Declare Function WritePrivateProfileString Lib "Kernel" (ByVal

lpApplicationName As String,

        ByVal lpKeyName As String,

        ByVal lpString As String,

        ByVal lplFileName As String) As Integer

where lpApplicationName = Section name

 lpKeyName   = Key name

 lpDefault   = Default string to return

 lpReturnedString  = Buffer for returned string

 nSize    = Size of Buffer

 lpFileName   = The name of the .INI file

For getting integer values :-

Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal Section As String,

          ByVal Entry As String,

          ByVal Default As Integer,

          ByVal FileName As String) As Integer

Declare Function GetProfileInt Lib "Kernel" (ByVal Section As String,

          ByVal Entry As String,

          ByVal Default As Integer) As Integer

---

Rakesh Dhall 1-5489(8-322)              rdhall@koptss03.delcoelect.com

Engineering Systems Engineer            Electronic Data Systems

Powertrain Test Development Support     Delco Electronics Account


INI VB:n ini ja Help

LUOKKA: INI

Päivä: 06-05-94 (10:52)             Numero: 2115 / 2218 (Vast. nro 2111)

Knlle: EERO LEHIKOINEN

Knltä: KARI RINNE

 Aihe: VB:n INI ja HELP...

Luettu: 06-06-94 (03:53)              Tila: Julkinen viesti

 Kok.: Ohjelmointi (23)           Lukumalli: Etsi tekstiä (+)

> GetPrivateProfileInt - returns int value

> WORD GetPrivateProfileInt( LPSTR lpApplicationName  'lpOhjelmanNimi?

>                          , LPSTR lpKeyName          'MikäsTämäOlisi?

>                          , int nDefault             'JaTämä?

>                          , LPSTR lpFileName )   'NoTämänTaidanTietää

>                                                 'VaiTiedänköSittenkään

> Jos joku voisi hieman tarkentaa? ja tuo LPSTR, mitäs tuo tarkoittaakaa

UINT GetPrivateProfileInt(

    LPCSTR lpszSection,   /* address of section                   */

    LPCSTR lpszEntry,     /* address of entry                     */

    int default,          /* return value if entry not found      */

    LPCSTR lpszFilename); /* address of initialization filename   */

LPSTR     32-bittiseksi koodattu osoite merkkijonoon

LPCSTR    muuten sama mutta kertoo että funktio ei muuta

          merkkijonoa (constant)

Merkkijonojen pitää päättyä null-tavuun, eli c-merkkijonoja.

UINT GetPrivateProfileInt(  // palauttaa numeroarvon ini.tiedostosta

                            // 0 ... 32767

                            // esim. MySpesialCardIRQ=2

    LPCSTR lpszSection,     // Ini-tiedostot tavataan jakaa osiin,

                            // esim. ÄHardwareÅ, eli etsi siitä osasta

    LPCSTR lpszEntry,       // minkä arvon haluat palauttaa esim.

                            // MySpesialCardIRQ arvon

    int default,            // palauta tämä arvo ellei ole määritelty

    LPCSTR lpszFilename )   // Ini-tiedoston nimi. Ellei polkua ole

                            // määritelty, etsitään Windows-hakemistosta.

C:llä malli olisi seuraava, basicista en tiedä.

irkku = GetPrivateProfileInt( "Hardware", "MySpesialCardIRQ",

0, "spescard.ini" );


INI VB:n ini ja Help

LUOKKA: INI

Päivä: 06-07-94 (02:49)             Numero: 2118 / 2218 (Vast. nro 2115)

Knlle: KARI RINNE

Knltä: EERO LEHIKOINEN

 Aihe: VB:n INI ja HELP...

Luettu: 06-07-94 (22:51)              Tila: Julkinen viesti

 Kok.: Ohjelmointi (23)           Lukumalli: Etsi tekstiä (+) on vastauksia

KR>C:llä malli olisi seuraava, basicista en tiedä.

Paljolti samanlainen!

KR>irkku = GetPrivateProfileInt( "Hardware", "MySpesialCardIRQ",

KR>                               0, "spescard.ini" );

Annas kun arvaan:

ApplicationName = "Test"

KeyName = "EkaOsa"

IniFile = "Test.ini"

R = GeyPrivateProfileInt(ByVal ApplicationName,ByVal KeyName,0,ByVal

  IniFile")

Siis tuo ByVal ettei arvoa muuteta.

Tuo siis noutaa numero arvon, kun Int-lopussa korvataan String:llä siin

saadaan merkkijono, kiitti, taisi aueta minullekkin ;) kylläpä kesti.

Täytynee kokeilla tuota, Kiitti! Aiankin tuosta suomenkielisestä

osasta, se selvitti PALJON.

Hm, taitaa olla nuo windowsin kutsut jotenkin samanlaisia kielestä

riippumatta.


INI VB:n INI ym.

LUOKKA: INI

Päivä: 06-07-94 (19:33)             Numero: 2120 / 2218 (Vast. nro 2111)

Knlle: EERO LEHIKOINEN

Knltä: SAMI PITKO

 Aihe: VB:n INI ja HELP...

Luettu: 06-08-94 (00:10)              Tila: Julkinen viesti

 Kok.: Ohjelmointi (23)           Lukumalli: Etsi tekstiä (+)

>GetPrivateProfileString - returns string

>WritePriviteProfileString

>Kummallista vaikka noin selvät ohjeet mutta ei silti men päähän!

Tämän tallennat kovalevyllesi vaikkapa nimellä INIHANDL.BAS (Kaikki

rivit joissa on alussa alaviiva, pitää korjata jatkumaan edellisen rivin

loppuun.)

--- INIHANDL.BAS

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal

_       lpApplicationName As String, ByVal lpKeyName As Any, ByVal

_       lpDefault As String, ByVal lpReturnedString As String, ByVal

_       nSize As Integer, ByVal lpFileName As String) As Integer

Declare Function WritePrivateProfileString Lib "Kernel" (ByVal

_       lpApplicationName As String, ByVal lpKeyName As Any, ByVal

_       lpString As Any, ByVal lplFileName As String) As Integer

Const BUFFER_SIZE = 1024    ' Luettavien stringien maksimipituus

Function ReadIni (Filename As String, Section As String, Keyname As

_       String) As String

    Dim i As Integer, Default As String, ReturnedStr As String

    ReturnedStr = String$(BUFFER_SIZE, Chr$(0))

    Default = "DEFAULT STRING"

    i = GetPrivateProfileString(Section, Keyname, Default, ReturnedStr,

_       Len(ReturnedStr), Filename)

    i = InStr(ReturnedStr, Chr$(0))

    If i <> 0 Then

        ReturnedStr = Left$(ReturnedStr, i - 1)

    End If

    If ReturnedStr <> Default Then

        ReadIni = ReturnedStr

    Else

        ReadIni = ""

    End If

End Function

Sub WriteIni (Filename As String, Section As String, Keyname As String,

_       Value As String)

    Dim i As Integer

    i = WritePrivateProfileString(Section, Keyname, Value, Filename)

End Sub

---

Sitten lisäät tiedoston projektiisi (.MAK tiedostoon). Helpoiten hoituu

valitsemalla Visual Basicin menuista File/Add file ja sitten valitset

file-dialogista tiedoston INIHANDL.BAS. Tällöin sinun ei tarvitse tehdä

tähän tiedostoon mitään muutoksia ja voit käyttää sitä vaikka kaikissa

ohjelmissasi.

Kun haluat kirjoittaa INI-tiedostoon, kutsut:

        Call WriteIni("EERON.INI", "Ohjelman asetukset", "Taustaväri",

_       "YÖNSININEN")

Jolloin tiedosto EERON.INI näyttää tältä:

--- EERON.INI

ÄOhjelman asetuksetÅ

Taustaväri=YÖNSININEN

---

INI-tiedostoissa saa käyttää skandeja. Ne ovat Windowssissa

ISO-skandeja, joten jos joskus eksyt DOSsin puolelle, niin siellä ne

näyttävät sigmoilta ja summilta. (Esim. EDITillä tutkiessa)

Ja kun haluat lukea tiedostosta, niin kutsut:

        TaustaVari$ = ReadIni("EERON.INI", "Ohjelman asetukset",

_       "Taustaväri")

Ja jos meinaat tallennella paljon tietoa INI-tiedostoon, niin kannattaa

määritellä INI-tiedoston nimi:

        Global Const EERON_INI_TIEDOSTO = "EERON.INI"

Säästää nimitäin ohjelman kokoa melkoisesti. Toinen kikka on se, että

muuttaa sen Globaliksi muuttujaksi ja muuttaa sen ohjelman alussa:

        EERON_INI_TIEDOSTO = App.Path & "ÖEERON.INI"

Jolloin sinun pitää säilyttää INI tiedostoa ohjelman kanssa samassa

hakemistossa. Muuten se _pitää_ olla windows hakemistossa.

Jossain vastauksesta mainitusta VB:n stringien päättämisestä nollaan

(C-tyyli), niin tuolla Declare rivillä mainittu ByVal hoitaa sen

automaagisesti, kuten manuaaleissa mainitaan.

Spitco


INI why app.ini ??

LUOKKA: INI

Date: 06/27/94 (12:00)              Number: 10752 of 10897 (Refer# NONE)

From: CEZAR_MART@MINDLINK.BC.CA

Subj: Why <app>.ini file?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I have a rather complex application that maintains a database on the

NT server. The database is in native Access format. I open the database

with False,False options (multiuser..) On another client I run a similar

program that shares the same database. Sometimes when it starts it freezes

on opening the database. When I walk to the first client and quit the

program the second program starts. It happens only sometimes. After

days of struggling with it I wrote <app>.ini files for both programs.

In those files I point at a shared system.mda files. And suddenly it

started working. Strange, because no VB manual says it is necessary

to have <app>.ini files and system.mda file. Because I'd like to

know what i'm doing, please, tell me why (if at all) it is required

to have those files.

Thanks in advance

Cezar


Instances detect prev

LUOKKA: API

Date: 08/16/94 (10:13)              Number: 15752 of 15821 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Previous instance of application

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

From VB Tips & Tricks v1.9

Detecting Previous Instances Of A Program

Detecting A Previous Instance Of A Program And Exiting

There are times when you may want to prevent a second instance of your

program from running. The App object provides a PrevInstance property that

allows you to determine whether a previous instance of the program is

running. Here's how you might write your code:

Sub Form_Load ()

If App.PrevInstance Then

   msg$ = App.EXEName & " already running "

   MsgBox msg$, 48

   End

End If

End Sub

Notice that the procedure uses the EXEName property of the App object to

display the program's name in the Visual Basic message box.

Source: Microsoft Developer Network News, July 1993

Detecting A Previous Instance Of A Program And Restoring

Below is how to detect a previous instance of a program. If it's found,

this routine then restores the program.

Declare the following:

Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal

  lpWindowName As Any) As Integer

Declare Sub ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal

nCmdShow As Integer)

Declare Sub SFocus Lib "User" Alias "SetFocus" (ByVal hWnd As Integer)

CheckUnique Function:

Function CheckUnique (F As Form) As Integer

'Check for previous instance of application. If found, ensures

'is restored from Icon and Focused on! It is up to Main routine

'to end application if required.

Dim x As Integer

Dim Title As String

    CheckUnique = True

    If App.PrevInstance Then

        'MsgBox "Prev Instance found!"

        Title = F.Caption

        F.Caption = Title & " - New"    'This is necessary as you may find

                                                     yourself!

        hWnd = FindWindow(0&, Title)

        F.Caption = Title               'Restore caption

        DoEvents

        If hWnd Then

            'MsgBox "Handle found!"

            ShowWindow hWnd, 1          'Restores from Minimsed if necessary

            DoEvents

            SFocus hWnd                 'Sets focus

            DoEvents

            CheckUnique = False

        End If

    End If

End Function

Tip Submitted By: Terry Brooking

This function can be found with the new version of COMMON01.BAS that

came with this help file.


Instances detect prev

LUOKKA: API

Date: 05/11/94 (21:46)              Number: 5419 of 5645 (Refer# NONE)

From: TARRJ@CCMAIL.US.DELL.COM

Subj: Re: Preventing multiple instances

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Matt - could you modify the code below (taken from KB) ?  You pass the

function the Title information of your app in the Form_Load Event and it will

check to see if it is already loaded.  The CheckUnique() function uses

FindWindow to return a handle if an instance is already running.

'Form_Load.....

'It is important that the title (specified using the variable Title$ below)

'is not the same as the EXE filename. Because the form has not been shown

'when Form_Load is called, the title is temporarily 'set to the EXE filename.

'As such, attempting to run the first instance of the application will fail

'since CheckUnique will return False.

Title$ = "Your Title Here"

X% = CheckUnique(Title$)

If X% = False Then

   End

End If

'Declaration section...

'Calls used to set focus to a previous instance if it exists

Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any, ByVal

lpCaption As Any)

Declare Function ShowWindow% Lib "User" (ByVal Handle As Integer, ByVal

Cmd As Integer)

Declare Function SFocus% Lib "User" Alias "SetFocus" (ByVal Handle As

Integer)

Function CheckUnique (FormName As String) As Integer

Dim Handle%

Dim X%

    Handle% = FindWindow(0&, FormName)

    If Handle% = 0 Then

        ' -1 is a true value.

        CheckUnique = True

    Else

        X% = ShowWindow(Handle%, 1)

        X% = SFocus(Handle%)

        ' 0 is a false value.

        CheckUnique = False

    End If

End Function


Instances prev.copies

LUOKKA: VBgen

Date: 10/19/94 (12:27)              Number: 23579 of 23637 (Refer# NONE)

From: CSTUART@METRONET.COM

Subj: Re: Preventing multiple copies of App

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>How can I prevent the user from being able to run multiple copies

>of my app at once?

This will bring the original copy.

   If app.PrevInstance Then

        app.Title = app.Title & Space$(1)

        Me.Caption = Me.Caption & Space$(1)

         AppActivate "MyApp"

         SendKeys "% R", True

   End If

------------------------------------------------------------------------

Chuck Stuart

Mesquite TX USA


Internationalize

LUOKKA: VBgen

Date: 09/20/94 (15:06)              Number: 20088 of 20148 (Refer# NONE)

From: EBBE@DBM.FI

Subj: Re: Select language

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

There are several. The way I've done it is to use a set of language-

specific DLLs, and a master DLL that knows how to call the correct

language.

Then, I use the Tag property of Labels and the HelpContextID property

of other controls, and load strings from the appropriate DLL using

the values of those properties as the string resource number. The string

load function resides in the master DLL, and gets called with the

resource ID and the code of the current language.

In a form_load event I loop through every control on the form, and call

the string load function using the appropriate property of the control.

All messages, titles and other texts have an entry in the various

DLLs as well.

--

Ebbe Jonsson, Systems Mangler                            ebbe@dbm.fi

DBM Database Marketing Oy, Helsinki, FINLAND

Tel: +358 0 605 900, Fax: +358 0 605 991                 " Why me? "


Internationalize

LUOKKA: VBgen

Date: 09/24/94 (16:31)              Number: 20633 of 20702 (Refer# NONE)

From: MANNY.BAGNAS@SANDIEGOCA.NCR.COM

Subj: SUMMARY: Internationalization

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

As promised, here is the summary of responses to my request for

help on internationalization of VB apps.  Ironically, the most

helpful hint was posted to this newsgroup under a separate (but

related) topic.  My thanks to all who contributed.

Begin responses

-----------------------------------------------------

I have written a database analyser called Daisy and have both

British/American versions of the software. There are surprisingly few things

that have to be done to deal with those two languages and VB handles them

well. (The most important thing is to get your spelling right, as we have all

done a superb demo in a foreign country and you have been rubbished

becuase you mis-spelt colour!)

This is probably because Windows does things reasonably well and if you

handle everything through Windows and the formatting and decode calls that

come with it, provided you have the Internationalisation right everything

works. (The only problem we had was when a company changed the country

from 1 (USA) to 44 (UK) half-way through entering data into an Access

database. half the dates had the months first and the

other had the days. Try sorting that one out!)

By the way a lot of my German and French friends prefer to run in English as

they always feel it looses in translation and they get a version months behind.

(This probably says how bad the language skills of the English are, rather

than anything about forcing English software on Europe!)

James Miller

Daisy@CityScape.co.uk

-------------------------------------------------------------

This topic came up earlier this summer or so. I think there were no

responses. This would not be the first time Microsoft completely botched

the national language issue. I don't think they handled it well in NT.

NT does provide a model. Its resource files have a language level in the

hierarchy. I know several people who have written tools for WinApps (VB

included) to use NT resource files. These were internal use only. This

would provide a way, but I can't afford to hire someone to do it yet.

Meanwhile we are going to be rewriting our apps language by language.

Don't know what we will do in places such as Switzerland and Quebec where

we may have to change languages dynamically.

 --

Gerald Ruderman

g@vanward.ci.net

---------------------------------------------------------------------

I'm currently writing a program, that must be able to run under any given

windows environment, and thus I must establish the users International

settings in his/hers WIN.INI file.  All output to the screen is then

formatted according to these settings, and all input is then validated

before convertion to a neutral format.

A good example is dates. I've decided from the start, that I will use the

Windows Short date format for all input and dispaly.  Therefore I make a

GetProfileString call to the WIN.INI file, where I get the value of the

sShortDate key. Example:

  'Get the WIN.INI international shortdate setting.

  LReturn = Space$(NSize + 1)

  SectionName = "INTL"     'International

  KeyName = "sShortDate"

  N% = GetProfileString(SectionName, KeyName, Empty, LReturn, NSize)

  sShortDate = Left$(LReturn, InStr(LReturn, Chr$(0)) - 1)

This value is assigned to a global value that is then

used in all displays by use of f.instance:

txtDate = format$(date(),sShortDate)

Regarding saving in a neutral format, f.instance when saving a particular

date to a database, I first use the IsDate function to verify if the

variable's value can pass as an date, and then I convert the date through

the CnVDate function before saving it to the database, for example:

  If Not IsDate(txtDate) Then

    msg "Re-enter date !",MB_ICONEXCLAMATION, "Incorrect Date Format"

    Exit Sub

  End If

  'L2 is a table, "File Date" is in field in this database table.

  L2("File Date") = CVDate(txtFileDate)

 ---------------------------------------------------------------------

 " Mr. Arne J. Boye-Moeller                                          "

 "                         Direct Tel. work: (+45) 75 45 44 88 - 121 "

 " Frodesgade 125 A               Telefax:   (+45) 75 18 15 39       "

 " DK-6700 Esbjerg, DENMARK       e-mail:    abm@rhh.dk              "

----------------------------------------------------------------------------

There are several. The way I've done it is to use a set of language-

specific DLLs, and a master DLL that knows how to call the correct

language.

Then, I use the Tag property of Labels and the HelpContextID property

of other controls, and load strings from the appropriate DLL using

the values of those properties as the string resource number. The string

load function resides in the master DLL, and gets called with the

resource ID and the code of the current language.

In a form_load event I loop through every control on the form, and call

the string load function using the appropriate property of the control.

All messages, titles and other texts have an entry in the various

DLLs as well.

--

Ebbe Jonsson, Systems Mangler                            ebbe@dbm.fi

DBM Database Marketing Oy, Helsinki, FINLAND

Tel: +358 0 605 900, Fax: +358 0 605 991                 " Why me? "


Internationalize

LUOKKA: VBgen

Date: 10/17/94 (20:44)              Number: 23329 of 23461 (Refer# NONE)

From: ABLEY@ORIGINUK.DEMON.CO.UK

Subj: Multi-language support in app

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Does anybody have a favourite way to provide multiple-language support

for a Visual Basic application?

We need to provide the facility to run an application in English, German

or Russian, including all (or most) of the menus, labels, and button controls

which appear on every form. The user needs to be able to change language

at will, not just at install time. We have a Cyrillic true-type font.

The way we've thought of doing it at the moment is to stick a routine

in the form_load event of every form, which would re-write the .Caption

and .Text properties of appropriate controls on the form with those

appropriate to the currently selected language. It's slightly complicated

by the fact that we need to change font as well, for Russian.

The different captions, etc. could be stored in an .MDB which is accessed

by this routine, to allow the text to be changed easily without recompiling.

1. Is this is a crazy way to do it? Is there a better way?

2. If we do it like this, is there a way to obtain a list of the visible

   controls on a form? That way our .MDB records could contain fields like:

   <formname> <controlname> <language> <font> <string>

   and we could use a call to the same routine in the form_load event

   of every form.

Joe

 <abley@originuk.demon.co.uk>


Internationalize

LUOKKA: VBgen

Date: 10/18/94 (12:26)              Number: 23396 of 23461 (Refer# NONE)

From: D1CAMERO@BCSC02.GOV.BC.CA

Subj: Re: Multi-language support in app

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

One app I wrote only required support for french and english so I used

a method simliar to yours, except I did not use a database, I used

internal constants (the app only have maybe 10 forms).  One  thing I did

a bit different was to use two sets of labels which I would make visible

or invisible, depending on the language.  For a small app this was OK,

and allowed me to place the labels dependant on the translation.

All messages were kept in a multidimensional array, which worked well.

Don Cameron

d1camero@bcsc02.gov.bc.ca

Victoria, British Columbia, Canada


Internationalize

LUOKKA: VBgen

Date: 11/15/94 (09:54)              Number: 128603 of 128905 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: International Keyboards - number handling

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Chuck Huston <huston@CSB.VARIAN.COM> wrote:

>I'm having problems with the Val function (used with text boxes to

>translate their string data into numerical data).  For example, a

>U.S. configuration with a text box entry of "6.37" will correctly

>Val to the number 6.37.  When a French user (with appropriate drivers,

>control panel setting, etc.), however, enters the same number as "6,37"

>(note they use a comma "," instead of a decimal point "."), the Val

>doesn't recognize the comma as a number delimiter and puts 6 into the

>variable.

>

>What am I missing?  Do I have to manually parse commas for non-U.S.

>users?

Use CInt or CFloat, etc. They work a treat with international numbers.

Antony


Joystick

LUOKKA: joystick

Date: 05-28-95 (02:25)              Number: 344417 of 345086 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: How To: Read JoyStick

There are several API functions for joysticks in MMSYSTEM.DLL that comes

with Win3.1. I think only two are required in VB,  joyGetPos%  and

joyGetDevCaps%. Below are some declarations and constant definitions for

you.

' Joystick error return values

Global Const JOYERR_NOERROR = 0      ' No error

Global Const JOYERR_PARMS = 165      ' Bad parameters

Global Const JOYERR_NOCANDO = 166    ' Request not completed

Global Const JOYERR_UNPLUGGED = 167  ' Joystick is unplugged

' Constants used with JOYPOS

Global Const JOY_BUTTON1 = &H1

Global Const JOY_BUTTON2 = &H2

Global Const JOY_BUTTON3 = &H4

Global Const JOY_BUTTON4 = &H8

' Joystick ID constants

Global Const JOYSTICKID1 = 0

Global Const JOYSTICKID2 = 1

' Joystick Capabilities

Type JOYCAPS

  Mid As Integer            ' Manufacturer ID

  Pid As Integer            ' Product ID

  Pname As String * 32      ' Product name

  Xmin As Integer           ' Min and max position values

  Xmax As Integer

  Ymin As Integer

  Ymax As Integer

  Zmin As Integer

  Zmax As Integer

  NumButtons As Integer     ' Number of buttons

  PeriodMin As Integer      ' Minimum message period when captured

  PeriodMax As Integer      ' Maximum message period when captured

End Type

' Size of JOYCAP structure (needed for function call)

Global Const JOYCAPSIZE = 54

' Joystick Position Information

Type JOYPOS

  X As Integer              ' X, Y, and Z position

  Y As Integer

  Z As Integer

  Buttons As Integer        ' Button states

End Type

' Windows API Joystick functions

Declare Function joyGetDevCaps% Lib "MMSystem" (ByVal JoyId%, JCaps As

JOYCAPS, ByVal CapSize%)

Declare Function joyGetPos% Lib "MMSystem" (ByVal JoyId%, JPos As

JOYPOS)

Rgds,

John


Joystick code

LUOKKA: joystick

13400 (58+)  KPICKUP@OZEMAIL.COM.AU  07.04.95  01:00

Keith Pickup: "Re: ***Joystick Code Needed.*** - Reply"

You can access the joystick via the driver that Windows provides or you

could

use my DLL which does not require the driver. Functions are:

Declare Function STICK% Lib "JOYSTICK.DLL" (ByVal XorY%)

Declare Function STRIG% Lib "JOYSTICK.DLL" (ByVal Which%)

'STICK: Reads Joystick position

'STICK(0)    Reads Joystick 1, x-Position

'STICK(1)    Reads Joystick 1, y-Position

'STICK(2)    Reads Joystick 2, x-Position

'STICK(3)    Reads Joystick 2, y-Position

'STICK(1) .. STICK(3) are the positions stored at the time of the last

STICK(0).  That means that a STICK(0) is needed to really read both sticks

positions.

'STRIG: reads joystick buttons

'STRIG(0)    Checks if the first button of first joystick is pressed and has

not been pressed the last time STICK(0) has been called.

'STRIG(1)    Checks if the first button of the first joystick is currently

being pressed

'STRIG(2)    Checks if the second button of first joystick is pressed and has

not been pressed the last time STICK(2) has been called.

'STRIG(3)    Checks if the second button of the first joystick is currently

being pressed

'STRIG(4)    Checks if the first button of second joystick is pressed and has

not been pressed the last time STICK(4) has been called.

'STRIG(5)    Checks if the first button of the second joystick is currently

being pressed

'STRIG(6)    Checks if the second button of second joystick is pressed and

has

not been pressed the last time STICK(6) has been called.

'STRIG(7)    Checks if the second button of the second joystick is currently

being pressed

'The odd numbers return -1 if the corresponding buttons are held down. The

even numbers return -1 only if the buttons are just pressed down

Let me know if you want it?

kpickup@ozemail.com.au


Key pressed

LUOKKA: timing

Date: 05/28/94 (01:20)              Number: 7269 of 7311 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Timing Key up/down events

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 27/5/94, Mark wrote to ALL: *****>>

MM> I'm writing an app. that needs to time how long each key is pressed.

MM> I've used the timer control with the Key up/down events.The main

MM> problem I believe is that the keyboard (?) or Windows is doing an

MM> auto-repeat of the key and creating these events again. This effectivly

MM> ruins the timing.  Does anyone know how I can get the time (In .5 or so

Dim PressedTime As Long

Dim fPressed As Integer

Declare Function GetCurrentTime& Lib "USER" ()

Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)

    If Not fPressed Then

        PressedTime = GetCurrentTime()

        fPressed = True

    End If

End Sub

Sub Text1_KeyUp (KeyCode As Integer, Shift As Integer)

    ReleaseTime& = GetCurrentTime()

    fPressed = False

    Label1 = Str$(ReleaseTime& - PressedTime)

 End Sub


Keyb.buffer clearing

LUOKKA: misc

Date: 10/25/94 (11:11)              Number: 24398 of 24448 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Clearing Keyboard Buffer

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

-------------------------------------------

HUOM! parempi tapa: disabloi koko formi...

-------------------------------------------

JD>How do I clear the keyboard buffer in VB win?

JD>I'm using the Form_KeyPress... it's a game for my kid which when he

JD>presses a key, a picture will be loaded and a wav will be played

JD>simultaneously. The problem is, he bangs the keyboard thus about five

JD>characters are fed in the buffer.  Please help... any idea at all...

How about a workaround?  Assign a value to a global flag in the KeyDown

event, then test for it at the top of the event.  If the value still

exists, set KeyAscii = 0, otherwise accept the value.

        Sub Form_KeyPress

           If flag% <> 0 then KeyAscii = 0 Else flag% = 1

        End Sub

Reset the value (flag% = 0) at the bottom of the event that plays the

WAV.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                                m_rubin@tatertot.com


Kysymys

LUOKKA: misc

Päivä: 07-30-95 (12:03)

Numero: 537 / 537 (Vast. nro EI OLE)

Knltä: ILKKA MAATTA

 Aihe: Visual Basic:lla tekstin scrollausta ja muuta

 Kok.: fi.atk.ohjelmointi (23)    Lukumalli: Yleinen (A) (+)

Olisiko jolla kulla VisualBasicille valmis rutiini tai

idea kayttokelpoisesta rutiinista miten saisi maaratyn

tekstin juoksutetuksi vaakasuunnassa text, label kont-

rollissa tai ikkunan otsikossa niin etta ensin tulee

haluttu teksti jota seuraa ao tekstin mittainen vali.

Samaan tapaa kun noissa ulkomainoksissa scrollaa teksti.

Ja toinen juttu, VB:ssa on jokin keino haistella mihin

Windows on asennettu. Milla sen saa ongittua selville?

        -Ilkka-


Landscape/portrait

LUOKKA: printing

Date: 12/23/94 (14:48)              Number: 30594 of 30737 (Refer# NONE)

From: AANIBADEV@AOL.COM

Subj: Re: Landscape & Portrait on same page???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Declare this in a module:

******************

Type LOGFONT

    lfheight As Integer

    lfwidth As Integer

    lfescapement As Integer

    lforientation As Integer

    lfweight As Integer

    lfitalic As String * 1

    lfunderline As String * 1

    lfstrikeout As String * 1

    lfcharset As String * 1

    lfoutprecision As String * 1

    lfclipprecision As String * 1

    lfquality As String * 1

    lfpitchandfamily As String * 1

    lffacename As String * 32

End Type

Declare Function CreateFont% Lib "GDI" (ByVal H%, ByVal W%, ByVal E%,

  ByVal O%, ByVal W%, ByVal I%, ByVal U%, ByVal S%, ByVal C%, ByVal

OP%,

  ByVal CP%, ByVal Q%, ByVal PAF%, ByVal F$)

Declare Function CreateFontIndirect Lib "GDI" (lpLogFont As LOGFONT) As

  Integer

Declare Sub deleteobject Lib "GDI" (ByVal hObject As Integer)

Declare Function SelectObject Lib "GDI" (ByVal hDC As Integer, ByVal

  hObject As Integer) As Integer

Declare Function TextOut Lib "GDI" (ByVal hDC As Integer, ByVal X As

  Integer, ByVal Y As Integer, ByVal lpString As String, ByVal nCount As

  Integer) As Integer

Declare Sub GetTextFace Lib "GDI" (ByVal hDC As Integer, ByVal nCount As

  Integer, ByVal lpFacename As String)

Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC As Integer, ByVal

  nIndex As Integer) As Integer

*********************

Once this ia declared, use this code:

Dim font as LOGFONT

font.lfwidth = 0

font.lfescapement = 900

font.lforientation = 900

font.lfweight = 400

font.lfitalic = Chr$(0)

font.lfunderline = Chr$(0)

font.lfstrikeout = Chr$(0)

font.lfcharset = Chr$(0)

font.lfoutprecision = Chr$(0)

font.lfclipprecision = Chr$(0)

font.lfquality = Chr$(2)

font.lfpitchandfamily = Chr$(33)

font.lffacename = "Arial" + Chr$(0)

font.lfheight = 36

hfont = CreateFontIndirect(font)

holdfont = SelectObject(printer.hDC, hfont)

printer.CurrentX = 800

printer.CurrentY = 2500

printer.Print Format$(Now, "mm-dd-yy, hh:mm AM/PM")

deleteobject hfont

printer.EndDoc

**************************

Try this to see how this works for you. The lfheight and the lforientation

are what you need to change. Keep in mind that the currentx and currenty

are going to be weird. Play with it.


Line breaks

LUOKKA: TextBox

Date: 06/24/94 (12:25)              Number: 10300 of 10373 (Refer# NONE)

  To: ALL

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: How to add CRLF to mu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 06-25-94 GAT@CSN.ORG  wrote:

G>wjm (weijin@panix.com) wrote:

G>:  In the multi-line text box, I added the CRLF characters to the

G>: end of lines. The text displays two vertical lines for the CRLF

G>: instead wrap the line. How can I start new lines in a text box?

Almost.  The "soft" break that Microsoft uses is CR & CR & LF, or

Chr$(13) + Chr$(13) + Chr$(10).  Try it that way.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Line breaks

LUOKKA: TextBox

Date: 06/24/94 (08:45)              Number: 10340 of 10373 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: How to add CRLF to mu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 06-26-94 Luke Webber wrote:

LW>If the text box *is* multiline, you must have messed up in assigning

LW>CRLF. It should be Chr$(13) & Chr$(10). Do *not* get them the wrong

LW>way  around, a printer wouldn't care, but a text box certainly will.

Chr$(13) & Chr$(13) & Chr$(10) in multiline textboxes.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


Line breaks

LUOKKA: TextBox

Date: 06/24/94 (09:06)              Number: 10343 of 10373 (Refer# NONE)

From: ELLEN@MAX.TIAC.NET

Subj: Re: How to add CRLF to mu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Michael Rubin (michael.rubin@pcgfx.com) wrote:

: Chr$(13) & Chr$(13) & Chr$(10) in multiline textboxes.

Remember the cartoon characters who start falling of a cliff only after they

realize they no longer on a solid ground ? For about a year now I've been

using textboxes with only CR & LF . Bet you that now, after I read Michael's

response, all my application will show those 2 vertical lines and I'll spend

all day Monday converting everything to CR & CR & LF .

- muni .    muni@cibadiag.com


Line Feeds to CRLF

LUOKKA: VBgen

Date: 02-10-95    Time: 12:51p     Number: 80

From: weikko.ikola@csc.fi           Refer:

Subject: Code Snippet: LF to CRLF          0: comp.lang.ba   Status: Public

This function converts Line Feeds (LF, chr$(10)) to Carriage Return-Line

Feed

couples (CRLF, chr$(13) & chr$(10)) in a string. Number of converted lines is

available in LCnt.

Function Lines (ByVal a As String, LCnt As Integer) As String

Dim LF As String: LF = Chr$(10)

Dim CRLF As String: CRLF = Chr$(13) & LF

Dim S As String

'

' LF (x'0a') to CRLF (x'0d' x'0a')

'

i = 1

K = 1

LCnt = 0

While K

    K = InStr(i, a, LF)

    If K > 0 Then

        S = S & Mid$(a, i, K - i) & CRLF

        LCnt = LCnt + 1

    Else

        S = S & Mid$(a, i)

    End If

    i = K + 1

Wend

Lines = S

End Function


Line speed up

LUOKKA: VBgen

28510 (44+)  rcw@netcom.com  31.07.95  22:43

Robert Woodcock: "Re: Speeding up Line Method? Possible?"

Mark A. Odell (mao@tiac.net) composed eloquently:

>I'm writing a waveform viewer that has up to 12

>picture boxes, each displaying a different physiologic

>signal. Each screenful is about 4K samples per picture

>box. On my Pentium, plotting this data using an initial

>pic.Pset(0, sig_val(0)) then successive

>pic.Line -(idx, sig_val(idx)) calls takes too long to plot

>each signal, about a second or two per signal (I have 12

>signals so 12 to 24 seconds per screen). My customer would

>like to run this on 486's so just imagine the results.

>Anyhow, anyone got any VB tips on how I might speed this

>plotting process up? Are there DLL's in the USER or GDI to

>help with fast plotting?

There are the GDI functions MoveTo and LineTo, which should be near

drop-in replacements for what you're doing.

Just remember, the default scaling mode is *PIXELS*, and changing the

ScaleMode property doesn't cut it.

Here's the decs:

Declare Function MoveTo& Lib "GDI" (ByVal hDC%, ByVal X%, ByVal Y%)

Declare Function LineTo% Lib "GDI" (ByVal hDC%, ByVal X%, ByVal Y%)

The hDC parameter should be set to Control.hDC, and for quickie functions

like this you can get away with caching it in a variable. (I don't

recommend storing it between plots, though)

My guess is your code looks something like this:

<code to fill array>

Pset (0,sigval(idx))

For idx = 1 to ubound(sigval)

Picture1.Line -(idx,sigval(idx))

DoEvents

Next

If so, that DoEvents is gonna hurt.

Try only calling it every 10th or 20th time:

If idx Mod 10 = 0 then DoEvents

You can get a nice speedup by drawing to a memory hDC (autoredraw = true)

and then copying that to the visible control as necessary (and only as

necessary)

You say you have 12 of these things? You'd be wasting memory by setting

all of the autoredraw properties to true. Try making another picture box,

invisible, autoredraw = true, the same size as all the others, draw to

it, then bitblt its contents (or the updated portion) to the visible

picture box as necessary (perhaps every 10 plots). It depends on what

your customer wants in the way of interacting. (S)he might put priorities

on seeing the whole thing in .5 seconds, or seeing it drawn

over 1 second.

If you need scaling, it takes a little bit of API mucking, because the

Scale* properties won't work. You need 5 functions:

First you call SetMapMode(), SetWindowExt(), and SetWindowOrg().

SetMapMode sets scaling to MM_ISOTROPIC or MM_ANISOTROPIC, which

defines how the x and y dimensions scale together. For this, you'll want

MM_ANISOTROPIC.

SetWindowExt sets the equivilent of the ScaleWidth and ScaleHeight

properties.

SetWindowOrg sets the equivilent of the ScaleTop and ScaleLeft properties.

Next, you need to call GetClientRect to get a RECT structure of this,

which you pass the bottom and right elements to SetViewPortExt.

I don't really understand this too well myself, I'm taking it out of some

nicely commented example code. I hope I haven't missed anything... :/

I don't know how fast you can hope to get it, but you should be able to

cut that 24 seconds down to at least 12. Good luck!

_________________________________________________________

Robert Woodcock

rcw@netcom.com


Linked ListBox

LUOKKA: ListBox

Date: 08/08/94 (12:00)              Number: 14912 of 15159 (Refer# NONE)

From: MCCRACKEN_DG@LINCOLN.GPSEMI.COM

Subj: Re: How to disable List Box Scroll Bars?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <14@tiger.DIALix.oz.au> wolfs@tiger.DIALix.oz.au (Wolfgang

Steinert) writes:

>In article <Cu4M65.F3u@undergrad.math.uwaterloo.ca>, Stephen Johnston

(sjjohnst@undergrad.math.uwaterloo.ca) writes:

>>I'm linking the data in two list boxes together, and I would like to disable

>>(clear) the scroll bar in one of them.  Does anyone know of an API call or

>>message that I can send that will do this?

>

>I was looking for something similar the other day and posted the

>Question to the Group. Unfortunately it seems you can't do it. (

>At least that's what the replies implied ). Then again I might be

>wrong. Maybe someone DOES find the solution. If you know, please

>post it to the net.

> Regards ... Wolf

The reply I saw in this group was to cover the bar with another item

i.e. a pic object with no picture in it. I used method this to cover

that little white gap in a combo box

I set the back colour to the same colour as the form's background so in

effect it was not seen by the user (thanks to VBPJ).

Dave McC.


Linked ListBox

LUOKKA: ListBox

Date: 08/11/94 (17:09)              Number: 15201 of 15234 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: linked listboxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Look into the API.  On the click of one listbox you can use a SendMessage

API with the LB_GETTOPINDEX message to get the index of the item at the

top viewable portion of the list box.  Then you can use SendMessage again

with LB_SETTOPINDEX to set the top index of the other listbox.

(Declarations)

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

    ByVal wParam%, ByVal lParam As Any)

Global Const WM_USER = &H400

Global Const LB_ERR = -1

Global Const LB_GETTOPINDEX = WM_USER+15

Global Const LB_SETTOPINDEX = WM_USER+24

(Code)

lngTopIndex = SendMessage(lst1.hWnd, LB_GETTOPINDEX, 0&, 0&)

If SendMessage(lst2.hWnd, LB_SETTOPINDEX, lngTopIndex, 0&) = LB_ERR

then

    'Error

End If

__________

                           Bradley S. Murray


Linked ListBox

LUOKKA: ListBox

Date: 08/25/94 (08:39)              Number: 16949 of 17020 (Refer# NONE)

From: DSJ@PIPELINE.COM

Subj: Re: linked list boxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

From VBKB as of 6/94 - Q103809

The example below uses two list boxes, side by side, to demonstrate this

technique to simulate the appearance of two list boxes scrolling together.

Step-by-Step Example

--------------------

1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)

   if Visual Basic is already running.  Form1 is created by default.

2. Add two list boxes, one timer control, and one command button to Form1.

   For the best visual effect, place the list boxes side by side with the

   List1 box on the left.

3. Add the following code to the (general) (declarations)

section of Form1:

   DefInt A-Z

4. Add the following code to the Form Load event procedure of Form1:

   Sub Form_Load ()

      'Initialize two list boxes with the alphabet

      For i = 1 To 26

         list1.AddItem Chr$(i + 64)

      Next i

      For i = 1 To 26

         list2.AddItem Chr$(i + 64)

      Next i

      Timer1.Interval = 1

      Timer1.Enabled = True

   End Sub

5. Add the following code to the Command1 Click event procedure of Form1:

   Sub Command1_Click ()

      End

   End Sub

6. Add the following code to the Timer1_Timer event procedure

of Form1:

   Sub Timer1_Timer ()

      Static PrevTI_List1

      'Get the index for the first item in the visible list

      TopIndex_List1 = list1.TopIndex

      'See if the top index has changed

      If TopIndex_List1 <> PrevTI_List1 Then

         'Set the top index of List2 equal to List1 so that the list boxes

         'scroll to the same relative position

         list2.TopIndex = TopIndex_List1

         'Keep track of the current top index

         PrevTI_List1 = TopIndex_List1

      End If

      'Select the item in the same relative position in both list boxes

      If list1.ListIndex <> list2.ListIndex Then

         list2.ListIndex = list1.ListIndex

      End If

   End Sub

7. Press the F5 key to run the program. Select a letter in the List1 box.

   Then try the scroll bar of the List1 box. You should see the same letter

   highlighted in the List2 box when you select a letter from the List1

   box. Then when you try the scroll bar of the List1 box, you should see

   the List2 box scroll in unison with the List1 box.

That's how you link list boxes per MS.

sj


Linked ListBox

LUOKKA: ListBox

Date: 09/03/94 (20:45)              Number: 18214 of 18257 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Scrolling Tandem List Boxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I can't believe as much as I preach the benefits of Idle Loops, I

completely overlooked the obvious solution to this problem as follows:

Sub Form_Load ()

   Dim I As Integer

   form1.Show

   For I = 0 To 99

      list1.AddItem Str$(I)

      list2.AddItem Str$(I)

   Next I

   Do

      list2.TopIndex = list1.TopIndex

      DoEvents

   Loop

End Sub

As I have said before, the Idle loop will have absolutely no

other effect on your program.

Chuck

Mesquite TX


Linked ListBox

LUOKKA: ListBox

Date: 09/17/94 (19:57)              Number: 19860 of 19876 (Refer# NONE)

From: EMMETTH@NETCOM.COM

Subj: Re: need hlp with advanced list box technique

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The following program works by using the  SendMessage to select the items

in the list box.  This stops the program from 'Ping-Ponging' caused by

List1 calling list2's click event which calls list1's click even which...

Option Explicit

Const WM_USER = &H400

Const LB_SETSEL = (WM_USER + 6)

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

 wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Sub Form_Load ()

    'Init List 1

    List1.AddItem "Item 1-1"

    List1.AddItem "Item 1-2"

    List1.AddItem "Item 1-3"

    List1.AddItem "Item 1-4"

    List1.AddItem "Item 1-5"

    'Init List 2

    List2.AddItem "Item 2-1"

    List2.AddItem "Item 2-2"

    List2.AddItem "Item 2-3"

    List2.AddItem "Item 2-4"

    List2.AddItem "Item 2-5"

End Sub

Sub List1_Click ()

    Dim Counter As Long

    Dim RetCode As Long

    For Counter = 0 To List1.ListCount - 1

        RetCode = SendMessage(List2.hWnd, LB_SETSEL,

List1.Selected(Counter), ByVal Counter)

    Next Counter

End Sub

Sub List2_Click ()

    Dim Counter As Long

    Dim RetCode As Long

    For Counter = 0 To List2.ListCount - 1

        RetCode = SendMessage(List1.hWnd, LB_SETSEL,

List2.Selected(Counter), ByVal Counter)

    Next Counter

End Sub


ListBox > 64 k

LUOKKA: ListBox

6025 (3+)  Don.Sleffel@WichitaKS.attgis.com  28.07.95  04:23

Don Sleffel: "New Listbox VBX breaks 64K barrier"

I frequently see inquiries here about a listbox that will hold huge

amounts of data, i.e. greater than 64K.

I just uploaded a listbox VBX to the CICA Indiana site that will

acceptmillions of items.  As of today it was still only in the

/pub/pc/win3/uploads directory.  The file is blist.zip.

BLIST.VBX is a Visual Basic control which implements a virtual list

box.  The control has the same look and feel, most of the same

properties, and functions as the default list box.  The difference is,

that unlike the standard list box which is limited to 64K of data,

BLIST can display up to 5 million lines of any size.  BLIST was

designed to display data from a database which could possibly be

greater than what could be saved in a standard list box.  Often in

these applications it is impossible to know ahead of time how much

data will be returned from a data base query.

As much as possible BLIST functions the same as the standard list box,

however there are a few differences.  Read the documentation with it

for details.  I included some sample VB code with it to demonstrate

its operation.  If anyone uses it I would be most interested in your

comments.

 Don Sleffel	<Don.Sleffel@WichitaKS.attgis.com>

 2118 Frontenac

 Wichita, KS  67219


Listbox > 64k

LUOKKA: ListBox

26219 (100+)  mskilton@wharf.demon.co.uk  19.07.95  12:37

Mike Skilton: "Re: Beating the Listbox 64K limit"

Philip Patel <advisor@alabama.com> wrote:

>Is this a personel challenge.  If not, why not purchase a VBX

>of the shelf for about $100 and solve the problem.  I'm

>assuming there are some out there that break the 64K limit and

>I think there are.

>advisor@alabama.com

Why not use VBMSG.VBX or MSGBLST.VBX and make the listbox owner

draw, then you can have 8192 entries of any string length you like...

------------

Mike Skilton

  Internet : mskilton@wharf.demon.co.uk

CompuServe : 100445,1555


ListBox > 64kB

LUOKKA: ListBox

Date: 11/19/94 (03:53)              Number: 132233 of 132515 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Listbox > 64 kB found!

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

I recently found a listbox that is able to contain more than

64 kB of data. The limit is 2024 character per line and 8192

lines. The VBX is called MLIST.VBX and I found it on the Pegasus 5

CD.

Unfortunately the VBX is dated from February '94 (Version 4.20). But I know

for sure that there are several updates availabe until now. The recent version

should be 4.56. You can get the updates in the MS-BASIC-forum on

Compuserve. But I don't have access to Compuserve and I can't find the VBX

anywhere on a FTP-server. So I would like to know wether anyone of you

guys joining this list who has access to Compuserve would be so kind to

fetch the MList.vbx and put it on a FTP-server and let us know which one?


ListBox 500K needed

LUOKKA: ListBox

Date: 06/06/94 (15:04)              Number: 8197 of 8514 (Refer# NONE)

From: TSLIM@SOLOMON.TECHNET.SG

Subj: Re: Listbox with 500K data needed

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I wrote some codes to handle this.  What I did was to swap half of the

items in the listbox to a temporay file, and then swap the other half

in.  Not a nice solution, but I didn't have to pay extra bucks.

If anyone is interested, I can mail the codes.


ListBox adding icons

LUOKKA: ListBox

Date: 11/30/94 (18:30)              Number: 28472 of 28565 (Refer# NONE)

From: DAARON@UCLINK2.BERKELEY.EDU, David A. Karp

Subj: Re: ListBox Questions

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> Just wonder if I can add a small icon at the beginning of a line in the list

> box. Do I have to do it via API calls or there is a simplier way ? Or if

>there > is some listbox VBX can do this ?

Also, you can use the free vbx, XLIST, that comes with VB3 Professional.

(kts. ..\cdk )


ListBox Cbo preselect

LUOKKA: ListBox

Date: 08/25/94 (19:05)              Number: 17023 of 17029 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Setting text in drop-

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Pre-selecting in the combobox...

(Declarations)

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

ByVal wParam%, lParam As Any)

Global Const WM_USER = &H400

Global Const LB_SELECTSTRING = WM_USER + 13

Sub cListBoxSet (lstBox As Control, ByVal strNewText$, flgClickBypass%)

'Sets a list box to the given text if it is in the list

'If not it un-sets the list box

Static lRet&

    gflgClickBypass = flgClickBypass

    lRet = SendMessage(lstBox.hWnd, LB_SELECTSTRING, -1&, strNewText)

    gflgClickBypass = False

End Sub

__________

                           Bradley S. Murray


ListBox graphics

LUOKKA: ListBox

Date: 03-16-95 (22:48)              Number: 260945 of 262621 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Graphics in a List Bo

to your first question. One quick'n'dirty approach is to use grid control.

Place your icons in the first column, other data in the second and remove

gridlines. Of course usage is a little bit tedious, but it looks quite OK. I

have used this, but prepared small BMPs - 32 x 16 (W x H) pixels, they look

better than normal sized icons in my opinion.

    Lasse


ListBox ItemData etc.

LUOKKA: ListBox

Date: 10/22/94 (21:41)              Number: 24100 of 24188 (Refer# NONE)

From: TAYLOR@SATURN.BROOKS.AF.MIL, William D. Taylor

Subj: Re: Help with listboxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I would then like the user to be able to select an item from the list and for

>all the associated fields to that corresponding record in the file to be

>displayed in the relevant text boxes.  The problem I have it that I wish for

>the list to be sorted and I am having trouble associating each item in the

>list with its corresponding record in the file.

The problem with using ItemData in a sorted list is that you don't know the

index of the item after using the AddItem method.  So how do you then set

the ItemData(index) property for the item?  It's fairly simple using API calls.

I wrote the function described below (which should be extended to return an

error on an error condition).

The following subroutine will allow you to add an item to a list control (or

combo box), associate a long value with the item, optionally disallow a

duplicate addition, and optionally select the item.  This is not possible

without API calls since VB 3.0 does not return the position of the inserted

item if the list is sorted, which effectively prevents furthur manipulation of

the item (such as setting the ItemData property or selecting the item).  Also

the VB AddItem method always add an item, never checking for an existing

exact duplicate, which may be undesirable.

A space followed by an underscore is used to indicate line continuation ( _).

Const WM_USER = &H400

Const LB_ADDSTRING = (WM_USER + 1)

Const LB_SETSEL = (WM_USER + 6)

Const LB_SETCURSEL = (WM_USER + 7)

Const LB_SELECTSTRING = (WM_USER + 13)

Const LB_FINDSTRINGEXACT = (WM_USER + 35)

'Const LB_ERR = (-1)

'Const LB_ERRSPACE = (-2)

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Any) As Long

Sub AddListItem (lisControl As Control, ByVal ItemText As String, ItemData As

  Long, AddDuplicate As Integer, SelectItem As Integer)

'AddDuplicate (boolean):  True=always add; False=add if not duplicate

'SelectItem (boolean):  True=select item (works with sorted lists)

    '* add error handling

    Dim ItemPos As Long

    ItemText = ItemText & Chr$(0)

    If AddDuplicate = False Then 'check for matching item

        ItemPos = SendMessage(lisControl.hWnd, LB_FINDSTRINGEXACT, -1,

          ItemText)

    End If

    If (ItemPos < 0) Or (AddDuplicate = True) Then 'not found or always add

       ItemPos = SendMessage(lisControl.hWnd, LB_ADDSTRING, 0, ItemText)

    End If

    If ItemPos >= 0 Then 'no error

        lisControl.ItemData(ItemPos) = ItemData

        'If SelectItem=True then lisControl.ListIndex = ItemPos 'may cause

                                                                           ' click event

            If lisControl.MultiSelect = 0 Then

            If SelectItem = True Then

                ItemPos = SendMessage(lisControl.hWnd, LB_SETCURSEL,

          ItemPos, 0&)

            End If

        Else

            ItemPos = SendMessage(lisControl.hWnd, LB_SETSEL, SelectItem,

               ItemPos&)

        End If

    End If

End Sub


ListBox layout probl.

LUOKKA: ListBox

Date: 07/01/94 (22:47)              Number: 10998 of 11050 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: List Box Layout Probl

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 07-01-94 George R. wrote:

GR>: wrote: Well, I thought I was nuts but I've run into a layout

GR>: problem that I haven't seen mentioned anywhere. As I carefully

GR>: layout four or five  list boxes I notice that they have definite

....

GR>The listbox resizes according to the font used so the item on the

GR>bottom of the listbox will be fully displayed, i.e, (listbox height /

GR>font height) * font height.  This, as you'll find out, is controlled

GR>by the absence of the LBS_NOINTEGRALHEIGHT listbox style.

GR>Unfortunately, you can't do didly about it with just VB.

Actually, you can.  Use the SetClassWord% API function with a GCW_STYLE

message.  You can change the class bit so that the listbox does or

doesn't report to it's parent.  That way it will still recalculate

integral height, but only when YOU want it to.  Email me for help.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


ListBox LB_AddString

LUOKKA: ListBox

Date: 05/14/94 (12:01)              Number: 5923 of 5978 (Refer# NONE)

  To: ALL

From: MICHAEL.RUBIN@PCGFX.COM

Subj: textbox repaint

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I've been watching this thread, and thought for certain that the

SendMessage API function suggested would solve the problem - it di for

me in the past.  Since Jeff posted an unhappy response, I thought I'd

post some code in hopes of helping him out (I executed this incorrectly

a few tiles before I got it right):

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

-->

 <-- ByVal wParam%, lParam As Any)

Declare Function SendMessageBynum& Lib "User" Alias "SendMessage" -->

 <-- (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam&)

Declare Function SendMessageByString& Lib "User" Alias "SendMessage"

-->

 <-- (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam$)

    temp% = SendMessageBynum&(list1.hWnd, WM_SETREDRAW, 0, 0)

    For x% = 0 To NumDisplay% - 1

 temp% = SendMessageByString&(lstName.hWnd, LB_ADDSTRING, 0,-->

 <-- AddStr$)

    Next x%

    temp% = SendMessageBynum&(list1.hWnd, WM_SETREDRAW, 1, 0)

The key here is that you MUST use LB_ADDSTRING to add a string to the

listbox.  The AddItem method overrides the SendMessage function and

washes out the whole effort.  Try it one more time, Jeff.  BTW, this

works well for any control with a hWnd property.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


ListBox many fields

LUOKKA: ListBox

Date: 03/30/94 (13:38)              Number: 2335 of 2518 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: List box display

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (+)

On 03-28-94 BKISHI@NEWS.DELPHI.COM  wrote:

B>Does anybody have tips (or know of free code somewhere) that can help

B>me implement a directory-style list in VB?  In particular, I have

B>several records of data, each with 5 fields.  I want to display all

B>the fields and sort by any of them, quickly.  (Like the filename,

B>date, and size fields in a directory list)  In addition, I want to be

B>able to select multiple records  and delete records.

B>Is the grid control the answer?  I'm worried it will get quite slow

B>and bulky to write to all those rows and columns...

B>The list boxes don't seem to be powerful enough.  Is that true?

It's remarkable what you can get the lowly listbox to do.  In this case,

I suggest creating a user type of variable:

>>Type YourVar

>>     FileName As String * 12

>>     Date As String * 8

>>     ...

>>End Type

and create an array called A of type YourVal:

>>Global A As YourVal

Next, read all of the values from your data object into the array just

after you create your Table object or Dynaset.  Now, suppose you want to

wish to see only the filename and the date.  You would create a string

that included only those variables and add it to the listbox.  The

ListIndex value would correspond to the element of the array:

>>For x% = 0 to NumberOfRecords% - 1

>>     List1.AddItem = A(x%).Filename + Chr$(9) + A(x%).Date

>>Next x%

Here's how to use it: when you double-click on a listbox string, the

ListIndex property tells you which element in the array the listbox

string came from.  Set a temporary string variable to a distinctive

element in the array, say the filename:

>>TempStr$ = A(List1.ListIndex).FileName

and do a FindFirst through the Dynaset (or a Seek through the Table if

you want to move fast) to set the record pointer on the correct record.

I know it sounds convoluted.  Most database actions seem ridiculously

complicated when you are dealing with only a few records, but they work

very well when the record count grows larger.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatetot.com


ListBox PgUp/PgDn

LUOKKA: ListBox

Date: 08/17/94 (01:03)              Number: 15870 of 15901 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: VBPRO:WIN

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 08-16-94 S.PANTER@DCE.VIC.GOV.AU  wrote:

S>Does anyone know how to send a page up/page down instruction to a list

S>box on  button click event?

Use the SendMessage API function:

First, send a LB_GETITEMHEIGHT message to determine the height of a

typical string, then divide the listbox's height by that number to get

the number of strings visible.

Next, get the current ListIndex, and add the number of visible strings

to it.  That calculation will give you the ListIndex of the string that

you'll want to be in the top position.

Lastly, send a LB_SETTOPINDEX message with the newly calculated

ListIndex to tell the listbox to display that string on top.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                                m_rubin@tatertot.com


ListBox redraw

LUOKKA: ListBox

5. How do I speed up control property access?

   Instead of using a property in a loop, you will be better off using

   a normal variable in the loop and then assign the variable once to

   the property afterwards. Also, when reading a property, you should

   read it once into a variable instead of using it in a loop.

   Sometimes it is not possible to simply put contents of a property

   into a variable. For example, if you are using a list box or you

   need to conserve memory. In these cases you can send the

   WM_SetRedraw message to the control to prevent redrawing. You can

   typically increase the speed 6-10 times - or even more.

     'Add the following declares:

     Declare Function SendMessage Lib "User" (ByVal hWnd As

     "Integer, ByVal wMsg As Integer, ByVal wParam As

     "Integer, lParam As Any) As Long

     Const WM_SetRedraw = &HB

     'Add this to your code:

     Result% = SendMessage(Text1.hWnd, WM_SetRedraw, 0, 0)

     'redraw off

     'Do your stuff here!

     Result% = SendMessage(Text1.hWnd, WM_SetRedraw, 1, 0)

     'redraw on

   This same method applies to list boxes and other controls.


ListBox RemoveItem

LUOKKA: ListBox

Date: 08/08/94 (22:46)              Number: 14982 of 15159 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: Problem w/ RemoveItem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article: <tarrj.505.000C9DEB@ccmail.us.dell.com>

tarrj@ccmail.us.dell.com (John Tarr) writes:

>

> Just a guess but if you are trying to remove multiple items from a Multiple

> select listbox you need to start at the bottom and work your way up so the

> ListIndex for each item doesn't change on you.  Rule of thumb - Add from

top

> to bottom, Delete from bottom to top.

> For i% = Yourlst.ListCount - 1 To 0

>    If Yourlst.Selected(i%) Then

>       Yourlst.RemoveItem i%

>    Endif

> Next

This is amazing. Sir, you must truly be psychic! Not only did you

answer a blank posting, you also answered a problem I was about to post

on. Thanks very much for preemptively sorting my problem for me!

Just one point. I found that I need to put "Step -1" at the end of the

For statement. If I leave this out it doesn't work. If it does work for you

I'd be interested to know how.

Ian Piper


ListBox resize fixed!

LUOKKA: ListBox

26583 (16+)  tomw@tsys.demon.co.uk  20.07.95  23:27

Tom Wheeley: "Re: Resizing Problem. Help!"

> Robert Gelb (rgelb@csulb.edu) wrote:

> : I have a form with label on the top of the form and a listbox just

> : underneath the label.

>

> : For some strange reason, when I try to reset the height property of the

> : listbox, it doesn't want to comply.

>

> List boxes always size to a multiple of the font height whether in design

> mode or at run time.

> Greetings from down under from Ian Barnes, author of VB Servants.

Not if you set the right style bits they don't :-)

Setting LBS_NOINTEGRALHEIGHT (&H100) will do the trick nicely!


ListBox sample phone

LUOKKA: ListBox

============================================================

Date:         Wed, 21 Sep 1994 09:55:16 EDT

From:         "Vernon V. Soehner" <vsoehner@NECTECH.COM>

Subject:      Max. item in List Box

Hi. For what its worth and IMHO maybe this might help.  I just wrote

similar type inquiry app for a phone directory with about 1000 items x 85

characters wide, which is very fast off a network.  Less than 1/2 second.

Here is quick description of my approach. The bottle neck (as usual) is

going to be the I/O to get the data.  So I kept it short and simple with as

little interface as possible.  My input file is ordinary already sorted

ascii text file by last name.  I am not sure what a word-wheel is, but I

set up a command button array for 26 letters of the alpahbet( similar to

some common help menus).  The user simply clicks on a selected letter (for

example "B" button) and my code opens the file, reads it sequentialy

looking for the "B"'s whereupon it loads a listbox with "additem" command

until it hits the "C"s and stops. It does not have to read any further

which saves I/O time.  I believe the max size of data that can be in a list

box is 64K. By using the letter buttons, I have minimized the data which is

loaded in the listbox.  I also set up a search box to search the file for

all strings of data. I also had to set of a trap for if a user enters a

very non-unique search string ('E' for example) for when the 64K boundary

is hit. The user will get "Search String not unique enough message.".  Good

Luck.

    Dim I

    I = 65 + Index          ' set I to decimal 65 which is ascii A and array index

    Letter = Chr(I)          ' convert it to a string

    RecNum = 0

    FileNum = 1

    On Error GoTo Open1Err

    Open "w:\user\phone.dat" For Input Access Read Shared As #1 Len =

    4096

    On Error GoTo Mem1err

    Do While Not EOF(1)

        Line Input #FileNum, nextline         ' read a line

        If Left(nextline, 1) = Letter Then    ' check first character

        List1.AddItem nextline, RecNum

        RecNum = RecNum + 1

        End If

        If Left(nextline, 1) > Letter Then Exit Do ' Exit to save runtime

    Loop

    Close

 _/  _/ Vern Soehner, MA. and N.H. in U.S.A.

  _/_/  vsoehner@nectech.com

    _/    vern.soehner@f127.n324.z1.fidonet.org


ListBox scroll

LUOKKA: ListBox

Date: 09/26/94 (21:03)              Number: 20813 of 20918 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Can I .... on textfie

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I need to be able to choose one specific line in a textfield, just as you

>do when you are choosing an articel in your newsgroup, the articel vill

>pop up when you double-click on it.

>Is there anyone that have a suggestion for a solution on this matter.

What's wrong with using a listbox?  If not, there are sendmessage calls you

can make to find the current line index in the text box.  Just do it on

the Text_DoubleClick event.

Global Const WM_USER = &H400

Global Const EM_LINEFROMCHAR = WM_USER + 25

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

  ByVal wParam%, lParam As Any)

Function GetLineNumber% (txtIn as Control, ByVal intCharPos%)

  'Returns the line number where intCharPos resides

  If intCharPos <= 1 then

    GetLineNumber = SendMessage(txtIn.hWnd, EM_LINEFROMCHAR,

 intCharPos, 0&)

  Else

    GetLineNumber = SendMessage(txtIn.hWnd, EM_LINEFROMCHAR,

 txtIn.SelStart, 0&)

  End If

End Function

__________

                           Bradley S. Murray


ListBox searches

LUOKKA: ListBox

27165 (233+)  jari.kallonen@guisys.pp.fi  24.07.95  23:01

jari Kallonen: "Re: Listbox searches"

jcaputo@realtech.com (Jim Caputo) wrote:

>Is there a way of searching a listbox the same way it's done in Help

>files, the Search for Help on option, using the first several letters

>of the item, rather that just the first letter.

'To general section of form

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Const WM_USER = &H400

Const LB_FINDSTRING = (WM_USER + 16)

'To textbox change event

Sub Text1_Change ()

   'Searchin matced string

   Dim ix%

   ix = miFindItem(List1, (Text1.Text))

   If ix = -1 Then Exit Sub

   List1.ListIndex = ix

End Sub

'form function

Function miFindItem% (lst As ListBox, sTarget As String)

   miFindItem = SendMessage(lst.hWnd, LB_FINDSTRING, -1, ByVal

sTarget)

End Function

'This should work, have summertime

'Jari Kallonen


ListBox searches

LUOKKA: ListBox

27777 (119+)  aod@dodge.com  27.07.95  18:38

Andrew O. Dennison: "Re: Listbox searches"

Option Explicit

' 8/5/94 aod added win api's

' routines optimized for searching a list box

' 2/21/95 aod the WIN API do not obey case !!

' replaced with a single generalize routine

' options to FIND

Global Const CaseSensitive = 0

Global Const CaseInsensitive = 1

Global Const Prefix = False

Global Const FullString = True

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Const WM_USER = &H400

Const CB_ERR = (-1)   ' not found

Const CB_FINDSTRINGEXACT = (WM_USER + 24)

Const CB_FINDSTRING = (WM_USER + 12)

Const LB_FINDSTRING = (WM_USER + 16)

Const LB_FINDSTRINGEXACT = (WM_USER + 35)

Const LB_ERR = (-1)   ' not found

' Finds exact strings or just a prefix in a cbo or lst box

' with or w/o case-sensitivity

' compare% = CaseSensitive or  CaseInsensitive

' exact% = false for prefix match only

' rowIndex% is set only if found

Function boxFind% (lst As Control, ByVal item$, rowIndex%, compare%,

exact%)

    Dim l%, index%

    If exact% Then

        l% = 32000          ' compare entire item

    Else

        l% = Len(item$)     ' only first l letters must match

    End If

    ' linear search

    Debug.Print item$, l%

    For index% = 0 To lst.ListCount - 1

        'Debug.Print Left$(lst.List(index%), l%)

        If StrComp(Left$(lst.List(index%), l%), item$, compare%) = 0

Then

            boxFind% = True

            rowIndex% = index%

            Exit Function

        End If

    Next index%

End Function

' returns TRUE, index is set to item found

Function cboFindPrefix% (cbo As Control, item$, index%)

    cboFindPrefix% = boxFind%(cbo, item$, index%, CaseSensitive,

Prefix)

End Function

' N.B. must be a cbo Box

' search from initial index, (-1) is start

' returns TRUE index is set to item found

'       FALSE, index is set to -1 (CB_ERR)

Function cboFindPrefixIgnoreCase% (cbo As ComboBox, ByVal item$,

index%)

    index% = SendMessage(cbo.hWnd, CB_FINDSTRING, index%, ByVal

item$)

    cboFindPrefixIgnoreCase% = index% <> CB_ERR

End Function

' Search lst & cbo for exact match

' do binary search if sorted

' return TRUE and rowIndex to entry found

' handles any type of list control

' use WIN for unsorted LIST & COMBO Boxes

' else return false and rowindex = -1

' use binary search if sorted

Function lstFind% (lst As Control, ByVal entry$, rowIndex%)

    Dim low%, high%

    If lst.Sorted Then

        ' binary search

        low% = 0

        high% = lst.ListCount - 1

        While low% <= high%

            rowIndex% = (low% + high%) ™ 2

            'Debug.Print low%, rowIndex%, high%

            Select Case lstStrComp%(entry$, lst.List(rowIndex%))

            Case -1        ' entry < list

                high% = rowIndex% - 1

            Case 0          ' equal

                lstFind% = True

                Exit Function

            Case 1

                low% = rowIndex% + 1

            End Select

        Wend

        ' not found, exits at bottom

    Else

        ' linear search

        For rowIndex% = 0 To lst.ListCount - 1

            If lst.List(rowIndex%) = entry$ Then

                lstFind% = True

                Exit Function

            End If

        Next rowIndex%

        Exit Function

    End If

    rowIndex% = -1  ' not found

End Function

' Search by item data

' if found returns TRUE, and sets rowindex

Function lstFindItemData% (lst As Control, ItemData%, rowIndex%)

    Dim i%

    For i% = 0 To lst.ListCount - 1

        If lst.ItemData(i%) = ItemData% Then

            lstFindItemData% = True

            rowIndex% = i%

            Exit Function

        End If

    Next i%

End Function

' returns TRUE, index is set to item found

Function lstFindPrefix% (lst As Control, item$, index%)

    lstFindPrefix% = boxFind%(lst, item$, index%, CaseSensitive,

Prefix)

End Function

' N.B. must be a lst Box

' search from initial index, (-1) is start

' returns TRUE index is set to item found

'       FALSE, index is set to -1 (CB_ERR)

Function lstFindPrefixIgnoreCase% (lst As ListBox, ByVal item$,

index%)

    index% = SendMessage(lst.hWnd, LB_FINDSTRING, index%, ByVal item$)

    lstFindPrefixIgnoreCase% = index% <> CB_ERR

End Function

' List boxes sort w/o case significance

' so 1st compare ignoring case, then be case sensitive

Function lstStrComp% (ByVal l$, ByVal r$)

    Dim comp%

    comp% = StrComp(l$, r$, 1)

    If comp% = 0 Then   ' if matched then be case sensitive

        comp% = StrComp(l$, r$, 0)

    End If

    'Debug.Print comp%; l$, r$

    lstStrComp% = comp%

End Function


ListBox searches

LUOKKA: ListBox

Date: 01/04/95 (14:11)              Number: 31578 of 31612 (Refer# NONE)

From: LPETROF@EPIX.NET

Subj: TextBox Search of ListBox

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

First of all I want to thank all for helping me out... here is the one

I found worked best (I made a few adjustments to put it all in a .bas

file, and to add one desired feature to the function)  here's the code

Loren J. Petrof

lpetrof@epix.net

Just clip this entire thing.... paste it into a .bas file and follow the

declarations (btw... this is assuming that the listbox is List1 and the textbox is

Text1)

Žcut here�

' TextSearch has been developed by David A. Karp

' and had some slight adjustments made by Loren J. Petrof

' Included with this is the ListText_Change and ListText_GotFocus

' Put ListText_Change in the intended Textbox's change event

' and put ListText_GotFocus in the intended TexBox's GotFocus event

' Put the following Declare on one line

Declare Function SendMessageByString& Lib "User" Alias "SendMessage"

(ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam$)

Function FindMatch (object As Control, ByVal A$)

    On Error Resume Next

    Rem * find an entry in listbox _Object_ matching _A$_ *

    If A$ = "" Then Exit Function

    Dim B$, rt%

    B$ = A$

    Const LB_FINDSTRING = &H400 + 16

    Const LB_FINDSTRINGEXACT = &H400 + 35

    Do Until B$ = ""

        rt% = SendMessageByString(object.hWnd, LB_FINDSTRING, -1, B$)

        If rt% > -1 Then

            FindMatch = rt%

            Exit Function

        End If

        B$ = Left$(B$, Len(B$) - 1)

    Loop

    FindMatch = True

End Function

Sub ListText_Change ()

Rem * do search *

' The two following lines need to be on one line

Screen.ActiveForm.List1.ListIndex = FindMatch(Screen.ActiveForm.List1,

Screen.ActiveForm.Text1.Text)

End Sub

Sub ListText_GotFocus ()

Rem * highlight text *

Screen.ActiveForm.Text1.SelStart = 0

Screen.ActiveForm.Text1.SelLength = Len(Screen.ActiveForm.Text1.Text)

End Sub

Žend cut�


ListBox select all

LUOKKA: ListBox

Date: 10/17/94 (23:26)              Number: 23365 of 23461 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re: HELP: how does we sel

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

see correction below...

OC>how does we select or deselect all item's in a Listbox ?

OC>with the API application "Sendmessage..." ???

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

  wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Global Const WM_USER = &H400

Global Const LB_SETSEL = (WM_USER+6)

'to select all

r% = SendMessage(List1.hWnd, LB_SETSEL, True, -1&)

'to de-select all

r% = SendMessage(List1.hWnd, LB_SETSEL, False, -1&)

Can ONLY be used with multi-select listboxes.

Regards,  Email: ian.carter@almac.co.uk  CIS: 100435,3040

Ian C.    Tel/Fax: (+44)(0)1909-773689

-----correction----------------------------------------------------------------------

Date: 10/22/94 (21:26)              Number: 24096 of 24188 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: How does we Select ALL item in a listbox *FAST*

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>How does i select all item's in a listbox FAST....

-snip+

>r% = SendMessage(List1.hWnd, LB_SETSEL, True, -1&)

>'to de-select all

>r% = SendMessage(List1.hWnd, LB_SETSEL, False, -1&)

You were soooo close! Because lParam can be a string pointer, it's

declared As Any (no ByVal), so instead of -1& you need ByVal -1&. Et voila!

--

Luke Webber


ListBox size changing

LUOKKA: ListBox

Date: 07/01/94 (23:03)              Number: 10920 of 10926 (Refer# NONE)

From: SALSTE@CC.HELSINKI.FI

Subj: Re: dynamic list box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sounds pretty easy.

SUB Form_Resize()

LBox.Width = ScaleWidth - 2*LBox.Left

LBOX.Height = ScaleHeight - 2*LBox.Top

OR something else like that. OR you could even buy VSVBX to do that for

you.

--

Tuomas Salste      salste@helsinki.fi      http://www.helsinki.fi/~salste/


ListBox size changing

LUOKKA: ListBox

Date: 07/02/94 (16:30)              Number: 11044 of 11050 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: List Box Layout Problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Its a feature of (VB) list boxes that they adjust their height to show only an

integer number of lines in the specified box.  As you say, the problem can

occur when you change resolution if you were using in design mode a

bitmapped font such as MS Sans Serif.  In resolutions above 640 x 480 there

is an option of smaller/larger fonts and if the user has picked the opposite

set you have problems.

You can get round it by using Window's standard true type fonts such as

arial: only trouble is that is wider than MS Sans Serif.

You can get the same problem with labels and text boxes if you start off with

a bitmapped font which lacks the same point size in other resolutions.  The

way rounf is to design using the larger fonts then if the user adopts smaller

fonts it does not affect layout though it may look as though his pants don't

quite fit.

michael.cowan@almac.co.uk nottingham, england


ListBox sort desc.

LUOKKA: ListBox

Date: 08/07/94 (00:54)              Number: 14763 of 15159 (Refer# NONE)

From: TDH@MATH.UFL.EDU

Subj: Re: List Box w/desc sort?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

An inelegant but obvious way is to have 2 listboxes, one of which is invisble

and the other mirrors the first one but in reverse order. Additem to the

first listbox then update the second one. Something like this I think

listbox1.additem "newitem"

listbox2.additem "newitem", listbox1.listcount - listbox1.newindex

When newitem get added to listbox1, its index is recorded in

listbox1.newindex.

The distance betw newindex and the listcount is how far the newitem is from

the bottom of listbox1, which is also how far it should be from the top of

listbox2.


ListBox syncronizing

LUOKKA: ListBox

=============================================================

Date:         Thu, 6 Oct 1994 07:33:07 GMT

Comments:     MEMO 10/06/94 07:32:00

From:         "MURRAY, BRAD" <MURRAY1@BWMAIL1.HCC.COM>

Subject:      Synchronizing Listboxes

>>   Can I synchronize two listboxes? If I scroll in one box, I want

>>   the second box to scroll as well.

>Look at the TopIndex property....

That won't help you when you are scrolling.  You will have to put a timer

on your form that will check the TopIndex of the one with the focus and

set the other one.  Make a form-level variable that is set on the Set_Focus

event of each list box so yout know which one has the focus.

__________

                           Bradley S. Murray

 Princeton Computer Consulting, Inc.      Phone: (609) 799-5300

 20 Lorrie Lane  Box 7345                   Fax: (609) 275-5651

 Princeton, NJ 08543-7345              Internet: bmurray@pluto.njcc.com


ListBox trap scroll

LUOKKA: ListBox

===========

Date:         Wed, 14 Sep 1994 23:25:45 EDT

From:         Chuck Stuart <WJ5A@AOL.COM>

Subject:      Trap Scroll Bar Even...

>I would like to be to capture scrollbar events on a listbox.  Has anyone

>done this?

The only way is to monitor the listindex property inside an idle loop.

Chuck

Mesquite TX


Lists

LUOKKA: internet

=============================================================

Date:         Sat, 15 Oct 1994 10:56:25 -0400

From:         Ed Fields <efields@PSA.TIAC.NET>

Subject:      Repost: VB FAQ and LISTSERV location sites

You can have the VB FAQs e-mailed to you by sending a message

to "mail-server@rtfm.mit.edu" with ONLY the text

     send usenet/news.answers/visual-basic-faq/*

     in the BODY of the message.

Be informed that the response will include all parts of the VB FAQ and will

result in the reception of several mail messages.

---------------

Most FAQs (including this one) are available at the anonymous ftp archive

site "rtfm.mit.edu".  All parts of the VB FAQ may be found in the directory

"pub/usenet/comp.lang.basic.visual".

> Does anyone know the listserv addres for the MS ACCESS list?

                To: LISTSERV@INDYCMS.BITNET

        Subject:

        ----------------

        SUBSCRIBE ACCESS-L John Doe

        SET ACCESS-L DIGEST

> Does anyone know the listserv addres for the MS ACCESS list?

                To: LISTSERV@INDYCMS.BITNET

      Subject:

        ----------------

        SUBSCRIBE ACCESS-L John Doe

        SET ACCESS-L DIGEST

> Does anyone know the listserv addres for the MS EXCEL list?

                To: LISTSERV@INDYCMS.BITNET

        Subject:

        ----------------

        SUBSCRIBE EXCEL-L John Doe

        SET EXCEL-L DIGEST

>What is the name of the VB newsgroup on the Usenet?

        comp.lang.basic.visual

======================

General VB Programmer Interest Groups

WIN3-L            LISTSERV@UICVM.UIC.EDU

                 Microsoft Windows Version 3 Forum

WFW-L           LISTSERV@UMDD.UMD.EDU

                Microsoft Windows For Workgroups Forum

                (very busy!)

WINHLP-L      LISTSERV@HUMBER.BITNET

                 Windows Help Compiler (WINHELP) Discussion List

>please remember to send Subscribe message to LISTSERV not to the -L

address!


Long

LUOKKA: numbers

1702 (74+)  geir.tutturen@itf.nlh.no  16.12.94  10:55

Geir Tutturen: "Re: Longs don't work in VB."

In article <3crd8g$nee@crl4.crl.com>, jeremi@crl.com (William Jeremiah)

says:

>

>Print 32768   'this works

>Print 32767+1 'this creates an overflow

>

>So try it with a variable:

>

>Dim X as Long 'this has to be big enough

>

>X=32768   'this works

>X=32767+1 'this creates an overflow

>

>Any ideas?  Is this a bug? (Microsoft released a program with bugs?!)

Whether this is a bug or a feature may be a topic for discussion.

VB has an internal representation for numbers in the calculations, and

will always try use least memory consuming data types. Which means

that when you add to integers VB "assumes" that the result is an integer

even if you assign the calculation result to a long.

This "feature" may rather tricky to debug if aren't aware of it.

>I need to add numbers that sometimes come out to > 32767

>How do I do it?

>

What you are trying to do is something like this:

  Dim X As Long

  Dim Y As Integer

  Y = 32767

  X = Y + 1  'the right side are all integers and will cause owerflow

  Text1 = Str$(X)

This will not cause overflow:

  Dim X As Long

  Dim Y As Integer

  Dim Z As Long

  Y = 32767

  Z = 1

  X = Y + Z  'There's a long on the right side and the result is assumed "long"

  Text1 = Str$(X)

Hope this helps!

Geir

1709 (67+)  huw@criterion.canon.co.uk  16.12.94  13:48

Huw Barnes: "Re: Longs don't work in VB."

If you don't specify a type for a number, VB uses the simplest. If you cast

one of the numbers in the above expression to a long you'll get the desired

result,

X=32767& + 1


LostFocus

LUOKKA: timer

Date: 07/20/94 (02:52)              Number: 12530 of 12618 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: apparent bug w/ textbox l

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I've got a text box and a combo box.  I validate the text box

>in lostfocus, and if the fails, I beep and resetfocus to the text box.

>In setfocus on the combo box, I take the text from the text box and use

>it to do a lookup in a paradox db.

>

>The problem is, vb lets me get into the combo box *APPARENTLY* without

>it triggering the lostfocus from the text box first.

>

>1. type in the text box

>2. click on the "drop arrow" on the combo box

>3. error from search because the value from the text box is invalid

>

>If I put a msgbox or breakpoint in the textbox lost focus, everything

>works exactly as I expected- lostfocus fails and I stay in the text

>box.  But- without the msgbox or breakpoint- I get the search failure.

>

>Help?  (This is my first vb program.)

This is one of those oddities of VB.  Usually when that happens what you

do is put a DoEvents in where you were putting the break point.  This acts

like a break and then continue in your program and should work.

Brad


MDI active child?

LUOKKA: MDI

Date: 08/16/94 (18:02)              Number: 15821 of 15821 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: mdi question

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>   if there is at least one child window then

>      ...do something to the active child window...

If Forms.Count > 1 then... might be one way to approach it.

Or try If (MDIForm.ActiveForm Is Nothing).

>Also, if I have different type of child windows, what is the simpliest

>way of determining which class of child window is the active child.

The simplest way (which is what you asked for) is to put an invisible static

text control on the form called ClassName. Initialize it with the class name

at form load. Then you can check it later with code like this:

    If (SomeForm.ClassName = "Invoice") Then...

It makes for very readable code. I'm assuming your class ID will be a

string, but it could just as easily be a number.

If using this approach, trap for errors in case you try to access a form

without a ClassName control. (Best way is to create a function which

retrieves the class name for you, traps any errors, etc.). E.g.:

    Function FormGetClassName(F as Form) as String

        'return the class name, or "" if error

    End Function

You could do something similar with the ".Tag" property. This is probably

even simpler. You're also assured the .Tag property exists for each form.

But then you've precluded use of .Tag for anything else (unless you

do something fancy). That might be OK for your purposes though.

Keeping a separate array of data structures is possible, but you have to do

the housekeeping as forms are created and destroyed, which you will

find to be a hassle, and unless you're storing a significant amount of info

about each form I find it doesn't pay off.

But if you create a wrapper function (as above) you can use any of these

three approaches in a manner which is opaque to the rest of your code.

--------------------------------------------------------------------

Tim Shea    Internet: shea@marcam.com    Phone (USA): (617) 965-0220


MDI active child?

LUOKKA: MDI

Date: 10/05/94 (23:51)              Number: 21918 of 21922 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Checking for a child

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>to know if a child form is running, from a parent form.  He has a parent

>form which would like to know which child form(s) are running and go

>through logic based on the result of such a check.  Is it possible to

>determine this, and what would it return?  Thanks for you help.

What I do is create arrays of user-defined types to hold properties for all

of my MDI children.  One of these properties is flgInUse which tells me if

the window is in use.  This way I can easily find out which one to use when

it is time to open a new child.  When you create a child, make sure you put

its array location in its .Tag so that it is easy to reference its properties

in the user-defined type.

__________

                           Bradley S. Murray


MDI change color!

LUOKKA: MDI

Date: 11/09/94 (18:39)              Number: 26352 of 26376 (Refer# NONE)

From: BEMILLER@AMOCO.COM

Subj: Re: MDI simple questions - please help

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>>>: Two simple questions regarding MDI.

>>>

>>>: 1. Is it possible to set the color of the MDI form to something other than

>>>:  white? If so, how?

>>>

>>>I haven't found a way to do this. It may be possible via the API, though.

>>>(You'd probably be changing all windows' color schemes).

>>>

>>Why bother?  Just put a picture area over the entire MDI (except

>>the toolbar, obviously) and colour that any way you like.  You can

>>also put any normal control over the picture box.

>>Seriously guys, with a little imagination here we can easily

>>bypass the old 'Henry Ford' colour scheme.

>Even more seriously, as we discoved during the previous cycle of this

>question, last week as I recall, minimized icons will not show through the

>picture box.

>------------------------------------------------------------------------

>Chuck Stuart

>Mesquite TX USA

>Contract Programmer.

>Author of VBTrace, runtime VB Trace/Profile/XRef utility.

>------------------------------------------------------------------------

Try this:

'declare functions for changing system colors

Declare Function GetSysColor Lib "User" (ByVal nIndex%) As Long

Declare Sub SetSysColors Lib "User" (ByVal nChanges%, lpSysColor%,

  lpColorValues&)

Global SavedColors(18) As Long

' ** Save current system colors.

' perhaps stick this in MDIForm_Load

  For i = 0 To 18

    SavedColors(i) = GetSysColor(i)

  Next i

  ReDim NewColors(18) As Long

  ReDim IndexArray(18) As Integer

  'set mdi background to lime green

  NewColors(0) =  &HFF00& 'lime green

  IndexArray(0) = 12 'COLOR_APPWORKSPACE

  SetSysColors 1, IndexArray(0), NewColors(0)

' ** Restore system colors when you leave app.

' perhaps stick this in your MDIFORM_Unload

  ReDim IndexArray(18) As Integer

  For i = 0 To 18

     IndexArray(i) = i

  Next i

  SetSysColors 19, IndexArray(0), SavedColors(0)


MDI child form size

LUOKKA: MDI

Date: 06/26/94 (03:51)              Number: 10564 of 10664 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: MDI Child Form size

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Put this line in your MDI child's Form_Load() event:

    Me.Move Me.Left, Me.Top, <desired width>, <desired height>

where <desired width> and <desired height> are the desired width and

height of your form in twips.


MDI children

LUOKKA: MDI

Date: 09/11/94 (11:21)              Number: 19030 of 19086 (Refer# NONE)

From: JEMILLER@NETCOM.COM

Subj: Re: MDI Children

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Two approaches:

1) Use TypeOf and Is: let's say you have MDI child forms based on two

different forms: frmChild1 and frmChild2.  You can reference the type of

form by using:

if TypeOf SomeFormVar Is frmChild1 then

  ...whatever you want to do...

end if

2) Use the Tag property of the form to identify what that form is.

John.


MDI faster display

LUOKKA: MDI

Date: 09/08/94 (22:30)              Number: 18747 of 18922 (Refer# NONE)

From: STONEGRP@USE.USIT.NET

Subj: Re: painting MDI Children

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

try this -

on form activate - do a "show" and then a "doevents"

this will force faster (total) repaint of form - giving it the

appearance of more "snap" to the form display.

hope it works for you.


MDI minim.caption

LUOKKA: MDI

Date: 01/04/95 (19:44)              Number: 172066 of 172332 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: HowTo: Set MDI form ICON caption when Minimized.

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

"BUG: Iconic MDI Application Titles Do Not Update Properly"

PSS ID Number: Q104137.

"CAUSE: In an MDI application, the main window calls DefFrameProc instead

of DefWindowProc to handle unprocessed messages. DefFrameProc does not

handle the WM_SETTEXT message (which is generated by SetWindowText)

correctly when the main window is minimized, because it does not update the

title after the change has been made."

To cut a longish story short, the note continues to suggest that you should

call DefWindowProc youself to make up for the bug...

In my case, (want to dynamically alter the MDI form's Icon caption when

minimized), I simply added a call to DefWindowProc in my update code, eg:

Sub Timer1_Timer()

        Dim TimeString$, R&

        TimeString$ = Time$     ' Verbose...

        R& = DefWindowProc(MDIForm1.hwnd, WM_SETTEXT, 0, TimeString$)

End Sub

This all works just peachy!

+-----------------------------------o0o---------------------------------------+

 Jerry.Cashman@asx.decus.com.au                    Australian Stock Exchange


MDI pros and cons

LUOKKA: MDI

Date: 06/23/94 (02:53)              Number: 10069 of 10157 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: Pros and Cons of MDI?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

MDI Pros:

- Documents can share a single menu, toolbar, message bar.

- Easy to tell what windows are part of the app. The MDI parent provides a

  handy "container" for all objects within it. Allows closing of entire app

  with a single click.

MDI Cons:

- SDI is simpler: menu, toolbar, message bar are attached to the object

  to which they pertain. This is less abstract, and clearer, particularly

  to new MS-Windows users.

- Some of the MDI behavior can be confusing. E.g. maximizing a child

  versus the parent. Parent and child can both have scrollbars.

- MDI tends to block out other windows in the background (if you're working

  with more than one app). Working with two MDI apps at once requires

  lots of window management.

VB is essentially MDI, but with a transparent background. Notice that none

of the windows have their own menus or toolbars. Whether users like this

seems to be a matter of opinion.

--------------------------------------------------------------------

Tim Shea    Internet: shea@marcam.com    Phone (USA): (617) 965-0220


MDI removing maximize

LUOKKA: MDI

Date: 06/25/94 (11:57)              Number: 10457 of 10514 (Refer# NONE)

From: MAURICE1@DELPHI.COM

Subj: Re: Non Sizable MDI Parent?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

try...

Const GWL_STYLE = (-16)

Const WS_MAXIMIZEBOX = &H10000

TempVal& = GetWindowLong(Me.hWnd, GWL_STYLE)

TempVal& = TempVal& And (Not WS_MAXIMIZEBOX)

Garbage& = SetWindowLong(Me.hWnd, GWL_STYLE, TempVal&)

This worked for me to remove the maximize button from a running app. There

are also style bits for the border, but I have yet to try them. I have some code

to intercept the message for resizable borders thus killing resizing all

together while still keeping the standard border. If you need it, let me know.

Tell me how this works out for you.

-------------------------------------------------------------------------------

  Maurice1@delphi.com


MDI sending messages

LUOKKA: MDI

Date: 10/24/94 (04:50)              Number: 24240 of 24335 (Refer# NONE)

From: NPFLUGER@NETCOM.COM

Subj: Re: Messaging API and Event Processing

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: I am writing an MDI application that tracks students and their tests.

: One child form is their demographic information. Another is a test history

: listing their tests.

: I would like to "disable" the -Tests+ button on the Student's form to

: prevent a user from opening multiple "histories" on the same student.

: I do NOT want to make the history screen a pop-up. Period.

Well, you need to send messages across MDI forms.  One really neat way

that uses no resources is to define an invisible label on all forms that need

to have messages sent to them. (I call it lbl_menu after the fact that I had

one central menu on the MDI main that called different forms for different

commands.  Wasn't totally my idea, but I like it now, as a form doesn't have

to be active to have menu choices that work).  To send a message, just say

XXX_form!lbl_menu = "Message" (like "DisableTest", "enableTest") and then

in the XXX_form you put

Sub lbl_menu_Change ()

    if (lbl_menu.Caption = "") Then Exit Sub

    Select Case lbl_menu.Caption

      case "DisableTest"

     'Disable testing

      case "EnableTest"

     'Enable Testing

     End Select

    lbl_menu.Caption = ""

end Sub

Turns out that as soon as a label changes, the change event is executed for

it immediately. (Does not seem to go through the normal message queue)

Nathan Pfluger

npfluger@netcom.com (formally cs.tamu.edu Shannon.  :)


MediaView

LUOKKA: MediaView

Date: 04-01-95 (20:34)              Number: 280289 of 280746 (Refer# NONE)

From: MEDIAVIEW-L@WILLAMETTE.EDU

Subj: MMV 2.1/3.0 solution (fwd

For those of you not on the WinHelp list, you might mind this of interest.

Tod

Tod R. Massa      tmassa@willamette.edu

Asst. Registrar for Institutional Research  Willamette University

       www: http://www.willamette.edu:80/~tmassa/

==========

---------- Forwarded message ----------

Thank you to everyone that responded to my Viewer 2.1/3.0 survey... and

especially to those interjecting words of encouragement.  I was getting tired

of thinking about this anymore:-)

Before making this final summary let me say that Microsoft has a solution to

our woes.

After extending the feedback date, and receiving more replies, my

conclusions

didn't really change:

 - Programmers were happy

      They got raw power and control with MediaView

 - Viewer developers were unhappy (the middle group)

      They needed bug fixes, and a future

      MediaView with C++/VB wasn't the solution

      WinHelp 4.0 wasn't the solution

 - WinHelp Plus developers were happy

      Viewer gave them full text search now plus more

      WinHelp 4.0 was a future

The MS Solution...

Rick Segal said he is going to take care of the middle group, the Viewer

developers primarily using it as Viewer.  To quote from Rick "The middle

group

is the target of my shorterm tactical efforts."

Plan for a TOLL FREE conference call in early May.  Microsoft will outline

their Viewer/MediaView plan in that conference call.

Rick didn't spell it out to me in detail, but from our messages I feel safe in

assuming the solution will be a Viewer like interface to MediaView, not a

repaired Viewer.  This should be an excellent solution.  I think it will

answer most everyone's concerns... I'm not sure about the overseas letter

character issues but this is a positive step.

   No need to program, yet open to programmers (power users:-)

   Manage the project with a project editor

   Compile with project defined windows, panes, popups...

   Use a topic editor if you can't remember the markups

   No bugs, MV1.3 is solid as a rock.  (hey! who's chuckling in the backgrd)

   New features, even if we don't know how to use em yet.

   A future and direction

THESE ARE MY ASSUMPTIONS, but I'm pretty sure they're close.  It sounds

like

Rick has been thinking about this for a while, so I'll pretent we pushed him

over the edge. :8-)  In any case, I'm looking forward to May.

Roger F Bindl --- Hadron Data Graphics

     hadron@msn.fullfeed.com

Articles, demo's, and services listed at:

   http://www.msn.fullfeed.com/hadron/


MediaView

LUOKKA: VBgen

Date: 03-07-95 (01:04)              Number: 247775 of 251087 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: MediaView ToolKit - Question

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

> Can anyone tell me what is in the MediaView toolkit that is available from

ftp.microsoft.com,

> I guess it has something to do with multimedia, it is 8M in size so I want to

know exactly what it is before I download it ?

The MediaView toolkit includes the compiler and runtime libraries for

MediaView which is Microsoft's internal multimedia engine. It is similar

in it is "innards" to Viewer and WinHelp except the user interface is

designed by the developer. Included is a sample multimedia file and it s

source (which is where most of the bulk comes from) as well as a sample

interface using Visual Basic and another using C++. The use of VB is

possible thru a single VBX and a number of dlls/.

It is a powerful system but it is not officially supported by Microsoft.

The currently quiet discussion list mediaview-l is available by

subscribing to listproc@willamette.edu. I have written a draft

programming model on how to best use MediaView and Vb and have been

working on refinements.

Basically, MediaView allows you to create a standalone multimedia

application wmuch individual character as MS Dinosaurs (which I

think is a stunning piece of aesthetic work) o integration with a

Visual Basic application that is something other *just* multimedia.

==========

Tod R. Massa                                            tmassa@willamette.edu

Asst. Registrar for Institutional Research              Willamette University

                                   www: http://www.willamette.edu:80/~tmassa/


MediaView long

LUOKKA: MediaView

Date: 02/13/95 (11:20)              Number: 224762 of 225504 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: MediaView and VB

From: "Tod R. Massa, Asst. Registrar for IR" <tmassa@WILLAMETTE.EDU>

For those of you are interested in using Visual basic to develop interfaces for

use with MediaView multimedia titles, I have written a white paper on the

subject. Basically it covers what you need to do to provide macro-like

functionality in your interface as well as a model for creating context strings

and such to allow for some really powerful functionality.

This is a draft document so any comments are welcome. It is currently

available as a Word for Windows v. 6 document and is available by ftp from:

ftp  jupiter.willamette.edu

 cd outgoing/tmassa

 vbmodel.doc

If you would like it in a different format, let me know.

=========

Tod R. Massa                                            tmassa@willamette.edu

Asst. Registrar for Institutional Research              Willamette University

                                   www: http://www.willamette.edu:80/~tmassa/==

Date: 02/14/95 (01:34)              Number: 227259 of 227855 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: MediaView-L

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

From: "Tod R. Massa, Asst. Registrar for IR" <tmassa@WILLAMETTE.EDU>

To simplify things and get the MediaView developers together, I've set

up a separate listserv (listproc actually) for MediaView. The list is

open to everyone interested in developing with MediaView.

MEDIAVIEW-L:  INFORMATION

ABOUT THIS FORUM: MEDIAVIEW-L is open to the networking community.

Its

primary role is to serve as a means of communication among software

developers working with MediaView from Microsoft. While this list is of

special interest to MediaView developers working with Visual Basic, C/C++

developers will find a home here as well.

LISTPROC ADDRESSES:

     <MEDIAVIEW-L@willamette.edu>:  Use this address to post messages

     you wish all MEDIAVIEW-L subscribers to read.

     <listproc@willamette.edu>:  Use this address when you wish to

     execute commands that allow you to cancel your subscription to

     the list, search the archives, review subscribers, etc.

SUBSCRIBING TO THE LIST:

Anyone may subscribe to the list by sending a <sub MEDIAVIEW-L your

name> command to <listproc@willamette.edu>.  For example <sub

MEDIAVIEW-L Sue Smith> For example <get MEDIAVIEW-L mar1993>.

LISTOWNER: The listowner is Tod R. Massa, Assistant Registrar for

Institutional Research, Willamette University, Salem, OR 97301

(503-375-5303) <tmassa@willamette.edu.

17 February 1995

Date: 02-23-95 (01:16)              Number: 230561 of 231964 (Refer# NONE)

From: MEDIAVIEW-L@WILLAMETTE.EDU

Subj: Keyword Indexes and WordWheels

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

"Soon to be Frequently Asked Question Number 1: Why doesn't my Keyword

Index work in my Visual Basic interface?"

Keyword Indexes and WordWheels are identified to the VBX by reading the

baggage file PROJECT.MVX which is a duplicate of your MVP project file

with the same name. (Your project file would be named PROJECT.MVP and

copied to PROJECT.MVX)

Your project file would include the following lines:

ÄBAGGAGEÅ

PROJECT.MVX

äand other file nameså

Thus when the keyword search or full-text search is initiated, your

interface attempts to read the baggage file

driveÖpathÖPROJECT.M12+PROJECT.MVX

which it does by assembling szFileName to the .MVX extension defined in

Module1.BAS. The MV12KIT.M12 does state clearly that filenames in the

baggage section are case sensitive even if the documentation says nothing

about including the .mvx file (or even creating it).

Now, if you open the title file using FileöOpen, the CommonDialog returns

the filename in caps. However, if you design your project to open a specific

title automatically, and you fail to specify the file name in caps such as

Call OpenFile("filename.m12")

the file will open but the Keyword Index search will fail and return an

error message. The full-text search dialog will not display any

wordwheels either.

Simply changing the statement to

Call OpenFile("FILENAME.M12")

solves the problem.

The question I have now is: Am I an idiot for taking three days to solve

this problem?

=========

Tod R. Massa      tmassa@willamette.edu

Asst. Registrar for Institutional Research  Willamette University

       www: http://www.willamette.edu:80/~tmassa/

Date: 02-23-95 (01:20)              Number: 231141 of 231964 (Refer# NONE)

From: MEDIAVIEW-L@WILLAMETTE.EDU

Subj: Re: Keyword Indexes and WordWheels

From: Ian Gibson <igibson@sciborg.uwaterloo.ca>

The advice given by Tod on how to get "INDEX" to work certainly helps but

it doesn't seem to be the complete answer.  I added PROJECT.MVX (in caps)

to the baggage section of my PROJECT.MVP file and then copied the whole

thing to PROJECT.MVX.  Recompile the RTF and still no index!!!!  I only

see the index IF I open the PROJECT.M12 from the File/Open drop-down

menu. If I open POJECT.M12 from the command line associated with the icon

I dont see the index! Or does the command line have to be in CAPS as well!!!

********************************************************************

Ian L. Gibson, Department of Earth Sciences, University of Waterloo,

Waterloo, Ontario, N2L 3G1, Canada.                Fax: 519-746-0183

Date: 02-23-95 (01:23)              Number: 231338 of 231964 (Refer# NONE)

From: MEDIAVIEW-L@WILLAMETTE.EDU

Subj: Re: Keyword Indexes and WordWheels

From: "Tod R. Massa, Asst. Registrar for IR" <tmassa@willamette.edu>

On Tue, 21 Feb 1995, Ian Gibson wrote:

> The advice given by Tod on how to get "INDEX" to work certainly helps >

but it doesn't seem to be the complete answer.  I added PROJECT.MVX (in >

caps) to the baggage section of my PROJECT.MVP file and then copied the >

whole thing to PROJECT.MVX.  Recompile the RTF and still no index!!!!  I >

only see the index IF I open the PROJECT.M12 from the File/Open >

drop-down menu. If I open POJECT.M12 from the command line associated >

with the icon I dont see the index! Or does the command line have to be in >

CAPS as well!!! -

As Ian has found out now, yes, the command line does have to be in CAPS!

It probably best if code is placed in the Load Event of frmMain to

Convert Command$ to Command$=Ucase$(Command$) before calling

OpenFile() just to make sure the file is always opend oin CAPS.

AS one of the Microsoft guys pointed out to me, case-sensitivity in Basic

is rarely an issue so the docs should spell it out clearly - which they

don't.

=========

Tod R. Massa      tmassa@willamette.edu

Asst. Registrar for Institutional Research  Willamette University

       www: http://www.willamette.edu:80/~tmassa/


MediaView new list

LUOKKA: MediaView

Date: 02-14-95 (19:35)              Number: 227900 of 227988 (Refer# NONE)

From: LISTPROC@WILLAMETTE.EDU

Subj: SUB MEDIAVIEW-L MATTI HARJU

You have been added to list mediaview-l@willamette.edu.

The system has recorded your address as

   matti.harju@pcb.compart.fi

and in order for your messages to get posted (if the list accepts postings),

you will have to send them from this address, unless the list does not require

subscription for posting.

If a message is ever rejected, please contact the list's owner:

tmassa@willamette.edu

For information on this service and how to use it, send the following

request in the body of a mail message to listproc:

   HELP

All requests should be addressed to listproc.

Please note that MEDIAVIEW-L is _not_ a Bitnet listserv.  Please read

the following and retain this message for future reference.

ABOUT THIS FORUM:

MEDIAVIEW-L is open to the networking community.  Its primary role is

to serve as a means of communication among software developers working

with

MediaView from Microsoft. While this list is of special interest to MediaView

developers working with Visual Basic, C/C++ developers will find a home

here

as well.

GROUND RULES:

MEDIAVIEW-L is not a chat line.  Personal messages should be addressed

to an individual, not broadcast to all subscribers.  All subscribers

are asked to show courtesy and exercise tolerance in their postings.

LISTPROC ADDRESSES:

     <MEDIAVIEW-L@willamette.edu>:  Use this address to post messages

     you wish all MEDIAVIEW-L subscribers to read.

     <listproc@willamette.edu>:  Use this address when you wish to

     execute commands that allow you to cancel your subscription to

     the list, search the archives, review subscribers, etc.

SUBSCRIBING TO THE LIST:

Anyone may subscribe to the list by sending a <sub MEDIAVIEW-L your

name>

command to <listproc@willamette.edu>.  For example <sub MEDIAVIEW-L

Sue Smith>

(Note:  Your local e-mail address may change from time to time, for

example, you may move to a new host machine or your campus may change

from

a Bitnet to an Internet site.  This list is not automatically informed of

these address changes.  If you are aware that your address is going to

change, please sign off MEDIAVIEW-L and re-subscribe under your new

address.)

SIGNING OFF THE LIST:

You may leave the list at any time by sending a <signoff MEDIAVIEW-L>

command to <listproc@willamette.edu>.

SUBSCRIPTION VISIBILITY: It is possible for anyone to determine that you

are a MEDIAVIEW-L subscriber through the use of the <rev MEDIAVIEW-L>

command,

which returns the network addresses and names of all subscribers.  You

may conceal your subscription by sending a <set MEDIAVIEW-L conceal yes>

command to <listproc@willamette.edu>.

OTHER LISTPROC COMMANDS:

The following commands must be sent to <listproc@willamette.edu>:

     <set MEDIAVIEW-L mail ack>.  This command will give you automatic

     acknowledgement of any postings to the list made by you.

     <set MEDIAVIEW-L mail noack>.  This command prevents you from

getting

     automatic acknowledgement of your postings to the list. The default

     setting is NOACK.

     <set MEDIAVIEW-L mail postpone>.  This command will stop messages

from

     MEDIAVIEW-L until you change mode again with one of the previous

     commands.

     Note:  There is no "resume" or "set mail" command.  To restart

     mail after having postponed it, set your mail to either ack or noack

     as described above.  This will resume your mail from MEDIAVIEW-L.

     <set MEDIAVIEW-L>.  This command returns information on your current

     MEDIAVIEW-L settings.

     <help>.  This command will send you a list of valid listproc

     requests.

ARCHIVES:

Postings to MEDIAVIEW-L will be archived once a month with a filename for

that

month and year, e.g. mar1993.

To retrieve a list of available archives send the command <index> to

<listproc@willamette.edu>.  Files for MEDIAVIEW-L will be listed under the

'Subarchive: MEDIAVIEW-L' section.  To retrieve an archive file, send the

following the command <get MEDIAVIEW-L filename> to

<listproc@willamette.edu>.

For example <get MEDIAVIEW-L mar1993>.

LISTOWNER: The listowner is Tod R. Massa, Assistant Registrar for

Institutional Research, Willamette University, Salem, OR 97301

(503-375-5303) <tmassa@willamette.edu.

17 February 1995

Tod R. Massa      tmassa@willamette.edu

Asst. Registrar for Institutional Research  Willamette University


Menus add to oth. pgms

LUOKKA: menus

Date: 06-22-95 (12:43)              Number: 369991 of 370426 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: adding to menus in other programs

From: Ravi Krishna Mikkilineni <micky@OPTIMASW.COM>

>1)    Use FindWindow function to get the Handle of the desired Window.

>2)    Use GetMenu(hWnd) call to get the Menu handle of the window by

>passing the hWnd from the above call.

>3)    Use AppendMenu Fuction to Append New Menu Items to the menu.

>- Ravi.

>

>Can you send me a little code to show how the 3 api's work?

>I'm having a little trouble understanding them.

Here is the piece of code which does the trick...

Step 1)  In  Form Declarations copy the following lines...

Declare Function GetMenu Lib "User" (ByVal hWnd As Integer) As Integer

Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal

lpWindowName As Any) As Integer

Declare Function AppendMenu Lib "User" (ByVal hMenu As Integer, ByVal

wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As Any)

As Integer

Step 2) Copy the following code to Form Load event...

Sub Form_Load ()

Dim hWnd, Result As Integer

    hWnd = FindWindow("CtlPanelClass", "Control Panel")

    If Not hWnd Then

        Result = Shell("control.exe", 1)

    End If

    hWnd = FindWindow("CtlPanelClass", "Control Panel")

    hMenu = GetMenu(hWnd)

    Result = AppendMenu(hMenu, 0, 100, "MyMenu")

    MsgBox "Menu Item 'MyMenu' is added to Control Panel..."

End Sub

- Ravi.


Menus itse lisätyt?

LUOKKA: menus

Põivõ: 10-18-94 (16:46)             Numero: 2499 / 2506 (Vast. nro 2474)

Knlle: PETRI SUVILA

Knltõ: SAMI PITKO

 Aihe: Ongelma Visual Basicin kanssa

 Kok.: Ohjelmointi (23)           Lukumalli: Yleinen (A) (+)

--------------------------------------------

HUOM: esim. MSGBLAST.VBX:n avulla voi päästä kiinni sanomiin!

Eli onnistuu! PS ja SP eivät tätä tiedä!!!!

---------------------------------------------

>SP>Sitten kritisointi: Nyt kun tuo menuvalinta on lisätty, niin kuinka

>SP>siihen liitetään koodia? Tietääkseni ei mitenkään. (Tai ehkä tutkimalla

>

>Eikö Visual Basicissä saa millään komennolla pointtereita

>proceduureista.

Jos tarkoitat, että voiko DLL kutsuille välittää parametrinä jonkun VB

muuttuja todellinen osoite, niin kyllä voi. Mutta se ei liity mitenkään

tuohon koodin liittämiseen siihen juuri tehtyyn &About valintaan.

VB:n rakenne on tapahtumapohjainen. Ensin pitää käyttäjän/ohjelman

aktivoida jokin tapahtuma, jonka perusteella kontrolli siirtyy

ohjelmoijan tekemään koodiin. Control-boxin valikot eivät valitettavasti

aiheuta minkäänlaista tapahtumaa, johon ohjelmoija voisi laittaa oman

koodinsa odottamaan tapahtumaa.

Siis: kaikki muut control-boxista löytyvät valinnat (Restore, Move,

Size, Minimize, Maximize, Close ja Switch to...) käynnistävät VB:n

sisäänrakennettun koodiosuuden.

Eli kun lisäät sinne yhden valinnan lisää, niin et voi tehdä koodia joka

aktivoituisi kun valitset sen valinnan.

>Kun tiedät noista API kutsuista, niin kuinka saadaan Task Lististä

>ohjelma pois eli ettei sitä voisi aktivoida ALT-TAB painettaessa?

>

>Itse olen saanut ikonin pois näkyvistä VB toiminnoilla, mutta Task

>Listissä se vielä kummittelee eli juuri toisin päin se pitäisi tehdä.

Eipä ole tullut tuollaista tarvetta, niin en ole tutkinut. Kait siihen

jokin ratkaisu löytyy... ensin pitäisi vain keksiä, jotta minkähän

niminen API-kutsu sen tekee. Sen jälkeenhän kaikki on vain dokumenttien

lukemista ja soveltamista.

Noilla ohjelman ikoneilla temppuillessa huomasin yhden bugin

(ominaisuuden?) VB:n toiminnassa. Kun ohjelma on ikonina alareunassa ja

esim. timer-tapahtuman avulla päivittää form.caption ominaisuuttaa, niin

screen saverin kello alkaa laskea alusta -> screen saver ei aktivoidu

koskaan... (tekaisin ohjelman, joka näyttää ulkolämpötilan captionissa

ja ikoni on joko aurinko, pilvi, sadepilvi tai lumihiutale, riippuen

ulkona vallitsevasta säätilasta. Pitäähän säätila nähdä kun ikkunasta

katsoo...)

Spitco


Menus msgblaster etc.

LUOKKA: menus

Date: 07-14-95 (16:16)              Number: 387444 of 388565 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: MsgBlaster VBX

From: "Chandler, Chris 064719" <L064719@PO200.APPL.GE.COM>

 ----------

From: owner-visbas-l

To: Multiple recipients of list VISBAS-L

Subject: MsgBlaster VBX

Date: Thursday, July 13, 1995 10:42PM

I am testing the MSGblast VBX (version 2.1b) with vb3.0 pro (it seems

great).  I use it to display my menus' description in a status box.

Here is the procedure :

 --------------------------------------

Sub MsgBlaster1_Message (MsgVal As Integer, wParam As Integer, lParam

As Long, ReturnVal As Long)

    Dim Msg As String

    If wParam = 0 Then

        Panel3D1.Caption = ""

    End If

    Select Case wParam

        Case 2

            Msg$ = "Open"

        Case 3

            Msg$ = "Quit"

    End Select

    Panel3D1.Caption = Msg$

End Sub

It works ! But I have a problem : at runtime, if I add a new item in my menu

(e.g. 'Print') between 'open' & 'quit', when my cursor is on 'print', in fact it's

case 3 and the message "quit" is displayed : it shouldn't be like that.

So my question is : is it possible, with msgblast, to track the caption of a

menu to have something like that :

    Select Case menu.caption

        Case &open

            Msg$ = "Open"

        Case &Print

            Msg$ = "Print"

        Case &Quit

            Msg$ = "Quit"

IF NOT, have you another solution ?

BWILLOT@VM1.ULG.AC.BE

--------

You can return the string in the menu with the GetMenuString API.  Then

use the returned string in a case statement to determine the status bar

info you wish to display.

If MsgVal = WM_MENUSELECT Then

   'wParam specifies the menu-item identifier

   'lParam - Lo word specifies one or more menu flags.

   '         Hi word specifies the menu handle of the system menu

   '         if the lo word contains the MF_SYSMENU flag.

   hMenu = GetMenu(Me.hWnd)

   sMenu = Space$(255)

   iResult = GetMenuString(hMenu, wp, sMenu, 255, MF_BYCOMMAND)

   sMenu = Left$(sMenu, iResult)

   Select Case sMenu

      Case "&Open...":  pnlStatusBar.Caption = "Open File"

      ...

      ...

   End Select

End If

Chris Chandler

L064719@PO200.APPL.GE.COM


Menus multiple

LUOKKA: menus

Date: 05/11/94 (19:26)              Number: 5405 of 5645 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: Menus in MDI apps

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2qol4p$1qu@Venus.mcs.com> millera@MCS.COM (Alan Miller)

writes:

>Joel Hammond <joel@vthvax.tamu.edu> wrote:

>>Would someone with experience in MDI applications advise me on how

>>best to manage multiple menus in an MDI app?

>>I'm faced with the decision of: 1) using one menu on the mdi form and

>>executing a different procedure depending on the window in focus (or

>>changing the visibility) or,  2) create a menu for each child, duplicating

>>selections for the common functions.  Both seem messy.  How is this best

>>handled?

I struggled with this same issue. My menu structure is pretty consistent

across MDI children, although as each child becomes the active window

it does make some changes to the basic menu structure. It was a pain to

maintain all those menus individually, so here's what I did:

1. I created a single menu owned by the MDI parent. This allowed

me to maintain the menus on one place.

2. I wrote one subroutine which put that menu into a "neutral" state.

3. I put code in the Activate event for all MDI child forms. This takes the

menu in its "neutral" state and  "customizes" it for that child. That allows

one to change menu wording, enable/disable items, hide/show entire

menus, whatever. As children activate, the menus change automagically.

4. When a menu item is chosen by the user, the code finds the active form

(there's a VB call or property for this purpose) and sends it a message

saying what menu item was chosen. In my case I pass messages by putting

an invisible static text control on each form and changing its caption when

I want to send a message. This triggers the "Changed" event for that control,

enabling the message to be processed.

5. When the MDI child form deactivates, the menu is returned to its neutral

state.

This has worked out pretty well in practice. It's not much more work than

handling the menu picks directly, and it saves me lots of time maintaining

menus.

--------------------------------------------------------------------

Tim Shea    Internet: shea@marcam.com    Phone (USA): (617) 965-0220


Menus pop-up

LUOKKA: menus

Date: 04/24/94 (12:21)              Number: 4146 of 4173 (Refer# NONE)

From: GINS@SUNSPOT.COM

Subj: Re: How to create menus in run-time

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Antti:

>How can I create pop-up menus in run-time? Any hints or examples would be

>appreciated.

Start a project with one form with one button.

Design in one menu item: MNUPOPUP and make it invisible.

Design one sub menu under MNUPOPUP: MNUITEMS with index = 0 (use

any caption).

Use the following for the command1_click:

Sub Command1_Click ()

    Dim i%

    On Error Resume Next

    For i = 0 To 5

        Load mnuItems(i)

        mnuItems(i).Caption = "Selection " & i

    Next i

    Me.PopupMenu mnuPopUp

End Sub


Metafiles

LUOKKA: graphics

Date: 08/04/94 (10:41)              Number: 14338 of 14404 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: METAFILES

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I've done something similar, only using Arcs and other API calls as well.

I ended up building the data into user-defined types and writing them

directly into a binary file. Trying to use the metafile functions

was just too much of a headache.

OTOH, you could take a look at metalib.zip on cica in the vbasic

directory (ftp.cica.indiana.edu pub/win31/programr/vbasic).

tommy@Fateepee.CAM.ORG (Tommy Petrogiannis) writes:

>I am looking for code to create a METAFILE in memory and copy it to the

>clipboard. I am trying to create a graphic image that is simply composed of

>MOVETO and LINETO commands.

>Does anybody know what is the best way to do this in VB3 pro?


Metafiles

LUOKKA: graphics

Date: 11/14/94 (11:19)              Number: 26776 of 26823 (Refer# NONE)

From: BURDET@SICMAIL.EPFL.CH

Subj: Metafiles and the clipboard, the sequel...

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here are remarky I got by mail and my answer. I am making progress with

metafiles, but this is much more complicated than it ought to be, I think...

Weel, as I understand it, metafiles are a touchy subject in Windows, because

they actually are rather imperfect, as recents columns by Petzold in PC

Magazine have demonstrated (he is decribing the "enhanced" metafiles of

NT).

REM File META.FRM ( Visual Basic 2.0 Form, just two routines, no form

description )

REM

-------

Option Explicit

Dim MouseRect As rectangle

Sub btnReadMeta_Click ()

Dim hDCmeta As Integer, hMF As Integer

Dim temp As Long, nom As String

   nom = "C:ÖH.WMF"

   FrmMeta.Cls

   hMF = GetMetaFile(nom)

   FrmMeta.Cls

   temp = PlayMetafile(hdc, hMF)

   pic.Cls

   temp = PlayMetafile(pic.hDC, hMF)

   'pic.Picture = LoadPicture(nom)

   temp = DeleteMetaFile(hMF)

   ClipBoard.Clear

   ClipBoard.SetData LoadPicture(nom)

End Sub

Sub btnMeta_Click ()

Dim hDCmeta As Integer, hMF As Integer

Dim temp As Long, nom As String, hGlob As Integer, prevMapMode As

Integer

   nom = "C:ÖH.WMF"

   On Error Resume Next

      Kill nom

   On Error GoTo 0

   FrmMeta.Cls

   'hdCmeta = CreateMetaFile(ByVal 0&)

   hDCmeta = CreateMetaFile(nom)

   prevMapMode = SetMapMode(hDCmeta, MM_ISOTROPIC)

   ' prevMapMode = SetMapMode(hDCmeta, MM_ISOTROPIC)

   temp = SetWindowExt(hDCmeta, 100, 100)

   temp = SetViewportExt(hDCmeta, 100, 100)

   temp = hMoveTo(hDCmeta, 10, 10)

   temp = hLineTo(hDCmeta, 100, 100)

   temp = hLineTo(hDCmeta, 10, 100)

   temp = hLineTo(hDCmeta, 10, 10)

   hMF = CloseMetaFile(hDCmeta)

   FrmMeta.Cls

   temp = PlayMetafile(hdc, hMF)

   'hGlob = GlobalAlloc(ByVal GMEM_MOVABLE + GMEM_DISCARDABLE,

SizeOF(METAFILEPICT))

   'temp = DeleteMetaFile(hMF)

End Sub

REM File META1.BAS ( Visual Basic 2.0 Module )

REM

-------

Option Explicit

Global Const GMEM_DISCARDABLE = &H100

Global Const GMEM_MOVABLE = &H2

Global Const MM_TEXT = 1

Global Const MM_ISOTROPIC = 7

Global Const MM_ANISOTROPIC = 8

Type rectangle

   Left As Integer

   Top As Integer

   Right As Integer

   Bottom As Integer

End Type

Type POINTAPI

   X As Integer

   Y As Integer

End Type

Type METAFILEPICT

   mm As Integer

   xExt As Integer

   yExt As Integer

   hMF As Integer

End Type

Declare Sub DrawFocusRect Lib "User" (ByVal hDC As Integer, aRect As

rectangle)

Declare Sub InvertRect Lib "User" (ByVal hDC As Integer, aRect As

rectangle)

Declare Function PolyGon Lib "GDI" (ByVal hDC As Integer, lpoints As

POINTAPI,

ByVal Count As Integer) As Integer

Declare Function hMoveTo Lib "GDI" Alias "MoveTo" (ByVal hDC As Integer,

ByVal

X As Integer, ByVal Y As Integer) As Long

Declare Function hLineTo Lib "GDI" Alias "LineTo" (ByVal hDC As Integer,

ByVal

X As Integer, ByVal Y As Integer) As Long

Declare Function CreateMetaFile Lib "GDI" (ByVal lpstring As Any) As Integer

Declare Function CloseMetaFile Lib "GDI" (ByVal hMF As Integer) As Integer

Declare Function DeleteMetaFile Lib "GDI" (ByVal hMF As Integer) As

Integer

Declare Function PlayMetafile Lib "GDI" (ByVal hDC As Integer, ByVal hMF

As

Integer) As Integer

Declare Function GetMetaFile Lib "GDI" (ByVal lpfilename As String) As

Integer

Declare Function GlobalAlloc Lib "Kernel" (ByVal wFlags As Integer, ByVal

dwBytes As Long) As Integer

Declare Function SetMapMode Lib "GDI" (ByVal hDC As Integer, ByVal

nMapMode As

Integer) As Integer

Declare Function SetViewportExt Lib "GDI" (ByVal hDC As Integer, ByVal X

As

Integer, ByVal Y As Integer) As Long

Declare Function SetWindowExt Lib "GDI" (ByVal hDC As Integer, ByVal X

As

Integer, ByVal Y As Integer) As Long

________

Olivier L. Burdet, IBAP, Beton Arme et Precontraint

Swiss Federal Institute of Technology, EPFL, Ecublens, CH-1015 Lausanne

Tel: +41-21.693.28.91,  Fax: +41-21.693.58.85

E-mail: burdet@sicmail.epfl.ch


Milliseconds

LUOKKA: timing

Date: 05/26/94 (09:56)              Number: 7148 of 7221 (Refer# NONE)

From: DMAIN@CIX.COMPULINK.CO.UK

Subj: Millisecond Stopwatch code fragment

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Code fragment to get time in milliseconds in VB

'Here's the declares

Type tagTIMERINFO               ' ti structure

    dwSize As Long

    dwmsSinceStart As Long

    dwmsThisVM As Long

End Type

Dim ti As tagTIMERINFO

Declare Function TimerCount Lib "Toolhelp.dll" (ti As tagTIMERINFO) As

Integer

' Here's the code

Dim r%, StartTime, EndTime, Milliseconds

ti.dwSize = 12                  ' Set size of TIMEINFO structure

r% = TimerCount(ti)             ' Get start time in milliseconds

StartTime = ti.dwmsThisVM       ' Store it

' Put the routine you want to time here

r% = TimerCount(ti)             ' Get end time in milliseconds

EndTime = ti.dwmsThisVM         ' Store it

Milliseconds = StartTime - EndTime ' Duration of routine

dmain@cix.compulink.co.uk


Milliseconds

LUOKKA: timing

Date: 05/26/94 (14:12)              Number: 7189 of 7221 (Refer# NONE)

From: DAVID.GARDINER@CSSIP.EDU.AU

Subj: Re: Millisecond Stopwatch

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1994May24.213540.5372@news.mhs.oz.au>, Hoe Kit Loh

<hloh@ozemail.com.au> writes:

> When you issue a Time$ statement, and make a timer from it (hr:mn:sec),

> the smallest units it gives is seconds.  How do you get 1/100ths of a

> second and so on??

To do accurate timing:

It is not real easy, and I wouldn't depend on getting an actual resolution

of 1/100th of a second - Windows is a cooperative multitasking machine,

so things may not always occur at regular intervals.

The best resolution can be found by using functions provided in the

Toolhelp.dll.

From Windows 3.1 SDK help:

1. C version:

typedef struct tagTIMERINFO

        DWORD dwSize;

        DWORD dwmsSinceStart;

        DWORD dwmsThisVM;

  TIMERINFO;

BOOL TimerCount( TIMERINFO FAR* lpti)

2. VB

Type TIMERINFO

        Long dwSize

        Long dwmsSinceStart

        Long dwmsThisVM

Type End

Declare Function TimerCount Lib "Toolhelp.dll" (ByVal lpti as TIMERINFO) as

Integer

Use:

1. dwSize must be initialized before calling function.

2. on return, dwmsSinceStart contains the amount of time in milliseconds

   since the current task became active.

--

David Gardiner <>< Smarthouse Project - Uni of South Australia & Clipsal.

Also Asst Admin for Centre for Sensor Signal & Information Processing.

Internet: gardiner@cssip.edu.au  Ph: +61 8 302 3606  Fax: +61 8 302 3873


Milliseconds

LUOKKA: timing

Date: 05/26/94 (17:49)              Number: 7198 of 7221 (Refer# NONE)

From: KEEPER@NETCOM.COM

Subj: Re: Millisecond Stopwatch code fragment

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

For a low-overhead millsecond timer function, don't bother with

ToolHelp.  Just call the timeGetTime() function in MMSYSTEM.DLL.

It will return a LONG that contains the number of milliseconds

since Windows was started.  (PS - ToolHelp just uses the MMSYSTEM

functions.)

Declare Function timeGetTime Lib "MMSYSTEM.DLL" () As Long

--

                                The Keeper

                             keeper@netcom.com


Milliseconds

LUOKKA: timing

-Date: 07/16/94 (09:05)              Number: 12214 of 12223 (Refer# NONE)

From: SMITHSC@BIOCOM1.BIOC.UAB.EDU, Stephen C. Smith

Subj: Re: Need help getting accurate timer ( <1/18th sec)

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <30713j$t4m@ucsbuxb.ucsb.edu> uthomson@mcl.ucsb.edu (Daniel

Thomson) writes:

> I need help fast finding a way to get an accurate timer.

>I've tried both timer and GetTickCount (WinAPI), and both

>are only accurate to 1/18th of a second, although both

>carry the number out to many more decimal places.  We need

>something that can get us at least 1/100th second resolution,

>preferably millisecond resolution.

Here's some code I've used for this:

Type TIMERINFO                      ' Millisecond timer info structure

    dwSize As Long                  ' Size of structure in bytes

    dwMSec As Long                  ' msec. since current task started

    dwmsThisVM As Long              ' msec. since current VM started

End Type

Global gti As TIMERINFO              ' Actual timer structure

Dim MSec As Long                    ' Millisecond counter (from TimerCount())

Declare Function TimerCount Lib "toolhelp.dll" (lpti As TIMERINFO) As

Integer

Sub StartTimer ()

Dim i%

    ' This function uses TimerCount() to initiate timing of events

    ' to millisecond accuracy ...

    i = TimerCount(gti)              ' Get msec. timer info

    MSec = gti.dwMSec                ' Save current msec. count

End Sub

Function GetElapsedTime () As Long

Dim i%

    ' This function returns the elapsed time in milliseconds since

    ' the last call to StartTimer() ...

    i = TimerCount(gti)              ' Fill timer info structure

    GetElapsedTime = gti.dwMSec - MSec   ' Elapsed time = Current -

Previous

End Function

The above seems to work quite well.

Steve Smith

smithsc@biocom1.bioc.uab.edu


Milliseconds

LUOKKA: timing

Date: 05/25/94 (13:56)              Number: 7019 of 7084 (Refer# NONE)

From: LWALTERS@OZEMAIL.COM.AU

Subj: Re: Millisecond Stopwatch

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Use the API function GetTickCount. This returns the number of milliseconds

since the start of Windows.

I use this for profiling my applications and for alogrithm optimisation programs.

----------------------------------------------------------------------------

Lawrence Walters   Phone  : 61+ 2-831-7729

Senior Consultant   Fax : 61+ 2-831-8050

Baseware Australia Pty Ltd  EMail :

LWALTERS@ozemail.com.au


Milliseconds

LUOKKA: timing

Date: 08/31/94 (13:28)              Number: 18040 of 18053 (Refer# NONE)

From: A421ALTE@HORUS.SARA.NL

Subj: Re: timing milliseconds or shorter

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <CvCpBn.7o3@csn.org> gat@csn.org (George Tatge) writes:

>Bob Jenner (bjenner@world.std.com) wrote:

>: Anybody know how to get time resolutions shorter than the DOS timer tick?

>: Millisecond would be fine, microseconds would be wonderful.  I have

>: a very nice high-res timer library for the one-letter language in

>: the three-letter environment... seems like it ought to be possible

>: in VB, too.

>

>Look up GetTickCount()

>

>gt

NO NO NO the GetTickCount only gets updated every 55 milliseconds

If you want to have precise timing you need an external clock

(usually found on your average D/A card)

  Robert Altena


Milliseconds

LUOKKA: timing

Date: 09/03/94 (18:46)              Number: 18193 of 18257 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Re: timing milliseconds or shorter

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

form the MSDN CD 8

PSS ID Number: Q45702

----------------------------------------------------------------------

The GetCurrentTime() and GetTickCount() functions are identical. Each

returns the number of milliseconds (+/- 55 milliseconds) since the user

started Windows, and the return value of each function is declared to be a

DWORD.

The following code demonstrates these two functions:

   DWORD dwCurrTime;

   DWORD dwTickCount;

   char szCurrTime 50 ;

   dwCurrTime = GetCurrentTime ();

   dwTickCount = GetTickCount ();

   sprintf (szCurrTime, "Current time = %lu nTick count = %lu",

            dwCurrTime, dwTickCount);

   MessageBox (hWnd, szCurrTime, "Times", MB_OK);

NOTE: GetCurrentTime() and GetTickCount() return an unsigned double word

(32-bit DWORD) which gives a maximum count of 4,294,967,296 ticks. This

number will yield a maximum count of 49.71 days which the system keeps

track of running time.

DWORD GetTimerResolution(void)

The GetTimerResolution function retrieves the number of microseconds per

timer tick.

Parameters

This function has no parameters.

Return Value

The return value is the number of microseconds per timer tick.

Chuck

Mesquite TX


Milliseconds summary

LUOKKA: timing

Date: 06/05/94 (22:55)              Number: 8098 of 8514 (Refer# NONE)

From: KELLEY@HEALTHY.UWATERLOO.CA, Catherine L. Kelley

Subj: Re: Millisecond timer:  Summary

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Many thanks to all of those who responded to my recent request about the

accuracy of the TimerCount function (from toolhelp.dll).  I will summarize

the answers that I got, in case anybody else is interested in this question.

May I express apologies in case I have any terminology wrong, as I am not

a programmer by birth.   What I have listed below is my understanding of

what others have told me.

1.  This function does *not* rely on the hardware clock, which ticks only

    18 times per second (approx. 55 msec resolution).

2.  The algorithm that is used to estimate elapsed msec is different for

    running standard vs. enhanced mode - the technical details about how

    the estimation is done are in the Windows 3.1 SDK help file which

    comes with VB professional edition.

3.  Several people have indicated to me that they have tested this timer

    and are convinced that it provides msec resolution.

4.  Others have warned that the timing may not always be 100% on the

button, because the Windows multitasking environment is such that  even

though the timer may be "right", your request for a time might not be

processed right away.

5.  However, these small delays in timing are likely to be infrequent and

    not profound (depending of course on the system that you are using and

    what else may be going on).

-Cathy Kelley

kelley@healthy.uwaterloo.ca


Modular desig

LUOKKA: coding

Date: 07/12/94 (10:34)              Number: 11814 of 11852 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Modular structure in VB... questions...

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

There's lots that can be said about this type of thing.  I'll throw out a

couple.

1. It's entirely possible that at some point, somebody's going to say,

"oh-oh, I *really* need to fire some code you've got in your event.  Of

course, if you planned everything perfectly (-: this wouldn't come up.

But, if it does, don't panic, there are lots of work arounds.  I think

some are in the FAQ, others are lying around in various places.

2. Being VB, you'll inevitably need some truly global vars.  You'll also

need some semi-global but no such thing exists.  A simple trick on the

semi-global ones is to have each developer use a separate prefix of a

couple of letters.  That way, everybody else knows to keep their mits off.

For the true globals, you might want to have a "global czar" on the team

who's job it is to make sure she/he knows who's doing what to which when.

3. In addition to having each person use "private" .bas files that applies

only to them, you'll want some global ones for code reuse.  Once again,

you might want to make a "global module czar" to mediate.

Certainly lots more can be said but thats a start.

gt


Modules & memory

LUOKKA: coding

Date: 07-25-95 (19:51)              Number: 395735 of 395921 (Refer# NONE)

From: VISBAS-L@EVA.DC.LSOFT.COM

Subj: ReÄ2Å: Modules and Memory

From: Mark Hurd <mark_hurd@colybrand.com.au>

See Microsoft Visual Basic Knowledge Base Article Q112860, "How to

Optimize Memory Management in VB 3.0 for Windows".

It explains memory management completely.

However, the important bit is this:

-- Quote --

Each Visual Basic form or module consists of one or more code segments in

the .EXE file.  The code segments are marked LOADONCALL, MOVEABLE,

and DISCARDABLE, which you can verify by using a copy of EXEHDR.EXE

to dump the file header information.  Thus, on first reference to the form or

module, Windows loads the code associated with it.  Windows is then free to

discard it and demand-load it as it sees fit (for example, if you run low on

memory). Unloading a form will not force the code segment out of memory,

it's still present until Windows decides to discard the code segment.

Unloading a form does unload the instance of that form and all resources

used by it and the controls on that form.  However, when a form is unloaded,

the Module Data Segment is not unloaded; it remains in memory until the

application terminates.  Thus, if you load a Form, change the values of some

module level variables, unload the Form, and then load it again, the value

you last assigned to the module level variable in the Form will still be

present.  To deallocate memory used by the Module data segment in the

form, use the following line of code after you unload the form:

   Unload Form2

   Set Form2 = Nothing

This will clear all data in the Module code segment for the form.

--End Quote--

Note that Set <Form> = Nothing solves many DDE shutdown problems too.

Mark Hurd <Mark_Hurd@colybrand.com.au>


Mouse btn up/down

LUOKKA: mouse

Mouse Button Up Or Down Status

--------------------------------------------------

Here is how to check the mouse button 'up_or_down' status.

Declare Function GetKeyState Lib "user" (ByVal k%) As Integer

Declare Function GetAsyncKeyState Lib "user" (ByVal k%) As Integer

This functions will tell you whether a key is up or down, and if it's "toggled".

The high order bit tells you if the key is up or down. The low order bit tells

you if it's toggled - each time the key is pressed and then released the low

order bit will change.

The first function maintains the keyboard state when the last *window

message* was received by the app and is the one you normally use. The

second one corresponds to the real time keyboard state.

Now, why on earth do I talk keyboard when the question was about the

mouse? - That's because the mouse buttons are considered

as "virtual" keyboard keys. Some virtual key codes are:

VK_LBUTTON     1

VK_RBUTTON     2

VK_MBUTTON     4

VK_TAB         9

VK_ESCAPE     27

So to wait for the left mouse button to be first pressed and then released you

could use:

Do While GetKeyState(VK_LBUTTON)>=0: DoEvents: Loop

Do While GetKeyState(VK_LBUTTON)<0: DoEvents: Loop

Submitted By: Dan Bystrom


Mouse cursor

LUOKKA: mouse

21.How do I make the mouse cursor invisible/visible?

   Use the API call ShowCursor(False) or ShowCursor(True). Just be aware

   that the Windows cursor is a shared object, so if your process hides it

   then it must also redisplay it as well. Also the function is not truly

   "True" or "False" in nature - it is LIFO, so that if your process has

   for some reason set it "False" multiple times then you must set it

   "True" the same number of times in order to re-display the cursor. Hard

   to explain but play with it - you'll see what I mean...

   ÄGalen Raben (galenr@hpgrla.gr.hp.com)Å


Mouse leaving form

LUOKKA: mouse

Date: 09/11/94 (09:12)              Number: 19017 of 19086 (Refer# NONE)

From: MKHEINTZ@VELA.ACS.OAKLAND.EDU, Michael Heintz

Subj: Re: Event detect mouse leave the form?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

One way to do this (without any custom controls) is to start a timer when

the first MouseMove is detected on the form.  In the timer event, use the

GetCursorPos API function to get the current mouse cursor coordinates.

Then check the coordinates of the mouse cursor to see if they still fall

on the form.  If not, then perform any necessary processing.

You will need at least two API calls to do this, one to get the top and left

coordinates of the window you are checking (ClientToScreen) and the other

to get the coordinates of the Mouse (GetCursorPos).  Both return the

coordinates in the POINTAPI structure, in PIXELS!!  To get the region of

your window, multiply the Height and Width of your form by

Screen.TwipsPerPixelY and Screen.TwipsPerPixelX to get the window region

in pixels... then check to see if the coordinates of the mouse cursor fall

within this region.

--

Michael Heintz

InterNet: mkheintz@vela.acs.oakland.edu         BITNET:

mkheintz@oakland.BITNET


Mouse on ? word

LUOKKA: PictureBox

Date: 04-25-95 (11:06)              Number: 307201 of 307873 (Refer# NONE)

From: BRIAND@AZTEC.ASU.EDU

Subj: Re: Tracking text under the cursor

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>>From what you seem to be trying to say, you need to store the locations of

>>each word in an array.  The simplest way I can think of doing this is to

>>create a user-defined type:

>>

>>TYPE WordType

>>   Top as Integer

>>   Left as Integer

>>   Bottom as Integer

>>   Right as Integer

>>End Type

>>

>>Print the text on a picture box, then use the CurrentX and CurrentY along

>>with the TextWidth and TextHeight properties to determine where each

word is in the picture box.

>>If you need more help, or an example, just write.

This is the example I promised.  First, create a form (FORM1) with a picture

box on it.  Then go to the OptionsöProject menu and change Startup form to

Sub Main.  Finally, create a new module with the following code:

DefInt A-Z

Type WordType

   Top        As Integer

   Bottom     As Integer

   Left       As Integer

   Right      As Integer

   Word       As String

   PromptText As String

End Type

Global Words() As WordType

Sub DisplayText (WordHolder() As WordType, PicBox As PictureBox)

   NumWords = UBound(WordHolder)

   PicBox.CurrentX = 0

   PicBox.CurrentY = 0

   For WordNum = 0 To NumWords

      WordHolder(WordNum).Top = PicBox.CurrentY

      WordHolder(WordNum).Left = PicBox.CurrentX

      WordHolder(WordNum).Bottom = PicBox.CurrentY + PicBox.TextHeight(

WordHolder(WordNum).Word)

      WordHolder(WordNum).Right = PicBox.CurrentX + PicBox.TextWidth(

WordHolder(WordNum).Word)

      If WordHolder(WordNum).Right > PicBox.ScaleWidth Then

         PicBox.Print Chr$(13);

         WordNum = WordNum - 1

      Else

         PicBox.Print WordHolder(WordNum).Word;

      End If

   Next

End Sub

Sub Main ()

   'Form1.Load                    'Load the form

   'Make the picture box take up the form's entire client

   'area

   Form1.Picture1.Top = 0

   Form1.Picture1.Left = 0

   Form1.Picture1.Height = Form1.ScaleHeight

   Form1.Picture1.Width = Form1.ScaleWidth

   'Create some sample text

   'This could be text loaded in from a file

   '** Note - The text MUST currently end with a space.

   Text$ = "This is an example of how to determine which "

   Text$ = Text$ + "word the cursor is over in a picture "

   Text$ = Text$ + "box.  This example is of course "

   Text$ = Text$ + "released into public domain. "

   'Parse the text into the Words array

   Call ParseText(Text$, Words())

   'Create the prompts for the text

   Words(0).PromptText = "This program"

   Words(3).PromptText = "A model"

   Words(11).PromptText = "The mouse cursor"

   Words(16).PromptText = "A control in VB that can display a Bitmap,

    MetaFile  or Icon"

   Words(17).PromptText = "A control in VB that can display a Bitmap,

MetaFile  or Icon"

   Words(20).PromptText = "A model"

   Words(26).PromptText = "This program can be copied, modified, and used

 without violating a copyright."

   Words(27).PromptText = "This program can be copied, modified, and used

 without violating a copyright."

   Form1.Show

   'Display the text on the Picture Box

   Call DisplayText(Words(), Form1.Picture1)

   Form1.Picture1.AutoRedraw = True

End Sub

Sub ParseText (Text$, WordHolder() As WordType)

   'Find the number of spaces in the text, to determine

   'approx. how many words are in it.

   Start = 1                              'Start at the

                                          'beginning

   Do

      I = InStr(Start, Text$, Chr$(32))   'Look for a space

                                          'after the one

                                          'just found

      'If a space was found, add 1 to the counter and move

      'the start to its location

      If I > 0 Then

         NumSpaces = NumSpaces + 1

         Start = I + 1

      End If

   Loop Until I = 0

   ReDim WordHolder(NumSpaces + 1)        'Rediminsion the

                                          'array to the #

                                          'of words in the

                                          'text.

   Start = 1                              'Reset the

                                          'starting position

   WordNum = 0                            'Create a counter

                                          'for the current

                                          'location in the

                                          'array

   Do

      I = InStr(Start, Text$, Chr$(32))   'Look for a

                                          'space after

                                          'the one just

                                          'found

      'If a space was found, make the next word = to what

      'was in between it and the previous space

      If I > 0 Then

         WordHolder(WordNum).Word = Mid$(Text$, Start, (I - Start) + 1)

         Start = I + 1

         WordNum = WordNum + 1

      End If

   Loop Until I = 0

End Sub

'*** This goes in the picture box's code under the mouse move event.

Sub Picture1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y

 As Single)

   Form1.Caption = ""

   For I = 0 To UBound(Words)

      If Y >= Words(I).Top And Y <= Words(I).Bottom Then

         If X >= Words(I).Left And X <= Words(I).Right Then

            Form1.Caption = Words(I).PromptText

         End If

      End If

   Next

End Sub

I hope this does what you need.  As you can see when you move the cursor

over words that have an associated prompt string, the form's title becomes

the prompt string.  There are a few known bugs in the program that you can

probably work out if you need to...

First, the text that is being parsed needs to end in a space, so the last word

will be recognized.  Second, the 2nd space after a period is considered a

word, you don't need to worry about this, but you need to know it when

assigning prompt.

--

                             Brian Dahem

                           briand@aztec.inre.asu.edu


Mouse restrict movem.

LUOKKA: mouse

Date: 02-22-95    Time: 05:09p     Number: 24

From: jsimmons@cs.sunysb.edu        Refer:

Subject: How do I restrict mou             0: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

In article <3i9uv3$3ci@belfort.daimi.aau.dk> jarn@daimi.aau.dk (Jan Riis

Nielsen) writes:

>Can anyone tell me how I can restrict the movement of the mousepointer

>inside the bounds of a control? Preferably it should also work in drag-mode!

Type Rect

    left As Integer

    top As Integer

    right As Integer

    bottom As Integer

End Type

Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, lpRect As

Rect)

Declare Sub ClipCursor Lib "User" (lpRect As Rect)

GetWindowRect Control.hWnd, x

ClipCursor x

_______

Jason Simmons               Author of VBScript - a scripting language

jsimmons@cs.sunysb.edu                  for the VB interface designer

                (ftp.cica.indiana.edu : programr/vbasic/vbscript.zip)


MouseDown on MDI

LUOKKA: mouse

18364 (76+)  gcarter@chat.carleton.ca  23.05.95  17:22

Greg Carter: "Re: MouseDown on MDI"

Jim O'Neil (joneil@mitre.org) wrote:

> The problem is I can't find an event to attach to - MDI forms apparently

> have no mouse or click events.  I tried MessageBlaster and the

RBUTTONDOWN

> message, but that wasn't being trapped either.  It's not a big deal not to

> have the functionality, but now that I've invested some time in it, I'd

> like to come up with some solution.

    Here is some code to do just that.  You'll have to modify it a

bit(I was counting the number of mousedowns).  You'll have to change

the message that it is looking for, from the left mouseup to the

right mouse up. WM_LBUTTONUP = &H202 --- to --- WM_RBUTTONUP =

&H205, in the following code.

 (Thanks to Kermit for the original code)

Put the following declarations in a global module:

'You won't use this type but you need it for the following type

Type POINTAPI

   X As Integer

   Y As Integer

End Type

'This is the Window's message stucture

Type MSG

   hWnd As Integer	'The window handle to which it was sent

   message As Integer	'The message ID

   wParam As Integer	'The messages short parameter

   lParam As Long	'The messages long parameter

   time As Long	'The time it was sent

   pt As POINTAPI	'The point the message occured

End Type

'Now add these symbolic constants

Global Const PM_NOREMOVE = &H0

Global Const PM_NOYIELD = &H2

Global Const WM_LBUTTONUP = &H202	'Left button up message ID

'And finally this DLL (on one line)

Declare Function PeekMessage% Lib "User" (lpMsg As MSG,

ByVal hWnd%, ByVal wMsgMin, ByVal wMsgMax,

ByVal wFlags%)

'Its parameters are as follows:

'lpMsg is loaded with a message structure

'hWnd is the handle of the window whose messages will be examined

'wMsgMin and wMsgMax specify the range of message to seek

'wFlags will be PM_NOREMOVE - don't remove the message from the queue

'	PM_NOYIELD - don't yield to other applications

'	     we'll do this with DoEvents()

'PeekMessage returns zero it no messages stisfying the criteria

'were available, non-zero otherwise.

Add the following sub in the MDI Forms general section:

Sub PollMessages ()

   Dim MyMsg As MSG, GotOne%

   do 'i.e. forever

      GotOne = PeekMessage(MyMsg, Me.hWnd, WM_LBUTTONUP,

WM_LBUTTONUP,

PM_NOREMOVE Or PM_NOYIELD)

      if GotOne <> 0 Then TargetTrys = TargetTrys + 1

'place your code to show/hide the chart here,

      DoEvents

   Loop

End Sub

And in the forms load procedure:

Sub MDIForm_Load ()

   Me.Show

   PollMessages

End Sub

Note: Make sure you show the form before polling or it will never

appear and make the PollMessages call the last one in the sub.

Also, make sure when you end the aplication to use the statement 'End'

otherwise the code stays in memory and the infinite loop

doesn't get released.

It seems alot - but its nice and clean.

This should do exactly what you want, I have used it and it works.

----------------------------------------------------------------------

Greg Carter

Fourth Year Electrical Engineering

Carleton University

Ottawa, Ontario, Canada

Email address : gcarter@chat.carleton.ca

World Wide Web: http://chat.carleton.ca/~gcarter


MS fileitä

LUOKKA: VBgen

S13082        BV0442.ZIP    Huge Array Support in DLL for VB

S13139        VBITMAP.ZIP   Accessing Image Data with Visual Basic

S13150        VBCOMDEM.EXE  Windows COM Port Example for VB 1.00

S13159        VBROWBUF.ZIP  Row Buffering with Visual Basic

S13182        VBEXAMPS.ZIP  VB Programmer's Guide" Examples"

S13227        VBAPI.EXE     VB CDK VBAPI.LIB Without CodeView

S13230        VBROWSE.ZIP   DBLIB Browse Mode with VB Library

S13235        VBTEXT.ZIP    Insert Text Files in SQL Server

S13619        BV0555.ZIP    VB Pro Toolkit Alternative Setup

S13719        VB2.ZIP       MSJ Source: January 1993

S14206        VB2SQL.ZIP    Fixed VBSQL.VBX for Visual Basic 2.0

S14212        VB3.ZIP       VB 3.0 Database Access, OLE Support

S14213        VBDIST.ZIP    MSJ: VB Distribution Disk

S14249        VBCOBSQL.EXE  VBCOBSQL - Sample Application

S14250        VBFILEIO.EXE  VBFILEIO - Sample Application

S14252        NETGO.EXE     Sample for Bidirectional DDE in VB

S14291        SUBVBX.EXE    Subclassing VBX Grid Control in MFC

S14292        AFXVBX.EXE    Using VBX Controls in _AFXDLL Dialog

S14347        VBKB.EXE      Visual Basic Knowledge Base

S14447        VBKB_FT.EXE   VB KB Help Files w/ Full-Text Search

S14494        VBA.EXE       MSJ: Application Interoperability

S14515        MSGBLAST.EXE  MSGBLAST.VBX and Example Files

S14616        SETUPK.EXE    New VB Setup Toolkit & Setup Wizard

S14631        VBRUN300.EXE  Updated VBRUN300.DLL File

S14632        VBRUN200.EXE  VBRUN200.DLL File

S14633        VBRUN100.EXE  VBRUN100.DLL File

S14635        DATAMGR.EXE   VB Data Manager Source Code

S14638        VBHC505.EXE   Updated Help Compilers for Word 6.0

S14640        DATAINDX.EXE  VB Data Access Guide Index

S14642        MSCOMM.EXE    Updated MSCOMM.VBX Control for VB

S14643        VBGRID.EXE    Updated GRID.VBX Control for VB

S14650        WE0993.EXE    Built-in Constants in VB for Apps

S14655        CUSTOM.EXE    Whitepaper:  OLE, WordBasic, VBA

S14663        POSITION.EXE  Help File for VB/Word OLE Automation

S14678        OUTVBX.EXE    Using MSOUTLIN.VBX with MFC

S14706        MBF2IEEE.EXE  DLL to Convert MBF to IEEE in VB

S14725        BNDREAD.EXE   VB Code Sample: Bound Read-Only Text

S14726        CDPLAY.EXE    VB Code Sample: Musical CD Player

S14727        DB-XL.EXE     VB Code Sample: from DB to Excel

S14728        FINDPRT.EXE   VB Code Sample: FindFirst on Strings

S14729        FOCUSPRB.EXE  VB Code Sample: Tracking Controls

S14730        LSTGRID.EXE   VB Code Sample: from List to Grid

S14731        OUTLNDRG.EXE  VB Code Sample: from Outline to List

S14732        PRTPREV.EXE   VB Code Sample: Add Print Preview

S14733        SEEKLST.EXE   VB Code Sample: Seeking w/ Table Obj

S14734        SQLSMTS.EXE   VB Code Sample: Using SQL from List

S14735        VBEXTDEV.EXE  VB Code Sample: Call Printer Driver

S14754        WP1013.EXE    Complete Contents of VB Help File

S14760        VBAPP.EXE     VB for Applications helpfile

S14761        COMLYR.EXE    Jet 2.0/VB 3.0 Compatibility Layer

S14762        WINAPI.EXE    WINAPI.TXT for VB for Windows

 S14347   VBKB.EXE      WINDOWS: Visual Basic Knowledge Base

 S14447   VBKB_FT.EXE   WINDOWS: VB KB Help Files w/ Full-Text Search


MS Pro Exam

LUOKKA: VBgen

27140 (257+)  jwgilb@ccmail.monsanto.com  24.07.95  20:13

Jim Gilbert: "Re: Anyone who has taken the VB Professional Exam from

Microsoft"

weigand@stimpy.eecis.udel.edu (Steven Weigand) wrote:

>In article <3utotl$6po@news.usit.net>, Drew Bolce' <dbolce@usit.net.com>

wrote:

>>I am preparing to take the Microsoft Certified Professional exam.  I

>>would like to get the experience, strength and hope of people who have

>>already taken the exam.  I am not looking to cheat, I just want to be

>>sure I have prepared properly.

I took (and passed) the VB MCP exam last year.  A couple of words of

advice:

- study the manuals - the appendices that list the limits of things (no

of ctls, no of forms, etc.)

- study the stuff you never use - whether that is OLE, DDE, API use,

whatever.  If it is part of VB, it is probably in the test.

- Be prepared for questions like "Which of the following is false, except

when such-and-such happens"

- You can download a sample test from somewhere on the MSL.  It's not

quite as hard as the real thing.  But, it gives you a feel for what the exam is

like.  There are basically 2 types of questions - 'pick one answer among 4

choices', or 'pick any or all of 4 choices'

Now, as far as whether or not this is a good thing, let me just say that

this is one of only 4 tests you must take to become "Microsoft Certified".  I

have only taken this one test, because it's the only one that deals with things

I am interested in.  Two of the tests deal with *internals* of Win & NT, and

are more based towards someone like a LAN administrator or systems-type

person.  By making you take 4 tests, I think MS is trying to make it less like

the Novell CNE (which are not that hard to come by).  The fact that the tests

are $100 a pop kind of reduces the casually interested.

I am not 100% sold on this idea of certification, but I can tell you that

the larger companies I have dealt with are starting to look into it.  I don't

want to start a debate like the 'VB jobs 61+k /year' thread turned into, just

my 02 worth.

--

Jim Gilbert                    all normal disclaimers about my opinions

jwgilb@ccmail.monsanto.Com         Monsanto Co., St. Louis, MO


MS Viewer 2.0

LUOKKA: MediaView

Date: 04-10-95    Time: 04:26p     Number: 515

From: roebuck@primenet.com          Refer:

Subject: MS Viewer 2.0                     3: comp.os.ms-w   Status: Public

-------------------------------------------------------------------------------

>   huelin@hubble.sheridanc.on.ca (Shawn Huelin) writes:

>  Are there any books on learning to publish with MS Viewer 2.0.  Other

>  than the Microsoft documentation?

>  --

>  Shawn Huelin

>>>>

The Viewer How-To CD by Stephen Pruitt and published by the

Waite Group is pretty good.

Patrick Roebuck

roebuck@primenet.com


Msafinx.dll

LUOKKA: VBgen

Date: 09/28/94 (21:49)              Number: 21082 of 21392 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: "File Not Found" Erro

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If you are using any of the financial functions (DDB, FV, IPmt, IRR, MIRR,

NPer, NPV, Pmt, PPmt, PV, Rate, SLN, SYD, IIF) you need to have

MSAFINX.DLL

int your Windows/System directory.  IIF is usually the culptrit.

_________

                           Bradley S. Murray


Msajt200.dll

LUOKKA: Access

Date: 10/03/94 (15:22)              Number: 21581 of 21728 (Refer# NONE)

From: SEAGRAM@INTERLINK.NET

Subj: Re: VB app using Acc1.1 asking for MSAJT200.DLL

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I have a humble little app that is using an Access 1.1 file. I am

>including the MSAJT110.DLL (Jet Engine) and the MSAJT112.DLL (the

>compatablity bridge) in the Setupwiz setup. On some PC's this installs just

>fine. On others, a message pops up asking for MSAJT200.DLL and kills the

>program right there.

There is a piece of the puzzle missing: VBDB300.DLL. That file determines

whether you data access goes to 1.1 or 2.0 engine. That is:

If you have OLD VBDB300.DLL then you need MSAJT110.DLL

If you have NEW VBDB300.DLL then you need MSAJT112.DLL and

MSAJT200.DLL.

On your PC your app works with new VBDB300.DLL and uses MSAJT200.DLL

(just try

renaming MSAJT110.DLL to MSAJT110.XXX -- your app should still work).

Since you are distributing your new VBDB300.DLL, then your clients will need

the above mentioned 2 DLLs. You should convert your database to v2.0 as

well.

If you really want to stay in 1.1, then you have to get old VBDB300.DLL from

the original instalation diskettes.

BTW, why did you want to distribute v1.1 Jet engine and v1.1 .MDB file with

v2.0 compatibility layer?

Hope this helps,

Marko

PS By "new" and "old" VBDB300.DLL, I refer to the original and to one that

came as part of the compatibility layer, respectively.

-----------------------------------------------------

Marko Milisavljevic         m_milis@pavo.concordia.ca

Montreal, Canada                seagram@interlink.net


MsComm.Vbx Quirks

LUOKKA: VBgen

13312 (144+)  kevin@biomed.queensu.ca  12.04.95  01:01

Kevin Hood: "Re: MSCOMM.VBX Quirk"

>I'm facing another problem when using MSCOMM.VBX: I can't use baudrates

>higher than 19200 :-( I really need at least 38400, is there anyway

>to use 38400 or even 57600 ?

AHA - I found it - my filing system works.  I was recently sent this

from a net-xpert (Eric F. Himmer  75540.1770@compuserve.com).

I have not tried it but you are welcome to give it a go:

==============================================================

=====

' Example showing how to obtain baudrates greater than 19200 using

MSCOMM

' is provided by: Eric F. Himmer  75540.1770@compuserve.com

'

' Please feel free to ask questions or make suggestions!

'------------------------------------------------------------------

' This section should be placed in your global module

' DCB as taken from Daniel Appleman's book: "Visual Basic Programmer's

' Guide to the Windows API"Type DCB    	' 25

bytes

    Id As String * 1

    BaudRate As Integer

    ByteSize As String * 1

    Parity As String * 1

    StopBits As String * 1

    RlsTimeout As Integer

    CtsTimeout As Integer

    DsrTimeout As Integer

    Bits1 As String * 1

    Bits2 As String * 1

    XonChar As String * 1

    XoffChar As String * 1

    XonLim As Integer

    XoffLim As Integer

    PeChar As String * 1

    EofChar As String * 1

    EvtChar As String * 1

    TxDelay As Integer

End Type

'Comm Baud Rate indices

Global Const CBR_110 = &HFF10       ' -240

Global Const CBR_300 = &HFF11       ' -239

Global Const CBR_600 = &HFF12       ' -238

Global Const CBR_1200 = &HFF13      ' -237

Global Const CBR_2400 = &HFF14      ' -236

Global Const CBR_4800 = &HFF15      ' -235

Global Const CBR_9600 = &HFF16      ' -234

Global Const CBR_14400 = &HFF17     ' -233

Global Const CBR_19200 = &HFF18     ' -232

Global Const CBR_38400 = &HFF1B     ' -229

Global Const CBR_56000 = &HFF1F     ' -225

Global Const CBR_128000 = &HFF23    ' -221  -  Not currently supported by

Windows 3.1x?

Global Const CBR_256000 = &HFF27    ' -217  -  Not currently supported by

Windows 3.1x?' The following are as defined by the MSCOMM control

Global curParity As String	' "E" "O" "N" "M" or "S"

Global curDataBits As String	' "7" or "8"

Global curstopBits As String	' "1" "1.5" or "2"

Global curCommPort As Integer	' 1 2 3 or 4

Global curBaudRate As String	' Actual baud rate wanted" "9600"

etc

Global curHandShake As Integer	' none=0, XonXoff=1, RtsCts=2

'------------------------------------------------------------------' This section usually

into the general declaration section of the

' form in which it will be used.

Declare Function BuildCommDCB Lib "User" (ByVal lpDef As String, lpDCB As

DCB) As Integer

Declare Function GetCommState Lib "User" (ByVal nCid As Integer, lpDCB As

DCB) As Integer

Declare Function SetCommState Lib "User" (lpDCB As DCB) As IntegerDim

adjustedAsyncData As DCB

'------------------------------------------------------------------

' This subroutine will set the baud rate to a higher rate than MSCOMM

' can be configured for.  It is assumed that the port has already been

' opened by the PortOpen call to MSCOMM.Sub AdjustAsyncValues ()

    Dim rv%

    ' Only purpose of using BuildCommDCB in this case is to get the comm port

id

    ' for use by GetCommState (id's are most likely 0=COM1, 1=COM2...)

    rv = BuildCommDCB("COM" & CommPort.CommPort & ":" &

CommPort.Settings, adjustedAsyncData)

    If rv < 0 Then

        MsgBox "Error: Comm settings are invalid"

        Exit Sub

    End If    rv = GetCommState(Asc(adjustedAsyncData.Id),

adjustedAsyncData)

    If rv < 0 Then

        MsgBox "Error: Cannot obtain current MSCOMM settings"

        Exit Sub

    End If

    Select Case curBaudRate

        Case "56000"

            adjustedAsyncData.BaudRate = CBR_56000       ' BaudRate (as

index)

        Case "38400"

            adjustedAsyncData.BaudRate = CBR_38400       ' BaudRate (as

index)

    End Select

    ' This example is not concerned with overriding any other MSCOMM

    ' settings other than the baud rate, so the following lines have

    ' been commented out, but shown for your future use if desired.

    'adjustedAsyncData.ByteSize = Chr$(&H8)      ' ByteSize (data bits)

    'adjustedAsyncData.Parity = Chr$(&H0)        ' Parity

    'adjustedAsyncData.StopBits = Chr$(&H0)      ' StopBits

    'adjustedAsyncData.RlsTimeout = 0            ' RlsTimeout (CD timeout)

    'adjustedAsyncData.CtsTimeout = 0            ' CtsTimeout

    'adjustedAsyncData.DsrTimeout = 0            ' DsrRimeout

    'adjustedAsyncData.Bits1 = Chr$(&H80)

        ' 1                         ' fBinary (enabled)

        ' 0                         ' fRtsDisable (reflect actual state)

        ' 0                         ' fParity (disabled)

        ' 0                         ' fOutxCtsFlow (disabled)

        '   0                       ' fOutxDsrFlow (disabled)

        '   00                      ' fDummy (2 reserved bits)

        '   0                       ' fDtrDisable (reflect actual state)

        '

    'adjustedAsyncData.Bits2 = Chr$(&H0)

        ' 0                         ' fOutX (XON/XOFF disabled)

        ' 0                         ' fInX (XON/XOFF disabled)

        ' 0                         ' fPeChar (no parity substituition char)

        ' 0                         ' fNull (do not discard nulls)

        '   0                       ' fChEvt (disabled flagging of EvtChar event)

        '   0                       ' fDtrFlow (disabled)

        '   0                       ' fRtsFlow (disabled)

        '   0                       ' fDummy2 (1 reserved bit)

'adjustedAsyncData.XonChar = Chr$(&H11)       ' XonChar

    'adjustedAsyncData.XoffChar = Chr$(&H13)      ' XoffChar

    'adjustedAsyncData.XonLim = 100               ' XonLim (min chars before

XON sent)

    'adjustedAsyncData.XoffLim = 100              ' XoffLim (min buff space

before XOFF sent)

    'adjustedAsyncData.PeChar = "?"               ' PeChar (parity substitution

char)

    'adjustedAsyncData.EofChar = Chr$(&HFF)       ' EofChar (end-of-data

char)

    'adjustedAsyncData.EvtChar = Chr$(&HFE)       ' EvtChar (char to signal an

event)

    'adjustedAsyncData.TxDelay = 0                ' TxDelay (not used by

Windows 3.1x)

    ' Override the MSCOMM settings using the SetCommState API call

    rv = SetCommState(adjustedAsyncData)

    If rv < 0 Then

        MsgBox "Error: Cannot override MSCOMM settings"

    End IfEnd Sub

'------------------------------------------------------------------

' This section is an excerpt showing the PortOpen function, followed

' by the resetting of the commport to the higher rate.    ' There are two

methods for setting the baud rate, one is by

    ' providing the baud rate as a value (i.e. "9600"); the other is

    ' by providing the baud rate using an index value (i.e. &hFF16 to

    ' to specify 9600 baud, see CBR_ values defined above).

    '

    ' MSCOMM does not support the setting of baud rates using an index

    ' value; therefore, whereas values greater than 32767 are negative

    ' integers, they cannot be used to set the baud rate; hence,

    ' a baud rate of 38400 or greater is invalid to MSCOMM).

    '

    ' To get higher baud rates, we have to set MSCOMM to 19200 (or any

    ' lower rate) and change it later using an index value representing

    ' the rate we really want by using the API.

    If (curBaudRate = "38400") Or (curBaudRate = "56000") Then

        CommPort.Settings = "19200" & "," & curParity & "," & curDataBits & ","

& curStopBits

    Else

        CommPort.Settings = curBaudRate & "," & curParity & "," & curDataBits

& "," & curStopBits

    End If

    CommPort.CommPort = curCommPort

    CommPort.Handshaking = curHandShake

    CommPort.Notification = 0

    CommPort.Interval = 55

    CommPort.DTREnable = True

    CommPort.PortOpen = True

    If CommPort.PortOpen Then

        CommPort.RTSEnable = True

        ' If user wants higher than MSCOMM's max of 19200, then call our baud

rate

        ' adjustment subroutine after raising RTS (had to give MSCOMM some

time to

' complete the open for some reason... so if the next statement gets

called

' too quickly after the open, it will not work).

        If (curBaudRate = "38400") Or (curBaudRate = "56000") Then

AdjustAsyncValues

    End If


MSDN

LUOKKA: VBgen

Date: 03-03-95 (18:47)              Number: 244139 of 244354 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: TECHNET VS MSDN

From: KEVIN ALBERT <KEVIN_ALBERT@SMTPGATE.MITCHELL.COM>

     Microsoft has set up a service on the World Wide Web called Developer

     Network OffRamp.  It is located at http://www.microsoft.com.  Included is

     information regarding MSDN membership and new changes to the

Development Library and Platform.

     To join MSDN, in US call (800) 759-5474 and ask for department 1209.

   For international numbers, email me and I will pass them along to you.

     To summarize information I have:

     The MSDN Level 1 includes the Development Library for US$195.

     The MSDN Level 2 additionally includes the Development Platform for

     US$495.

     Each of these subscriptions entitles you to quarterly updates for one

     year.

     The Library contains technical articles, sample code, product

     documentation, bug reports, and some Microsoft Press books.

     The Platform provides the Library, all current development toolkits (SDKs

     and DDKs), and US and international versions of Microsoft operating

     systems Windows, Windows for Workgroups, and Windows NT (retail and

     debug).

     I have found the Platform to be an outstanding value - would be even

     better if I had time to utilize more of it.

     kevin_albert@smtpgate.mitchell.com

______________________________ Reply Separator

Subject: No subject given

Author:  Visual Basic List <VISBAS-L@LISTSERV.TAMU.EDU> at

SMTPGate-Mitchell

Date:    3/2/95 12:05 PM

SUBJECT: TECHNET VS MSDN

 tech net - i believe contains the knowledge bases, manuals

            whitepapers, info on virutally all of microsoft software

            about $200 year (shipped monthly)

 msdn - has 2 levels

    level 1 - is toolkits,ddk's (ole,odbc,sdk,etc) about $200 year

    level 2 - is level 1 + operating systems (win,win nt) $390+ year

            (level 2 is of better value)

    shipped every quarter


MSDN cd-rom

LUOKKA: VBgen

Date: 08/16/94 (01:21)              Number: 15718 of 15821 (Refer# NONE)

From: BKMA@CONNECTED.COM

Subj: The coolest resource! MSDN CD

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

After getting email asking what it is, MSDN contains a mountian of

material -- which would cost you a small fortune -- on a CD ROM.  It

is better than a book because you can do a full text search over it

with a decent search engine (not just Keywords in a help file):

The latest issue contains the following:

Welcome to the July 1994 Library

Technical Articles

 Ask Dr. GUI

 C/C++ Articles

 FoxPro Articles

 LAN Manager Articles

 Microsoft Access Articles

 Microsoft Excel Articles

 Multimedia Articles

 SQL Server Articles

 Visual Basic Articles

 Visual C++ (16-bit) Articles

 Visual C++ (32-bit) Articles

 Visual C++ 1.5 (16-bit) Articles

  MFC 2.5 Technical Notes

 Windows (16-bit) Articles

  Development Environment Articles

  GDI Articles

  Kernel and Drivers Articles

  OLE and DDE Articles

  Window Manager Articles

 Windows (32-bit) Articles

 Windows for Pen Computing Articles

 Windows for Workgroups Articles

 WordBasic Articles

Sample Code

 Technical Article Samples

  C++ Samples

  DDE Samples

  GDI Samples

  Kernel Samples

  Miscellaneous Samples

  Multimedia Samples

  OLE Samples

  Visual Basic Samples

  Win32 and Windows NT Samples

  Window Manager Samples

  Windows for Workgroups Samples

 Book and Periodical Samples

  Advanced Windows NT Samples

  Animation Techniques for Win32 Samples

  Dr. Dobb's Samples

  Inside OLE 2.0 Samples

  Microsoft Systems Journal Samples

   1990 Volume 5

    July-Aug 1990 Number 4

    Sept-Oct 1990 Number 5

    Nov-Dec 1990 Number 6

   1991 Volume 6

    Jan-Feb 1991 Number 1

    Mar-Apr 1991 Number 2

    May-June 1991 Number 3

    July-Aug 1991 Number 4

    Sept-Oct 1991 Number 5

    Nov-Dec 1991 Number 6

   1992 Volume 7

    Jan-Feb 1992 Number 1

    Mar-Apr 1992 Number 2

    May-June 1992 Number 3

    July-Aug 1992 Number 4

    Sept 1992 Number 5

    Oct 1992 Number 6

    Nov 1992 Number 7

    Dec 1992 Number 8

   1993 Volume 8

    January 1993 Number 1

    February 1993 Number 2

    March 1993 Number 3

    April 1993 Number 4

    May 1993 Number 5

    June 1993 Number 6

    July 1993 Number 7

    August 1993 Number 8

    September 1993 Number 9

    October 1993 Number 10

    November 1993 Number 11

    December 1993 Number 12

   1994 Volume 9

    January 1994 Number 1

    February 1994 Number 2

    March 1994 Number 3

    April 1994 Number 4

    May 1994 Number 5

    June 1994 Number 6

    July 1994 Number 7

    August 1994 Number 8

  Programming Windows 3.1 (Petzold) Samples

 Product Samples

  Application Toolkits and SDKs

   Microsoft Excel SDK Samples

   Office Developer's Kit 1.0 Samples

   Open EIS (Enterprise Information System) Pak Samples

  Languages

   Macro Assembler 6.1 Samples

   MFC 2.0 and VC++ 1.0 (32 bit) Samples

   Visual Basic 2.0 Samples

   Visual Basic 3.0 Samples

   Visual C++ 1.0 (32-bit) Samples

   Visual C++ 1.5 (16-bit) Samples

    MFC

    OLE

    General

  System Toolkits, DDKs, and SDKs

   Embedded SQL Programmer's Toolkit for COBOL Version 4.21 Samples

   Microsoft CD-ROM Extensions DDK Samples

   Microsoft Video for Windows SDK Samples

   Microsoft Windows for Workgroups

    16-bit RAS Software Development Kit

   Multimedia Developer Registration Kit

   ODBC 1.0 SDK Samples

   SNA Server for Windows NT SDK Samples

   SQL Server Benchmark Kit Samples

   SQL Server for Windows Programmer's Toolkit SDK Samples

   Win32 SDK Samples

   Windows 3.1 SDK Samples

   WOSA/XRT Samples

 Conference and Seminar Samples

  DevCast II, August 1993, Samples

  DevCast III, December 1993, Samples

  DevCast IV, March 1994, Samples

  DevCast V, June 1994, Samples

  Tech*Ed, March 1993, Samples

  Tech*Ed, March 1994, Samples

 Sample City

  C++ Samples

  DDE Samples

  FoxPro Samples

  GDI Samples

  Kernel Samples

  Microsoft Access Samples

  Miscellaneous Samples

  Multimedia Samples

  Visual Basic Samples

  Win32 and Windows NT Samples

  Window Manager Samples

  Windows for Pen Computing Samples

Backgrounders and White Papers

Specifications

 CLAXP Compiler Specifications 8.00

 Digital Video MCI Specification

 EMM386 I/O Trapping Extensions

 Extended Capabilities Port Specifications

 Extended Memory Specification (XMS) 3.0

 IME Program Specification:  Japanese Version

 Microsoft Flash File System Media Control Specification 1.0

 Microsoft TrueType Specifications

  TrueType 1.0 Font Files Revision 1.02

 Microsoft Windows Telephony API Specification

 Microsoft Windows Telephony SPI Specification

 Network Driver Interface (NDIS) Spec 2.0.1

 NLSAPI Functional Specification 5.4

 Plug and Play Specifications

 Symbolic Debugger Specification

 Trademark Usage Guidelines

 Virtual DMA Services (VDS) 1.0

 Windows SNA Specifications

  Windows APPC specification

  Windows CPI-C specification

  Windows CSV specification

  Windows HLLAPI specification

  WinLUA specification

 Windows Sockets 1.1 Specification

 WOSA Extensions for Real-Time Market Data (WOSA/XRT) Version 1.00

Knowledge Base and Bug Lists

 C KBase

 C++ KBase

 CodeView KBase

 Compiler Utilities KBase

 Microsoft Excel 4.0 SDK KBase

 FORTRAN KBase

 FORTRAN Powerstation for MS-DOS KBase

 FoxBASE+ for Macintosh KBase

 FoxBASE+ for MS-DOS KBase

 FoxPro for MS-DOS KBase

 FoxPro for Windows KBase

 FoxPro Library Construction Kit KBase

 LAN Manager KBase

 Mail KBase

 Mail File Format API KBase

 MASM KBase

 Microsoft Access KBase

 Microsoft Access Distribution Kit KBase

 Microsoft CD-ROM Extensions KBase

 Microsoft Foundation Classes (MFC) KBase

 Microsoft Test for Windows KBase

 MS-DOS KBase

DDK KBase

 Multimedia Viewer KBase

 Networking Protocol KBase

 ODBC SDK KBase

 OLE KBase

 SNA Server for Windows NT KBase

 SQL Server KBase

 Visual C++ Products KBase

 Visual Basic for Applications KBase

 Visual Basic for MS-DOS KBase

 Visual Basic for Windows KBase

 Win32 DDK KBase

 Win32 SDK KBase

 Windows DDK KBase

 Windows Far East SDK KBase

 Windows for Workgroups KBase

 Windows NT KBase

 Windows NT Advanced Server KBase

 Windows SDK KBase

 WordBasic KBase

 Workgroup Add-Ons for MS-DOS KBase

 XMS KBase

Books and Periodicals

 Advanced Windows NT

 Animation Techniques for Win32: A C++ Programmer's Guide to DIBs,

Palettes, and Sprites

 Inside OLE 2

 Inside Visual Basic Articles (Cobb)

 Internationalization Handbook for Software Design

 MS-DOS Programmer's Reference 6.0

 Microsoft Developer Network News

  1993 Volume 2

   July 1993 Number 4

   September 1993 Number 5

   November 1993 Number 6

  1994 Volume 3

   Jan 1994 Number 1

   March 1994 Number 2

   May 1994 Number 3

 Microsoft Systems Journal

  1990 Volume 5 (July-Nov, Num 4-6)

  1991 Volume 6

   Jan-Feb 1991 Number 1

   Mar-Apr 1991 Number 2

   May-June 1991 Number 3

   July-Aug 1991 Number 4

   Sept-Oct 1991 Number 5

   Nov-Dec 1991 Number 6

  1992 Volume 7

   Jan-Feb 1992 Number 1

   Mar-Apr 1992 Number 2

   May-June 1992 Number 3

   July-Aug 1992 Number 4

   Sept 1992 Number 5

   Oct 1992 Number 6

   Nov 1992 Number 7

   Dec 1992 Number 8

  1993 Volume 8

   January 1993 Number 1

   February 1993 Number 2

   March 1993 Number 3

   April 1993 Number 4

   May 1993 Number 5

   June 1993 Number 6

   July 1993 Number 7

   August 1993 Number 8

   September 1993 Number 9

   October 1993 Number 10

   November 1993 Number 11

   December 1993 Number 12

  1994 Volume 9

   January 1994 Number 1

   February 1994 Number 2

   March 1994 Number 3

   April 1994 Number 4

   May 1994 Number 5

   June 1994 Number 6

   July 1994 Number 7

   August 1994 Number 8

 Programming Windows 3.1 (Petzold)

 Visual Basic Programmer's Journal Articles

Product Documentation

 Applications

  FoxPro 2.5 for Windows

   Developer's Guide

   Installation and Configuration

   Language Reference

   User's Guide

  FoxPro Kits and Tools

   FoxPro Connectivity Kit

   FoxPro for MS-DOS Distribution Kit

   FoxPro for Windows Distribution Kit

   FoxPro Library Construction Kit

   FoxPro Migration Kit

   Resource Kit for Version 2.5x

  Microsoft Access 1.1

   Introduction to Programming

   Language Reference

   User's Guide

  Microsoft Access 1.1 Distribution Kit

   Distribution Kit Guide

   Help Compiler Guide

   Wizards Design Guide

  Microsoft Access 2.0

  Microsoft Excel 5.0

   Macro Function Reference

   Worksheet Function Reference

  Open EIS (Enterprise Information System) Pak 1.1

   EIS Builder User's Guide

  Word for Windows 6.0

   Developer's Kit

   Fields Reference

 Languages

  FORTRAN PowerStation 32 Programmer's Guide

  Macro Assembler 6.1 (16-bit)

   Getting Started

   Environment and Tools

   Programmer's Guide

   Reference

  Macro Assembler 6.11 for Windows NT (32-bit)

  Visual Basic 3.0 Professional Edition

  Visual C++ 1.0 (16-bit)

   C++ Tutorial

  Visual C++ 1.0 (32-bit)

   App Studio User's Guide

   Build Tools User's Guide

   C Language Reference

   C++ Language Reference

   Class Library Reference

   Class Library User's  Guide

   CodeView Debugger User's Guide

   Getting Started

   Help Compiler User's Guide

   iostream Class Library Reference

   Preprocessor Reference

   Programming Techniques

   Run-Time Library Reference

   Source Profiler User's Guide

   Spy++ User's Guide

   Visual Workbench User's Guide

  Visual C++ 1.5 (16-bit)

   App Studio User's Guide

   C Language Reference

   C++ Language Reference

   Class Library Reference

   Class Library User's Guide

   CodeView Debugger User's Guide

   Command-Line Utilities User's Guide

   Database Classes

   iostream Class Library Reference

   OLE 2 Classes

   Programming Techniques

   Programming Tools for Windows

   Run-Time Library Reference

   Source Profiler User's Guide

   Visual Workbench User's Guide

  Visual Control Pack

   Control Development Guide

   Custom Control Reference

 Office Developer's Kit 1.0

  Office Programming Resources

   Introduction to the Microsoft Office Developer's Kit

   Designing Integrated Solutions with Microsoft Office

   Microsoft Jet 2.0/Visual Basic 3.0 Compatibility Layer

   Object Browser

   Programming Integrated Solutions with Microsoft Office

   Sample Applications

  Electronic Forms Designer 1.0

   Developer's Guide

  Mail 3.2 SDK

   Common Messaging Calls

   Directory Syncronization with Foreign Mail Systems

   File Format API for Gateways and Applications

   Mail Administrator's Guide

   Mail User's Guide: Windows and Presentation Manager

   Mail User's Guide: Workstation Software for MS-DOS

   Schedule+ Libraries

   Technical Reference

   Workgroup Templates

    Developer's Handbook

  Microsoft Access 2.0

   Advanced Topics

   Building Applications

   Language Reference

   User's Guide

  Microsoft Excel 5.0

   Developer's Kit

   Query User's Guide

   User's Guide

   Visual Basic for Applications Reference

   Visual Basic User's Guide

  PowerPoint 4.0 User's Guide

  Visual Basic 3.0 Professional Edition

   Control Development Guide

   Crystal Reports for Visual Basic

   Custom Control Reference

   Data Access Guide

   Help Compiler Guide

   Language Reference

   Programmer's Guide

  Word 6.0

   Developer's Kit

   Quick Results

   User's Guide

 SDKs

  Common Messaging Calls (CMC) Application Programming Interface 1.0

   Developer's Guide

  Common Speller Application Programming Interface (CSAPI)

  International SDKs

   MS-DOS 6.2/V BIOS Technical Reference Guide

   Windows 3.1 Arabic Supplement Programmer's Reference

   Windows 3.1 SDK Chinese Version

    Chinese Windows Installation and Device Driver Guide

    Chinese Windows Intelligent Font Environment

    Chinese Windows Software Development Kit Extension

     Book 1

     Book 2

   Windows 3.1 Hangeul Version

    Hangeul Windows Installation and Device Driver Guide

    Hangeul Windows Intelligent Font Environment

    Hangeul Windows Software Development Kit Extension

     Book 1

     Book 2

   Windows 3.1 Hebrew Supplement Programmer's Reference

  LSAPI Software Developer's Toolkit 1.10

  Mail 3.2 SDK

  Messaging Application Program Interface (MAPI) 1.09 SDK

   Client Developer's Guide

   Provider Developer's Guide

  Microsoft Test 3.0 User's Guide

  Multimedia Standards Update

  Open Database Connectivity SDK 2.0

   Programmer's Reference

   SDK Guide

  OLE 2

   OLE 2.0 Programmer's Reference

    Vol 1: Working with Windows Objects

    Vol 2: Overview of OLE Automation

   OLE 2.01 Release Notes

   OLE 2.01 User Interface Library

  OS/2 to Windows Porting Guide and Tools

  Remote Access Service Application Programming Interface 3.11 (16-bit)

  Resource Localization Tools

   Resource Localization Manager User's Guide

   Resource Localization Tools Tutorial

   Resource Localization Toolset User's Guide

  Simple MAPI SDK

  SNA Server for Windows NT SDK

   3270/5250 Applet User's Guide

   3270 Emulator Interface Specification

   Administration Guide

   APPC Programmer's Guide

   CPI_C Programmer's Guide

   CSV Programmer's Guide

   Installation Guide

   LUA Programmer's Guide

   Reference

   SNA Device Interface Specification

   Windows HLLAPI Specification

  SQL Server Benchmark Kit

  SQL Server for Windows NT: Programmer's Toolkit

   Microsoft Open Data Services Programmer's Reference

   Programmer's Reference for C

   Programmer's Reference for Visual Basic

   Transact-SQL Reference

  TCP/IP Sockets Developer's Kit Programmer's Reference (DOS and OS/2)

  User Interface Design Guide (Preliminary Version)

  Video for Windows Development Kit 1.1 Programmer's Guide

  VoiceView Software Support in Microsoft Windows

  Win32 SDK

   Programmer's API Reference Vol. 1

   Programmer's API Reference Vol. 2

   Programmer's API Reference Vol. 3

   Programmer's API Reference Vol. 4

   Programmer's API Reference Vol. 5

   Programming Techniques

   RPC Programmer's Guide and Reference

   Tools User's Guide

   Win32s Programmer's Reference

   Windows NT SNMP Programmer's Reference

  Windows 3.1 SDK

   Getting Started

   Guide to Programming

   Multimedia Programmer's Guide

   Multimedia Programmer's Reference

   Programmer's Reference Volume 1: Overview

   Programmer's Reference Volume 2: Functions

   Programmer's Reference Volume 3: Messages, Structures, and Macros

   Programmer's Reference Volume 4: Resources

   Programming Tools

   Setup Toolkit for Windows

   Windows for Pen Computing Reference

   Windows for Workgroups Reference

   The Windows Interface: An Application Design Guide

  Windows 3.1 Telephony SDK

   Programmer's Guide

   Service Provider Programmer's Guide

  Windows for Pen Computing 1.1 Japanese Edition SDK

   Introduction

   Programmer's Reference

  Windows NT for Alpha AXP Calling Standard

  Windows Resource Kits

   Windows 3.1 Resource Kit

   Windows for Workgroups 3.1 Resource Kit

    Addendum for Version 3.11

   Windows NT Resource Kit

    Concepts and Planning Guide

    Messages

    Optimizing Windows NT

    Resource Guide

  WOSA Extensions for Real-Time Market Data SDK

 DDKs

  Microsoft CD-ROM Extensions DDK

  Windows 3.1 DDK

   Device Driver Adaptation Guide

   Installation and Update Guide

   Minidriver Development Guide

   Multimedia Device Adaptation Guide

   Printers and Fonts Kit

   Virtual Device Adaptation Guide

  Windows NT Device Driver Kit

   Getting Started

   Kernel-mode Driver Design Guide

   Kernel-mode Driver Reference

   Network Drivers

   Programmer's Guide

   Win32 Subsystem Driver Design Guide

   Win32 Subsystem Driver Reference

  Windows Sound System Version 2.0 DDK Release Notes

Product Tools and Utilities

Unsupported Tools and Utilities

 Windows Help Authoring Guide for Word for Windows 2.0

Conferences and Seminars

 DevCast II, August 1993

 DevCast III, December 1993

 DevCast IV, March 1994

 DevCast V, June 1994

 Microsoft FoxPro Developer Conference, October 1993

 Tech*Ed, March 1993

 Tech*Ed, March 1994

  Microsoft Access

  Microsoft At Work

  Microsoft Excel

  Microsoft FoxPro

  Pen

  Visual Basic

  Visual Basic for Applications

  Visual C++

  Win32

  Windows

  Windows NT

  Workgroups

Development Platform Contents

 Introduction to the Development Platform

 DDKs

  Windows (16-bit)

  Windows (32-bit)

 Operating Systems

  MS-DOS

  Windows (16-bit)

  Windows (32-bit)

 SDKs

  MS-DOS

  Windows (16-bit)

  Windows (32-bit)

 Tools

  Windows (16-bit)

  Windows (32-bit)

Martin Evaldsen

--

Bainbridge Knowledge Management Arts, Inc.  Serving Puget Sound since

1987

  Gurus' in Visual Basic, Access Basic, NT SQL, Client/Server in WIndows

   Fax: 1-206-779-7747             ö   Internet: BKMA@Connected.Com

     DLL, VBX, OCX developers      ö Winhelp/Viewer/Advisor Custom Tools

Date: 08/16/94 (01:21)              Number: 15720 of 15821 (Refer# NONE)

From: BKMA@CONNECTED.COM

Subj: The coolest Resource: In US/Canada

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Ok, more cut and paste:

about how to order it:

To join using your credit card, call  (800)759-5474, department 1016

(24 hours a day, 7 days a week).

Join Level 1 of the Developer Network and get the next four quarterly

releases of the Development Library, packed with inside information on

programming for Microsoft Windows and Windows NT. In addition, you'll

receive the next six issues of the Microsoft Developer Network News (a

bimonthly newspaper that contains programming tips, phone numbers, and

information on development products), and other program benefits.

The list posted earlier is off level 1 CD.

Or join Level 2 of the Developer Network to receive all the Level 1

benefits, plus at least four quarterly releases of the Development

Platform, containing the latest operating systems and API-level SDKs and

DDKs from Microsoft.

Level 2 is 10+ CD ROM per quarter with Win NT in every language that is

made etc..... if you are doing international stuf, makes loading Arabic

Windows one day and Russian windows the next a snap!.

To join the Microsoft« Developer Network, contact the phone number listed

below for your country. If your country is not listed, call this U.S.

number for ordering information:

(402) 691-0173.

Note     Developer Network program benefits may vary by country.

Asia

Hong Kong (852) 804 4234

India and Central Asia 91 11 646 0694

Japan 03 5600 5033

South Korea (080) 022-7337

Taiwan 886 2 504 3122

Caribbean

Caribbean (same as U.S. and Canada) (800) 759-5474 or(402) 691-0173

Europe

Austria, Belgium, Channel Islands, Czech Republic, Denmark, Finland,

Greece, Greenland, Hungary, Iceland, Ireland, Italy, Luxembourg, Norway,

Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland

+31 10 258 88 64  (European Subscription Centre in the Netherlands)

France 05 90 59 04 (toll-free)

Germany 0130 81 02 11 (toll-free)

Netherlands 06 022 24 80 (toll-free)

Russia and neighboring countries 7 095 244 3474

United Kingdom 0800 96 02 79 (toll-free)

Latin America

Argentina, Bolivia, Paraguay, Uruguay 54-1-814-4807

Brazil (55) 011-542-4781

Chile 56-2-2042597

Colombia (57) (1) 618-2245

Mexico and Central America (915) 325-0911

Venezuela 58-2-910008

Middle East and Africa

Israel (972) (3) 575-7034

South Africa and Southern Africa 27 11 445 0000

Turkey and Northern Africa 90-212-258 59 98

United Arab Emirates and the Middle East 971 4 513888

Southeast Asia and Australia

Australia 61 2 870 2100

Malaysia 800-1108 (toll-free)

New Zealand 64 9 308 9318

Singapore, Indonesia, Philippines (65) 2207380

Thailand 001-800-65-6591 (toll-free)

--

Bainbridge Knowledge Management Arts, Inc.  Serving Puget Sound since

1987

  Gurus' in Visual Basic, Access Basic, NT SQL, Client/Server in WIndows

   Fax: 1-206-779-7747             ö   Internet: BKMA@Connected.Com

     DLL, VBX, OCX developers      ö Winhelp/Viewer/Advisor Custom Tools


MSDN cdrom

LUOKKA: VBgen

Date: 09/06/94 (14:48)              Number: 18416 of 18426 (Refer# NONE)

From: PEB@NETAXS.COM

Subj: Re: vbkb vs vbkb_ft

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: Also, 5 mb takes a while for me to acquire, and a fair piece

: of my too-rapidly vanishing disk space.  Anyone care to

: comment on the value of having it around?

I *highly* recommend looking into the Level I Microsoft Developer's

Network subscription.  For under $200, you get all the help files,

books, some SDK's on quarterly CD's.  If you are doing C++ development

and using SDK's, get the Level II for $500 which includes a license of

every MS operating system (Windows, Wfw, NT, betas(?)) as well as all

the SDK's.  If you need any of them, its very good bang for the buck.

The Level I is valuable if only to avoid a disk upgrade to hold some

of the help files!

--

Paul Begley

peb@netaxs.com


MSDN cdrom

LUOKKA: VBgen

Date: 09/09/94 (00:48)              Number: 18773 of 18922 (Refer# NONE)

From: DAVID@DESIGNER.COM

Subj: Re: vbkb vs vbkb_ft

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <34jlfv$aer@werple.apana.org.au>

           webber@werple.apana.org.au "Luke Webber" writes:

>No, I don't believe the betas are shipped on the CDs. I agree that level

>one is an essential resource, but level 2 is strictly optional. Not too

>many people need the Hangeul and Japanese Windoze versions, or most of

>the other stuff. As for the quarterly updates, it seems a trifle over the

>top for the level 2 stuff, but about right for level 1. If you subscribe to

>level 2 sometime in the next quarter you just *might* get a copy of Chicago

>in your last update, though 8^).

Well betas are on the level 2 subscription... I've had (just to name two)

MS Test beta and NT 3.5 beta

I totally disagree that level 2 isn't worth it... yes you are right that

most people don't need the Japanese version of Windows BUT there is an

awful lot more to level 2 than that... let's take a look shall we?

Okay, the current level 2 disks are made up of 10 CDs

Disk 1: Has all SDKs and DDKs

Disk 2: Win32 SDK and Windows NT DDK

Disk 3: Windows NT service packs

Disk 4: Windows 3.1, 3.11 and Windows for Workgroups 3.11

Disks 5-9: Windows NT 3.1 (US, French, German, Italian and Spanish)

Disk 10: Video for Windows Samples

In other words over the year, you get the latest SDK, DDK and OSs

+ public beta test software that is available - not bad when you

consider how much it costs to go upto Level 2 and compare that to

how much it's going to cost you to upgrade your OS once!

In fact the level 2 upradge cost me roughly the same price as the

upgrade to NT, but I got all the SDK, DDKs etc thrown in for free!

Perhaps the currency exchange rate isn't too good, but it's certainly

worth the extra outlay up here.

--

David Cragg                           Internet: david@designer.com

                                    Compuserve: 100255,3373


MSDN cdrom

LUOKKA: VBgen

Date: 01/06/95 (07:49)              Number: 174620 of 176248 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Books on VB,Windows NT 3.5, and SQL Server

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

        MSDN CD Level I is $195 per year (4 issues ....2CD/Issue) not $495

        Level II is $495 and has 20+ CD's per issue -- mainly operating

        systems and SDK's

        (little additional documentation)

Includes the best articles from Visual Basic Programmer Journal,

Pinnacle Publications, and Inside Visual Basic.  5 years of MSJ,

etc.....  and starting with the Jan'95 issue, 3-10 advanced articles

written just for the CD on Visual Basic, Access etc.,  for example, the

April CD should include one on how to add spell checking to a VB

application...

I personally view it as the best buy for knowledge,.,,,

Ken


MSDN FAQ

LUOKKA: VBgen

*************************************

*  Microsoft Developer Network (MSDN) 	*

*  Frequently Asked Questions (FAQ)   	*

*************************************

There are six sections in this document:

1. General MSDN Questions

2. Development Library Content Questions

3. Development Platform Content Questions

4. Development Library Support Questions

5. Development Platform Support Questions

6. General Microsoft Questions

***********

General MSDN Questions

***********

1. How much does a membership in the Developer Network cost?

2. If I upgrade to Developer Network Level 2 membership do I get a rebate

for NT SDK/DDK CD that I recently purchased?

3. How can I join the Developer Network?

4. What is the difference between MSDN Level 1 and Level 2 membership?

5. How do I get set-up support for the Development Library?

6. How do I get product support for the contents of the Development

Platform?

7. What licensing options are available for Level 1 and 2 memberships?

8. What about Level 2? Are additional user licenses available?

9. What is the Windows Development Toolkit (WDT)?

10. I'm not a MSDN member yet but I'd like to check out the Developer

Network News free-of-charge. Can I do that?

11. I didn't get my disc this month how can I get it? I have a membership

problem or question.

12. How can I send in a suggestion for the next edition of MSDN?  Do you

know if they are going to include more information about X?

13. Why did I get a renewal notice for $295? Why did you raise the cost of

Level 1?

14. I received two sets of discs 1-4 (or 5-8)? I have a membership problem,

can you help me?

1. How much does a membership in the Developer Network cost?

 MSDN Level 1 membership costs $195 U.S. ($275 CAN) per year, MSDN

Level 2 membership is $495 U.S. ($695 CAN) per year. Developers that

are currently members of MSDN Level 1 can upgrade to Level 2 membership

for $395 U.S. ($555 CAN). Int'l customers: please contact your local

subsidiary.

2. If I upgrade to Developer Network Level 2 membership do I get a rebate

for the NT

 SDK/DDK CD that I recently purchased?

Realizing that all developers already have one or more of the individual

components of the Development Platform (who doesn't have MS-DOS

and Windows?) we chose not to have an "upgrade" price which would create

a suggested retail price that in fact no one would pay. Rather than

use such marketing tactics we chose to have one "real price" for all

developers.

3. How can I join the Developer Network?

 In the U.S. and Canada call (800) 759-5474, 24 hours a day, 7 days a week.

In France, call 05 90 59 04 (Toll Free). In Germany, call 0130 81 02 11

(Toll Free). In the Netherlands, call 06 022 24 80 (Toll Free). In the United

Kingdom, call 0800 96 02 79 (Toll Free). For any other country in Europe,

call +31 10 258 88 64. In Japan, call 03-5461-2617. Everywhere else, call

402-691-0173.

4. What is the difference between MSDN Level 1 and Level 2 membership?

 MSDN Level 1 membership provides all of the information you need to

develop for Windows and Windows NT via the searchable Development

Library (CD) and the Developer Network News. Level 2 membership includes

Level 1 benefits plus all the Microsoft operating systems and

Windows-related API -level SDKs and DDKs on the Development Platform

(CD set).

5. How do I get set-up support for the Development Library?

For Library set-up support, please call (206) 635-7033.  For Platform products

support, call (800) 936-5800.

You may also get set-up support in the MSDN forum on CompuServe.

6. How do I get product support for the contents of the Development

Platform?

 Development Platform support is available by calling (800) 936-5800 or by

posting your question in section five of the MSDN CompuServe forum.

7. What licensing agreements are available for Level 1 and 2 memberships?

 Level 1 membership includes a single-user license for the Development

Library. Level 2 membership includes a single-user license that applies to

both the Development Library and Platform.

For Level 1 members, additional user licenses to share a single Development

Library CD over a network may be purchased for $40 ($55 CAN)

each. Each additional user license allows one designated user to install the

Development Library viewer software on a single workstation to

access the CD's contents. To order additional user licenses, call 800 759

5474.

For large workgroups, Level 1 memberships with concurrent-user licenses are

available in two configurations: a five-user license is $595 ($835

CAN) and a twenty-five-user license is $2495 ($3495 CAN). Concurrent-user

licenses permit the members of a large group to install the

Development Library viewer software on their workstations, but allow no more

than five (or twenty-five) users to run the application at a given

time. The number of developers supported by a concurrent-user license

depends primarily on their usage patterns and network performance.

Developers who expect to make heavy use of the Development Library

should consider individual memberships.

8. What about Level 2? Are additional user licenses available?

 No. Level 2 membership includes a single-user license for both the

Development Library and Development Platform. Because Microsoft

operating systems can be licensed only to a single user, additional licenses

are not available for Level 2 memberships.

9. What is the Windows Development Toolkit (WDT)?

 The Windows Development Toolkit is a retail product that provides the base

level toolkits that developers need to write applications for

Windows, WFW and Windows NT. The WDT will be obsolete when Daytona

is released, and it will not be revised.

10. I'm not a MSDN member yet but I'd like to check out the Developer

Network News free-of-charge. How can I do that?

 Limited Developer Network News subscriptions are available. Send email

with your mailing address to:

CIS: >INTERNET:msdn@microsoft.com

Internet: msdn@microsoft.com

11. I didn't get my disc this month how can I get it? I have a membership

problem or question.

 The Microsoft Developer Network Service Center folks can help you. They

can be reached at (800) 759-5474.

12. How can I send in a suggestion for the next edition of MSDN?  Do you

know if they are going to include more information about X?

 Please send in your MSDN suggestions to one of the following addresses:

 Internet:  msdn@microsoft.com

 CompuServe: >INTERNET:msdn@microsoft.com OR GO MSDN

 Mail:  	Microsoft Developer Network

One Microsoft Way

Redmond, WA  98052-5399

 Fax:	(206) 936-2490

Attn: Developer Network

13. Why did I get a renewal notice for $295? Why did you raise the cost of

Level 1?

 That was a form misprint. The Level 1 annual membership fee is still $195

US/CAN and you can renew by calling 800 759 5474.

14. I received two sets of discs 1-4 (or 5-8)? I have a membership problem,

can you help me?

 This is a packaging error. Please call the Developer Network Service Center

at 800 759 5474 and they will address your membership problem and

get you what you need immediately.

**********

Development Library Content Questions

**********

1. Will the ODK show up?

2. How can I find out about items removed from each Library edition?

3. Where is the Chicago UI guide?

1. Will the ODK show up?

 Yes. Most of the ODK (what was ready) was shipped in the April

Library.We're working our buns off to prep and test the rest of the ODK so it

will show up in its entirety in the July Library.

2. How can I find out about items removed from each Library edition?

 Check out the Help menu, Release Notes, Items Removed from the Library.

3. Where is the Chicago UI guide?

 In the Product Documentation bin, SDKs, User Interface Design Guide

(Preliminary).

**********

Development Platform Content Questions

**********

1. Does the Development Library serve as the documentation for the

Development Platform?

2. Can I get printed copies of the documentation for the development-kits

included on the Development Platform?

3. Why doesn't the Development Platform contain compilers?

4. Will Chicago be included in the Development Platform?

5. Why isn't Pen Windows on the Development Platform?

6. Does the Development Platform contain the MAPI SDK?

7. What is the difference between the Simple MAPI SDK and the Extended

MAPI SDK?

8. Is the OLE 2.0 SDK 16 or 32 bit?

9. Is the MAC Mail 3.1 MPW C SDK going to be included on the Development

Platform?

10. Why isn't the LM PDK on the Development Platform?

11. Will the Office Development Kit (ODK) show up on the Development

Platform?

12. Will Win G information show up on the Development Platform?

13. Which SDKs, DDKs and OSs will ship with the Development Platform

CDs? ODK? ADT? Chicago?

14. Why isn't the second beta of Daytona on the July Platform?

15. Why isn't Chicago on the July Platform?

1. Does the Development Library serve as the documentation for the

Development Platform?

 Yes, the Development Library provides all the documentation for the SDKs

and DDKs distributed via the Development Platform, but these docs

are a subset of the information provided on the Library.

2. Can I get printed copies of the documentation for the development-kits

included on the Development Platform?

 Yes. Printed copies of selected manuals can be ordered from Microsoft Press

at an additional cost. End-user documentation for the operating

systems (as distinct from the development kits) is not provided as part of the

Developer Network. (800) MS-PRESS

3. Why doesn't the Development Platform contain compilers?

 The full SDKs are included on the Development Platform. Tools, headers,

libs etc. Traditionally, SDKs do not contain compilers. The

Development Platform is really intended to be a development platform on top

of which you add the compiler of your choice, be that from Borland,

MS, Symantec etc. The only exception to this rule is when a compiler is not

generally available- an example of this is the Alpha and MIPS

compiler in the Win32 SDK. These will remain in the SDK (and thus the

Development Platform) until such a time when compilers are generally

available for these platforms.

4. Will Chicago be included in the Development Platform?

 Chicago will be included once the Non- Disclosure Agreement (NDA) is

removed. We do not include NDA software on the Development Library

or Platform. There are public Chicago-related technical articles and other

information on the Development Library.

5. Why isn't Pen Windows on the Development Platform?

 Pen Windows is included in Windows 3.1. The only thing not included is the

tablet driver that is specific to the pen tablet the customer is using

(this comes from the tablet's manufacturer). The Pen SDK is included in the

Windows 3.1 SDK, and pen driver samples are in the DDK.

6. Does the Development Platform contain the MAPI SDK?

 Yes, the Development Platform contains the Simple MAPI SDK and CMC

SDK, which are the kits most developers need to mail-enable their

applications. However, we don't have a full MAPI SDK, which would allow

developing a MAPI-compatible mail provider. This SDK is not ready

for distribution as we go to production for the July Platform.

7. What is the difference between the Simple MAPI SDK and the Extended

MAPI SDK?

 The Simple MAPI is a simple, quick API for mail-enabling applications so that

they can access the messaging features of Windows for

Workgroups or Microsoft Mail 3.x. Extended MAPI is a more complex,

object-oriented API for building messaging-reliant applications like mail

clients, groupware applications, etc. The Extended MAPI is currently in beta

and under a non-disclosure agreement.

8. Is the OLE 2.0 SDK 16 or 32 bit?

 It's 16bit. 32bit OLE is included in the Daytona SDK.

9. Is the MAC Mail 3.1 MPW C SDK going to be included on the Development

Platform?

 We are looking at this, but there are no current plans to include this

information at this time.

10. Why isn't the LM PDK on the Development Platform?

 To include this content would require extensive work (specifically, for all the

documentation). We do not have enough demand for this content

to justify the effort. We will continue to sell the LM SDK separately as long as

we have customer demand and as long as MS continues to sell

LAN Manager.

11. Will the Office Development Kit (ODK) show up on the Development

Platform?

  No, on the Development Library. Some of the ODK will be on the April

Library and the entire kit will appear on the July Library.

12. Will Win G information show up on the Development Platform?

 Yes. We are planning on including the final version of WinG on the October

Platform.

13. Which SDKs, DDKs and OSs will ship with the Development Platform

CDs? ODK? ADT? Chicago?

 The Development Platform delivers all API-level SDKs and DDKs, plus

operations systems - both international and domestic versions. The ODK

is a special case and will show up in its entirety on the July Library. The ADT

will not be included on the Development Platform. Chicago will

show up on the Platform when the NDA is lifted. Of course, we're working

with the Chicago group to make this happen ASAP.

14. Why isn't the second beta of Daytona on the July Platform?

 The first beta was shipped as a premium release to give you a taste of

Daytona. The second beta did not contain any major updates and had

extremely limited changes relevant to developers. We will pick up the final

when it is available.

15. Why isn't Chicago on the July Platform?

 Chicago is still under a non-disclosure agreement and we cannnot pick it up

until the NDA is lifted. MSDN isn't designed to be a beta

distribution program, but we do try to grab sneak previews when possible.

**********

Development Library Support Questions

**********

1. My search ranges keep disappearing. Why?

2. Where can I find the sample code listed in the Knowledge Base articles

found on the Development Library?

3. Where is VxD Lite?

4. Why do I get a General Protection Fault after double clicking on the

Development Library icon?

5. My CD-ROM reports "Unable to read drive d:". What's wrong?

6. When I search I get a "An error has occurred: [1 | 5]". What's wrong?

7. Copy has a 32k-limit. How can I copy larger articles?

8. WHAT6 .HLP files are missing!

9. Can I copy the Development Library contents to a large hard drive and run

from there?

10. Words like if, then, etc are hyperlinked when they're used as normal

words in sentences. Why?

11. When I print a topic with a graphics, if the graphic won't fit on a page, it

gets printed twice.  Why?

12. When printing a topic with a button to a Postscript printer I get a DIV

error. Why?

13. I get a GPF in GDI.EXE at 0014:13FE when I print. Why?

14. I see a bunch of Dr. GUI graphics. What's wrong with my system?

15. I get a "String Parameter is missing an ending quotation mark." message.

Why?

16. How do I get the Development Library to print correctly?  The graphics

usually print as a black box instead of the graphic, or I get an error

during printing.

17. What have you added since the last Library?

18. I get a GPI or other error messages during Development Library set-up.

What can I do?

19. I am on a network and can't install the Development Library. Why is

setup failing?

20. I have a second hard drive and want to install the Development Library to

this drive. Windows is on my C: drive and I have less than 2MB of

free space.  Setup for the Library won't allow me to specify a different drive

and setup fails because it doesn't have enough hard disk space.  How

can I install the Library to a different drive?

1. My search ranges keep disappearing. Why?

 There is a bug in the software that eats predefined search ranges.  Ranges

are stored in a file called VIEWER.INI which is located in your

Windows directory.  If you have lost your ranges, you can run Setup to have

the default ranges restored.  Create any ranges of your own that

you use often.  Make a backup of  VIEWER.INI.  If your ranges should

disappear again, simply restore the backed-up version of VIEWER.INI, or

at least the search range section which looks like [MSDNCDx. Ranges]

(where x is the number of the CD).

2. Where can I find the sample code listed in the Knowledge Base articles

found on the Development Library?

 The files referred to in the Knowledge Base are part of the Microsoft

Software Library which can be found on the Internet at ftp.microsoft.com in

the /softlib/mslfiles directory, on CompuServe (!GO MSL), and on the MSDL

(206-936-MSDL).  Numbered files (i.e. 3-30.ZIP) have been renamed

to be more descriptive.  Download INDEX.ZIP for all filenames and abstracts.

3. Where is VxD Lite?

 VxD Lite was removed from the Development Library due to licensing issues.

MSDN Level 2 members can use the DDK instead (which is a

superset of the VxD Lite).

4. Why do I get a General Protection Fault after double clicking on the

Development Library icon?

 This problem can occur if the Library is trying to refer to a non-existent topic.

 Edit VIEWER.INI in the Windows directory using a text editor

such as Windows Notepad.  In the [MSDNCDx.Last] section (where x=MSDN

CD number), and set Source=0.  Save the file and try the Library

icon again.

5. My CD-ROM reports "Unable to read drive d:". What's wrong?

 The most common reason for this is debris and dust on the disc.  Use a soft

cloth or facial tissue and some water (use a mild detergent if

necessary). Wipe the disc from the center to the edge.  NEVER use solvents

of any kind as they may have an adverse effect on the

polycarbonate material that the CD is made of.

 The second most common reason is that the CD-ROM drive is in need of

cleaning or repair.  Any dust on the drive's lens will cause read

problems.  Although most CD-ROM drives have doors that minimize exposure

to dust, there is no firewall.  Try using aerosol air to clean the lens,

or take the drive in for a cleaning.

 Some older CD-ROM drives are unable to read more than 540 MB on a CD.

Trying to read past is sometimes actually prevented by a physical

bar in the drive.  Check with your drive manufacturer that your drive can read

at least 640 megabytes.  Most drive manufactures will send you the

firmware upgrade if available at no charge.

 Although a CD has yet to be found to be the culprit, the CD manufacturing

process is not error-free.  If you suspect a bad CD, call the Microsoft

Developer Network order center at (800) 759-5474 and a replacement disc

will be sent out.

6. When I search I get a "An error has occurred: [1 | 5]". What's wrong?

 The  Library search engine uses the space pointed to by MSDOS's TEMP

variable (usually set in AUTOEXEC.BAT).  Be sure that TEMP is not

assigned to a RAM drive.  Some searches require as much as 4 megs,

sometimes more!  Be sure you have enough space on your hard drive.  If

TEMP is assigned to a network drive, the Windows directory will be used by

default.

 There is a bug in the search engine that doesn't release the system

resources it uses.  This only happens when you use a custom "Restricted"

range.  After 5 or so searches, all of your system resources will be used up_a

fact which can be verified by using the Help.About box in Program

Manger which show the percentage of  system resources used.  Closing the

Viewer software will free up the resources again.

7. Copy has a 32k-limit. How can I copy larger articles?

 Use CTRL-INSERT instead of Edit.Copy.

 Alternatively you can install the Generic/Text Only printer driver in Control

Panel and Connect it to FILE:.  When you print to this printer, you

will be asked for a file name.

8. WHAT6 .HLP files are missing!

 The help files were inadvertently left off the April Library.  They can be

found on CompuServe in the MSDN forum's Library 1 as WHATHL.ZIP

and on ftp.microsoft.com in the /developers/msdn/ area has WHATHLP.ZIP.

9. Can I copy the Development Library contents to a large hard drive and run

from there?

 Yes. See the CD insert for licensing information. Please note that licensing is

required for additional users.

10. Words like if, then, etc are hyperlinked when they're used as normal

words in sentences. Why?

 The hyperlinking process is automated.  These 'false jumps' are an

unavoidable byproduct of the automated process.

11. When I print a topic with a graphic that won't fit on a page, it gets

printed twice.  Why?

 This is a known bug. There are no known workarounds. This problem has

been addressed in the July Library.

12. When printing a topic with a button to a Postscript printer I get a DIV

error. Why?

 This is a known problem.  Install the Olivetti HG 308 PS Postscript printer

driver and try printing to your printer with that.

13. I get a GPF in GDI.EXE at 0014:13FE when I print. Why?

 This GPF occurs when you try to print a topic with a graphic to some

printers.  If you are printing to a Hewlett-Packard printer, try using the

HP4/4M printer driver instead of your usual driver. This problem has been

addressed in the July Library.

14. I see a bunch of Dr. GUI graphics. What's wrong with my system?

 There is nothing wrong with your system.  The "Dr. GUI" bitmap is an anchor

for graphics that weren't prepped in time, or are not available in a

format that can be converted to a viewable format for the Library.

 If there are important graphics missing, please send email to

INTERNET:msdn@microsoft.com and we'll see if they can be acquired.

15. I get a "String Parameter is missing an ending quotation mark." message.

 This bug is caused by attempts to open multiple instances of the Library

software which is not possible.

16. How do I get the Development Library to print correctly?  The graphics

usually print as a black box instead of the graphic, or I get an error

during printing.

 Try copying the topic and pasting to word processing application such as

Word for Windows or Windows Write.  The Library software uses

screen fonts and will not print correctly and can cause other errors with some

printers and printer drivers.  Pasting into a word processor will

usually convert these fonts to printer or Windows Truetype fonts and print

correctly. This problem has been addressed in the July Library.

17. What have you added since the last Development Library edition

shipped?

 With each new issue of the Library, there is a What's New section. Also look

for the red dots next to content items as they signify that the item

is new since the last Library. Note: This issue has been addressed in the July

Library; check out the Content menu and select "New Content".

18. I get a GPI or other error message during the Development Library set-up.

 What can I do?

 One suggestion is to manually install the Library. There is a text file on the

Library with instructions on how to install the browser software

manually.  Look for the file MANSETUP.TXT.  Print this file out and follow the

instructions to manually install the Development Library.

19. I am on a network and can't install the Development Library. Why is

setup failing?

 The Library uses Viewer 2.0 and will try to copy several files to the Windows

\SYSTEM sub-directory.  If you are running shared Windows from

a network, setup may fail because it is unable to copy these files to the

network drive. You must have write privileges to the drive where

Windows is installed and running.

20. I have a second hard drive and want to install the Development Library to

this drive. Windows is on my C: drive and I have less than 2MB of

free space.  Setup for the Library won't allow me to specify a different drive

and setup fails because it doesn't have enough hard disk space.  How

can I install the Library to a different drive?

 The Library uses Viewer 2.0 and will try to copy several files to the Windows

\SYSTEM sub-directory.  If you are running Windows from a disk

drive that is almost full, setup may fail because it is unable to copy these files

to the because there is not enough space on the drive.

**********

Development Platform (part of Level 2 membership) Support Questions

**********

1. Development Platform .DOCs and .WRIs are unreadable. Is my disc

corrupt?

2. The liner notes say that Service Pack (SP) 3 is on the Development

Platform but I can only find SP 2. Why?

3. Which Daytona forum should MSDN Level 2 members use to get support?

4. The WHAT6 tools on the Development Platform point me to a net location.

What's up?

5. I'm having problems installing Video for Windows from the April

Development Platform. Why?

6. Where - on the Platform - are the .ERR files the Help compiler needs?

7. Some of the Win32 SDK stuff (disc five) is missing. How come?

8. What utility is needed to view the files in the doc directory of Development

Platform disc 8.

1. Development Platform .DOCs and .WRIs are unreadable. Is my disc

corrupt?

 The Development Platform contains all of the operating systems and SDKs,

including international ones.   Some versions (i.e. Japanese) use

DBCS (double-byte character sets).  Files created for these systems can only

be read on DBCS-enables systems (i.e. Win31-J).  To find the

equivalent files in English, look on the next disc in the same directory.

2. The liner notes say that Service Pack (SP) 3 is on the Development

Platform but I can only find SP 2. Why?

 The liner notes were incorrect. Service Pack 2 is the latest. It includes

CSD003, also the latest.

3. Which Daytona forum should MSDN Level 2 members use to get support?

GO DAYTONADEV is the developer forum for NT 3.5 prerelease users.

4. The WHAT6 tools on the Development Platform point me to a net location.

What's up?

 The tools had a bad setup that failed to copy some fles and installed icons

in the Program Manager that referenced locations on the Microsoft

corporate network. Not too useful. The correct tools are on the July

Development Library so we've removed these tools from the July Platform.

5. I'm having problems installing Video for Windows from the April

Development Platform. Why?

 The problem was not that the SDK did not install; it was that there was no

entry to install the Video for Windows run time in our installer utility.

This has been fixed for the July Platform.

6. Where are the .ERR files the Help compiler needs?

 They were tough to find on the April Platform but are available in the same

directory that contains the Help compiler in the July Platform.

 7. Some of the Win32 SDK stuff (disc five) is missing. How come?

 We omitted some things on the Win32 SDK and Windows NT DDK disc (Disc

5) in April. For example, we left off the CD audio tracks that are

part of the hardware compatibility tests. We will be fixing this for the July

release of the Platform.

8. What utility is needed to view the files in the doc directory of Development

Platform disc 8.

 Japanese Windows ( 3.1 or NT ).

**********

General Microsoft Questions

**********

1. How do I get more information about DevCast?

2. How do I participate in Microsoft product betas like Chicago?

3. How do I find out general non-technical information about Microsoft

development products?

1. How do I get more information about DevCast?

  Send mail to >INTERNET:devcomm@microsoft.com.

2. How do I participate in Microsoft product betas like Chicago?

 Send a brief programming profile, company name, address and phone number

plus the product you wish to test to:

Email:	 >INTERNET:msdn@microsoft.com

Mail:	Beta Coordinator - X product

Microsoft

One Microsoft Way

Redmond, WA 98052

FOR CHICAGO: email >INTERNET:winbeta@microsoft.com

3. How do I find out general non-technical information about Microsoft

development products?

 Call the Microsoft Developer Solutions Team at (800) 426-9400.

We trust that readers are intelligent enough to realize that all text herein

consists of personal comments and does not represent the official policies or

positions of any party.


MsgBlaster & forms

LUOKKA: forms

Date: 12/10/94 (08:44)              Number: 149590 of 149927 (Refer# NONE)

Subj: Re: Keeping a form from moving

From: "Tom W. Childers" <N5GE@AOL.COM>

Here is how we have done it.  This is tested and verified.

First you will need to get a copy of msgblast.vbx.  you should be able to get

it from one of the MS forums on compuserve.  I got mine from MS University,

but it should be out there on one of the IS's.

After you get a copy of it put it on the form you want to keep in one place

and put this code in the form's load event.

Const WM_NCLBUTTONDOWN = &H00A1

Const EATMESSAGE = 0

MsgBlaster1.hWndTarget = YourForm.hWnd

MsgBlaster1.MsgList(0) = WM_NCLBUTTONDOWN

msgBlaster1.MsgPassage(0) = EATMESSAGE

What this does is trap the nonclient area button down message and eat it

(keeps it from being processed).

The Msgblast.vbx is a good tool that can be used for any kind of message

handling in VON BECKER.


MsgBlaster 32-bit

LUOKKA: VBgen

Date: 07-27-95 (21:17)              Number: 397917 of 398304 (Refer# NONE)

Subj: MSGBLASTER 32 bits OCX

From: Kenneth Lassesen <kenl@microsoft.com>

Talked to Ed Staffin this morning and he is willing to send people his

beta.  Just drop him an email at  v-edstaf@Microsoft.Com.

 (The v- means he is a vendor selling his services to microsoft).

                Ken


MsgBlaster documentat

LUOKKA: VBgen

Date: 12/25/94 (13:59)              Number: 30831 of 30906 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Documentation for MessageBlaster?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> I have the public domain MessageBlaster VBX but can only find

> bits and pieces of documentation for it (mostly what messages

> I can trap).

I wrote a context-sensitive helpfile for it once. It's available on cica

under the name BLASTER.ZIP.

Regards,

Arjen

--

Arjen Broeze                                   Telephone: (+31)53-338666

arjen@shear.iaf.nl                             Address:   Gronausevoetpad 104

                                                          7511 BN Enschede, NL


MsgBlaster using

LUOKKA: VBgen

===========

Date:         Wed, 7 Sep 1994 16:50:00 CDT

From:         Ed Staffin <edstaff@MCS.COM>

Subject:      Hi

>Text item:      How Can I Trap Ctrl/Alt-Esc Combo's

>

>  Using Message Blaster, Spyworks, or VB Messenger,you can capture the

>Windows Message and disable these tasks by basically eating the message

>(i.e. not passing it on to Windows). (See code snipet below)

>

>  Sub (your favorite subclassing VBX message event here)

>      Const WM_SYSCOMMAND = &H112

>      Const SC_NEXTWINDOW = &HF040  ' ALT-TAB

>      Const SC_PREVWINDOW = &HF050  ' SHIFT ALT-TAB

>      Const SC_TASKLIST = &HF130  ' CTRL-ESC

>

>      If Msg = WM_SYSCOMMAND Then

>          Select Case wParam

>              Case SC_NEXTWINDOW, SC_PREVWINDOW, SC_TASKLIST:

>                  ' don't pass the value back to Windows

>                RetVal = 0

>                  CallDefProc = False

>          End Select

>      End If

>  End Sub

>

>Along these sames lines, you can capture window resize, restore, move,

etc.

>

>Steve Husak

>shusak@lante.com

>Lante Corp.


MsgBox

LUOKKA: MsgBox

Date: 06/22/94 (09:56)              Number: 9811 of 9875 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Suggestions for Help facility within MsgBox like dialog

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I needed the same thing once, so I created a VB form that duplicates the

standard messagebox like you did. I simply captured the standard

message-box bitmaps and use them in the VB-form.

The whole thing consists of two parts:

    MESSAGE.FRM    ' messagebox form

    MESSAGE.BAS    ' contains constants and a MessageBox function

You use it by calling the MessageBox function in the MESSAGE.BAS file.

This routine takes care of loading the form and positioning the controls

on it. It simply returns on of the ID... constants in the CONSTANT.TXT

file. The only disadvantage is that you don't have the variable argument list

anymore, but you can add as much functionality to it as you like.

--

Arjen Broeze                                   Telephone: (+33)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13


MsgBox custom

LUOKKA: VBgen

27782 (114+)  Rami.Rasanen@f73.n369.z1.fidonet.org  27.07.95  09:11

Rami Rasanen: "Re: msgbox captions"

Check out the following example.  It's a little custom message box

function and sub, using five panels  on which the buttons are located.  By

ZOrdering the correct panel, and 4 lines to load an icon, this can be quite

effectively used.

Note: This version of the msgbox form uses 3D panels (Threed.vbx), so you

have to have the Pro version to load this.  For standard owners, do the

following first before loading:

-With notepad, change all the references to

  ' Begin SSPanel MsgPnl '

to

  ' Begin PictureBox MsgPnl '

before loading. Then, When loading the mak file, an error message will

still appear - just to tell you that some of the listed properties of the

panel (like rounded corners) are not valid.

Finally, the only other step is to view the msgbox form in VB, and set the

PictureBoxes borderstyles to none. Do NOT change the word MsgPnl when

changing the text - MsgPnl is a control array.

   -MSGBOX.MAK-----

MSGCALL.FRM

D:™WIN™SYSTEM™THREED.VBX

MSGBOX.BAS

MSGBOX.FRM

ProjWinSize=511,2,285,201

ProjWinShow=2

IconForm="msgDemo"

   -MSGBOX.BAS-----

Option Explicit

'------ Windows standard Icons & API Declares ------

'<<NEXT 2 LINES ON 1 LINE>>

Declare Function LoadIcon Lib "User" (ByVal hInstance As Integer, ByVal

lpIconName As Any) As Integer

'<<NEXT 2 LINES ON 1 LINE>>

Declare Function DrawIcon Lib "User" (ByVal hDC As Integer, ByVal X As

Integer, ByVal Y As Integer, ByVal hIcon As Integer) As Integer

Global Const IDI_HAND = 32513&

Global Const IDI_QUESTION = 32514&

Global Const IDI_EXCLAMATION = 32515&

Global Const IDI_ASTERISK = 32516&

'----- for message dialog ----

Global MsgAction%  'the global variable for message box click

'------ custom message box button panels ------

Global Const msgpnl_OK% = 0                 ' OK button only

Global Const msgpnl_OKCANCEL% = 1           ' OK and Cancel buttons

Global Const msgpnl_YESNO% = 2              ' Yes and No buttons

Global Const msgpnl_YESNOCANCEL% = 3        ' Yes, No, and Cancel

buttons

Global Const msgpnl_SAVEDONTCANCEL = 4      ' Save, Don't Save and

Cancel

buttons

'------ custom message box return values  ------

Global Const cmd_IDOK% = 1                ' OK pressed

Global Const cmd_IDCANCEL% = 2            ' Cancel pressed

Global Const cmd_IDYES% = 3               ' Yes pressed

Global Const cmd_IDNO% = 4                ' No pressed

Global Const cmd_IDSAVE% = 5                ' Save pressed

Global Const cmd_IDDONTSAVE% = 6            ' Don't Save pressed

Sub CentreDialog (dlg As Form, vOffset%, hOffset%)

  'make sure we're not minimized when called

   dlg.WindowState = 0

  'move to the centre, and move it by the hOffset% & vOffset% amounts

'<<NEXT 2 LINES ON 1 LINE>>

   dlg.Move ((screen.Width - dlg.Width) ™ 2) - hOffset%, ((screen.Height -

dlg.Height) ™ 2) - vOffset%

End Sub

Function GetUserResponse% (Message$, title$, iconNo&, buttonSet%)

'set the global MsgAction% to false before proceeding.

  MsgAction% = False

'load the dialog by setting it's properties before displaying.

'set the title, the message, and the appropriate button panel.

  dlgMsg.Caption = title$

  dlgMsg.MsgText = Message$

  dlgMsg.MsgPnl(buttonSet%).ZOrder 0

'if a valid icon value is specified, load & display it too.

  If iconNo& >= IDI_HAND And iconNo& <= IDI_ASTERISK Then

    Dim hIcon%, success%

   'clear the picturebox & set AutoRedraw to true.

    dlgMsg!Picture1 = LoadPicture("")

    dlgMsg!Picture1.AutoRedraw = True

   'load the icon & draw it to the picturebox.

    hIcon% = LoadIcon(0&, iconNo&)

    success% = DrawIcon%(dlgMsg!Picture1.hDC, 0, 0, hIcon%)

  End If

'everything's ready, so show the messagebox.

'As this is a function, show modally and wait

'for the users response (set in the global

'variable MsgAction%), and assign this to the

'return of the function.

  dlgMsg.Show 1

  GetUserResponse% = MsgAction%

End Function

Sub PostUserMessage (Message$, title$, iconNo&, buttonSet%)

'basically the same as GetUserResponse%(), but doesn't

'return a value, so ther's no need for the MsgAction% here.

'load the dialog; set the title, message and appropriate button panel.

  dlgMsg.Caption = title$

  dlgMsg.MsgText = Message$

  dlgMsg.MsgPnl(buttonSet%).ZOrder 0

'load & display a valid icon

  If iconNo& >= IDI_HAND And iconNo& <= IDI_ASTERISK Then

      Dim hIcon%, success%

     'clear the picturebox & set AutoRedraw to true.

      dlgMsg!Picture1 = LoadPicture("")

      dlgMsg!Picture1.AutoRedraw = True

     'load the icon & draw it to the picturebox.

      hIcon% = LoadIcon(0&, iconNo&)

      success% = DrawIcon%(dlgMsg!Picture1.hDC, 0, 0, hIcon%)

  End If

'show the messagebox modally then exit.

  dlgMsg.Show 1

End Sub

   -MSGBOX.FRM-----

VERSION 2.00

Begin Form dlgMsg

   BackColor       =   &H00FFFFFF&

   BorderStyle     =   1  'Fixed Single

   Caption         =   "My MessageBox"

   ClientHeight    =   1980

   ClientLeft      =   2985

   ClientTop       =   2970

   ClientWidth     =   5460

   ClipControls    =   0   'False

   Height          =   2385

   KeyPreview      =   -1  'True

   Left            =   2925

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   1980

   ScaleWidth      =   5460

   Top             =   2625

   Width           =   5580

   Begin PictureBox Picture1

      AutoRedraw      =   -1  'True

      AutoSize        =   -1  'True

      BorderStyle     =   0  'None

      Height          =   480

      Left            =   420

      ScaleHeight     =   480

      ScaleWidth      =   480

      TabIndex        =   17

      Top             =   450

      Width           =   480

   End

   Begin SSPanel MsgPnl

      Alignment       =   1  'Left Justify - MIDDLE

      AutoSize        =   3  'AutoSize Child To Panel

      BackColor       =   &H00FFFFFF&

      BevelOuter      =   0  'None

      BevelWidth      =   2

      BorderWidth     =   0

      FloodShowPct    =   0   'False

      Font3D          =   0  'None

      ForeColor       =   &H00000000&

      Height          =   435

      Index           =   4

      Left            =   270

      RoundedCorners  =   0   'False

      TabIndex        =   13

      Top             =   1410

      Width           =   4815

      Begin SSCommand cmdMsg

         Caption         =   "Save"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   10

         Left            =   540

         RoundedCorners  =   0   'False

         TabIndex        =   16

         Top             =   60

         Width           =   1215

      End

      Begin SSCommand cmdMsg

         Caption         =   "Don't Save"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   9

         Left            =   1860

         RoundedCorners  =   0   'False

         TabIndex        =   15

         Top             =   60

         Width           =   1215

      End

      Begin SSCommand cmdMsg

         Caption         =   "Cancel"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   8

         Left            =   3150

         RoundedCorners  =   0   'False

         TabIndex        =   14

         Top             =   60

         Width           =   1215

      End

   End

   Begin SSPanel MsgPnl

      Alignment       =   1  'Left Justify - MIDDLE

      AutoSize        =   3  'AutoSize Child To Panel

      BackColor       =   &H00FFFFFF&

      BevelOuter      =   0  'None

      BevelWidth      =   2

      BorderWidth     =   0

      FloodShowPct    =   0   'False

      Font3D          =   0  'None

      FontBold        =   0   'False

      FontItalic      =   0   'False

      FontName        =   "MS Sans Serif"

      FontSize        =   8.25

      FontStrikethru  =   0   'False

      FontUnderline   =   0   'False

      ForeColor       =   &H00000000&

      Height          =   435

      Index           =   0

      Left            =   270

      RoundedCorners  =   0   'False

      TabIndex        =   11

      Top             =   1410

      Width           =   4815

      Begin SSCommand cmdMsg

         Caption         =   "OK"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   0

         Left            =   1950

         RoundedCorners  =   0   'False

         TabIndex        =   0

         Top             =   60

         Width           =   915

      End

   End

   Begin SSPanel MsgPnl

      Alignment       =   1  'Left Justify - MIDDLE

      AutoSize        =   3  'AutoSize Child To Panel

      BackColor       =   &H00FFFFFF&

      BevelOuter      =   0  'None

      BevelWidth      =   2

      BorderWidth     =   0

      FloodShowPct    =   0   'False

      Font3D          =   0  'None

      ForeColor       =   &H00000000&

      Height          =   435

      Index           =   1

      Left            =   240

      RoundedCorners  =   0   'False

      TabIndex        =   9

      Top             =   1410

      Width           =   4815

      Begin SSCommand cmdMsg

         Caption         =   "OK"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   2

         Left            =   1440

         RoundedCorners  =   0   'False

         TabIndex        =   3

         Top             =   60

         Width           =   915

      End

      Begin SSCommand cmdMsg

         Caption         =   "Cancel"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   1

         Left            =   2520

         RoundedCorners  =   0   'False

         TabIndex        =   4

         Top             =   60

         Width           =   915

      End

   End

   Begin SSPanel MsgPnl

      Alignment       =   1  'Left Justify - MIDDLE

      AutoSize        =   3  'AutoSize Child To Panel

      BackColor       =   &H00FFFFFF&

      BevelOuter      =   0  'None

      BevelWidth      =   2

      BorderWidth     =   0

      FloodShowPct    =   0   'False

      Font3D          =   0  'None

      ForeColor       =   &H00000000&

      Height          =   435

      Index           =   2

      Left            =   270

      RoundedCorners  =   0   'False

      TabIndex        =   12

      Top             =   1410

      Width           =   4815

      Begin SSCommand cmdMsg

         AutoSize        =   2  'Adjust Button Size To Picture

         Caption         =   "Yes"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   3

         Left            =   1380

         RoundedCorners  =   0   'False

         TabIndex        =   1

         Top             =   60

         Width           =   915

      End

      Begin SSCommand cmdMsg

         AutoSize        =   2  'Adjust Button Size To Picture

         Caption         =   "No"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   4

         Left            =   2520

         RoundedCorners  =   0   'False

         TabIndex        =   2

         Top             =   60

         Width           =   915

      End

   End

   Begin SSPanel MsgPnl

      Alignment       =   1  'Left Justify - MIDDLE

      AutoSize        =   3  'AutoSize Child To Panel

      BackColor       =   &H00FFFFFF&

      BevelOuter      =   0  'None

      BevelWidth      =   2

      BorderWidth     =   0

      FloodShowPct    =   0   'False

      Font3D          =   0  'None

      ForeColor       =   &H00000000&

      Height          =   435

      Index           =   3

      Left            =   270

      RoundedCorners  =   0   'False

      TabIndex        =   10

      Top             =   1410

      Width           =   4815

      Begin SSCommand cmdMsg

         Caption         =   "Cancel"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   7

         Left            =   3030

         RoundedCorners  =   0   'False

         TabIndex        =   7

         Top             =   60

         Width           =   915

      End

      Begin SSCommand cmdMsg

         Caption         =   "No"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   6

         Left            =   1950

         RoundedCorners  =   0   'False

         TabIndex        =   6

         Top             =   60

         Width           =   915

      End

      Begin SSCommand cmdMsg

         Caption         =   "Yes"

         Font3D          =   0  'None

         FontBold        =   0   'False

         FontItalic      =   0   'False

         FontName        =   "MS Sans Serif"

         FontSize        =   8.25

         FontStrikethru  =   0   'False

         FontUnderline   =   0   'False

         ForeColor       =   &H00000000&

         Height          =   345

         Index           =   5

         Left            =   840

         RoundedCorners  =   0   'False

         TabIndex        =   5

         Top             =   60

         Width           =   915

      End

   End

   Begin Label MsgText

      Alignment       =   2  'Center

      BackStyle       =   0  'Transparent

      Caption         =   "Your Message Goes Here"

      Height          =   855

      Left            =   1230

      TabIndex        =   8

      Top             =   450

      Width           =   3075

   End

End

Option Explicit

Dim ActionOnEscape%      'action on escape press

'ESC_CANCEL% points to the cmdMsg() button that

'would return a 'Cancel' if pressed.  This is used

'so that if the user hits escape, the Keypress

'event for the form fires the cmdMsg_click,

'passing ESC_CANCEL%, effectively cancelling the dialog.

'A more elaborate routine would set this according

'to the default action to be taken on an escape

'press.  For example, if the button choices were

'only YES and NO, the default action should be

'set to no.

Const ESC_CANCEL% = 1

Sub cmdMsg_Click (Index As Integer)

'here, you simply assign the appropriate return

'value to each button

  Select Case Index%

    Case 0: MsgAction% = cmd_IDOK%

    Case 1: MsgAction% = cmd_IDCANCEL%

    Case 2: MsgAction% = cmd_IDOK%

    Case 3: MsgAction% = cmd_IDYES%

    Case 4: MsgAction% = cmd_IDNO%

    Case 5: MsgAction% = cmd_IDYES%

    Case 6: MsgAction% = cmd_IDNO%

    Case 7: MsgAction% = cmd_IDCANCEL%

    Case 8: MsgAction% = cmd_IDCANCEL%

    Case 9: MsgAction% = cmd_IDDONTSAVE%

    Case 10: MsgAction% = cmd_IDSAVE%

  End Select

  Me.Hide

End Sub

Sub Form_Activate ()

  MsgAction% = False

  ActionOnEscape% = ESC_CANCEL%

End Sub

Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)

  Select Case KeyCode

    Case 27: cmdMsg_Click ActionOnEscape%

  End Select

End Sub

Sub Form_Load ()

  CentreDialog Me, (Me.Height) / 2, 0

End Sub

   -MSGDEMO.FRM-----

VERSION 2.00

Begin Form msgDemo

   AutoRedraw      =   -1  'True

   BackColor       =   &H00FFFFFF&

   Caption         =   "Template"

   ClientHeight    =   4650

   ClientLeft      =   2460

   ClientTop       =   1425

   ClientWidth     =   6150

   Height          =   5055

   Left            =   2400

   LinkTopic       =   "Form1"

   ScaleHeight     =   4650

   ScaleWidth      =   6150

   Top             =   1080

   Width           =   6270

   Begin CommandButton getMsgs

      Caption         =   "Notice Message"

      Height          =   375

      Index           =   5

      Left            =   510

      TabIndex        =   10

      Top             =   3780

      Width           =   2115

   End

   Begin CommandButton getMsgs

      Caption         =   "Notice Message"

      Height          =   375

      Index           =   4

      Left            =   480

      TabIndex        =   8

      Top             =   2580

      Width           =   2115

   End

   Begin CommandButton getMsgs

      Caption         =   "Dinner Message"

      Height          =   375

      Index           =   3

      Left            =   480

      TabIndex        =   7

      Top             =   2070

      Width           =   2115

   End

   Begin CommandButton getMsgs

      Caption         =   "Revert Message"

      Height          =   375

      Index           =   2

      Left            =   480

      TabIndex        =   4

      Top             =   1590

      Width           =   2115

   End

   Begin CommandButton getMsgs

      Caption         =   "Save Message"

      Height          =   375

      Index           =   1

      Left            =   480

      TabIndex        =   3

      Top             =   1140

      Width           =   2115

   End

   Begin CommandButton getMsgs

      Caption         =   "Quit Message"

      Height          =   375

      Index           =   0

      Left            =   480

      TabIndex        =   1

      Top             =   690

      Width           =   2115

   End

   Begin CommandButton Command1

      Caption         =   "End"

      Height          =   495

      Left            =   3330

      TabIndex        =   0

      Top             =   210

      Width           =   1185

   End

   Begin Label Label1

      Caption         =   "User message box called as a sub:"

      Height          =   495

      Index           =   1

      Left            =   360

      TabIndex        =   9

      Top             =   3330

      Width           =   1935

   End

   Begin Label UserCommand

      Caption         =   "<UserCommand>"

      Height          =   765

      Left            =   3000

      TabIndex        =   6

      Top             =   1320

      Width           =   2955

      WordWrap        =   -1  'True

   End

   Begin Label Label2

      Caption         =   "Return value:"

      Height          =   195

      Left            =   2970

      TabIndex        =   5

      Top             =   1080

      Width           =   1275

   End

   Begin Label Label1

      Caption         =   "User message boxes called as a function:"

      Height          =   495

      Index           =   0

      Left            =   300

      TabIndex        =   2

      Top             =   180

      Width           =   1935

   End

End

Option Explicit

Sub Command1_Click ()

   End

End Sub

Sub Form_Load ()

   CentreDialog Me, (Me.Height) / 2, (Me.Width) / 2

End Sub

Sub getMsgs_Click (Index As Integer)

'this sub just demos a few message variations

Dim user%, Message$, title$, iconNo&, buttonSet%

  Select Case Index%

    Case 0:

      Message$ = "You are about to end this session."

      title$ = "Quit MyApp"

      iconNo& = IDI_ASTERISK

      buttonSet% = msgpnl_OKCANCEL%

      user% = GetUserResponse%(Message$, title$, iconNo&, buttonSet%)

'Disclaimer: the following code line is not necessarily

'good programming practice...it's just for displaying the

'appropriate string in the UserCommand label

UserCommand=IIf(user%-cmd_IDCANCEL%,"User said OK","User said

Cancel")

    Case 1:

      Message$ = "Save changes to to the worksheet before continuing?"

      title$ = "Quit MyApp"

      iconNo& = IDI_QUESTION

      buttonSet% = msgpnl_SAVEDONTCANCEL%

      user% = GetUserResponse%(Message$, title$, iconNo&, buttonSet%)

      If user% = cmd_IDSAVE% Then UserCommand = "User said SAVE"

      If user% = cmd_IDDONTSAVE% Then UserCommand = "User said DON'T

SAVE"

      If user% = cmd_IDCANCEL% Then UserCommand = "User said Cancel"

    Case 2:

      Message$ = "Revert to the last-saved worksheet?"

      title$ = "File Save"

      iconNo& = IDI_EXCLAMATION

      buttonSet% = msgpnl_YESNOCANCEL%

      user% = GetUserResponse%(Message$, title$, iconNo&, buttonSet%)

      If user% = cmd_IDYES% Then UserCommand = "User said YES"

      If user% = cmd_IDNO% Then UserCommand = "User said NO"

      If user% = cmd_IDCANCEL% Then UserCommand = "User said Cancel"

    Case 3:

      Message$ = "I'm getting anchovies on the pizza. OK?"

      title$ = "Little Fishes"

      iconNo& = IDI_HAND

      buttonSet% = msgpnl_YESNO%

      user% = GetUserResponse%(Message$, title$, iconNo&, buttonSet%)

      UserCommand = IIf(user% - cmd_IDNO%, "User said YES", "User said

NO")

    Case 4:

      Message$ = "The date completed cannot be earlier than the date in."

      title$ = "Entry Error"

      iconNo& = IDI_ASTERISK

      buttonSet% = msgpnl_OK%

      user% = GetUserResponse%(Message$, title$, iconNo&, buttonSet%)

      UserCommand = IIf(user%, "User said OK", "")

    Case 5:

      Message$ = "The date completed cannot be earlier than the date in."

      title$ = "Entry Error"

      iconNo& = IDI_ASTERISK

      buttonSet% = msgpnl_OK%

      PostUserMessage Message$, title$, iconNo&, buttonSet%

      UserCommand = "Sub called- no return value"

  End Select

End Sub

   -------end of project--------------

Rami Rasanen       Eagle Eye BBS  ("`-''-/").___..--''"`-._

Fidonet 1:369/73  (305) 584-6258   `6_ 6  )   `-.  (     ).`-.__.`)

Internet: rasanen@msn.com          (_Y_.)'  ._   )  `._ `. ``-..-'

Home of DELPHI Echo              _..`--'_..-_/  /--'_.' ,'

Ft Lauderdale, FL               (il),-''  (li),'  ((!.-'

--

Fidonet:  Rami Rasanen 1:369/73

Internet: Rami.Rasanen@f73.n369.z1.fidonet.org


Name of ctrl/frm runti

LUOKKA: VBgen

=============================================================

Date:         Thu, 6 Oct 1994 10:01:00 CDT

From:         Ed Staffin <edstaff@MCS.COM>

Subject:      Getting the name control/form at run time

(mcs=microsoft)

Go to fpt.mcs.com in the mcsnet.users\edstaff directory. There you will find

a zip file called vbapi.zip. In there is a small dll and a vb project that is an

example of how to use the two functions

I wrote called GetControlName and GetFormName. It's real easy ...

Declare Function GetControlName Lib "vbapi.dll" (c As Any, s As String) As

   Integer

Declare Function GetFormName Lib "vbapi.dll" (c As Any, s As String) As

Integer

    Dim ControlName As String

    Dim FormName As String

    Dim rc%

    rc = GetControlName(YourControl, ControlName )

    rc = GetFormName(YourForm, FormName )

    ' rc will be true if all went well.


Naming & coding

LUOKKA: coding

Visual Basic Programming Conventions from Microsoft Consulting Services

1. Naming Conventions

1.1 Objectives

To help programmers (especially in multiprogrammer projects) standardize and

decode the structure and logic of an application

To be precise, complete, readable, memorable, and unambiguous

To be consistent with other language conventions (most importantly the

Visual Basic Programmer's Guide and standard Microsoft® Windows™

Hungarian C)

To be efficient from a string size and labor standpoint, thus allowing a greater

opportunity for longer/fuller object names

To define the minimum requirements necessary to do the above

Note:

On pages 32 and 33 of the Visual Basic 2 Programmer's Guide, Visual Basic

has defined control naming conventions that will likely be adopted by many

corporations and Visual Basic ISVs. As a result, it would take a very strong

argument to justify deviating from the Visual Basic 2 standard without causing

a lot of heartache and confusion. Lacking such a compelling argument, this

document therefore is a superset of the published Visual Basic conventions.

1.2 Conventions

1.2.1 Option Explicit

"Option Explicit" must always be used to force proper variable declarations

and aid good variable commenting. The time lost trying to track down bugs

caused by typos (aUserNameTmp vs. sUserNameTmp vs. sUserNameTemp)

far outweighs the time needed to Dim variables.

1.2.2 Control naming

The following table defines our standard Control name prefixes. (These are

consistent with those documented in the Visual Basic 2 Programmers Guide.)

Table 1. Standard Control Name Prefixes

Prefix	Control Type Description

ani	Animation button

bed	Pen Bedit

cbo	Combobox and dropdown Listbox

chk	Checkbox

clp	Picture Clip

cmd	Command Button

com	Communications

ctr	Control (Used within procs when the specific type is unknown)

db	ODBC Database

dir	Dir List Box

dlg	Visual Basic Pro Common Dialog

drv	Drive List Box

ds	ODBC Dynaset

fil	File List Box

frm	Form

fra	Frame

gau	Gauge

gpb	Group Push Button

grd	Grid

hed	Pen Hedit

hsb	Horizontal Scroll Bar

img	Image

ink	Pen Ink

key	Keyboard key status

lbl	Label

lin	Line

lst	Listbox

mpm	MAPI Message

mps	MAPI Session

mci	MCI

mnu	Menu

opt	Option Button

ole	Ole Client

pic	Picture

pnl	3d Panel

shp	Shape

spn	Spin Control

txt	Text/Edit Box

tmr	Timer

vsb	Vertical Scroll Bar

1.3 Control Prefix Notes

1.3.1 Menus

Because Menu handlers can be so numerous, Menu names require a little

more attention. Menu prefixes therefore continue beyond the initial Mnu label

by adding an additional (upper case) character prefix for each level of

nesting, with the final menu caption being spelled out at the end of the name

string. When there is ambiguity caused by character duplications, such as a

menu having both main Format and File menus, use an additional (lower case)

character to differentiate the items. Examples:

Menu Caption Sequence	Menu Handler Name

Help.Contents	mnuHContents

File.Open	mnuFiOpen

Format.Character	mnuFoCharacter

File.Send.Fax 	mnuFSFax

File.Send.Email	mnuFSEmail

This results in all the family members of a particular menu group being listed

right next to each other. This multi-tiered format provides a very direct way to

find a menu handler, especially when there are a great many of them.

1.3.2 Other controls

For new controls not listed above, try to come up with a unique 3-character

prefix. However, it is more important to be clear than to stick to 3 characters.

For derivative controls, such as an enhanced list box, extend the prefixes

above so that there is no confusion about what control is really being used.

For example, a control instance created from the Visual Basic Pro 1.0 3D

Frame could use a prefix of fra3d to make sure there is no confusion over

which control is really being used.

1.3.3 Variable and routine naming

Variable and function names have the following structure:

<prefix><body><qualifier><suffix>

The prefix describes the use and the scope of the variable, as in

iGetRecordNext and sGetNameFirst. The qualifier is used to denote standard

derivatives of a base variable or function, as in iGetRecordNext and

sGetNameFirst. The suffix is the optional Visual Basic type char ($, %, #, and

so on).

Prefixes

The following table defines variable/function name prefixes that are based on

Hungarian C. These must be used universally, even when Visual Basic

suffixes (such as %, &, #, and so on) are also used.

Table 2. Prefixes for Variable and Function Names

Prefix	Variable Use Description (precedes Control prefix and body)

b	Boolean (vb type = %)

c	Currency - 64 bits (vb type = @)

d	Double - 64 bit signed quantity (vb type = #)

db	Database

ds	Dynaset

dt	Date+Time (vb type = variant)

f	Float/Single - 32 bit signed floating point (vb type = !)

h	Handle (vb type = %)

i	Index (vb type = %)

l	Long - 32 bit signed quantity (vb type = &)

n	Integer (sizeless, counter) (vb type = %)

s	String (vb type = $)

u	Unsigned - 16 bit unsigned quantity (must use &)

ul	Unsigned Long - 32 bit unsigned quantity (must use #)

vnt	Variant (big and ugly to discourage use and make sure it gets the

reader's attention)

w	Word - 16 bit signed quantity (vb type = %)

a	Array

User defined type

Prefix	Scope or Use (precedes Use prefix above)

g	Global

m	Local to module or form

st	Static variable

v	Variable passed by value (local to a routine)

r	Variable passed by reference (local to a routine)

Hungarian is as valuable in Visual Basic as it is in C because the Visual

Basic type suffixes alone do not provide standard (and valuable) information

about what a variable/function is used for or where it is accessible. For

example, iSend (which might be a count of the number of messages sent),

bSend (which might be a flag/Boolean defining the success of the last

Send operation), and hSend (which might be a handle to the Comm interface)

all succinctly tell a programmer something very different. This information is

fundamentally lost when the name is reduced down to Send%. Scope prefixes

such as g and m also help reduce the problem of name contention, especially

in multideveloper projects. Hungarian is also well known to Windows

programmers and constantly referenced in Microsoft and industry

programming books. Additionally, the bond between C programmers and

Visual Basic programmers can be expected to become much stronger as

Visual C++ begins to live up to its potential. This transition will result in many

Visual Basic programmers moving to C for the first time and many

programmers moving fluidly back and forth between each environment.

Body

The body of variable and routine names should use mixed case and should

be as long as needed to describe their purpose. Function names should also

begin with a verb, such as InitNameArray or CloseDialog.For frequently used

or long terms, abbreviations (such as Init, Num, Tbl, Cnt, and Grp for

Initialization, Number, Table, Count, and Group) are suggested to

help keep name lengths reasonable. Names greater than 32 characters

generally begin to inhibit readability on VGA displays. When abbreviations are

used, they must be used consistently throughout the application. Randomly

switching between "Cnt" and "Count" within a project will greatly frustrate

developers.

Qualifiers

Often related variables and routines are used to manage and manipulate a

common object. In these cases it can be very helpful to use standard

qualifiers to label the derivative variables and routines. Although putting the

qualifier after the body of the name might seem a little awkward (as in

sGetNameFirst, sGetNameLast instead of sGetFirstName, and so on),

this practice will help order these names together in the Visual Basic editor

routine lists, making the logic and structure of the application easier to

understand.

The following table defines common qualifiers and their standard meaning.

Table 3. Common Qualifiers

Qualifier	Description (follows Body)

First	First element of a set.

Last	Last element of a set.

Next	Next element in a set.

Prev	Previous element in a set.

Cur	Current element in a set.

Min	Minimum value in a set.

Max	Maximum value in a set.

Save	Used to preserve another variable which must be reset later.

Tmp	A "scratch" variable whose scope is highly localized within the

code. The value of a

Tmp variable is usually only valid across a set of contiguous statements.

Src	Source. Frequently used in comparison and transfer routines.

Dst	Destination. Often used in conjunction with Source.

1.3.4 Constant naming

The body of constant names are described in UPPER_CASE with

underscores ("_") between words. Although standard Visual Basic constants

do not include Hungarian use information, prefixes such as i, s, g, and m can

be very useful in understanding the value and scope of a constant,

so constant names follow the same rules as variables. Examples:

mnUSER_LIST_MAX	'Max entry limit for User list (integer value, local

to module)

gsNEW_LINE	'New Line character string (global to entire application)

1.3.5 Variant data types

With the single exception listed below, variants should NOT be used. When a

type conversion is needed, variant use would probably provide a slight

performance win over the explicit basic type conversion routines (val(), str$(),

and the like), but this gain is not sufficient to overcome the ambiguity and

general sloppiness they allow in code statements. Example:

vnt1 = "10.01" : vnt2 = 11 : vnt3 = "11" : vnt4 = "x4"

vntResult = vnt1 + vnt2     ' Does vntResult = 21.01 or 10.0111?

vntResult = vnt2 + vnt1     ' Does vntResult = 21.01 or 1110.01?

vntResult = vnt1 + vnt3     ' Does vntResult = 21.01 or 10.0111?

vntResult = vnt3 + vnt1     ' Does vntResult = 21.01 or 1110.01?

vntResult = vnt2 + vnt4     ' Does vntResult = 11x4 or ERROR?

vntResult = vnt3 + vnt4     ' Does vntResult = 11x4 or ERROR?

Additionally, the type conversion routines assist in documenting

implementation details, which make reading, debugging, and maintaining

code more straightforward. Example:

(iVar1 = 5 + val(sVar2)     'use this

vntVar1 = 5 + vntVar2       'not this!

Exception

While working with databases, messages, DDE, or OLE, a generic service

routine can receive data that it does not need to know the type of in order to

process or pass on. Example:

Sub ConvertNulls(rvntOrg As Variant, rvntSub As Variant)

 'If rvntOrg = Null, replace the Null with rvntSub

   If IsNull(rvntOrg) Then rvntOrg = rvntSub

End Sub

2. Commenting

All procedures and functions must begin with a brief comment describing the

functional characteristics of the routine (what it does). This description

should not describe the implementation details (how it does it) because these

often change over time, resulting in unnecessary comment maintenance work

or, worse, erroneous comments. The code itself and any necessary inline or

local comments will describe the implementation. Parameters passed to a

routine should be described (a) if they are not obvious and (b) when specific

ranges are assumed by the routine. Function return values and global

variables that are changed by the routine (especially through reference

parameters) must also be described at the beginning of each routine.

Every nontrivial variable declaration should include an inline comment

describing the use of the variable being declared.

Variables, controls, and routines should be named clearly enough that inline

commenting is only needed for complex or nonobvious implementation details.

An overview description of the application enumerating primary data objects,

routines, algorithms, user interface dialogs, database and file system

dependencies, and so on, should be included at the start of the .BAS module

that contains the project's Visual Basic generic constant declarations.

Note     The Project window inherently describes the list of files in a project,

so this overview section only needs to provide information on the most

important files and modules or files that the Project window doesn't know

about, such as .INI or database files.

3. Code Formatting

Because many programmers still use VGA displays, screen real estate must be

conserved as much as possible while still allowing code formatting to reflect

logic structure and nesting. For this reason:

Standard (tab-based) block nesting indentations should be from two to four

spaces. More than four spaces is unnecessary and causes unnecessary

statement hiding through truncation. Fewer than two is not effective in

reflecting logic nesting.

The functional overview comment of a routine should be indented one space.

The highest level statements that follow the overview comment should be

indented one tab, with each nested block indented an additional tab.

Example:

Function iFindUser (rasUserList() as String, rsTargetUser as String) as Integer

 'Search UserList and if found, return index of first occurrence of TargetUser,

' else return -1

    Dim i as Integer                    'loop counter

    Dim bFound as Integer               'target found flag

    iFindUser = -1

    i = 0

    While i <= Ubound(rasUserList) and Not bFound

       If rasUserList(i) = rsTargetUser Then

          bFound = True

          iFindUser = i

       End If

    Wend

End Function

Variables and nongeneric constants should be grouped by function rather

than being split off into isolated areas or special files. (Visual Basic generic

constants such as "HOURGLASS" should be grouped in a generic section of

a main global file so that they do not complicate the reading of the

application-specific declarations.)

4. Operators

Always use "&" when concatenating strings and "+" when working with

numerical values. Using only "+" can cause problems when operating on two

variants. For example:

vntVar1 = "10.01"

vntVar2 = 11

vntResult = vntVar1 + vntVar2                   'vntResult = 21.01

vntResult = vntVar1 & vntVar2                   'vntResult = 10.0111

5. Scope

Always define variables with the smallest scope possible. Global variables

can create enormously complex state machines and make understanding the

logic of an application extremely difficult. They also make the reuse and

maintenance of your code much more difficult. If you have to use globals,

keep their declarations grouped by functionality and comment them well.

With the exception of globals that should not be passed, procedures and

functions should only operate on objects that are passed to them. Global

variables that are used in routines should be identified in the general

comment area at the beginning of the routine.

Likewise, try to put as much logic and as many user interface objects in

Dialog Boxes as possible. This will help segment your application's complexity

and minimize its run-time overhead.

(c) 1993 Microsoft Corporation. All rights reserved.


NetWare

LUOKKA: VBgen

Date: 02-23-95 (10:16)              Number: 233064 of 234156 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: <None>

>I would be interested in any information you have about NWCALLS.DLL

>as well. Please post it to the list as im sure other would be to.

For any who are interested, the below files are available on Compuserve,

from ftp.novell.com, ftp.novell.de and all Novell mirror sites.

NWTEST.ZIP

Source code and executable illustrating use of the NetWare Interface for

Visual Basic (NIVB).  Includes NetWare DLLs required.  Also requires

VBRUN200.DLL.  For more information, see "A NetWare Interface for Visual

Basic" in June '93 issue of NetWare Application Notes.

NIVB.ZIP

NetWare Interface for Visual Basic (NIVB).  Contains declarations for

NetWare APIs for use with Visual Basic for Windows v2.0.  Based on

NetWare C

Interface for Windows SDK.  For more information, see "A NetWare Interface

for Visual Basic" in June '93 issue of NetWare Application Notes.

A reprint of the NetWare Application Notes article is available for $15 by

calling:

        (800) 377-4136    or  (303) 297-2725.

 -dave


Network logging

LUOKKA: VBgen

     Date: 02-07-95    Time: 07:15p     Number: 163

     From: sydtech@winternet.com         Refer:

  Subject: WFWG network login?               0: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

>I've used the WNetGetUser (KB article Q113688) to get the userid someone

>is logged in as.

>

>We need to log in a user, providing the password without user

>intervention.  A call to MS says the API calls are documented in the WFWG

>Dev Kit, which we don't have (and rather not invest in).  Several docs w/

>API calls checked don't yield anything.

>Does anyone out there know the calls or have an example?

I wrote a simple VB DLL (that is, it's written specifically for VB, so you don't

have to mess aroundwith allocating string space, etc) a while back that

encapsulates the WfW logon, logoff, and workstation information API calls.

These calls work on Windows NT as well as WfW. Here's some sample code

for calling functions in VBWFW.DLL:

Logon/Logoff:

   Dim x As Integer, fresult As Integer

   fresult = 0

   If Command2.Caption = "&Logon" Then

      x = NetLogon((frmNetInfo.hWnd), 1, fresult)

      If x = 1 Then

         Command2.Caption = "&Logoff"

      Else

         MsgBox "Logon failed!"

      End If

   Else

      x = NetLogoff((frmNetInfo.hWnd))

      If x <> 1 Then

         MsgBox "Logoff failed!"

      Else

         Command2.Caption = "&Logon"

      End If

   End If

Get workstation/user info:

   Dim a$, b$, c$, d$

   'CRLF = Chr$(13) + Chr$(10)

   If NetWorkstationInfo(a$, b$, c$, d$) Then

      MsgBox "Computer Name: " & a$ & CRLF & "Username: " & b$ & CRLF ->

      -> & "Workgroup:" & c$ & CRLF  ->

      -> & "Logon domain:" & d$

   Else

      MsgBox "Unable to get information."

   End If

If there's sufficient interest, I'll put this up for anonymous FTP at my site.

Scott


Network Type

LUOKKA: VBgen

20714 (3+)  cmo9696@hertz.njit.edu  11.06.95  00:41

Chris M. Okoniewski: "Re: Determining Network Type"

In article <3ra703$lnf@dmsoproto.ida.org>, Chris Chubb <cchubb@ida.org>

wrote:

>I am writing an application that must get the userID from the network.

>I have a routine that will get if for WFWG. I have another

>routine that will get it for Novell networks.

>

>What is the best way to determine which type of network is being run?

>Right now I check for WFWNet.DRV in the system directory, but

>that method is fraught with peril. (User HAD WFWG, but uses

>a Novell back-end)

Checking file existance is dicey indeed...  There are a number of very

poorly documented (in terms of usage from VB) functions in USER.EXE

that will take care of most any network related manipulations you may

have the need to control from your programs.  They all fall in the

category WNet* (for Windows Network...), and I believe that they are

network independant.  (You might not need those two username functions

after all!)

To check a username, use WNetGetUser(strUserName, intUserNameStrLen).

In WfWg, you must call it twice to get a valid username.

Checking the type of network operating may be possible via WNetGetCaps.

I've never used this function in VB, so I can't vouch for this, but I

have some sample C code that uses the function to determine the type of

network driver in use.  Call the function with one parameter, set to 2,

to do this.  The return value should be one of the following:

---- From WINNET.H sample code (Originally from an MSPJ article, true

     author unknown...) ----

#define  WNNC_NET_NONE                          0x0000

#define  WNNC_NET_MSNet                         0x0100

#define  WNNC_NET_LanMan                        0x0200

#define  WNNC_NET_NetWare                       0x0300

#define  WNNC_NET_Vines                         0x0400

#define  WNNC_NET_10NET                         0x0500

#define  WNNC_NET_Locus                         0x0600

#define  WNNC_NET_Sun_PC_NFS                    0x0700

#define  WNNC_NET_LANstep                       0x0800

#define  WNNC_NET_9TILES                        0x0900

#define  WNNC_NET_LANtastic                     0x0A00

#define  WNNC_NET_AS400                         0x0B00

#define  WNNC_NET_FTP_NFS                       0x0C00

#define  WNNC_NET_PATHWORKS                     0x0D00

#define  WNNC_NET_LifeNet                       0x0E00

#define  WNNC_NET_POWERLan                      0x0F00

#define  WNNC_NET_MultiNet                      0x8000

#define  WNNC_SUBNET_NONE                       0x0000

#define  WNNC_SUBNET_MSNet                      0x0001

#define  WNNC_SUBNET_LanMan                     0x0002

#define  WNNC_SUBNET_WinWorkgroups              0x0004

#define  WNNC_SUBNET_NetWare                    0x0008

#define  WNNC_SUBNET_Vines                      0x0010

#define  WNNC_SUBNET_Other                      0x0080

---- End code ---

Chris Okoniewski

cmo9696@hertz.njit.edu


Networks

LUOKKA: VBgen

Date: 10/30/94 (21:33)              Number: 25192 of 25315 (Refer# NONE)

From: CRISJ@XNET.COM

Subj: Re: VB and networks

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>My VB application needs to support several networks including Netware,

>LAN Server and Vines.  I have two questions:

>1. Can VB use the Universal Naming Convention   Server volume directory

>   to access files?  If so, do you have an example?

>2. What is the best way to determine the type of network being used.  I

>   tried reading SYSTEM.INI's  boot.description  network.drv= to search

>   for NETWARE and other networks, but at a customer's site, this didn't

>   work.  Their network.drv= was WFW and a second variable was set to

>   their network type (secondnet.drv, I think).  There must be an easier

>   way to positively determine what types of networks are installed, rather

>   than guessing that network.drv and secondnet.drv are the only variables

>   that could be used.

Declare Function WNetAddConnection% Lib "user" (ByVal lpszNetPath As

Any, ByVal lpszPassword As Any, ByVal lpszLocalName As Any)

Declare Function GetDriveType% Lib "kernel" (ByVal nDrive%)

Declare Function WNetGetConnection% Lib "user" (ByVal lpszLocalName As

  String, ByVal lpszRmtName As String, iRmtLen As Integer)

Declare Function WNetCancelConnection% Lib "user" (ByVal lpszLocalName

  As String, ByVal iForce As Integer)

Declare Function WNetBrowseDialog% Lib "user" (ByVal hWParent As

Integer, ByVal

iType As Integer, ByVal lpszPath As String)

Declare Function WNetGetUser Lib "wfwnet.drv" (ByVal szUser As String,

  nBufferSize As Integer) As Integer

Declare Function MnetNetworkEnum Lib "wfwnet.drv" (lphNetwork As

Integer) As Integer

Declare Function MNetSetNextTarget Lib "wfwnet.drv" (ByVal hNetwork As

Integer) As Integer

Declare Function WNetGetCaps Lib "User" (ByVal nFlags As Integer) As

Integer

' WNet constants

Global Const WN_SUCCESS = &H0

Global Const WN_NOT_SUPPORTED = &H1

Global Const WN_NET_ERROR = &H2

Global Const WN_MORE_DATA = &H3

Global Const WN_BAD_POINTER = &H4

Global Const WN_Bad_Value = &H5

Global Const WN_Bad_Password = &H6

Global Const WN_Access_Denied = &H7

Global Const WN_Function_Busy = &H8

Global Const WN_BAD_USER = &HA

Global Const WN_OUT_OF_MEMORY = &HB

Global Const WN_Cancelled = &HC

Global Const WN_Not_Connected = &H30

Global Const WN_Open_Files = &H31

Global Const WN_Bad_NetName = &H32

Global Const WN_Bad_Localname = &H33

Global Const WN_Already_Connected = &H34

Global Const WN_Bad_JobID = &H40

Global Const WN_Job_Not_Found = &H41

Global Const WN_Job_Not_Held = &H42

Global Const WN_Bad_Queue = &H43

Global Const WN_Bad_Handle = &H44

Global Const WN_Cant_Set_Copies = &H45

Global Const WN_Already_Locked = &H46

Global Const WN_No_Error = &H50

Global Const WNBD_Conn_Disktree = 1

Global Const WNBD_Conn_PrintQ = 3

Global Const WNBD_CONN_SelAll = 0

Global Const WNNC_NET_TYPE = 2

Global Const WNNC_NET_MultiNet = &H8000

Global Const WNNC_SUBNET_WinWorkgroups = &H4

Global Const MNM_NET_PRIMARY = 0

'GetDriveType constants

Global Const Drive_Unknown = 0

Global Const Drive_Removable = 2

Global Const Drive_Fixed = 3

Global Const Drive_Remote = 4

' WNetGetCaps constants

Global Const WNNC_NET_NONE = &H0

Global Const WNNC_NET_MSNet = &H100

Global Const WNNC_NET_LanMan = &H200

Global Const WNNC_NET_NetWare = &H300

Global Const WNNC_NET_Vines = &H400

Global Const WNNC_NET_10NET = &H500

Global Const WNNC_NET_Locus = &H600

Global Const WNNC_NET_SunPCNFS = &H700

Global Const WNNC_NET_LANstep = &H800

Global Const WNNC_NET_9TILES = &H900

Global Const WNNC_NET_LANtastic = &HA00

Global Const WNNC_NET_AS400 = &HB00

Global Const WNNC_NET_FTP_NFS = &HC00

Global Const WNNC_NET_PATHWORKS = &HD00

Global Const WNNC_NET_LifeNet = &HE00

Global Const WNNC_NET_POWERLan = &HF00

Global Const WNNC_SUBNET_NONE = &H0

Global Const WNNC_SUBNET_MSNet = &H1

Global Const WNNC_SUBNET_LanMan = &H2

Global Const WNNC_SUBNET_WinWork = &H4

Global Const WNNC_SUBNET_NetWare = &H8

Global Const WNNC_SUBNET_Vines = &H10

Global Const WNNC_SUBNET_Other = &H80

Sub GetNetType ()

    Dim tTempStr As String

    Dim nFlags As Integer

    Dim nByteHi As Integer

    Dim nByteLo As Integer

    tTempStr = ""

    nFlags = WNetGetCaps(WNNC_NET_TYPE)     ' Get network type bit flags

' Check for main network types

    If (nFlags And WNNC_NET_NONE) Then tTempStr = "Network not

installed or not running"

    If (nFlags And WNNC_NET_MSNet) Then tTempStr = "MSNet"

    If (nFlags And WNNC_NET_LanMan) Then tTempStr = "LanMan"

    If (nFlags And WNNC_NET_NetWare) Then tTempStr = "NetWare"

    If (nFlags And WNNC_NET_Vines) Then tTempStr = "Vines"

    If (nFlags And WNNC_NET_10NET) Then tTempStr = "10 NET"

    If (nFlags And WNNC_NET_Locus) Then tTempStr = "Locus"

    If (nFlags And WNNC_NET_SunPCNFS) Then tTempStr = "Sun PC NFS"

    If (nFlags And WNNC_NET_LANstep) Then tTempStr = "LANstep"

    If (nFlags And WNNC_NET_9TILES) Then tTempStr = "9 TILES"

    If (nFlags And WNNC_NET_LANtastic) Then tTempStr = "LANtastic"

    If (nFlags And WNNC_NET_AS400) Then tTempStr = "AS-400"

    If (nFlags And WNNC_NET_FTP_NFS) Then tTempStr = "FTP NFS"

    If (nFlags And WNNC_NET_PATHWORKS) Then tTempStr =

"PATHWORKS"

    If (nFlags And WNNC_NET_LifeNet) Then tTempStr = "LifeNet"

    If (nFlags And WNNC_NET_POWERLan) Then tTempStr = "POWERLan"

    If (nFlags And WNNC_NET_MultiNet) Then

        tTempStr = "MultiNet "

'               Multinet is a bit mask that identifies all the sub nets so

check each one ...

        If (nFlags And WNNC_SUBNET_NONE) Then tTempStr = tTempStr &

"None" & ",

"

        If (nFlags And WNNC_SUBNET_MSNet) Then tTempStr = tTempStr &

"Subnet:

MsNet" & ", "

        If (nFlags And WNNC_SUBNET_LanMan) Then tTempStr = tTempStr &

"Subnet:

LanMan" & ", "

        If (nFlags And WNNC_SUBNET_WinWork) Then tTempStr = tTempStr &

"Subnet:

Windows for Workgroups" & ", "

        If (nFlags And WNNC_SUBNET_NetWare) Then tTempStr = tTempStr &

"Subnet:

NetWare" & ", "

        If (nFlags And WNNC_SUBNET_Vines) Then tTempStr = tTempStr &

"Subnet:

Vines" & ", "

        If (nFlags And WNNC_SUBNET_Other) Then tTempStr = tTempStr &

"Subnet:

Other" & ", "

        If Right$(tTempStr, 2) = ", " Then tTempStr = Left$(tTempStr,

Len(tTempStr) - 2)

    End If

    Form1.Panel3D2.Caption = "Network Type: " + tTempStr

End Sub


Networks find drives

LUOKKA: misc

26488 (110+)  rgritton@wa34b.atk.com  20.07.95  18:56

Randy Gritton: "Re: Help with data accessing"

In article <806237823snz@itochu.demon.co.uk>, Andy@itochu.demon.co.uk

says

>I have an application which consists of a series of diagrams and a

>database of parts. Each part is linked to a point on the diagram.

>The application will be distributed on CD-ROM complete with images

>and parts, the program engine will then install on the HDD.

>

>My problem is I want to be able to use a CD-ROM to store the images and

>parts database and this is accessed from the program.

>

>I need to be able to determine what the drive name of the CD-ROM, from

>within the program so I can call the images etc. I'm at a loss as to how

>I can make sure the program recognises the data location as different

>systems have different CD-ROM name (e.g. D:, E: etc).

I had a similar problem trying to find the logical mapping for network

drives, where a server drive path could be mapped to any drive letter on

client PCs.  I used a drive control on my main form, with the VISIBLE

setting set to False.  Then I read the list box looking for the network path

where my database resided.  (See code following.)

Sub FindNetPath ()

    PathFound = False

    NetDirPath = ""

    For iCtr = 0 To frmMain!Drive1.ListCount - 1

        If InStr(frmMain!Drive1.List(iCtr), "Ž™™SERVER™USER™PUB�") Then

            NetDirPath = Left$(frmMain!Drive1.List(iCtr), 2)

            PathFound = True

            Exit For

        End If

    Next iCtr

    If Not PathFound Then

        MsgBox "You do not have a drive mapped to 'SERVER™USER™PUB' !",

MB_ICONEXCLAMATION , "DRIVE MAP ERROR"

        End

    End If

End Sub

You could probably use a similar routine, ignoring drives a: - c: and then

having to perform checks on any other drives to see if they are CD-ROMs. My

guess is you will need MCI API calls to do this (not having a CD player on

my computer :-(  I am not sure what it takes to verify this).

There may be easier ways to do this but this works for me.

Randy Gritton

rgritton@wa34b.atk.com


Novell

LUOKKA: misc

Date: 01/29/95 (07:22)              Number: 203707 of 204206 (Refer# NONE)

From: BERTHON.RIKKEN@BUREAUGS.MEDFAC.LEIDENUNIV.NL

Subj: Login_user name from lan(NOVELL) to

This is a routine NetworkTest that reads the username and the full

name of someone who's logged in on a Novell Network. Works OK for us

on Netware 3.12

----------------------------------------------------------

'***< Declarations >***

Declare Function WNetGetUser% Lib "USER" (ByVal user$, BufSize%)

Declare Function ReadPropertyValue Lib "NWNetAPI.dll" (ByVal objName$,

ByVal

 objType%, ByVal PropName$, ByVal Segment%, ByVal propvalue$,

PropValMore%,

 PropValFlag%) As Integer

Sub NetworkTest ()

    WN_SUCCESS = 0

    WN_NET_ERROR = 2

    WN_MORE_DATA = 3

    OT_USER = 1

    On Error GoTo neterror

          'Reference your favorite error trapping algorithm

    Dim result%, GetName$, Size%

    Dim propType$, propvalue$, propMore%, propFlag%

    GetName$ = String$(255, 0)

    Size% = Len(GetName$)

    propType$ = "IDENTIFICATION"

    propvalue$ = String$(255, 0)

    propMore% = 0

    propFlag% = 0

    result% = WNetGetUser(GetName$, Size%)

    If result% = WN_SUCCESS Then

        username = Left$(GetName$, Size% - 1)

        result% = ReadPropertyValue(username, OT_USER, propType$, 1,

propvalue$,

 propMore%, propFlag%)

        propvalue$ = Left$(propvalue$, InStr(propvalue$, Chr$(0)) - 1)

        'The user's NetWare Full Name is now in propValue$

        MsgBox "You are user '" + username + "' and your name is '" +

propvalue$

 + "'"

    Else

        MsgBox "Network unavailable."

    End If

EndNetw:

    Exit Sub

neterror:

    Resume EndNetw

End Sub

Cheers,

Berthon Rikken

Bureau of the Dutch Growth Foundation

berthon.rikken@bureaugs.medfac.LeidenUniv.nl


Novell

LUOKKA: VBgen

Date: 01/17/95 (22:12)              Number: 189239 of 191526 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: NetWare  Interface For Visual Basic SDK

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Recently, I was in need of a highly functional, well documented and

supported SDK or interface to Novell's API for Access 2.0.

 A colleague of mine asked the members of this LISTSERVE for suggestions

and received the following response:

>Subject:      Re: Netware VBX/DLL

>

>Take a look at ZTECH Software's NetWare Interface for Visual Basic.  They

>support VLM among other things.  The price is $195, and the phone number

>is (512) 495-9101 (it's a number in Austin, Texas, USA.).

I ordered this piece of software and wanted to share my opinions with this

group.

The 'NetWare Interface for Visual Basic' is very thorough with regard to

coverage of the Novell Client and Server APIs.  The SDK itself is a

collection of Visual Basic definitions for Netware's APIs which appear to

have been painstakingly recreated from the C calls of Novell's SDK.

 Included with the text files containing this information is a 361page

manual -- yes, a manual, which details each of the calls, and several useful

and well documented sample code pieces.

The documentation explains the purpose of the call, the parameters, and the

return values in a clearly understandable form.  The calls are divided into

the types of services they address, much in the same way Novell's SDK is

organized.  Actual usage is demonstated within the many pieces of sample

VB code included.

Technical support is available from 8am-5pm CST and the developers are

accessible by fax and internet/Compuserve e-mail.

Speaking of technical support-- I have had the occasion to speak to two

individuals at Ztech for tech support, Mike and Tim.  Both of these guys are

extremely knowledgeable and truly understand the concept of CUSTOMER

SERVICE.

Enough of the fluff -- some minor criticisms

1) The application I am developing is in Access Basic.  Flame on, see if I

care.  The sample code was distributed already in .BAS format which is not

as easily incorporated into Access as plain ASCII text..  Not that this was

a big problem having VB handy but could have been an inconvenience.

2) The Novell APIs are complex animals and the sample code included is very

helpful.  It would be even more helpful, however, to have an index to the

sample code functions to help locate certain examples.

In conclusion--

If you do VB and you do Novell, look SERIOUSLY at Ztech Software's

NetWare Interface for Visual Basic.  It is well worth the money!


Novell Netware

LUOKKA: misc

Date: 07-18-95 (12:12)              Number: 389803 of 390073 (Refer# NONE)

Subj: Novell Bindery Access Solution

From: "R. K. Staten" <STATENRK@ICARUS.SOM.CLARKSON.EDU>

>     I have a need to interrogate Novell to find out if a user is a member

>     of a Novell group. We have 3.11 and 3.12 servers. Does anyone have

>     some example code or know of a VBX or set of API calls I can use?

>     terry-k@dircon.com.uk

The following program will display a list of all the groups that a user

is a member of.  Modify it as you need.  I hope this helps.

'*** Add this code to a new form that has a list box ***

'*** Name the list box lstValues ***'

Declare Function NWGetConnectionHandle Lib "NWCALLS.DLL" (ByVal

server$, ByVal res%, conn%, res2 As Any) As Integer

Declare Function NWReadPropertyValue Lib "NWCALLS.DLL" (ByVal conn%,

ByVal objectName$, ByVal objectType%, ByVal PropName$, ByVal

dataSetIndex%, ByVal dataBuffer$, moreFlag%, propFlags%) As Integer

Declare Function NWGetObjectName Lib "NWCALLS.DLL" (ByVal conn%,

ByVal objectID&, ByVal objectName$, objectType%) As Integer

Dim serverName As String

Dim objectName As String

Dim ccode as integer

Sub Form_Load

  serverName = "??????" '*** The name of the server goes here ***'

  objectName = "??????" '*** The name of the user goes here ***'

  Main

End Sub

Sub Main

  ccode = NWGetConnectionHandle(serverName, 0, conn%, Null)

        if ccode <> 0 then

                msgbox "Error with NWGetConnectionHandle"

                end

        endif

    dataSetIndex% = 1

    Do

        dataBuffer$ = String$(128, 0)

        propName$ = "GROUPS_I'M_IN"

        ccode = NWReadPropertyValue(conn%, objectName, 256, propName$,

dataSetIndex%, dataBuffer$, more%, PropFlags%)

        If ccode% <> 0 Then

            MsgBox "NWReadPropertyValue() Error: " + Hex$(ccode%), 32,

"ERROR"

            End

        End If

        'If property is an item

        If PropFlags% < 2 Then

         msgbox "Ooops, not a set"

        Else

           WriteSetProperty conn%, dataBuffer$

        End If

    dataSetIndex% = dataSetIndex% + 1

    Loop Until more% = 0

End Sub

Sub WriteSetProperty (ByVal conn%, ByVal dataBuffer$)

    i% = 0

    Do

        'take four bytes off buffer$, convert to long integer

        place1& = Asc(Left$(Right$(dataBuffer$, 128 - i%), 1))

        place2& = 256 * Asc(Left$(Right$(dataBuffer$, 127 - i%), 1))

        place3& = Asc(Left$(Right$(dataBuffer$, 126 - i%), 1))

        place3& = place3& * 256

        place3& = place3& * 256

        place4& = Asc(Left$(Right$(dataBuffer$, 125 - i%), 1))

        'Error check for long integer overflow

        If place4& < 128 Then

            place4& = place4& * 256

            place4& = place4& * 256

            place4& = place4& * 256

            objectID& = place1& + place2& + place3& + place4&

            'If objID is 0 then end of list

            If objectID& = 0 Then

                Exit Do

            End If

            'Get object name from object ID and add to list

            objname$ = String$(48, 0)

            ccode = NWGetObjectName(conn%, objectID&, objname$, objtype%)

            If ccode% <> 0 Then

                MsgBox "NWGetObjectName() Error: " + Hex$(ccode%),32,

"ERROR"

                End

            End If

            lstValues.AddItem objname$

        End If

        i% = i% + 4

    Loop While i% <= 125

End Sub

'*** Disclaimer ---> I just typed this in a couple of minutes ago

'*** so forgive me it seems a bit sloppy.  It does work however;

'*** I did test it. ***'

'***

'*** Ken Staten

'*** Statenrk@Icarus.som.clarkson.edu

'*** or

'*** Ken@Icarus.som.clarkson.edu


Novell NetWare

LUOKKA: VBgen

18.How do I program the Novell NetWare API from VB?

   Tom Tregilgas (Tom.Tregilgas@InfoB.unisg.ch) had a lot of information on

   this one. Normally I leave it to the other FAQ parts to list books &

   how-to-get-info's, but since this topic is very specific and more

   NetWare than VB I include all the stuff here for your convenience:

   If you are interested in seeing how Visual Basic can be used for

   NetWare programming, obtain the following files from your friendly

   neighboorhood Novell FTP Mirror site.

   Mirror sites are (according to ftp.novell.com):

         Novell Germany            ftp.novell.de

         Netherlands               ftp.rug.nl

         United Kingdom            ftp.salford.ac.uk

         Logan, Utah               netlab2.usu.edu

         New Zealand               tui.lincoln.ac.nz

         Tuscaloosa, Alabama       risc.ua.edu

         Ottowa, Ontario, CA       novell.nrc.ca

         Boston, Mass              bnug.proteon.com

   novlibÖ11Önivb.zip              Netware Interface for Visual Basic

   novlibÖ11Önwtest.zip            NetWare Test for Visual Basic

   There are also two Novell App Notes on the subject of using NetWare with

   Visual Basic (although this is _NOT_ supported by Novell...) which are:

   October 92      Interfacing Visual Basic for Windows and NetWare

   July 93         A NetWare Interface for Visual Basic

   The AppNotes can be obtained by contacting the Novell Research Order

   Desk, FAX: +1 303 294-0903, Voice 800 377-4136, +1 303 297-2725.

   Address as follows:

   Novell Research Order Desk

   1601 Park Avenue West

   Denver, CO 80216-5199

   AppNotes are $95/year ($135 outside US)

   Here are a few books which might help you out to figure the calls out:

   Windows Development on NetWare Systems, Lori Gauthier and Sue

Whitehead

   (c) 1994, Windcrest, Blue Ridge Summit, PA 17294-0850 (McGraw-Hill)

   $34.95 Comes with disk This book also tells you how to "upgrade" to the

   currently supported SDK calls

   NetWare System Interface Technical Overview, Novell (c) 1990,1989

   (Addison-Wesley), $32.95 (describes Novell's C Network Compiler API's)

   Visual Basic Programmer's Guide to the Windows API, Daniel Appleman

   Ziff-Davis Press, 5903 Christie Ave, Emeryville, CA 94608, $34.95  Comes

   with disk

   It should be mentioned that the APIs included with the NIVB are _not_

   current, and for this purpose, you should get the Novell SDK kit. Also,

   Novell will not support NIVB, but you can sometimes get some helpfrom

   Compu$erve, or from others on the Infobahn <g>

   Good luck!

   p.s. It behooves you to become a member in the PDP (Professional

   Developer's Program) since you get the AppNotes (& Bullets!) for...free.

   p.p.s. Novell does NOT support the NIVB...

   p.p.p.s. Also, no docs come with it.  You'll probably need the Client C

   SDK kit to be able to really _use_ the code.

   p.p.p.p.s. To make things even better, the calls in NIVB are fairly old,

   and not of the Client C SDK kit variety.  However, there _are_ books

   which could help you out, e.g. "NetWare System Interface Technical

   Overview", by Novell. ISBN:0-201-57027-0, published by Addison-Wesley

   Publishing co, $32.95 US, $42.95 in Canada.

   Update:

   AppNotes are dead, however, Develper Notes live on.  There is one

   article about NetWare programming with Visual Basic here:

   July/Aug 94     NetWare Programming in Visual Basic:

                   Using Apiary's NetWare Client SDK for Visual Basic


Null

LUOKKA: Access

4. How do you avoid the "Invalid use of null" error when reading null

   values from a database?

   If you try to retrieve a null value (empty field) from a database,

   you will get the error: "Invalid use of Null". Here is one way to

   get around this problem:

   I've worked around this problem with the following code:

     TextBox.Text = MyTest.Fields("TestFld") & ""

   This code converts the Null-Value into an empty string.

    Ralf Metzing (rmm@dragon.stgt.sub.org)


Null

LUOKKA: VBgen

5. What is "NULL"?

   Contrary to popular belief, Null is not nothing. It's even less

   than nothing.   8^)

   The VB documentation describes all the horrors of misunderstanding

   the infamous NULL. Since people don't read the documentation, we

   feel like informing that

     If ThisVarIsNull = NULL then DoSomething

   will *always* fail, and the DoSomething can't possibly be executed.

   You *must* use IsNull(ThisVarIsNull) which will return True if the

   var is Null (phew!).

   If you want to find out why someone came to think of this strange

   value, read some relational database theory.


Obj.not Array

LUOKKA: Access

Date: 09/15/94 (14:52)              Number: 19433 of 19445 (Refer# NONE)

From: JOE@BFTSI0.UUCP

Subj: Re: Object not an Array : error!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> We're getting an error message, "Object not an array."  I have set an

> object variable to a table in a database.  The object variable is a

> global variable declared in a basic module.  I use the variable to

> access fields in my database with commands like:

I've seen this before! VB has a parser bug which makes it

difficult to use database objects declared in a module from

within a form. You'll need to declare and set aliases, like this:

MAIN.BAS:

Dim DB As Database, T1 As Table, etc.

Sub Main()

    Set DB = OpenDatabase(App.Path & " mydb.mdb")

    Set T1 = DB.OPenTable("T1")

    etc.

    Foo.Show

End Sub

FOO.FRM:

Dim DB_Alias as Database, T1_Alias as Table, etc.

Sub Form_Load()

    Set DB_Alias = DB

    Set T1_Alias = T1

    etc.

End Sub

Sub Form_Deactivate()

   ' Do NOT close DB_Alias or T1_Alias here, because

   ' that will close DB and T1 as well! Even if you

   ' do want to close the 'master' objects, closing

   ' them through the aliases will make things confusing

   ' when you or someone else needs to make a change

   ' six months later.

End Sub

Sub SaveIt_Click()

    T1_Alias.AddNew

    T1_Alias(0) = Now

    T1_Alias(1) = "Somebody clicked me!"

    T1_Alias.Update

    ...or whatever...

End Sub

--

Joe Foster (joe@bftsi0.UUCP or joe%bftsi0.uucp@uunet.uu.net)


Obj.not Array

LUOKKA: Access

Date: 09/17/94 (23:18)              Number: 19896 of 20037 (Refer# NONE)

From: TOB1@DELPHI.COM

Subj: Re: Object not an Array : error!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I have seen this (and there is a BUG noted in the Developer's CD) with

Dynasets but maybe its also a problemn with tables...

In any event this suggested fix is to place a SET EQUIP = EQUIP

statement in the failing subroutine...if this doesn't work (or you get

a worse error on the SET line ) you may need to use a local copy of the

EQUIP variable (LEquip as Table....SET LEquip = Equip) and may even need

to recreate the table locally ("---.CreateTable(""))..

tob


Obj.not Array

LUOKKA: Access

Date: 09/24/94 (17:24)              Number: 20647 of 20702 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Object not an Array : error!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>We're getting an error message, "Object not an array."  I have set an

>object variable to a table in a database.  The object variable is a

>global variable declared in a basic module.  I use the variable to

>access fields in my database with commands like:

> Equip("EquipmentType") = 2

>, where Equip is my object variable set to my table, and EquipmentType

>is a field in that table.  I use commands like this throughout my

>application successfully in several different procedures and on

>several different forms.  But, in one procedure when I try to run the

>application, I get the error: "Object not an array."  In this same

>procedure, I use another object variable similarly that was declared

>in the same place as 'Equip' without a problem.

This is a known problem. MS's recommended workaround is to make a

reference to a table (or recordset) method at some point prior to your

reference to the table field.

In other words, add a subroutine to the "General" section of your form

something like the following...

Sub AAA_IllBeFirst

 Equip.FindFirst

End Sub

This reference to a table method will force the VB parser to recognise

"Equip" as a table reference, and Bob will presumably marry your aunty.

--

Luke Webber


Obj.not Array

LUOKKA: Access

Date: 09/26/94 (11:31)              Number: 20763 of 20785 (Refer# NONE)

From: ABM@RHH.DK

Subj: Re: Object not an Array : error!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The problem is a reported bug in version 3.00.  The correct Microsoft Support

title is : Referencing Data Object Gives Error: Object not an Array

This happens when you reference a field of a dynaset, table or snapshot

object in a form or a module that does not contain a Set statement for that

object.

The actual error report is generated when you compile your program.

WORKAROUND:

Add a dummy Sub procedure to each form or module, and use a Set

statement that refers to the global database/table/dynaset in a meaningful

way.  Give the Sub procedure a name like 'AAAAA_Fix_Parser' so it will be

the first code parsed in hat form or module.  Make sure the dynaset in the

dummy Sub procedure is the exact same dynaset that is causing the problem.

I've found that it is possible to stuff all my dynasets/table/database error

causing Set calls into this dummy Sub procedure without any further

problems.  Everyting works.

Example, use the following dummy procedure if MyDs is the dynaset causing

the problem (NB! You don't ever have to call it !):

  Sub AAAAA_Fix_Parser

     Set MyDs = MyDB.CreateDynaset("...")

   End Sub

For further information, read Q100367 on ftp.Microsoft.com


Obj.not Array

LUOKKA: Access

15.Why do I get "object not an array" when I try reference the fields of a

   global object variable which I have set to a table?

   VB has a parser bug which makes it difficult to use database objects

   declared in a module from within a form.

   WORKAROUND: Just perform some _method_ on the table object

somewhere  _before_ you try to reference fields. Say in a form-based

subroutine  AAAA_IllBeFirst you have a Tbl.MoveFirst, which is never even

 executed.  Then VB suddenly realises what the object is and all is forgiven.

   Credit to Luke Webber and "Joe Foster of Borg".

   Ayn Shipley (ashipley@hookup.net)


ODBC db closing

LUOKKA: Access

Date: 02-06-95    Time: 11:55a     Number: 453

     From: michalb@nummy                 Refer:

  Subject: Closing an ODBC database          2: comp.lang.ba   Status: Public

Using the Close method on an ODBC database doesn't close  the database.

A solution to this problem presented in the MS knowledge base is enter a

ConnectionTimeout entry to the ODBC section of the <app name>.ini file in

the \windows directory. I'm looking for a way to control  the

connectionTimeout without creating a <app name>.ini file (or by changing the

location of the file). Is there a way to do this?


ODBC driver/API calls

LUOKKA: database

Date: 03-15-95 (23:28)              Number: 259443 of 262621 (Refer# NONE)

Subj: Re: Oracle ODBC driver

Kim JangHyun wrote:

> So I tested Oracle ODBC driver provided Microsoft between them, but

> it was too slow to use. My problem is just this "too slow".

> Has anyone had any solution about this, please let me know.

> I heard that Q+E MultiLink from the Pioneer Software is a good product.

> Is it true? :->

If you are using the Jet Data Access Objects (i.e., dynasets, snapshots)

the performance will likely be slow.  I use direct ODBC API calls to

Oracle and the performance is excellent.   I've tried Q+E Multilink/VB

and it is an excellent product if you need database bound controls and

it seems to be as fast as the direct ODBC API calls.  I'm not using it

on my current project because most of the database interaction is in

the background rather than data entry.

--

Timothy King

tcking@usit.net


ODBC performance

LUOKKA: Access

6302 (10+)  jensr@hrp.no  16.06.95  15:36

Jens Roynlid: "Re: Please help: ODBC performance"

In article <67D4188D@intouch.nl> jan.sijm@intouch.nl (Jan Sijm) writes:

>I must be going crazy...What is it that we are doing wrong what could

>cause extremely bas performance when accessing ODBC data sources (in

>our case a DB2/2 database server). We had an import program that took 7

>minutes to run on an Access 2.0 database. The same program took hours

>when running it using the Jet Engine and the ODBC driver. I converted the

>program to use SQL_PASSTHROUGH and Execute statements and it still

>takes 55 minutes to complete (e.g. 8 times more than on Access). The

>problem is *not* the database server, because it is really fast.

>What can we do to further improve the performance ? Does anyone have

>any performance figures on any type of database server (e.g. Oracle, SQL

>Server, SyBase) ?

I am pretty sure that the performance bottleneck here is the JET engine in

VB, which can be (usually is ... ?) slow when using a ODBC connection to a

remote DB. There are several things to do:

1. Try a different ODBC driver (a third-party driver may be faster).

Visionware in England provides very fast client-server ODBC drivers.

2. Look at your querues to the DB. The JET engine may try local joins

instead of passing SQL statements to the server. This slows performance.

3. Use the ODBC API from VB instead og JET. This involves more

programming, but the performance gains are substantial (10-15 times faster

than JET).

Jens R.


ODBC speed up Oracle

LUOKKA: database

Date: 03-16-95 (23:03)              Number: 260948 of 262621 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Oracle ODBC driver

I have been using the ODBC drivers from microsoft with no problems.  There

has been testing done that shows that on average ODBC is as fast as most

proprietary drivers.  The big hold-up is JET and using DAO's.  Even going

throuth Jet Response time for displaying a record (this involves a view that

has a join on three tables and a separate query to retrieve other information

based on the results of the first) and updating a form takes < 1 sec.

The biggest performance improvers that I have found in development of my

project are:

1.  Never open and access the Oracle database directly (Except by direct

ODBC Calls).  Create an Access/VB database and attach the Oracle tables to

the Access Database.  When you Attach a table, the table characteristics

are cached in the local database.  If you don't do this JET has to get all the

characteristics of a table from Oracle before it can use it each time.  This

takes a lot of time.  This is a biggee

2.  For non row returning quiries always use SQL passthrough if practical.

This passes your query straight to the server without any processing by JET.

3.  Use SQL queries rather than DAO's to do updates, inserts, and deletes to

your ORACLE tables whenever possible rather than DAO's.  Even without

using passthrough, these are generally much faster.

4.  Avoid heterogenous joins.

5.  Don't create snapshots and dynasets based on tables.  Base them on SQL

queries That limit both the fields and records requested to only what you

need.

6.  Use snapshots unless you need to update the recordset or unless you

expect an extremely large number of records to be returned.  Snapshots

retrieve and store all fields of accessed records.  Dynasets only retrieve the

Primary Key field(s) and must send out another data request to retrieve the

remaining fields for a record.  Dynasets may be faster for large recordsets

depending on how you are accessing them.

If you have it available check chapter 4 of the Advanced Topics book from

the Access Developers Toolkit.  There are also several white papers/tech

notes/etc on the Developers Network CD that address improving Access

(JET) performance that are applicable to both Access and VB.

I have found that by following these rules my application seems to run about

as fast as applications developed using Oracle Tools of the same complexity.

Bill Brown


OLE and Excel

LUOKKA: OLE

28497 (57+)  Rami.Rasanen@p1.f73.n369.z1.fidonet.org  31.07.95  10:51

Rami Rasanen: "Excel and Ole Automation"

 t> I am using Ole automation to access information in an Excel

 t> spreadsheet, but after I close the excel object, I find that VB has

 t> not released all the resources and the spreadsheet is still in memory.

 t> I'm using the following code to open an excel sheet:

 t> Set XlApp = GetObject("", "Excel.Application")

 t> Set Excel = XlApp.Application

 t> Excel.Workbooks.Open "File.xls"

 t> Set Sheet = Excel.WorkSheets("Sheet1")

 t> And then I close Excel with this code:

 t> Excel.Workbooks(1).ÄCloseÅ (False)

 t> Set XlApp = Nothing

 t> Set Excel = Nothing

 t> Set Sheet = Nothing

Try this:

VERSION 2.00

Begin Form Form1

   Caption         =   "Form1"

   ClientHeight    =   4008

   ClientLeft      =   1560

   ClientTop       =   1800

   ClientWidth     =   6372

   Height          =   4332

   Left            =   1512

   LinkTopic       =   "Form1"

   ScaleHeight     =   4008

   ScaleWidth      =   6372

   Top             =   1524

   Width           =   6468

   Begin CommandButton Command1

      Caption         =   "Command1"

      Height          =   1212

      Left            =   2040

      TabIndex        =   0

      Top             =   840

      Width           =   1932

   End

End

Sub Command1_Click ()

    Dim xl As Object

    Dim xlchart As Object

    Dim xl3DColumn As Integer

    xl3DColumn = -4100 'xl constant for 3D Column chart

    'Create Microsoft Excel object

    Set xl = CreateObject("Excel.Application.5")

   'xl.visible = True

    'add an Microsoft Excel workbook

    xl.workbooks.add

    'put values into cells

    xl.range("b1").value = 3

    xl.range("b2").value = 2

    xl.range("b3").value = 1

    xl.range("b4").value = 3

    xl.range("b5").value = 2

    xl.range("b6").value = 1

    xl.range("a1").value = 6

    xl.range("a2").value = 8

    xl.range("a3").value = 12

    xl.range("a4").value = 6

    xl.range("a5").value = 8

    xl.range("a6").value = 12

    xl.range("A1:B6").Select

    'add a new chart and capture the chart object

    Set xlchart = xl.charts.add()

    'make the chart 3D Column

    xlchart.Type = xl3DColumn

    'rotate the chart

    xl.visible = True

    For i = 30 To 180 Step 10

        For j = 1 To 10000: DoEvents: Next

        xlchart.rotation = i

    Next

    xl.application.activeworkbook.saved = True

    xl.application.quit 'A_EXIT

    Set xl = Nothing

End Sub

Fidonet:  Rami Rasanen 1:369/73.1

Internet: Rami.Rasanen@p1.f73.n369.z1.fidonet.org


OLE VB&Word

LUOKKA: OLE

3421 (134+)  charlywalter@delphi.com  20.01.95  05:58

Charly Walter: "OLE with Word, examples wanted!"

>   So, I am looking for exaples of OLE automation between VB and Word.

>I've read both manuals, but I couldn't find any concrete examples of how to

>do it. If you have a simple example of OLE between Word and VB, please

>mail it  to me, or even post it here, as there are undoubtedly many people

>who would be interested.

Using OLE Automation with Word 6.0 is simple. Here are some code snippets

that should be self-evident

           Set WordObj = CreateObject("Word.Basic")

           If WordObj.CountWindows Then

              WordObj.Window1

              WordObj.FileTemplates 0, TemplateDirectory$ & TemplateName$

           Else

              WordObj.FileNew TemplateDirectory$ & TemplateName$

           End If

           .

           WordObj.FileTemplates 0, TemplateDirectory$ & "normal.dot"

           WordObj.FileSaveAs DocDirectory & sFileName

           .

           WordObj.FilePrint

           WordObj.ToolsProtectDocument "CHARLY", 1, 1

           WordObj.FileClose 1

           .

           WordObj.StartOfDocument

           WordObj.EditFind lChevron

           If WordObj.EditFindFound() Then

               WordObj.CharRight 1, 1

               WordObj.Insert Text1.Text

           End If

           WordObj.EndOfDocument

           .

           WordObj.EditSelectAll

           WordObj.EditCut

           Text1.Text = ClipBoard.GetText(1)

Any questions ?

Regards,

Charly


OLE2UI

LUOKKA: setup

Date: 08/21/94 (20:01)              Number: 16505 of 16587 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Re: need to find ole2ui.dll

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

OLE2UI does not exist.  Remove all references to it from the Wizard.INI

file.

Chuck

Mesquite TX


On top Windows

LUOKKA: on top

Date: 11/07/94 (15:49)              Number: 26119 of 26127 (Refer# NONE)

From: STEVE.LAWRENCE@ECCLES.SEUK.COM, Steve Lawrence

Subj: Independant Application Ontop

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

 Da> I have read FAQ and all the latest comments on keeping a VB program

 Da> window  ontop but there has been no mention of how to do it to other

 Da> windows programs  that don't have that facility.

 Da> Is it possible to adapt the code for puting a window ontop so that it

 Da> can  receive a command line reference to another already existing

 Da> program and make  that progrma stay ontop, including when it is

 Da> iconised?

 Da> For example to be able to enter a command such as "ontop

notepad.exe"

 Da> so that  notepad then stays ontop of any other program.

 Da> This would be a very useful facility. I would like to do it to MSmail.

 Da> David (david.davies@phys.utas.edu.au)

Good question... I had exactly the same problem as yourself some time

ago... Again, MS Mail was my offending application.

This was a long time ago now, but as I recall there are a number of

problems I encountered.

The first was to get the Window handle of the application that's going

to stay ontop. It's not enough to say, like you did : ONTOP <exe name>

'cos you won't get a window handle from it. And if you have say,

3 copies of notepad running, who's to say which one's gonna stay ontop?

The solution (for me) was to run your app 'ONTOP' and have the user

click on the window/icon they wanted to stay ontop (which activates it)

and then press a button on your form which adds the ontop app into a

listbox (optional).

'cos the application you want to stay ontop is active right until you

press your button then you can use the GETACTIVEWINDOW () api to return

the Window handle for that app :

Declare Function GetActiveWindow% Lib "User" ()

Once you've got the handle you can get the Window text to stuff into

your list box :

Declare Function GetWindowText Lib "User" (ByVal hWnd As Integer, ByVal

lpString As String, ByVal aint As Integer) As Integer

If you stuff this into a timer which is active when ONTOP is NOT

iconic (See ISICONIC() - or something) you can do something like :

Sub Timer1_Timer ()

Dim Caption$

Caption$ = String(50, Chr(0))

LastSelectedWindow = String(50, Chr(0))

ActiveWindow = GetActiveWindow()

result = GetWindowText(ActiveWindow, Caption$, 50)

If Caption$ = LastSelectedWindow Then GoTo EndTimer1

lblActiveWindow.Caption = Caption$

LastSelectedWindow = Caption$

LastSelectedHandle = ActiveWindow

EndTimer1:

End Sub

which puts the name of the active application into a label, and then

when you press PUT-ME-ONTOP command button (or whatever) it's able to

add the Window text to your listbox and store the window handle along with

it..

From there you use the SHOWWINDOW() API call to set the status of the

windows in your listbox..

Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal

nCmdShow As Integer) As Integer

'  ShowWindow() Commands

Global Const SW_HIDE = 0

Global Const SW_SHOWNORMAL = 1

Global Const SW_NORMAL = 1

Global Const SW_SHOWMINIMIZED = 2

Global Const SW_SHOWMAXIMIZED = 3

Global Const SW_MAXIMIZE = 3

Global Const SW_SHOWNOACTIVATE = 4

Global Const SW_SHOW = 5

Global Const SW_MINIMIZE = 6

Global Const SW_SHOWMINNOACTIVE = 7

Global Const SW_SHOWNA = 8

Global Const SW_RESTORE = 9

Something like :

        For a = 1 To NumberOfOntopWindows

        Handle = OntopWindowName(a, 2)

        void = ShowWindow(Handle, SW_SHOWNA)

        Next a

does the trick for me..

Now, comes the sad part. On slower machines I find that there's an

appreciable flicker when it's cycling through the apps to put ontop. This

flicker only happens on the last app that's been added to the list.

So, if I have say, Word, Excel, Mail, and Notepad all 'ontopped' and

Excel was the last in my list, then my Excel icon flickers slightly

every time it hits the timer...

This isn't noticeable on fast machines... But it was enough to have

a number of 386 users put off using it..

 shrug  I never figured out how to cure it, short of putting in a dummy

transparent icon and always making sure it was last in the list..

I appreciate that there are probably better ways of doing this... and I'm

sure I'll get lots of comment along the lines of <you could have done <x>

or should have done <y>, or could have put a % after your integer

variables to make it faster... etc... However, I *HAVE* done it, and

whats more it was one of my first VB apps... so rather than flaming *my*

code, if you feel you have something constructive to say, then please

post a better alternative..


Option Explicit

LUOKKA: coding

2. When/Why should I use Option Explicit?

   Option Explicit forces you to declare all variables before using

   them. Opinions vary greatly on this subject. The main reason to use

   the OPTION EXPLICIT statement at the top of all modules is to

   minimize the amount of bugs introduced into your code by

   misspelling a variable name. Most variants of BASIC (including VB)

   have the capability to create variables 'on the fly' (without any

   declarations). This capability can be a double edged sword.

   At the minimum, some suggest using the DEFINT A-Z statement in leu

   of OPTION EXPLICIT. This statement will cause any variables which

   are created on the fly to be created as integers as opposed to

   variant (VB 3.0) or single precision (VB 1.0 and 2.0). (Integers

   take up less memory).

   The OPTION EXPLICIT statement causes VB to 'disable' its ability to

   create variables on the fly. Thus, all variables must be declared

   using a DIM or REDIM statement. All variables not declared will

   cause an error when the OPTION EXPLICIT statement is used. This

   will eliminate bugs caused by a misspelled variable. The option

   works module-wide, so you can have some modules with and some

   without this option in your project.


Out of memory

LUOKKA: coding

27421 (253+)  rdela@ctp.com  26.07.95  00:40

Rory Dela Paz: "Re: Out of memory? I don't think so!"

>>Generally when your program runs fine in the design mode but you still

>>get an out of memory error when you try to compile it into an exe, you

>>have one or more module (.bas or .frm) bumping the "p" code limit of 64k.

>> The behavior can be erratic and even compile ok yet give runtime errors

>>when you try to execute it.  Try breaking your large .bas modules up into

>>smaller ones and moving some code from your .frm modules into .bas

>>modules.

Umm, actually, this is be counterproductive. I know this really sucks,

but every .bas file goes into the Global Symbol Table which has a 64K limit.

We ran into this and we actually had to collapse .bas files (from >100 to

about 63 or so). The .bas file itself can be larger than 64K though. It's

a function in a .bas file that cannot be larger than 64K. One more thing you

might want to consider is the length of your function names. If you've got

function names like ImALongFunctionName, you definitely want to shorten

those.

The same thing goes for control names in your .frm files. If you've got a

control named cmdOkSometimes and it has a control event associated with it

like Click, you'll have subroutine names like cmdOkSometimes_Click. Along

the same lines, make sure similar controls in different/same forms have the

same names. That is, if you have a button named cmdOk in one form and it's

named cmdOkay in another form, make sure both are named cmdOkay. The

reason for this is only unique instances of event procedures are put in the

global symbol table. Also, see whether you can use control arrays, that helps

a lot too.

>Now, is it better to move code to a .BAS module (thus becoming

>Global) than have it reside in its appropriate Form?  I'm still going

Actually, as soon as you declare a procedure, whether it be Private, in a

.bas file, an event procedure, or a procedure in a .frm, it still ends up in

the global symbol table. We found this out the ugly way - pretty much had to

get a confession from an MS Premier Support guy that this was the case. So,

unfortunately, even if you put functions in .bas files and make them

private, you're still hitting the GST.

>nuts with random Out of Memory errors that I can't pinpoint.  It's

>making little sense since the form that it complains about is really

>nothing at all.

Try finding the knowledgebase article numbered Q112860. Pretty much

everything I outlined above is contained in that MS document. Also, what I

outlined above still might not get rid of your Out Of Memory errors but

Q112860 has some other suggestions on how to avoid this stupid error.


Out of memory

LUOKKA: coding

15.I have  several  megabytes of memory. Why do I get an "out of

   memory" error?

   Unfortunately, Microsoft has been more famous for memory barriers

   than anything else. This is a late descendant of the infamous 640K

   barrier that has been plaguing us for years. Although Windows

   allows the user to access several megabytes of memory, it uses two

   limited (64K) memory areas called User Heap and GDI Heap for some

   specific data structures. Go to the Help"About box in Program

   Manager to see the percentage of free resources in the *most*

   exhausted heap. If these areas are exhausted, you are out of luck.

   VB programs are unfortunately rather greedy on these structures.

   Windows 4 is supposed to free us from this limitation...

   Note that every visible control (ie every button) is a window to

   Windows. Every new control takes up some bytes in the precious User

   heap.

   Also, there is another way to run out of memory in Windows, not

   related to VB. Windows requires free Upper Memory Area (UMA, also

   called Upper Memory Blocks, not to be confused with High RAM, which

   is the first 64K of extended memory) to do certain tasks. If you

   use QEMM or DOS 6+ MemMaker and you have many device drivers

   (network, etc) this area may have been filled up before you launch

   Windows. You will then be unable to start applications, even though

   you have plenty of free RAM. The problem can be solved with careful

   memory setup, but this is far beyond the scope of this FAQ.

   On a completely unrelated problem: When you run a program with an

   outline control with some ATI graphics cards, it may crash with

   just that error message. (see Knowledge Base Q100194 PRB: "Some ATI

   Video Drivers Hang When Using MSOUTLIN.VBX")


Out of memory

LUOKKA: coding

Date: 11/15/94 (19:06)              Number: 26906 of 26906 (Refer# NONE)

From: WEIKKO.IKOLA@CSC.FI

Subj: Re: "Out of memory" on a Laptop

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>We have a Viglen dossier PC (486SX-25 with 8MB RAM) that is running a

>VB 3 Pro program. When the program is loading the Form Load() seems to

>cause an "Out of memory" message.

>Anyone got any bright ideas ?

On Error Resume Next

Load the Form

Load the Form

On Error GoTo 0

Don't ask me why this helps, but it does. Probably something with memory

allocation B-)

Greetings,

Wende (weikko.ikola@csc.fi)


Out of memory

LUOKKA: coding

Date: 03-27-95 (15:26)              Number: 272342 of 277779 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: VB-Out of Memory

>>Lately, I've been getting frequent "Visual Basic- Out of Memory" error

>>boxes when running VB3.0 which is absolutely no fun at all. I've got a

>>486-66 with 16M ram, Windows 3.1 (enhanced) using large swapfile and

>>about 125M

>The running out of memory is NOT due to lack of your total memory

>available. Look at general Memory Management in KB  Q 112860

>Also read your Programmer's Guide Appendix D to look whether you have

>exceeded some of the limits.

>Normally too many Global variables cause this problem. Try splitting the

>module.

We have this "out of memory" problem for a while now. What I have

learned so for is "out of memory" is not out of memory.

This could be running out of limit on one of the following

      1. Windows Resources

      2. TextBox (or any other control) limit of 30k or what ever the limit

      3. One of those symbol table VB Keeps

      4. May be related to "out of string space"

      5. May be really out of memory

There are more than one type "out of memory" in VB 's Error Table.

Q 112860 has got good stuff. But it does not help to solve our application

by VB. I am still looking for good debugging tools for VB which will throw

more light on this "out of memory" errors. This message also has few side

effects like "Overflow" " Could not decrypt file"

Tools I use are VB/RIG to automatically put error handling.

VBCompress.


Outline exp./select1

LUOKKA: Outline

Date: 07/19/94 (01:45)              Number: 12403 of 12479 (Refer# NONE)

From: HPD@AKGUH.UUCP

Subj: Re: Outline control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In the hope of finding a better way of doing this, here

is my code for expanding an outline control and selecting an item

in a outline control at an arbitrary indent level. Note that I

am using two routines here.

Calling ShowOutlineList will expand an outline control until

the item pointed to by Outline1.ListIndex is reached.

Looking forward to an improvement on this.

Paul Debban

hpd@akgua.att.com

Sub ShowOutlineList()

Dim nEnd As Integer

Dim nStart As Integer

Dim sTemp As String

Dim sPathSep As String

    'Display item currently pointed to by Outline1.ListIndex

    nStart = 0

    nEnd = 0

    sPathSep = Form1.Outline1.PathSeperator

   If Form1.Outline1.ListIndex > 0 Then

    sTemp = Form1.Outline1.FullPath(Form1.Outline1.ListIndex)

        Form1.Outline1.ListIndex = 0

        Do

            nStart = nEnd + 1

            nEnd = InStr(nStart, sTemp, sPathSep)

            If nEnd > 0 Then

                ExpandOutline Left$(sTemp, nEnd - 1)

            Else

                ExpandOutline sTemp

            End If

        Loop Until nEnd = 0

    End If

End Sub

Sub ExpandOutline (PathString As String)

'PathString = FullPath Property of Item to be Expanded

Dim iOutlineIndex As Integer

For iOutlineIndex = Form1.Outline1.ListIndex To (Form1.Outline1.ListCount -

1)

    If PathString = Form1.Outline1.FullPath(iOutlineIndex) Then

        If Form1.Outline1.HasSubItems(iOutlineIndex) Then

           Form1.Outline1.Expand(iOutlineIndex) = True

        End If

        Form1.Outline1.ListIndex = (iOutlineIndex)

        Exit For

    End If

Next

End Sub


Outline exp./select2

LUOKKA: Outline

Date: 07/20/94 (17:32)              Number: 12611 of 12618 (Refer# NONE)

From: PLZBMH@PLN1.NOTT.AC.UK

Subj: Re: Outline control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I think I have an improvement, this function will expand the parents of a

given indexed item in a given outline in order to show that item. Note that

the parameter Index is assumed to be a valid index fo rthe outline, check this

before calling the routine.

Sub UnfoldOutLine (outln As Outline, ByVal Index As Integer)

    Dim Indent As Integer

    Indent = outln.Indent(Index)

    Index = Index - 1

    Do While Index >= 0 And Indent > 1

        If outln.Indent(Index) < Indent Then

            UnfoldOutLine outln, Index

            outln.Expand(Index) = True

            Exit Do

        End If

        Index = Index - 1

    Loop

End Sub

Note the recursion which ensures that the successive parents of the item are

all expanded first.

To show and hilite item X in outline OutLine1 do this:

   UnfoldOutLine Outline1, X


P-code

LUOKKA: coding

16.What is Pseudocode?

   VB/Win does not generate machine code like most compilers do.

   Instead it creates what is called pseudocode (a real misnomer,

   IMO). A good explanation is given below:

   A bit of history: the original P-code was an instruction set for a

   "virtual Pascal" machine. This came with a portable Pascal compiler

   written at ETH in Zuerich. The portable compiler produced

   instructions for this phony machine which had an instruction set

   ideally suited to the stack and heap management of Pascal.  To

   executed portable Pascal programs, you had two choices: either

   write an interpreter for P-code, or translate the small set of P-

   code instructions (there were about 80) into assembler; assemble

   it; and run it at native speed.  Thus "P-code" originally stood for

   "Portable" or "Pascal" code. The broader meaning, "pseudo-code"

   came later. P-code was widely popularized by the UCSD Pascal

   system, a small workstation that was implemented entirely in Pcode

   and interpreted. It was sold for some years, and one company even

   re-did the microcode for a PDP-11 microchip to interpret P-code.

   The original Borland Turbo Pascal had obvious similarities to the

   UCSD system although it was not interpreted. The dialect was

   virtually identical.  Today P-code is used extensively in Microsoft

   apps, for two reasons. First, it is much more compact than  native

   code; so the apps are smaller. Second, having an interpreter at the

   core of an app makes it much easier to customize and extend. That

   is why VB is becoming the heart of the MS major apps.  It is simply

   not true that P-code apps run much slower than native apps. The

   slowdown is determined by the granularity of the interpreted

   routines. If every little thing is an interpreted op, the slowdown

   might be as much as 3-to-1 for the 80x86 architecture, or about 2-

   to-1 for the Motorola 68000 family (which is better suited to

   writing interpreters).  But in practice, modern P-code systems have

   large-scale instructions, each of which is executed by a big

   compiled subroutine. These subs run at native speed, so the

   overhead of the interpreter is occasional at worst.

    Roger E. Ison (r_ison@csn.org)

   It is also possible that since the code may not need recompilation

   to run on other platforms *if* the run-time interpreter is first

   ported, VB applications can become very portable. This depends on

   Microsoft's long-term plans.

   A note on the word "pseudocode": I wrote above that it is a

   misnomer, and I stand on that. Pseudocode is *really* the pascal-

   like (mostly) explanation of an algorithm that is intended for

   human readers, not computers. But since somehow the term pseudocode

   stuck to the psaudo-machine-code created by VB the word is used

   here.


Parameters passing

LUOKKA: coding

27529 (147+)  dingbat@codesmth.demon.co.uk  26.07.95  15:09

Andy Dingley: "Re: sending variables between forms"

I use a different technique to return parameters (any number) from

forms. It's more complex, but I have it down to a single function

call.

Give every "parent" form hidden labels called lblReturnParam1(and so

on, as needed) and set their .Tags accordingly. Give each child form a

similar label of "lblCallingFormTag"

    To call the form:

Sub mnuOptions_PromoMessage_Click ()

  On Error GoTo mnuOptions_PromoMessage_Click_ErrHandlr

  Load frmPromoMessage

  frmPromoMessage!lblCallingFormTag = Me.Tag

  frmPromoMessage.Show MODAL

  Exit Sub

mnuOptions_PromoMessage_Click_ErrHandlr:

  Exit Sub

End Sub

     On return from the child form:

Sub cmdOK_Click ()

  SetDialogReturnValue lMyStringParameter$, (lblCallingFormTag),

"lblReturnParam1"

  Unload Me

End Sub

      And the magic code in WIDGET.BAS:

' Places the contents of ReturnText$

' into the first form with a .Tag property of FormTag$

' into the first label with a .Tag of LabelTag$

'

' The actual .Tag value is irrelevant,

' provided it belongs to the desired form, and should be unique

'

' On error, does nothing

'

Sub SetDialogReturnValue (ReturnText$, FormTag$, LabelTag$)

Dim i%, j%

  On Error GoTo 0

  i% = 0

  Do While i% < Forms.Count

    If (Forms(i%).Tag = FormTag$) Then

      j% = 0

      Do While j% < Forms(i%).Controls.Count

        If TypeOf Forms(i%).Controls(j%) Is CommandButton Then

        ElseIf TypeOf Forms(i%).Controls(j%) Is ButtonBar Then

        ElseIf TypeOf Forms(i%).Controls(j%) Is StatusBar Then

        Else

          If (Forms(i%).Controls(j%).Tag = LabelTag$) Then

            Forms(i%).Controls(j%).Caption = (ReturnText$)

            Exit Sub

          End If

        End If

        j% = j% + 1

      Loop

    End If

    i% = i% + 1

  Loop

End Sub

PS - Make hidden controls like this bright red. - Makes them more

obvious at design time.

Andy Dingley                          dingbat@codesmth.demon.co.uk


Parameters passing

LUOKKA: coding

28338 (149+)  visualware@interramp.com  30.07.95  20:00

John M. Miano: "Re: Passing argument to Forms. Is it possible?"

Passing Parameters To Forms

The following is one technique can be used to pass parameters to a form.

You will need some kind of message subclassing control such as Message

Blaster or Message Hook.

Declare a global variable in your application global AppMessage as integer

at application startup time do

    AppMessage = RegisterWindowMessage("Your-Message-Name")

Define something like

const PARAM_1 = 1

const PARAM_2 = 2

const ...

const PARAM_END = 999

Create a function something like

Sub SubclassForm (frm as form, ctl as Control)

' Ctl is a message blaster or something like that.

' Actual usage depends upon the subclass control

' used.

ctl.TargetHwnd = frm.Hwnd

ctl.Message (0) = AppMessage

End sub

On each form you want to send parameters to place a subclass control.

In the form's load event call "SubclassForm".

The Subclass control's event procedure will look something like

sub CONTROL_Subclass (msg as integer, wp as integer, lp as integer, return

as integer)

Place code that looks something like:

select case wp

case PARAM_1

param1_value = lp

or

param1_value = me.tag

case PARAM_2

param2_value = lp

case PARAM_3

....

case PARAM_END

' Any initialization code to be called when all parameters

' have been passed.

To pass an integer parameter to the form do

status= SendMessage (form.hwnd, AppMessage, PARAM_n,

value-to-pass)

to pass a string or float do

form.tag = value

status= SendMessage (form.hwnd, AppMessage, PARAM_n, 0&)

-----------------------------------------------

VisualWare, Inc.

Custom Visual Basic, C++, and Windows Programming

1675 East Main St, Suite 218

Kent OH 44240

(216) 297-4444

visualware@interramp.com


Parameters passing

LUOKKA: coding

Date: 07/24/94 (22:56)              Number: 13059 of 13095 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: re-usable code

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Andy Dingley (dingbat@codesmth.demon.co.uk) wrote:

: The idea of a form ID here is to have one that identifies the type of a form

: (like an object's class), rather than the instance of a form.

: I don't like using the .Tag property for this either, although it could

: easily be done. There have been too many instances when another piece of

: code wanted to use .Tag for its own purposes.

There's a raft of tricks for dealing with this.  Some easier than others.

A very easy one is to simply include a hidden label on each form of

interest.  Use whatever property in the label you like for the ID.  Use a

couple if you want to build up subtypes.  Always make the labels the same

name.

So then you dispatch on:

Select Case (theForm.HiddenIDLabel.propertyOfChoice)

and do secondary dispatch on the secondary prop if desired.

gt


Parameters passing

LUOKKA: coding

Date: 07/28/94 (23:22)              Number: 13649 of 13893 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: Adding variables to a control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1700177D8S86.D1CAMERO@bcsc02.gov.bc.ca>

D1CAMERO@bcsc02.gov.bc.ca writes:

>I want to "add" a few properties to any control.  I would like to use

>the tag field, but it is already in use.  Other than creating arrays,

>etc.  Can anybody think of some way to add properties to controls?

I don't know of any GOOD solutions. One approach is to use the

.tag property to store more than one value. E.g. treat it like a

key/value dictionary. I wrote routines which do this:

    TagSetValue(Tag, Key, Value)

    Value = TagGetValue(Tag, Key)

This allows one to store any number of variables in the .tag

property. The tag ends up looking like this: " key1,val1  key2,val2 ..."

It's obviously not a blazingly fast solution but it works.

Another approach is to put invisible static text fields on a form

and use these to store values.

The last approach is to have a parallel array of data structures.

This adds the burden of keeping your controls and the array

in synch, and having good ways to get from one to the other.

In practice I've found using the .tag property to be most convenient

esp. for small numbers of controls and variables, where the performance

hit isn't much of an issue. You write the dictionary routines once

and you can use them in a variety of circumstances.

This is one of the things I dislike the most about VB. You can't add

variables to controls, and you can't include controls in data

structures. Controls are second-class citizens with respect to

language support.


Parameters passing

LUOKKA: coding

11.Is there any way to pass a variable to a form apart from using global

   variables?

   The standard workaround is to put an invisible text box (or caption or

   any other control that suits your use.) on the target form and access it

   by Form.textbox = "value". Then you can use the Change event of that

   control to do anything you want in that form. Also, check out the .Tag

   property which is a "what-you-want" property where you can hook any

   string you want onto a control. This property can also be accessed from

   other modules.

   ÄDave Mitton (mitton@dave.enet.dec.com)Å

   Perhaps a more elegant and flexible way is to implement a stack with

   global routines. I've done this for a math project, but this stack was

   rather complicated and special purpose (and inspired by HP calculators,

   of which I'm a great fan).

   Jan G.P. Sijm (jan.sijm@intouch.nl) has implemented some routines for

   general stacks:

   '--------------------------------------------------------------------

   Option Explicit                        'Variable declarations required

   Dim m_vStack() As Variant              'Stack of variant types

   '*-------------

   '*  This function will pop a value of a stack of variant

   '*  values. The value to be popped (e.g. the variable it

   '*  is assigned to) must have one of the basic variable

   '*  types that Visual Basic supports. The type of the

   '*  return value is determined by the type of the variable

   '*  it is assigned to.

   '*

   '*  Input    : None

   '*  Modifies : m_vStack, Stack of variant's

   '*  Return   : Value of last pushed variant

   '*-------------

   Function stkPop () As Variant

     Dim iM As Integer

     iM = UBound(m_vStack)                'Get current stack size

     stkPop = m_vStack(iM)                'Pop value from stack

     iM = iM - 1                          'Decrement number of elements

     ReDim Preserve m_vStack(iM) As Variant

   End Function

   '*-------------

   '*  This function will push a value onto a stack of

   '*  variant values. The value to be pushed must have one

   '*  of the basic variable types that Visual Basic supports

   '*

   '*  Input    : vValue, Value to be pushed

   '*  Modifies : m_vStack, Stack of variant's

   '*-------------

   Sub stkPush (ByVal vValue As Variant)

     Dim iM As Integer

     On Error Resume Next                 'Trap for undimensioned array

     iM = UBound(m_vStack)                'Get current array size

     iM = iM + 1                          'Increment number of elements

     ReDim Preserve m_vStack(iM) As Variant

     m_vStack(iM) = vValue                'Push value on stack

   End Sub

   'This is a short example of how the stack routines can be used in a

   'Visual Basic program. This example will push three parameters onto

   'the stack. A modal dialog is displayed. The dialog will pop the

   'parameters from the stack and set edit controls with the values.

   Sub ShowDialog()

     '

     '  Push the parameters for the dialog

     '  onto the stack and display the dialog

     '

     stkPush sName

     stkPush sStreet

     stkPush sCity

     dlgPerson.Show MODAL

   End Sub

   Form_Load()

     '

     ' Pop the parameters of this dialog from the

     ' stack in REVERSED ORDER and place the values

     ' in the appropriate edit controls.

     '

     dfCity.Text = stkPop()

     dfStreet.Text = stkPop()

     dfName.Text = stkPop()

   End Sub

   '--------------------------------------------------------------------


Parameters passing

LUOKKA: coding

Date: 09/17/94 (11:20)              Number: 19766 of 19852 (Refer# NONE)

From: MUNDSACK@NETCOM.COM

Subj: Re: passing TYPE structures to a form

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: >The most graceful way I can think of would be to set a global variable of

: >your type, and then have the form use it.  I hate using global variables

: I am using global vars to do this but I have a pretty huge structure which

: obviously eats up a lot of resources.

One thing I have done in the past is to keep an open file of the Type

structure, declared Global, and then I can pass Type structs by simply their

record position in the file.  For example:

In program init:

TypeFile = FreeFile

Open <file$> For Random As #TypeFile Len = Len(MyType)

Then, whenever I want to retrieve a record from the file:

Dim MyVar As MyType

Get #TypeFile, <recnum>, MyVar

This way, the records doesn't stay in memory after you leave the current

Sub or Function.

--

Jon Mundsack

mundsack@netcom.com


Parameters passing

LUOKKA: coding

Date: 11/27/94 (19:34)              Number: 28189 of 28251 (Refer# NONE)

 From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: RE:  Global Maniac, How do I avoid using global variables?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Let's face it - VB is one of those languages where you just can't get away

from them. So stop worrying about it, and think of some ways to control their

use to avoid it going wrong and making bugs for you. Naming conventions

(like always using a "g" prefix) or grouping them into a single file (or at least

keeping their location tightly controlled to avoid duplicates) are good

ideas.

> Is there a way to create a

> function which calls a form and transfers all the variables in a clear,

> well defined manner?

Transferring into forms is easy - use a hidden label and the following code.

I give my labels a bright red background & make them invisible, so that I can

see them easily at design time.

 Load frmWibble

 frmWibble!lblCallingFormTag = Me.Tag       ' More on this later

 frmWibble!lblVar1 = "ABC"

 frmWibble!lblVar2 = str$(1234.5)

 frmWibble.Show

This also fits in well with the Form_Activate trick (read the FAQ) for making

forms appear to display faster

To get data *out* of a form, I don't like to use globals. It works, but makes

it difficult to re-use the called form elsewhere (and code re-use is

difficult enough under VB as it is). Instead I use some bizarre VB magic

which I ought to show you as a code fragment, only the disks are in a

different country (you wouldn't *believe* my travel arrangements this week)

Here's a brief summary of it.

Give the called form a hidden label called "lblCallingFormTag"

Give the calling form a unique .Tag value, and one or more hidden labels

called "lblReturnValue" or similar, with .Tag values to match.

Write a shared subroutine in a library module called:

   Sub SetReturnParameter (FormTag$, LabelTag$, Value$)

Call the called form with code like that above - make sure that

lblCallingFormTag receives the value of the calling form's .Tag

When you wish to return from the called form, use code like this:

  Sub _Click

    SetReturnParameter (lblCallingFormTag), "lblReturnValue1", "Magic Value

1"

    SetReturnParameter (lblCallingFormTag), "lblReturnValue2", "Magic Value

2"

    Unload Me

  End Sub

NB - The parameters should be just as shown above - the first is a label's

contents, the second is a literal string

Inside the SetReturnParameter routine are two nested loops; the first scans

the Forms collection to find the calling form (by comparings .Tags), then the

second scans the form's Controls collection to find the control to store the

return value in.

Returning data from a Windows dialog is always a pain, but when you can't

store a pointer to a data structure (the usual non-VB solution), then VB's

way of doing it gets rather messy. My way does work though, and the

per-usage coding effort is quite small.

PS   Jan - Do you fancy this as an FAQ note ?

--

Andy Dingley                             dingbat@codesmth.demon.co.uk


Parameters passing

LUOKKA: coding

Date: 12/22/94 (00:42)              Number: 159841 of 163156 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: How do you access Module level variables in other module

From: Kenneth Lassesen <kenl@MICROSOFT.COM>

My usual approach is to create

        frmFancy.frm

and

        frmFancy.Bas

with frm holding the controls and the events only and the module

holding the meat.  Thus

sub pbOK_CLick

        ProcessNewData Me  'in BAS module

        UnLoad Me

end sub

Tvhis permits all the module variables to be access by function calll

from any where and parallels the creation of objects in C i,e,

        Fancy_SetLogin ....

        A$=Fancy_GetLastQuery()

In fact the module is the usual method of displaying the form

        Fancy_Show

instead of directly showing.   (The advantage is that the frm and bas

can be cut and paste between projects easily)

        Ken

----------

From: Lasse Rantanen  <lasse@RANTANE.PP.FI>

Subject: Re: How do you access Module level variables in other modules???

Date: Tuesday 20 December 1994 17:26

>I'm writing generic VB subroutines that take a form as a parameter

>and then operate on the controls in the form.  Of course, I can

>easily access a control in the form using Form!Control.

>

>However, I would also like to access a Module-level variable in the

>form. I don't want to make the variable Global to the application since

>it is an MDI application and there will be as many instances of the

>variable as there are instances of the form.

>

>For example, suppose in the Declarations section of the

>form I declare

>Dim FormWideVariableArray(100) as Integer

>

>Then, in some event I call a generic routine with the form as a parameter,

>where GenericRoutine was written in a code module

>

>GenericRoutine Me

>

>Sub GenericRoutine (Frm as Form)

>

>I want to get the instance of FormWideVariableArray for the form that

>was passed into GenericRoutine.

>

>Right now I'm doing it by creating a Global array of Form information, and

>storing the information that I want local to each form in that global array.

>This is really ugly and hard to work with, so I'd appreciate a better

>solution.

>

>Marty Wagner

>marty@icad.com

Hi Marty,

a couple of ideas which could at least partly solve your problem:

1. Use forms TAG property to hold some of your data (maybe the tag property

of some controls, too).

2. Store your data in an invisible control, e.g. a list box or grid or ...

General idea is to find a proper container for your data which is specific

to an instance.


Parameters passing

LUOKKA: coding

Date: 12/22/94 (12:27)              Number: 160946 of 163156 (Refer# NONE)

Subj: Re: How do you access Module level variables in other modul

From: Kenneth Lassesen <kenl@MICROSOFT.COM>

Assume all variables are in structure,FrmInstance as  MyInstance, in

form1.frm.  Then call

        SetInstance FrmInstance

In Module1.BAS create

Dim ModuleInstance as MyInstance  'Module Level

Sub SetInstance(AnInstance as MyInstance)

        ModuleInstance=AnInstance

End Sub

You have now move the data into the module.  To return it to the form

after processing  simply call

        GetInstance FrmInstance

Sub GetInstance(AnInstance as MyInstance) 'In Module1.Bas

        AnInstance=ModuleInstance

End Sub

Several of my articles on next year's MSDN CD issues use this techniques

(for example Spelling 101: Adding a Spell Checker to VB,Access and VBA)

        Ken

        MSDN

----------

> I'm writing generic VB subroutines that take a form as a parameter

> and then operate on the controls in the form.  Of course, I can

> easily access a control in the form using Form!Control.

> However, I would also like to access a Module-level variable in the

> form. I don't want to make the variable Global to the application since

> it is an MDI application and there will be as many instances of the

> variable as there are instances of the form.

Really a great idea, I would appreciate that too (somewhat like an

additional property just like in C++). Anyhow, I too have not figured

out yet how to make something like that (I'm afraid it is simply not

possible), so I use the following workaround:

Just create a label on your child form, set its visible property to

false. Now you can store anything you like and access it from

outside. This is not a very nice solution (as it destroys the outfit

of your form during development), but it works. (For a single

parameter you could use the Tag property of the child form, too (I

use it too distinguish between different child forms).

If someone knows better ways to solve this problem, please tell me, I

am interested.

Hope I could help,

              Stefan

> For example, suppose in the Declarations section of the form I declare

> Dim FormWideVariableArray(100) as Integer

> Then, in some event I call a generic routine with the form as a parameter,

> where GenericRoutine was written in a code module

> GenericRoutine Me

> Sub GenericRoutine (Frm as Form)

> I want to get the instance of FormWideVariableArray for the form that

> was passed into GenericRoutine.

>

> Right now I'm doing it by creating a Global array of Form information, and

> storing the information that I want local to each form in that global array.

> This is really ugly and hard to work with, so I'd appreciate a better

> solution.

> Marty Wagner

> marty@icad.com


Parameters passing

LUOKKA: coding

13347 (109+)  livewire@netcom.com  12.04.95  03:47

Paul Thompson: "Re: Help: Communicating Between Forms"

>What are the possible ways of communicating between forms?

>What is the BEST way of doing it?

  I stopped having forms load or show other forms because I was running into

too much ugliness related to passing data between forms. What I've been

doing recently is putting any form that is loaded/shown/called by another in

it's own .FRM file then creating a .BAS file which contains the "interface" to

the subordinate form.  The calling section calls a function or sub and passes

params.  The function or sub (in the .BAS file) loads the form.  Data is passed

from the "interface" function to the form by module-level variables.  This has

the good/bad side effect of requiring subordinate forms to go into their own

.FRM file with an appropriate .BAS file containing the caller interface.  I end

up with lots of files, but it "feels" better.


Parameters passing

LUOKKA: coding

Date: 05-12-95 (16:22)              Number: 327595 of 329412 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Any way to pass a parm to Form_Load() ?

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Has anyone figured out some way to pass a parameter to

a form's Form_Load() event?

-----------------------------------------------------------------------------------------

Well, you can do it in a roundabout fashion without using the Form.Tag or

global variables.  I'll use a simplified situation.

First, set up a .BAS module with two functions in it.

(i.e SetInputParams and GetInputParams)

SetInputParams should be a function which just sets module level variables.

Ex. Sub SetInputParams (ByVal tempX as variant, ByVal tempY as variant)

                passX=tempX

                passY=tempY

(passX and passY are declared in the general declarations of the .BAS file)

GetInputParams is just a function which returns these module level variables.

        Ex. Sub GetInputParams (wantX as variant, wantY as variant)

                wantX=passX

                wantY=passY

Now when you want to send a Form some parameters, do this:

        1. Call SetInputParams from the calling function to set the input

           parameters.

        2. In the Form_Load event, call GetInputParams to get those input

           parameters.


Parameters passing

LUOKKA: coding

Date: 06-08-95 (14:32)              Number: 355320 of 358553 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: 1)Passing Variables

There are two possible solutions to your first question (we use the first

quite extensively in our application) :

1. You could put an invisible text box on the second form, and place some

code in the change event of that text box. Then when you want to pass some

information to that form, place something in the text box (you could first

check to see if the form is loaded, using the Forms collection). To pass

data across, first set up some global variables :

e.g.

In form 1, put your data in global variables (maybe an array) :

     g_intData = 3       'g_intData is a global integer

     form2!txtTrigger = "GO!"

Then, the code on form 2 could read something like :

     Sub txtTrigger_Change

          'First reset the trigger, so that putting "GO!" in this text box

again will fire it off!

          txtTrigger.Text = ""

          If txtTrigger.Text = "" then exit sub        'Only process the

code once

          'Put your processing code here :

          txtDisplay.Text = g_intData             'Display the data in a

textbox

     End Sub

You might find it useful to colour the text box in design time, so that

other programmers realise that it won't be displayed during run time.

2. An alternative method is to use DDE to transfer data between forms (or

applications). You need to set up the LinkTopic (e.g. frmSource) of the form

providing the data, and the LinkSource (e.g. "ApplicationNameöfrmSource")

and LinkMode of the control (e.g. textbox) receiving the data. It is

possible to initiate the DDE process from both the Source and Desitination

forms. If the second form is not loaded, then you get an error such as "No

foreign application responded to a DDE initiate". You should trap for this

error.

Mark Bennett

mjbennett@sunbury02.datasci.co.uk


Parameters passing

LUOKKA: coding

Date: 05/12/94 (20:32)              Number: 5666 of 5763 (Refer# NONE)

From: MARKDA2@AOL.COM

Subj: Re: Load a Form and Pass Parameter to it, How

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The Tag property is commonly used to pass strings to a form without using

Global variables.  You may also set any properties of controls on the form,

such as textbox text or label captions.  When you modify any property of an

unloaded form or any of its child controls, the form is loaded but not shown.

The load completes BEFORE the property value is updated.  To access to

property value, use the Form_Activate event proceedure, which occurs after

the Form_Load event proceedure but after the property values you set are

updated, and any time the form becomes the active form.  To do this, the

form must activate: you can put a Me.Show statement in the form's load

event.  If you only want the code in the form's Form_Activate proceedure to

execute once, use a flag declared in the form's declarations to check if the

code has been executed before.

Option Explicit

Dim Initialized as Integer

Sub Form_Load ()

'

'any load code you have

'

Me.Show 'Fire Form_Activate event

End Sub

Sub Form_Activate ()

If Initialized Then Exit Sub

'

'Initialization code here

'

Initialized = True

End Sub

Mark


Passing by reference

LUOKKA: coding

9. What is passing by reference?

   Arguments are either passed by reference or by value. When they are

   passed by value, they cannot be changed by the procedure or

   function they are passed to. They *can* be altered when passed by

   reference, since passing by reference is just passing the address.

   Note that procedures are less strict about variable types when you

   use BYVAL. If you declare that your Sub takes a Variant, VB takes

   that seriously and gives a nasty "mismatch error" if you try to

   pass ie. a string to it. Make it ByVal (at the cost of some speed)

   and your sub will be more tolerant.

   Also note the following nasty trap:  Arguments are passed by

   reference unless enclosed by parentheses or declared using the

   ByVal keyword.  VBWin Language Ref., p. 55


Password encrypt

LUOKKA: files

Date: 09/13/94 (17:53)              Number: 19188 of 19190 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: Encryption VBX's or DLL's ???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sir,

I picked up a sample app which does encryption just in VB code.

Actually someone posted it here. It's no RSA, but fairly good for

simple purposes. I've attached it here. I've played with it

and added few of my own bits but the encryption algorithm is

someone else's, so I can't really say how good it is. Fun though.

Ian Piper

'To use this code:

'Take everything from here to the 'End of code line, and save it as

'encrypt2.frm. Then add it to a VB app.

'You may need to sort out some of the line breaks.

VERSION 2.00

Begin Form Form1

   BorderStyle     =   3  'Fixed Double

   Caption         =   "Encryption demo"

   ClientHeight    =   3156

   ClientLeft      =   2136

   ClientTop       =   1668

   ClientWidth     =   5712

   Height          =   3576

   Left            =   2088

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   3156

   ScaleWidth      =   5712

   Top             =   1296

   Width           =   5808

   Begin TextBox Text2

      Height          =   624

      Left            =   1584

      MultiLine       =   -1  'True

      ScrollBars      =   1  'Horizontal

      TabIndex        =   9

      Top             =   1404

      Width           =   4008

   End

   Begin CommandButton Command5

      Caption         =   "E&xit"

      Height          =   372

      Left            =   4608

      TabIndex        =   4

      Top             =   2124

      Width           =   984

   End

   Begin CommandButton Command4

      Caption         =   "Hidden 2"

      Height          =   372

      Left            =   1656

      TabIndex        =   5

      Top             =   2628

      Width           =   1380

   End

   Begin CommandButton Command3

      BackColor       =   &H00000000&

      Caption         =   "Hidden 1"

      Height          =   372

      Left            =   180

      TabIndex        =   6

      Top             =   2628

      Width           =   1380

   End

   Begin CommandButton Command2

      Caption         =   "&Read in password"

      Height          =   372

      Left            =   2412

      TabIndex        =   2

      Top             =   2124

      Width           =   1992

   End

   Begin CommandButton Command1

      Caption         =   "&Store password"

      Height          =   372

      Left            =   180

      TabIndex        =   1

      Top             =   2124

      Width           =   1992

   End

   Begin TextBox Text1

      Height          =   372

      Left            =   1584

      TabIndex        =   0

      Top             =   936

      Width           =   4000

   End

   Begin Label Label3

      Alignment       =   1  'Right Justify

      Caption         =   "Stored as:"

      Height          =   300

      Left            =   216

      TabIndex        =   8

      Top             =   1440

      Width           =   1128

   End

   Begin Label Label2

      Caption         =   "Type a password in below and click on 'Store

password'. This will hide the command

buttons below.  You will have to retype the password to see the command

buttons

again."

      Height          =   732

      Left            =   144

      TabIndex        =   7

      Top             =   72

      Width           =   5484

   End

   Begin Label Label1

      Alignment       =   1  'Right Justify

      Caption         =   "Password:"

      Height          =   300

      Left            =   396

      TabIndex        =   3

      Top             =   972

      Width           =   984

   End

End

Option Explicit

Declare Function GetPrivateProfileInt% Lib "Kernel" (ByVal

lpApplicationName$,

ByVal lpKeyName$, ByVal

nDefault%, ByVal lpFileName$)

Declare Function GetPrivateProfileString% Lib "Kernel" (ByVal

lpApplicationName$, ByVal lpKeyName As Any,

ByVal lpDefault$, ByVal lpReturnedString$, ByVal nSize%, ByVal

lpFileName$)

Declare Function WritePrivateProfileString% Lib "Kernel" (ByVal

lpApplicationName$, ByVal lpKeyName$, ByVal

lpString$, ByVal lplFileName$)

Dim Pass$

Dim Strg$

Dim H$

Sub Command1_Click ()

    Dim i

    Dim J$

    Dim x%

    Dim msg$

'This bit is a bit naff. It takes a combination of a hard-coded

'buried password, and various strings which are likely to vary

'from one try to the next, even on the same machine.

    Pass$ = text1

    msg$ = Format$(Now, "ddmmyyhhmmss")

    msg$ = msg$ & LTrim$(Str$(FileLen("C: config.sys")))

    msg$ = msg$ & "theburiedpassword"

    msg$ = msg$ & LTrim$(Str$(FileLen("C: autoexec.bat")))

    Strg$ = msg$

    Call Crypt(Pass$, Strg$)

'When writing an encrypted password to a sequential access file like the

'INI files, you need to convert the resultant encrypted file to hex data.

'This is because you can end up with an encrypted password that contains

'characters which cannot be properly read using sequential access.  So,

'before saving your encrypted password, use this routine:

H$ = ""

For i = 1 To Len(Strg$)

   J$ = Hex$(Asc(Mid$(Strg$, i, 1)))

   If Len(J$) = 1 Then J$ = "0" + J$

   H$ = H$ + J$

Next

'This will create a string like "0EF31105" or some such.  Save that to

'the INI file.

'Store the LENGTH of the password string as 2 bytes and concatenate

    H$ = Format$(Len(H$), "00") + H$

    x% = WritePrivateProfileString%("SECURITY", "PASSWORD", H$,

"ENCRYPT.INI")

'hide the buttons

    command3.Visible = False

    command4.Visible = False

    text2 = H$

End Sub

Sub Command2_Click ()

    Dim x%

    Dim i

    Dim J$

'To read it back in,

  H$ = Space$(80)

  x% = GetPrivateProfileString%("SECURITY", "PASSWORD", "PASSWORD",

H$,

Len(H$), "ENCRYPT.INI")

    Pass$ = text1

'fudge it for a blank password

    If Len(text1.Text) < 1 Then MsgBox "Enter a password!": Exit Sub

    H$ = Mid$(H$, 3, Val(Left$(H$, 2)))

Strg$ = ""

For i = 1 To Len(H$) Step 2

   J$ = Mid$(H$, i, 2)

   Strg$ = Strg$ + Chr$(Val("&H" + J$))

Next

'Strg$ would then contain the encrypted string, which you can now

'decrypt.

    Call Crypt(Pass$, Strg$)

    If InStr(Strg$, "theburiedpassword") Then

        MsgBox "Correct password"

        command3.Visible = True

        command4.Visible = True

    Else

        MsgBox "Incorrect password"

        command3.Visible = False

        command4.Visible = False

    End If

End Sub

Sub Command5_Click ()

    End

End Sub

Sub Crypt (Pass$, Strg$)

  Dim a

  Dim i

  Dim B

  a = 1

  For i = 1 To Len(Strg$)

     B = Asc(Mid$(Pass$, a, 1)): a = a + 1: If a > Len(Pass$) Then a = 1

     Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor B)

  Next

End Sub

Sub Form_Load ()

    readINI

End Sub

Sub readINI ()

    Dim x%

    H$ = Space$(80)

    x% = GetPrivateProfileString%("SECURITY", "PASSWORD",

"ohtheywillneverthinkofthis", H$, Len(H$),

"ENCRYPT.INI")

    If InStr(H$, "ohtheywillneverthinkofthis") Then

        command3.Visible = True

        command4.Visible = True

        label2.Caption = "Type a password in below and click on 'Encrypt

password'. This will hide the command

buttons below.  You will have to retype the password to see the command

buttons

again."

    Else

        command3.Visible = False

        command4.Visible = False

        label2.Caption = "You've already stored a password. Retype it and click

on 'Read in password' to see

the command buttons again. Delete the file encrypt.ini to reset the program."

        text2 = H$

    End If

End Sub

'End of code


Password encrypt

LUOKKA: VBgen

Date: 06/25/94 (14:15)              Number: 10500 of 10514 (Refer# NONE)

From: RAMI.RASANEN@P1.F73.N369.Z1.FIDONET.ORG

Subj: HowToStorePassWord

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here's a small example, while no "enigma machine", yet provides a simple

way of storing a password with encryption. The password is first encrypted

then converted to Hex. The reverse process will first convert to ascii

then decrypt. Thanks to Matt Hart for the code with some modifications

and changes.

The form has 2 Command buttons, one is Crypt, the other is DeCrypt.

'general section

Declare Function GetPrivateProfileInt% Lib "Kernel" (ByVal

lpApplicationName$,

ByVal lpKeyName$, ByVal nDefault%, ByVal lpFileName$)

Declare Function GetPrivateProfileString% Lib "Kernel" (ByVal

lpApplicationName$, ByVal lpKeyName As Any, ByVal lpDefault$, ByVal

lpReturnedString$, ByVal nSize%, ByVal lpFileName$)

Declare Function WritePrivateProfileString% Lib "Kernel" (ByVal

lpApplicationName$, ByVal lpKeyName$, ByVal lpString$, ByVal lplFileName$)

'Call the Crypt routine again the decrypt the Strg$.  Without the proper

'Pass$, you'll get garbage back.  The longer the password, the longer it

'takes to "number crunch" to figure out the password.

Dim Pass$

Dim Strg$

Dim H$

Sub Command1_Click ()

    Pass$ = "PASSWORD"

    Strg$ = "You won't crack this easily"

    Print "Original = "; Strg$

    Call Crypt(Pass$, Strg$)

    Print "Encrypted = "; Strg$

'When writing an encrypted password to a sequential access file like the

'INI files, you need to convert the resultant encrypted file to hex data.

'This is because you can end up with an encrypted password that contains

'characters which cannot be properly read using sequential access.  So,

'before saving your encrypted password, use this routine:

H$ = ""

For i = 1 To Len(Strg$)

   J$ = Hex$(Asc(Mid$(Strg$, i, 1)))

   If Len(J$) = 1 Then J$ = "0" + J$

   H$ = H$ + J$

Next

   Print "Hex = "; H$

'This will create a string like "0EF31105" or some such.  Save that to

'the INI file.

'Store the LENGTH of the password string as 2 bytes and concatenate

   H$ = Format$(Len(H$), "00") + H$

   x% = WritePrivateProfileString%("SECURITY", "PASSWORD", H$,

"E: PROJECT.INI")

End Sub

Sub Command2_Click ()

'To read it back in,

  H$ = Space$(80)

  x% = GetPrivateProfileString%("SECURITY", "PASSWORD", "PASSWORD",

H$,

Len(H$), "E: PROJECT.INI")

  Print "After INI read = "; H$

 'PASSWORD=160000000000000000

  H$ = Mid$(H$, 3, Val(Left$(H$, 2)))

  Print "Before hex conversion = "; H$

Strg$ = ""

For i = 1 To Len(H$) Step 2

   J$ = Mid$(H$, i, 2)

   Strg$ = Strg$ + Chr$(Val("&H" + J$))

Next

   Print "After hex conversion = "; Strg$

'Strg$ would then contain the encrypted string, which you can now

'decrypt.

    Call Crypt(Pass$, Strg$)

    Print "Decrypted = "; Strg$

End Sub

Sub Crypt (Pass$, Strg$)

  a = 1

  For i = 1 To Len(Strg$)

     B = Asc(Mid$(Pass$, a, 1)): a = a + 1: If a > Len(Pass$) Then a = 1

     Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor B)

  Next

End Sub


Password encrypt

LUOKKA: VBgen

2832 (49+)  Ian@monty.demon.co.uk  11.01.95  21:20

Ian Piper: "Re: Encryped Password File??"

> In a previous article, hirtle@manta.nosc.mil (Timothy L. Hirtle) says:

>

> >I wrote a program that allows password protected access. I store

> >the password and an activation variable in a binary file. I also

> >make this file hidden. I am uncomfortable with this method as an

> >experienced user could still get access to this file. I am looking

> >for a way to Encrypt and Decrypt the password, so the file is

> >unlegible to users using a text reader. Any ideas?

Below is a sample app which I developed, based on some encryption stuff

someone had previously posted here. It's not bombproof by any means,

but should deter casual prying. It works much like several of the other

suggestions put up here, with a couple of exceptions. The main one is

that rather than just using one word this uses an internal password in

combination with the password the user has typed in. The internal

password is created on the fly and should be unique, so even if you

choose the same user password the stored/encrypted password is different

every time.

Ian Piper

Note: this is a complete VB project, mak and frm files. You need to cut

this text and save it as frm and mak files to use it.

Take everything below the double line to

the next double line and save it as encrypt2.frm

Below this is encrypt2.mak

===================

VERSION 2.00

Begin Form Form1

   BorderStyle     =   3  'Fixed Double

   Caption         =   "Encryption demo"

   ClientHeight    =   3156

   ClientLeft      =   2136

   ClientTop       =   1668

   ClientWidth     =   5712

   Height          =   3576

   Left            =   2088

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   3156

   ScaleWidth      =   5712

   Top             =   1296

   Width           =   5808

   Begin TextBox Text2

      Height          =   624

      Left            =   1584

      MultiLine       =   -1  'True

      ScrollBars      =   1  'Horizontal

      TabIndex        =   9

      Top             =   1404

      Width           =   4008

   End

   Begin CommandButton Command5

      Caption         =   "E&xit"

      Height          =   372

      Left            =   4608

      TabIndex        =   4

      Top             =   2124

      Width           =   984

   End

   Begin CommandButton Command4

      Caption         =   "Hidden 2"

      Height          =   372

      Left            =   1656

      TabIndex        =   5

      Top             =   2628

      Width           =   1380

   End

   Begin CommandButton Command3

      BackColor       =   &H00000000&

      Caption         =   "Hidden 1"

      Height          =   372

      Left            =   180

      TabIndex        =   6

      Top             =   2628

      Width           =   1380

   End

   Begin CommandButton Command2

      Caption         =   "&Read in password"

      Height          =   372

      Left            =   2412

      TabIndex        =   2

      Top             =   2124

      Width           =   1992

   End

   Begin CommandButton Command1

      Caption         =   "&Store password"

      Height          =   372

      Left            =   180

      TabIndex        =   1

      Top             =   2124

      Width           =   1992

   End

   Begin TextBox Text1

      Height          =   372

      Left            =   1584

      TabIndex        =   0

      Top             =   936

      Width           =   4000

   End

   Begin Label Label3

      Alignment       =   1  'Right Justify

      Caption         =   "Stored as:"

      Height          =   300

      Left            =   216

      TabIndex        =   8

      Top             =   1440

      Width           =   1128

   End

   Begin Label Label2

      Caption         =   "Type a password in below and click on 'Store

password'. This will hide the command

buttons below.  You will have to retype the password to see the command

buttons again."

      Height          =   732

      Left            =   144

      TabIndex        =   7

      Top             =   72

      Width           =   5484

   End

   Begin Label Label1

      Alignment       =   1  'Right Justify

      Caption         =   "Password:"

      Height          =   300

      Left            =   396

      TabIndex        =   3

      Top             =   972

      Width           =   984

   End

End

Option Explicit

Declare Function GetPrivateProfileInt% Lib "Kernel" (ByVal

lpApplicationName$, ByVal lpKeyName$,

ByVal nDefault%, ByVal lpFileName$)

Declare Function GetPrivateProfileString% Lib "Kernel" (ByVal

lpApplicationName$, ByVal lpKeyName As

Any, ByVal lpDefault$, ByVal lpReturnedString$, ByVal nSize%, ByVal

lpFileName$)

Declare Function WritePrivateProfileString% Lib "Kernel" (ByVal

lpApplicationName$, ByVal lpKeyName$,

ByVal lpString$, ByVal lplFileName$)

Dim Pass$

Dim Strg$

Dim H$

Sub Command1_Click ()

    Dim i

    Dim J$

    Dim x%

    Dim msg$

    Pass$ = text1

'The next few lines build up a string from various items

'available on the computer, and should be unique every time

'it's used. This string is used as a complement to the password

'when doing the encryption.

'These are just examples, of course. You could probably think

'of other strings which are more difficult to predict.

    msg$ = Format$(Now, "ddmmyyhhmmss")

    msg$ = msg$ & LTrim$(Str$(FileLen("C:™config.sys")))

    msg$ = msg$ & "iopl99mj"

    msg$ = msg$ & LTrim$(Str$(FileLen("C:™autoexec.bat")))

    Strg$ = msg$

    Call Crypt(Pass$, Strg$)

'When writing an encrypted password to a sequential access file like the

'INI files, you need to convert the resultant encrypted file to hex data.

'This is because you can end up with an encrypted password that contains

'characters which cannot be properly read using sequential access.  So,

'before saving your encrypted password, use this routine:

H$ = ""

For i = 1 To Len(Strg$)

   J$ = Hex$(Asc(Mid$(Strg$, i, 1)))

   If Len(J$) = 1 Then J$ = "0" + J$

   H$ = H$ + J$

Next

'This will create a string like "0EF31105" or some such.  Save that to

'the INI file.

'Store the LENGTH of the password string as 2 bytes and concatenate

    H$ = Format$(Len(H$), "00") + H$

    x% = WritePrivateProfileString%("SECURITY", "PASSWORD", H$,

"ENCRYPT.INI")

'hide the buttons

    command3.Visible = False

    command4.Visible = False

    text2 = H$

End Sub

Sub Command2_Click ()

    Dim x%

    Dim i

    Dim J$

'To read it back in,

  H$ = Space$(80)

  x% = GetPrivateProfileString%("SECURITY", "PASSWORD", "PASSWORD",

H$, Len(H$),

"ENCRYPT.INI")

    Pass$ = text1

'fudge it for a blank password

    If Len(text1.Text) < 1 Then MsgBox "Enter a password!": Exit Sub

    H$ = Mid$(H$, 3, Val(Left$(H$, 2)))

Strg$ = ""

For i = 1 To Len(H$) Step 2

   J$ = Mid$(H$, i, 2)

   Strg$ = Strg$ + Chr$(Val("&H" + J$))

Next

'Strg$ would then contain the encrypted string, which you can now

'decrypt.

    Call Crypt(Pass$, Strg$)

    If InStr(Strg$, "iopl99mj") Then

        MsgBox "Correct password"

        command3.Visible = True

        command4.Visible = True

    Else

        MsgBox "Incorrect password"

        command3.Visible = False

        command4.Visible = False

    End If

End Sub

Sub Command5_Click ()

    End

End Sub

Sub Crypt (Pass$, Strg$)

  Dim a

  Dim i

  Dim B

  a = 1

  For i = 1 To Len(Strg$)

     B = Asc(Mid$(Pass$, a, 1)): a = a + 1: If a > Len(Pass$) Then a = 1

     Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor B)

  Next

End Sub

Sub Form_Load ()

    readINI

End Sub

Sub readINI ()

    Dim x%

    H$ = Space$(80)

    x% = GetPrivateProfileString%("SECURITY", "PASSWORD",

"ohratsnonesetyet", H$, Len(H$),

"ENCRYPT.INI")

    If InStr(H$, "ohratsnonesetyet") Then

        command3.Visible = True

        command4.Visible = True

        label2.Caption = "Type a password in below and click on 'Encrypt

password'. This will hide the

command buttons below.  You will have to retype the password to see the

command buttons again."

    Else

        command3.Visible = False

        command4.Visible = False

        label2.Caption = "You've already stored a password. Retype it and click

on 'Read in password' to see the

command buttons again. Delete the file encrypt.ini to reset the program."

        text2 = H$

    End If

End Sub

================================

Encrypt2.mak follows

=================================

ENCRYPT2.FRM

C:™WINDOWS™SYSTEM™CMDIALOG.VBX

C:™WINDOWS™SYSTEM™THREED.VBX

ProjWinSize=100,787,229,215

ProjWinShow=2

IconForm="Form1"

Title="ENCRYPT2"

ExeName="ENCRYPT2.EXE"

==================================


Password encrypt

LUOKKA: VBgen

2702 (23+)  combat@enterprise.america.com  10.01.95  00:54

combat: "Re: Encryped Password File??"

: >I wrote a program that allows password protected access. I store

: >the password and an activation variable in a binary file. I also

: >make this file hidden. I am uncomfortable with this method as an

: >experienced user could still get access to this file. I am looking

: >for a way to Encrypt and Decrypt the password, so the file is

: >unlegible to users using a text reader. Any ideas?

i recently implemented a password encryption method in one of my

vb programs.  i have a simple program that allows the setting of

the password.  the following code takes a variable of type string

and encrypts it.

For x = 1 To Len(str1)

    str2 = str2 & Chr$((Asc(Mid$(str1, x, 1)) + 25) Xor &hff)

Next x

this takes the next character, adds 25 to the ascii value, then

flips the bits from on to off and vice versa.  the variable str2

then contains the encrypted string, which i saved to a file.

then to decrypt it, you do a similar thing.

For x = 1 To Len(str2)

    str1 = str1 & Chr$((Asc(Mid$(str2, x, 1)) Xor &hff) - 25)

Next x

now str1 contains the decrypted version again.

hope this info helps ya some!

combat@america.com


Password encrypt

LUOKKA: VBgen

Date: 01/12/95 (17:18)              Number: 32283 of 32286 (Refer# NONE)

From: ED@EJFREED.DEMON.CO.UK

Subj: Re: Encryped Password File??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try using XOR encryption. There is an example of how to do this in the

in the Microsoft KB article below :-

How to Encrypt a String with Password Security in VB

Article ID: Q110308

---------------------------------------------------------------------

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0

---------------------------------------------------------------------

SUMMARY

=======

To restrict access by computer hackers, you can encrypt strings, such as

strings stored in your compiled executable .EXE program. Encryption helps

protect your program from unauthorized modifications.

The sample Visual Basic code below encrypts a string with the XOR operator

using password security. You can also adapt this technique to other

dialects of Basic or other languages.

MORE INFORMATION

================

Software tools for debugging and viewing binary code can easily find ASCII

strings stored in compiled executable .EXE programs. If you want to hide or

protect strings in .EXE programs, you can use techniques such as these:

 - Append a series of Chr$() functions in your Basic code. For example,

   the following string concatenates ASCII values 65 through 68, which

   represent the capital letters A through D:

      A$ = Chr$(65) + Chr$(66) + Chr$(67) + Chr$(68)

      Print A$

   This code prints ABCD. Since the ABCD is stored in code instead of in a

   string constant, it is not directly visible when viewed in a debugger.

   This method is okay for small amounts of data, but is inefficient for

   larger strings.

 - Add or subtract a constant or a letter's position value to the

   ASCII/ANSI value of each character in the string.

   NOTE: Don't exceed the byte value range of 0 to 255. For example, if you

   add 50 to the extended-ASCII character CHR$(230) and assign it to a

   string in Basic, you get an "Illegal function call" error.

 - Use the Xor function in a formula using a key or password string. Byte

   values changed with Xor always stay within the byte value range 0 to

   255. This technique is flexible and elegant. See the sample program in

   the next section below.

   NOTE: The Xor function is also known as the exclusive-OR function. An

   exclusive-OR means A or B, but not both. For example, if A is true,

   and B is false, then A Xor B is true, but if both A and B are true,

   then A Xor B is false.

 - Use third-party compression and encryption software, such as LZEXE or

   PKLITE, on the compiled executable EXE file. For secure encryption

   routines, see the QuickPak Professional Library from Crescent Software,

   Inc., shown in the Reference section below.

 - Keep a checksum to protect against viruses or hackers. You can keep a

   checksum of various important values in the program, and the program can

   refuse to run if any checksums have changed.

   NOTE: A checksum is an error-detection scheme that involves creating a

   sum of the bits in a set of bytes of data, then using that sum to later

   check for a change in the data.

Example of String Encryption Using Xor Function

-----------------------------------------------

Calling the Encrypt routine below encrypts a string using a password.

Calling the routine again decrypts the encrypted string.

1. Start a new project in Visual Basic. Form1 is created by default.

2. Add the following code to the Form Load event:

   Sub Form_Load ()

      form1.Show  ' Must Show form in Load event before Print is visible.

      secret$ = "This is the string that will be encrypted."

      PassWord$ = "password"

      Call Encrypt(secret$, PassWord$)     'Encrypt the string.

      Print " After encrypting it once: "  'Print the result.

      Print secret$

      Print

      Call Encrypt(secret$, PassWord$)  'A second encryption decrypts it.

      Print "After a second encryption: "

      Print secret$

   End Sub

3. Add the following Encrypt procedure to the general declarations section:

   Sub Encrypt (secret$, PassWord$)

      ' secret$ = the string you wish to encrypt or decrypt.

      ' PassWord$ = the password with which to encrypt the string.

      L = Len(PassWord$)

      For X = 1 To Len(secret$)

         Char = Asc(Mid$(PassWord$, (X Mod L) - L * ((X Mod L) = 0), 1))

         Mid$(secret$, X, 1) = Chr$(Asc(Mid$(secret$, X, 1)) Xor Char)

      Next

   End Sub

4. Start the program, or press the F5 key. Close the form to end the

   program.

Xor: The Exclusive-OR Operator

------------------------------

The exclusive-OR operator (Xor in the Basic language) performs a logical

exclusion on two expressions. For example:

   Result = expr1 Xor expr2

A useful behavior of Xor is that the first expression expr1 is returned

without losing any bits when you perform Result Xor expr2. This ability to

restore the first expression from the Result combined with the second

expression is why the Xor function is useful for encryption.

The Xor operator performs a bit-wise comparison of identically positioned

bits in two numeric expressions and sets the corresponding bit in the

result according to the following truth table:

   If bit in expr1 is:     And bit in expr2 is:    The result is:

   ---------------------------------------------------------------

         0                           0                    0

         0                           1                    1

         1                           0                    1

         1                           1                    0

ASCII and ANSI Character Sets

-----------------------------

For a listing of the ASCII and ANSI character sets, see the Help menu in

Visual Basic.

American Standard Code for Information Interchange (ASCII) is the 7-bit

character set widely used to represent letters and symbols found on a

standard United States keyboard. The ASCII character set is the same as the

first 128 characters (0 to 127) in the American National Standards

Institute (ANSI) character set. The ANSI character set uses all 8 bits in a

byte, and includes 256 characters (0 to 255). ANSI characters 128 to 255

are sometimes referred to as the extended-ASCII characters.

REFERENCES

==========

The following company offers encryption software and other products for

Basic:

   Crescent Software, Inc.

   11 Bailey Ave

   Ridgefield, CT  06877  USA

   Contact:  Don Malin  (203) 438-5300

   Fax: (203) 431-4626

   Ask about the QuickPak Professional Library for Windows.

Products from Crescent Software are manufactured independent of Microsoft.

Microsoft makes no warranty, implied or otherwise, regarding these

products' performance or reliability.

Additional reference words: 2.00 3.00

KBCategory: kbprg kbcode

KBSubcategory: PrgOther

Copyright 1993 Microsoft Corporation. All rights reserved.


Path runtime dir

LUOKKA: VBgen

Date: 07/07/94 (20:01)              Number: 11480 of 11683 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: path from setup?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sounds like you only need the runtime dir, use App.path.  If you need more

info, you'll need to do your own setup app which adds that stuff to your

private ini file during the install.

gt


Path stripp.filenames

LUOKKA: filenames

Date: 05/15/94 (11:20)              Number: 6183 of 6231 (Refer# NONE)

From: JMP2@TNTVAX.NTRS.COM

Subj: Re: Stripping filenames from fullpath filename...HELP

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I assume that you are not using the File list box control, or the answer would

be found there.  Given that, you simply need to parse your fullpath filename

backward (from the right) until you find a " ".  This could probably be done

several ways, but the first one that comes to mind is show below.

FName$ = (your fullpath filename)

For I = Len(FName$) to Len(FName$)-11 step -1

   If Mid$(FName$,I,1) = ' ' then

      Exit For

   End If

Next I

ShortFile$ = Right$(FName$,I-1)

The For/Next construct loops through the last 12 positions of the fullpath

filename looking for a " ".  When it is found, the loop is left, and the

position of the " " is used to extract the rightmost portion of the fullpath

filename.

You only need to search through 12 positions since a filename can only be

aaaaaaaa.aaa at the most.  This code should work as long as you can

guarantee that FName$ contains a valid fullpath filename.  Please note: I

have used this technique before but have not tested this particular piece of

code.

Joe Pappalardo


PC speakers sounds

LUOKKA: sounds

4029 (79+)  bp24mjh@texaco.com  27.01.95  00:21

"Mark J. Hogan": "Re: VBX that allows sound to play out of PC Speaker"

>

> Actually, you'd be more interested in downloading the PC speaker driver

> which accomplishes the same thing.  It would be in the directory of sundry

> Windows drivers on their softlib or MSDL directories.

Yes, then use these calls.

Declare Function sndPlaySound Lib "MMSYSTEM.DLL" (ByVal

lpszSoundName$, ByVal wFlags%) As Integer

Declare Function waveOutGetNumDevs Lib "MMSystem" () As Integer

Global Const SND_SYNC = &H0

Global Const SND_ASYN = &H1

Global Const SND_NODEFAULT = &H2

Global Const SND_LOOP = &H8

Global Const SND_NOSTOP = &H10

example:

x% = sndPlaySound("Tada.wav", SND_SYNC)

Mark Hogan


Performance

LUOKKA: Access

Date: 04-25-95 (04:52)              Number: 306507 of 307873 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: VB/ACCESS Performance

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>I'm  developing an application in VB with Access 2.0. I would like

>to hear from anybody who has experience with an Access 2.0 database

>having 30000-40000 records used by 5-6 users concurrently. Specifically,

>on these issues:

>- data retrieval time

>- locking conflicts and resolution

>- transactions

>- any other performance bottleneck.

>

>                                                   Jaspreet Singh

>                                                   R Systems India Pvt. Ltd.

>                                                   Noida, UP

>                                                   INDIA.

<---- End Included Message ---->

How about an Access Database with a VB front end accessing 10,000+

records with 40+ simutaneous users In a Microsoft LanManager network?

Item 1 - Data Retreival Time

Access times remainded pretty good.  No noticable draw down.

Item 2 - Locking conflicts and resolution

I had no problem using Optimistic record locking.  Use Dynasets, not bound

datacontrols, though.

Item 3 - Transactions

Definately use transactions, and build a secondary "Transaction Log file" for

the unexpected Power outages.  It gives you a really good recover option.

Item 4 - Bottlenecks

Avoid Find First, etc.  Restrict your active data to as small chunks as

possible. Use SQL query's extensively.

*********************************************************************

James G. Flippin, Jr.                           flippin@acm.org (USA)

Computer Specialist

U.S. Department of Veterans Affairs

Regional Office Waco

---------------------------------------------------------------------

Writing from Deep in the Heart of Texas (Waco, TX)

                                        äAKA: Six-Shooter Junctionå

---------------------------------------------------------------------

Running Under Windows NT 3.5 Server


PicBox disab. update

LUOKKA: PictureBox

Date: 11/29/94 (12:39)              Number: 28324 of 28326 (Refer# NONE)

From: ERS3@NS1.CC.LEHIGH.EDU

"Arjen Broeze": "Re: How do I _disable_ screen updates during "Print" to

PicBox?"

> I have two picture boxes which I am "Printing" formatted text out to.

> I also have label controls which are updated before or after the

> "printing".

> But it seems that there is some kind of automatic screen update

> after each "Print" statement which causes at least three separate

> printing events to be visible. And this is on a fast machine.

Take a look at the LockWindowUpdate function. This will lock the update

until you call the function again with a NULL parameter.

Declare Function LockWindowUpdate Lib "User" (Byval hWndLock As

Integer)   As Integer

Sub PrintSomething()

Dim iRes As Integer

    iRes = LockWindowUpdate(Picture1.hWnd)

    ' Print Something in Picture1

    iRes = LockWindowUpdate(Byval 0&)

End Sub

--

Arjen Broeze                                   Telephone: (+31)53-338666

arjen@shear.iaf.nl                             Address:   Gronausevoetpad 104


Picture remove

LUOKKA: PictureBox

Date: 10/20/94 (12:28)              Number: 23695 of 23771 (Refer# NONE)

From: RICKH@CV.HP.COM

Subj: Re: Remove picture property of a control at design time

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Yao Dong Gan (ygan@girtab.usc.edu) wrote:

: Hi there,

: I have read the FAQ about this subject. But the answer does not work.

: Yes, I can press Del key and clean the "bitmap" text, then the property

: window will still there after I press OK button.

: Only way is to press Cancel button or give another "picture" may be a

: blank bitmap can finish the step.

Follow these steps:

1...Single click on the form.

2...Single click on the Picture Property, that says (Bitmap)

3...Double click on the (Bitmap) text that is at the top of the

    Properties window. This will highlight the entire text.

4...Press your DELETE key on the keyboard.

5...The text should now read (None).


Picture remove/delete

LUOKKA: PictureBox

Date: 07-03-95 (03:44)              Number: 377588 of 378002 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Form.Picture = (none), HOW TO!!!?

From: Lasse Rantanen <lasse@RANTANE.PP.FI>

>On Fri, 30 Jun 1995, Martin Fastier wrote:

>> Once you have set the form.picture property to a specific Bitmap/File how

>> do you set it back to nothing/None!

>You click on the property setting line, where it says something like <bitmap>

>then hit ÄBackspaceÅ or ÄDelÅ & it should clear it.

>Les Ferguson <lhf@nzxray.galen.co.nz>

>Galen Group Ltd

>P.O.Box 105-354, Auckland Central, NZ.

Actually what you have to do is explained in Knowledge Base article

        PRB: Problem Changing Control's Picture to (None) in VB 3.0

        Article ID: Q108602

--- Start of quote -----

To work around this behavior, click the Picture property in the

Properties list before highlighting the (bitmap), (icon), or (metafile)

value. Or, change the focus to any other property on the Properties

window, then reselect the Picture property. The DEL key then

correctly deletes the (bitmap), (icon), or (metafile) value and changes

the value to (none). The graphic correctly disappears from the form or

picture control.

--- End of quote -----

However, to my experience only the first part of this is true (or because

I'm a Finn there might be something I don't understand). So when you want to

delete a picture assigned to the picture property, click on the picture

property line, double click on the property setting line, e.g. (bitmap) and

press DEL.

        Lasse


Picture remove/delete

LUOKKA: PictureBox

Date: 06/03/94 (11:58)              Number: 7756 of 7791 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Re(2): How to Set Picture to (none)?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sorry guys.  The problem is that you've hit upon the most frequently asked

question in the universe and everybody figures that somebody else will

answer.  It's a well known bug.  It's in the VB bug list.  It's just about

everywhere.  There's a lot of incantations for this beastie.  Just

remember to face the northwest when invoking any of them.

One of many.

click the offensive control

single click the pic property

hit the BS key (pun intended)

hit the Delete key

gt


Picture remove/delete

LUOKKA: PictureBox

Date: 10/13/94 (20:32)              Number: 22849 of 22884 (Refer# NONE)

From: MALCOLM.ROSS@DURHAM.AC.UK

Subj: Re: ÄQÅ: Remove an icon from something at design time. How ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: The only way I've been able to to this is to try to highlight the word

: "(bitmap)" in the picture property and hit delete. Try clicking on some

: other controls, and repeating if tha doesn't work. I've never been able

: to fully explain why this is.

Another way to do this is to click on the Properties window so that the

text cursor is in position to edit the word (Bitmap), press Home (or use

cursors to get to start of line) and press the Del key.  Occasionally,

even this doesn't work, in which case close the Properties window, reopen

it and try again.

The same procedure works for getting rid of form icons.


PictureBox copy scree

LUOKKA: PictureBox

Date: 09/09/94 (03:18)              Number: 18792 of 18922 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Screen capture

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You'll have to look up the api-declarations yourself but the following

code does exactly what you want (copy the screen into a picturebox

(ScaleMode PIXELS and copy the picturebox to the clipboard (the PictureBox

doesn't have to be visible)):

    hDCScreen = GetDC(0)

    Picture1.Width = Screen.Width   Screen.TwipsPerPixelX

    Picture1.Height = Screen.Height   Screen.TwipsPerPixelY

    Picture1.AutoRedraw = True

    R = BitBlt(Picture1.hDc, 0, 0, Picture.Width, Picture1.Height, hDCScreen,

      0, 0, SRCCOPY)

    Picture1.AutoRedraw = False

    ReleaseDC(0, hDCScreen)

    ClipBoard.SetData Picture1.Image

--

Arjen Broeze                                   Telephone: (+31)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13

                                                          7533 VR Enschede, NL


PictureBox ctl array1

LUOKKA: PictureBox

Date: 08/10/94 (23:32)              Number: 15130 of 15159 (Refer# NONE)

From: JPRUITT@HQ.WALLDATA.COM

Subj: Re: 1 routine for 3 different picture boxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I need some help. I have 2 forms. Form1 has 3 option buttons. Form2 has 3

>picture boxes with text boxes placed in them (one for address info, one

>for family info and one for job info).

>The picture boxes are saved on the form as very small boxes, but when an

>option button is clicked, the appropriate picture box is enlarged.

>What I'd like to do is write one routine for resizing the picture boxes:

>        PictureX.Height = 2100

>        PictureX.Left = 120

>        PictureX.Top = 120

>        PictureX.Width = 6500

>        (where PictureX will refer to Picture1, Picture2 or Picture3)

>For ex: show Form1

>        click option1

>        call resize_picturebox

>        show Form2 with Picture1 Visible and enlarged

>or      show Form1

>        click option2

>        call resize_picturebox

>        show Form2 with Picture2 Visible and enlarged

>I'd like some help on how to pass the picture box control name to the

>call resize_picturebox routine so that no matter which option I select,

>the correct picture box will be resized and visible.

If you have VB3.0 then you can use control arrays to do what you want.

All you have to do is create the three buttons and three picture boxes as

control arrays (ie. controls with the same names).  Control arrays are great

because you only have to have one function for each array not one for each

button/picturebox.

The functions would then look somewhat like the following

' User Defined Resize Function

Sub Resize_PictureBox(Index As Integer)

     Picture1(Index).Height = 2100

     Picture1(Index).Left = 120

     Picture1(Index).Top = 120

     Picture1(Index)Width = 6500

     ' or use Picture1(Index).Move 120, 120, 6500, 2100

End Sub

'Click function for Command1 pushbutton

Sub Command1_Click(Index As Integer)

     Resize_PictureBox(Index)

End Sub

Joe Pruitt

WALL DATA Inc.

jpruitt@hq.walldata.com


PictureBox ctl array2

LUOKKA: PictureBox

Date: 08/12/94 (01:00)              Number: 15250 of 15271 (Refer# NONE)

From: CFIELDS@NANDO.NET

Subj: Re: 1 routine for 3 different picture boxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>>I need some help. I have 2 forms. Form1 has 3 option buttons. Form2 has 3

>>picture boxes with text boxes placed in them (one for address info, one

>>for family info and one for job info).

>>What I'd like to do is write one routine for resizing the picture boxes:

Thanks to everyone who responded to this question. Here is a summary of

the responses:

 1) setup routine...Sub PicResize(p as PictureBox)

        p.Height = 1200

        ...

        p.Top = 120

        End Sub

    from Form1      Call PicResize(Form2.Picture1)

 2) use control arrays...Sub PicResize(Index As Integer)

      Picture1(Index).Height = 1200

      ...

      Picture1(Index).Top = 120

        or   Picture1(Index).Move 120, 120, 6500, 1200

    End Sub

    from Form1    Call PicResize(Index)

 3) set up routine... Sub PicResize(PictureX as Control)

      PictureX.Height = 1200

      ...

      PictureX.Top = 120

    End Sub

    from Form1    Call PicResize Form2.Picture1

Other suggestions didnot include code, but instructed me to create

control arrays, to create a routine to resize, and make use of indexes.

Based on a little of all of the helpful answers here is the coding I used:

 1) In module1.bas....Sub PicResize(Picture as Control)

    Picture.Move 120, 120, 1200, 6500

        End Sub

 2) On option1........Call PicResize(Form2.Picture1)

    On option2........Call PicResize(Form2.Picture2)

       On option3........Call PicResize(Form2.Picture3)

So far, this is working just fine. I greatly appreciate all of your

suggestions. My problem was how to pass from optionbutton on form1 to the

resize routine and what went into the parentheses. You all showed me what

I should do.

Cassandra.....cfields@nando.net


Postlists

LUOKKA: internet

Date: 11/18/94 (11:37)              Number: 131514 of 131870 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Repost - VB FAQ Info and other goodies

Read: NO                            Status: RECEIVER ONLY

---------------

You can have the VB FAQs e-mailed to you by sending a message

to "mail-server@rtfm.mit.edu" with ONLY the text

     send usenet/news.answers/visual-basic-faq/*

     in the BODY of the message.

Be informed that the response will include all parts of the VB FAQ and will

result in the reception of several mail messages.

---------------

Most FAQs (including this one) are available at the anonymous ftp archive

site "rtfm.mit.edu".  All parts of the VB FAQ may be found in the directory

"pub/usenet/comp.lang.basic.visual".

-------------------------------------------

List Server Housekeeping hints:

-------------------------------------------

Please Note that all LISTSERV housekeeping messages require blank

Subject

lines and only the command in the body of the message.

IMPORTANT: These messages must be mailed only to

LISTSERV@tamvm1.tamu.edu

and NOT to the general readership at VISBAS-L

> Would someone 'kindly' tell me how to unsubscribe to this list?

Inform the LISTSERV to remove your name from it's mailing list.

note: some list servers require UNSUBSCRIBE, ours requires SIGNOFF.

              To: LISTSERV@tamvm1.tamu.edu

       Subject:

        ----------------

        SIGNOFF VISBAS-L

>I'm being inundated by too many VISBAS-L messages!

Inform the LISTSERV to send you a composite message daily via it's

DIGESTS

option.

                To: LISTSERV@tamvm1.tamu.edu

        Subject:

         ----------------

        SET VISBAS-L DIGESTS

>I'm going on vacation, How do I place my mail on hold and restart when I

return?

Inform the LISTSERV to

                To: LISTSERV@tamvm1.tamu.edu

        Subject:

        ----------------

        SET VISBAS-L NOMAIL

>I'M back from vacation and wish to reactivate the list

                To: LISTSERV@tamvm1.tamu.edu

        Subject:

        ----------------

        SET VISBAS-L MAIL

>I told a friend about this list and have forgotten the proper message

syntax to subscribe.

Send the following message to our list server (note: discard the 2nd message

line if the digests option is unwanted).

                To: LISTSERV@tamvm1.tamu.edu

        Subject:

        ----------------

        SUBSCRIBE VISBAS-L John Doe

        SET VISBAS-L DIGESTS

=======================

Other VB related sources

=======================

>New subscribers may be interested in Database/VB related issues at:

                To: LISTSERV@TAMVM1.TAMU.EDU

        Subject:

        ----------------

        SUBSCRIBE VBDATA-L John Doe

        SET VBDATA-L DIGEST

> Does anyone know the listserv addres for the MS ACCESS list?

                To: LISTSERV@INDYCMS.BITNET

        Subject:

        ----------------

        SUBSCRIBE ACCESS-L John Doe

        SET ACCESS-L DIGEST

> Does anyone know the listserv addres for the MS ACCESS list?

                To: LISTSERV@INDYCMS.BITNET

        Subject:

        ----------------

        SUBSCRIBE ACCESS-L John Doe

        SET ACCESS-L DIGEST

>What is the name of the VB newsgroup on the Usenet?

        comp.lang.basic.visual

======================

General VB Programmer Interest Groups

WIN3-L            LISTSERV@UICVM.UIC.EDU

                 Microsoft Windows Version 3 Forum

WFW-L           LISTSERV@UMDD.UMD.EDU

                Microsoft Windows For Workgroups Forum

                (very busy!)

WINHLP-L      LISTSERV@HUMBER.BITNET

                 Windows Help Compiler (WINHELP) Discussion List

                -or-

WINHLP-L - Windows Help Compiler (WINHELP) Discussion List

        Server: LISTSERV@ADMIN.HUMBERC.ON.CA

        Syntax: Subscribe WINHLP-L  firstname   lastname

                Unsubscribe WINHLP-L

        Owner:  YARDY@ADMIN.HUMBERC.ON.CA,

BYRNES@ADMIN.HUMBERC.ON.CA

======================

Additional General VB Programmer Interest Areas

>***************************************************************************

>Edupage, a summary of news items on information technology, is provided

>three times each week as a service by Educom -- a Washington, D.C.-based

>consortium of leading colleges and universities seeking to transform

>education through the use of information technology.

>EDUPAGE is what you've just finished reading. To subscribe to Edupage:

send

>a message to: listproc@educom.edu and in the BODY of the message type:

>subscribe edupage Moe Howard (assuming that your name is Moe Howard; if

it

>isn't, substitute your own name) ... To cancel subscription to Edupage:

>send a message to: listproc@educom.edu and in the BODY of the message

type:

>unsubscribe edupage.   Edupage is also available in Portuguese and

Spanish;

> to subscribe, send mail to edunews@nc-rj.rnp.br.

>look at our WWW server: URL:  http://educom.edu/. To communicate with

>Edupage or Educom, send mail to COMMENTS@educom.edu or

INFO@educom.edu.

--------------------------------------------

=======================================================

please remember to send Subscribe messages to LISTSERV not to an -L

address!


Preview

LUOKKA: printing

Date: 06/26/94 (12:23)              Number: 10621 of 10664 (Refer# NONE)

From: BRADSPIES@DELPHI.COM

Subj: Re: Print preview in VB?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If you have Crystal Reports you have a print preview capability.

Robert W. Bradspies - bradspies@delphi.com - 73520,1636


Preview

LUOKKA: printing

Date: 08/23/94 (23:13)              Number: 16758 of 16834 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Implementing "Print Preview"?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Do it the way most programs do it:

Create a metafile and print to it using the standard windows API functions

(DrawText, BitBlt, StretchBlt, MoveTo, LineTo, Rectangle etc).

You can display this metafile in any size in a picturebox, by simply resizing

the picturebox.

You can even StretchBlt this metafile to the printer to get a perfect

printout.

--

Arjen Broeze                                   Telephone: (+31)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13


Preview

LUOKKA: printing

Date: 08/29/94 (16:34)              Number: 17742 of 17760 (Refer# NONE)

From: MSYS@KBT.COM

Subj: Re: print preview!!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

VideoSoft (makers of VSVBX) are just about to release a new package,

entitled VSVIEW... it contains a printer object with print preview

capabilities.. I've seen the beta, and it looks good. Watch for it on

CICA or CI$ (MSBasic forum).

nb

'                                                               '

'  Norm Bernstein             Hard/Firm/Software Consulting     '

'  Marisystems, Inc.          (circuits/8051/VB & Pascal)       '

'  msys@kbt.com    Cserve:71121,1070   landline: (617) 341-3611 '


Preview

LUOKKA: printing

=============================================================

Date:         Thu, 6 Oct 1994 14:25:00 PDT

From:         "Olafur Orn Jonsson, P&S" <oliorn@SIMI.IS>

Subject:      scrolling printouts

>I'm working on a program that allows printing to forms and the printer.  My

>problem is with printing to forms.  When output is sent to the printer,

>stuff that is longer than one page is no problem.  But, a form does not allow

>scrolling.  How can I get my output on a form that the user can scroll?

create picture control and a vertical scrollbar (You can have horizontal

scrollbar to).  Print the stuff to the picture and with the scrollbars you

scroll the picture up and down, left and right  on the form. The picture

control will probably be bigger than the form.  If the user resizes the

form you do not change the size of the picture.  Then you have the scroll

you need.

If you do not want the picture to take the whole form you can create that

picture inside another picture control and then that control controls the

size of the scroll area.  When the user resizes the form you change the

size of the outer picturebox.

Oli

Olafur Orn Jonsson, Iceland

internet e-mail : oliorn@simi.is


Printer ch.orientatio

LUOKKA: printing

Date: 12/29/94 (12:00)              Number: 31124 of 31236 (Refer# NONE)

From: GAVAN

Subj: Re: API call to change printer orientation??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Is there a simple Windows API call I can use inside VB to change the

>default >printer orientation from portrait to landscape & back again?  I

>couldn't find anything usable sifting through the C documentation that VB

>comes with.

Type orientstructure

  orientation As Long

     pad As String * 16

  End Type

Declare Function escape% Lib "GDI" (ByVal hDC%, ByVal nesc%, ByVal

nlen%, lpdata As orientstructure, lpout As Any)

Function printer_orientation% (isportrait%)

'set printer to either portrait or landscape

'return current orientation before change

    Const portrait = 1

    Const landscape = 2

    Const GETSETPAPERORIENT = 30

    Dim orient As orientstructure

    If isportrait% = portrait Or isportrait% = True Then

        orient.orientation = portrait

    Else

        orient.orientation = landscape

    End If

    printer_orientation = escape(printer.hDC, GETSETPAPERORIENT,

    Len(orient), orient, Null)

    printer.EndDoc

End Function


Printer change

LUOKKA: printing

3. How can I change the printer Windows uses in code without using the

   print common dialog? How can I change orientation?

   You can change the printer the VB 3.0 Printer object is pointing to

   programmatically (without using the common dialogs). Just use the

   WriteProfileString API call and rewrite the ÄWINDOWSÅ,  DEVICE entry in

   the WIN.INI file!  VB will instantly use the new printer, when the next

   Printer.Print command is issued. If you get the old printer string

   before you rewrite it (GetProfileString API call), you can set it back

   after using a specific printer. This technique is especially useful,

   when you want to use a FAX printer driver: Select the FAX driver, send

   your fax by printing to it and switch back to the normal default

   printer.

   ÄHajo Schmidt (hajo@bwl.bwl.th-darmstadt.de)Å

   It is recommended (and polite, as we're multitasking) to send a

   WM_WININCHANGE (&H1A) to all windows to tell them of the change.

Also,

   under some circumstances the printer object won't notice that you have

   changed the default printer unless you do this.

     Declare Function SendMessage(ByVal hWnd As Integer,

     öByVal wMsg As Integer, ByVal wParam As Integer,

     ölParam As Any) As Long

     Global Const WM_WININICHANGE = &H1A

     Global Const HWND_BROADCAST = &HFFFF

     ' Dummy means send to all top windows.

     ' Send name of changed section as lParam.

     lRes = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0,

     öByVal "Windows")

   ÄNic Gibson (nic@skin.demon.co.uk)Å

   To change between landscape and portrait orientation, search of VBKB_FT

   on "lands*" finds Article ID: Q80185 "How to Set Landscape or Portrait

   for Printer from VB App".

   This is an extract:

     Declare Function Escape% Lib "GDI" (ByVal hDC%, ByVal nEsc%, ByVal

nLen%,

       ölpData As Any, lpOut As Any)

     Sub Command1_Click ()

        Const PORTRAIT = 1

        Const LANDSCAPE = 2

        Const GETSETPAPERORIENT = 30

        Dim Orient As OrientStructure

        Printer.Print ""

        Orient.Orientation = LANDSCAPE

        x% = Escape(Printer.hDC, GETSETPAPERORIENT, Len(Orient), "",

Null)

        Print x%

     End Sub

   ÄAyn Shipley (ashipley@hookup.net)Å


Printer controlling

LUOKKA: printing

Printer Control

---------------------

A user can control *everything* (printer, paper size, orientation, print quality,

etc.) from within the print setup common dialog.  In fact, here is all the code

you need:

Sub FilePrintSetup_Click ()

Dim Msg$

    On Error GoTo FilePrintSetupError

    CMDialog1.Flags = PD_PRINTSETUP     ' Just enable print setup

    CMDialog1.Action = DLG_PRINT        ' Show printer setup dialog box

PrintSetupExit:

    Exit Sub

FilePrintSetupError:

    If Err <> CDERR_CANCEL Then         ' If user didn't select CANCEL

        Beep

        Msg$ = "Error" & Str$(Err) & ": " & Error$

        MsgBox Msg$, MB_ICONEXCLAMATION, "Error"

    End If

    Resume PrintSetupExit

End Sub

The capitalized constants are defined in CONSTANT.TXT.  You do need t to

set the CancelError property to True if you want the CDERR_CANCEL error to

indicate the user pressed Cancel.  (Even this really isn't needed, though).

Submitted By:  Stephen C. Smith


Printer controlling

LUOKKA: printing

Date: 12/09/94 (07:52)              Number: 148727 of 149212 (Refer# NONE)

Subj: Re: Printing *.prn files

From: David Musgrove <dwm@DLD.DIRCON.CO.UK>

>Is this to posible to print from VB a binary printer file (*.prn) directly

>to printer, without shell to DOS via ex. "copy /b dummy.prn lpt1"?

From the VB Knowledge base - it may help:

Using PASSTHROUGH Escape to Send Data Directly to Printer

Article ID: Q96795

Summary:

By using the Windows API Escape() function, your application can pass data

directly to the printer. If the printer driver supports the PASSTHROUGH

printer escape, you can use the Escape() function and the PASSTHROUGH

printer escape to send native printer language codes to the printer driver.

Printer escapes such as PASSTHROUGH allow applications to access

certain

facilities of output devices that are not directly available through the

graphics device interface (GDI). The PASSTHROUGH printer escape allows

the application to send data directly to the printer, bypassing the

standard print-driver code.

More Information:

A printer driver that supports the PASSTHROUGH printer escape does not

add

native printer language codes to the data stream sent to the printer, so

you can send data directly to the printer. However, Microsoft recommends

that applications not perform functions that consume printer memory, such

as downloading a font or a macro.

The sample program listed below sends native PCL codes to the printer to

change the page orientation and the paper bin. A Hewlett-Packard LaserJet

is the assumed default printer.

An Important Note

-----------------

The Windows API Escape() function used below is provided in Windows

version 3.0 and later for backward compatibility with earlier versions of

Microsoft Windows. New applications should use the GDI

DeviceCapabilities() and ExtDeviceMode() functions instead of the Escape()

function shown below.

In order to use the ExtDeviceMode() function, you need to create a DLL

because the ExtDeviceMode() function is exported by the printer driver, not

by the Windows GDI. To execute the ExtDeviceMode() function, you need to

obtain a function pointer to it from the current printer driver. Visual

Basic does not support pointers.

Steps to Create Example

-----------------------

1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)

   if Visual Basic is already running. Form1 is created by default.

2. Add the following code to the general declarations section of Form1:

   ' Enter the entire Declare statement on one, single line.

   Declare Function Escape Lib "Gdi" (ByVal Hdc%, ByVal nEscape%,

      ByVal ncount%, ByVal indata$, ByVal oudata$) As Integer

   Const PASSTHROUGH = 19

   Const RevLandScape = "&l3O" ' PCL command to change Paper

                                                              ' orientation to Reverse

Landscape.

   Const Portrait = "&l0O"     ' PCL command to change paper

                                                    ' orientation to Portrait.

   Const ManualFeed = "&l3H"   ' PCL command to change Paper Bin

                                                          ' to Manual Feed Envelope.

   Const AutoFeed = "&l1H"     ' PCL command to change Paper Bin

                                                       ' to Paper Tray AutoFeed

3. Add a list box (List1) to Form1.

4. Add the following code to Form1's Form_Load event procedure:

   Sub Form_Load ()

     List1.AddItem "HP/PCL Reverse Landscape"

     List1.AddItem "HP/PCL Portrait"

     List1.AddItem "HP/PCL Manual Feed Envelope"

     List1.AddItem "HP/PCL Paper Tray Auto Feed"

   End Sub

5. Add the following code to the List1_Click event procedure:

   Sub List1_Click

   Select Case List1.ListIndex

      Case 0:

         PCL_Escape$ = Chr$(27) + RevLandScape

      Case 1:

         PCL_Escape$ = Chr$(27) + Portrait

      Case 2:

         PCL_Escape$ = Chr$(27) + ManualFeed

      Case 3:

         PCL_Escape$ = Chr$(27) + AutoFeed

   End Select

   PCL_Escape$ = Chr$(Len(PCL_Escape$)) + PCL_Escape$ + Chr$(0)

   ' Enter the entire Result% statement on one, single line.

   Result% = Escape%(Printer.hDC, PASSTHROUGH, Len(PCL_Escape$),

       PCL_Escape$, "")

   Select Case Result%

      ' Enter each Case statement on one, single line.

      Case Is < 0: MsgBox "The PASSTHROUGH Escape is not

         supported by this printer driver.", 48

      Case 0: MsgBox "An error occurred sending the escape

         sequence.", 48

      Case Is > 0: MsgBox "Escape Successfully sent.

         Sending test printout to printer."

      Printer.Print "Test case of "; List1.Text

   End Select

   End Sub

6. From the Run menu, choose Start (ALT, R, S) to run the program. List1 is

   filled with four escape sequences to send to the printer.

7. Select any of the options in the list box. A message box appears to

   indicate the success of the operation.

If the printer driver does not support the PASSTHROUGH printer escape, you

must use the DeviceCapabilities() and ExtDevMode() functions instead.

I don't know if this will sort you out - my printer driver doesn't support

the PASSTHROUGH printer escape! (It's only a LaserJet 4MP: if it doesn't

work with this then this may prove to be not a very reliable method anyway).

You'll need to chunk the .PRN file into string length segments, but with

Open As Binary this is easy enough. Anyway, good luck with it.

==========================================================

David Musgrove

Telephone: +44 (0)171 229 1449    Fax: +44 (0)171 727 0281


Printer controlling

LUOKKA: printing

Päivä: 01-19-95 (13:36)             Numero: 277 / 283 (Vast. nro 273)

Knlle: ILKKA MAATTA

Knltä: SAMI PITKO

 Aihe: Printteri porttia

Luettu: 01-19-95 (17:33)              Tila: Julkinen viesti

 Kok.: Ohjelmointi (23)           Lukumalli: Yleinen (A) (+)

>Onnistuuko VisualBasic:lla lpt portin ohjaminen jollain VBX:llä

>tms vastaavsti kuin COM portinkin?

1) Jos Printer objektin tarjoamat palvelut riittävät, niin tulostaminen

on helppoa. Kaikki tulostus menee oletusprintterille printteridriverin

läpi.

    Printer.FontName = "Arial"

    Printer.FontSize = 10

    Printer.Print "Koetulostus"

    Printer.NewPage

    Printer.Print "Seuraava sivu"

    Printer.EndDoc

Oletusprintterin vaihto menee API-käskyjen käyttämiseksi.

2) Jos haluat ohjata printteridriverin ohitse dataa, käytä porttia

seuraavalla tavalla:

    Open "LPT1" For Output As #1

    Print #1, "Koetulostus"

    Print #1, Chr$(27);"&l0H";  ' Eject Laserjet page using PCL

    Close #1

3) Jos taasen haluat k„yttää printteriporttia 8-bittisenä

digitaalilähtönä, niin joudut etsimään jostain IOVBX.ZIPin (tai

vastaava) jossa on IOPORT.VBX. Sillä voit ohjata IO-portteja kuten

QuickBasicin INP ja OUT käskyillä.

Spitco


Printer orientation

LUOKKA: printing

1110 (12+)  itaylor@homegrove.win-uk.net  30.11.94  20:49

Ian R Taylor: "Re: Printing orientation"

Declare Function Escape% Lib "GDI" (ByVal hDC%, ByVal nEsc%

   , ByVal nLen%, lpData As OrientStructure, lpOut As Any)

    Const PORTRAIT = 1

    Const LANDSCAPE = 2

    Const GETSETPAPERORIENT = 30

    Const NOUGHT = 0&

    Dim Orient As OrientStructure

    Printer.Print

    Orient.Orientation = PORTRAIT

    x% = Escape(Printer.hDC, GETSETPAPERORIENT, Len(Orient), Orient,

  NOUGHT)


Printer orientation

LUOKKA: printing

Date: 06-20-95 (10:35)              Number: 367772 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Printer Orientation Again

      If you have a moment, tell me if you have achieved a fourth means to

 change the printer orientation from within VB.  The methods I have

discussed

 and replied with are:

 1. Common Dialog

 2. Using the escape API

                Declare Function Escape% Lib "GDI" (ByVal hDc%, ByVal nEsc%,

                                ByVal nLen%, lpData As OrientStructure, lpOut

 As Any)

 3. Creating a separate device context for the printer and bypassing the VB

 printer object altogether.

 Problems with all three, no need to rehash it with you, I'm sure you know.

  My question is: Is there a way that you know of reinitialize the printer in

 method 2. without ejecting a blank page?  i.e

 Sub Command1_Click ()

   Const PORTRAIT = 1

   Const LANDSCAPE = 2

   Const GETSETPAPERORIENT = 30

   Const NULL = 0&

   Dim Orient As OrientStructure

     Printer.Print ""

     Orient.Orientation = LANDSCAPE

     x% = Escape(Printer.hDC, GETSETPAPERORIENT,

                 Len(Orient), Orient, NULL)

     Printer.EndDoc

     Printer.Print "Should print in landscape mode"

     Printer.EndDoc

 End Sub

 If you can solve this puzzle, you can have lunch on me.....

 M.Williams

See: Managing Your Print Jobs, Part 2(From Inside Visual Basic for

Windows, Cobb, Dec 1994) on the next issue of MSDN CD) ....Ž I'm the

lucky person who selects the journal articles that goes on the CD.�

Also: A Print Preview Program for Visual Basic (From Inside Visual

Basic for Windows, Cobb, May 1994) on the currentissue of MSDN CD)

To set  the printer to landscape without ejecting a blank page you can

use the function  AbordDoc :

Sub Command1_Click ()

   Const PORTRAIT = 1

   Const LANDSCAPE = 2

   Const GETSETPAPERORIENT = 30

   Const NULL = 0&

   Dim Orient As OrientStructure

* Dim ret as Integer

     Printer.Print ""

     Orient.Orientation = LANDSCAPE

     x% = Escape(Printer.hDC, GETSETPAPERORIENT,

                 Len(Orient), Orient, NULL)

*   On Errior Resume Next

*   ret = AbordDoc(Printer.hdc)

*   On Error Resume Goto 0

     Printer.EndDoc

     Printer.Print "Should print in landscape mode"

     Printer.EndDoc

 End Sub

 Ken,

Ken,

     The code above was the thing I needed to really get a handle on the

problem.  I am impressed.  I would however like to alter it in a couple of

lines to remove a nasty printer error that pops up now and again.  I traced

it the AbortDoc GDI function.  For some reason the Printer.EndDoc generates

an error after the call is made.  I had Appleman's help on this...pp.521.  To

correct this I just altered the error trap a little.  Other than this it

works like a charm.  Listed below:

GLOBAL DECLARATIONS

Option Explicit

Type OrientStructure

  Orientation As Long

  Pad As String * 16

End Type

Declare Function AbortDoc% Lib "GDI" (ByVal hDC%)

Declare Function Escape% Lib "GDI" (ByVal hDC%, ByVal nEsc%, ByVal

nLen%,

lpData As OrientStructure, lpOut As Any)

TEST COMMAND BUTTON ON FORM1

Sub Command1_Click ()

On Error GoTo prnFX

   Const PORTRAIT = 1

   Const LANDSCAPE = 2

   Const GETSETPRINTORIENT = 30

   Const Null1 = 0&

   Dim Orient As OrientStructure

   Dim ret As Integer

   Dim x As Integer

     Printer.Print ""

     Orient.Orientation = LANDSCAPE

     x = Escape(Printer.hDC, GETSETPRINTORIENT, Len(Orient), Orient,

Null1)

     ret = AbortDoc(Printer.hDC) '<<<Cancels the first Print call above.>>>

   Printer.EndDoc                     '<<<This EndDoc will generate an

error>>>

   Printer.Print "Tell the author of this routine he did a fine job"

   Printer.EndDoc

prnFX:

   If Err > 0 Then

      Resume Next

   End If

End Sub

     Also, anyone using this routine may want to change the printer DC back

to portrait if he/she wishes to continue printing other documents.  I created

two global subs called PrnPortrait and PrnLandScape to simplify.  The credit

should go to kenl@MICROSOFT.COM (Kenneth Lassesen).   Thanks again.

M.Williams


Printer printer ready

LUOKKA: printing

Date: 06-18-95 (00:15)              Number: 366222 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Is Printer Ready????

>        IF Not IsPrinterReady(1) Then   'NOTE: If you have your

printer

>attached to another port change the parameter as parameter.

>                                                     ' (ej. LPT2, send2 )

>                MsgBox "The printer is not ready"

>        Else

>              ....

>        End If

>

>

>Rem *******************

>Function IsPrinterReady (ByVal Port As Integer) As Integer

> On Error GoTo PrinterNotReady

> Dim FileNum, OK

>        FileNum =3D FreeFile

>        OK =3D True

>        Open "LPT" & Port For Output As FileNum

>        Print #FileNum, Tab(5); Tab(0);

>       'Test if the printer is ready

>        Close FileNum

>

>IsPrinterReady =3D OK

>Exit Function

>

>PrinterNotReady:

>        OK =3D False

>        Resume Next

>     =20

>End Function

The function you suggested works beautifully. I really appreciate your

assistance.

Al Balzowski


Printing change orien

LUOKKA: printing

Date: 11/25/94 (09:47)              Number: 27940 of 27960 (Refer# NONE)

From: PELICAN@ONRAMP.NET

Subj: Re: Change print orientation w/wm_wininichange

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Check out pprtr44.zip at cica, garbo and simtel mirrors, e.g. oak.oakland.edu

in /simtel/win3/dll:

  Windows DLL providing higher-level language access via functions to

  retrieve and change all printer attributes available via  ExtDevMode in

  DEVMODE structure (orientation, pagesize, etc).  Also  get list of

  available printers, get/change default printer, get port, get printer

  device capabilities.  Shareware $10. CIS SWREG available (#1462).

---------------------

Paul F Poellinger              2019 Round Lake Drive

Silent O Software              Houston, TX  77077

pelican@onramp.net   Compuserve: 70732,3576   AOL: PFPelican


Printing device FILE

LUOKKA: printing

===========

Date:         Wed, 14 Sep 1994 10:59:45 +22304916

From:         Marc Moshman <mmoshman@IMFAIX2S.IMF.ORG>

Subject:      Printing to a File

> Is there any way to specify the filename that is used when you

> connect the Generic/text only printer to the device FILE.

You can hard-code the filename by doing the following:

a) In WIN.INI, in the [ports] section, add a path\filename= line, e.g.,

   [ports]

   C:\FILES\MYREPORT.OUT=

b) Then, from the control panel, printers icon, highlight the Generic/text

   printer and select the Connect button.  Connect the printer to the

   C:\FILES\MYREPORT.OUT 'port', or whatever you named it.

This technique works on any printer you've installed, not just the Generic/

text one.

// Marc //

mmoshman@imfaix2s.imf.org


Printing graph

LUOKKA: printing

Date: 05/24/94 (20:46)              Number: 6793 of 6809 (Refer# NONE)

 From: PANU.JUVONEN@HUT.FI

Subj: Re: Graph Printing Question ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

   ilathwel@rpms.ac.uk (Ian Lathwell) writes:

>Anyone know if you can print a graph (using the GRAPH control) on the

>same page with some text, printed with the Printer object.

I did it by first taking a copy of the graph to the clipboard as a metafile

(the Graph control supports this directly) and then taking that metafile

and printing it on the page with some API calls. Wasn't very easy actually

(and I did it only with the help of some examples I saw here and in some

other places), but works quite well. I haven't got the code here now, but

if I remember to (and someone wants me to), I might post it sometime

later...

The graph is printed on the Printer object with the DC it provides, so

you can use Printer to print the other stuff on the same page.

--

Panu Juvonen


Printing long names

LUOKKA: printing

Date: 12/27/94 (07:08)              Number: 30917 of 30948 (Refer# NONE)

From: ANDYB@ACCESS.DIGEX.NET

Subj: Re: Printing Long Variable Strings

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I use the following to print word-wrapped text to the printer to fill in the

whole width of the page, or just a column.

* Create a text box on a convenient form called txtPRN.

* Do the following where appropriate:

Global Const WM_USER = &H400

Global Const EM_SETREADONLY = (WM_USER + 31)

Global Const EM_GETLINE = (WM_USER + 20)

Global Const EM_GETLINECOUNT = (WM_USER + 10)

Declare Function SendMessageI Lib "User" Alias "SendMessage" (ByVal

hWnd As Integer, ByVal wMsg As Integer, ByVal wparam As Integer, lParam

As Any) As Long

txtPRN.Width = Printer.Width - Printer.CurrentX - 750   ' Setup text box

dimensions = to printing diminsions

szBuff = Printer.FontName

txtPRN.FontName = szBuff ' Make font for printer and this text box the same.

iTemp = Printer.FontSize

txtPRN.FontSize = iTemp ' Make the font size the same . . .

txtPRN.Text = szBigBuff ' Make contents of text box what you want to print

lBuff = SendMessageI(frmBill!txtPRN.hWnd, EM_GETLINECOUNT, 0, 0) ' Get

number of lines of wrapped text

For i = 0 to lBuff ' Notice that lBuff is free to use since VB takes a snapshot

of the For limit.

 ' Set first WORD to size of buffer

 szBuff256 = Chr$(250) + Chr$(0)

 ' Returns no chars found

 lBuff = SendMessageI(txtPRN.hWnd, EM_GETLINE, j, ByVal szBuff256)

 Printer.Print Left(szBuff256, lBuff)

Next i

' At this point you are done.

Hope this helps.

 Andy Harrah

hirtle@manta.nosc.mil (Timothy L. Hirtle) wrote:

>When I print long variable strings using Printer.print Name, the

>printer prints the data on a single line that continues to my right

>margin only. I would like it to realize that it reached my right

>Tim

>hirtle@nosc.mil


Printing orient. etc.

LUOKKA: printing

Date: 07-07-95 (00:42)              Number: 380924 of 381583 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Creeping Printer Object..

From: "Michael Williams." <PEARSON701@AOL.COM>

     Below is an example of simple orientation change and print using the

P.O.  The line centering occurs properly in both portrait and landscape mode

but is shifted equally to the right about 3 characters off center.  This

occurs regardless of any font or size change.  I have yet to figure this one

out.  I thought it may be in my printer/orientation routine, but I found

nothing.  I've encloded the printer routine below also.  Any help is

appreciated.

Sub Command1_Click ()

prnLandScape                'My orientation routine

Printer.FontName = "Embassy BT"

Printer.FontSize = 16

Printer.FontBold = False

Printer.ScaleLeft = 0       'Just to make sure...

For i = 0 To 2

    Printer.CurrentX = (Printer.Width / 2) - (Printer.TextWidth(FontView(i))

/ 2)

    Printer.Print FontView(i)

Next i

Printer.EndDoc

End Sub

ORIENTATION ROUTINE

Type OrientStructure

  Orientation As Long

  Pad As String * 16

End Type

Declare Function AbortDoc% Lib "GDI" (ByVal hDC%)

Declare Function Escape% Lib "GDI" (ByVal hDC%, ByVal nEsc%, ByVal

nLen%,

lpData As OrientStructure, lpOut As Any)

Sub prnLandScape ()

On Error GoTo prnFX1

   Const PORTRAIT = 1

   Const LANDSCAPE = 2

   Const GETSETPRINTORIENT = 30

   Const Null1 = 0&

   Dim Orient As OrientStructure

   Dim ret As Integer

   Dim x As Integer

     printer.Print ""

     Orient.Orientation = LANDSCAPE

     x = Escape(printer.hDC, GETSETPRINTORIENT, Len(Orient), Orient,

Null1)

     ret = AbortDoc(printer.hDC) '<<<Cancels the first Print call above.>>>

   printer.EndDoc                '<<<This EndDoc will generate an error>>>

prnFX1:

   If Err > 0 Then

      Resume Next

   End If

End Sub


Printing strings 1

LUOKKA: printing

Date: 06/23/94 (03:25)              Number: 9927 of 10157 (Refer# NONE)

From: BR_WARREN@PNL.GOV

Subj: Example of printing large text string

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I mentioned in a previous post that I would post an example of printing

large text strings.  Well, here goes:

Notice that I do no error checking!  This will behave unpredictably if

there are no spaces in the first 70 characters.  If you were unconcerned

about readability of the string you could just crop it at 70 each time.

I chose 70 because it makes for a nice margin (also tab(7)).  This is

just something I have spit out right here (except for the Strchr function).

I have not tested this!  Your mileage may vary!

Brad

++++++++++++++Begin code+++++++++++++++

Sub print_string(s$)

  dim pos%, test$

  if len(s$) <= 70 then

    printer.print tab(7); s$

  else

    while len(s$) >70

      test$ = trim$(left$(s$, 71))

      pos% = Strchr%(test$, " ")

      if pos% > 0 then

        printer.print tab(7); left$(test$, len(test$) - pos%)

        s$ = mid$(s$, len(test$) - pos% + 1)

      else

        printer.print tab(7); mid$(test$, 1, 70)

        s$ = mid$(s$, 71)

      end if

    wend

    if len(s$) > 0 then

      printer.print tab(7); s$

    end if

  end if

end sub

Function Strchr%(byval target$, byval test$)

'I made this function to behave exactly like the C function

'of the same name.  It searches for a charcter in a string

'starting from the end.  It returns -1 if unsuccessful.

  dim char$, pos%, i%

  pos% = -1

  if len(test$) > 1 then

    Beep

    test$ = left$(test$, 1)

  end if

  for i% = 0 to len(target$) - 1

    char$ = right$(target$, 1)

    if char$ = test$ then

      pos% = i%

      exit for

    else

      target$ = left$(target$, len(target$) - 1)

    end if

  next i%

  Strchr% = pos%

end function

+++++++++++++++End Code++++++++++++++


Printing strings 2

LUOKKA: printing

Date: 06/23/94 (11:34)              Number: 9934 of 10157 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Printing Large Text Strings?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Actually, Brad, this approach is only good for fixed-pitch fonts.

What you really need to do is to build the print string up logically,

either a word at a time or a byte at a time and do a comparison like this...

 if Printer.TextWidth(P$) > Printer.ScaleWidth then

  Printer.Print Left$(P$, Len(P$)-1)

  P$ = Right$(P$, 1)

 endif

... if you get the picture.

br_warren@pnl.gov (Brad Warren) writes:

>In article <2tldnn$p59@search01.news.aol.com>, lobber1@aol.com

(Lobber1) says:

>>To all VB's :

>>I am trying to print a large text string to the printer. Of course it

>>only prints the first few characters because of the lack of a

>>line-wrap. What can I do? Can somebody give me a quick routine that

>>will break up the text string so that it can be printed???

>I do something like this:

>Sub Print_String (p$)

>  Const PAGEWIDTH = xx

>  While Len(p$) > PAGEWIDTH

>    Printer.Print Left$(p$, PAGEWIDTH)

>    p$ = Right$(p$, Len(p$) - PAGEWIDTH)

>  Wend

>  Printer.Print p$

>  EndDoc

>End Sub

>of course, if you were trying to print a string that contains words (like a

text editor)

>then you would want to find the next space in the string (InStr) and see if

>that is PAGEWIDTH.  keep going until you get a space past PAGEWIDTH.

>then print to the last space and do the Right$.  I guess I could post an

example

>Brad

--

Luke Webber


Printing Word/Wp files

LUOKKA: printing

Date: 02/14/95 (03:25)              Number: 227392 of 227855 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Printing out Word or WordPerfect files

>I need to print out Word or WordPerfect files in my VB app.

>I tried those encapulated postscript files, but that took 10 minutes for

ONE page!  Not acceptable.

>I tried using SendKeys but if you shell the programs in after the print

>command things get wierd since you have to have

>timers and stuff for waiting for the background printing.  But you don't

>know how long it will print and you can't leave

>the app.  That will cause to much of a  pause (which I don't know how to do

>anyway) so that method is also not acceptable.

>

>You can't have the program in the background, since the Title bar will

change from print to print.  And AppActivate

>needs a static title bar.

you can utilize ShellExecute API command here and let Word or WordPerfect

do

your printing. There are three main uses for ShellExecute:

  - starting a program by calling it by name,

  - starting a program by calling a data file (data file extension must be

  associated with the desired program)

  - and starting a program to print a file by calling a data file (association!).

I have attached a short program demonstrating these three possibilities. I

used Word as example. What you need in you case is the third alternative.

Copy these into your forms declaration section

----------------------------------------------

Declare Function ShellExecute Lib "Shell" (ByVal hWnd As Integer, ByVal

lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String,

ByVal lpszDir As String, ByVal fsShowCmd As Integer) As Integer

Const SW_HIDE = 0

Const SW_SHOWNORMAL = 1

Const SW_SHOWMINIMIZED = 2

Const SW_SHOWMAXIMIZED = 3

Const SW_MAXIMIZE = 3

Const SW_SHOWNOACTIVATE = 4

Const SW_SHOW = 5

Const SW_MINIMIZE = 6

Const SW_SHOWMINNOACTIVE = 7

Const SW_SHOWNA = 8

Const SW_RESTORE = 9

Add three command buttons to your form (keep the default names) and make

captions e.g.

 "Word" (Command1), "Open Test.doc" (Command2) and "Print Test.doc"

(Command3).

Copy following subroutines to appropriate places.

----------

Sub Command1_Click ()

   hInstance = ShellExecute(Form1.hWnd, "Open", "winword.exe", "", "c:™",

SW_SHOWNORMAL)

   If hInstance < 32 Then

      MsgBox "Error " & hInstance & " occurred."

   End If

End Sub

Sub Command2_Click ()

   hInstance = ShellExecute(Form1.hWnd, "Open", "test.doc", "", "c:™",

SW_SHOWNORMAL)

   If hInstance < 32 Then

      MsgBox "Error " & hInstance & " occurred."

   End If

End Sub

Sub Command3_Click ()

   hInstance = ShellExecute(Form1.hWnd, "Print", "test.doc", "", "c:™",

SW_HIDE)

   If hInstance < 32 Then

      MsgBox "Error " & hInstance & " occurred."

   End If

End Sub


Printing X/Y-coords

LUOKKA: printing

Date: 09/08/94 (14:37)              Number: 18681 of 18922 (Refer# NONE)

From: ITFGT@ITF.NLH.NO

Subj: Re: ***** PRINTING TO X,Y CO-ORDINATES ANY EXAMPLE CODE ****

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

To print with great accuracy with understandable coordinates, you have to

scale the printer object in a proper way, ie:

  Printer.Scale (0,0)-(2100, 2970)

which should allow you an accuracy of 0.1 mm on an A4 paper sheet.

Then use

  Printer.CurrentX = YourXpos

  Printer.CurrentY = YourYPos

to set the desired starting point for text printing.

(Remember to set both X and Y !).

For VBs graphical methods, just use the coordinates directly.

ie:

  Printer.Line (100,100)-(150,150),,B

will print a tiny square box (5 mm) in the upper left corner.

When finished, use

  Printer.Enddoc

to get it out.

Geir


Q/A database

LUOKKA: internet

Date: 07-24-95 (16:57)              Number: 394622 of 394700 (Refer# NONE)

From: Mike Dixon <mdixon@WHIDBEY.NET>

To: Multiple recipients of list VISBAS-L <VISBAS-L@eva.dc.LSOFT.COM>

FTP now available for the Visual Basic

Question/Answer/Information/Database !!

Now over 300K of Q & A, Info, News, Tips, etc., on VB. This hypertext

database is available in two forms:

1- WWW online version at: http://www.whidbey.net/~mdixon/qaid0001.htm

2- Standalone version at: ftp.whidbey.net/pub/mdixon/

The standalone version is a windows hypertext interface which you can print,

export, copy and paste, etc. (really nice)

  +-+-------------------------------------------------+-+-+-+

  ö&ö    From the Windows 95 Desktop of Mike Dixon    ö_öOöXö

  +-+-------------------------------------------------+-+-+-+

  ö Windows 95 Question/Answer/Information Database (QAID)  ö

  ö & the Visual Basic 95 QAID - which can be found at:     ö

  ö http://www.whidbey.net/~mdixon/qaid0001.htm             ö

  ö Interactive WWW and DOWNLOADABLE versions available.    ö

  ö mdixon@whidbey.net  FTP at ftp.whidbey.net/pub/mdixon/  ö

-----------------------------------

7907 (26+)  Anders.Bjurestig@South.Telia.Se  31.07.95  08:54

Anders Bjurestig: "Re: VB Database FAQ"

Try the searchengine for this Newsgroup(and the others) at

Visual Basic Homepage http://www.apexsc.com/vb/index.html

It's very useful, just type your subject, set it for maximum

search(200 answers, search all posts)


QueryUnload

LUOKKA: VBgen

24968 (222+)  dagsunde@oslonett.no  12.07.95  22:33

Dag Sunde: "Re: How to detect Windows terminate in VB?"

Iain Murray <imurray@mic.dundee.ac.uk> wrote:

>When Windows closes, some apps (even though they are NOT ACTIVE) pop

>up and say e.g. "edited file not saved - do you want to save it now".

>

>I'd like to add this feature to my VB program - HOW IS THE WINDOWS

>EXIT TRAPPED from within VB >so I can run my file save procedure?

Use the Form_QueryUnload(...)

Syntax

Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)

Sub MDIForm_QueryUnload (Cancel As Integer, UnloadMode As Integer)

Remarks

The QueryUnload event uses the following arguments:

Cancel

Setting this argument to any value other than zero stops the QueryUnload

event in all loaded forms and stops the form and application from closing.

UnloadMode

Indicates the reason for the QueryUnload event.

The UnloadMode argument can have these values:

Value	Description

0	The user has chosen the Close command from the Control-menu

box on the form.

1	The Unload method has been invoked from code.

2	The current Windows-environment session is ending.

3	The Microsoft Windows Task Manager is closing the application.

4	An MDI child form is closing because the MDI form is closing.

Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)

Dim Msg	' Declare variable.

' Set the message text.

Msg = "Do you really want to exit the application?"

' If user clicks the 'No' button, stop QueryUnload.

If MsgBox(Msg, 36, Me.Caption) = 7 Then Cancel = True

End Sub

Search Help:QueryUnload...

Dag Sunde.


QuickSort

LUOKKA: VBgen

Date: 06-29-95 (08:49)              Number: 374832 of 377040 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Sorting, better than QSOR...

From: "Michael Williams." <PEARSON701@AOL.COM>

     I'm not sure if your "QSORT" is the same as the QuickSort Algorithm but

QuickSort is the fastest one in any language that I know of.  Below is a

clip,  you should be able to extrapolate whatever you need from it...

Sub Quickest (Array (), L, R )

Dim I, J, X, Y

I = L

J = R

X = Array( L + R) / 2)

While (I <= J)

     While(Array(I) < X And I < R)

             I = I + 1

     Wend

If ( I < = J) then

     Y = Array(I)

     Array(I) = Array(J)

     Array(J) = Y

     I = I + 1

     J = J -1

End If

///////////////////////////////////////////////////////////////////////

Your iteration and assignment code goes here ///

//////////////////////////////////////////////////////////////////////

End Sub


QuickSort

LUOKKA: VBgen

Date: 08/11/94 (17:11)              Number: 15205 of 15234 (Refer# NONE)

From: RICHARD@CYCLONE.MSFC.NASA.GOV, Richard Hollingsworth

Subj: QuickSort help..

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Thanx for all info on quick sort.  It helped a lot.  A question though.  I have

the sort working fine for an array of numbers.  Now I have to convert it to

handle structures (an array of data records), and I have to sort on multiple

keys without messing up the stuff that's already sorted.

I think it's the swapper call or routine thats screwed up.  It wont handle

anything but numbers.  Here's the call and routine:

SWAP elements(i).Code, elements(j).Code                'sort the Code field

SWAP elements(i).Description, elements(j).Description  'take the Descr field

along

SWAP elements(i).Length, elements(j).Length            'take the Length field

along

.

.

Sub SWAP (x as integer, y as integer)

dim temp as integer

temp = x

x = y

y = temp

end sub

Q? -- Do I call the swap routine the same way for numbers and strings?

      Is routine SWAP written correctly to handle both, or do I need to write a

seperate swap routine to handle numbers, then figure out each time which

swapper to call?

I think the swap routine just has to be a lot more complex than the algorithm

shows.  Any advice?


QuickSort

LUOKKA: VBgen

Date: 08/11/94 (19:29)              Number: 15216 of 15234 (Refer# NONE)

From: MARK@AND.NL

Subj: Re: QuickSort help..

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Concerning the SWAP problem: couldn't you use a variant type?

Declare Tmp's for all types you'd like to swap.

Then use a Select Case VarType(..) to select which

swap type is needed. Then, just swap this type.

Of course, I assume you wish to swap two variables

of the *same* type...

Mark Nieuwmans

mark@and.nl


QuickSort

LUOKKA: VBgen

Date: 08/13/94 (09:43)              Number: 15441 of 15487 (Refer# NONE)

From: WOLFS@TIGER.DIALIX.OZ.AU

Subj: Re: qsort routine help!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Wow, some-one who don't know how to and freely admits. Normally I

don't bother cause there are quite a number of examples but for

what it's worth I dug out a sample which works on arrays. Should

be a piece of pie for you to change it around to suit your needs.

But I am not going to email you. Someone else might want this too.

Cut out the sample and use the load file option in VB

This one gives the form:      The next gives the .BAS file

--------------------------------cut here-------------------------

VERSION 2.00

Begin Form Form1

   AutoRedraw      =   -1  'True

   Caption         =   "Form1"

   ClientHeight    =   5310

   ClientLeft      =   1095

   ClientTop       =   1485

   ClientWidth     =   2295

   Height          =   5715

   Icon            =   0

   Left            =   1035

   LinkMode        =   1  'Source

   LinkTopic       =   "Form1"

   ScaleHeight     =   5310

   ScaleWidth      =   2295

   Top             =   1140

   Width           =   2415

End

Sub Form_Load ()

Static Array(9) As Integer

Array(1) = 9

Array(2) = 8

Array(3) = 7

Array(4) = 6

Array(5) = 5

Array(6) = 4

Array(7) = 3

Array(8) = 2

Array(9) = 1

Print " i          Array(i)"

Print "---         --------"

For i = 1 To 9

        Print i, Array(i)

Next i

Call SortQuick(Array(), 1, UBound(Array, 1))

Print

Print "Sorting..."

Print

Print " i          Array(i)"

Print "---         --------"

For i = 1 To 9

        Print i, Array(i)

Next i

End Sub

Sub SortQuick (Array() As Integer, SortFrom%, SortTo%)

        If SortFrom% >= SortTo% Then Exit Sub

        If SortFrom% + 1 = SortTo% Then  'Final case

            If Array(SortFrom%) > Array(SortTo%) Then

                Temp% = Array(SortFrom%)

                Array(SortFrom%) = Array(SortTo%)

                Array(SortTo%) = Temp%

            End If

        Else    'Have to split problem

            AtRandom = (SortFrom% + SortTo%)   2

            Test = Array(AtRandom)

                Temp% = Array(AtRandom)

                Array(AtRandom) = Array(SortTo%)

                Array(SortTo%) = Temp%

            Do

                For i = SortFrom% To SortTo% - 1

                        If Array(i) > Test Then Exit For

                Next i

                For j = SortTo% To i + 1 Step -1

                        If Array(j) < Test Then Exit For

                Next j

                If i < j Then

                    Temp% = Array(i)

                    Array(i) = Array(j)

                    Array(j) = Temp%

                End If

            Loop Until i >= j

                    Temp% = Array(i)

                    Array(i) = Array(SortTo%)

                    Array(SortTo%) = Temp%

            Call SortQuick(Array(), SortFrom%, i - 1)

            Call SortQuick(Array(), i + 1, SortTo%)

        End If

End Sub

-------------------------cut here too-----------------------------

'Dummy text so VB won't load generic Global.Bas

 -------------------------- ------------------------------------

"    Wolfgang A.Steinert   " Insanity is hereditary             "

"                          " You get it from your kids ...      "

" wolfs@tiger.DIALix.oz.au "                                    "


QuickSort

LUOKKA: VBgen

Date: 12/07/94 (02:14)              Number: 29055 of 29145 (Refer# NONE)

From: MAURER@TURANDOT.CSEE.USF.EDU, Peter Maurer

Subj: Re: PROBLEM SORTING LARGE ARRAYS

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> I am having a problem sorting a large (10000+) number array. The quicksort

>routine I usually use is recursive and I run out of stack space quickly when

>sorting much more than 1000 items.

>If you have a good understanding of the quicksort routine you're using

>you should be able to modify it to use an array to store pending

>computations.  I must admit that I wouldn't relish the thought of doing

>that myself though ..

Iterative Quicksort is implemented like this:

   Dim StartPoint(32) As Integer, EndPoint(32) As Integer

   Dim StackPtr As Integer, First As Integer, Last As Integer

   Dim SplitPoint As Integer

   ' Array to be sorted assumed to be in global variable

   StartPoint(1) = 1

   EndPoint(1) = SizeOfList

   StackPtr = 1                       ' push whole list on stack

   While StackPtr > 0

      First = StartPoint(StackPtr)

      Last = EndPoint(StackPtr)

      StackPtr = StackPtr - 1         ' pop the stack

      While First < Last

         Split(First,Last,SplitPoint)

         If (SplitPoint - First) <= (Last - SplitPoint) Then  ' push longest list

            StackPtr = StackPtr + 1

            StartPoint(StackPtr) = SplitPoint + 1

            EndPoint(StackPtr) = Last

            Last = SplitPoint - 1

         Else

            StackPtr = StackPtr + 1

            StartPoint(StackPtr) = First

            EndPoint(StackPtr) = SplitPoint - 1

            First = SplitPoint + 1

         End If

      Wend

   Wend

...

   Sub Split(First As Integer, Last As Integer, SplitPoint As Integer)

      ' List is in global variable L

      Dim x As Integer, Unknown As Integer

      Dim Temp As Integer ' L is assumed to be an array of integers

      x = L(First)

      SplitPoint = First

      For Unknown = First+1 To Last

         If L(Unknown) < x Then

            SplitPoint = SplitPoint + 1

            Temp = L(SplitPoint)

            L(SplitPoint) = L(Unknown)

            L(Unknown) = Temp

         End If

      Next Unknown

      Temp = L(First)

      L(First) = L(SplitPoint)

      L(SplitPoint) = Temp

   End Sub

Algorithms courtesy of Sara Baase, "Computer Algorithms, Introduction to

Design and Analysis, Second Edition," Addison Wesley Publishing Co, New

York, 1988.  VB code by me, not compiled, may have a few bugs.

The dimension (32) for StartPoint and EndPoint is a bit generous.  This

allows you to sort arrays up to four gigabytes in size.  For a 10000 element

array, a dimension of 14 or 15 should do just fine.  The relationship

is: a dimension of x allows you to sort up to 2**x items.  The If statement

to select the longest list for pushing on the stack is NECESSARY for this

relationship to be true.  Otherwise the stack must be as long as the list.

You might also consider using the "leaf" sort technique.  Quicksort isn't

too fast for short lists, so when the list gets small (10-20 items), use

Insertion sort to sort the list, and terminate the While First<Last loop.

Pete Maurer

maurer@usf.edu


Quotes

LUOKKA: Access

27048 (56+)  bclow@acs3.acs.ucalgary.ca  24.07.95  10:52

Brian Christopher Low: "Re: Problem with ' character in SQL"

Mark Ferguson (mark@cddc.demon.co.uk) wrote:

: I have a problem with the "'" character in SQL statements. I build up

: my search criteria from an item selected from a Listbox. This Listbox

: is made up from items from my table. The data used is made up of Gaelic

: names, eg. "A'Chuill", "Beinn A'Bhuird". Unfortunately VB doesn't seem

: to like searching on an item which contains "'". Is there a way to get

: round this?

If you need to have the single quote (') in your strings then

quote the entire string with double quotes (").  Eg.

    SELECT * FROM mytable WHERE name="A'Chuill"

If you have a double quote in your text, then quote the string

with single quotes, eg.

    SELECT * FROM mytable WHERE text='he said "Hi there."'

Or if you have BOTH, then you need to split your string,

alternate between quotes, and then & the strings together, eg,

   ... WHERE text="Tammy's friend said " & '"Hi there"'


Quotes

LUOKKA: SQL

Date: 05/12/94 (23:26)              Number: 5691 of 5763 (Refer# NONE)

From: LRP.ADMIN@MHS.UNC.EDU

Subj: Re: Re:SQL problems

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can also just type in the double quotes like this:

  Dim sql As String

  Dim ErrMsg As String

  On Error GoTo DemogErr

  sql = "exec get_demog" & " " & "'" & id_hold &+ "'"

It doesn't show up too clearly here, but the sequence of characters is double

quote-single quote-double quote.  The resulting string, sql, will contain:

exec get_demog '999999999'

I assume the same thing will work if you have embedded apostrophes in a

string field.

Ray Porter

lrp.admin@mhs.unc.edu


Quotes

LUOKKA: SQL

Date: 07/06/94 (23:42)              Number: 11387 of 11683 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Finding strings in Dynase

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 6/7/94, William D. Taylor wrote to ALL: *****>>

WD>I want to search for a string in a VB (Access 1.0)

WD>database.  Something like this:

WD>  Ds.FindFirst "MyField = '" & MyString & "'"

WD>The problem is that the string may (and in fact does) contain a single

WD>quote, which causes a syntax error.  How do I get around this, and

WD>guarantee that no amount of single/double quotes or CR/LF characters

WD>in the string will generate a syntax error?

seem to recall you should use

Ds.FindFirst "MyField = " & chr$(34) & MyString & Chr$(34)

michael.cowan@almac.co.uk nottingham, england


Quotes

LUOKKA: SQL

Date: 07/18/94 (13:29)              Number: 12330 of 12384 (Refer# NONE)

  To: ALL

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: Accepting names like O'Brien

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I've found the same thing with Access (if you look in the sample

phone.mak program supplied with VB 3, this falls over if you try to

store a name like O'Brien). I could not find any way to extract

these names becuase the single quote acts as a field close

character. Chronic, huh? I eventually got around it by trapping

the record at the time when I added it, and replacing the ' (ASCII

39) symbol with a ` symbol (ASCII 96). This is cosmetically almost

acceptable for just browsing, and you can always substitute it back

again for display if you don't like it.

Incidentally when I originally noticed this problem I reported it to

Microsoft, who told me I was talking waste products until they tried

it for themselves. Amazing that they should have failed to have noticed

such a glaring inadequacy in their own databases.

Ian Piper


Quotes

LUOKKA: SQL

Date: 07/18/94 (13:59)              Number: 12337 of 12384 (Refer# NONE)

From: M_MILIS@PAVO.CONCORDIA.CA

Subj: Re: Accepting names like O'Brien

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You could use double quotes, like:

        Query1.pWHere = "NAME = """ & gName & """"

since it is unlikely that a name would contain one of those. This, of course,

does not solve this problem in general, but that"s the best I can do at

4:13am.

PS Or you can try doubling the aposthrophe, so it comes out like:

NAME = 'O''Brien'. I haven''t tried it.

-----------------------------------------------------

Marko Milisavljevic

m_milis@pavo.concordia.ca

Montreal, Canada


Quotes

LUOKKA: SQL

Date: 07/18/94 (13:59)              Number: 12338 of 12384 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Accepting names like

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You might run your string through a parser at both ends, replacing the '

with ö and " with öö when it's read and vice versa when it's written.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


Quotes

LUOKKA: SQL

Scanning co.la.bas.vis (1562) Conference Date: 07/18/94 (22:20)

Number: 12385 of 12479 (Refer# NONE)

From: ROBBIJE@UNCVX1.OIT.UNC.EDU

Subj: Re: Accepting names like O'Brien

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> PS Or you can try doubling the aposthrophe, so it comes out like:

> NAME = 'O''Brien'. I haven''t tried it.

Below is my code for solving the problem with single quotes.  It could also

be modified to work with double quotes.  I haven't tried this in Access.

 ' Loop through replacing single "'" w/ double "''" because

 '   of VB string checking

 iSerial = 1

 iSerial = InStr(iSerial, sSerial, "''")

 ' If InStr doesn't find "'" then iSerial is zero or False

 Do While iSerial   ' Will fail when iSerial = 0

  sSerial = Right$(sSerial, iSerial - 1) + "''''" + Mid$(sSerial, iSerial + 1)

  iSerial = iSerial + 1

 Loop

 datSerial.Recordset.FindFirst "UCase$(TEXT) = """ + UCase$(sSerial) + """"

Jim


Quotes

LUOKKA: SQL

Date: 07/18/94 (22:48)              Number: 12388 of 12479 (Refer# NONE)

From: KAI-UWE@HERBING.IN-BERLIN.DE, Kai-Uwe Herbing

Subj: Re: Accepting names like O'Brien

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try

     Query1.pWhere = "NAME = " + SQLText(gName)

and include the function below with your code:

Function SQLText (ByVal sString As String) As String

    Dim nApostroph As Integer

    nApostroph = InStr(1, sString, "'")

    Do While nApostroph

        sString = Left$(sString, nApostroph) & " & ""'"" & " & Mid$(sString,

              nApostroph)

        nApostroph = InStr(nApostroph + 11, sString, "'")

    Loop

    SQLText = "'" + sString + "'"

End Function

------------------------------------------------------------------------

Kai-Uwe Herbing                  Voice      +49 (30) 852-0892


Quotes

LUOKKA: SQL

Date: 07/19/94 (02:22)              Number: 12406 of 12479 (Refer# NONE)

From: ROBONEAL@RIPCO.COM

Subj: Re: Accepting names like O'Brien

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Construct your query with double quotes enclosing the name.

i.e.

:       Query1.pWHere = "NAME = '" + gName + "'"

would be

:       Query1.pWHere = "NAME = "" + gName + """

Rob O'Neal

roboneal@ripco.com


Quotes

LUOKKA: SQL

Date: 08/02/94 (10:35)              Number: 14102 of 14165 (Refer# NONE)

From: GSBELL@AMOCO.COM

Subj: Re: FindFirst Problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Use the following instead.  Replace each single quote with two

double-quotes. It ain't pretty but it should work.

    Data1.Recordset.FindFirst "LastName = """ & SearchStr & """"

 Gordon Scott Bell


Quotes

LUOKKA: SQL

Date: 09/11/94 (12:08)              Number: 19032 of 19086 (Refer# NONE)

From: WOLFS@TIGER.DIALIX.OZ.AU

Subj: Re: Access DB and apostrophe!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Well here is a solution. If you use SQL - you should be able

to insert records that includes columns with apostrophies

contained in their values ( i.e. O'Connor ).  What you must do

though is check for the position of the apostrophie and

substitute the one with TWO: (sheesh my english is failing

me). Here an example (cut from an app I wrote ):

    ' checking for imbedded inverted commas. We have to insert a

    ' second imbedded comma otherwise we get an SQL error.

    nResult = InStr(szCity, "'")

    ' we have an apostrophe ... now replace it with two of

    ' them...

    ' e.g the string  O'Brian will end up as O''Brian

    ' Naturally we still have to enclose the whole string

    ' then in inverted comma's

    If nResult > 0 Then

        nLen = Len(szCity)

        szTemp = szTemp & Left(szCity, nResult - 1)

        szTemp = szTemp & "''"

        szTemp = szTemp & Mid(szCity, nResult + 1, nLen)

        szCity = szTemp

    End If

    szCity = "'" & szCity & "'"

    ' building the SQL insert string

    szSQL2 = ""

    szSQL2 = szSQL2 & " INSERT INTO country_has_city("

    szSQL2 = szSQL2 & "             atm_count,"

    szSQL2 = szSQL2 & "             ctrycode,"

    szSQL2 = szSQL2 & "             city,"

    szSQL2 = szSQL2 & "             statename_short ) VALUES ("

    szSQL2 = szSQL2 & "             0,"

    szSQL2 = szSQL2 & "        '" & szCountryCode & "',"

    szSQL2 = szSQL2 & "         " & szCity & ","       <-

    szSQL2 = szSQL2 & "        '" & szState & "' )"      "

                                                         "

         note the absence if inverted commas here -------

 -------------------------- ------------------------------------

"    Wolfgang A.Steinert   " Insanity is hereditary             "

" wolfs@tiger.DIALix.oz.au "


Quotes

LUOKKA: SQL

Date: 05/12/94 (20:02)              Number: 5660 of 5763 (Refer# NONE)

From: MARKDA2@AOL.COM

Subj: Re: Re:SQL problems

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Dim DQ as String * 1

DQ = Chr(34) 'Double quote

sql = "Select * from password where section = " & DQ & "director's office" &

DQ

This will put double quotes in your sql string which override any apostrophies

between them.

Mark


Quotes etc.

LUOKKA: SQL

Date: 10/05/94 (23:45)              Number: 21913 of 21922 (Refer# NONE)

From: WOLFS@TIGER.DIALIX.OZ.AU

Subj: Re: SQL question in VB. Please HELP..........

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>>      I am trying to write an SQL statement in VB and it gives me a

>>run time error. I am getting a name of a city using InputBox function

>>and store the name of the city in a variable.

>>

>>      MyVar = InputBox(type the city)

>>

>>then I want to use this MyVar into a WHERE clause.

>>

>>that is.

>>      select * from parts where CITY = MyVar

>>

>>The problem is that in the where clause it does not take a

>>variable. If I write CITY = NewYork, it works fine. I have declared this

>>variable as string. Can someone please let me know what I am doing

>>wrong.

>

>Imram, just remember you are creating a STRING which must contain

>the actual value.

>   Try this:  "select * from parts where CITY = " & MyVar

>

Close... you need to include single quotes if you have a string. And don't

forget to check for apostrophes ( or whatever you want to call them things ).

They can bomb you out if you try and insert - replace them with a two

apostrophes:

without apostrophes:

          "select * from parts where CITY = '" & MyVar & "'"

with apostrophes:

          "update PEOPLE set NAME = 'Henry''s' WHERE ...."

--

 Regards ... Wolf


Quotes summary

LUOKKA: SQL

Date: 07/21/94 (16:41)              Number: 12737 of 12767 (Refer# NONE)

From: CFIELDS@NANDO.NET

Subj: Re: Accepting names like O'Brien

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Thank you all for so many suggestions. After trying some of them on my

application, I wanted to post an answer to my question. What worked for

me was to replace the single quote with two double quotes:

 gName = "Doe, John"

 Query1.pWhere = "NAME = """ + gName + """"

When the user got the .exe and tried it there were no errors! :) Thank you.

Other suggestions?

1) replace single quote with double quote (didn't work for me)

2) replace single quote with vertical bars/double quotes with double

vertical bars when it's written (didn't try)

3)replace apostrophe in name with double apostrophe (didn't try)

4)replace ASCII 39-open apostrophe with ASCII-96-closed apostrophe...trap

record when added and change (didn't try)

5)replace single quote with ? when searching (didn't try)

6)add function routine to change apostropee (didn't try)

Replacing the single quote was the quickest solution for me without

having to change any coding and I used the first one that worked. :)

This is a summary.  Thanks to everyone who responded.

Cassandra.....cfields@nando.net


Read 1 byte

LUOKKA: VBgen

Date: 10/20/94 (17:02)              Number: 23761 of 23771 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Reading 1 byte from a binary file

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Andrew Chambers <atc@waikato.ac.nz> writes:

-snip+

>So how do I simply read a stream of bytes from a file?

>My program is supposed to read the data and set pixels on the screen

>whose level/colour depends on the value of the byte read in.

>see its just a simple graphics viewer.

You could use the Get statement with a fixed-length string. I wouldn't

recommend reading one byte at a time, instead read into a 1K or so

string, then use Mid$ to get each byte in turn.

--

Luke Webber


Readonly

LUOKKA: TextBox

Date: 06/02/94 (18:45)              Number: 7629 of 7791 (Refer# NONE)

From: JO1919G92@AUVAX1.ADELPHI.EDU

Subj: Re: How to make a scrollable label?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Use a textbox.  Then use the SendMessage() function to set it to read only.

If I remember correctly, it is done this way:

(Declarations)

Global Const WM_USER = &H400

Global Const EM_SETREADONLY = WM_USER + 31

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

ByVal

  wParam%, lParam As Any)

(Procedure call)

lRet = SendMessage( Text Box Name .hWnd, EM_SETREADONLY, True, 0)

______________

" Bradley S. Murray                     Phone: (609) 799-5300                 "

" Princeton Computer Consulting, Inc.     Fax: (609) 275-5651                 "

" PO Box 7345                        Internet: jo1919g92@auvax1.adelphi.edu   "

" Princeton, NJ 08543-7345


Readonly

LUOKKA: TextBox

Date: 06/03/94 (10:13)              Number: 7729 of 7791 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: How to make a scrollable

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

extracted from MS vb_tips.hlp:

   Add the following constants and declarations to the module level or to

   the global section of your code:

   Const WM_USER = &H400

   Const EM_SETREADONLY = (WM_USER + 31)

   Enter the following Declare statement as one, single line:

   Declare Function SendMessage Lib "User" (ByVal hWnd As Integer,

      ByVal wMsg As Integer, ByVal wParam As Integer,

      ByVal lParam As Any) As Long

      Set the text box to read-only mode:

      ret = SendMessage(Text1.hWnd, EM_SETREADONLY, True, 0&)

michael.cowan@almac.co.uk

nottingham, england & europe


Readonly

LUOKKA: TextBox

Date: 06/25/94 (01:06)              Number: 10420 of 10514 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: TextBox Text Color Proble

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

make the text boxes readonly with

x%=SendMessage(text1.hwnd, &H400 +31, 1,0L)

and read/write ditto but 0 instead of 1 as the third parameter

michael.cowan@almac.co.uk

nottingham, england


Readonly

LUOKKA: TextBox

Date: 06/26/94 (14:14)              Number: 10631 of 10664 (Refer# NONE)

From: RLANGBP@CC.CURTIN.EDU.AU

Subj: Re: TextBox Text Color Problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2ucncv$4e5@chnews.intel.com>

Dave Emme <demme@hobbs.ch.intel.com> writes:

 stuff deleted

> Here's my problem: When the textboxes are unlocked, all text in all

> boxes looks normal black, as expected.  However when the textboxes

> are locked, the text in those which are single line looks gray,

> while the text in those which are multiline looks black, as before.

> I would prefer that all of the text in the locked textboxes look

> black.  I would *really* prefer that it all looks *the same*, so

> as not to make the user wonder what semantic difference there is

> between the gray text and the black text.  Besides, it looks

> wierd!

 stuff deleted

> Any suggestions?

Three suggestions, Dave (all pretty basic)

1. Set the multi-line property on the single-line box to true

   just before you disable it, and back to false just after

   you enable it. I think this is the easiest but its untested.

2. Leave all boxes as multi-line and intercept the carridge

   return character in the keyPress event for the "single-line"

   box. I don't have my manuals handy but it looks something like:

   Sub Text1_KeyPress(keyAscii)

       if (keyAscii = 13) then    ' ie. return

           beep

           keyAscii = 0           ' ie. null

       end if

   end Sub

   You could display a message instead of a beep, or use

       SendKeys"ätabå"

   to go to the next text box. I think this is from the FAQ.

   Seems like too much bother.

3. From the VB FAQ for how to make a text box read only...

   It involves an API call ("SendMessage") and you

   would have to remember to reverse the process.

   Also it allows the user to copy if *she* wants to. :-)

   This is a direct quote from the FAQ

   >     'After making the following declarations...

   >     Global Const WM_USER = &H400

   >     Global Const EM_SETREADONLY = (WM_USER + 31)

   >     Declare Function SendMessage Lib "User" (ByVal hWnd As

   >     öInteger ByVal wMsg As Integer, ByVal wParam As

   >     öInteger, lParam As Any) As Long

   >     'Then Try:

   >     SendMessage(Text1.hWnd, EM_SETREADONLY, 1, 0)

   >     ÄPete Jones (pjones@csi.compuserve.com)Å

   Maybe you should use

      i% = SendMessage(Text1.hWnd, EM_SETREADONLY, 1, 0)

   to set to read only, and,

      i% = SendMessage(Text1.hWnd, EM_SETREADONLY, 0, 0)

   to set to read/write. Dunno what i% returns. Presume its zero

   for successful operation.

The VB FAQ can be obtained in Windows Help file format

via FTP from

   quasar.sba.dal.ca under /www/hlp

or from this news group. (comp.lang.basic.visual)

Hope this helps.

Cheers,               Curtin University Physics Department

Brad Lang             email: rlangbp@cc.curtin.edu.au


Readonly

LUOKKA: TextBox

Date: 07/23/94 (18:44)              Number: 12970 of 12981 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Disabling Editing in

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

That doesn't work either because you can still cut and paste.  You have to

use the SendMessage API

Declaration:

  Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

    ByVal wParam%, lParam As Any)

  Global Const WM_USER = &H400

  Global Const EM_SETREADONLY = WM_USER + 31

Usage:

  lRet = SendMessage(txtTest.hWnd, EM_SETREADONLY, True, 0&)

Brad


Readonly

LUOKKA: TextBox

Date: 09/13/94 (21:36)              Number: 19257 of 19445 (Refer# NONE)

From: DIJKHUIS@TELECOM.PTT.NL

Subj: Re: disabling text input

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can call SendMessage to send a EM_SETREADONLY message to the

edit control.

Example:

- Create a text box Text1 on a form

- Include the appropriate Windows API calls and constants

Dim iResult%

iResult = SendMessage(text1.hWnd, EM_SETREADONLY, True, 0)

Changing the WPARAM from True to False re-enables editing.

A disadvantage of this method is that you will still see the caret on the

control when it has the focus.

Kindest regards,

Luuk Dijkhuis


Readonly

LUOKKA: TextBox

Date: 09/14/94 (00:45)              Number: 19267 of 19445 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: disabling text input

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Ignore the stuff others have said about changing the KeyASCII to 0 and the

like because the user can still cut and paste.  Do this:

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

    ByVal wParam%, ByVal lParam As Any)

Global Const WM_USER = &H400

Global Const EM_SETREADONLY = WM_USER + 31

lRet = SendMessage(Text1.hWnd, EM_SETREADONLY, True, 0&)

Where Text1 is the text box you want to be read-only.

__________

                           Bradley S. Murray


Readonly

LUOKKA: TextBox

Date: 09/19/94 (23:21)              Number: 20041 of 20041 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: disabling text input

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article: <3549uf$3e2@pluto.njcc.com>  bmurray@pluto.njcc.com (Brad

Murray) writes:

> Ignore the stuff others have said about changing the KeyASCII to 0 and the

> like because the user can still cut and paste.  Do this:

>

*Not in fact so* in the case of the SetFocus method. I do it this way and

it works really well. All you do is put this in the Text1_GotFocus routine:

OtherControl.SetFocus

(where OtherControl could be anything - I usually set it to the default

command button on the form).

If you do this then the user will not be able to select text to cut and copy,

as the focus immediately moves to another control. Neat and easy.

I'm sure the SendMessage method works well, but please don't rubbish other

techniques which *do* also work.

Ian Pipe


Readonly

LUOKKA: TextBox

Date: 11/30/94 (23:25)              Number: 140938 of 141613 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: disabling a text box

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Here is a procedure I include in every program I write.  I got the basis

for this information from someone on the list...

Declare Function SendMessage% Lib "user" (ByVal hwnd%, ByVal wMsg%,

ByVal  wParam%, ByVal lParam&)

Global Const WM_USER = &H400

Global Const EM_SETREADONLY = (WM_USER + 31)

'----------------------------------------------------------------------------'

'  MakeTextBoxReadOnly (TextBox, State%)                                     '

'  Call this function to make a Text Box read-only.  Pass a state of TRUE to '

'  make if Read-Only, and pass a State of FALSE to make it read/writable     '

'----------------------------------------------------------------------------'

'

Sub MakeTextBoxReadOnly (C As Control, State%)

    Dim Ret%

    If State% Then

        Ret% = SendMessage(C.hwnd, EM_SETREADONLY, 1, 0)

    Else

        Ret% = SendMessage(C.hwnd, EM_SETREADONLY, 0, 0)

    End If

End Sub


Redraw off

LUOKKA: ListBox

Date: 08/15/94 (22:10)              Number: 15696 of 15821 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: Text Box Scrolling Question

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Send a WM_SETREDRAW message to the TextBox:

 Success = SendMessage(Text1.hWnd, WM_SETREDRAW, False, 0)

to prevent the text box from being redrawn.  Now make your edits, then

 Success = SendMessage(Text1.hWnd, WM_SETREDRAW, True, 0)

 InvalidateRect Text1.hWnd, 0, False

Which will aloow changes to occur in the text box, and do a repaint of the

box. I use this to speed up the system when I add several hundred items to a

listbox.  Should work in your case, though.  Of course, you'll need to get the

declares for SendMessage, InvalidateRect, and the WM_SETREDRAW

constant.

Stephen Johnston


Redraw off

LUOKKA: ListBox

Date: 08/26/94 (03:26)              Number: 17099 of 17164 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Re: Clipcontrols ... yes or no?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Play around with these.

'--KILL REPAINT

   Declare Function SendMessage Lib "User" (ByVal hWnd, ByVal wMsg,

     ByVal wParam, lParam As Any) As Long

   Global Const WM_SetRedraw = &HB

   'Result% = SendMessage(Text1.hWnd, WM_SetRedraw, 0, 0)

   'Do your stuff here!

   'Result% = SendMessage(Text1.hWnd, WM_SetRedraw, 1, 0)

Chuck

Mesquite TX


Redraw off

LUOKKA: ListBox

Date: 04/11/94 (13:19)              Number: 3164 of 3179 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Sharing lists betwee

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The AddItem method repaints a listbox after each call to the method.

There is an excellent alternative: use the SendMessage API call and

WB_SETREDRAW to 0 to suspend repainting the list box.  Use

SendMessage and LB_ADDSTRING in place of the AddItem method, then

Use SendMessage and WB_SETREDRAW to 1 to paint the list box.  The net

result is that the list box remains static until all of the strings are in menory,

then it's painted once.  In a flash.  Try it - if you require more precise

assistance, email me a request and I'll dig out the code for you.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatetot.com


Redraw off

LUOKKA: ListBox

Date: 09/04/94 (09:26)              Number: 18245 of 18257 (Refer# NONE)

From: RROSE@BUD.INDIRECT.COM

Subj: Re: Listbox Auto Redraw

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

 Disabling/enabling the listboxes might solve your problem.  The technical

 solution is to enable and disable the redrawing abilities of the list

 box.  This is done by sending the listbox the wm_SetRedraw message.

 The following is a quick, untested subroutine.  This is based upon a

 Pascal routine that I wrote which does work:

 Sub SetRedraw(Ctrl As Control, State As Integer)

    Dim I As Integer

    i = SendMessage(Ctrl.HWnd, WM_SETREDRAW, State, 0)

    If State Then

       InvalidateRect(Ctrl.HWnd, 0, True);

       UpdateWindow(Ctrl.HWnd)

    End

End Sub

Richard Rosenheim

rrose@indirect.com


Redraw off

LUOKKA: ListBox

Date: 04/13/94 (23:12)              Number: 3357 of 3514 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Sharing lists betwee

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 04-11-94 JON@LOKI.DEMON.CO.UK  wrote:

J>>The AddItem method repaints a listbox after each call to the method.

J>>There is an excellent alternative: use the SendMessage API call and

J>>WB_SETREDRAW to 0 to suspend repainting the list box.

J>I do the combo list setup in the Form_Load procedure, so the control

J>isn't visible at that time. Thanks for the response, anyhow.

I tested this, and you're right - you can actually load a listbox or

combo box in the Form_Load event procedure without the form becoming

visible!

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatetot.com


Redraw off

LUOKKA: VBgen

Date: 10/09/94 (11:38)              Number: 22398 of 22428 (Refer# NONE)

From: CSTUART@METRONET.COM

Subj: Re: Stopping Refresh?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

'--KILL REPAINT

   Declare Function SendMessage Lib "User" (ByVal hWnd, ByVal wMsg,

     ByVal wParam, lParam As Any) As Long

   Global Const WM_SetRedraw = &HB

   Result% = SendMessage(Text1.hWnd, WM_SetRedraw, 0, 0)

     Do your stuff here!

   Result% = SendMessage(Text1.hWnd, WM_SetRedraw, 1, 0)

   Text1.Refresh

-----------------------------------------------------------------------

Chuck Stuart

Mesquite TX USA


REG.DAT&associat.appl.

LUOKKA: VBgen

Date: 10/14/94 (21:55)              Number: 23024 of 23026 (Refer# NONE)

From: GSBELL@AMOCO.COM

Subj: Re: Modifying a DOS environmental variable from VB/Win

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>>how to modify and/or create a DOS environmental variable, like PATH,

>>from within a VB/Win program so that a Shell()ed application can see it?

>

>Interesting question, I don't know.   Note that if the program you want to

>run happens to have an entry in REG.DAT with an associated file-extension,

>then you can use a call to SHELL.DLL to get the full-path spec for that

>executable, assuming that you can reference an existing file with that

>extension.  This is the trick I use to obtain the location of EXCEL so that

>I can shell it without having to worry about whether it is in the path.

>

>Declare Function FindExecutable% Lib "shell.dll" (ByVal lpszFile$, ByVal

>lpszDir$, ByVal lpszResults$)

Yeah, I've written the following program to find associated applications.

It'll work for files that do not exist, too.

'*** BEGIN VB3 CODE ***

Option Explicit

Declare Function FindExecutable Lib "Shell.DLL" (ByVal lpszFile$, ByVal

lpszDir$, ByVal lpszResults$) As Integer 'append to above Declare

Function FileExists (ByVal pFilename$) As Integer

    On Error Resume Next

    FileExists = (FileLen(pFilename$) > 0)

    On Error GoTo 0

End Function

Sub Form_Load ()

    Dim AssocFile$

    Dim AssocApp$

    AssocFile$ = "C:ÖTEST.DOC"  'set to any associated file,

  'it does not have to exist.

    AssocApp$ = GetAssocApp(AssocFile$)

    If AssocApp$ <> "" Then

    MsgBox AssocApp$ & " " & AssocFile$, 64

    Else

 MsgBox "No assocatiated application exists for " & AssocFile$, 48

    End If

End Sub

Function GetAssocApp (ByVal AssocFile$) As String

    'Returns the associated application for the passed associated file

    'The file does not have to exist.

    Dim fFileExists%

    Dim File1%

    Dim lpszResult$

    Dim Ret%

    Dim Pos%

    fFileExists% = FileExists(AssocFile$)

    If Not fFileExists% Then

    'create temporary file

    File1% = FreeFile

    Open AssocFile$ For Binary As #File1%

    Close #File1%

    End If

    lpszResult$ = String$(128, 0)

    Ret% = FindExecutable(AssocFile$, "", lpszResult$)

    lpszResult$ = UCase$(Left$(lpszResult$, InStr(lpszResult$, Chr(0)) - 1))

    If Not fFileExists% Then

    'delete temporary file

    Kill AssocFile$

    End If

    GetAssocApp = lpszResult$

End Function

'*** END VB3 CODE ***

 Gordon Scott Bell


Registration db

LUOKKA: VBgen

Date: 09/12/94 (19:09)              Number: 19135 of 19171 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Registration Database

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 9/11/94 9:07 PM wj5a@aol.com (WJ5A) wrote:

>Does anyone have any code showing how to add an application to the

>Windows Registration Database?

You can use API calls to access the registration database, but the easiest

way is to make a temp file that defines the registration and run it as a

command line parameter with RegEdit.EXE

Declare Function GetTempFileName% Lib "Kernel" (ByVal cDriveLetter%,

    ByVal lpPrefixString$, ByVal wUnique%, ByVal lpTempFileName$)

Function sGetTempFileName$ ()

'Gets the name of an unused temp file using 3 letters from the

'application's title.

    Static strTemp As String * 255

    Static iRet%

    iRet = GetTempFileName(4, UCase$(App.Title), 0, strTemp)

    sGetTempFileName = sStripNull(strTemp)

End Function

Sub RegisterFileType (ByVal strExtension$, ByVal strKey$, ByVal

    strDescription$, ByVal strCommand$)

'Registers the file type in the Registration Database

Static iRet%

Static strTempFileName$

    'Get the temp file name

    strTempFileName = sGetTempFileName()

    iRet = FreeFile

    Open strTempFileName For Output As #iRet

    Print #iRet, "REGEDIT"

    Print #iRet, "HKEY_CLASSES_ROOT ." & strExtension & " = " & strKey

    Print #iRet, "HKEY_CLASSES_ROOT " & strKey & " = " & strDescription

    Print #iRet, "HKEY_CLASSES_ROOT " & strKey & " shell open command =

"

    & strCommand

    Close #iRet

    'Shell to RegEdit

    'The -s parameter turns off the message box upon completion

    iRet = Shell("REGEDIT -s " & strTempFileName)

    'Erase the temp file

    Kill strTempFileName

End Sub

__________

                           Bradley S. Murray


Registry database

LUOKKA: VBgen

25196  Juha.Nikkanen@liinos.jsp.fi  13.07.95  21:30

Juha Nikkanen: "Re: VB and registry database"

Mika Jokivuori <Mika.Jokivuori@PT5.Tempo.Mailnet.Fi> wrote:

>  How I can read registry database with Visual Basic?

>  Maybe sample programs...

Here's a quick & dirty example, which reads the registry to a listbox,

just like REGEDIT /V. The outline look you can add by changing the

listbox to an outline control.

Originally I was inspired by the PC-Magazines Delphi example,

which made me wonder how difficult it would be with VB.

Now that you happened to ask, I just had to give it a try.

I ran this only under NT 3.51, but it should work with 3.1x as well.

(Anybody with 95?)

Check the WIN 3.1 SDK Help for other registry functions.

You need a form with List1 and Command1, then paste the following to

the declarations section (NOTE, I've used the non existant  "line

continuation character_"  at the end of some long lines).

-- cut ---

Option Explicit

Declare Function RegOpenKey& Lib "Shell.dll" (ByVal hKey&, ByVal_

lpszSubKey As String, lpHkResult&)

Declare Function RegEnumKey& Lib "Shell.dll" (ByVal hKey&, ByVal_

iSubKey&, ByVal lpSzBuffer$, ByVal cBufflen&)

Declare Function RegQueryValue& Lib "Shell.dll" (ByVal hKey&, ByVal_

lpszSubKey$, ByVal lpSzBuffer$, cBufflen&)

Declare Function RegCloseKey& Lib "Shell.dll" (ByVal hKey&)

Const HKEY_CLASSES_ROOT& = 1&

Const ERROR_SUCCES& = 0&

Sub Command1_Click ()

    List1.Clear

    ' --- the root is always open, so we don't need to open it

    GetRegistry HKEY_CLASSES_ROOT, List1

End Sub

Sub GetRegistry (ByVal hKey&, lb As ListBox)

    Dim Buff$, BuffLen&, ValBuff$, ValLen&

    Dim e&, index&

    Dim hNextKey&

    Static level%   '--- indentation by level of recursion

    level = level + 1

    Buff = String(80, 0)

    BuffLen = 80

    '--- loop through the given hKey

    While RegEnumKey(hKey, index, Buff, BuffLen) = ERROR_SUCCES

       '--- get the keys value

       ValBuff$ = String(80, 0)

       ValLen = 80

       If RegQueryValue(hKey, Buff, ValBuff, ValLen) = ERROR_SUCCES_

Then

          If ValLen > 1 Then '--- if more than terminating zero

             '--- add the key name and the value

             lb.AddItem String(level - 1, 9) + Left(Buff, InStr(Buff,_

Chr(0)) - 1) + " = " + Left(ValBuff, ValLen - 1)

          Else

             '--- add the key name

             lb.AddItem String(level - 1, 9) + Left(Buff,InStr(Buff,_

Chr(0)) - 1)

          End If

       End If

       '--- open current key

       If RegOpenKey(hKey, Buff, hNextKey) = ERROR_SUCCES Then

          '--- recurse the tree

          GetRegistry hNextKey, lb

          e = RegCloseKey(hNextKey)

       End If

       '--- increment the index for current level enumeration

       index = index + 1

    Wend

    level = level - 1

End Sub

-- cut ---

--

Juha Nikkanen

Liinos Oy, Finland

email: jussi@liinos.jsp.fi

cis:   75360,1634


Registry database

LUOKKA: VBgen

Date: 10/12/94 (14:08)              Number: 22705 of 22754 (Refer# NONE)

From: RANDALL@PRIMENET.COM

Subj: Re: VB & Registry Databas

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>  How I can read registry database on Visual Basic 3.0 Pro?

>  I know API (SHELL.DLL) RegOpenKey, but I don't understand it.

Function GetRegDat (ext As String, dsc As String, exeN As String) As Integer

'gets registration database data: type description and executable

'call with ext (extension)  function puts description in dsc, exe name in exeN

'returns:

'  True if successful  -1

'  0 if can't open reg database

'  1 if can't return type

'  2 if can't return exe

'  Dsc = type (puts in second parameter)

'  exeN = executable (puts in third parameter)

'Needs the followinf declarations

'Declare Function RegOpenKey Lib "Shell.dll" (ByVal hkey As Long, Ö

'  ByVal subkey As String, phkey As Long) As Long

'Declare Function RegCloseKey Lib "Shell.dll" (ByVal hkey As Long) Ö

'  As Long

'Declare Function RegQueryValue Lib "Shell.dll" (ByVal hkey As Long, Ö

'  ByVal subkey As String, ByVal hbuff As String, buffsize As Long) Ö

'  As Long

  Dim phkey As Long

  Dim retbuff As String

  Dim sizBuff As Long

  Dim phkey2 As Long

  Dim RetBuff2 As String

  Dim sizbuff2 As Long

  GetRegDat = True

  RetBuff2 = ""

  res = RegOpenKey(HKey_Classes_Root, ByVal ext, phkey)  'open extension

                                                                                        k

  If res = 0 Then

    retbuff = String$(255, 32)

    sizBuff = 255

    res = RegQueryValue(ByVal phkey, ByVal "", ByVal retbuff, sizBuff) 'get

    If res = 0 Then

      If sizBuff > 1 Then retbuff = Left$(retbuff, sizBuff - 1)

      res = RegOpenKey(HKey_Classes_Root, ByVal retbuff, phkey2) 'open

      If res = 0 Then

        RetBuff2 = String$(255, 32)

        sizbuff2 = 255

        res = RegQueryValue(ByVal phkey2, ByVal "", ByVal RetBuff2, sizbuff2)

'get type description

        If res = 0 Then

          If sizbuff2 > 1 Then RetBuff2 = Left$(RetBuff2, sizbuff2 - 1)

          dsc = RetBuff2

        Else

          GetRegDat = 1

        End If

      Else

        GetRegDat = 1

      End If

      res = RegCloseKey(phkey2)

      retbuff = retbuff & "ÖshellÖopenÖcommand"

      res = RegOpenKey(HKey_Classes_Root, ByVal retbuff, phkey2)  'open

      If res = 0 Then

        RetBuff2 = String$(255, 32)

        sizbuff2 = 255

        res = RegQueryValue(ByVal phkey2, ByVal "", ByVal RetBuff2, sizbuff2)

'get exe

        If res = 0 Then

          If sizbuff2 > 1 Then RetBuff2 = Left$(RetBuff2, sizbuff2 - 1)

          exeN = RetBuff2

        Else

          GetRegDat = 2

        End If

      Else

        GetRegDat = 2

      End If

      res = RegCloseKey(phkey2)

    End If

  Else

    GetRegDat = 0

  End If

  res = RegCloseKey(phkey)

End Function


Resolution

LUOKKA: display

Date: 05/14/94 (11:30)              Number: 5915 of 5978 (Refer# NONE)

From: GRTORLBA@BACH.SEATTLEU.EDU, George R. Torralba

Subj: Re: Avoiding Screen Resolution Problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I think the most painless way of acheiving this is to leave the form's

.ScaleMode property to Twips.  If you need some to deal with pixel

coordinates/dimensions, use the Screen object TwipsPerPixelX/Y or toggle

the form's .ScaleMode property to Pixels.  I've been successful with this

kind of method.

George

In article <2qlvvj$p7c@eccdb1.pms.ford.com>,

Ankur Mittal <amittal@tc1225.pto.ford.com> wrote:

: Windows are Device Independent by default. But, applications developed

: using VB 3.0 aren't. Is there a simple solution to handle this? One

: solution to this might be resizing the various controls on a form_load()

: event. This can be quite annoying because of the volume and types of

: controls that exist on a form in my application. Most of my development

: work is done on an XGA 1024x768 resolution and all of my users are on

: VGA 640x480 screen resolution.


Resolution

LUOKKA: display

Date: 05/15/94 (15:02)              Number: 6063 of 6068 (Refer# NONE)

From: 90093925@VAX1.DCU.IE

Subj: Re: Re: Re: Avoiding Screen Resolution Problem

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> In article <2qnk8m$6pm@search01.news.aol.com>, gamaliel@aol.com

(Gamaliel) writes:

>> In article <2qlvvj$p7c@eccdb1.pms.ford.com>,

amittal@tc1225.pto.ford.com (

>> Ankur Mittal) writes:

>>

>> This sizing subroutine will size forms

>> and controls to assume the same appearance

>> regardless of screen resolution differences.

>> Note that Timer and Menu controls have no

>> form and are skipped for resizing. Other

>> non-problematic controls may delt with likewise.

>>

>>

>> ***** First find the resolution of your design monitor *****

>>   FORM_LOAD TO GET VALUE

>>  'Screen.TwipsPerPixelX & Y values (DesignX% & DesignY%)

>>         'To get values from Debug window use in a Form_Load

>>     Debug.Print Screen.TwipsPerPixelX

>>     Debug.Print Screen.TwipsPerPixelY

>>

>> '******************************

>>

>>   EACH FORM_LOAD

>>  'To use this sizing subroutine place this call

>>  'in each Form_Load procedure in the program

>> Dummy% = SetDeviceIndependentWindow (NAME OF FORM HERE)

>>

>> '*****************************

>>   .BAS MODULE

>> ' NOTE NOTE*** Place function in your .bas module so that all forms

>>   'can call it

>>

>> Function SetDeviceIndependentWindow (ThisForm As Form)

>> '3/13/93

>> 'Changes position and size of controls and forms

>> 'to create a device-independent form

> etc.

> etc.

>

> I too am having trouble with screen resolution and was over the moon to

> see this function. I'm developing on an Elonex SVGA and some times run >

> on a Philips VGA with the result that some controls are off the screen.

> But my design monitor (SVGA) and the other (VGA) both have 15

> TwipsPerPixel. The problem seems to be the number of pixels as opposed

> to the size of each one. When I tried calculating the X and YFactor% >

values as Number of Pixels ratios, half my window went off the screen.

> Any ideas

>

> Derek.

I'm probably just talking to myself on this one but as long as someone is

listening (debatable!) it doesn't matter.

I got around this number of pixels problem by changing

 Screen.TwipsPerPixel

to

 Screen.Width OR Screen.Height

and things are rosey in the garden now. Thank you world!!


Resolution

LUOKKA: display

Date: 06/10/94 (13:00)              Number: 8669 of 8689 (Refer# NONE)

From: TIVADAR@INTERACCESS.COM

Subj: Re: Writing for multiple Screen Resolutions

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I solved the particular problem i had with this code.  Mine was that

the control "Line" is not, obviously, placed on screen due to the LEFT,

TOP, etc.. properties, but rather by (x1,y1) and (x2,y2).

So if you also have lines on your form, then add

if TypeOf ThisControls(x) Is Line then

 ThisControls(x).x1 = ThisCOntrols(x).x1 * Xfactor

etc...

also, I nixed the TwipsPerPixelX and simply use Screen.Width

so, for me on 800x600   XDesign = 12000 instead of 15

(having converted to pixels instead of twips)

seems to work for me, tho i DO miss a single line of pixels on bottom of

screen after resolution change. i suspect it's due to roudoff error

(pixels must be in integers of course)

John Q.


Resolution

LUOKKA: display

Date: 06/25/94 (14:10)              Number: 10497 of 10514 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: What's the best way to fi

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 06-26-94 JEETE@KEA.LINCOLN.AC.NZ  wrote:

J>I've just discovered that forms created in VB with my screen set up as

J>super  VGA (800 x 600) get "chopped off" when displayed on 640 x 480

J>screens.

Now THERE's a shocker! <g>

J>Some ideas I've had:

J>1. Always design forms to the lowest screen resolution e.g. design on

J>640 x  480 then they'll always fit on 800 x 600 although they'll

J>appear smaller.

J>2.Set up a user coordinate system and use the scale properties of

J>forms together with the actual screen size (got from the Screen object

J>at  runtime) to scale controls to fit.

J>Will these ideas work? Does anyone have any better ideas? Thanks.

These ideas will work, but you'll have to keep a close eye on captions.

You cannot count on your users to have the identical system fonts as

your developement machine, so you should use the TextWidth and

TextHeight properties to verify that captions wall always fit on their

parent controls.

Look into VideoSoft's VSVBX.VBX as well.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Resolution

LUOKKA: display

Date: 06/26/94 (22:35)              Number: 10680 of 10897 (Refer# NONE)

From: M_MILIS@PAVO.CONCORDIA.CA

Subj: Re: What's the best way to fit forms on any screen?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <48035.mthompso@fox.nstn.ns.ca> "Miles Thompson"

<mthompso@fox.nstn.ns.ca> writes:

  stuff deleted

>I got tired of counting Twips, pixels, what have you so I did this.

>I kicked the machine over to standard VGA resolution, drew a form to what I

>thought should be the maximum size in VGA, named StdSize and compiled it.

>Anytime I have to check, no matter what the resolution I run it, draw my ne

>for over top, then use the close box to shut it down. You could get fancy

>and rule it off, but I wanteda quick, easy to use reference.

> Miles Thompson

> mthompso@fox.nstn.ns.ca

Another idea, if you are using a bigger display then 640x480, is to make a

640x480 bitmap and use it as wallpaper. You can then see how forms will

fit on a smaller screen. Unfortunately, I have no easy solution for seeing how

your form will look with different pixels per inch, which is when all the

fonts change.

Hope this helps,

Marko


Resolution

LUOKKA: display

21.How do I make my applications screen-resolution independent?

   There are two methods: Either get a custom control that does the

   job for you, or you write lots of complicated code in the Load and

   Resize events.

   For the first option, check out VideoSoft's $hareware VSVBX.VBX

   (download VSVBX.ZIP from Cica or mirrors). It has a will of its

   own, as you will experience, but it's generally better than trying

   what is described below.

   For the brave (or stupid), try to write "screen resolution-smart

   code" in the form's Load event. If the form is resizable (normally

   it should be), you'll have to put some magic into the Resize event

   as well. There are 4 rules of thumb:

   a. Do not trust the form's height and width properties.  These

      measure the entire form, not the client area where your controls

      are.  To see this in action, create a simple applet with the

      only code being in the resize event which resets a line control

      from 0,0 to the form's width,height properties.  The top left

      corner is in the client area, the bottom right corner

      disappears.  The API call GetClientRect will return the size of

      the client area in pixels.  You can use the screen object's

      TwipsPerPixelX and TwipsPerPixelY properties to convert from

      pixels to twips. If that's not enough, GetWindowRect will return

      the actual size of the entire form, client and non-client areas

      combined.  GetSystemMetrics will return individual pieces of

      things like border width/hight, caption height, etc.

   b. Use the TextWidth and TextHeight properties.  You can use them

      off the form if all your controls share the same font, otherwise

      use them off of the given control.  I typically do a

      TextWidth("X") and TextHeight("X") to get a value which I use as

      a margin between controls.  I grab these values on startup, and

      multiply it by 2, 1.5, .75, .5, .25 to get varying margin sizes,

      depending on how close or far apart I want to space things. If

      your control has an autosize property, you may want to use it,

      and then calculate the maximum width of a control in a given

      "column" of controls on your screen and position all of them

      accordingly.

   c. Try not to resize your controls in the resize event.  You will

      spawn another resize event in the process.  Of course, you can

      use a flag to determine whether the resize event is the original

      event or the spawned one.  Using the load event, and setting the

      forms borders to fixed minimizes the amount of work you have to

      do.

   d. Make sure you use a consistant scale.  I don't even bother with

      the scale properties, but instead just convert pixels (from API

      calls) into twips and be done with it.  If you do use scale

      properties, be sure you convert your numbers correctly.  I had

      no end of difficulty when I failed to convert into twips with

      one number that was used in a series of calculations to position

      controls.  Also be sure all your controls share the same SCALE -

      - another nasty problem I had before I gave up on them

      completely.

       Thanks to our generous anonymous source "D"


Resolution

LUOKKA: display

Date: 09/19/94 (09:16)              Number: 19978 of 20037 (Refer# NONE)

From: BALDRICK@QUAY.IE

Subj: Re: screen resolution problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

iWidth = GetSystemMetrics(SM_CXSCREEN)

iHeight = GetSystemMetrics(SM_CYSCREEN)

--

Ger O'Rourke


Resolution

LUOKKA: display

Date: 09/21/94 (01:39)              Number: 20162 of 20274 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re: screen resolution pro

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

There's always a solution. Only you can know whether it is easy or not.

For instance, the framework might start something like this:-

Sub Form_Resize()

Dim nWidth%

  nWidth = screen.Width / screen.TwipsPerPixelX

  Select Case nWidth

  Case 640

    'alignment stuff for 640x480

  Case 800

    ' alignment stuff for 800x600

  Case 1024

    ' alignment stuff for 1024x768

  Case 1280

    ' alignment stuff for 1280x960

  Case Else

    MsgBox "Sorry but we don't support this screen mode", 16

    End

  End Select

End Sub

Regards,     Email:   ian.carter@almac.co.uk

Ian C.       Tel/Fax: (+44)(0)1909-773689


Resolution

LUOKKA: display

Date:         Thu, 4 Aug 1994 12:00:45 +0300

From:         giora drachsler <giora@SHUM.CC.HUJI.AC.IL>

Subject:      Determining Screen Resolution  XE "Determining Screen

Resolution"

        The best way is a call to GetDeviceCaps. It will give you all

        you asked for plus a few more info (see list below).

        Put this declaration in the main,

Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC%, ByVal nIndex%) As

Integer

        and copy this function. You are invited to use the other options too.

Function ScreenResolution% (FormName As Form)

'Last rev. 25 Sep. 93

        ' Device Parameters for GetDeviceCaps() [nIndex%]

    'Const DRIVERVERSION = 0  '  Device driver version

    'Const TECHNOLOGY = 2     '  Device classification

    'Const HORZSIZE = 4       '  Horizontal size in millimeters

    'Const VERTSIZE = 6       '  Vertical size in millimeters

    'Const HORZRES = 8        '  Horizontal width in pixels

    'Const VERTRES = 10       '  Vertical width in pixels

    'Const BITSPIXEL = 12     '  Number of bits per pixel

    'Const PLANES = 14        '  Number of planes

    'Const NUMBRUSHES = 16    '  Number of brushes the device has

    'Const NUMPENS = 18       '  Number of pens the device has

    'Const NUMMARKERS = 20    '  Number of markers the device has

    'Const NUMFONTS = 22      '  Number of fonts the device has

    'Const NUMCOLORS = 24     '  Number of colors the device supports

    'Const PDEVICESIZE = 26   '  Size required for device descriptor

    'Const CURVECAPS = 28     '  Curve capabilities

    'Const LINECAPS = 30      '  Line capabilities

    'Const POLYGONALCAPS = 32 '  Polygonal capabilities

    'Const TEXTCAPS = 34      '  Text capabilities

    'Const CLIPCAPS = 36      '  Clipping capabilities

    'Const RASTERCAPS = 38    '  Bitblt capabilities

    'Const ASPECTX = 40       '  Length of the X leg

    'Const ASPECTY = 42       '  Length of the Y leg

    'Const ASPECTXY = 44      '  Length of the hypotenuse

    Const LOGPIXELSX = 88    '  Logical pixels/inch in X

    'Const LOGPIXELSY = 90    '  Logical pixels/inch in Y

    'Const SIZEPALETTE = 104  '  Number of entries in physical palette

    'Const NUMRESERVED = 106  '  Number of reserved entries in palette

    'Const COLORRES = 108     '  Actual color resolution

    X% = GetDeviceCaps%(FormName.hDC, LOGPIXELSX)

    'Y% = GetDeviceCaps%(FormName.hDC, LOGPIXELSY)

    ScreenResolution% = X%      ' horizontal

End Function

                                        Giora Drachsler

                                        Hebrew University

                                        Jerusalem, Israel

                                        Giora@SHUM.cc.huji.ac.il


Resolution

LUOKKA: display

Date: 10/19/94 (21:40)              Number: 23656 of 23771 (Refer# NONE)

From: GLENG@CRL.COM

Subj: Re: Video Mode at run time?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

:What's a good way to tell what video mode a user is in at run-time?  I'm now

:using TwipsPerPixelX, but that returns the same value for 1024x768 and

800x600.

Look at screen.width and screen.height. divide them by the appropriate twips

per pixel.


Resolution

LUOKKA: display

Date: 04/28/94 (09:55)              Number: 4398 of 4446 (Refer# NONE)

  To: ALL

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Resolution / Display

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 04-25-94 ROOT@SGP.HP.COM  wrote:

R>not have similar displays or monitors. Most of them have 14" display

R>and work with 640x480 resolutions. What can I do ....?

R>How can get my application to realise this or get it to display

R>correctly for each display type. Now when I display my form on

R>a 640x480 screen, the form does not fit too well and the fonts

R>looked a little 'screwed'...This is real nightmare

Use the screen object's TwipsPerPixelX and TwipsPerPixelY properties to

identify the screen's resolution, use TrueType fonts in your controls

and resize all forms, fonts and controls appropriately depending on

screen resolution.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Resolution

LUOKKA: display

Date: 11/01/94 (14:08)              Number: 25430 of 25466 (Refer# NONE)

From: CTMCCULL@CACD.ROCKWELL.COM, CHARLES T MC CULLOUGH

Subj: Re: Help with screen resolution

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Windows

>: can be configured to support a wide variety of screen resolutions and

>: colors.  Most minimal systems use the VGA driver which sets the screen

>: to 640x480 at 16 colors.  Other people have screen at 800x600,

1024x768,

>: 1280x1024 and others.  Colors range from 16 to 16.7 million.  What I need

>: to know is: how do I make my application adapt to the screen size and

>: color range of a given machine.  Of course programs for my own machine

>Check out VSVBX.VBX.  In proportional mode you can set the size of

>one of its containers and every control in the container will be

>resized proportionally.  So, your app can check the screen resolution

>(Screen control) and adjust your forms based on that.  There's a demo

>version available on ftp.cica.indiana.edu.

>

>Screen colors are another matter entirely.  I know that my Viper

>board has real problems when it's in > 256 color mode and running

>a VB app developed on a system with fewer colors.  It's a driver

>problem, and Diamond hardly ever updates its drivers.

>

I've been programming for over 25 years (not in VB obviously) and I say

this has always been and ALWAYS WILL BE a problem...  back in the days of

the MainFrame and simpleton terminals, anyone who wrote a program always

had to program for the least common denominator.  If your terminal had

blinking characters and mine didn't and you wrote your program to blink

some particular line of text and then I ran your program on my terminal,

I got a line with hieroglyphics before and after the line that was supposed

to blink.  And if your terminal did a Home and Clear of the screen and mine

did the Home the same way but the Clear a different way, then I got text

over text and a real mess.

Nowadays, if I write a program that has beautiful dark blue letters on a

lovely light blue background in 32000 color mode and you run the program

on a PC with 16 colors the blues all get mapped to the same hue and you

can't read a thing!

The only way to do things is to make sure that your program fits in the

minimal display with the 16 STANDARD colors.  Then if you detect that the

program is running at a higher resolution you can have 'Extras' visible

all the time whereas the lower resolution has to overlay the extras.

Before you release any software, switch your PC to 640x480, 16 color and

verify it fits and can be fully seen, if not, then fix it!

I have always TRIED to view the higher resolutions as, not a way for one

program to show more, but for more programs to show at one time what they

used to be able to show only one at a time.

I have written some programs that, when more screen space is detected as

being available, stretch just one or two text or list boxes vertically or

horizontally to make more of the data visable.  This usually entails

making sure the controls that might change shape are the bottom-most or

right-most objects so all I have to do is set the Height or Width to the

form size minus the Top or Left and I don't have to move a lot of other

controls around.  If I do happen to have several controls that would

have to be moved, then I put them all into a Frame at design time and

then reposition just the Frame at run time and all the objects inside

of it keep their relative position.

I haven't been able to use VSVBX and you can bet I'd use it if I had it,

but it seems funny to go to a higher resolution to see more and then make

everything bigger so you can still see it.  Kinda' self-defeating.

Charles T. McCullough

Collins Avionics and Communications Division

Rockwell

M/S 137-152

855 35th Street, N.E.

Cedar Rapids, Iowa  52498

(319) 395-5542


Resolution

LUOKKA: display

Date: 04/28/94 (15:23)              Number: 4513 of 4520 (Refer# NONE)

From: GINS@SUNSPOT.COM

Subj: Re: Resolution / Display

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2piead$lfe@hpscit.sc.hp.com> root@sgp.hp.com (Super CIM9)

writes:

>I am nearing completion of my VB project which is being developed

>on a PC with 1024x768 Ultra Video Graphics Display(17"). But to my dismay

>and shock, I realised that most of the intented end users do not have

>similar displays or monitors. Most of them have 14" display

>and work with 640x480 resolutions. What can I do ....?

Oh, you found the "gotcha".  Relax, its not all that bad.  The trick is that

you need to size and place your controls at run time, using relative positions.

So what you need to do is to write procedures that when called re-create the

design you have already built, but this time based on their relative position

within the form.

Start by sizing the form to some percentage of screen.width and sreen.height.

Then place the controls within the form based on some other variable, such

as percent of width, height, or relation to other controls within the form.

When this is done, call this routine from the form's resize event. By the way,

it usually is best to put the form sizing in the load event -- thereafter any

changes the user makes will reorganize based on the new size.

Now, no matter what the resolution, the forms organize correctly.


Resolution

LUOKKA: display

Date: 05/02/94 (10:02)              Number: 5070 of 5181 (Refer# NONE)

From: GAMALIEL@AOL.COM

Subj: Re:Writing for multiple Screen Resolutions

Read: (N/A)                         Status: PUBLIC MESSAGE

I read in a post that someone was having a problem with the appearance of

their VB forms on various systems. A customer of mine informed me of the

same problem. To solve the problem I used this resizing subroutine in my

programs..

This sizing subroutine will size forms and controls to assume the same

appearance regardless of screen resolution differences. Note that Timer and

Menu controls have no form and are skipped for resizing. Other

non-problematic controls may delt with likewise.

***** First find the resolution of your design monitor *****

  FORM_LOAD TO GET VALUE

 'Screen.TwipsPerPixelX & Y values (DesignX% & DesignY%)

        'To get values from Debug window use in a Form_Load

    Debug.Print Screen.TwipsPerPixelX

    Debug.Print Screen.TwipsPerPixelY

'******************************

  EACH FORM_LOAD

 'To use this sizing subroutine place this call

 'in each Form_Load procedure in the program

Dummy% = SetDeviceIndependentWindow (NAME OF FORM HERE)

'*****************************

  .BAS MODULE

' NOTE NOTE*** Place function in your .bas module so that all forms

' can call it

Function SetDeviceIndependentWindow (ThisForm As Form)

'3/13/93

'Changes position and size of controls and forms

'to create a device-independent form

Dim DesignX%        'Screen.TwipsPerPixelX value

            ' on design system

Dim DesignY%        'Screen.TwipsPerPixelY value

            'on design system

Dim XFactor As Single   'Horizontal resize ratio

Dim YFactor As Single   'Vertical resize ratio

Dim x As Integer    'For /Next loop variable

    'Set the Design so you avoid resizing forms on

    'systems that use the resolution of your design monitor

    'NOTE NOTE *** Change 15 to value from Debug window

DesignX% = 15: DesignY% = 15

    'Calculate the ratio of the current screen size

    'to the size of the design screen

XFactor = DesignX% / Screen.TwipsPerPixelX

YFactor = DesignY% / Screen.TwipsPerPixelY

    'If you're running on the design system

    'don't resize form and controls

If XFactor = 1 And YFactor = 1 Then Exit Function

    'Adjust ThisForm so that it is in the same relative

    'location and is porportionally the same size on the

    'current system as it is on the design system

ThisForm.Move ThisForm.Left * XFactor, ThisForm.Top * YFactor,

ThisForm.Width *

XFactor, ThisForm.Height * YFactor

    'Modify each control on the form so that it is

    'proportionally spaced and sized

For x = 0 To ThisForm.Controls.Count - 1

    'Skip sizing of timer controls

     If TypeOf ThisForm.Controls(x) Is Timer Then GoTo Nx

    'Treat Drive List and Combo Boxes differently

    'than other controls because they produce dropdown lists.

If TypeOf ThisForm.Controls(x) Is DriveListBox Then

ThisForm.Controls(x).Move ThisForm.Controls(x).Left * XFactor,

ThisForm.Controls(x).Top, ThisForm.Controls(x).Width * XFactor

ElseIf TypeOf ThisForm.Controls(x) Is ComboBox Then

    'If not simple Combo box

If ThisForm.Controls(x).Style <> 1 Then

ThisForm.Controls(x).Move ThisForm.Controls(x).Left * XFactor,

ThisForm.Controls(x).Top * YFactor, ThisForm.Controls(x).Width * XFactor

End If

Else    'Move and resize all other controls except Menu controls which are

      'text only

If TypeOf ThisForm.Controls(x) Is Menu Then GoTo Jump

ThisForm.Controls(x).Move ThisForm.Controls(x).Left * XFactor,

ThisForm.Controls(x).Top * YFactor, ThisForm.Controls(x).Width * XFactor,

ThisForm.Controls(x).Height * YFactor

Jump:

    'Adjust the font size of text box and label controls

If TypeOf ThisForm.Controls(x) Is TextBox Then

ThisForm.Controls(x).FontSize = ThisForm.Controls(x).FontSize * XFactor

ElseIf TypeOf ThisForm.Controls(x) Is Label Then

ThisForm.Controls(x).FontSize = ThisForm.Controls(x).FontSize * XFactor

ElseIf TypeOf ThisForm.Controls(x) Is CommandButton Then

ThisForm.Controls(x).FontSize = ThisForm.Controls(x).FontSize * XFactor

End If

End If

Nx:

Next x

ThisForm.FontSize = ThisForm.FontSize * XFactor

End Function


Resolution

LUOKKA: display

21640 (171+)  Christopher_Dodds@lehman.com  19.06.95  15:49

Christopher Dodds: "Re: API calls for path, and screen resolution?"

Bob Moss <jrmoss@jcpenney.com> wrote:

>orbach@odie.ee.wits.ac.za wrote:

>>I have looked in the online help for the Windows 3.1 API, but I can not

>>seem  to find the API functions to get the current path, or the API

>>functions which tell you the present resolution being used. If any one

>>could help me with this info, I would be very grateful. Even better, if there

>>are any VB commands to perform these functions, then I would really like

>>to know about them.

>    ----------

>    You can use the VB CurDir$ function to get the current path.

>    The VB TwipsPerPixelX and TwipsPerPixelY properties can help

>you determine the screen resolution indirectly; otherwise, you

>might be able to use the GetSystemMetrics API function.

>    ----------

In fact if you divide screen.width & screen.height by the relevant

TwipsPerPixelX/Y then you get the screen resolution expressed in '1024

x 768' form.


Resolution

LUOKKA: PictureBox

Date: 09/11/94 (23:19)              Number: 19062 of 19086 (Refer# NONE)

From: PAT@PHARROW.DEMON.CO.UK

Subj: Re: Q: Problem with picture scaling on high res, large font

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <34qqmc$jq5@gazette.medtronic.COM>

           nathan.torgerson@medtronic.com "Nathan Torgerson" writes:

>It appears as if the bitmap in the pictureboxes are in 1024x768, but the

>labels, panels, and

>picture box itself are the size they would be with a 800x600 display.

I had a similar problem, but with a different card. I found that by specifying

the form as a proportion of screen.width and screen.height I could overcome

the problem for MY SYSTEM I have not tried it on other systems. The code I

used in each form load was:

  name.top = screen.top * .05

  name.left = screen.left * .05

  name.width = screen.width * .9

  name.height = screen.height * .9

I copied this and pasted it into each form load, changing "name" as required.

--

Patrick Harrow


Rounding numbers

LUOKKA: numbers

Date: 06/23/94 (00:46)              Number: 10055 of 10157 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Rounding of numbers

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

X=34.40586124

Y=format$(X,"0.00")

see under Format$ in the manual for others

michael.cowan@almac.co.uk

nottingham, england


Screen autom.scaling

LUOKKA: display

Date: 04-09-95    Time: 07:02p     Number: 110

From: gcarter@chat.carleton.ca      Refer:

Subject: Sizing controls in di             0: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

Bonnie Jarvis (hjarvis@awinc.com) wrote:

> How do you make a programs user interface appear the the same on

> screen, regardless of which screen resolution the user may choose?

> If you run VB's "Learning Visual Basic" in VB's help menu, in

> different screen resolutions, you will see that it appears the same,

> regardless of the screen resolution you choose, ie: from 640 x 480 to

> 800 x 600 or higher.

> Can this be done with VB programs, or did Microsoft use another

> language to do this? If it can be done in VB, How?

I am currently using these two simple procedures to adjust the display.

Ignore the ^M, the editor I am using put these in, they are not part

of the code. Declare these two variables in a bas file:

    Global scalex As Long

    Global scaley As Long

They will be used to check the current screen resolution

Now in either you sub Main or the main form loads procedure do the following

Scalex = screen.Width / screen.TwipsPerPixelX

Scaley = screen.Height / screen.TwipsPerPixelY

Now In each forms load procedure Add the following code,

Note this is to adjust the resolution from forms designed in 800 X 600

to a display of 640 X 480.  I have found that forms designed in 800 X 600

look

fine in higher resolutions.  This code was modified from another user who was

designing in 640 X 480 and wanted to display in higher resolutions.

If scaley < 600 Then

   adjustresolution FormNameHere

End If

In the same bas file that you declared scalex and scaley, add the following

procedures

Sub adjustresolution (Source As Form)

'resize forms and then pass controls to resizing in a loop

Dim x As Integer

   Source.Height = Source.Height * (scaley / 550)

   Source.Width = Source.Width * (scalex / 750)

   Source.FontSize = Source.FontSize - 1.5

   For x = 0 To Source.Controls.Count - 1

       resizing Source.Controls(x)

   Next x

End Sub

Sub resizing (Source As Control)

'add or take away controls as needed

On Error Resume Next

If TypeOf Source Is Line Then

   Source.Y1 = Source.Y1 * (scaley / 600)

   Source.Y2 = Source.Y2 * (scaley / 600)

   Source.X1 = Source.X1 * (scalex / 800)

   Source.X2 = Source.X2 * (scalex / 800)

   Exit Sub

End If

If TypeOf Source Is Menu Then

 '  Case Menu

   Exit Sub 'menus do not resize

End If

   If TypeOf Source Is ComboBox Then

   'nothing

       Source.FontSize = Source.FontSize - 1.25

   Else

       Source.Height = Source.Height * (scaley / 600)

   End If

    Source.Left = Source.Left * (scalex / 800)

    Source.Width = Source.Width * (scalex / 800)

If TypeOf Source Is ListBox Then

    Source.FontSize = Source.FontSize - 1.25

End If

If TypeOf Source Is CheckBox Then

   Source.FontSize = Source.FontSize - 1.25

End If

If TypeOf Source Is CommandButton Then

   Source.FontSize = Source.FontSize - 1.25

End If

If TypeOf Source Is SSPanel Then

   Source.FontSize = Source.FontSize - 1.5

End If

If TypeOf Source Is SSFrame Then

   Source.FontSize = Source.FontSize - 1.5

End If

If TypeOf Source Is Frame Then

   Source.FontSize = Source.FontSize - 1.25

End If

 Source.Top = Source.Top * (scaley / 600)

End Sub

To go from forms designed in low res to higher

use

   If (scaley > 480) And (scalex > 640) Then

     adjustresolution FormName

inside adjustresolution change the code to this

   source.Top = source.Top * (scaley / 480)

   source.Height = source.Height * scaley

   source.Left = source.Left * (scaleyx / 640)

   source.Width = source.Width * scalex

In the resizing procedure add 1.25 to the font size

and scale the top, left, width, and height accordingly.

If I can find the original I will post it.  Do a search

at www.apexsc.com/vb/ in the news archives, use the key

word resolution, and you should find the original. Thats

how I found it.

----------------------------------------------------------------------

Greg Carter

4th year Electrical Engineering

Carleton University

Email address : gcarter@chat.carleton.ca

Take a look at my home page on the

World Wide Web: http://chat.carleton.ca/~gcarter


Screen autom.scaling

LUOKKA: forms

Date: 01/12/95 (10:25)              Number: 180792 of 181462 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: A scaley problem in V

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

"One trick is the automatically scaling a form to fit the dimension of the

screen by expanding or shrinking controls and font sizes. The first thing you

should do is set all of the fonts to a True Type Font. This is done by adding

AutoForm_SameFont to the Form_load subroutine:

        AutoForm_SameFont Me, "Arial"

And then in the Form_resize add AutoForm_Resize as shown below:

Sub Form_Resize ()

Static MyResize As tagAutoForm_Resize

AutoForm_Resize Me, MyResize

End Sub

The procedure AutoForm_SameFont is simply:

Sub AutoForm_SameFont (Frm As Form, ByVal AFontName$)

On Local Error Resume Next

Frm.FontName =3D AFontName$

AFontName$ =3D Frm.FontName 'Validates fontname

For i% =3D 0 To Frm.Controls.Count - 1

    Frm.Controls(i%).FontName =3D Txt$

Next i%

On Local Error GoTo 0

End Sub

The AutoForm_Resize is a bit more complex, it requires the following =

declaration and code:

Type tagAutoForm_Resize

    PriorWidth As Long

    Priorheight As Long

    OriginalWidth As Long

    Originalheight As Long

    OriginalFontSize As Double

End Type

Sub AutoForm_Resize (Frm As Form, Parms As tagAutoForm_Resize)

Dim FontX As Double, FontY As Double, Xscaling  As Double, yscaling As =

Double, Fontscaling As Double

'Do nothing if minimized

If Frm.WindowState =3D 1 Then Exit Sub

'Initialization that happens on Form_Load

If Parms.PriorWidth =3D 0 Or Parms.Priorheight =3D 0 Then

    Parms.PriorWidth =3D Frm.Width

    Parms.Priorheight =3D Frm.Height

    Parms.OriginalWidth =3D Frm.Width

    Parms.Originalheight =3D Frm.Height

    Parms.OriginalFontSize =3D Frm.FontSize

    Exit Sub

End If

'Determine scaling in each direction

Xscaling =3D Frm.Width / Parms.PriorWidth

yscaling =3D Frm.Height / Parms.Priorheight

' This is for making sure FONT stays appropriate for control

FontX =3D Frm.Width / Parms.OriginalWidth

FontY =3D Frm.Height / Parms.Originalheight

If FontX < FontY Then

        Fontscaling =3D Parms.OriginalFontSize * FontX / Frm.FontSize

Else

        Fontscaling =3D Parms.OriginalFontSize * FontY / Frm.FontSize

End If

On Error Resume Next

For i% =3D 0 To Frm.Controls.Count - 1

    If TypeOf Frm.Controls(i%) Is Menu Then

    Else

    'WARNING: Change FontSize may cause some controls to RESIZE

    'So we record dimensions PRIOR and use this after the font change

    CtlY =3D Frm.Controls(i%).Height

    CtlX =3D Frm.Controls(i%).Width

    Frm.Controls(i%).FontSize =3D Frm.Controls(i%).FontSize * Fontscaling

    Frm.Controls(i%).Move Xscaling * Frm.Controls(i%).Left, yscaling * =

Frm.Controls(i%).Top, Xscaling * CtlX, yscaling * CtlY

    End If

Next i%

On Error GoTo 0

Frm.FontSize =3D Frm.FontSize * Fontscaling

Parms.PriorWidth =3D Frm.Width

Parms.Priorheight =3D Frm.Height

End Sub

"

=A9 1994 Microsoft MSDN

Ken


Screen refresh&updatW

LUOKKA: VBgen

Date: 01/25/95 (16:37)              Number: 199799 of 201095 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: DoEvents Alternatives

     I have seen many recommendations for use of DoEvents in the past few

days. It seems that often DoEvents is recommended to speed the painting of

forms on the screen.  I just want to caution everyone that DoEvents has

some ugly consequences at times, and it should be used with caution.  In a

large routine, use of DoEvents allows Windows to process events and the

result may be triggering of other events in your application.

     For example, you have an impatient user on a slowwww system that starts

clicking things and pressing keys because your application is not

responding.  DoEvents will allow Windows to detect the user's actions much

easier than if DoEvents is not present in your code, triggering other events

before you really want them to be triggered.

     If your application is not painting forms on the screen as fast as you

     like, there are two alternatives much better than DoEvents:

     1. Form.Refresh

     2. Declare Sub UpdateWindow Lib "User" (ByVal hWnd As Integer)

        Call UpdateWindow(Form.hWnd)

     KEVIN_ALBERT@SMTPGATE.MITCHELL.COM


Screen saver

LUOKKA: VBgen

Date: 11/20/94 (12:33)              Number: 27386 of 27407 (Refer# NONE)

From: RONNYONG@UNICOMP.NET

Subj: Re: Screen Saver in Visual BASIC?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Does anyone know how to create a screen saver in Visual BASIC?

From the Microsoft Knowledge Base, available at gopher.microsoft.com:

 - In the File Make EXE File dialog, insert the string SCRNSAVE: (in

   upper case) at the beginning of the Application Title. For example:

   SCRNSAVE:Flying Fish.

 - In the File Make EXE File dialog, specify the program file name

   extension as .SCR instead of .EXE.

 - Locate the .SCR program file in the  WINDOWS directory.

 - Give your form the following property settings so that it

   occupies the entire screen and does not have a title bar:

      Caption     = ""     (no caption)

      ControlBox  = False

      MaxButton   = False

      MinButton   = False

      WindowState = 2      (maximized)

 - Place code in all MouseMove, MouseDown, and KeyDown event handlers

   that exit the program. Because Visual Basic may invoke the MouseMove

   event when the form is first loaded, you must write code to ignore

   the first MouseMove event. The following MouseMove code avoids an

   artifact event that occurs when the application is first activated or

   when the application is running and another instance starts (causing

   loss of focus) and then quits (restoring focus):

   ' Enter the following two lines as one, single line of code:

   Sub Form_MouseMove (Button As Integer, Shift As Integer,

      X As Single, Y As Single)

      Static count As Integer

      If count > 2 Then

         End

      Else

         count = count + 1

      End If

   End Sub

   This gives you a bit of slack when it comes to artifact MouseMove

   events. You'll want to do something similar with the MouseDown and

   KeyDown events.

Preventing Multiple Launches

----------------------------

Windows usually launches the screen saver program multiple times. To

prevent more than one copy of your screen saver from running, add the

following statements to the Form_Load event handler, or Sub Main if used.

Sub Form_Load ()

   If App.PrevInstance Then

      End

   End If

End Sub

There is no reason to attempt to restore the previous instance of the

screen saver as the active window because it will become the active window

when the new instance ends. All you have to do is terminate when you see

another instance running.

To prevent multiple instances of the application from running as well as to

keep the application running, you should move the code from the

Form_Load()

to a Sub Main(). Then set the project's Startup Form Option to Sub Main().

Sub Main ()

   If App.PrevInstance Then   ' If already running, end the application.

      End

   Else

      Form1.Show 1             ' Show the screen saver form.

   End If

End Sub

Launching the Screen Saver

--------------------------

Windows takes care of launching the Screen Saver. It keeps track of system

idle time and launches the screen saver program. You can use a timer

control to periodically draw graphics on the form.

Screen savers are selected and configured from Windows Control Panel in

the Desktop dialog. The screen saver section of this dialog has a button

labeled Setup that invokes the screen saver program with the command

line option /c. When your program is invoked with this option, you can

display a configuration form to allow the user to select settings such

as speed, number of objects, colors, and so on. Detect the /c command line

parameter by checking the Command$ function. For example:

Sub Form_Load ()

   If Command$ = "/c" Then

      frmConfig.Show   ' display configuration form

      Unload Me        ' bypass regular form

   End If

End Sub

When Windows launches the screen saver, it usually specifies the command

line option /s.


Screen saver

LUOKKA: VBgen

(3849/3859)

Area: Windows-kysymykset ja vastaukset

From: Matti Kohtala  To: Rauno Laukkarinen

Date: 03 Feb 95  00:56:37

Subj: Screensaver

 RL> Olen jostain kuullut, että Windowsin Screensaver-ohjelmat olisivat

 RL> tavallisia exe-tiedostoja vaikka tarkennin ei olekaan .exe

 RL> Jos näin, niin miten saisin oman exe-tiedoston toimimaan

 RL> Screensaverina?

 En tiedä millä ohjelmointikielellä ajattelit niitä tehdä,

 mutta esim. Visual Basic:llä se onnistuu seuraavasti:

 Asetetaan Properties ikkunassa Formille seuraavat ominaisuudet:

    Caption     = ""

    ControlBox  = False

    MaxButton   = False

    MinButton   = False

    WindowState = 2

 Tarkistetaan Form_Load tapahtumassa ettei saveri ole jo käynnissä,

 sekä näytetään konffausformi, jos komentoriviparametrinä on "/c".

 (Kun saverin pitäisi käynnistyä on parametrinä "/s", mutta molempia

 vaihtoehtoja ei ole tarpeen tarkistaa - mikäli se ei ole toinen sen

 täytyy olla se jäljelle jäänyt vaihtoehto).

    Sub Form_Load ()

      If App.PrevInstance Then End

      If Command$ = "/c" Then

        frmConfig.Show

        Unload Me

      End If

    End Sub

 Lisäksi täytyy lisätä End saverin lopettamiseksi ainakin MouseMove,

 MouseDown ja KeyDown tapahtumiin.

 Kun ohjelmaa kääntää EXE:ksi täytyy Application Title kohtaan laittaa:

   SCRNSAVE:Oma Saver

 ja File Name kohtaan fileen jatkeeksi .SCR, niin teksti Oma Saver näkyy

 Control Panelissa saverin valinnassa, kunhan käännetyn .SCR:n heittää

 Windows:n SYSTEM-hakemistoon.

(3855/3859)

Area: Windows-kysymykset ja vastaukset

From: Matti Kohtala  To: Matti Kohtala

Date: 03 Feb 95  19:23:35

Subj: Screensaver

 MK> Lisäksi täytyy lisätä End saverin lopettamiseksi ainakin

 MK> MouseMove, MouseDown ja KeyDown tapahtumiin.

 Lisättäköön vielä, että MouseMove tapahtumaan on hyvä lisätä pientä

 viivettä, muutoin saveri tuppaa sammumaan heti käynnistyttyään.

 Esim:

   Sub Form_MouseMove

     Static mones As Integer

     If mones = 3 Then End

     mones = mones + 1

   End Sub

 Ja vielä jos viitsii laittaa API-funktion avulla saverin

 kellumaan päälimmäiseksi, ei pitäisi saverin päälle jäädä

 missään tilanteessa muita ikkunoita.

 Eli esitellään funktio:

   Declare Function SetWindowPos Lib "user" (ByVal h%, ByVal hb%,

      ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer

 Ja esittely tietty kaikki samalle riville.

 Sitten vain asetetaan saveri kellumaan kaikkien muiden ikkunoiden päälle:

   ret% = SetWindowPos (SaveriForm.hWnd, -1, 0, 0, 0, 0, 3)

 Jos ret% <> nolla, niin operaatio on onnistunut,

 mutta sillä ei liene suurta merkitystä tässä tapauksessa.


Scroll bar slider

LUOKKA: scroll bar

Date: 07/11/94 (20:49)              Number: 11764 of 11768 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: Help needed to design a "slider"

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Simple.  Create a scroll bar (vertical or horizontal).  This is your slider

(call it Slider).  Create a Label or a TextBox.  This is your number - call it

SliderVal.

Then in the Change event for Slider put the following line:

 SliderVal = Format$(Slider.Value)

And in the Change event for SliderVal put the following line if its a text

box):

 If Val(SliderVal) > Slider.Max then

  Slider.Value = Slider.Max

 ElseIf Val(SliderVal) < Slider.Min then

  Slider.Value = Slider.Min

 Else

  Slider.Value = Val(SliderVal)

 End If

It may be better to place this in the Lost_Focus event - otherwise if you type

a value in the text box, it is immediately reflected in the sliders position,

and this updates the text box - while your editing it.  Which may make editing

hard...

This sounds like pretty much what you need.

Stephen Johnston


Scroll bars on forms

LUOKKA: scroll bar

Date: 03-14-95 (12:02)              Number: 257066 of 257250 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Scroll a Form when Forms are Limited to Screen Size

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

There is a free custom control called MhFormScroll available at CICA

and its mirror sites - look for MHFS200.ZIP.

Stephen D


Scroll bars on forms

LUOKKA: scrolling

Date: 03/30/94 (01:16)              Number: 2309 of 2518 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Scroll bars on forms?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (+)

The easiest way I can think of is to make the form an MDI child of

another form.  You can set the child's window style so that it scrolls.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatetot.com


Scroll forms

LUOKKA: forms

Date: 08/27/94 (22:15)              Number: 17461 of 17472 (Refer# NONE)

From: GLENG@CRL.COM

Subj: Re: Scrollable form

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1f.17312.1562.0NC93A40@compart.fi>,

Eino Kukkonen <eino.kukkonen@compart.fi> wrote:

>I know I can print text to a form using form.print method. There must be

>a simple way to scroll that text. Yes, that's right, you guessed it: I

>am simple too, because I haven't found how to do it. So, please, help

>somebody.

One way I've done this is to put a tall picture box on the form, print to

the picture box, and programatically move the picture box up and down

with a vertical scroll bar. I used this method for a "print preview" in

an application. Remember to set the autoredraw to true for the picture

box. Good luck!

Glen


Scroll forms

LUOKKA: forms

Date: 03-14-95 (19:06)              Number: 257450 of 262621 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Scroll a Form when Forms are Limited to Screen Size

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

On Mon, 13 Mar 1995, huan liang wrote:

> A VB form can't be sized larger than the screen, but is there a way to scroll

> the contents of a form to enlarge the usalbe area of a form?

        You can put a Picture control in your form and size it to any size that

you desire. Then put other controls inside Picture control (Inside means

select picture as current control and drag&drop other control on picture

control). Put a vertical and/or horizontal scroll bar on a form (not inside

picture control) and set MaxValue property to appropriate value. The rest is

some more code in scroll bar's change event for move picture control

up/down/left/right by move method.

        When complete, for users view, they feel the form is scrollable

BUT ,In fact, the picture is scrolled.


Scrollbar

LUOKKA: ListBox

Date: 12/01/94 (11:14)              Number: 28542 of 28565 (Refer# NONE)

From: ME@CANIS.METAWORKS.DE

Subj: Re: Listbox question

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> How do I add a Horizontal scrollbar to a Listbox ?

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg  As Integer, ByVal wParam As Integer, lParam As Any) As Long

Global Const WM_USER = &H400

Global Const LB_SETHORIZONTALEXTENT = (WM_USER+21)

ok& = SendMessage(List1.hWnd, LB_SETHORIZONTALEXTENT, cxExtent,

0)

cxExtent specifies the number of pixels by which the list box can be

scrolled.

By default, the horizontal extent of a list box is zero. Windows does not

display the scroll bar unless the horizontal extent is set to a value

greater than the width, in pixels, of the client area of the list box.

This message is not useful for multicolumn listboxes. Multicolumn

listboxes should instead use the LB_SETCOLUMNWIDTH message.


Scrolling

LUOKKA: scrolling

Date: 05/28/94 (12:10)              Number: 7310 of 7311 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: Displaying data in VB 3.0 pro

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

It's a 2D problem, but it can be split quite easily into two 1D problems. Try

getting it working for vertical scrolling first, then worry about horizontal

as well. Horizontal is sometimes slightly harder; although a line will

usually be much the same height, they can often vary in length.

Place a PictureBox on your form, the size of the area that you want to

contain your data. The code that displays it then goes in picReport_Paint.

The first thing to do is to work out the size of the data, how it fits into

the picture, and whether scroll bars are needed. This needs to be redone if

anything changes, so put it in a separate procedure and call it from

Form_Activate. Calculate the overall space needed to show the entire data

(approximately is OK, if it would be difficult or slow to do it accurately).

This usually involves counting the lines needed, then mutiplying by

TextHeight() to get it in twips. If the height needed is bigger than that

available, then enable the vertical scroll bar. The scroll bar will usually

go from 0 to a number of twips

= (Number_of_Data_Lines * StandardTextHeight) - picReport.Height

LargeChange & SmallChange should also be set from the code;

   scrlVReport.SmallChange = StandardTextHeight

   scrlVReport.LargeChange = picReport.Height * 0.9

may be a good starting point.

It's convenient to think of the drawing happening onto a conceptual area

that is larger that the picture's client area. Work with a set of co-ordinates

that are based on their (0,0) origin being at the picture's origin. This

makes it easier to do the scrolling & clipping, based on the picture box's

extent. The start of the virtual coordinate space is at -1 * the current

value of the scrollbar.

You could rely on the picture box's own clipping. However it's usually some

effort to calculate the data, and doing your own clipping can be used to

show when it's time to stop calculating.

Inside picReport_Paint itself, use some code roughly like the following.

This has been typed directly into my net.box, so apologies if it's a bit

rough. If you can't make sense of it, mail me and I'll dig out a genuine

example

sub picReport_Paint

dim ThisLineY as integer

dim StandardTextHeight as integer

   ' Erase the background - very necessary when scrolling is used

   picReport.Cls

   ' Calculate the text height once and store it.

   ' This is quicker, and it gives more consistent line spacing

   StandardTextHeight = TextHeight ("Xg9")

   ' Start from the beginning of our virtual coordinate space

   ' NB *minus* the scrollbar value

   ThisLineY = - scrlVReport

   snpData.MoveFirst

   do while not snpData.EOF

      if (ThisLineY >= 0) and (ThisLineY <= picReport.Height) then

         ' NB - Use picReport.*, not Form.*

         picReport.CurrentX = ThisLineY

         picReport.Print snpData! My Data

      end if

      ThisLineY = ThisLineY + StandardTextHeight

      snpData.MoveNext

   loop

end sub

The scrollbar _Change events should call picReport.Refresh. This causes

Windows to issue a paint event to picReport. If the data changes, then re-do

the size calculation and call picReport.Refresh.

You'll also need to watch the Form_Resize event. It's usual to resize the

picture at this point, making it a fixed amount less than the size of the

form. Obviously this will then entail calling the sizing subroutine &

refreshing the picture.

A list box is by far the simplest way, if it's good enough for waht you need.

--

Andy Dingley     Codesmiths of Newcastle

dingbat@codesmth.demon.co.uk


Scrolling

LUOKKA: scrolling

Date: 06/22/94 (10:00)              Number: 9815 of 9875 (Refer# NONE)

  To: ALL

From: JONAS@WAM.UMD.EDU

Subj: Re: Scrollable, NON-Editable text?

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Just for your information, though, I did it a different (and much harder)

way.  I put a picture box inside of a frame and placed a scroll bar next

to the frame controlling the .top location of the picture box.  This has

the advantage that the curser dosen't change in the box or highlight

any of the text.  This is a good solution for me because I wanted the

user to be able to click on a certain word in the box and pull up a

different form.  You write to the picture box with the .print command.

Scrolling, while passible, is not great.

 Thanks again, hope people learned stuff,

  Jonas Keating


Scrolling

LUOKKA: scrolling

Date: 06/26/94 (03:52)              Number: 10568 of 10664 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: How to Scroll text like cast in MOVIES?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> :  In VB, is it impossible to simulate text scrolling similar to

> : the cast scrolling in movie endings? I have VB pro, so solutions must

> : limit to the VBX in the pro edition.

There is an excellent sample program to do this in the VB How-to book.

Here is a modification I made of the sample for the gangscreen in one of

my apps (Padlock, folks, the thinking man's screenlocker, available by

anon. ftp from ftp.demon.co.uk). Please forgive the crappy code quality

- I wrote this bit two years ago.

You need a form with two picture boxes, one inside the other. You also

need two timers (you could get away with one - I used the second here to

time-out the gangscreen, rather than use a command button).

VERSION 2.00

Begin Form gangscreen

   BackColor       =   &H00808080&

   Caption         =   "The Padlock Gang Screen"

   ClientHeight    =   4032

   ClientLeft      =   3408

   ClientTop       =   2400

   ClientWidth     =   4140

   ControlBox      =   0   'False

   Height          =   4452

   Left            =   3360

   LinkMode        =   1  'Source

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   4032

   ScaleWidth      =   4140

   Top             =   2028

   Width           =   4236

   Begin Timer Timer2

      Enabled         =   0   'False

      Interval        =   1000

      Left            =   3888

      Top             =   4056

   End

   Begin Timer Timer1

      Enabled         =   0   'False

      Interval        =   5

      Left            =   3288

      Tag             =   "2"

      Top             =   4068

   End

   Begin PictureBox Picture1

      BackColor       =   &H00808080&

      Height          =   3855

      Left            =   150

      ScaleHeight     =   3828

      ScaleWidth      =   3888

      TabIndex        =   0

      Top             =   105

      Width           =   3915

      Begin PictureBox Picture2

         BackColor       =   &H00808080&

         BorderStyle     =   0  'None

         Height          =   2235

         Left            =   105

         ScaleHeight     =   2232

         ScaleWidth      =   3612

         TabIndex        =   1

         Top             =   165

         Width           =   3615

      End

   End

End

Sub Form_Load ()

    Timer1.enabled = 0

    Picture1.Cls

    Picture2.visible = 0

    Picture2.AutoRedraw = -1

    Picture2.Top = Picture1.scaleheight

    Picture2.backcolor = Picture1.backcolor

    Picture2.height = 14 * Picture1.TextHeight("A")

    Picture2.CurrentY = 0

    PrintCentre Picture2, ""

    PrintCentre Picture2, "Padlock was created"

    PrintCentre Picture2, "during September 1992"

    PrintCentre Picture2, "using Visual Basic"

    PrintCentre Picture2, "with the help of..."

    PrintCentre Picture2, ""

    PrintCentre Picture2, "PaulD"

    PrintCentre Picture2, "RobinG"

    PrintCentre Picture2, "SteveC"

    PrintCentre Picture2, "JackO'H"

    PrintCentre Picture2, "AlanV"

    PrintCentre Picture2, "AlecS"

    PrintCentre Picture2, ""

    PrintCentre Picture2, "Plus..."

    Picture2.visible = -1

    Timer1.enabled = -1

End Sub

Sub PrintCentre (C As Control, Txt As String)

    'Display text in the centre of the control

    C.CurrentX = (C.Scalewidth - C.TextWidth(Txt)) / 2

    C.Print Txt

End Sub

Sub Timer1_Timer ()

    Delta = Val(Timer1.Tag)

    Picture1.Scalemode = 3

    If Picture2.Top + Picture2.height > 0 Then

 Picture2.Top = Picture2.Top - Delta

    Else

 Timer1.enabled = 0

 Picture1.fontsize = 16

 Picture1.CurrentY = Picture1.scaleheight / 2

 Txt$ = "Ian Michael Piper"

 Picture1.CurrentX = (Picture1.Scalewidth - Picture1.TextWidth(Txt$)) / 2

 Picture1.Print Txt$

 Timer2.enabled = -1

    End If

End Sub

Sub Timer2_Timer ()

    Unload gangscreen

End Sub


Scrolling

LUOKKA: scrolling

Date: 08/27/94 (09:33)              Number: 17375 of 17472 (Refer# NONE)

From: JNICHOLS@RAIN.ORG

Subj: Re: Smooth scrolling

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The easiest way is to use nested Picture Boxes, one created within

another.  Then you simply use the Move funtion or change the value of the

child box's Top property.  Use the Print funtion to display text on the

child Picture box.  Source code would look something like this:

FormLoad()

Picture1.Scalemode = Pixel  'Parent Picture Box

Picture2.Scalemode = Pixel  'Child Picture Box

Picture2.Top = Picture1.ScaleHeight  'Set the child box out of sight at

the bottom of the parent box

Timer1_Timer()

Picture2.Top = Picture2.Top - 1  'Scroll the text upwards

It should be as simple as that.

J. Nichols


Scrolling

LUOKKA: scrolling

Date: 08/29/94 (13:54)              Number: 17716 of 17760 (Refer# NONE)

From: WEIKKO.IKOLA@CSC.FI

Subj: Re: Scrollable form

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>In article <1f.17312.1562.0NC93A40@compart.fi>,

>Eino Kukkonen <eino.kukkonen@compart.fi> wrote:

>One way I've done this is to put a tall picture box on the form, print to

>the picture box, and programatically move the picture box up and down

>with a vertical scroll bar. I used this method for a "print preview" in

>an application. Remember to set the autoredraw to true for the picture

>box. Good luck!

If you have, say, hundreds of lines of text, remember to set the AutoRedraw

to False to make your hard disk (and end users) live longer, and take care of

the repainting yourself. Also remember that a picture box's maximum Height is

32K, which is about 800 lines with FixedSys 10,8.

Greetings,

Wende (weikko.ikola@csc.fi)


Scrolling

LUOKKA: scrolling

Date: 08/29/94 (14:57)              Number: 17721 of 17760 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: VB Gurus Only - AutoRedraw

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I must have some fundamental misunderstanding of what you are

trying to do.  A pic box doesn't repaint whenever you output to it.

But maybe it is the back color that is messing you up, since that will

paint the whole background.

So, working from the assumption that what I think you want to do is show

text with various background colors in various places (if this is wrong,

then ignore this) I'd suggest you try a pure VB approach before giving in

to all the API stuff.  Being able to go to the API is great, and often

essential, but when it's not needed, one ends up with more portable code

by staying in plain VB.

To do the different background colors in VB you can use the line method

with BF on the end for a filled box.  You want do write a string, and you

know where you want it.  So first, use textwidth and textheight on the

string to get the length and width of the rectangle.  Move current x,y to

the proper place.  Draw the rect. with the line method using the color you

want for the background.  Move current x,y back to where they were.  Set

the forecolor and use the print method on your text.  Note that you may want

to increase the size of the rect. a bit to get the precise appearance you

want.

I think you'll probably find this plenty fast and if so, a simpler, more

portable approach.

gt


Scrolling

LUOKKA: scrolling

Date: 08/29/94 (23:12)              Number: 17796 of 17864 (Refer# NONE)

From: TAYLOR@SATURN.BROOKS.AF.MIL, William D. Taylor

Subj: Re: VB Gurus Only - AutoRedraw

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You aren't the only person to say that it doesn't repaint.  However, I beg to

differ.  By default, the AutoRedraw a picture control is false, and you are

correct--it doesn't redraw the entire control.  However, you will find that if

the picture control gets covered up by another window (or minimized), it will

not redraw itself when it is uncovered (or restored).  This is not acceptable

for my application.

So.. the obvious solution is to set the AutoRedraw property to True.  That's

what it's for, isn't it?  That's when the entire control appears to redraw

itself every time a graphics method is used.  If you print a single character

(or draw a line--whatever), say in the upper left corner of the control, while

the mouse pointer is in the lower right, you will see the mouse pointer flash.

Unless I am quite mistaken (and I have been wrong once before), this

indicates that the entire control is being redrawn.  Try it before you post.

This doesn't happen when AutoRedraw is False.

Here's some code I just tried to make sure I wasn't dreaming again...

Start a new project and drop a picture control (Picture1) on the form.

Add this code:

Sub Form_Load ()

    Picture1.AutoRedraw = True

End Sub

Sub Picture1_Click ()

    Picture1.Print "A";

End Sub

Now, click somewhere in the lower-right of the control.  See the pointer

blink?  Cover and uncover the control.  It redraws itself.

Try this again with Picture1.AutoRedraw = False.  The pointer doesn't blink

anymore.  Cover and uncover the control.. it doesn't redraw itself anymore,

either.

If someone else's VB acts differently, please post.

Now, if I wanted to store everything on the control in an array, I could

write a routine to redisplay all of the graphics methods on the control in the

Paint event, but I don't want to.

>To do the different background colors in VB you can use the line method

>with BF on the end for a filled box.  You want do write a string, and you

>know where you want it.  So first, use textwidth and textheight on the

>string to get the length and width of the rectangle.  Move current x,y to

>the proper place.  Draw the rect. with the line method using the color you

>want for the background.  Move current x,y back to where they were.  Set

>the forecolor and use the print method on your text.  Note that you may

want

>to increase the size of the rect. a bit to get the precise appearance you

>want.

Interesting approach.  If I can get the control to stop redrawing itself

completely for every graphics method, and have it redraw when uncovered, I

will certainly attempt pure VB methods.  In fact, I originally wrote the code

using only VB methods, when I ran into unacceptable performance and tried

the API route.

Ed Staffin's post may be a solution, but it is too complex for me and

for something that should not be such a big problem.

Last, I would like to use BitBlt to erase parts of the control to the

background window color, but don't I have to have a source bitmap?  I don't

really want to create a source bitmap, I just want to erase at the destination.

-WDT


Scrolling

LUOKKA: scrolling

Date: 08/30/94 (15:35)              Number: 17859 of 17864 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: VB Gurus Only - AutoRedraw

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I've pretty well convinced myself that it only repaints the invalid rect

even with AutoDraw set to true.  Here's the basic steps I used:

1. Set AD true.

2. print a bunch of text

3. relocate x,y back up

4. Set AD false.

5. change color (for visual ease)

6. print some more text.

7. Set AD back to true.

Now, when you play around hiding and exposing various little sections, you

will see that the text you printed while false, is NOT cleared out except

in the invalid rect that needs painting.  If it was blting the whole pic

then that would get wiped out too.

gt


Scrolling

LUOKKA: scrolling

Date: 09/03/94 (14:21)              Number: 18139 of 18257 (Refer# NONE)

From: DANC@DELLGATE.US.DELL.COM

Subj: Re: Scrollable form

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Message-ID: <danc.88.2E67A24B@dellgate.us.dell.com>

>The only way I've come across so far (apart from buying a third

>party add-on) is to place an Image object so that it takes up the

>width of the form, plus as much height as you need.  Then you

>print to the Image (or is it picture control?) and can scroll

>quickly by using the Move command to reposition the image.

Something that I have done is simular to this. I first created a scrolling

region that is included in the VB help file under the knowledge base section.

I added a couple of commands in the form resize event to keep the outside

picture box and scroll bars along the edges. If the form is large enough, make

the scroll bars invisible. With that done, you should be able to place just

about any control you want on the inside picture box.

Dan Champagne

danc@dellgate.us.dell.com


Scrolling

LUOKKA: scrolling

Date: 09/06/94 (14:18)              Number: 18414 of 18426 (Refer# NONE)

From: WEIKKO.IKOLA@CSC.FI

Subj: Re:  Q  scrollable PictureBox  URGENT

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Create a picbox (here called picDoc)

Create a vertical scrollbar beside it (here called scrPicDoc)

Calculate the picbox height that you need, e.g. picDoc.Height =

NumberOfLines

* picDoc.TextHeight("W"). Keep in mind that a picbox's max height is 32K,

that's about 800 lines with Fixedsys 10,8 font.

'Set the scrollbar defaults.

'panDoc is a container (SSPanel) for picDoc.

scrPicDoc.Height = panDoc.Height

scrPicDoc.Max = picDoc.Height / screen.TwipsPerPixelY

scrPicDoc.SmallChange = picDoc.TextHeight("W") / screen.TwipsPerPixelY

scrPicDoc.LargeChange = scrPicDoc.Height / screen.TwipsPerPixelY

scrPicDoc.Value = 0

When scrolling:

Sub scrPicDoc_Change ()

    picDoc.Top = -scrPicDoc.Value * screen.TwipsPerPixelY

End Sub

Greetings,

Wende (weikko.ikola@csc.fi)


Scrolling like movies

LUOKKA: scrolling

Date: 06/26/94 (23:09)              Number: 10683 of 10897 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: How to Scroll text like cast in MOVIES?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Well, you could make a large text string delimited by spaces and set it to

the caption fo a label (with alignment center). Use a timer for the delay

and scan the text for CRLF's and remove them and reprint the text.

Here's a code example:

Global sCredits As String

Sub Form_Load()

    sCredits = Chr$(13)+Chr$(10)+"Thanks to"+Chr$(13)+Chr$(10)+"Mary

       Jane"+Chr$(13)+Chr$(13)+"Edgar Allen Poe"+Chr$(....

End Sub

Sub Timer1_Timer()

    If Instr(sCredits, Chr$(13)>0 Then

        sCredits = Mid$(sCredits, Instr(sCredits, Chr(13)) + 2)

        Label1.Caption = sCredits

    End If

End Sub

To modify the Interval for the Timer you can make the text go slower

and quicker.

Arjen


Scrolling like movies

LUOKKA: scrolling

Date: 06/30/94 (23:20)              Number: 10808 of 10897 (Refer# NONE)

From: ANDERS.GIDLOEF@ITAB.CT.SE

Subj: How to Scroll text like cast in MOVIES?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

One Picture-control with ScaleMode=Pixel (3)

One Text-control inside the Picture-control with Align=Center (2),

Multiline=True

One Timer-control with Interval=2

Expand the Text-control so that all text you want in will fit, but place it

with the first row in the bottom of the picture-control.

In Form_Load concatenate the Text you want to have with Chr$(13) &

Chr$(10) last on every row.

In the Timer1_Timer event place this code:

If Text1.Top < -Text1.Height Then

   Text1.Top = Picture1.ScaleHeight

Else

   Text1.Top = Text1.Top - 1

End If

This works great for me (at least ;)

Rgds Anders

agf@itab.ct.se


Scrolling report 1/2

LUOKKA: scrolling

Date: 05/25/94 (01:22)              Number: 6841 of 6934 (Refer# NONE)

 From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: Refresh & the Paint event

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> Andy Dingley (dingbat@codesmth.demon.co.uk) wrote:

> I'm trying to write a scrolling form, as a viewer for a report. The form

> has a 3D panel on it, with a vertical scroll bar alongside, and the report

> itself is drawn on a picture that sits on the panel. All the drawing takes

> place in the picture's _Paint method.

I want (in simple terms) to have a scrolling report appear on a form. I want

it to appear within an inscribed 3D panel. If it's a big report, I'd like a

vertical scrollbar at the side of the panel. I need to draw some text, and

some rectangular boxes -- nothing flash.

I really am having big trouble getting this to work right, and can't imagine

why anything so simple should be so awkward in VB (I could do it in Pascal in

a fraction of this time).

Now panels don't provide a _Paint event, so I placed a Picture onto the

panel, so that I could use its _Paint event. I suppose I could equally well

use the form's _Paint event, but a picture box (incorrectly) seemed like it

would allow simpler clipping & triggering of the redraw.

First problem: all VB graphics output appears on the layer underneath the

panel and is hidden from view. I can't change the layering, so I need to turn

ClipControls off. Now all hell breaks loose, and picReport_Paint no longer

gets called when I'd expect it to; if I call Refresh, if the form is hidden &

uncovered, or if the form is resized.

Why can't I just put code in my _Paint event, and call picReport.Refresh

when want to change it ? What's the magic ?

At present, I'm using the API RedrawWindow() function (explicitly called

after making the report, after scrolling and after resizing the form) to

trigger the _Paint event. Messy 8-(

*Surely* someone has already done this ? It must be a fairly common

requirement.

--

Andy Dingley     Codesmiths of Newcastle

dingbat@codesmth.demon.co.uk


Scrolling report 2/2

LUOKKA: scrolling

Date: 05/25/94 (01:46)              Number: 6847 of 6934 (Refer# NONE)

From: SHEA@MARCAM.COM

Subj: Re: Refresh & the Paint event

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <769809126snz@codesmth.demon.co.uk>

dingbat@codesmth.demon.co.uk (Andy Dingley) writes:

>First problem: all VB graphics output appears on the layer underneath the

>panel and is hidden from view. I can't change the layering, so I need to turn

>ClipControls off. Now all hell breaks loose, and picReport_Paint no longer

>gets called when I'd expect it to; if I call Refresh, if the form is hidden &

>uncovered, or if the form is resized.

I don't understand the problem you are having. I just tried (what I think you

are trying to do) & it worked. I've also done a lot of scrolling areas within

beveled 3-D frames before & had no problems. I just:

1. Created a form (called Form1).

2. Created a 3-D Frame on it (called ClipFrame).

3. Created a PictureBox (called Bgnd), and GROUPED IT inside ClipFrame.

4. Added the following code to Bgnd_Paint():

        Bgnd.Line (0,0)-(1000,1000)

This drew the line on Bgnd correctly. (Note if you omit the "Bgnd." from

the call to "Line" it will draw on Form1, not the "Bgnd" Picture Box.)

You can scroll up and down easily by changing the Bgnd.Top property

in response to scroll events. A little math will give you the proper

.Min and .Max values for your scroll bar. ClipFrame will clip Bgnd

(and any graphics on it).

--------------------------------------------------------------------

Tim Shea    Internet: shea@marcam.com    Phone (USA): (617) 965-0220


Scrolling report 3/3

LUOKKA: scrolling

Date: 05/25/94 (09:47)              Number: 6861 of 6934 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Refresh & the Paint event

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The code below might illustrate what you want:

---------------cut here------------------------

VERSION 2.00

Begin Form Form1

   Caption         =   "Form1"

   ClientHeight    =   4860

   ClientLeft      =   285

   ClientTop       =   1965

   ClientWidth     =   6855

   Height          =   5265

   Left            =   225

   LinkTopic       =   "Form1"

   ScaleHeight     =   4860

   ScaleWidth      =   6855

   Top             =   1620

   Width           =   6975

   Begin VScrollBar S1

      Height          =   4470

      LargeChange     =   3

      Left            =   6105

      Max             =   10

      TabIndex        =   1

      Top             =   120

      Width           =   405

   End

   Begin SSPanel Panel3D1

      Alignment       =   6  'Center - TOP

      BevelInner      =   1  'Inset

      BevelWidth      =   2

      BorderWidth     =   4

      Caption         =   "Hi Andy"

      Font3D          =   4  'Inset w/heavy shading

      FontBold        =   -1  'True

      FontItalic      =   0   'False

      FontName        =   "MS Sans Serif"

      FontSize        =   18

      FontStrikethru  =   0   'False

      FontUnderline   =   0   'False

      Height          =   4440

      Left            =   165

      TabIndex        =   0

      Top             =   120

      Width           =   5940

      Begin PictureBox P1

         BackColor       =   &H00C0C0C0&

         BorderStyle     =   0  'None

         Height          =   3615

         Left            =   255

         ScaleHeight     =   3615

         ScaleWidth      =   5505

         TabIndex        =   2

         Top             =   600

         Width           =   5505

      End

   End

End

Option Explicit

Sub P1_paint ()

'this does nothing sensible, just uses randoms everywhere to

'simulate movement

Dim cr$

Dim i%, x%

cr$ = Chr$(13) & Chr$(10)

p1.Cls

p1.CurrentX = Int(Rnd * 900)

p1.CurrentY = Int(Rnd * 3300)

p1.Print "Thought for today..." & cr$

p1.Print cr$

p1.Print "    Help save the plankton! " & cr$

x% = Form1!S1.Value + 1

For i% = 1 To 20

 p1.Circle Step(500, 200 Ö (1 + (x% * Rnd + .2))), Int((800 Ö i%) * (x% * Rnd +

1)), RGB(Int(Rnd * 255), Int(Rnd * 255), i * 8), , , Rnd + .3

Next

End Sub

Sub S1_Change ()

Call P1_paint

End Sub


Scrolling static text

LUOKKA: scrolling

Date: 01/18/95 (15:44)              Number: 189976 of 191526 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Showing static text file

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

> >I have the following problem:

> >I want to show a static text file to the user, and he should not be

> >able to edit or to select the text. There should not be a scroll bar

> >but two spin buttons to scroll a whole page.

>

> It means a bit of work (for scrolling etc) but you could try printing the

> text to a picture box.

>

> >I already tried to set the text control to READONLY via Sendmessage, but

> the

> >user still can select with the mouse.

>

> Alternatively try putting

>      Command1.SetFocus ' Or something similar

>

> into the mouse down event for the text control and using the readonly

> message.  This means the user can neither edit not select using the mouse.

>

> Sadler

> S.P.Johnson@open.ac.uk

I agree with S.P.Johnson.  I have read a file into an array (one line for

each postion in the array - Dim FileArray(10000) As String * 80).  I then

printed the lines to be viewed to a picture box.  Actually there were two

picture boxes, one off screen which was printed to and another onscreen

which had the offscreen image copied to it for greater speed.  The code I

have uses a scroll bar and the .value property to know which lines to

print, but this could be modified to us the spin button and a global

"page" value.  I cannot take the credit for this idea as I got it off of

Compuserve and modified to fit my needs.  If you are interested I can send

you the example.

HTH

Mike Strange

Lead Systems Analyst


Scrolling1

LUOKKA: scrolling

Date: 08/27/94 (23:46)              Number: 17480 of 17567 (Refer# NONE)

From: TAYLOR@SATURN.BROOKS.AF.MIL, William D. Taylor

Subj: VB Gurus Only - AutoRedra

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I am writing an application that uses a picture control to display text.  I am

using API calls to manipulate the text, because of the dismal performance of

VB's output methods.  (VB likes to redraw the entire picture control when

anything is output to it.  Stupid.)  I would like to take advantage of VB's

"persistent bitmap" to automatically redraw portions of the picture box when

necessary.

According to the help file, when the AutoRedraw property is True, the

control's hDC property points to the persistent bitmap, and when the

AutoRedraw property is False, the hDC property points to the window hDC.

So, for example, to output text to the control, I use the following code:

   Declare Sub TextOut Lib "GDI" (ByVal hDC%, ByVal x%, ByVal y%,

     ByVal lpString$, ByVal nCount%)

   Picture1.AutoRedraw = False

   TextOut Picture1.hDC, X, Y, strText, Len(strText)

   Picture1.AutoRedraw = True

   TextOut Picture1.hDC, X, Y, strText, Len(strText)

This works as it should.  The problem begins when I wish to change the

background color for text display (not the entire control background).  I use

the following code:

   Declare Sub SetBkColor Lib "GDI" (ByVal hDC%, ByVal newcolor&)

   Picture1.AutoRedraw = False

   SetBkColor Picture1.hDC, RGB(0,0,255)

   Picture1.AutoRedraw = True

   SetBkColor Picture1.hDC, RGB(0,0,255)

The background color change is completely ignored.  If I don't set the

AutoRedraw property to True, the text is displayed with a blue background as

desired, but when the control is repainted, the VB background color takes

over.  As soon as the AutoRedraw property is set to True, the entire

background becomes the VB background color.

Why does this happen, and is there any work-around?  All other API calls

using the device context handles work as expected, including SetTextColor.

The only one I can't get to work properly is SetBkColor.  It appears that when

the control is repainted, VB repaints the background using a background

color it has stored somewhere, rather than the background color of the

device context.

Also, if someone knows an efficient way to erase part of a window to its

background color, that would be helpful.  Right now, I am using PatBlt with

WHITENESS as the dwROP parameter.  However, I don't really want white

output, I want the background color of the window.

Thanx for any info..

-WDT


Scrolling2

LUOKKA: scrolling

Date: 08/28/94 (08:48)              Number: 17535 of 17567 (Refer# NONE)

From: EDSTAFF@MCS.COM

Subj: Re: VB Gurus Only - AutoRedraw

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I don't know if I want to answer this. Does answering this mean I am a

"Guru?" I hope not.  Anyhow ...

Well, I believe what you need is to trap the WM_CTLCOLOR message and

return a handle to a brush of the color you want. This means you have to

create one of the color you want. Now I have never done this in VB, only in

C, so I can't guarantee this works, but it should. Use my msgblast.vbx to

catch the WM_CTLCOLOR. Read up on this message.  Doing at SetBkColor

is not enough.

BTW, on your other question, BitBlt is lightning fast. One thing I suppose you

could do is do a FillRect, but I haven't tried it so no guarantees.

Later ... Ed


Search incr.

LUOKKA: ListBox

Date: 07/31/94 (18:20)              Number: 13933 of 14165 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Typing to list: has this been done?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Incremental

It's very simple. Look up the LB_SELECTSTRING message for listboxes in

the windows-helpfile. With the SendMessage API you can send this message

to the listbox. It will automatically select the right string.

Here's an example that 'duplicates' the search in WinHelp:

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Const WM_USER = &H400

Const LB_SELECTSTRING = (WM_USER+13)

Sub Text1_Change()

Dim sString As String

Dim wIndex As Long

    sString = Text1.Text

    wIndex = SendMessage(List1.hWnd, LB_SELECTSTRING, -1, ByVal

sString)

End Sub

The -1 tells the ListBox to start searching at the beginning. If you

want to start searching from a certain index, put that index instead of

the -1.

--

Arjen Broeze                                   Telephone: (+31)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13


Search incr.

LUOKKA: ListBox

============================================================

Date:         Thu, 22 Sep 1994 21:15:32 WST

From:         Chris Chillidog Chelliah <chelliah@CS.UWA.EDU.AU>

Subject:      Incremental search - Reply

Here's some code I've written to just that.  But this only searches for

entries in the listbox that start with the searchkey.  I've got some

code that searches anywhere within a listbox entry, but that's a little

deviant for now!! :-)

This code works for me fine, ... keep me informed on how it goes for

you.

___________

chelliah@cs.uwa.edu.au    _--_|\        Christopher Chelliah

hunk@tartarus.uwa.edu.au /      \       Dept of Computer Science

Phone: +61-91-43-4523    *_.--._/       The University of Western Australia

FAX:   +61-91 43-4798          v        Crawley, Perth           6009

------CODE--------------------

'This is a segment of code from a PhoneBook application I wrote.

'lstNumbers is a listbox with the phone details.  Eg. a typical entry in

' this listbox is :

'                       Bloggs, Joe     Ext. 4523

'txtSearchKey is a textbox that the user is typing the search key in

'flgEditing is a form level variable defined as integer.  It prevents a

'recursive event chain

'

'To run this bit of code, create a new form with a listbox (called

'lstNumbers) and a textbox

'(called txtSearchKey) and paste this code in.

'This declaration has to be made on one continuous line

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal

wMsg As Integer, ByVal wParam As Integer, lparam As Any) As Long

Sub txtSearchKey_Change ()

    Dim nIdx As Integer, strTemp As String

    Const LB_FINDSTRING = WM_USER + 16

    Const LB_SETTOPINDEX = WM_USER + 24

    If (flgEditing = True) Or (lstNumbers.ListCount < 1) Then

        'Prevent an endless event loop!

       Exit Sub

    End If

    flgEditing = True

    strTemp = (txtSearchKey.Text)

    nKeyedLength = Len(strTemp)

    nIdx = SendMessage(lstNumbers.hWnd, LB_FINDSTRING, -1, ByVal

     strTemp)

    If nIdx <> -1 Then

       txtSearchKey.Text = lstNumbers.List(nIdx)

       txtSearchKey.SelStart = nKeyedLength

       txtSearchKey.SelLength = Len(txtSearchKey.Text) - nKeyedLength + 1

       lstNumbers.ListIndex = nIdx

    else

       lstNumbers.listindex = -1

    End If

    flgEditing = False

End Sub

Sub txtSearchKey_KeyPress (KeyAscii As Integer)

    flgEditing = True

    If KeyAscii = 8 Then

       If txtSearchKey.Text = "" Then                   'Search Key is blank.

          Dim nIdx As Integer

          Const LB_SETTOPINDEX = WM_USER + 24

          'De-select entry

          lstNumbers.ListIndex = -1

          'Move to the top of the list

          nIdx = SendMEssage(lstNumbers.hWnd, LB_SETTOPINDEX, 0, ByVal

            0&)

       Else                                             'Search Key has changed

          txtSearchKey.Text = Left(txtSearchKey.Text, nKeyedLength)

          txtSearchKey.SelStart = nKeyedLength

       End If

    End If

    flgEditing = False

End Sub


Search incr.

LUOKKA: ListBox

==============================================================

Date:         Fri, 23 Sep 1994 12:04:53 PDT

From:         Simon Bernstein <simonb@MICROSOFT.COM>

Subject:      Incremental search

How to Quickly Search a List Box

ID: Q119738

SUMMARY

=======

A popular item in a user interface is to "link" a text box to a list box so

that as the user types text into the text box, the nearest match in the

list box is selected. Although this technique can be implemented fairly

easily using pure Visual Basic code, the Windows API provides a quick and

easy way of doing this.

MORE INFORMATION

================

This technique uses the LB_FINDSTRING message for a list box to locate a

partial match for a string in a list box. To do this, call the Windows API

SendMessage function. The SendMessage function requires the following

parameters to list the files:

   SendMessage (hWnd%,LB_FINDSTRING, wParam%, lparam)

where

   hWnd%     is the hWnd of the list box.

   wParam%   is an integer that specifies the starting point for the

             search. Use -1 to search the whole list box.

   lParam    is a long pointer to the string to find.

Example to Demonstrate Searching a List Box

-------------------------------------------

1. Start a new project in Visual Basic and a text box (Text1) and a list

   box (list1) to Form1.

2. Add the following code to the General declarations section of Form1:

   ' Enter the Declare statement on one single line:

   Declare Function SendMessage Lib "user" (ByVal hwnd As Integer,

      ByVal wMsg As Integer, ByVal wp As Integer, ByVal lp As Any) As Long

   Const WM_USER = &H400

   Const LB_FINDSTRING = (WM_USER + 16)

3. In the Form_Load method for the form, add a few items to the list box

   using the following code:

   Sub Form_Load()

       List1.Clear

       List1.AddItem "Apples"

       List1.AddItem "Banana"

       List1.AddItem "Bread"

       List1.AddItem "Break"

   End Sub

4. In the Change method of the text box, add the following code:

   Sub Text1_Change()

       ' The following code should be on one single line:

       List1.ListIndex = SendMessage(List1.hWnd, LB_FINDSTRING, -1,

       Cstr(Text1.Text))

   End Sub

When the code runs, typing text into the text box will select the first

item in the list that matches the text in the text box.


Search incr.

LUOKKA: ListBox

Date: 04/30/94 (03:13)              Number: 4676 of 4713 (Refer# NONE)

From: DANC@DELLGATE

Subj: Re: ListBox Searches w/1+ Character

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sorry, I refined this a little to be a little more stable, but can't find my

code right now. If you have any problems, let me know, but here is some

code that will get you started.

' Code by Dan Champagne

' 4/18/94

' This code can be used to do an incremental search in either a

' list box, dir, combo, or a file box. The following code is set

' for a file box called FILE1. To make it work with a list box, or

' a file box with a different name, change all occurences of FILE1

' with whatever you or VB has named your list, combo, dir, or file box.

' There are two places where you will need to change these. They are

' on the last couple of lines in the KeyPress code.

' Also, thanks to John Tarr for helping debug the code.

'In a .BAS file, add the following:

'searchme$ is a global vaiable that will keep track of what the

'user has typed so far.

Global searchme$

'The following needs to be on one line.

Declare Function SendMessageBystring& Lib "User" ALIAS "Send

  Message" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam$)

Global Const WM_USER = &H400

Global Const LB_SELECTSTRING = (WM_USER + 13)

Global Const LB_FINDSTRING = (WM_USER + 16)

'In File1 under keydown, add the following:

'This checks if the user has pressed the up or down arrow.

'If they have, reset searchme$ to "".

If KeyCode = 40 Or KeyCode = 38 Then

   searchme$ = ""

End If

'In File1 under lostfocus, pathchange, patternchange, and click add:

'If the user has done any of the above, reset the searchme$ string.

searchme$ = ""

'In File1 under keypress add:

Dim result&

Select Case KeyAscii

    Case 8     'Backspace

        If searchme$ <> "" Then

            searchme$ = Left$(searchme$, Len(searchme$) - 1)

        Else

           File1.ListIndex = 0

        End If

        KeyAscii = 0

        Exit Sub

    Case 27    'Escape

        searchme$ = ""

        KeyAscii = 0

        Exit Sub

    Case 13    'Enter

        searchme$ = ""

        KeyAscii = 0

        Exit Sub

    Case Asc("a") To Asc("z"), Asc("A") To Asc("Z"), Asc("'"), Asc("."), Asc("

"), Asc("0") To Asc("9")

        searchme$ = searchme$ & Chr$(KeyAscii)

        KeyAscii = 0

End Select

result& = SendMessageBystring(FILE.hWnd, LB_FINDSTRING, 0, searchme$)

If result& = -1 Then

   searchme$ = Left$(searchme$, Len(searchme$) - 1)

Else

   result& = SendMessageBystring(FILE1.hWnd, LB_SELECTSTRING, -1,

searchme$)

End If


Security

LUOKKA: Access

6916 (19+)  stevea@Direct.CA  04.07.95  04:00

Steve Atwal: "Re: Security for a VB/Access DB"

In article <3t0i1r$b20@bighorn.accessnv.com>

Richard Rosenheim <rrose@accessnv.com> wrote:

> I'm developing a Visual Basic application which is utilizing the

> Access' Jet Engine for the database.  I'm having trouble figuring out

> how to set up security for the database when I distribute the

> application.

> I want people to be able to access the database from Access so that they

> can do ad-hoc queries.  But I don't want them to be able to add, delete,

> or otherwise modify information except via my application.  And of course, I

> don't want Admin to be able to change any of the security settings.

I just went through this ordeal. It is quite simple when you understand how it

works. Best thing to do is read the MS Access User's Guide. The steps to

take to totally secure an Access DB are:

        1. if you screw up, you need to be able to restore your original

           system.mda file, so back it up somewhere safe.

        2. use the MS Access Workgroup Administrator,  and create a NEW

           workgroup file.  This creates a brand new system.mda file.

        3. each workgroup that you create has, by default, an Admin

          user belonging to the Admin group. You can have as many workgroups

           as you want,  but each time  you want to use a particular DB you

           need to JOIN the workgroup that allows you to access that DB, and

           use the appropriate userid/password that is recognized by that

           workgroup.

        4. to activate the security logon screen, give the Admin user a

           password. This will also prevent  other users from

           bypassing your security since the Admin user has no password and

           users belonging to other workgroups will be able to get into your

           Access DB.

        5. now, create another user belonging to the Admin group and give him

           the same permissions as the Admin user. Make sure you give this

           user a password too.

        6. create your other groups and users, and assign permissions to them.

        7. transfer ownership of the DB to the new admin user you created

           (this will allow the new admin user to revoke DB Open/Run

           permissions for other users).

        8. revoke DB Open/Run permission for the Users, Admin, Guest groups

           (this will prevent unauthorized opening of the DB by others). You

           cannot remove these default users/groups, so the next best thing

           to do is stop them from  opening your DB.

        9. remember to  write down all the user id's, passwords, PIN's, and

           print off a copy of the list of users/groups from within Access.

Steve


Setup

LUOKKA: setup

3. What alternatives to setup wizard do I have?

   Perhaps the best one is to simply modify the setup app which is

   supplied with VB.  Look in your VB directory for the setupkit

   setup1 directory.  There you will find everything you need to do a

   complete setup program.  This sample setup is coded to install a

   few sample app files and create a program group.  You can comment

   out those lines and change to your files and program mgr. group.

   There are also a few global variables you will want to change.  All

   of this is contained in the comments in the code.

   Using this, and the distribution information in the manual telling

   you about which files to distribute with your app will make things

   much easier than using the setup wizard (IMNSHO).

   There are also several third party setup products available.

    George Tatge (gat@csn.org)


Setup expand

LUOKKA: VBgen

Date: 12/04/94 (01:15)              Number: 28760 of 28804 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re: corrupted cmdialog.vbx..

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

CK> My installed version of VB 3.0 has a corrupted cmdialog.vbx file.

CK>I don't want to go through the installation procedure just for the

CK>file. Anybody will kindly enough to send a copy of cmdialg.vbx to me

CK>?  Thanks in advance!

All you need to do is place the VB diskette #1 in drive A: and using

Progman's File - Run option, type "a: setup /z cmdialog.vb_

c: windows system cmdialog.vbx".

You will be prompted for the diskette that contains the file. Get this

info prior to starting this action from the packing list file

PACKING.LST in your VB directory.


Setup missing MSAFINX

LUOKKA: DLL

Date: 07/14/94 (14:05)              Number: 12048 of 12069 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Installing

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 07-12-94 Stephen Johnston wrote:

SJ>In article <12a.7830.961@compudata.com>,

SJ>Barry Roomberg <barry.roomberg@compudata.com> wrote:

SJ>>I used the Install Setup wizard, and tried to install on another

SJ>>machine.  I can execute my app, but when bringing up one of the

SJ>>forms it bombs with "FILE NOT FOUND" after drawing the form.

SJ>>I'm not intentially opening a file here, so I assume I'm missing a

SJ>>DLL. Is there anyway to figure out what file?

SJ>re you using the IIf function somewhere in your code?  If so, you

SJ>need to include a DLL (MSAFINX.DLL?) with your application.  You can

SJ>find more details in the FAQ.

Same for any of the date manipulation functions, such as DateAdd

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


Setup wizard

LUOKKA: setup

1. What are some tips for using Setup Wizard?

   There were loads of bugs in the setup utilities supplied with VB3.

   Be sure to get the newest version of SETUPKIT (usually called

   SETUPK.EXE or -.ZIP). It is available from the sources listed in

   the beginning of this document, and in the General FAQ.

   Alternatively, if you have the older versions, you may have to

   manually remove the line referring to OLE2UI.DLL in the file

   SETUPWIZ.INI. See later in this document for dates of newest files

   on ftp.microsoft.com.

   Follow the instructions in SETUPK.TXT exactly. The files actually

   belong in two separate directories. Not placing them correctly can

   create strange and unusual side effects -- none of them good(!)

   Set all involved EXE, DLL and VBX files to Read-Only so that the

   setup program doesn't modify them.

    Charles F. Mulks (21667cfm@msu.edu)

   A *very* good tip. Actually, make all executables on your system

   read-only. If not, you can get a sharing violation if you try to

   run the same DOS executable twice at the same time.

   Also, the source code for a SETUP program is *included* with VB3

   Pro. It is quite trivial to tailor it to your specific needs.

   The question remains: Is SetupWiz good? No! Good enough? Perhaps.


Setup Wizard

LUOKKA: setup

Date: 03/30/94 (21:18)              Number: 2371 of 2518 (Refer# NONE)

From: SETH@CIX.COMPULINK.CO.UK

Subj: RE: Setup Wizard

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (+)

Close down windows and restart before you run the setup wizard. Only run

the setup Wizard no other programs. Don't  ALT + TAB  out od setup Wizard

to see what is up to this can crash it or bring up the errors you

experienced.

This ensures that all the DLLs VBXs are unloaded prior to running the set

up Wizard. Also check that you have share installed.


Setup/commdlg

LUOKKA: setup

6. Why won't my setup program install commdlg.dll et. al.?

   There are a couple of DLLs that are almost always in use by

   windows.  Commdlg.dll is the most common example.  When faced with

   this problem, there is no easy way out.  The full explanation is

   several pages long and beyond the scope of this FAQ.  The general

   idea is as follows:

   Your setup program will need to create a .BAT file to expand and

   then copy these files.  Then, it will need to shutdown Windows

   (see ExitWindowsExec API call) and run the .BAT file.  Then it will

   need to restart windows and continue your setup program.  Your

   setup program should delete the temporary .BAT file that is no

   longer needed.

    George Tatge (gat@csn.org)


Share

LUOKKA: Access

Date: 09/17/94 (20:02)              Number: 19863 of 19876 (Refer# NONE)

From: LGAINOUS@IX.NETCOM.COM

Subj: Re: What a studip answer!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>a specific "device=" line out of system.ini when there can be an unlimited

>number of "device=" statements.

>

>I emailed an "answer" to the questioner in which I said that you could use

>GetPrivateProfileString with a zero in the lpKeyName argument.  I said that

>this would return all of the data in the specified section.

1. Read the entire system.ini file into a hidden text box.

2. Use the Instr() Function to Search for vshare.386 in the text box.

3. If vshare.386 is not found Then

   a. Ask permission to change system.ini

   b. Make a backup copy of system.ini

   c. Use the SelText property of the text box

      to insert the device=vshare.386 line into the

       386Enh  section.

   d. Overwrite system.ini with the new contents of the text box.

   e. Restart Windows with using the ExitWindows API Call.

This isn't my solution, but one that I received.  I had to

modify it somewhat.  One thing was to search for the string

" 386Enh " if vshare wasn't found, then replace the

string " 386Enh " with:

" 386Enh " & chr$(13) & chr$(10) & "device=vshare.386" &

chr$(13) & chr$(10)


Share/Vshare

LUOKKA: VBgen

Date: 10/18/94 (23:39)              Number: 23491 of 23637 (Refer# NONE)

From: TREGILGAS@SGCL1.UNISG.CH

Subj: ÄAÅ How to REALLY load Share.exe

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

 If you want to save yourself some conventional memory, and are using

Windows 3.x in enhanced mode, then simply add the following line to your

system.ini in the Ä386enhÅ Section: "device=vshare.386"  Copy the file

vshare.386 to your %windir%Ösystem directory, and off you go!

vshare.386 can be found in many places, as WW1000.exe

winftp.cica.indiana.edu

Tom Tregilgas@sgcl1.unisg.ch University of St. Gallen, Switzerland


Share/Vshare3

LUOKKA: VBgen

Date: 09/04/94 (17:33)              Number: 18261 of 18295 (Refer# NONE)

From: M_MILIS@PAVO.CONCORDIA.CA

Subj: Re: Share.exe Vs VShare.386

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <345pd6$eco@ixnews1.ix.netcom.com> Techton@ix.netcom.com

(Al Neese) writes:

>The only time you DO NOT have to use SHARE.EXE is when you run

>Microsoft Windows for Workgroups in Enhanced mode. Microsoft Windows

>for Workgroups in Enhanced mode benefits of using VSHARE.386...

Installing VSHARE.386 is a must if you are doing any serious database

programming. 500 locks that manual suggest you put for use with

SHARE.EXE is not enough if you do large transactions. I have been bitten by

it as my database grew and suddenly stopped working one day. I do not

remember the error message, but it was not obvious that it ran out of locks.

(Out of Memory maybe?). It went away after I increased the number of locks.

The problem: how to guess how many locks you'll need.

THE SOLUTION: There is a version of VSHARE.386 that will work with plain

Windows as well. I definitely suggest to all who are distributing database

programs to bundle a copy of it and instead of putting SHARE.EXE in their

AUTOEXEC.BAT, put VSHARE.386 in SYSTEM.INI (after proper exemination

of these files and confirmation from the user, of course).

This life-saving file can be found under less-then-obvious name of

WW1000.EXE in ftp.microsoft.com, in their mslfiles directory (I hope I got it

right, they changed their directory structure recently.). It can also be

downloaded from their BBS; I'm sure it is on Cumpuserve as well.

-----------------------------------------------------

Marko Milisavljevic         m_milis@pavo.concordia.ca

Montreal, Canada                seagram@interlink.net


Shell

LUOKKA: shell

1. How do I tell when an application executed using the SHELL command

   is finished?

   Shell() doesn't really return a task handle, it returns an instance

   handle. Any documentation that says otherwise is wrong. But never

   mind that; the answer to your question is to use the API call

   GetModuleUsage.

     'Put this in the general declarations of your form/module

     Declare Function GetModuleUsage Lib "Kernel" (ByVal

     "hModule As Integer) As Integer

     'Here's where you shell out to the other program

     intHandle = Shell("PROGRAM.EXE")

     Do While GetModuleUsage(intHandle) > 0

        DoEvents

     Loop

    Kenn Nesbitt, Microsoft Consulting Services (kennn@netcom.com)


Shell

LUOKKA: shell

11.How can I call a 'hidden' DOS program from VB?

   If you run a DOS program minimized using the SHELL command, it will

   never complete. This is because DOS tasks by default are NOT setup

   to run in the background. The easiest way to get around this is to

   make a PIF file for the program you need to run with the

   "Background" option checked. Then SHELL to the PIF file to run the

   DOS program and it will return control to your VB application when

   it terminates.

   Tip: If you edit or replace the _DEFAULT.PIF file in the Windows

   directory to allow execution in background, this will apply to all

   DOS boxes that is not run with it's own .pif!


Shell WinExec

LUOKKA: shell

Date: 09/20/94 (18:55)              Number: 20135 of 20148 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: DOS Execution

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>: So is there any way possible in which I can run the DOS executible

>: file from the VB windows application.

>

>Well, I've never tried this, but maybe there is a way to run a .PIF file

>using WinExec?  Is WinExec a VB command?  I'm at home so I don't have

>access to the docs (they're at work), but it would seem to me that you

>could execute a PIF just as though it were any other Windows program.

WinExec is an API call, but you are right about everything else.

Declare Function WinExec% Lib "Kernel" (ByVal lpCmdLine$, ByVal

nCmdShow%)

Global Const SW_HIDE = 0

Global Const SW_NORMAL = 1

Global Const SW_MAXIMIZE = 3

Global Const SW_MINIMIZE = 6

    Select Case WinExec("C: WINDOWS DOSPROMPT.PIF", SW_NORMAL)

        Case 0

            MsgBox "System was out of memory, executable file was corrupt, or

                          relocations were invalid."

        Case 2

            MsgBox "File was not found."

        Case 3

            MsgBox "Path was not found."

        Case 5

            MsgBox "Attempt was made to dynamically link to a task, or there

                         was a sharing or network-protection error."

        Case 6

            MsgBox "Library required separate data segments for each task."

        Case 8

            MsgBox "There was insufficient memory to start the application."

        Case 10

            MsgBox "Windows version was incorrect."

        Case 11

            MsgBox "Executable file was invalid. Either it was not a Windows

                         application or there was an error in the .EXE image."

        Case 12

            MsgBox "Application was designed for a different operating system."

        Case 13

            MsgBox "Application was designed for MS-DOS 4.0."

        Case 14

            MsgBox "Type of executable file was unknown."

        Case 15

            MsgBox "Attempt was made to load a real-mode application

                         (developed for an earlier version of Windows)."

        Case 16

            MsgBox "Attempt was made to load a second instance of an

              executable file containing multiple data segments that were

              not marked read-only."

        Case 19

            MsgBox "Attempt was made to load a compressed executable file.

                      The file must be decompressed before it can be loaded."

        Case 20

            MsgBox "Dynamic-link library (DLL) file was invalid. One of the

                         DLLs required to run this application was corrupt."

        Case 21

            MsgBox "Application requires Microsoft Windows 32-bit extensions."

    End Select

__________

                           Bradley S. Murray


Shell/dos/icons

LUOKKA: shell

20.How do you change the icon and otherwise manipulate the DOS box?

   Enclosed is the results of my digging around to enable me to change the

   icon of a DOS box launched with the SHELL function. It illustrates most

   aspects of dealing with DOS boxes.

   Example of launching PIF file minimized and running it in the

   background (Needs Execute Background box checked in PIF file), and

   assigning the PIF file a new Icon rather than the default DOS Box Icon.

   (Note: it seems this method changes the icon of ALL the active DOS

   boxes)

   Code follows:

   x---------------------------------------------------------------------x

     Option Explicit

     Global Const SWP_NOSIZE = 1

     Global Const SWP_NOMOVE = 2

     Global Const SWP_NOACTIVATE = &H10

     Global Const SWP_SHOWWINDOW = &H40

     Global Const SWP_HIDEWINDOW = &H80

     Global Const SWP_FLAGS = SWP_NOMOVE Or SWP_NOSIZE Or

SWP_NOACTIVATE

     Global Const SWP_SHOW = SWP_SHOWWINDOW Or SWP_FLAGS

     Global Const SWP_HIDE = SWP_HIDEWINDOW Or SWP_FLAGS

     Global Const HWND_BOTTOM = 1

     Global Const GCW_HICON = (-14)

     Global Const GCW_HMODULE = (-16)

     Declare Function GetModuleUsage Lib "Kernel" (ByVal hWnd%) As

Integer

     Declare Function ExtractIcon Lib "Shell" (ByVal hInst%,

     öByVal lpExeName$, ByVal hIcon%) As Integer

     Declare Function DestroyIcon Lib "User" (ByVal hIcon%) As Integer

     Declare Function FindWindow Lib "User" (ByVal lpClassName As Any,

     öByVal lpCaption As Any) as Integer

     Declare Function SetWindowPos Lib "User" (ByVal h%, ByVal hb%,

     öByVal X%, ByVal y%, ByVal cx%, ByVal cy%, ByVal F%) as Integer

     Declare Function GetClassWord Lib "User" (ByVal hWnd%, ByVal

nIndex%)

     öAs Integer

     Declare Function SetClassWord Lib "User" (ByVal hWnd%, ByVal

nIndex%,

     öByVal wNewWord%) As Integer

     Sub LaunchPif(PifFile as String, IconName as String)

         Dim Res As Integer     'Return value from API call

         Dim MyInst As Integer  'Instance handle for this app

         Dim PifIcon As Integer 'Pif Icon Resource name

         Dim OldIcon as Integer 'Original Pif Icon resource (default = 0)

         Dim PifhWnd As Integer 'Dos Box Window handle

         'Launch PIF file

         PifInst = Shell(PifFile, 6)

         'Get Instance handle for main MDI Window (assumed to be frmMDI)

         MyInst = GetClassWord((frmMDI.hWnd), GCW_HMODULE)

         'Create new Icon resouce by loading Icon from disk file

         'Check Icon file exists

         If Dir$(IconName) <> "" Then

            'Make sure string is null terminated

            IconName = IconName & Chr$(0)

            'Create Icon resource in this window

            PifIcon = ExtractIcon(MyInst, IconName, 0)

         Else

            PifIcon = 0

         End If

         'Reset Default Icon on DOS Box to PifIcon

         'Check PIF file still running and Icon resource created

         If GetModuleUsage(PifInst) <> 0 and PifIcon > 0 Then

            'Get Pif Window handle

            PifhWnd = FindWindow(0&, "Window name in PIF file")

            'Set Icon handle to PifIcon resource

            OldIcon = SetClassWord(PifhWnd, GCW_HICON, PifIcon)

            'Hide and show window to get a redraw of the Icon

            Res = SetWindowPos(PifhWnd, HWND_BOTTOM, 0, 0, 0, 0,

SWP_HIDE)

            Res = SetWindowPos(PifhWnd, HWND_BOTTOM, 0, 0, 0, 0,

SWP_SHOW)

         End If

         'Wait for PIF file to complete

         Do While GetModuleUsage(PifInst) <> 0

            DoEvents

         Loop

         If PifIcon > 0 then

            'Reset Icon to original

            Res = SetClassWord(PifhWnd, GCW_HICON, OldIcon)

            'Tidy up by removing PIF Icon resource

            Res = DestroyIcon(PifIcon)

         Endif

     End Sub

   x---------------------------------------------------------------------x

   ÄDr David Baird (BairdD@AgResearch.CRI.NZ)Å


Shelling

LUOKKA: shell

Date: 01/25/95 (08:24)              Number: 198987 of 201095 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Invisible Shelling?

To prevent your screen from backing out when running a DOS program, try

using a PIF file:

You need to set the PIF file's Display Usage to 'Windowed' and its Execution

to 'Background' in order to get it to work.

You can use WinExec with the SW_MINIMIZE argument to run the DOS app

as an icon, or with the SW_HIDE argument to hide the icon altogether.

Since WinExec runs asynchronously, if you need your DOS app to finish

before continuing with your VB program, you need to write some code to let it

finish.

To solve this asynchronous problem, I use a method found in the VB

Programmer's Journal (Aug/Sept '94, p. 123, by Carl Franklin) which uses the

GetModuleUsage function to determine when the DOS app is finished.

Here's an example piece of code that waits until the DOS app is finished

before giving control back to the user (or continuing with the VB code after

the WinExec call).

Option Explicit

Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String, ByVal

nCmdShow As Integer) As Integer

Declare Function GetModuleUsage Lib "Kernel" (ByVal hModule As Integer)

As Integer

Const DEFAULT = 0

Const HOURGLASS = 11

Const SW_HIDE = 0

Const SW_MINIMIZE = 6

Sub Form_Click ()

  Dim hInstance As Integer

  Screen.MousePointer = HOURGLASS

  hInstance = WinExec("C:™TMP™COMPRESS.PIF", SW_MINIMIZE)

  Do

    DoEvents

  Loop Until GetModuleUsage(hInstance) = 0

  Screen.MousePointer = DEFAULT

End Sub

Note that if you use SW_HIDE instead of SW_MINIMIZE, Execution

'Background'

does not have to be checked in the PIF file.

Also note that calling the GetModuleUsage function a whole bunch of times

can be expensive.  An alternative might be to use a Timer control, and

periodically call GetModuleUsage.  I haven't tried this, so I don't know if it

would be more or less expensive then the above code block.

-BRIAN TOOMBS

-HCM, Inc


Shelling terminating

LUOKKA: shell

Date: 01/03/95 (00:51)              Number: 31433 of 31509 (Refer# NONE)

From: PADRON@GATE.NET

Subj: Re: Please help again. More about SHELLed processes!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>  I posted a message yesterday asking how to terminate a shelled

> process under VB 3.0.  Alex Black replied that I should use the

> Windows API function ShellExecute.  I have read the documentation on

> the function, and it seems like it will work.....except, that I

> cannot find the declaration for it in the SDK help.  Does anyone

> know how to use this function or where I can find the declaration to

> paste into my code?

>

>  Please reply to this post or send me mail in response.  Thank you SO

> much--I am using this for an important project and you help is

> greatly appreciated.

>

>  Kent A. Signorini

>  (signorin@cs.ualberta.ca)

>  (http://ugweb.cs.ualberta.ca/~signorin)

*** The following code did the work for me; sue it at your own risk ***

To start (SHELL) an application (like the Windows Calculator) from within

your VB app:

(put the following code in the declaration section of a VB code module)

' Use this variable to store the Windows handle to an application

' instance: IOW, the return value of the Visual Basic Shell Function

Global ghInstCalculator as Integer

(use the following function to start the Windows Calculator application)

Sub RunCalc ()

    On Error Resume Next

    Dim hWnd As Integer, hInst As Integer, intRetVal As Integer

    ' Activate launched application if it is already running.

    ' In other words, if you previously started the Windows Calculator

    ' application from within your VB app, then don't start another one;

    ' instead, just make it active and give it the focus.

    hWnd = GetWindow(Me.hWnd, GW_HWNDFIRST)

    Do While hWnd

        If GetWindow(hWnd, GW_OWNER) = 0 Then

            hInst = GetWindowWord(hWnd, GWW_HINSTANCE)

            If hInst = ghInstCalculator Then

                intRetVal = SetActiveWindow(hWnd)

                intRetVal = ShowWindow(hWnd, SW_RESTORE)

                Exit Sub

            End If

        End If

        hWnd = GetWindow(hWnd, GW_HWNDNEXT)

    Loop

    ' Launch application (for the first time)

    ghInstCalculator = Shell("CALC.EXE", 1)

End Sub

(put the following code somewhere in the 'Unload' event of your Main

window)

    Dim hWnd As Integer, hInst As Integer, intRetVal As Integer

    ' Close launched (SHELLed) Calculator application if it's running

    hWnd = GetWindow(Me.hWnd, GW_HWNDFIRST)

    Do While hWnd

        If GetWindow(hWnd, GW_OWNER) = 0 Then

            hInst = GetWindowWord(hWnd, GWW_HINSTANCE)

            If hInst = ghInstCalculator Then

                intRetVal = PostMessage(hWnd, WM_CLOSE, 0, 0&)

                End Do

            End If

        End If

        hWnd = GetWindow(hWnd, GW_HWNDNEXT)

    Loop

Last, you need the following API Declarations:

Declare Function GetWindow Lib "User" (ByVal hWnd As Integer, ByVal

            wCmd  As Integer) As Integer

Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal

                                         wMsg As Integer, ByVal wParam As

                                         Integer, lParam As Any) As Integer

Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal

                                           nIndex As Integer) As Integer

Declare Function SetActiveWindow Lib "User" (ByVal hWnd As Integer) As

                                             Integer

Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal

                                        nCmdShow As Integer) As Integer

Ah, and don't forget this...:

(on the Declaration section of a VB code module)

' Window message constants

Global Const WM_CLOSE = &H10

' GetWindow constants

Global Const GW_HWNDFIRST = 0

Global Const GW_HWNDNEXT = 2

Global Const GW_OWNER = 4

' GetWindowWord constants

Global Const GWW_HINSTANCE = -6

' ShowWindow constants

Global Const SW_RESTORE = 9

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

// Jorge Padron

// SoftWorld International


Sort

LUOKKA: VBgen

Date: 06-29-95 (15:25)              Number: 375108 of 377040 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Sorting, better than QSORT...

From: digest Michael Anderle <MAnderle2@AOL.COM>

  VBPJ a few of months ago had an article on different sorts.  Here is code

from one that I used which sorted an array of about 15k numbers in < 20

seconds(586-60). Pass it your array (single dimension) and Whether you want

ASCending or DESCending.

Sub Shell_Sort (arr(), nOrder As String)

Dim Distance

Dim Size

Dim Index

Dim NextElement

Dim Temp

Size = UBound(arr) - LBound(arr) + 1

Distance = 1

While (Distance <= Size)

  Distance = 2 * Distance

Wend

Distance = (Distance / 2) - 1

'-Sort Routine

While (Distance > 0)

    NextElement = LBound(arr) + Distance

  While (NextElement <= UBound(arr))

    Index = NextElement

      Do

        If Index >= (LBound(arr) + Distance) Then

          If nOrder = "ASC" Then

            If arr(Index) < arr(Index - Distance) Then

              Temp = arr(Index)

              arr(Index) = arr(Index - Distance)

              arr(Index - Distance) = Temp

              Index = Index - Distance

              gIterations = gIterations + 1

            Else

              Exit Do

            End If

          ElseIf nOrder = "DESC" Then

            If arr(Index) >= arr(Index - Distance) Then

              Temp = arr(Index)

              arr(Index) = arr(Index - Distance)

              arr(Index - Distance) = Temp

              Index = Index - Distance

              gIterations = gIterations + 1

            Else

              Exit Do

            End If

          End If

        Else

          Exit Do

        End If

      Loop

      NextElement = NextElement + 1

      gIterations = gIterations + 1

  Wend

    Distance = (Distance - 1) / 2

    gIterations = gIterations + 1

Wend

End Sub

------------

Michael T. Anderle

mAnderle2@aol.com

Programmer/Analyst


Sort

LUOKKA: VBgen

Date:         Thu, 4 Aug 1994 14:34:21 +0300

From:         giora drachsler <giora@SHUM.CC.HUJI.AC.IL>

Subject:      Sorting Algorithm  XE "Sorting Algorithm"

                If the array is really short, use the Bubble Sort.

        It is simple and it works well and it is easy to understand

        how it sorts.  If times are getting long, use a very clever

        mutation of it called Shell-Metzner sort.  It is not easy

        to understand how it works but it is very fast especially

        on long lists and has no memory (stack) overheads as

        Quick sort does.  It can be easily altered for any needs, even

        file sorts.

    ' Shell sort

    LastRec& = ubound (Ary$)        ' numb of elements in array

    Offset& = LastRec& \ 2          ' sort mid-pt

    DO WHILE Offset&                ' Loop until offset gets to zero.

        Limit& = LastRec& - Offset&

        DO

            LastSwap& = 0           ' Assume no swaps at this offset.

            FOR R& = 1 TO Limit&    ' Compare elements and swap ones out of

                                                   order:

                    IF Ary$(I%) > Ary$(I%+Offset&) THEN ' if first bigger

                        Tmp$ = Ary$(I%)                 ' swap them

                        Ary$(I%) = Ary$(I%+Offset&)     ' ( no SWAP cmd in

                        Ary$(I%+Offset&) = Tmp$         ' VB3 )

                    END IF

            NEXT I%

            ' Sort on next pass only to where last LastSwap& was made:

            Limit& = LastSwap& - Offset&

      LOOP WHILE LastSwap&

      Offset& = Offset& \ 2   ' No Switches at last offset, try one half as big:

   LOOP

                                        Giora Drachsler

                                        Hebrew University

                                        Jerusalem, Israel

                                        Giora@SHUM.cc.huji.ac.il


Sort

LUOKKA: VBgen

Date:         Fri, 5 Aug 1994 18:57:00 PDT

From:         "Wallace, Glynn W." <wallaceg@HQ.U18MS.KADENA.AF.MIL>

Subject:      Sorting Algorithm  XE "Sorting Algorithm"

Martin wrote:

    What I want to so is sort an array of strings alphabetically. I realise

    the easiest way to do this would be to pipe the data in to a list box

    whos 'sorted' property was set to true. However, I can't use this

    method. It has to be a coded solution. Does anybody out there have

    experience of this?

Martin,

Since you're trying to sort a small array, a technique called "bubble

sorting" is something you could use.  Here is some sample code to get you

started.  If you can't get it to work, mail me direct and I'll try to help.

 It's actually kind of a modified bubble sort.  The second set of

For.....Next evaluates what has happened in the previous For....Next, and

moves the strings again if they need it.

Also, if the strings are really big, or this isn't fast enough for what you

want, I can send you an example of a "quick sort" routine, that I almost

guarantee will be fast enough.  It's a little harder to explain, that's why

I'm sending this one.

****More recent remarks*****

I saw the post from Giora, and that may be what you need.  I can't say

because I've never tried the code (captured for future reference, of course

:-)).  It's true, you can run into a stack limit problem with Quick sorts,

but I've just recently made some timing tests:

I used a 2 dimensional, 3 element array, importing 1300 records from a

fixed-ascii mainframe.  The first element (used for sorting) was 9

characters.  The other two were over 50 characters long.  During the sort, I

had to move all 3 elements accordingly.  The results we

Standard Bubble Sort - over 10 minutes, I shut it down...don't know how long

it would have taken.

Modified Bubble Sort - similar to code below, 4.5 minutes

Quck Sort - around 3 seconds. No stack limit problems.

You be the judge.  Since I haven't tried Giora's code, I can't say how long

it would take but it looks like it might time-out to be a good compromise

between Bubble  and Quick, with no stack problems.

HTH

Glynn Wallace

wallaceg@hq.u18ms.kadena.af.mil

Okinawa, Japan

 ------------Code Sep----------------------

For I = 1 To UBound(YourArray) - 1

    If YourArray(I) > YourArray(I + 1) Then  'string value is greater; it

should be moved down

        Str1$ =YourArray( I)  'store info from greater string

       YourArray( I) = YourArray( I + 1)  'move info from lesser string to

proper location

        YourArray( I + 1) = Str1$  'replace info from greater string to

proper location

    End If

        For J = 1 To UBound(YourArray) - 1

            IfYourArray(J) > YourArray(J + 1) Then  'comments same as above

                Str1$ = YourArray(J)

                YourArray(J) = YourArray(J + 1)

               YourArray(J + 1) = Str1$

            End If

        Next

Next


Sort

LUOKKA: VBgen

Date: 12/10/94 (08:36)              Number: 149519 of 149927 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: quick sort routine?

Frm: Mike Anderson anderson=40marlboro#%forwarder@SHIPCO.GEIS.COM>

>Hi everyone I am new to this list. Need some help please.

>I need to sort a single dimensioned array of up to 256 numbers or letters. I

>presently have a quick sort routine from another source but it >is

>slower than I believe it should be on a 33Mhz machine.  Any suggestions

Here is a routine I have used.  Better of course would be a DLL in C, but this

is transparent to me  (on a DX2-66, though...).  There are faster sorts, but

this is cheap and easy...

Sub sort_PMS_sizes (srcArr(), rowIdx%, startIdx%, endIdx%)

    ' srcArr is the source array

    ' rowIdx is the first dimension of the 2-D array

    ' startIdx and EndIdx are the boundaries of the sort

    Dim Row As Integer, SmallestRow As Integer, temp_swap As Single

    Dim MaxRow As Integer, J As Integer

    Dim i%

    MaxRow = endIdx% - startIdx + 1

    '//this is the exchange sort routine//

    For Row = 1 To MaxRow

        SmallestRow = Row

        For J = Row + 1 To MaxRow

            If srcArr(rowIdx%, J) < srcArr(rowIdx%, SmallestRow) Then

                SmallestRow = J

            End If

        Next J

        ' Found a row shorter than the current row, so swap those

        ' two array elements:

        If SmallestRow > Row Then

            temp_swap = srcArr(rowIdx%, Row)

            srcArr(rowIdx%, Row) = srcArr(rowIdx%, SmallestRow)

            srcArr(rowIdx%, SmallestRow) = temp_swap

        End If

    Next Row

    '//end exchange sort routine

End Sub


Sort recursion

LUOKKA: VBgen

Date: 09/21/94 (12:04)              Number: 20193 of 20274 (Refer# NONE)

From: EXUIAN@EXU.ERICSSON.SE

Subj: Re: Recursion (Sorting Routines) in VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The following subroutine is used to quick sort a global array using two string

fields BL and CI. This is done by concantenating the strings before the

comparison so the overall array (which has a lot more fields than BL and CI)

gets sorted according to the BL field and then the CI field. In order to speed

up the search and not have to swap a lot of strings, a pointer array called

Index is used, and this is set up as follows for the n'th record in the arrays -

you just have to set index(n) to n whenever you add a new record.

Index(n) = n, BL(n)= something, CL(n) =something, ..... other fields

The subroutine will then change Index(n) = m, where m is the position the

record would have if it were sorted. Then to access the records in order, you

use the record position that Index points to e.g.

j'th sorted record = BL(Index(j)), CI(Index(j)) .....

Finally, the subroutine has start and stop parameters. These enable each

recursive call to sort a different subset of the array. So to sort an array

(0....n), you call Qsort(0,n). And the record array field variables (BL,CI) must

be module level or global.

I've found this code to be very fast, hope someone finds it useful ! If you

know that you have muliple fields on which to sort then you can make it even

faster by concantenating these fields into one string (according to the sort

order) as they are added to the record, thereby reducing the number of

concantenations the sort routine has to do. Its speed verses memory as

always !

Sub QuickSort (L As Integer, R As Integer)

'L is the left  boundary of the subset to be sorted

'R is the right boundary of the subset to be sorted

Dim I As Integer   ' dynamic left boundary  (for this recursion only)

Dim J As Integer   ' dynamic right boundary (for this recursion only)

Dim M As Integer   ' current midpoint       (for this recursion only)

Dim S As Integer   ' used to save index when doing the swaps

Dim C As String    ' used to store the current midpoint field

  I = L                    'initialize

  J = R                    'initialize

  M = Index((L + R)   2)   'Find midpoint

  C = BL(M) & CI(M)        'Make the comparison string from two fields

  Do

    While BL(Index(I)) & CI(Index(I)) < C

     I = I + 1

    Wend 'Find the first thing less than C in the left half.

    While C < BL(Index(J)) & CI(Index(J))

      J = J - 1

    Wend 'Find the first thing greater or equal to C in the right half.

    If I <= J Then

   ' Do the swapping of the index pointers rather than all elements of the

   ' array of records

      S = Index(I)              'save value of Index(I)

      Index(I) = Index(J)

      Index(J) = S            'use saved value since Index(I) was just overwritten

      I = I + 1

      J = J - 1

    Else

      Exit Do                   'this part is done, so iterate

    End If

  Loop

  ' Do a recursive sort of another subset of the array

  If L < J Then Call QuickSort(L, J)

  If I < R Then Call QuickSort(I, R)

End Sub


Sound Blaster

LUOKKA: sounds

Date: 11/20/94 (15:56)              Number: 27395 of 27407 (Refer# NONE)

 From: TJT@NP.AC.SG

Subj: Re: Help with DLLs and Sound Cards

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Does anyone know if there is a Visual Basic for Windows DLL (or other

>method) available which will let me utilize the text-to-speech features

>of the SoundBlaster or ProAudio Spectrum 16 sound cards, using the

>drivers supplied with those boards?  I've written a couple of DOS based C

>routines that work fine, but have no luck converting to a DLL for VB3.0 -

>keep getting general protection faults when calling the entry point to

>the TSR speech driver passing the struct containing the text.  Any help

>would be greatly appreciated.

The following code is what I tried. Try changing the 2nd parameter of the

OpenSpeech function from 4000 to say 0 and see the effect. You have to

first

run the speech engine in Windows - C: monologw fb_ngn.exe.

'''START OF CODE

'General-declarations section

Declare Function OpenSpeech Lib "c: monologw fb_spch.dll" (ByVal

hWnd%, ByVal mode%, ByVal Type1&) As Long

Declare Function CloseSpeech Lib "c: monologw fb_spch.dll" (ByVal

lpSCB&) As Integer

Declare Function Say Lib "c: monologw fb_spch.dll" (ByVal lpSCB&,

ByVal phrase As String) As Integer

Dim lpSCB As Long

Sub Form_Load ()

   Dim i%

   ChDir "c: monologw"

   lpSCB = OpenSpeech(0, 4000, 0&)

   i% = Say(lpSCB, "HELLO")

   i% = CloseSpeech(lpSCB)

End Sub

'''END OF CODE

In the dictionary that you have designed, use the first byte phonetics as

listed in Appendix B of Text-To-Speech User's Guide. Use the right phoneme

and phonetic modifier which can control the duration, pitch and volume of

that particular syllable so you can lay stress on that syllable.


Sound various subs

LUOKKA: sounds

SOUND

----------

Option Explicit

'****************************************************

'* SOUNDFX.BAS Version 1.0 Date: 3/30/94            *

'* DPM Computer Solutions                           *

'* 8430-D Summerdale Road San Diego CA 92126-5415   *

'* InterNet: DPMCS@HIGH-COUNTRY.COM                 *

'* Compuserve: 74227,1557                           *

'****************************************************

Declare Function OpenSound Lib "sound.drv" () As Integer

Declare Function VoiceQueueSize Lib "sound.drv" (ByVal nVoice%, ByVal

nByteS) As Integer

Declare Function SetVoiceSound Lib "sound.drv" (ByVal nSource%, ByVal

Freq&, ByVal nDuration%) As Integer

Declare Function StartSound Lib "sound.drv" () As Integer

Declare Function CloseSound Lib "sound.drv" () As Integer

Declare Function WaitSoundState Lib "sound.drv" (ByVal State%) As Integer

'*******************************************************

'* Procedure Name: AttenSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* Attention Sound #1                                  *

'*******************************************************

Sub AttenSound1 ()

Dim Succ As Integer, S As Integer

   Succ = OpenSound()

   S = SetVoiceSound(1, 1500 * 2 ^ 16, 50)

   S = SetVoiceSound(1, 1000 * 2 ^ 16, 50)

   S = SetVoiceSound(1, 800 * 2 ^ 16, 40)

   S = StartSound()

   While (WaitSoundState(1) <> 0): Wend

   Succ = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: ClickSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* Click Sound #1                                      *

'*******************************************************

Sub ClickSound1 ()

Dim Succ As Integer, S As Integer

   Succ = OpenSound()

   S = SetVoiceSound(1, 200 * 2 ^ 16, 2)

   S = StartSound()

   While (WaitSoundState(1) <> 0): Wend       ' Wait for sound to play.

   Succ = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: ErrorSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* Error Sound #1                                      *

'*******************************************************

Sub ErrorSound1 ()

Dim Succ As Integer, S As Integer

   Succ = OpenSound()

   S = SetVoiceSound(1, 200 * 2 ^ 16, 150)

   S = SetVoiceSound(1, 100 * 2 ^ 16, 100)

   S = SetVoiceSound(1, 80 * 2 ^ 16, 90)

   S = StartSound()

   While (WaitSoundState(1) <> 0): Wend       ' Wait for sound to play.

   Succ = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: SirenSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* SirenSound #1                                       *

'*******************************************************

Sub SirenSound1 ()

Dim Succ As Integer

Dim J As Long

   Succ = OpenSound()

   For J = 440 To 1000 Step 5

      Call Sound(J, J / 100)

   Next J

   For J = 1000 To 440 Step -5

      Call Sound(J, J / 100)

   Next J

   Succ = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: Sound                               *

'*-----------------------------------------------------*

'* Created:           By:                              *

'* Modified:          By:                              *

'*=====================================================*

'* Creates the sound.                                  *

'*******************************************************

Sub Sound (ByVal Freq As Long, ByVal Duration As Integer)

Dim S As Integer

   Freq = Freq * 2 ^ 16                 ' Shift frequency to high byte.

   S = SetVoiceSound(1, Freq, Duration)

   S = StartSound()

   While (WaitSoundState(1) <> 0): Wend

End Sub


Sounds

LUOKKA: sounds

Date: 10/11/94 (00:53)              Number: 22543 of 22612 (Refer# NONE)

From: CSTUART@METRONET.COM

Subj: Re: Q. Sounds in VB!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I like to include some sound effects in my application.

>Assuming the customer doesnot have a sound card. Any

>ideas.  Can I perchuse sound Library?

This is probably not what you are looking for but, at the very least, it will

allow you to play the standard Windows sounds.

Declare Function SndPlaySound Lib "mmsystem" (ByVal SoundName$, ByVal

SND_ASYNC)

Sub MakeSound (SoundType)

   Dim I

   Dim SoundName As String

   ON ERROR GoTo MakeSoundError

   Select Case SoundType

      Case 0

         SoundName = "SystemAsterisk"

     Case 1

         SoundName = "SystemExclamation"

      Case 2

         SoundName = "SystemHand"

      Case 3

         SoundName = "SystemDefault"

   End Select

   I = SndPlaySound(SoundName, 1)

Exit Sub

MakeSoundError:

   ErrorRoutine Error$, "MakeSound"

End Sub

--------

Chuck Stuart


Sounds

LUOKKA: sounds

Date: 04-09-95    Time: 05:16p     Number: 348

From: moodieblu@aol.com             Refer:

Subject: Help: Simple sound an             1: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

Compliments of DMPCS and VBTT (Visual Basic Tips and tricks available on

CIS and AOL as well as other places here is the code you want:

'****************************************************

'* SOUNDFX.BAS Version 2.0 Date: 02/01/95           *

'* VB Tips & Tricks                                 *

'* 8430-D Summerdale Road San Diego CA 92126-5415   *

'* Compuserve: 74227,1557                           *

'* America On-Line: DPMCS                           *

'* InterNet: DPMCS@AOL.COM                          *

'****************************************************

Option Explicit

Declare Function OpenSound Lib "sound.drv" () As Integer

Declare Function VoiceQueueSize Lib "sound.drv" (ByVal nVoice%, ByVal

nByteS) As Integer

Declare Function SetVoiceSound Lib "sound.drv" (ByVal nSource%, ByVal

Freq&, ByVal nDuration%) As Integer

Declare Function StartSound Lib "sound.drv" () As Integer

Declare Function CloseSound Lib "sound.drv" () As Integer

Declare Function WaitSoundState Lib "sound.drv" (ByVal State%) As Integer

'*******************************************************

'* Procedure Name: AttenSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* Attention Sound #1                                  *

'*******************************************************

Sub AttenSound1 ()

Dim iSucc As Integer, R As Integer

   iSucc = OpenSound()

   R = SetVoiceSound(1, 1500 * 2 ^ 16, 50)

   R = SetVoiceSound(1, 1000 * 2 ^ 16, 50)

   R = SetVoiceSound(1, 800 * 2 ^ 16, 40)

   R = StartSound()

   While (WaitSoundState(1) <> 0): Wend

   iSucc = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: ClickSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* Click Sound #1                                      *

'*******************************************************

Sub ClickSound1 ()

Dim iSucc As Integer, R As Integer

   iSucc = OpenSound()

   R = SetVoiceSound(1, 200 * 2 ^ 16, 2)

   R = StartSound()

   While (WaitSoundState(1) <> 0): Wend       ' Wait for sound to play.

   iSucc = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: ErrorSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* Error Sound #1                                      *

'*******************************************************

Sub ErrorSound1 ()

Dim iSucc As Integer, R As Integer

   iSucc = OpenSound()

   R = SetVoiceSound(1, 200 * 2 ^ 16, 150)

   R = SetVoiceSound(1, 100 * 2 ^ 16, 100)

   R = SetVoiceSound(1, 80 * 2 ^ 16, 90)

   R = StartSound()

   While (WaitSoundState(1) <> 0): Wend       ' Wait for sound to play.

   iSucc = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: SirenSound1                         *

'*-----------------------------------------------------*

'* Created: 2/2/94    By: David McCarter               *

'* Modified:          By:                              *

'*=====================================================*

'* SirenSound #1                                       *

'*******************************************************

Sub SirenSound1 ()

Dim iSucc As Integer

Dim J As Long

    iSucc = OpenSound()

    For J = 440 To 1000 Step 5

        Call Sound(J, J / 100)

    Next J

    For J = 1000 To 440 Step -5

        Call Sound(J, J / 100)

    Next J

    iSucc = CloseSound()

End Sub

'*******************************************************

'* Procedure Name: Sound                               *

'*-----------------------------------------------------*

'* Created:           By:                              *

'* Modified:          By:                              *

'*=====================================================*

'* Creates the sound.                                  *

'*******************************************************

Sub Sound (ByVal lFreq As Long, ByVal iDuration As Integer)

Dim R As Integer

   lFreq = lFreq * 2 ^ 16                 ' Shift frequency to high byte.

   R = SetVoiceSound(1, lFreq, iDuration)

   R = StartSound()

   While (WaitSoundState(1) <> 0): Wend

End Sub


Sounds API calls

LUOKKA: sounds

2514 (208+)  Duncan_Smith@mindlink.bc.ca  05.01.95  10:44

Duncan Smith: "Re: Generating tones?"

You need to play around with the following API calls located in the

SOUND.DRV file:

Declare Function OpenSound Lib "SOUND.DRV" () As Integer

Declare Sub CloseSound Lib "SOUND.DRV" ()

Declare Sub SetVoiceNote Lib "SOUND.DRV" (ByVal Voice%, ByVal Note%,

...

                                          ... ByVal Length%, ByVal Dots%)

Declare Sub StartSound Lib "SOUND.DRV" ()

... then try some of this code to make a noise:

Sub Annoying_Sounds ()

        CloseSound

        Voices = OpenSound()

        For I = 1 to 10

                SetVoiceNote 1, 40, 16, 0

                SetVoiceNote 1, 91, 16, 0

                SetVoiceNote 1, 140, 16, 0

                SetVoiceNote 1, 237, 16, 0

        Next

        StartSound

End Sub

Play around with the numbers and see what you come up with.

(Hint: if you send a longer series of noisemaking commands, the CloseSound

call shuts your sound driver up)

There are a few more API calls to get the routines which let you pass

octaves, notes, pitches, etc which I can post if you need them.  The demo

code will need to be a bit longer though.

____________________________________________________________

Duncan S. Smith              I                       D M G I

duncan_smith@mindlink.bc.ca  I   Diagonal Market Group, Inc.


Sounds API decs

LUOKKA: sounds

Date: 12/06/94 (22:14)              Number: 29050 of 29145 (Refer# NONE)

From: COMPUNET@PIPELINE.COM

Subj: Re: a SOUND question

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Credit for the following goes to Daniel Appleman - "VB

Programmers Guide to the Windows API". Get the book - you'll

get back many times your investment.

Declare Function SetSoundNoise Lib "Sound" (ByVal nSource As

Integer, ByVal nDuration As Integer) As Integer

Declare Function SetVoiceQueueSize Lib "Sound" (ByVal nVoice As

Integer, ByVal nBytes As Integer) As Integer

Declare Function SetVoiceNote Lib "Sound" (ByVal nVoice As

Integer, ByVal nValue As Integer, ByVal nLength As Integer,

ByVal nCdots As Integer) As Integer

Declare Function StartSound Lib "Sound" () As Integer

Declare Function OpenSound Lib "Sound" () As Integer

Declare Function SetVoiceAccent Lib "Sound" (ByVal nVoice As

Integer, ByVal nTempo As Integer, ByVal nVolume As Integer,

ByVal nMode As Integer, ByVal nPitch As Integer) As Integer

Declare Function SetVoiceSound Lib "Sound" (ByVal nVoice As

Integer, ByVal lFrequency As Long, ByVal nDuration As Integer)

As Integer

Declare Function StopSound Lib "Sound" () As Integer

Declare Sub CloseSound Lib "Sound" ()

''  SetSoundNoise() Sources

Global Const S_PERIOD512 = 0    '  Freq = N/512 high pitch, less coarse

hiss

Global Const S_PERIOD1024 = 1   '  Freq = N/1024

Global Const S_PERIOD2048 = 2   '  Freq = N/2048 low pitch, more coarse

hiss

Global Const S_PERIODVOICE = 3  '  Source is frequency from voice

channel   (3)

Global Const S_WHITE512 = 4 '  Freq = N/512 high pitch, less coarse hiss

Global Const S_WHITE1024 = 5    '  Freq = N/1024

Global Const S_WHITE2048 = 6    '  Freq = N/2048 low pitch, more coarse

hiss

Global Const S_WHITEVOICE = 7   '  Source is frequency from voice channel

 (3)

Sub PlaySiren ()

  di% = SetVoiceQueueSize(1, 1000)

  di% = SetVoiceAccent(1, 120, 255, 1, 0)

  freq% = 800

  duration% = 10

  offset% = 5

  Do

    soundval& = CLng(freq%) * &H10000

    di% = SetVoiceSound(1, soundval&, duration%)

    freq% = freq% + offset%

    If freq% >= 1000 Then offset = -5

    If freq% <= 800 Then offset% = 5

  Loop While di% = 0

  di% = StartSound()

End Sub


Sounds text to speech

LUOKKA: sounds

21630 (181+)  mu@werple.mira.net.au  19.06.95  14:42

Sean O Seaghdha: "Re: Text to Speech DLL for VB?"

On 15 Jun 1995 15:34:50 GMT, Jason Kaczor (ACP@mindlink.bc.ca) said...

>kshorter@ix.netcom.com (kevin shorter) wrote:

>>

>> Does anyone know of a text to speech DLL available

>> for VB. Or even a stand alone text to speech program

>> that would accept external input.

>

>If you use a Creative Labs product, there is a sub-program

>named "Monologue"...You can use DDE to send it text strings,

>it will then "speak" them...

Better yet, you can call the DLL.  This is from a simple test program with a

text box for the text (duh) and a button (Speak).

_____________

Declare Function OpenSpeech Lib "c:ÖsoundÖmonologÖfb_spch.dll" (ByVal

hWnd%, ByVal mode%, ByVal voiceType&) As Long

Declare Function CloseSpeech Lib "c:ÖsoundÖmonologÖfb_spch.dll" (ByVal

lpSCB&) As Integer

Declare Function Say Lib "c:ÖsoundÖmonologÖfb_spch.dll" (ByVal lpSCB&,

ByVal lpString As String) As Integer

Global lpSCB As Long

Sub Speak_Click ()

lpSCB = OpenSpeech(0, 0, 0)

x = Say(lpSCB, Text1)

y = CloseSpeech(lpSCB)

End Sub

_____________

The docs from Creative tell you almost nothing about what params

OpenSpeech will accept - these ones just work.

~~~

    ,     ,     ,                      Sean_O_Seaghdha@mail.indcom.gov.au

S e a n   O   S e a g h d h a              sgos2@cfs01.cc.monash.edu.au


Speed up

LUOKKA: Access

Date: 12/20/94 (20:42)              Number: 159056 of 163156 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Accessing individual records in large database

From: Damean Chen <CCCYEM@TEVM2.NSC.COM>

 1) Tuning the "smartdrv.exe" in the DOS

 2) Let the  "c:™windows™temp" point to a faster media (RAM drive etc)

   I could not tell for sure what's the optimal setup for your environment is as

different circumstances require diff set of conditions. But I actually speed up

my access time by 20-30% after some fine tuning.

The reason this works is because windows actually make use of VirTual

Memory  which writes to the "TEMP" dir . This is applicable as well to MS

Access which makes use of these features.


Speed up

LUOKKA: speed

Date: 05/24/94 (03:51)              Number: 6713 of 6809 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Why is VB so SLOW???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

My guess is your problem lies in the way that VB usually handles the

Picture and Image properties. If you have the AutoRedraw property set for

a control, it maintains a memory bitmap with which to refresh the screen

picture as needed. This means you are actually manipulating two bitmaps,

not just one. This need not always be a serious issue, but it certainly

does have the potential to become so if you are leaning heavily on this

feature.

Try turning off AutoRedraw property, then use your Paint procedure to

refresh the form. It's really only all the behind-the-scenes operations

and default behaviours that make VB slow when you are only doing the

things that Windows is supposed to be good at. If you are doing complex,

iterative mathematical or array manipulations operations, it's a

different story. Let's face it, most programs do most of their work out

there in the API, where all languages are equal.

Good luck,

Luke Webber


Speed up

LUOKKA: speed

Date: 05/25/94 (00:24)              Number: 6831 of 6934 (Refer# NONE)

 From: CHRIS_BECKETT@BCTV.WIC.CA

Subj: Re: Faster Form Displaying?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Form loads try to do a lot all at the same time.  Also, VB does not load all

modules immediately when the program is run.  Often the first time you show

a form, it will be slower than additional loads. You might try something like

the below example.  The problem you seem to be having is that Visual Basic

has to load and then show each control on you form.  This procedure forces

all the controls to load before displaying them.  It probably won't increase

your overall form load time, but the form should flash onto the screen instead

of displaying controls a few at a time.

Sub loadForm(frm as Form)

 Screen.MousePointer = HOURGLASS

 Load frm

 DoEvents()

 frm.Show

 Screen.MousePointer = DEFAULT

End Sub

+ Chris Beckett, Programmer/Analyst        Email:  cbeckett@bctv.wic.ca

+ Westcom TV/Radio Group                   Tel:    +1 (604) 421-9412

+ Vancouver, BC                            Fax:    +1 (604) 421-9461


Speed up

LUOKKA: speed

4. Any tips for speeding up VB?

   Who said "code in C"???? ;-)

   a. When SHOWing a form with lots of bound controls, have a blank

      frame covering everything. Then, in the Form_Activate event, set

      the Frame.Visible = False. This greatly speeds the display of

      the form and hides ugly thrashing as the data controls

      initialize.

       Christopher Biow (biow@cs.umd.edu)

   b. Try to keep any Global definitions to a minimum.  Massive

      numbers of global variables really seem to slow VB Windows down

      (besides chewing up memory).  In other words, if you've pasted a

      lot of stuff from the globals.txt file, trim all definitions and

      variables you don't use in your application.

   c. Keep the total number of controls and forms used to a minimum

      (you've probably already guessed that).

   d. Keep fancy graphics to a minimum (another one you know).

   e. Try "pre-processing" in the background (using Do_Events).

      Doesn't really speed anything up, but often there is a lot of

      "idle" time while the user is selecting menu's, buttons and such

      - if you can do some calculations, image loading or whatever

      during this idle time your user perceives the application is

      faster than it really is.

   f. Hide often-used forms rather than unloading them. Unloading

      saves memory, but it takes longer to re-load a form than to

      simply "un-hide" it.

       Tips b to f by Galen Raben (galenr@gr.hp.com)

   The following tip is along the same lines, but with a code sample.

   They are provided by Andy Dingley (dingbat@codesmth.demon.co.uk):

   You're limited by the system as to how quickly you can go from

   calling frmMyForm.Show to being able to type into the controls, but

   you can make the form *appear* to display faster. One technique is

   to keep forms loaded, and just switch their visibility on and off.

   This is heavy on resource usage, and doesn't help for the first

   time they're shown.

   Most forms have some processing (eg. querying a table to fill a

   list box) that goes on when they're first opened, and this is what

   causes the most serious delay. It's possible to display the form,

   make its controls appear on screen, then do the slow processing

   before finally making the form "live". As the user can see things

   happening, the perceived delay is less obvious.

   Include the following code in your form:

     Option Explicit

     Dim FirstActivation as integer

     Sub Form_Activate

        DoEvents   'Allow the _Load event to be seen on screen

        If FirstActivation Then

           ' Do all the slow loading stuff here

           If FillComboBox <> 0 Then

              Unload Me 'If it all goes horribly wrong, then you

                        'can call Unload from an _Activate event

                        '(Which you can't do from the _Load event)

           End If

           FirstActivation = False

        End If

        Screen.MousePointer = DEFAULT

     End Sub

     Sub Form_Load

        FirstActivation = True

     End Sub

   Show the form by using:

     Screen.MousePointer = HOURGLASS

     frmMyForm.Show MODAL

   Bruce Garrett (bruceg@access2.digex.net) had the following tips

   from his VBITS 93 notes:

   - Polling a control for its properties directly is 10 to 20

     times slower then placing the property values you need into

     variables and testing the value of the variables.

   - Swap tuning: Modules are not loaded until used; put related

     code in the same modules, reduce the number of intermodule

     calls and keep modules small.

   - Binary file I/O is faster then Text/Random.

   There was also a lot of discussion about "apparent" speed i.e: how

   it looks on the screen as opposed to how fast it's chugging

   internally. It was noted that the cute little flashing menu items

   and exploding windows in the Mac amounted to a little razzle-dazzle

   to distract you from how long it took to actually load something

   and get it on the screen.  Keeping all your forms loaded but hidden

   until needed was suggested.  Also the use of progress indicators

   and a simple quickly loaded and drawn startup form. Also preloading

   data you expect to need.


Speed up db

LUOKKA: Access

10.How can I speed up my VB database application?

   KB article Q109830 gives some hints.  Things you should do include:

   - Use Snapshots when possible.

   - Use transactions whenever possible.

   - Use Dynasets when possible.

   - Use SQL action queries when possible.

   ÄGeorge Tatge (gat@csn.org)Å

   Major Weakness: SQL is SLOW! A hand-coded search (with indices) is

MUCH

   faster than an equivalent SQL call, especially with complex search

   criteria. For example:

     SELECT * FROM Table WHERE SSN = '555-33-1234' AND Posted

#01-31-95#

   is a lot slower than:

     Table.Index = "SSN"

     Table.Seek "=", "555-33-1234"

     If Not Table.NoMatch Then

       While Not Table.EOF

         If Table("SSN") "555-33-1234" Then

           Table.MoveLast  'Forces an EOF

         ElseIf Table("Posted") #01-31-95# Then

           'Do something

         End If

         Table.MoveNext

       Wend

     End If

   Granted, it is a LOT more code, but I ran a VERY similar query that took

   THIRTY HOURS! The equivalent hand-written code took ELEVEN

MINUTES!

   That's 163 times faster! I think basically SQL isn't very good at

   figuring out which indexes to use (I also think I've read something to

   the effect that the newer version, 2.0 or 2.5, IS better at this).

   John McGuire (jmcguire@jax.jaxnet.com)


Speed up SHELL

LUOKKA: shell

20465 (41+)  bdetri01@mpg.gmpt.gmeds.com  10.06.95  01:53

"A Hint to those shelling to DOS"

I wrote an application that shells to DOS and runs a program.

It uses the VB Shell command.

I found that editing the _default.pif file and turning the

priority up from 50 to several thousand really speeds up the

performance of the DOS Program.

As an added bonus, when the SetupWizzard shells to DOS to

compress the files, it is now about 10 times faster than

before.

Bret


Splash screen

LUOKKA: splash

Date: 05/15/94 (12:48)              Number: 6051 of 6068 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Splash Screen Help?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 05-16-94 CFIELDS@NANDO.NET  wrote:

C>I wanted to try this on an application. FormSearch is the first form

C>that  connects to a huge database (about 30 seconds to run). 30

C>seconds to a  user can sometimes be long, so I was going to add a

C>blinking label.

C>I created FormIntro with one label.caption "Connecting to Database". I

C>added a timer (Enabled = True, interval=500).

C>I tried loading FormIntro first with a call to load FormSearch and

C>show  it when connection is complete and unloading FormIntro. Didnt

C>work right.

C>I tried loading FormSearch first with a call to show FormIntro then

C>continue with connection and show FormSearch and unload FormIntro. At

C>this point I saw the messages and consequently "sprinkled DoEvents" in

C>the code and changed ClipControl to False. The form stayed on the

C>screen  but the blinking label didn't work.

C>Question: Is there a sequence of events for this to work correctly? In

Gee, Cassandra, there's a typical way of doing this.  Try loading

FormIntro first, then FormSearch - both from your .BAS's Sub Main.

Don't allow FormSearch to Show until the connection is made, and follow

the Show with FormIntro.Unload.  The problem with the label is likely

that the CPU is hog-tied trying to connect to your monster database, and

you may have to go into THAT part of the code and sprinkle around some

additional DoEvents.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


Splash screen

LUOKKA: splash

Date: 05/15/94 (02:33)              Number: 6139 of 6231 (Refer# NONE)

From: CFIELDS@NANDO.NET

Subj: Re: Splash Screen Help?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>C>screen  but the blinking label didn't work.

>C>Question: Is there a sequence of events for this to work correctly? In

>the Show with FormIntro.Unload.  The problem with the label is likely

>that the CPU is hog-tied trying to connect to your monster database, and

>you may have to go into THAT part of the code and sprinkle around some

>additional DoEvents.

>

Shattered dreams and dulled blinking labels. Thanks for all the

suggestions. The result: show FormIntro with a better message, fancy

screen and let it sit there until the "hog-tied" CPU can connect to the

"monster" database. And then as I've done before, show FormSearch and

FormIntro.Unload.

Of course there is still the possibility as suggested to try and

interrupt the connection with coding and DoEvents, and maybe, just maybe,

my blinking label will be moving after all.  Thanks everyone!

Cassandra.....cfields@nando.net


Splash screen

LUOKKA: splash

Date: 05/15/94 (15:56)              Number: 6204 of 6231 (Refer# NONE)

From: GINS@SUNSPOT.COM

Subj: Re: Two nice little question....

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>(2) Does anybody know how to make those nice little windows with

>pictures/info. on the software come up while an application is loading? You

>know, like the one VB3.0 starts up with that has the VB icon and copyright

>info. Give the user something nice to look at while the form is loading.

Here's some code to play with. (It was in response to Cassandra's query the

other day).

Start new project with two forms: form1, form2, and .bas file.

Put Label1 on form1, flush left.

In form1 form_load put:

    form1_load

In form2 form_load put:

    form2_load

Put the following in .bas file:

=============

Declare Function SetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal

nIndex

As Integer, ByVal wNewWord As Integer) As Integer

Sub form1_load (Form As Form)

    Dim x%, aboutHWnd As Long

    Dim savetitle$

    Const GWW_HWNDPARENT% = -8

    Form.Show

    'call about box without button (0)

    form2.Show

    aboutHWnd = form2.hWnd

    ' make about form child of this one

    x = SetWindowWord(aboutHWnd, GWW_HWNDPARENT%, Form.hWnd)

    DoEvents

    'Release about box as childwindow

    Do Until form2.Tag = "DONE"

        DoEvents

    Loop

    x = SetWindowWord(aboutHWnd, GWW_HWNDPARENT%, 0)

    Unload form2

End Sub

Sub form2_load (Form As Form)

    Dim start!

    Form.Show

    DoEvents

    start = Timer

    Do Until Form.Label1.Left + Form.Label1.Width >= Form.ScaleWidth

        DoEvents

        Form.Label1.Left = Form.Label1.Left + screen.TwipsPerPixelX * 5

    Loop

    Do Until Timer > start + 2

    Loop

    Form.Tag = "DONE"

End Sub

 Thanks - Joshua

     "  Sunspot Software Developers

     "  gins@sunspot.com

     "  cis: 70314,1656


Splash screen

LUOKKA: splash

Date: 05/15/94 (11:33)              Number: 6274 of 6294 (Refer# NONE)

From: XMCMULLEN@DSM1.DSMNET.COM

Subj: Re: close

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>> 3: I have a MDIform with a number of children. I also have another form

>>  (a startup window) that is not a child. Because the loading

>>  of forms is slow, I have set the visible property of all

>>  MDI and children to false. Programmatically, I show the startup

>>  form on startup, wait for the user to hit OK then set the

>>  visible property of the MDI and children to true.

>>  However...on startup, all MDI and children are shown regardless

>>  (so it seems) of the visible property. Huh?

>>  What am I doing wrong?

try this set your strup form to be your splash form.

next put a timer on it so it has time to show its self befor you tell it to

load the main form of your program. this is accompllished as thuss

splashform_load()

me.show 'show the splash before contiuing

end sub

timer1()

load main

end sub

main_load()

startup code.

..

me.show

end sub

forms do not show them selve untill they are don processing the code in the

form load vent

unless you specify me.show

lm


Splash screen

LUOKKA: splash

To: ALL

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: Splash Screen

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I do this by loading another form, without borders, set modal and with a

timer. The timer determines how long your splash screen stays up. The modal

bit is important because otherwise people could click on the client area of

your application behind the splash screen (unless it's obscured by the splash)

and then your splash screen would disappear!

--

Ian Piper


Splash screen

LUOKKA: splash

Date: 04/13/94 (09:40)              Number: 3300 of 3347 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: How to Create a Splash Form in VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Use Sub Main to load your splash screen first, have a timer to unload the

splash screen and follow the load splashscreen command with a load

myrealform command.

This works for me.

--

Ian Piper


Splash screen

LUOKKA: splash

Date: 04/13/94 (12:56)              Number: 3331 of 3347 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: How to Create a Splash F

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 04-12-94 BRUCE-F@ACI1.ACI.NS.CA  wrote:

B>I would like to know how to create a splash screen or form in VB. I

B>want to  show a temporary screen while the program is loading ala

B>Lotus 123 for  Windows.

B>I can get the form to show up but any of the words which are in labels

B>will  not print until after the program loads.

Credit Tooraj for this one:  Sprinkle DoEvents liberally all over the

place, specifically just before loading the splash screen and before any

string manipulation or loading of labels with text (such as:

Label1.Caption = "My Caption").  Also, set the form's ClipControls

property to False.  This should help A LOT!

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatetot.com


Splash screen

LUOKKA: splash

Date: 04/15/94 (17:45)              Number: 3516 of 3590 (Refer# NONE)

  To: ALL

From: ARJEN@SHEAR.IAF.NL

Subj: Re: How to Create a Splash Form in VB

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 12 Apr 1994 11:12:10 -0300 bruce-f@aci1.aci.ns.ca

<bruce-f@aci1.aci.ns.ca> wrote:

> I would like to know how to create a splash screen or form in VB. I want to

> show a temporary screen while the program is loading ala Lotus 123 for

> Windows.

> I can get the form to show up but any of the words which are in labels will

> not print until after the program loads.

Use a Sub Main to start your program.

In the Sub Main do the following

Sub Main

     frmSplashScreen.Show

     ' This will put all texts into the labels

     frmSplashScreen.Refresh

     ' Wait a second or so

     Wait 1

     ' Load you main application form

     frmMain.Show

     'Unload splashscreen

     frmSplashScreen.Unload

The Sub Wait is Declared as follows:

Sub Wait(fSeconds As Single)

Dim fTime As Single

    fTime = Timer

    Do

    Loop Until Timer-fTime>=fSeconds

End Sub

--

Arjen Broeze                                   Telephone: (+33)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13


Splash screen

LUOKKA: splash

Date: 04/16/94 (18:24)              Number: 3750 of 3757 (Refer# NONE)

From: XRYSTA@MCODE.AMDAHL.COM

Subj: Re: How to Create a Splash Form in VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <140494210833.arjen@shear.iaf.nl>, "Arjen Broeze"

<arjen@shear.iaf.nl> writes:

> On 12 Apr 1994 11:12:10 -0300 bruce-f@aci1.aci.ns.ca

<bruce-f@aci1.aci.ns.ca> wrote:

> > I would like to know how to create a splash screen or form in VB. I want

> > to show a temporary screen while the program is loading ala Lotus 123 for

> > Windows. I can get the form to show up but any of the words which are >

> in labels will not print until after the program loads.

> Use a Sub Main to start your program.

> In the Sub Main do the following

>

> Sub Main

>      frmSplashScreen.Show

>      ' This will put all texts into the labels

>      frmSplashScreen.Refresh

>      ' Wait a second or so

>      Wait 1

>      ' Load you main application form

>      frmMain.Show

>      'Unload splashscreen

>      frmSplashScreen.Unload

>

> The Sub Wait is Declared as follows:

>

> Sub Wait(fSeconds As Single)

> Dim fTime As Single

>     fTime = Timer

>     Do

>     Loop Until Timer-fTime>=fSeconds

> End Sub

While the method Arjen describes for waiting will probably work it has an

annoying sideaffect of tying up windows during the wait time. A less intrusive

method would be to include a timer on your splash screen and in the form

load procedure for the splash screen set an interval. You will get control at

Timer1_Timer when the interval expires.

What I do -- because I want to do a bit of work while the splash is on the

desktop is to set two timers. The fist is set for 50 ms at form load time. When

it expires I set the second for 250 ms and then open my databases and other

things. When the second timer expires I hide the splash screen and show the

main program screen. I found I needed the extra timer to ensure the splash

screen was displayed before I started my open processing.


Splash screen

LUOKKA: splash

Date: 10/19/94 (20:56)              Number: 23650 of 23771 (Refer# NONE)

From: GLENG@CRL.COM

Subj: Re: Pausing?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

This may be similar to what you are talking about. I have a splash screen

(startup screen) that shows while my program is initializing. I wanted

the screen to display for 3 seconds or for the amount of time the

initialization takes place, so in a Sub Main, I did this

Dim Delay as Long

screen.mousepointer = 11

frmSplash.Show

SetWindowPos() ' use the API call to set the Splash window always on top

Delay = Timer ' seconds elapsed since midnight

'initialization

'stuff, including

load frmMain

frmMain.Show ' you'll still see the splash screen on top

do until Timer > Delay + 3

Loop

Unload frmSplash

screen.mousepointer = 0

This gives them enough time to read the startup screen, even if

initializing is really quick.


Splash screen

LUOKKA: splash

Date: 04/23/94 (09:55)              Number: 4053 of 4089 (Refer# NONE)

From: LARRY.MULL@LAUNCHPAD.UNC.EDU, Larry Mull

Subj: Re: How to Create a Splash Form in VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <140494210833.arjen@shear.iaf.nl>,

Arjen Broeze <arjen@shear.iaf.nl> wrote:

>On 12 Apr 1994 11:12:10 -0300 bruce-f@aci1.aci.ns.ca

<bruce-f@aci1.aci.ns.ca>wrote:

>> I would like to know how to create a splash screen or form in VB. I want

>> to show a temporary screen while the program is loading ala Lotus 123 for

>> Windows. I can get the form to show up but any of the words which are in

>> labels will not print until after the program loads.

>Use a Sub Main to start your program.

>In the Sub Main do the following

>

>Sub Main

>     frmSplashScreen.Show

>     ' This will put all texts into the labels

>     frmSplashScreen.Refresh

>     ' Wait a second or so

>     Wait 1

>     ' Load you main application form

>     frmMain.Show

>     'Unload splashscreen

>     frmSplashScreen.Unload

>

>The Sub Wait is Declared as follows:

>

>Sub Wait(fSeconds As Single)

>Dim fTime As Single

>    fTime = Timer

>    Do

>    Loop Until Timer-fTime>=fSeconds

>End Sub

Looks good, but I'd put a DoEvents in the loop, especially if you want to

be initializing data, files, etc while the splash is up - that's partly why it's

there, right!?  Here is a scenario:  Your prog takes 3sec to load on a fast 486

and 10 on a slower 386; a splash screen of 5 sec will be fine on the 486, but

the 386 sits for 5 sec w/nothing!!  Use a timer control to fire every 1000ms.

In the timer proc, check 1) if the prog is ready (use a boolean flag - set to

true when all is init'd) and if so check (2) if the time at startup + N seconds is

less than current time. This will ensure that your splash will stay up at least N

seconds, but longer if the prog is still initing.

What do you think?  Any other good ideas for splash screens?  BTW, I like

to make my splash screens a topmost window, but that may not be necessary

in all cases; however, it does allow you to display your main form

underneath the splash form and then remove the splash w/main ready and

waiting!  Topmost is probably not a good idea if your splash is full screen.

--

LarryM


Splash screen

LUOKKA: splash

Date: 11/30/94 (23:16)              Number: 140915 of 141613 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Splash Screens

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

This will display a form and allow loading of next form under it!

You can set a timer to destroy this form or use an event.

Sub main ()

    ' The splash form is displayed while the program loads.

    ' The API makes the form stay on top.

    Dim success%

    success% = 0

    ' Display the form on the screen.

    frmTOP.Show

    frmTOP.Refresh

    ' API call to set the splash form on top.

    ' Loop until API call is successful.

    Do While success% = 0

        success% = SetWindowPos(frmTOP.hWnd, HWND_TOPMOST, 0, 0, 0,

0,              Flags)

    Loop

    ' Load the main form.

    frmMain.Show

End Sub

Include the following API declaration and constants....

Declare Function SetWindowPos Lib "user" (ByVal h%, ByVal hb%, ByVal x%,

  ByVal  y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer

Global Const SWP_NOMOVE = 2

Global Const SWP_NOSIZE = 1

Global Const Flags = SWP_NOMOVE Or SWP_NOSIZE

Global Const HWND_TOPMOST = -1

Global Const HWND_NOTOPMOST = -2

David J. Smith

Atlantic Computer Institute

Nova Scotia, Canada

Dave-s@aci1.aci.ns.ca


Splash screen on top

LUOKKA: splash

Date: 06/09/94 (10:08)              Number: 8400 of 8514 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Non-Modal_Form_Show

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 06-07-94 IAN@MONTY.DEMON.CO.UK  wrote:

I>> What is the point of unloading the other form if you are loading the

I>> new form modally?  Modal forms are there so you can use them as

I>> pop-up boxes that the user has to act on before going back.  I would

I>> just do it without unloading the first form at all.

I>He is getting rid of the *modal* form and wants to show a *non-modal*

I>form.  I'm interested in this because it has happened in several of my

I>apps too,  and I've had to bodge my way around it. Does anyone have a

I>fix?

I've had very good luck doing this recently with a splash screen.  I

didn't want it to be modal, in case the user wanted to do something

while the splash screen was up (waiting for the app to load), but

definitely wanted it to stay on top, because it has information on it

that I want my user to see.  SetWindowPos works very well for this.

Here's the declaration:

Declare Sub SetWindowPos Lib "User" (ByVal hWnd%, ByVal --->

 <--- hWndInsertAfter%, ByVal X%, ByVal Y%, ByVal cx%, ByVal cy%, --->

 <--- ByVal wFlags%)

I executed Form2.Load from my .BAS module, and placed the following in

the form's Load event (the &H40 tells the form to Show):

    Call SetWindowPos(Me.hWnd, -1, 0, 0, 0, 0, &H40)

Works like a charm.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


SQL

LUOKKA: Access

Date: 07-04-95 (12:45)              Number: 378556 of 379246 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: select distinct

From: udaa310@KCL.AC.UK

>I have a table with Customer Name, Date, and Sales YTD fields. There are

>many records for each customer. I need to select only the most recent

>record for each customer and return all the data from each selected record

>into a dynaset.  I have tried every possible SQL statement I can come up

>with but none give the results I want. Anyone have a suggestion? The

>following have been tried.

>Select Distinct ÄCustomer NameÅ from Customers Order By ÄCustomer

NameÅ

>   only returns the Customer Name.

>Select Distinct ÄCustomer NameÅ, Date, ÄSales YTD) from ...etc.

>   return all records.

>------------------------------------------------------------------------

>Chuck Stuart - Mesquite TX USA

You can use aggregate functions Max or Last, together with the Group By

clause. If your date field is set by your program and includes time it may be

sufficient on its own.  If your table is kept in historical order then the

Last function might be sufficent. Anyway the example below shows both.

SELECT DISTINCTROW Sales.ÄCustomer NameÅ, Max(Sales.date) AS

MaxOfdate, Last(Sales.ÄSales YTDÅ) AS ÄLastOfSales YTDÅ

FROM Sales

GROUP BY Sales.ÄCustomer NameÅ;

Even though you are developing in VB it can be helpful to try out these

queries within Access first.

David Powell


SQL

LUOKKA: SQL

Date: 06/24/94 (23:32)              Number: 10410 of 10514 (Refer# NONE)

From: LLOYDB@ACTRIX.GEN.NZ

Subj: Some SQL - maybe useful

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I finally got my SQL to work and I'm off to bed (four hours late!).  Here's

the guts of what I was trying.  It's not complex, but it's not simple either

and VB enforces a lot of little rules that you have to get dead right: if

you're like me and VB's data access and SQL make you suicidal, then

perhaps this'll be of use.

   In essence, I'm using two tables:

Customers                      GroupMembers

   Company                        GroupName

   Address

   Town

   AccountNo <------------------> AccountNo

The tables are linked by their AccountNo fields (AccountNo is Customers'

primary key).  Within GroupMembers neither GroupName nor AccountNo is

unique, but their combination *is* unique; together they form GroupMembers'

primary key.  There's a one-to-many relationship between GroupMembers and

Customers; a typical set of GroupMembers records, encompassing all the

records for one GroupName, might be:

GroupName    Somnambulists    Somnambulists    Somnambulists

AccountNo    12345            12346            12347

The corresponding Customers records for the Somnambulists group might be:

Company      Subsidiary1      Subsidiary2      Subsidiary3

Address      Somewhere        Elsewhere        Software

Town         Smoke            Choke            Croak

AccountNo    12345            12346            12347

GroupMembers typically has dozens of sets of records, most of which have

just one member.  (We're not big on conglomerates in New Zealand yet!)  At

run time, a user enters a GroupName; I need to retrieve fields from the

Customers that belong to that group.  For instance, if "Somnambulists" is

entered, then I want the Company, Address, Town and AccountNo for all

three Customers in the Somnambulists group.  I want to clump these into

"records" by themselves (Customers records have additional fields - not

shown - that I don't want to retrieve) and tack the whole collection onto a

DataControl.  Here's the SQL to do it:

sql$ =        "SELECT Company, Address, Town, Customers.AccountNo "

sql$ = sql$ + "FROM Customers, GroupMembers, "

sql$ = sql$ + "Customers INNER JOIN GroupMembers "

sql$ = sql$ + "ON Customers.AccountNo = GroupMembers.AccountNo "

sql$ = sql$ + "WHERE GroupMembers.GroupName = '" +

enteredGroupName$ + "'"

The JOIN clause means that we're temporarily constructing a sort of "virtual

table", made up from the Customers table and part of the GroupMembers

table.

The first line tells SQL which fields we ultimately want from that virtual

table; the following lines indicate how the table is to be built.  In line 1

the first three fields are simply given by name.  This is safe because there's

only one of the constituent tables that they can come from.  Because

AccountNo is a field in *both* constituent tables, however, we have to

specify just one of them; that's why AccountNo is qualified with

"Customers.".  Line 2 gives the names of the constituent tables that SQL will

use to build the virtual one.  Line 3 tells us to join the constituent tables

with an INNER JOIN.  There are other types of JOIN clause as well, but this

is the most common.  Line 4 tells us how to perform the join; it gives an

expression (in this case a very simple one) that links the two constituent

tables together.  If we left out line 5, we'd end up with the correct fields,

but we'd get them for *all* customers who had an AccountNo appearing in

some GroupMembers record.  (Any customers who didn't feature in any group

would be excluded.)  But we're only interested in customers belonging to the

group whose name was specified by the user.  To eliminate all the others,

line 5 selects only those GroupMembers whose GroupName matches the one

that the user entered.

   We can use the above SQL string to specify the recordSource property of

a DataControl: myDataControl.recordSource = sql$.  (Remember, you won't

get far without specifying the control's databaseName as well!)  There are

some things to watch out for...

   First, VB may tell you that something or other isn't an index.  It's a

typically useless VB message, in that the "something" that's usually quoted

tends to comprise the entire SQL string; doesn't exactly tell you where to

start looking for the problem.  You need an index for the field that's used

in the WHERE clause - GroupName, in my case.  Note that this is a

secondary index.  A FAQ, to which the answer is worth repeating, is that you

can't create these from VB; you have to build such indices externally with an

RDBMS or something.

   An added complication comes if, like me, you're using tables defined by

someone else: you may not be able to build additional indices (you'll just

have to sweet-talk them into letting you, though).  The tables I'm talking to

are external, dBase tables - even more fun.  If this is you too, then make

sure you've specified the right connect property for the DataControl - dBase

tables come in several flavours.  (If you're using Paradox tables then be

extremely careful: the connect string in most of the documentation is wrong;

it should be "Paradox 3.X" instead of "Paradox".  Also I believe the

Incompatibility Layer's necessary if you want to use Paradox 4/Paradox for

Windows tables.  Considering what some people have said about the Layer

you might want to think about whether it's worth it.)  dBase tables are a

special case: VB won't automatically seek and use any indices you might

define for them; you have to tell it where to look via a text file called

"<TableName>.INF".  A non-maintained dBase index has an extension of

NDX and a name of its own; its INF entry is a line like this:

NDX1=MYINDEX.NDX

All maintained dBase indices go in the one file, whose extension is MDX.

These are the ones you normally use; accordingly the manual doesn't tell you

what to do with them.  A typical INF entry might be:

MDX1=MAINTAIN.MDX

If you get these wrong, or define the indices incorrectly, or for any other

reason prevent VB from finding the indices it needs, then your SQL will fail.

   You may be told that the object you're attempting to assign to the

DataControl has gone bye-byes.  There's a host of possible causes for this,

but two are more common than any others (aside from typo.s, of course).

First, you may get a "Couldn't find installable Isam" error.  This helpful

piece of jabberwock generally means that you're using external tables and

that your <ApplicationName>.INI (or wherever you aimed your

DB_OPTIONINIPATH) doesn't point to the correct database-engine DLL.

RTFM for this one.

Second, you may be attempting to join tables that aren't in the same

database as the one you assigned to the DataControl.  I haven't fiddled with

this, but I think I'm right in saying that the solution is to fully specify the host

database for the "missing" table, using a SQL "IN" clause.

   In the end it's a case of trying different things.  Lurk on CLBV - unlike

me, there's a lot of people here who know VB and SQL inside out.  Perhaps

most importantly: don't tear your hair out if things are going wrong.  For a

start the documentation's as messy as VB, so be prepared to believe that

you're not causing the problem yourself.  Apparently there's a replacement for

the data access engine available; that may help.  Sacrifice your dog/

girlfriend/boyfriend/grandmother to the devil if that's what it takes to get

the latest Knowledge Base, FAQ, and Hints and Tips for the product: there's

no point committing hari kiri if what you're dealing with is listed somewhere

as a known bug.  Finally, a solitary bouquet: MS' technical help for VB (over

here, at least) is right on the ball - really great, as is the Fax-back

service.  Register your copy of VB and make use of them.

   Hope this is of use to someone; sorry to be so long-winded.

Lloyd


SQL

LUOKKA: SQL

Date: 08/15/94 (19:37)              Number: 15675 of 15821 (Refer# NONE)

From: OBSHALOM@FAB8.INTEL.COM

Subj: Re:  Help! About SQL .....

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <32nbdq$a3b@news.csie.nctu.edu.tw>, ysfu@csie.nctu.edu.tw

(Jeffwen)says:

>           How I use SQL when I want to find some record.....?

>           SQL = " Select distinct Name from Films "

>           SQL = SQL & "where Man = " & MenSelect.Text

>           DataCtl.RecordSource = SQL

>           DataCtl.Refresh

>

>           When MenSelect.Text is  " A " ....Then I find Man = A

I might be mistaken but I belive that the problem is that the sql

statement should by ... where man = "A" ...

the way i use to get the extra "" is to write the following

SQL = SQL & "where Man = " & """" & MenSelect.Text & """"

I suppose & "'" & MenSelect.Text & "'" might also work but didn't check it


SQL

LUOKKA: SQL

Date: 08/15/94 (20:02)              Number: 15676 of 15821 (Refer# NONE)

From: GR00+@ANDREW.CMU.EDU

Subj: Re:  Help! About SQL .....

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Excerpts from netnews.comp.lang.basic.visual: 15-Aug-94  Help! About SQL

.....  Jeffwen@csie.nctu.edu.tw (1038)

>            How I use SQL when I want to find some record.....?

>            SQL = " Select distinct Name from Films "

>            SQL = SQL & "where Man = " & MenSelect.Text

>            DataCtl.RecordSource = SQL

>            DataCtl.Refresh

This should work for you:

SQL = SQL & "where Man = '" & MenSelect.Text & "'"

Not much different.  Just a minor syntax problem.  You have to

concatenate the single quotes around the text variable.

That's the only problem I see offhand.  Let me know if it still doesn't work.


SQL

LUOKKA: SQL

Date: 08/16/94 (01:36)              Number: 15724 of 15821 (Refer# NONE)

From: IAN.CARTER@ALMAC.CO.UK

Subj: Re:  Help! About SQL ....

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In a previous message, Jeffwen said:

J >           SQL = " Select distinct Name from Films "

J >           SQL = SQL & "where Man = " & MenSelect.Text

J >           DataCtl.RecordSource = SQL

J >           DataCtl.Refresh

Try:-

...SQL = SQL & "where Man = '" & MenSelect.Text & "'"

It is correct syntax to enclose literals in SQL statements in single

quotes. Although you are using some form of variable, it will appear to

the SQL parser to be a literal.

A good check when creating SQL statements using variables is to output

the resultant SQL string to the Debug window. You will see what the SQL

parser will see.

Regards,     Email:   ian.carter@almac.co.uk

Ian C.       Tel/Fax: (+44)(0)909-773689


SQL

LUOKKA: SQL

Date: 08/24/94 (18:27)              Number: 16847 of 16870 (Refer# NONE)

From: JONM@NESSIE.BE.INGRES.COM

Subj: Re: SQL access to databases - just doesn't work - please hel

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Stuart Coates (scoates@eurobase.demon.co.uk) wrote:

: 1. Can VB support transactions on the remote database using SQL...?

: I've tried issuing multiple db.ExecuteSQL("insert statement") and

: then a db.ExecuteSQL("rollback") but it seems that after each ExecuteSQL

: the ODBC driver (or VB) is doing a commit - which is no use as I need

: to do lots of MQT's in my app.  The remote DB is Ingres 6.4/04.

VB does *not* support transactions across SQL_PASSTHROUGH statements

(as above).

This is because Autocommit is turned on automatically.  Powerbuilder does

allow you to get around this by setting a flag in its .INI file.

: I'm very reluctant to use Dynasets to handle updates as I've heard horror

: stories about VB trying to bring back large amounts of data to the client

: when only a small amount is actually needed, why should I have to put up

: with any data being bought back when all of the programers here know SQL

: anyway and just just issue one statement.

I wrote a DLL while in UK Tech support that got around all this.  Call

UKTS for more info.  Alternatively give me a mail and I'll see what we can

do.

: 2. Can VB insert rows into an Access DB using an Insert statement...?

: This one is really causing my brain to bleed!....I've tried to insert

: individual rows into an Access DB using "INSERT INTO fred (col_a)

VALUES

: (1234)", and this just produces a 'Syntax error in INSERT statement' -

what's

: wrong with this.... the only docs that I can find show INSERTs from a

: sub-select. I can't believe that this is not possible using VB!

Hate to say it but it's true.  VB just sucks when it comes to a real man's

SQL syntax.  You have two alternative's here.

1) Add rows using Tables

2) Add rows using Dynasets

The benefits however to specifying everything in your code ie.

ds("id") = x

ds("name") = y

etc

etc

is that you can insert heaps and heaps and heaps of rows before closing your

dynaset (Do this in a transaction).  And you get a huge performance

improvement.  Since VB uses optimistic locking, you do the whole thing

at once on the first modification to database files...

--

" Jon Machtynger(jonm@ingres.com) Ph: 02-716 32 18 Fax: 02-725 46 50 "

" Excelsiorlaan 25,  B-1930 Zaventem,  Brussels


SQL Dynaset to ASCII

LUOKKA: SQL

Date: 06/26/94 (12:12)              Number: 10612 of 10664 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: What is the best way to send a Dynaset out to a comma-de

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

'  Export as comma-delimited ASCII

'  Last modified     APD   23/6/94

'  All comments: softdev@codesmth.demon.co.uk

Option Explicit

'  Export the snapshot as comma-delimited

'  Returns 0 if OK, error code otherwise

Function ExportAsCSV (snpStuffToGo As Snapshot, ByVal sFilename As

String, ByVal ShowHeaders As Integer) As Integer

Dim FNum

Dim sWork As String

Dim sOutLine As String

Dim FirstOnLine As Integer

Dim iField As Integer

   ExportAsCSV = -1

   On Error GoTo ExportAsCSV_ErrHandlr

   snpStuffToGo.MoveFirst

   FNum = FreeFile

   Open sFilename For Output Access Write Lock Read Write As #FNum

   If ShowHeaders Then

      FirstOnLine = True

      sOutLine = ""

      iField = 0

      Do While (iField < snpStuffToGo.Fields.Count)

         sWork =

MakeFieldNameSafeForExport(snpStuffToGo.Fields(iField).Name)

         sOutLine = sOutLine & IIf(FirstOnLine, "", ",") & sWork

         FirstOnLine = False

         iField = iField + 1

      Loop

      Print #FNum, sOutLine

   End If

   Do While Not snpStuffToGo.EOF

      FirstOnLine = True

      sOutLine = ""

      iField = 0

      Do While (iField < snpStuffToGo.Fields.Count)

         sWork = MakeValueSafeForExport(snpStuffToGo.Fields(iField))

         sOutLine = sOutLine & IIf(FirstOnLine, "", ",") & sWork

         FirstOnLine = False

         iField = iField + 1

      Loop

      Print #FNum, sOutLine

      snpStuffToGo.MoveNext

   Loop

   Close #FNum

   ExportAsCSV = 0

   Exit Function

ExportAsCSV_ErrHandlr:

   ExportAsCSV = Err

   On Error Resume Next

   If Not IsEmpty(FNum) Then Close #FNum

   Exit Function

End Function

'  If the field name contains embedded spaces, then translate them to "_"

'  NB - This version just looks for spaces - hunting any awkward characters

  might be an idea

'  Doesn't affect capitalisation

Function MakeFieldNameSafeForExport (ByVal FieldName As String) As String

Dim sWork As String

Dim iNextPos As Integer

Dim iSpacePos As Integer

   ' Copy the string from place to place, chunk by chunk

   ' A chunk is "All those characters up to the next space" (may be null)

   ' followed by the space itself (translated) (may also be null)

   sWork = ""

   iNextPos = 1

   Do

      iSpacePos = InStr(iNextPos, FieldName, " ")

      If (iSpacePos > 0) Then

         ' A space - copy the chunk

         sWork = sWork & Mid$(FieldName, iNextPos, iSpacePos - iNextPos) &

           "_"

         iNextPos = iSpacePos + 1

      Else

         ' No more spaces - copy the remainder

         sWork = sWork & Mid$(FieldName, iNextPos, Len(FieldName) + 1 -

            iNextPos)

      End If

   Loop Until (iSpacePos <= 0) Or (iNextPos > Len(FieldName))

   MakeFieldNameSafeForExport = sWork

End Function

'  Strings & dates get wrapped in quotes, numbers don't

'  It's all based on VarType

Function MakeValueSafeForExport (ByVal ExportValue) As String

   Select Case VarType(ExportValue)

   Case V_STRING  ' Wrapped

      MakeValueSafeForExport = """" & ExportValue & """"

   Case V_DATE  ' Wrapped

      MakeValueSafeForExport = """" & Format$(ExportValue) & """"

   Case V_CURRENCY, V_INTEGER, V_LONG, V_SINGLE, V_DOUBLE  '

 Unwrapped

      MakeValueSafeForExport = Format$(ExportValue)

   Case Else   '  Nulls as well; V_EMPTY, V_NULL

      MakeValueSafeForExport = ""

   End Select

End Function

--

Andy Dingley     Codesmiths of Newcastle

dingbat@codesmth.demon.co.uk


SQL filter & Snapshot

LUOKKA: SQL

Date: 06/27/94 (01:18)              Number: 10698 of 10897 (Refer# NONE)

From: DWK@UNITY.NCSU.EDU

Subj: Re: Filter properties in Snapshot

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

CHUAH YEN HUA (isc20006@leonis.nus.sg) wrote:

:  Got a problem using Filter property in Snapshot

:  Issue this command

:   set sn = db.createsnapshot("fileName")

:   sn.filter = "Name = 'var'"

:   set sn = db.createsnapshot()

:  Command could not get me all the name equal to value stored

:  in var (var is a variable) (Name is a field in the FileName)

:  However, if I issue this command,

:   set sn = db.createsnapshot("fileName")

:   sn.filter = "'var'"

:   set sn = db.createsnapshot()

:  This command would retrieve all the records whereby name = var

:  could someone enlighten me please

: chris

 Chris,

     Try the following for the filter:

              sn.filter = "name = '" & var & "'"

     this will allow VB to resolve the value in var and then plug it

     into the filter string.

David


SQL insert 1

LUOKKA: SQL

Date: 07/02/94 (17:52)              Number: 11053 of 11148 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: SQL syntax for INSERT ???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2v44ff$ns5@ousrvr.oulu.fi>

           mcat@phoenix.oulu.fi "Mika Erkkila" writes:

> I want to insert a new values (from text boxes) into my existing table, for

> example PersonName, Person#, BirthDate to table called PersonTable.

> I have tried to make VB understand my SQL, but it does not work...

> SQL$ = "INSERT INTO PersonData ('" & txtPersonName.text & "'," &

>         txtPersonNumber.text & "," & txtBirthDate.text &");"

Try:

SQL$ = "INSERT INTO PersonData ( ÄNameÅ, ÄNumberÅ, ÄDate Of BirthÅ)"

SQL$ = SQL$ & "SELECT '" & txtPersonName & "', " &

         txtPersonNumber & ", #" & txtBirthDate & "# ;"

--

Andy Dingley     Codesmiths of Newcastle

dingbat@codesmth.demon.co.uk


SQL insert 2

LUOKKA: SQL

Date: 07/03/94 (01:19)              Number: 11078 of 11148 (Refer# NONE)

From: M_MILIS@PAVO.CONCORDIA.CA

Subj: Re: SQL syntax for INSERT ???

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Mika,

If you have Access, try doing it in its query grid and see what SQL looks

like. If you do lots of database programming, having Access is a _must_.

Especially considering that VB (and Access, for that matter) have almost no

SQL documentation, so doing queries in Access and looking at resulting SQL

is a good way to start.

To answer your question, this is your SQL:

INSERT INTO PersonData (PersonName, Person#, BirthDate)

SELECT 'Mika Erkkil', 123456, #7/3/94#;

I see that you are trying to use txtBirthDate.text to insert date, but don't,

since it will not work. You could try DateSerial(txtBirthDate.text), so

finaly, you VB code could look like:

SQL$ = "INSERT INTO PersonData (PersonName, Person#, BirthDate)

SELECT """

 & txtPersonName & """, " & txtPersonNumber & ", " &

 DateSerial(txtBirthDate) & ";"

Marko Milisavljevic

m_milis@pavo.concordia.ca

Montreal, Canada


SQL parameter query

LUOKKA: SQL

Date: 07/20/94 (03:25)              Number: 12536 of 12618 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: Parameter Queries and VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <fulerton.61.2E288285@hookup.net>

           fulerton@hookup.net "Sean D. Fullerton" writes:

> Could some one show me the proper way to make a parameter query work

> in VB on a Access 2.0 DB (and i'm using the COMM LAYER)

Here is a small function, lifted directly from some live code (VB 3.0 Pro,

Access 2.0). It's an Execute of an action query, but it works just the same

when build a snapshot or dynaset with a select query. Just replace

db.Execute with Set snpTest = qryListPasswords.CreateSnapshot()

I always name my parameters as something like "PR_xxxx", which makes the

SQL easier to read.

'  Record an expired password

'  Sets PWD_EXPIRED bit in Flags

'  Return 0 if OK, Err otherwise

Function FlagPwdExpired (ByVal Username As String) As Integer

Dim qryPwdExpired As QueryDef

   FlagPwdExpired = -1

   On Error GoTo FlagPwdExpired_ErrHandlr

   Set qryPwdExpired = db.OpenQueryDef("Q_Pwd Expired")

   qryPwdExpired!PR_Username = Username

   qryPwdExpired.Execute

   qryPwdExpired.Close

   FlagPwdExpired = 0

   Exit Function

FlagPwdExpired_ErrHandlr:

   FlagPwdExpired = Err

   Exit Function

End Function

--

Andy Dingley     Codesmiths of Newcastle

dingbat@codesmth.demon.co.uk


SQL parameters 1

LUOKKA: SQL

Date: 04/21/94 (15:06)              Number: 3923 of 3946 (Refer# NONE)

From: M_MILIS@PAVO.CONCORDIA.CA

Subj: Re: SQL & parameters, HELP!!!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article bbeatty.766887250@sage.cc.purdue.edu

beatty@sage.cc.purdue.edu (Brian Beatty) writes:

>I have a Access database that has 3 tables, Company, Contact and

>Meeting (yes another PIM) I can get Company & Contact together fine

>but when I want to bring up the meeting for the active contact only

>I can't. I tried going through the help and it seems like I need

>a PARAMETERS statement,  I understand how to use it, sorta, but I

>can find where I set the value ?

>for instance I have contact #69, and I want to display his meetings,

>if it just for him it would be ...

>Select * from Contact, Meeeting where Contact.ID = 69 and

>Meeting.ContactID =69 Order by MeetingDate

>But I need to do it for a variable that would = 69.

>I have a dynaset that links Company & Contact and I trying to create one

>for Contact & Meeting

You can do it in 2 ways: (assume ContactID is a long or integer containing

69)

1) dynamically create an SQL statement:

   Dim ds As Dynaset, db as Database

   ...

   Set ds = db.CreateDynaset("

 SELECT *

 FROM Contact, Meeeting,

 Contact INNER JOIN Meeting ON Contact.ID = Meeting.ContactID

 WHERE Contact.ID = " & ContactID & " ORDER BY MeetingDate;")

2) create a query in Access, call it "MeetContact", with SQL statement:

 PARAMETERS MyID Long;

 SELECT *

 FROM Contact, Meeeting,

 Contact INNER JOIN Meeting ON Contact.ID = Meeting.ContactID

 WHERE Contact.ID = MyID ORDER BY MeetingDate;

   Then, in your code:

   Dim qd As QueryDef, ds As Dynaset, db As Database

   ...

   Set qd = db.OpenQueryDef("MeetingDate")

   qd.MyID = ContactID

   Set ds = qd.CreateDynaset()


SQL parameters 2

LUOKKA: SQL

Date: 04/21/94 (15:19)              Number: 3927 of 3946 (Refer# NONE)

From: ILATHWEL@RPMS.AC.UK

Subj: Re: SQL & parameters, HELP!!!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

kts. SQL: parameters 1...

Not sure I understand the question correctly, but I have to do something like

this, and I would do the following.

'Assuming that CurrentContact contains 69 (or whatever number)

SQLQ = "SELECT * FROM Contact, Meeting "

SQLQ = SQLQ + "WHERE Contact.ID = " + FOrmat$(CurrentContact)+" AND

Meeting.ContactID = " + Format$(CurrentContact)


SQL queries

LUOKKA: SQL

Date: 05/25/94 (12:56)              Number: 7004 of 7084 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: Stung by query syntax again

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Some tips for writing SQL queries:

   Use Access and QBE. Once it's "working" (even if the parameters are hard

   coded), then open up View.SQL and copy the stuff from the SQL window

  into your VB code. If you need to insert VB variables, try testing this under

   Access by using parameters instead. They're then nice & easy to spot when

   it comes to converting into VB - I always call my parameters "PR_xxxx", so

   I can just search my VB code for this to find any instances that I've

   missed.

   It never works first time. So put an error handler into your VB code that

   copies the contents of SQLStr onto the clipboard, should the query fail.

   Now it's quick & easy to switch back to Access, find a hacking-about query

   and paste the erroneous SQL into that. It's *much* easier to debug a SQL

   query in Access, after the variables have been merged in, than it is to do

   it blind from VB.

   Use carriage returns to break up your SQL, one before each reserved

   word is sensible. They're not significant in SQL. I assume you're not

   stupid enough to put them in the middle of field names - unfortunately

   Debug.Print is !

   When merging in the contents of a variable (building a SQL query in a VB

   string), it should *always* be surrounded by an ampersand and 3 double

   quotes, or an ampersand and 2 mixed quotes, depending on your local

   conventions:

     SQLStr = SQLStr & "WHERE Username <= """ & Username$ """ "

   or:

     SQLStr = SQLStr & "WHERE Username <= '" & Username$ "' "

   If you're using dates, then it will *always* be one quote, a hash and an

   ampersand:

     SQLStr = SQLStr & "WHERE Start_Date <= #" & Ö

         Format$(CutOffDate,"Long Date") "# "

   Another tip with dates is to format them with the long date format, not

   the short date. This is then safe against the transatlantic reversal of

   month & day position.

   If you're merging in a field/table name, enclose it in square brackets.

   That way the SQL will still be valid if the variable contains spaces:

     SQLStr = "SELECT * FROM Ä" & TableName$ "Å ;"

   When build SQL strings in VB, then you'll often do this on several lines,

   concatenating SQLStr with the new string. If you leave a space at the end

   of every string, then you can guarantee you won't have problems with the

   text from successive lines running into each other.

   If you're using Access 1, you'll keep running into the 1024 character

   limit on the length of a SQL string. Keep the table & field names short,

   especially if many JOINs are concerned. Using underscores in names is

   shorter than spaces, as you don't need the extra 2 characters for the

   square brackets around them. If your SQL is slightly too long, then you'll

   probably see a "Missing semicolon" error, even though the semicolon is

   obviously there (To you, anyway !).

   Making a QueryDef is a complicated process that is often slower than

   executing the query ! Don't mess with the .SQL property, as that is

   equally slow (Access needs to do a lot of work to turn SQL into its

   internal query format). Two ways around this:

      Use ready-built queries, written with Access. If you need to merge in

      values from variables, then use a query with parameters. Setting

      parameter values is quick to execute.

      If you really need to build SQL on the fly -- you need to build an ad

      hoc query, or to supply table or field names (which can't be done with

      query parameters), then try using:

        database.Execute SQLStr

      As this doesn't build a QueryDef, then it's quick.

--

Andy Dingley     Codesmiths of Newcastle

dingbat@codesmth.demon.co.uk


SQL query listbox

LUOKKA: Access

Date: 06-28-95 (14:22)              Number: 374191 of 374318 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: SQL Query for listbox

From: Lasse Rantanen <lasse@RANTANE.PP.FI>

>Hi all, I would like to replace my data aware controls dependency with

>data objects in my apps.

>I am currently using Mlist.vbx in my app, which is an enhanced listbox other

>than that it behaves like a normal listbox and would like to fill it with records

>which have >been read from a access 1.1 database.

>Currently I can loop through a table object and read all the records and

>fill the list box.

>

>What I would like to know is how can you perform a sql query like the one

>below which was using a data control and refill the listbox with the

>selected records.

>

>Sub RegOptOim_Click ()

>FindOim = InputBox$("Please enter a Surname :", "Surname Search")

>    If Len(FindOim) > 0 Then 'If they entered a Oim

>         Register.RecordSource = "SELECT * from Register WHERE

ÄSurnameÅ =

>'" & Surname & "'"

>            If Register.Recordset.NoMatch Then 'If no hit

>                MsgBox "That Surname is not on file.", 48, "Find error"

>            End If 'If no match

>    End If 'If Something to look up

>    Register.Refresh

>End Sub

some sample code how I did this (propably slow, but works).

First sample adds names to the list box only once (no replicates)

   DBName = CurrentWorkDirectory & "Ö" & Trim$(CurrentProjectID) & ".MDB"

   Set MyDB = OpenDatabase(DBName)     ' Open the database.

   Set MyDS = MyDB.CreateDynaset("Background")  ' Make dynaset from

table.

   ' Add records to listbox

   lstNames.Clear

   lstNames.AddItem "All"

   MyDS.MoveLast

   NumOfRecords = MyDS.RecordCount

   MyDS.MoveFirst

   For i = 0 To NumOfRecords - 1

      f$ = MyDS("Surname") & ""

      If f$ = "" Then f$ = "No answer"

      itemNum = SendMessage(lstNames.hWnd, LB_FINDSTRING, -1, ByVal

f$)

      If itemNum = LB_ERR Then

         lstNames.AddItem f$

      End If

      MyDS.MoveNext

   Next i

   lstNames.ListIndex = 0

   MyDS.Close

   MyDB.Close

Second sample adds persons with same surname into another list box (or all

persons)

   FName = lstNames.List(lstNames.ListIndex)

   If FName = "All" Then

      MyCriteria = "Background"

   Else

      MyCriteria = "Select * FROM Background WHERE Surname= '" & FName

& "'"

   End If

   DBName = CurrentWorkDirectory & "Ö" & Trim$(CurrentProjectID) & ".MDB"

   Set MyDB = OpenDatabase(DBName)     ' Open the database.

   Set MyDS = MyDB.CreateDynaset(MyCriteria)  ' Make dynaset from table.

   ' Add records to listbox

   lstPersons.Clear

   MyDS.MoveLast

   NumOfRecords = MyDS.RecordCount

   MyDS.MoveFirst

   For i = 0 To NumOfRecords - 1

      f$ = MyDS("PersonID") & "" & " " & MyDS("Surname") & "" & ", " &

MyDS("FirstName") & ""

      lstPersons.AddItem f$

      MyDS.MoveNext  ' Move to the next record.

   Next i

   lstPersons.ListIndex = 0

   MyDS.Close

   MyDB.Close

If you want to check that there are some records in the dynaset do following

check at proper place

   If MyDS.BOF = True And MyDS.EOF = True Then

      MsgBox "That Surname is not on file.", 48, "Find error"

      .... your actions

   End If

    Lasse


SQL stored pro

LUOKKA: Access

Date: 02/13/95 (11:20)              Number: 224752 of 225504 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Calling SQL Stored Procedur

Calling a stored procedure is extremely simple.  Just create a string

variable to hold your sql statement and other variables to hold your

parameters.  Format your sql statement and store it in the variable you

created then create a dynaset to hold your results using

DB_SQLPASSTHROUGH.  For example:

Dim SqlStm As String

Dim Conn As String

Dim Cust_id As String

Dim Db As Database

Dim Ds As Dynaset

Conn = "ODBC;dsn=server;uid=user;pwd=password"

Set Db = OpenDataBase(Conn)

Cust_id = "999999999"

SqlStm = "exec stored_proc_name "

SqlStm = SqlStm & "'" & Cust_id & "'"

Set Ds = Db.CreateDynaset(SqlStm)

Ds.MoveFirst

After this code, the Dynaset, Ds, will contain the results of the stored

procedure (stored_proc_name) for parameter Cust_id.

=-=-=

Ray Porter

Applications Analyst Programmer

Administrative Data Processing

University of North Carolina at Chapel Hill

Phone: 919/966-5878       Fax: 919/962-0900

eMail: lrp.admin@mhs.unc.edu

       dragon@email.unc.edu


SQL Workshop 3.0

LUOKKA: Access

7141 (13+)  74204.2246@compuserve.com  ???

Mike Sachais: "*** NEW *** SQL Server Stored Procedure Debugger"

SQL Workshop 3.0, is the FIRST and ONLY database development tool that

includes a WINDOWS BASED Stored Procedure Debugger for MS SQL

Server and SYBASE databases.  The debugger enables you to place break

points within a procedure and select variables you want to "watch" as you

run the procedure.

Below are some major features of SQL Workshop.  FREE demo copies

of SQL Workshop are available via ftp by downloading the file

SQLWS30.ZIP from ftp.cica.indiana.edu  (or one of its mirror sites)

 in the /pub/pc/win3/programr directory.  This file can also be

downloaded from Compuserve in the Sybase, Powersoft and Microsoft

SQL Server forums.

For further information about SQL Workshop contact:

Analytical Solutions, Inc.

3857 Foxwood Rd.

Duluth, GA 30136 USA

Tel: (404) 416-8821

Compuserve: 74204,2246

Internet: 74204.2246@compuserve.com

Product Description:

SQL Workshop is a powerful database development tool for querying,

creating, and maintaining database objects. It is the ONLY TOOL

AVAILABLE that delivers a fully integrated stored procedure

development environment for SYBASE and Microsoft SQL Server databases

INCLUDING A WINDOWS BASED STORED PROCEDURE DEBUGGER.

SQL Workshop is the perfect supplement when using PowersoftÆs

Powerbuilder, Microsoft Visual Basic, or any other GUI based

development tool.  By automating many of the tasks you perform to

develop and maintain database objects, SQL Workshop increases your

productivity and reduces your development time.

SQL Workshop works with any ODBC compliant database making it the only

tool you'll need to manage all of the data and databases in your

enterprise.  In addition to adhoc query facilities and database

management tools, SQL Workshop enables you to:

Debug stored procedures within the Windows environment

SQL Workshop is the only product that lets you debug stored

procedures within the MS Windows environment !  Place break

        points

within a procedure, select the variables you would like to "watch",

then run the procedure.  SQL Workshop stops at the breakpoints

within the procedure and displays the values of your chosen

     "watch"

variables.  SQL 	Workshop also allows you to "trace

breakpoints"

which enables you to run a procedure from start to finish and still

view the values of the "watch" variables.

In addition to displaying "watch" variables, SQL Workshop also

displays timing information at each break point which enables you

              to quickly locate performance problems within your procedures.

Reverse engineer database objects

SQL Workshop can easily create and reverse engineer database

           objects.

SQL Workshop can recreate all database objects including tables,

indexes, procedures, triggers, views, etc. Simply select the

              object you want to work with and SQL Workshop retrieves the SQL

              text of the object. You can then change and reload the object back

              into the database.

Run Bulk Copy within the Windows environment

SQL Workshop enables you to run the SQL Server Bulk Copy

      Program (BCP) from within the Windows environment.  You can also

       copy data from one server to another without having to switch

connections between servers.  No more hassles exiting Windows to

 the DOS prompt and formatting the BCP command line.  Simply

select a table to export/import data from/to, choose your delimiters,

  and click RUN.

That's all there is to it.

Compare and update data between two tables

SQL Workshop is the only database tool that can compare and

              transfer data between tables.  The tables can even exist on

    different servers and be from different database types (i.e. Oracle

  and Sybase). SQLWorkshop compares the data between the tables

  and updates the destination table based on the options you hoose.

  This invaluable in keeping tables in different environments in-sync

 with one another.

Export table data into text delimited files

SQL Workshop is the only database tool that let's you store the

results of any SQL statement (including execution of stored

procedures) in text delimited files.  This enables you to easily

change or merge table layouts without losing the data within the

tables.  Simply extract the data using a SQL SELECT query,

    change the table layout(s), and load the extracted data back into

  the new table.

Automatically generate stored procedure SQL scripts

SQL Workshop will generate Insert, Update, Delete and Select

        Stored Procedure code for you.  Simply select a table, choose the

       input parameters, and SQL Workshop does the 	rest.  You can

         review the code, change it, save it to a file and/or execute it to

     create new procedures.

Search database objects for specific text

SQL Workshop provides a facility to search for text in SQL Server

database objects.  For example, you can search through all objects

that reference the VIEW named MY_VIEW.  You can search one or

              more databases.  Even search the entire server !

Reference SQL Syntax using an on-line help facility

SQL Workshop provides an on-line help facility for SQL syntax.

          You can view and paste the syntax into query windows.  Then

   customize the syntax to your needs.  This eliminates the need to

   remember complex SQL syntax.


SQLstored pro

LUOKKA: Access

Date: 02/13/95 (11:20)              Number: 224751 of 225504 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Calling SQL Stored Procedures?

You have a few options, some better than others:

1.   Built-in VB options, using ODBC:  use the ExecuteSQL method for stored

procedures that do not return rows, and the CreateSnapshot method for

stored

procedures that do return rows.

i.e.:

     strSQL$ = "MyStoredProcThatDoesNotReturnRows " & parameter$

     RowsAffected% = db.ExecuteSQL(strSQL)

     '*********************

     strSQL$ = "MyStoredProcThatReturnsRows " & parameter$

     Set MySnapshot = db.CreateSnapshot(strSQL, DB_SQLPASSTHROUGH)

Of course, db must have been opened as an ODBC database.

2.   Use the ODBC API directly:  You can call stored procedures with the

SQLExecute() function, and others.  You must have the .BAS modules that

have

all the function declarations (available on the MSDN CDs, and probably

elsewhere), and time to study the sample programs.

3.   Use the DB-Library API.  You must have the SQL Server Programmer's

Toolkit, which includes documentation, declarations and constants, and the

VBX which you put in your app.   You call stored procedures with the

SqlExec() function, among others.

For simple stuff, option 1 is fine.  For enterprise stuff that needs to be

bulletproof and robust, I would recommend option 3.  We are using DB-Lib for

several applications at our school, and wouldn't be stuck without it.

I'd be willing to help further if you have other questions.

Anthony Stevens

Software Developer

UW Dental School

anthonys@argus.dental.washington.edu


Stack double!

LUOKKA: VBgen

Date: 04-01-95 (00:17)              Number: 279550 of 280746 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Stack

>I know this was just posted a while back, but I tried to do a DATABASE

search

>of the listserv and it told me that it doesn't support it yet.  Anyway, how

>can I change the stack size of my VB program?

>

>The problem that I am receiving is when I scroll through a listbox.  Using

>the up and down arrow keys (or the scrollbar) I receive a message every

now

>and then that say "Out of Stack space".  However, you click ok and the

>program lets you continue.  The wierd thing is that you can us pgup, pgdn,

>home, and end in the list box without getting this error.....

>

>Any suggestions would be appreciated.

SPATCH.ZIP will double the vb stack to 40k. If you can't find it let me know.

------------------------------------------------------------------------

Chuck Stuart - Mesquite TX USA


Stack increasing

LUOKKA: misc

3577 (25+)  cstuart@metronet.com  22.01.95  19:46

Chuck Stuart: "Re: Help - Out of Stack Space?"

>Stuart) writes: > >  >How do you increase stack space in Visual Basic?

>> SPATCH.ZIP will double the stack from 20k to 40k.

>And where is this file located ?

>Any downside using this utility ?

Hi Charly

No guarantees

 If Right$(Text1.Text, 6) <> "VB.EXE" Then MsgBox "You didn't provide the

proper path and name of the VB.EXE. Try again.": Exit Sub

Screen.MousePointer

= 11 Length = Len(Text1.Text) - 3

 VBPath = Text1.Text

 Text1.Text = "Making backup of VB.EXE"

 Text1.Refresh

 DestFile = Left$(VBPath, Length) & "001"

 FileCopy VBPath, DestFile

 Text1.Text = "Patching VB.001"

 Text1.Refresh

 Open DestFile For Binary Access Read Write As #1

   Get #1, 1555, StackVB%

   Get #1, 82743, StackCompiled%

   Get #1, 101254, Checksum%

   If StackVB% <> &H5000 Then GoTo ValidationError

   If StackCompiled% <> &H5000 Then GoTo ValidationError

   If Checksum% <> &HBC57 Then GoTo ValidationError

   StackVB% = &HA000

   StackCompiled% = &HA000

   Checksum% = &H1282

   Put #1, 1555, StackVB%

   Put #1, 82743, StackCompiled%

   Put #1, 101254, Checksum%

   MsgBox "Patch successful"

   Screen.MousePointer = 0

   Text1.Text = VBPath

   Exit Sub

ValidationError:

   MsgBox "Validation failure"

   Screen.MousePointer = 0

   Text1.Text = VBPath

   Exit Sub

FileError:

    Select Case Err

        Case Else: MsgBox "An error occurred while running Stack Patch. The

error number is: " & Err: Screen.MousePointer = 0: Text1.Text = "ERROR":

Exit Sub

        Resume

    End Select

------------------------------------------------------------------------

Chuck Stuart

Mesquite TX USA


Status bar

LUOKKA: status bar

Number: 14280 of 14404 (Refer# NONE)

From: GALENR@GR.HP.COM

Subj: Re: Status bar - how does it work?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can do this with a few API calls. Set up a timer, use GetCursorPos() and

WindowFromPoint() API calls to get the hWnd of the control under the cursor.

Use the hWnd value and Case to display your message.

Take a look at Article ID: Q111495 in the MS Knowledge Base for more info,

though set up as "balloon help" it can be easily modified for "status bar

help"...

- Galen -

galenr@hpgrla.gr.hp.com


Status bar

LUOKKA: status bar

Date: 04/26/94 (03:01)              Number: 4245 of 4287 (Refer# NONE)

From: DAVE.WATERSON@ALMAC.CO.UK

Subj: Status Area

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

use a picture box to hold a text box for the status message ( if you set the

font style to normal rather than bold it looks more professional). To trap

mouse events you need a copy of msgblaster.vbx from ftp.microsort.com.

Then use the MOUSE_MOVE event of the control (3dcommand etc) . This is

triggered when the mouse passes the control surround the controls with a

picturebox or sumsuch and use the MOUSE_MOVE event of this to clear the

status. This works in VBpro and avoids getting into windows message

handling of the MOUSE_ENTER MOUSE_EXIT messages to set and clear the

status bar.

/============================  /==========================

" Dave Waterson               " dave.waterson@almac.co.uk "

" Energy Action Grants Agency " dave@eaga.demon.co.uk "


Status bar menu items

LUOKKA: status bar

Date: 05-12-95 (16:05)              Number: 326284 of 329412 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: How to display status about menu items..

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

> >      ThanQ for your previous answers for my questions, especially to

> >Michel Christian. Now I came with another problem, in VB menu items only

> >have a click event generated, suppose if we have a got focus or

> >Lostfocus event then we can easily display what it will do in our Window

> >Title(like WordPerfect) or on the status bar (like MsWord), Even the > >

MouseMove event is not getting generated. How can we display the >

>status bar help on menu items

You can use a generic subclassing control (like msgblast.vbx) to subclass

the form containing the menu.  Then look for the WM_MENUSELECT

message. This is an example of code I used with Desaware's SBC.VBX.

Sub SubClass1_WndMessage (wnd As Integer, msg As Integer, wp As

Integer, lp As Long, retval As Long, nodef As Integer)

If msg = WM_MENUSELECT Then

   hMenu = GetMenu(Me.hWnd)

   sMenu = Space$(255)

   iResult = GetMenuString(hMenu, wp, sMenu, 255, MF_BYCOMMAND)

   sMenu = Left$(sMenu, nResult)

   If iResult = 0 Then

      'Remove the tab and the shortcut key

      sCharPos = InStr(sMenu, Chr$(9))

      If sCharPos Then

         sMenu = Left$(sMenu, sCharPos - 1)

      End If

      'Remove the trailing periods

      sCharPos = InStr(sMenu, "...")

      If sCharPos Then

         sMenu = Left$(sMenu, sCharPos - 1)

      End If

      'Remove Number from Windows in the "Window List"

      If Len(sMenu) > 3 Then

         iTemp = Val(Mid$(sMenu, 2, 2))

         If (iTemp > 0) And (iTemp < 10) And Left$(sMenu, 1) = "&" Then

            sMenu = Mid$(sMenu, 4)

         End If

      End If

      'Remove the "&" character

      sCharPos = InStr(sMenu, "&")

      If sCharPos Then

         If Mid$(sMenu, sCharPos, 2) <> "&&" Then

            If Len(sMenu) > sCharPos Then

               sMenu = Left$(sMenu, sCharPos - 1) & Mid$(sMenu, sCharPos +

1)

            Else

               sMenu = Left$(sMenu, sCharPos - 1)

            End If

         End If

      End If

      'Set the caption of the panel control

      pnlStatusBar.Caption = sMenu

   End If

End If

End Sub

Chris Chandler

L064719@PO200.APPL.GE.COM


Status bar on menus

LUOKKA: status bar

Date: 11/23/94 (22:19)              Number: 27799 of 27896 (Refer# NONE)

From: IAN@LYNAGH.DEMON.CO.UK

Subj: Re: Need help on status bar

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> I'm trying to have a status bar in my application which describes shortly

> the function a button or menu topic will perform. That's no problem with

> buttons or text boxes, but how do I do that thing with menus?! The menus

> doesn't have a "Button down" procedure or something like that.

The_menu_Click

 statusbar.caption = "This is a menu"

End Sub


Status bar status bar

LUOKKA: status bar

Date: 11/02/94 (21:06)              Number: 25611 of 25696 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: MacGuides in VB??? Help?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I picked this up from an earlier c.l.b.v. posting, and I think it

might be in the FAQ (If it isn't, maybe it can go in now?). I've

used it and it works very well. Warning: this is a long posting.

Ian Piper

------------------Begins-------------------------------------

How to Implement ToolTips Help in Visual Basic Applications

Article ID: Q111495

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

Windows, versions 2.0 and 3.0

------------------------------------------------------------------

SUMMARY

=======

This article shows by example how to implement the toolbar "ToolTips" help

in a Visual Basic application in a manner similar to the way "ToolTips" help

system is implemented in Microsoft Word version 6.0 for Windows and

Microsoft Excel version 5.0.

MORE INFORMATION

================

The following example implements a "ToolTips" help system by taking

advantage of the GetCursorPos() and WindowFromPoint() Windows API

functions.

The GetCursorPos() function returns the current location of the mouse cursor

and the WindowFromPoint() function returns the hWnd (window handle) of

the

control or form at a particular location on the screen.

Important Note: Modifications Required If Using Image Controls

-----------------------------------------------------------

IMPORTANT NOTE: Most toolbars in Visual Basic are made by using a

container

control (picture box) with individual image controls acting as buttons

placed inside the container. The Image control, however, is a "light"

control; it does not have an hWnd property. Because of this, the

WindowFromPoint() Windows API function will not be able to detect which

image control the cursor is over. It will give the hWnd of the image

control's parent, in this case the container.

Therefore, if you are using image controls as your toolbar buttons (or some

other control that doesn't have an hWnd property), you need to modify this

program. Have it detect when the mouse cursor is over the parent container.

Then calculate which image control the cursor is over by comparing the x

and

y coordinate returned by GetCursorPos, which is relative to the screen, to

the coordinates of the image controls, which are relative to the parent

container.

How to Use the GetCursorPos() and WindowFromPoint() Windows API

functions

----------------------------------------------------------------------

By using a timer, you can call the GetCursorPos() and WindowFromPoint() API

functions to find out if the mouse cursor is located over a control for

which you want to display a help window.

The help window is displayed by using an auto sizing label control on a

separate form. By locating the form relative to the cursor, changing the

label's caption, and resizing the form, you can display the ToolTips help.

Then you can use the ShowWindow() Windows API function to display the

help

form without giving it the focus. By using ShowWindow(), you can keep the

main forms title bar from flashing when focus changes. In contrast, the Show

method would cause the title bar to flash.

Step-by-Step Example

-----------------

1. Start a new project in Visual Basic. Form1 is created by default.

2. Place the following controls on Form1:

Timer (Timer1)

Text Box (Text1)

List Box (List1)

Combo Box (Combo1)    'See NOTE below

Check Box (Check1)

Picture Box (Picture1)

Option Button (Option1)

Command Button (Command1)

Vertical Scroll Bar (vScroll1)

Horizontal Scroll Bar (hScroll1)

NOTE: The combo box is a special case. The edit box portion of the combo

box

is a child window of the combo box, so it has a different window handle.

Therefore, you must make call the GetWindow() Windows API function, with

the

GW_CHILD parameter, in order to get the hWnd of this edit box.

3. Add the following code to the Form_Load event of Form1:

Sub Form_Load ()

' Set timer for 1 second, and enable it.

Timer1.Interval = 1000

Timer1.Enabled = True

End Sub

4. Add the following code to the timer event of Timer1:

Sub Timer1_Timer ()

Dim curhWnd As Integer      'Current hWnd

Dim p As POINTAPI

Static LasthWnd As Integer  'Hold previous hWnd

' Make sure the program has the input focus:

If GetActiveWindow() = Form1.hWnd Then

' Initialize point structure:

Call GetCursorPos(p)

' Which window is the mouse cursor over?

curhWnd = WindowFromPoint(p.y, p.x)

' Same as last window? If so, don't need to redraw:

If curhWnd <> LasthWnd Then

' Store the current hWnd:

LasthWnd = curhWnd

' Decrease timer interval to 5 ms (could choose 1 ms):

Timer1.Interval = 5

' Which control is the cursor over?

Select Case curhWnd

Case Command1.hWnd

DisplayHelp "Command Button"

Case Text1.hWnd

DisplayHelp "Text Box"

Case List1.hWnd

DisplayHelp "List Box"

Case Picture1.hWnd

DisplayHelp "Picture Box"

Case Check1.hWnd

DisplayHelp "Check Box"

Case Option1.hWnd

DisplayHelp "Option Box"

Case Combo1.hWnd

DisplayHelp "Drop Down Combo Box"

Case GetWindow(Combo1.hWnd, GW_CHILD) 'Edit box of combo box

DisplayHelp "Edit Box of Combo Box"

Case hScroll1.hWnd

DisplayHelp "hScroll Bar"

Case vScroll1.hWnd

DisplayHelp "vScroll Bar"

Case frmHelp.hWnd

' If it moves onto the help window, hide it:

frmHelp.Hide

Case Else

' Cursor is over the form or something else, so

' change interval back to 1 sec delay:

DisplayHelp ""

Timer1.Interval = 1000

End Select

End If

End If

End Sub

5. Create a new module. From the File menu, choose New Module (ALT, F,

M).

Module1 is created by default.

6. Add the following declarations to the General Declarations section of

Module1:

Global Const SW_SHOWNOACTIVATE = 4

Global Const GW_CHILD = 5  'Needed for edit portion of combo box

Type POINTAPI       'Stores location of cursor

x As Integer

y As Integer

End Type

Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)

Declare Function GetActiveWindow Lib "User" () As Integer

' Entr each of the following Declare statements on one, single line:

Declare Function WindowFromPoint Lib "user" (ByVal lpPointY As Integer,

ByVal lpPointX As Integer) As Integer

Declare Function GetWindow Lib "User" (ByVal hWnd As Integer,

ByVal wCmd As Integer) As Integer

Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer,

ByVal nCmdShow As Integer) As Integer

7. Add the following Sub procedure to Module1:

Sub DisplayHelp (Help$)

Dim lpPoint As POINTAPI ' Cursor Point variable

Dim ret As Integer      ' Return value of ShowWindow() API function

Rem Display Help String

Rem This Function displays the Help$ if Help$ <> "".

Rem if Help$ = "" then the Help String is removed.

Rem FUNCTION REQUIREMENTS:

Rem     GetCursorPos()    Windows API function

Rem     frmHelp           Name of the Help form

If Len(Help$) <> 0 Then  ' Double check help$

' Make sure help form is invisible:

frmHelp.Hide

' Change caption of label:

frmHelp.Label1.Caption = Help$

' Get the cursor position so you can calculate where to place the help form:

Call GetCursorPos(lpPoint)

' Offset the form from the cursor by 18 and 2 pixels (values chosen to

simulate the look of Microsoft Word version 6.0)

frmHelp.Top = (lpPoint.y + 18) * Screen.TwipsPerPixelY

frmHelp.Left = (lpPoint.x - 2) * Screen.TwipsPerPixelY

' Adjust width of form to label + 4     because 2 are needed for each pixel of

the border and 2 are needed to center the label (the label is inset by 1

pixel on the form). Also, adjust height of form to height of label + 2

because 2 ar needed for each pixel of the border:

frmHelp.Width = frmHelp.Label1.Width + (4 * Screen.TwipsPerPixelX)

frmHelp.Height = frmHelp.Label1.Height + 2 * Screen.TwipsPerPixelY

' Make sure form is on top:

frmHelp.ZOrder

' Show form without the focus:

ret = ShowWindow(frmHelp.hWnd, SW_SHOWNOACTIVATE)

Else frmHelp.Hide   ' Hide the form:

End If

End Sub

8. Create another form by choosing New Form from the File menu (ALT, F, F).

Form2 is created by default. Change the following properties of Form2:

Name = frmHelp

BorderStyle = 1 - Fixed Single

ControlBox = False

MinButton = False

MaxButton = False

9. Add a label control (Label1) to the frmHelp form and set AutoSize=True.

10. Add the following code the to Form_Load event of the frmHelp form:

Sub Form_Load ()

' Get rid of the forms Caption so title bar does not display:

Me.Caption = ""

' Give the form and label a light yellow background:

Me.BackColor = &H80FFFF

Label1.BackColor = &H80FFFF

' Inset label by 1 pixel:

Label1.Left = 1 * Screen.TwipsPerPixelX

Label1.Top = 0

End Sub

11. Start the program by pressing the F5 key. Then place the cursor over one

of the controls to display the help window.

-----------------------Ends-------------------------------


Stopwatch

LUOKKA: timing

Date: 10/04/94 (22:56)              Number: 21760 of 21852 (Refer# NONE)

From: BERKERY@EMMAX2.CRD.GE.COM

Subj: example of a VB stopwatch

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

' Simple stopwatch timer program

' It has 3 buttons, "start", "count up", "count down"

'        1 label, the time counter "0:00:00"

'        1 timer control function

' click on start and it begins timing by seconds from 0

' click on count up and you can preset a start time

'       f'rinstance 0:01:30 and it starts timing from there

' click on count down and you can preset the start time

'       the same as for counting up but it counts in

'       reverse until it reaches 0:00:00, then it will

'       continue counting up.

Option Explicit

Dim time_at_start As Double

Dim offset_diff As Double

Dim hr_offset As Integer

Dim mn_offset As Integer

Dim sc_offset As Integer

Dim countdown_flag As Integer

Dim time_string As String

Sub CountDown_btn_Click ()

    Dim midnight As Double

    Dim offset As Double

    'ask the user to specify a starting time

    time_string = InputBox$("start time", "time", "0:00:00")

    Label1.Caption = time_string

    hr_offset = CInt(Mid(time_string, 1, 1))

    mn_offset = CInt(Mid(time_string, 3, 2))

    sc_offset = CInt(Mid(time_string, 6, 2))

    'OK here's the trick. Set a differential between time

    '0:00:00 (midnight) and the amount of time to offset

    'the timer, also set a countdown flag var to tell the

    'timer function which way to go.

    countdown_flag = True

    midnight = TimeSerial(0, 0, 0)

    offset = TimeSerial(hr_offset, mn_offset, sc_offset)

    offset_diff = offset + midnight

End Sub

Sub CountUp_btn_Click ()

    countdown_flag = False

    'Ask the user to preset the time at which timing

    'is to begin

    time_string = InputBox$("start time", "time", "0:00:00")

    Label1.Caption = time_string

    hr_offset = CInt(Mid(time_string, 1, 1))

    mn_offset = CInt(Mid(time_string, 3, 2))

    sc_offset = CInt(Mid(time_string, 6, 2))

End Sub

Sub Form_Load ()

    ' initialize stuff

    hr_offset = 0

    mn_offset = 0

    sc_offset = 0

    'I make the interval 200 msec. but 500 will do

    'I don't like calling the timer only once a second

    'because it makes the time display a bit jumpy

    timer1.Interval = 200

    timer1.Enabled = False

End Sub

Sub Start_btn_Click ()

    Dim hr_start As Integer

    Dim mn_start As Integer

    Dim sc_start As Integer

    'start up the timer event process with the preset start

    'time specified by the user

    timer1.Enabled = True

    hr_start = Hour(Now) - hr_offset

    mn_start = Minute(Now) - mn_offset

    sc_start = Second(Now) - sc_offset

    time_at_start = TimeSerial(hr_start, mn_start, sc_start)

    'and if it's supposed to count down, then offset the

    'time at start backwards by whatever the user input.

    If countdown_flag = True Then

       time_at_start = Now + offset_diff

       End If

End Sub

Sub Timer1_Timer ()

    Dim hr As Integer

    Dim mn As Integer

    Dim sc As Integer

    Dim time_now As Double

    Dim time_diff As Double

    time_now = Now

    time_diff = time_now - time_at_start

    hr = CInt(Hour(time_diff))

    mn = CInt(Minute(time_diff))

    sc = CInt(Second(time_diff))

    time_string = Format(CStr(hr), " 0") & ":"

    time_string = time_string & Format(CStr(mn), "00") & ":"

    time_string = time_string & Format(CStr(sc), "00")

    Label1.Caption = time_string

End Sub

--------------------------------------------------------------------------

Jack Berkery, Computer Scientist, GE Research, Schenectady NY

  berkery@crd.ge.com  "The Common Sense Coach"


Strings C style

LUOKKA: DLL

2. How do I access C style strings?

   Use the 'lstrlen' and 'lstrcpy' calls found in the Kernel DLL.


Strings how wide

LUOKKA: string

Date: 09/03/94 (14:57)              Number: 18165 of 18257 (Refer# NONE)

From: PBOAKES@CIX.COMPULINK.CO.UK, "Phil Boakes"

Subj: Re: How Wide is My String

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

It depends on your Device Context. i.e. where the string's going to be

displayed. i.e. the font will effect the width.

But, you can get the width of a string for a given device context..

e.g. How wide will "Wibble Wobble" be in textbox "Text1" ?

Declare Function GetTextExtent& lib "User" (ByVal hDC%, ByVal TheString$,

ByVal TheStringLength%)

Then call with:

  Dim width As Long

     width = GetTextExtent((Text1.hDC), "Wibble Wobble", Len("Wibble

        Wobble"))

  The width is in bottom 16 bits, the height in top 16 bits.

Phil.


Strings how wide

LUOKKA: string

Date: 09/08/94 (13:41)              Number: 18648 of 18922 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: How Wide is My String

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Look at the TextWidth property. This applies to Forms, Picture boxes and

the Printer object, but yo could alway set a form or picture box font the

same as the grid, then test from that. Oh, and TextHeight is there as

well, of course.

--

Luke Webber


System colors manipul

LUOKKA: VBgen

MANIPULATING SYSTEM COLORS

--------------------------------------------------

When designing a large multi-form application, I try to design for colour as

well as style. Unfortunately, the user may be running the application with any

of the myriad system colour schemes that Windows provides.

I wrote the SYSCOLOR.BAS functions so that I could control the colour of

the various system components, such as Menubars, and  Scrollbars in my

applications. For instance, you could save the user's colour scheme - run

your application using YOUR design colours, and restore the user's scheme

upon exit. I have tried to make the functions as self-contained as possible,

so that SYSCOLOR.BAS can be 'slotted in' without conflict into an existing

project.

Note that SYSCOLOR.BAS is Windows 3.1 only. (Windows 3.0 has only 19

system colours, whereas Windows 3.1 has 21 system colours)

Option Explicit

'   //*************************************************//

'   //*                SYSCOLOR.BAS                   *//

'   //*                [GB] 03/07/94                  *//

'   //*************************************************//

'   //This module contains functions for manipulating the windows

'   //system colours.

'   //Functions are labelled PRIVATE and PUBLIC //

'   //You should only use the functions labelled +++ PUBLIC +++

'   //******************* LIST OF PUBLIC FUNCTIONS ************************//

'   //** FUNCTION Hex2Long (HexString As String) As Long

'   //Example: ALongInt = Hex2Long("C0")

'   //Purpose:

'   //Converts a valid Hex$ into it's corresponding decimal value//

'   //* Note - Do NOT use this for converting RGB Hex strings *//

'   //*********************************************************************//

'   //** SUB EnumerateSchemes()

'   //Example: EnumerateSchemes

'   //Purpose:

'   //Fills the Global Dynamic Array SCHEME(1 to i_LastScheme) with

'   //the names of the User's Colour schemes in CONTROL.INI

'   //Could be used to fill a Menu Array for the user to select from..

'   //No Initialisation needed.

Global Scheme() As String

Global i_LastScheme As Integer

'   //*********************************************************************//

'   //** SUB WriteSysColoursToINI (SchemeString As String, INIPath As

String)

'   //Example: WriteSysColoursToINI "Favorite",

"C:\WINDOWS\COLOURS.INI"

'   //Purpose:

'//Writes an entry in a private INI file that can be read by

GetSysColoursFromINI

'   //Note - INIPath is the FULL path, including the filename

'   //Entries written to CONTROL.INI can be read by Windows 3.1 Control

Panel

'   //No Initialisation required.

'   //*********************************************************************//

'   //** SUB GetSysColoursFromINI (SchemeString As String, INIPath As

String)

'   //Example: GetSysColoursFromINI "Favorite",

"C:\WINDOWS\COLOURS.INI"

'   //Purpose:

'   //Sets the User's system colours from a saved set in a private INI file

'   //Note - INIPath is the FULL path, including the filename

'   //Use WriteSysColoursToINI to write a private entry, or specify

'   //INIPath to be CONTROL.INI - both use the same format.

'   //*********************************************************************//

'   //** SUB SaveSysColours ()

'   //Example: SaveSysColours

'   //Purpose:

'   //This routine stores the User's System Colours//

'   //Call it to take a snapshot (to be restored by RestoreSysColours) //

'   //No Initialisation required.

'   //*********************************************************************//

'   //** SUB RestoreSysColours ()

'   //Example: RestoreSysColours

'   //Purpose:

'   //Restores system colours to that saved by SaveSysColours

'   //No Initialisation required.

'   //*********************************************************************//

'   //** SUB  SetColourSchemeFromControlPanel (SchemeString As String)

'   //Example: SetColourSchemeFromControlPanel "Wing Tips"

'   //Effect is not permanent//

'   //SchemeString could be got from the dynamic array Scheme()

'   //No Initialisation required.

'   //*********************************************************************//

'   //** SUB SetDefaultColourSchemeFromControlPanel ()

'   //Example: SetDefaultColourSchemeFromControlPanel

'   //This is the scheme that the user has set as their default

'   //Effect is not permanent. No initialisation needed//

'   //No Initialisation required.

'   //*********************************************************************//

'   //** SUB SetSysColour (Element As Integer, RGBValue As Long)

'   //Example1: SetSysColour COLOR_MENU, RGB(255,192,255)

'   //Example2: SetSysColour COLOR_MENU, QBColor(2)

'   //Example3: SetSysColour COLOR_BTNTEXT, 0

'   //Element is one of the COLOR_ constants below

'   //RGBValue can be RGB(x,y,z) or QBColor(x) or x //

'   //Purpose:

'   //Use to set one colour or more at a time

'   //No Initialisation required.

'   //USE THESE NAMES IN SETSYSCOLOUR (CONST_NAME, RGB(R,G,B))

Global Const COLOR_SCROLLBAR = 0

Global Const COLOR_BACKGROUND = 1

Global Const COLOR_ACTIVECAPTION = 2

Global Const COLOR_INACTIVECAPTION = 3

Global Const COLOR_MENU = 4

Global Const COLOR_WINDOW = 5

Global Const COLOR_WINDOWFRAME = 6

Global Const COLOR_MENUTEXT = 7

Global Const COLOR_WINDOWTEXT = 8

Global Const COLOR_CAPTIONTEXT = 9

Global Const COLOR_ACTIVEBORDER = 10

Global Const COLOR_INACTIVEBORDER = 11

Global Const COLOR_APPWORKSPACE = 12

Global Const COLOR_HIGHLIGHT = 13

Global Const COLOR_HIGHLIGHTTEXT = 14

Global Const COLOR_BTNFACE = 15

Global Const COLOR_BTNSHADOW = 16

Global Const COLOR_GRAYTEXT = 17

Global Const COLOR_BTNTEXT = 18

Global Const COLOR_INACTIVECAPTIONTEXT = 19

Global Const COLOR_BTNHILIGHT = 20

'   //*********************************************************************//

'   //Internal Flags//

Dim COLOURS_SAVED_OK As Integer

Dim RGBARRAY_SET_OK As Integer

'   //DLL Functions//

Declare Function GetSysColor Lib "User" (ByVal nIndex As Integer) As Long

Declare Sub SetSysColors Lib "User" (ByVal nChanges As Integer, lpSysColor

As Integer, lpColorValues As Long)

'   //** Note - ALIAS names should not conflict with normal declarations//

Declare Function Beeper Lib "User" Alias "MessageBeep" (ByVal BeepType

 As Integer) As Integer

Declare Function GetVer Lib "Kernel" Alias "GetVersion" () As Long

Declare Function ReadFromINI Lib "Kernel" Alias "GetPrivateProfileString"

(ByVal Topic As String, ByVal Keyname As String, ByVal DEFAULT As String,

  ByVal ReturnedString As String, ByVal maxsize As Integer, ByVal Filename

As String) As Integer

Declare Function WriteToINI Lib "Kernel" Alias "WritePrivateProfileString"

(ByVal Topic As String, ByVal Keyname As String, ByVal NewString As String,

  ByVal Filename As String) As Integer

Declare Function GetUsersWINDIR Lib "Kernel" Alias

"GetWindowsDirectory"   (ByVal ipbuffer As String, ByVal nSize As Integer)

As Integer

'   //There are 21 System Colours in Windows 3.1//

Dim ColourText(0 To 20) As String

Dim IndexArray(0 To 20) As Integer

Dim RGBArray(0 To 20) As Long

Dim OldRGBArray(0 To 20) As Long

Dim NumChanges As Integer

Dim WINDIR As String'   //Users Windows Directory//

Sub EnumerateSchemes ()

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //Initialises Scheme(1 to ?) and i_LastScheme//

'   //Scheme() is a dynamic array of CONTROL.INI Colour Scheme names//

'   //i_LastScheme is the number of the last valid entry//

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

Dim sz_Buf As Variant

Dim sz_Topic As String

Dim sz_Filename As String

Dim fn As Integer'  //File Handle//

Dim pos As Integer

fn = FreeFile

sz_Topic = "[color schemes]"

If WINDIR = "" Then WINDIR = GetWINDIR()

sz_Filename = WINDIR

If Right$(sz_Filename, 1) <> "\" Then sz_Filename = sz_Filename & "\"

sz_Filename = sz_Filename & "CONTROL.INI"

'   //Find the [color schemes] topic

Open sz_Filename For Input As #fn

Do Until EOF(fn)

    Input #fn, sz_Buf

    If Len(sz_Buf) > 14 Then

        If Left$(sz_Buf, 15) = sz_Topic Then Exit Do

    End If

Loop

'   //Enumerate the keynames//

Do Until EOF(fn)

Input #fn, sz_Buf

If Len(sz_Buf) > 1 And Left$(sz_Buf, 1) = "[" Then Exit Do

pos = InStr(1, sz_Buf, "=")

If pos Then sz_Buf = Left$(sz_Buf, pos - 1)

If pos Then

    i_LastScheme = i_LastScheme + 1

    ReDim Preserve Scheme(1 To i_LastScheme)

    Scheme(i_LastScheme) = sz_Buf

End If

Loop

End Sub

Sub GetSysColoursFromINI (SchemeString As String, IniPath As String)

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //Sets the System Colours from an INI File (CONTROL PANEL style) saved

Scheme setting//

If SchemeString = "" Then Exit Sub'  //Failed Test//

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

'   //Test if RGBArray contains valid entries//

If RGBARRAY_SET_OK = False Then Init_RGBArray'   //Also sets

IndexArray//

'   //Do simple checks//

On Error GoTo EH_GSCError

If Dir$(IniPath) = "" Then Exit Sub'  //Failed Test//

If SchemeString = "" Then Exit Sub'  //Failed Test//

'   //Set up vars for DLL call//

Dim INIEntry As String

Dim i_RetVal As Integer

Dim sz_Bad As String

sz_Bad = "unknown"

Dim sz_Buf As String * 255

Dim i_SizeOfBuf As Integer

i_SizeOfBuf = 255

'   //Fetch the CSV string containing the 20 Hex numbers//

i_RetVal = ReadFromINI("color schemes", SchemeString, sz_Bad, sz_Buf,

i_SizeOfBuf, IniPath)

'   //Check result//

If i_RetVal = 0 Then Exit Sub'  //Failed Test//

INIEntry = Left$(sz_Buf, i_RetVal)

If INIEntry = "unknown" Then Exit Sub'  //Failed Test//

'   //Check that there are 20 values (19 commas) in the string//

Dim i_Count As Integer

Dim AString As String

Dim pos As Integer

pos = 0

AString = INIEntry

For i_Count = 1 To 19

    pos = InStr(AString, ",")

    If pos = 0 Then Exit Sub'  //Failed Test//

    AString = Mid$(AString, pos + 1)

Next i_Count

'   //Fetch each value, and assign it to RGBArray//

Dim HexString As String

pos = 0

AString = INIEntry

For i_Count = 0 To 19

    pos = InStr(AString, ",")

    HexString = Left$(AString, pos - 1)

    AString = Mid$(AString, pos + 1)

    RGBArray(i_Count) = Hex2RGB(HexString)

Next i_Count

'   //Fetch 20th Value//

RGBArray(20) = Hex2RGB(AString)

'   //Re-order IndexArray to point to the CONTROL.INI order//

ReMapIndexArray2ControlPanel

'   //Do the deed//

NumChanges = 21'    //Change all the colours in 1 go//

SetSysColors NumChanges, IndexArray(0), RGBArray(0)

'   //Come here if an error//

EH_GSCError:

'   //Reset to ordinal values//

Init_IndexArray

End Sub

Function GetWINDIR () As String

'   //Last Edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

Dim sz_Buf As String * 255

Dim i_RetVal As Integer

Dim i_SizeOfBuf As Integer

i_SizeOfBuf = 255

'   //Use alias in case GetWindowsDirectory has been declared already//

i_RetVal = GetUsersWINDIR(sz_Buf, i_SizeOfBuf)

If i_RetVal = 0 Then '  //Failed Test//

    MsgBox "Could not locate Windows Directory", 16, "GetWINDIR Fatal

Error"

    End

End If

GetWINDIR = Left$(sz_Buf, i_RetVal)

End Function

Function H2D (Char As String) As Integer

'   //Last Edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

'   //Converts a single Hex caracter into it's decimal equivalent//

Select Case Char

    Case "0" To "9"

        H2D = Val(Char)

    Case "A" To "F"

        H2D = Asc(Char) - 55

    Case Else

        Exit Function'  //Failed Test//

End Select

End Function

Function Hex2Long (HexString As String) As Long

'   //Last Edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //Converts a valid Hex$ into it's corresponding decimal value//

'   //USES: IsHexDigit() //

'   //** Do NOT use this for converting RGB Hex strings **//

Hex2Long = 0'   //Default Value//

If HexString = "" Then Exit Function'  //Failed Test//

Dim LENH As Integer

LENH = Len(HexString)

If LENH > 8 Then Exit Function'  //Failed Test//

'   //Passed checks OK, so...//

HexString = UCase$(HexString)

Dim i_Count As Integer

Dim l_Temp As Long

Dim Char As String

Dim Dec As Integer

'   //Hex number is converted in one step//

'   //Count from the last char to the first//

For i_Count = LENH To 1 Step -1

    Char = Mid$(HexString, i_Count, 1)

    If Not IsHexDigit(Char) Then Exit Function'  //Failed Test//

    Select Case Char

        Case "0" To "9"

            Dec = Val(Char)

        Case "A" To "F"

            Dec = Asc(Char) - 55

        Case Else

            Exit Function'  //Failed Test//

    End Select

    l_Temp = l_Temp + (Dec * (16 ^ (LENH - i_Count)))

Next i_Count

Hex2Long = l_Temp

End Function

Function Hex2RGB (HexString As String) As Long

'   //Last Edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

'   //Converts a valid [BBGGRR] Hex$ into it's corresponding decimal value//

'   //Used to decipher the CONTROL.INI values//

'   //USES: IsHexDigit() //

Hex2RGB = 0'   //Default Value//

If HexString = "" Then Exit Function'  //Failed Test//

If HexString = "0" Then Exit Function'  //Failed Test//

Dim LENH As Integer

LENH = Len(HexString)

If LENH > 6 Then Exit Function'  //Failed Test//

'   //Passed checks OK, so...//

HexString = UCase$(HexString)

Dim i_Count As Integer

Dim l_Temp As Long

Dim Char As String

Dim Dec As Integer

'   //Check that all are Valid Hex Digits//

For i_Count = 1 To LENH

    Char = Mid$(HexString, i_Count, 1)

    If Not IsHexDigit(Char) Then Exit Function'  //Failed Test//

Next i_Count

'   //Hex string could be 1,2,4,6 digits long//

'   //1 digit (0) has been dealt with//

'   //Order is BGR//

'   //Make it a RGB string//

Dim AString As String * 6

AString = "000000"

RSet AString = HexString

Dim iRED As Integer

Dim iGREEN As Integer

Dim iBLUE As Integer

'   //Microsoft store it as BBGGRR!//

'   //Get Blue//

iBLUE = 16 * H2D(Mid$(AString, 1, 1)) + H2D(Mid$(AString, 2, 1))

'   //Get Green//

iGREEN = 16 * H2D(Mid$(AString, 3, 1)) + H2D(Mid$(AString, 4, 1))

'   //Get Red//

iRED = 16 * H2D(Mid$(AString, 5, 1)) + H2D(Mid$(AString, 6, 1))

Hex2RGB = RGB(iRED, iGREEN, iBLUE)

End Function

Sub Init_ColourText ()

'   //Last edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

'   //These strings are used in the INI-File routines//

'   //It is called by routines (Set/Write)Colours(To/From)INI //

ColourText(0) = "COLOR_BACKGROUND"

ColourText(1) = "COLOR_APPWORKSPACE"

ColourText(2) = "COLOR_WINDOW"

ColourText(3) = "COLOR_WINDOWTEXT"

ColourText(4) = "COLOR_MENU"

ColourText(5) = "COLOR_MENUTEXT"

ColourText(6) = "COLOR_ACTIVECAPTION"

ColourText(7) = "COLOR_INACTIVECAPTION"

ColourText(8) = "COLOR_CAPTIONTEXT"

ColourText(9) = "COLOR_HIGHLIGHT"

ColourText(10) = "COLOR_INACTIVECAPTIONTEXT"

ColourText(11) = "COLOR_ACTIVEBORDER"

ColourText(12) = "COLOR_INACTIVEBORDER"

ColourText(13) = "COLOR_WINDOWFRAME"

ColourText(14) = "COLOR_SCROLLBAR"

ColourText(15) = "COLOR_BTNFACE"

ColourText(16) = "COLOR_BTNSHADOW"

ColourText(17) = "COLOR_HIGHLIGHTTEXT"

ColourText(18) = "COLOR_BTNTEXT"

ColourText(19) = "COLOR_BTNHILIGHT"

ColourText(20) = "COLOR_GRAYTEXT"

End Sub

Sub Init_IndexArray ()

'   //Last edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

'   //This routine is called from other routines//

'   //See - Sub ReMapIndexArrayToControlPanel() //

Dim i_Count As Integer

For i_Count = 0 To 20

'   //Initialise reference array//

    IndexArray(i_Count) = i_Count

Next i_Count

End Sub

Sub Init_RGBArray ()

'   //Last edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

'   //This routine is called by other routines//

'   //**Note the variable RGBARRAY_SET_OK //

'   //It sets RGBArray - essential before SetSysColour!//

'   //It can also sets IndexArray - this is necessary for other routines//

If IndexArray(1) <> 1 Then Init_IndexArray

Dim i_Count As Integer

For i_Count = 0 To 20

'   //Get the User's System Colour values//

    RGBArray(i_Count) = GetSysColor(i_Count)

Next i_Count

RGBARRAY_SET_OK = True

End Sub

Function IsHexDigit (Char As String) As Integer

'   //Last edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

IsHexDigit = False'   //Assume guilt, look for innocence//

If Char = "" Then Exit Function'  //Failed Test//

Dim Digits As String

Digits = "0123456789ABCDEF"

Char = UCase$(Left$(Char, 1))

If InStr(Digits, Char) <> 0 Then IsHexDigit = True

End Function

Function IsWin31 () As Integer

'   //Last Edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

'   //The SYSCOLOR functions all assume a 21-Colour scheme//

'   //Windows 3.0 only has 19 colours//

IsWin31 = False

'   //First, a quick & Dirty test for Windows V3.1//

If GetVer() = 101976579 Then

    IsWin31 = True

    Exit Function

End If

'   //Now check properly...//

Dim check As Long

Dim major As String

Dim minor As String

Dim winver As String

Dim M As String

'   {Check that the user is running Windows V3.1 or above}

check& = GetVer()

major$ = Format$(check& And &HFF)

minor$ = Format$((check& And &HF00) / 256)

winver$ = major$ + "." + minor$

If Val(winver$) >= 3.1 Then IsWin31 = True

End Function

Sub ReMapIndexArray2ControlPanel ()

'   //Last edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

'   //INPUT: IndexArray in Value order//

'   //ie IndexArray(0)=0

'   //   IndexArray(1)=1

'   //OUTPUT: IndexArray according to CONTROL.INI//

'   //ie IndexArray(0)=1

'   //IndexArray(1)=12

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

'   //This is the order the CONTROL.INI entries are stored in//

IndexArray(0) = COLOR_BACKGROUND

IndexArray(1) = COLOR_APPWORKSPACE

IndexArray(2) = COLOR_WINDOW

IndexArray(3) = COLOR_WINDOWTEXT

IndexArray(4) = COLOR_MENU

IndexArray(5) = COLOR_MENUTEXT

IndexArray(6) = COLOR_ACTIVECAPTION

IndexArray(7) = COLOR_INACTIVECAPTION

IndexArray(8) = COLOR_CAPTIONTEXT

IndexArray(9) = COLOR_ACTIVEBORDER

IndexArray(10) = COLOR_INACTIVEBORDER

IndexArray(11) = COLOR_WINDOWFRAME

IndexArray(12) = COLOR_SCROLLBAR

IndexArray(13) = COLOR_BTNFACE

IndexArray(14) = COLOR_BTNSHADOW

IndexArray(15) = COLOR_BTNTEXT

IndexArray(16) = COLOR_GRAYTEXT

IndexArray(17) = COLOR_HIGHLIGHT

IndexArray(18) = COLOR_HIGHLIGHTTEXT

IndexArray(19) = COLOR_INACTIVECAPTIONTEXT

IndexArray(20) = COLOR_BTNHILIGHT

End Sub

Sub RestoreSysColours ()

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //Restores system colours to that saved by SaveSysColours

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

'   //Test if OldRGBArray is valid//

If COLOURS_SAVED_OK = False Then SaveSysColours

'    //Sets OldRGBArray and IndexArray//

Dim i_Count As Integer

'   //Pump values into the array//

For i_Count = 0 To 20

'   //Change the appropriate element in the array//

    RGBArray(i_Count) = OldRGBArray(i_Count)

Next i_Count

'   //Do the deed//

NumChanges = 21'    //Change all the colours in 1 go//

SetSysColors NumChanges, IndexArray(0), RGBArray(0)

End Sub

Sub SaveSysColours ()

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //This routine stores the User's System Colours//

'   //Call it to take a snapshot (to be restored by RestoreSysColours) //

'   //**Sets RGBArray and OldRGBArray//

'   //**Note the Variables COLOURS_SAVED_OK and RGBARRAY_SET_OK

//

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

If IndexArray(1) <> 1 Then Init_IndexArray

Dim i_Count As Integer

For i_Count = 0 To 20

'   //Get a User's System Colour value//

    OldRGBArray(i_Count) = GetSysColor(i_Count)

'   //Copy to the working set//

    RGBArray(i_Count) = OldRGBArray(i_Count)

Next i_Count

COLOURS_SAVED_OK = True

RGBARRAY_SET_OK = True

End Sub

Sub SetColourSchemeFromControlPanel (SchemeString As String)

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //Sets the System Colours from a CONTROL PANEL saved Scheme

setting//

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

If SchemeString = "" Then Exit Sub'  //Failed Test//

'   //Test if RGBArray contains valid entries//

If RGBARRAY_SET_OK = False Then Init_RGBArray'   //Also sets

IndexArray//

Dim IniPath As String

Dim USERWINDIR As String

'   //Get INI path//

USERWINDIR = GetWINDIR()

If Right$(USERWINDIR, 1) <> "\" Then USERWINDIR = USERWINDIR & "\"

IniPath = USERWINDIR & "CONTROL.INI"

On Error GoTo EH_SCSCP

If Dir$(IniPath) = "" Then Exit Sub'  //Failed Test//

'   //Set up vars for DLL call//

Dim INIEntry As String

Dim i_RetVal As Integer

Dim sz_Bad As String

sz_Bad = "unknown"

Dim sz_Buf As String * 255

Dim i_SizeOfBuf As Integer

i_SizeOfBuf = 255

'   //Fetch the CSV string containing the 20 Hex numbers//

i_RetVal = ReadFromINI("color schemes", SchemeString, sz_Bad, sz_Buf,

i_SizeOfBuf, IniPath)

'   //Test for bad return value//

If i_RetVal = 0 Then Exit Sub'  //Failed Test//

INIEntry = Left$(sz_Buf, i_RetVal)

If INIEntry = "unknown" Then Exit Sub'  //Failed Test//

'   //Check that there are 20 values (19 commas) in the string//

Dim i_Count As Integer

Dim AString As String

Dim pos As Integer

pos = 0

AString = INIEntry

For i_Count = 1 To 19

    pos = InStr(AString, ",")

    If pos = 0 Then Exit Sub'  //Failed Test//

    AString = Mid$(AString, pos + 1)

Next i_Count

'   //Fetch each value, and assign it to RGBArray//

Dim HexString As String

pos = 0

AString = INIEntry

For i_Count = 0 To 19

    pos = InStr(AString, ",")

    HexString = Left$(AString, pos - 1)

    AString = Mid$(AString, pos + 1)

    RGBArray(i_Count) = Hex2RGB(HexString)

Next i_Count

'   //Fetch 20th Value//

RGBArray(20) = Hex2RGB(AString)

'   //Re-order IndexArray to point to the CONTOL.INI order//

ReMapIndexArray2ControlPanel

'   //Do the deed//

NumChanges = 21'    //Change all the colours in 1 go//

SetSysColors NumChanges, IndexArray(0), RGBArray(0)

'   //Come here on error//

EH_SCSCP:

'   //Reset to ordinal values//

Init_IndexArray

End Sub

Sub SetDefaultColourSchemeFromControlPanel ()

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //Sets the System Colours from CONTROL.INI setting//

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

'   //Test if RGBArray contains valid entries//

If RGBARRAY_SET_OK = False Then Init_RGBArray'   //Also sets

IndexArray//

'   //Get Users CONTROL.INI Path//

Dim IniPath As String

Dim USERWINDIR As String

USERWINDIR = GetWINDIR()

If Right$(USERWINDIR, 1) <> "\" Then USERWINDIR = USERWINDIR & "\"

IniPath = USERWINDIR & "CONTROL.INI"

On Error GoTo EH_SDCSFCP

If Dir$(IniPath) = "" Then Exit Sub'  //Failed Test//

'   //Setup DLL ReadFromINI call//

Dim i_RetVal As Integer

Dim sz_Bad As String

sz_Bad = "unknown"

Dim sz_Buf As String * 255

Dim i_SizeOfBuf As Integer

i_SizeOfBuf = 255

'   //Fetch the current System Colour name//

Dim DefaultKey As String

i_RetVal = ReadFromINI("current", "color schemes", sz_Bad, sz_Buf,

i_SizeOfBuf, IniPath)

'   //Test for valid return value//

If i_RetVal = 0 Then Exit Sub'  //Failed Test//

DefaultKey = Left$(sz_Buf, i_RetVal)

If DefaultKey = "unknown" Then Exit Sub'  //Failed Test//

'   //Fetch the CSV string containing the 20 Hex numbers//

i_RetVal = ReadFromINI("color schemes", DefaultKey, sz_Bad, sz_Buf,

i_SizeOfBuf, IniPath)

'   //Test for valid return value//

If i_RetVal = 0 Then Exit Sub'  //Failed Test//

Dim INIEntry As String

INIEntry = Left$(sz_Buf, i_RetVal)

If INIEntry = "unknown" Then Exit Sub'  //Failed Test//

'   //Check that there are 20 values (19 commas) in the string//

Dim i_Count As Integer

Dim AString As String

Dim pos As Integer

pos = 0

AString = INIEntry

For i_Count = 1 To 19

    pos = InStr(AString, ",")

    If pos = 0 Then Exit Sub'   //Failed Test//

    AString = Mid$(AString, pos + 1)

Next i_Count

'   //Fetch each value, and assign it to RGBArray//

'   //** Note - Hex2RGB decodes the BBGGRR hex$ used by MS //

Dim HexString As String

pos = 0

AString = INIEntry

For i_Count = 0 To 19

    pos = InStr(AString, ",")

    HexString = Left$(AString, pos - 1)

    AString = Mid$(AString, pos + 1)

    RGBArray(i_Count) = Hex2RGB(HexString)

Next i_Count

'   //Fetch 20th Value//

RGBArray(20) = Hex2RGB(AString)

'   //Re-order IndexArray to point to the CONTROL.INI order//

ReMapIndexArray2ControlPanel

'   //Do the deed//

NumChanges = 21'    //Change all the colours in 1 go//

SetSysColors NumChanges, IndexArray(0), RGBArray(0)

'   //Come here if there's an error//

EH_SDCSFCP:

'   //Reset to ordinal values//

Init_IndexArray

End Sub

Sub SetSysColour (Element As Integer, RGBValue As Long)

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //Element is one of the COLOR_ constants in the

'   //Declarations() section of this module//

'   //RGBValue can be RGB(x,y,z) or OPTCOLOR(colour) or QBColor(x)//

'   //**Note -You may want to call SaveSysColours first so that you can use

'   //the routine RestoreSysColours to return the User to normal, later//

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

'   //Test if RGBArray contains valid entries//

If RGBARRAY_SET_OK = False Then Init_RGBArray'   //Also sets

IndexArray//

'   //Change the appropriate element in the array//

RGBArray(Element) = RGBValue

NumChanges = 21'    //Change all the colours in 1 go//

'   //Do the deed//

SetSysColors NumChanges, IndexArray(0), RGBArray(0)

'   //NB The changed colour will persist in subsequent calls

'   //to this routine until RestoreSysColours() is called//

End Sub

Sub TellBadNews ()

'   //Last Edited 02/07/94 [GB] //

'   //+++PRIVATE+++//

Dim msg As String

Dim answer As Integer

answer = Beeper(16)'   //Issue an MCI Fatal Error sound//

msg = "You appear to be running Microsoft" & Chr$(10)

msg = msg & "Windows(tm) Version 3.0 or less. " & Chr$(10)

msg = msg & Chr$(10)

msg = msg & "SYSCOLOR functions are designed to support" & Chr$(10)

msg = msg & " only the 21-colour scheme of Windows 3.1." & Chr$(10)

msg = msg & Chr$(10)

msg = msg & "Would you like to Exit back to Windows now?"

answer = MsgBox(msg, 4096 + 48 + 4, "SYSCOLOR Fatal Error")

If answer = 6 Then End

End Sub

Sub WriteSysColoursToINI (SchemeString As String, IniPath As String)

'   //Last edited 02/07/94 [GB] //

'   //+++PUBLIC+++//

'   //This routine stores the User's 20 Windows System colours in

INIPathName//

'   //Nothing needs to be initialised first//

'   //** The routine GetColoursFromINI will fetch the settings into the

system//

'   //** Note - You may want to call SaveSysColours first so that you can use

'   //the routine RestoreSysColours to return the User to normal, later//

If IsWin31() = False Then

    TellBadNews'    //Windows 3.1 only//

    Exit Sub

End If

'   //Obvious checks, first//

If Dir$(IniPath) = "" Then Exit Sub

If SchemeString = "" Then Exit Sub

Dim i_Count As Integer

Dim RGBString As String

Dim NumString As String

Dim sz_BigString As String

'   //Save as per CONTROL.INI style//

ReMapIndexArray2ControlPanel

For i_Count = 0 To 19

'   //Get a User's System Colour value, and//

'   //Encode it into a Decimal string//

    RGBString = Hex$(GetSysColor(IndexArray(i_Count)))

    sz_BigString = sz_BigString & RGBString & ","

Next i_Count

'   //Last value not followed by a comma//

RGBString = Hex$(GetSysColor(IndexArray(20)))

sz_BigString = sz_BigString & RGBString

Dim Topic As String

Dim Keyname As String

Dim i_RetVal As Integer

Topic = "color schemes"

Keyname = SchemeString

'   //Write the new setting//

i_RetVal = WriteToINI(Topic, Keyname, sz_BigString, IniPath)

'   //Re-Map for Save/Restore//

Init_IndexArray

End Sub


System menu

LUOKKA: menus

9. How do you change the system menu (on the Control-Menu Box)?

   You can turn off the minimize and maximize menu options by changing

   properties, but what if you need to remove the "close" option?

     'Make the following declares.

     Declare Function GetSystemMenu Lib "User" (ByVal hWnd

     "As Integer, ByVal bRevert As Integer) As Integer

     Declare Function RemoveMenu Lib "User" (ByVal hMenu

     "As Integer, ByVal nPosition As Integer, ByVal wFlags As

     "Integer) As Integer

     Global Const MF_BYPOSITION=&H400

     'Use the following code to remove the "close" option.

     SystemMenu% = GetSystemMenu (hWnd, 0)

     Res% = RemoveMenu(SystemMenu%,6, MF_BYPOSITION)

     '(also remove the separator line)

     Res% = RemoveMenu(SystemMenu%,6, MF_BYPOSITION)

   Adding menu items to the control menu is more complicated, since

   you need to respond to the events triggered when the user selects

   the new options. The newest Message Blaster (msgblast.vbx, see

   details in beginning of FAQ about how to get files) contains

   example code.


System menu

LUOKKA: menus

Date: 10/23/94 (03:21)              Number: 24149 of 24188 (Refer# NONE)

From: BWILCOX@EXECPC.COM

Subj: Re: System menu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> I know how to add menus to my program but I want to change the

> system menu (or whatever the menu is called that you get from the top

> left corner button in windows aps.)  I have seen programs with custom

> menus here but I am not sure if it can be done in visual basic.

You use Windows API to modify the system menu (get Appleman's book..see

the FAQ)

You need a 3rd party VBX to detect and respond to the menu clicks.

(MsgBlaster or SpyWorks)

Here is a snippet of code:

    hSysMenu% = GetSystemMenu(Me.hWnd, False)

    If Not Registered Then

        ok% = AppendMenu(hSysMenu%, mf_separator, 0, 0&)

        ok% = AppendMenu%(hSysMenu%, mf_string, IDM_REGISTER,

"Re&gister")

    End If

    ok% = AppendMenu(hSysMenu%, mf_separator, 0, 0&)

    ok% = AppendMenu%(hSysMenu%, mf_string, IDM_ABOUT, "&About...")

    ok% = AppendMenu(hSysMenu%, mf_separator, 0, 0&)

    ok% = AppendMenu%(hSysMenu%, mf_string, IDM_HELP, "&Help...")

    ' Set up message blaster to respond to desired events...

    MsgBlaster1.hWndTarget = hWnd

    MsgBlaster1.MsgList(0) = WM_SYSCOMMAND

--

Bob

bwilcox@execpc.com (Bob Wilcox)


System menu

LUOKKA: menus

Nic Gibson: "Re: Using a custom entry in the System Menu"

In article <39v1hp$gvg@acmey.gatech.edu>, gt7011c@prism.gatech.edu

(Alexander Gilman Carver) says:

>

>I have an application that I would like to leave minimized while it is running.

>I wanted to put some of its commands into the System Menu (control box).  I

>know how to do this with the API call to AppendMenu but I don't know how

to

>make my program respond when I click the menu item.  The menu is

>standard (except, of course, for my additions) and my menus are at the

>bottom.  I thought messaging would do the trick but my computer hangs up

>when I do the GetMessage API call.  Your input would be greatly

appreciated >by one who does not know much about the API calls.  I don't

have access to >Appleman's book nor to my VB books (I'm at school and the

books are in >Florida :( ).  If you could be very specific with your answers

(i.e. the code), it >would help so much more.

You will need a subclassing control of some sort. I would recommend that you

use MessageBlaster. It's Shareware, it's good and you can get it via ftp (I

think

it's usually msgblast.zip). This is code I use to put an "About..." option onto

the system menu in one of my apps. I recommend you read the section in the

API docs (win31wh.hlp) before you set the ID for the menu item (or items).

Briefly, don't use the bottom four bits of the ID (so don't give your menus IDs

like 1 or 2, use numbers divisible by 16). I've pulled out the constants from

my

Declarations section here as well.

' Append menu flags.

Global Const MF_SEPARATOR = &H800

Global Const MF_STRING = &H0

' New menu item IDs.

Global Const ID_ABOUTSEP = &H70

Global Const ID_ABOUTMENU = &H80

' Message we want.

Global Const WM_SYSCOMMAND = &H112

'   Routine to append the "About..." line to the system

'   menu for the main form.

Sub InsertAbout (frmForm As Form)

    Dim hWndForm As Integer

    Dim hSysMenu As Integer

    Dim bDummy As Integer

    ' Use the window handle to get the system menu

    ' handle (giving up if we fail).

    hSysMenu = 0

    hWndForm = frmForm.hWnd

    hSysMenu = GetSystemMenu(hWndForm, 0)

    If hSysMenu <> 0 Then

        ' Add the "About..." string and the separator.

        bDummy = AppendMenu(hSysMenu, MF_SEPARATOR, ID_ABOUTSEP,

0&)

        bDummy = AppendMenu(hSysMenu, MF_STRING, ID_ABOUTMENU,

           "&About...")

    End If

End Sub

Sub MsgBlaster1_Message (MsgVaL As Integer, wParam As Integer, lParam

As Long, ReturnVal As Long)

    ' Check for the WM_SYSCOMMAND for the

    ' about box.

    If MsgVaL = WM_SYSCOMMAND Then

' Check for the about menu id

        If (wParam And &HFFF0) = ID_ABOUTMENU Then

    ' Do the about box.

            Form_ParentCentre frmAdmin, frmAbout

            frmAbout.Show MODAL

        End If

    End If

End Sub

I have the MessageBlaster set up to postprocess the message. You *should*

eat those WM_SYSCOMMAND messages that refer to your own identifiers

but I haven't found a way to do this selectively with the MessageBlaster

control. This hasn't caused any problems yet. By the way, in the past I

have had great difficulty getting modifications to the system menu to

work consistantly when using some add-in shells for Windows that also

modify the system menu (especially the Norton Desktop).


System menu acc.

LUOKKA: VBgen

Date: 10/22/94 (21:48)              Number: 24102 of 24188 (Refer# NONE)

From: TAYLOR@SATURN.BROOKS.AF.MIL, William D. Taylor

Subj: Re: System menu

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I know how to add menus to my program but I want to change the

>system menu (or whatever the menu is called that you get from the top

>left corner button in windows aps.)  I have seen programs with custom

>menus here but I am not sure if it can be done in visual basic.

It's pretty easy (and free) using MSGBLAST.ZIP (available on

ftp.microsoft.com) and the menu API calls.  The following example adds an

"About..." system menu item.

Const WM_SYSCOMMAND = &H112

Const MF_STRING = &H0

Const MF_SEPARATOR = &H800

Const IDM_ABOUT = 100

Declare Function GetSystemMenu Lib "User" (ByVal hWnd As Integer, ByVal

  bRevert As Integer) As Integer

Declare Function AppendMenu Lib "User" (ByVal hMenu As Integer, ByVal

wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As Any)

As Integer

Sub Form_Load ()

    Dim i As Integer

    Dim hMenu As Integer

    Dim strMenu As String

    'Add to system menu

    hMenu = GetSystemMenu(Me.hWnd, 0)

    strMenu = "&About..." & Chr$(0)

    i = AppendMenu(hMenu, MF_SEPARATOR, 0, "")

    i = AppendMenu(hMenu, MF_STRING, IDM_ABOUT, strMenu)

    'Subclass window messages

    MsgBlaster1.hWndTarget = Me.hWnd

    MsgBlaster1.MsgList(0) = WM_SYSCOMMAND

End Sub

Sub MsgBlaster1_Message (MsgVal As Integer, wParam As Integer, lParam

As Long, ReturnVal As Long)

    Select Case wParam

    Case IDM_ABOUT

        frmAbout.Show

        ReturnVal = 0

    End Select

End Sub

-WDT


System menu add

LUOKKA: VBgen

Päivä: 10-08-94 (17:23)             Numero: 2449 / 2471 (Vast. nro EI OLE)

Knltä: PETRI SUVILA

 Aihe: Ongelma Visual Basicin kanssa

 Kok.: Ohjelmointi (23)           Lukumalli: Yleinen (A) (+)

Kuinka pystyy saamaan Visul Basicillä controlboxii (eli siihen ikkunan

vasemmassa yläkulmassa olevaan laatikkoon) lisää vaihtoehtoja.

Olen itse selvitäänyt mitä komentoja siihen tarvitaan, mutta nyt en

tiedä kuinka jonkun napin tai proceduurin paikan saa tietoon.

Tässä on esimerkki VB 3.0 mukana tuleesta Windows 3.1 3.1 SDK:

- cut start

BOOL AppendMenu(hmenu, fuFlags, idNewItem, lpNewItem)

HMENU hmenu;    /* handle of menu       */

UINT fuFlags;   /* menu-item flags      */

UINT idNewItem; /* menu-item identifier */

LPCSTR lpNewItem;       /* specifies menu-item content  */

Example

The following example appends the About item to the System menu:

HMENU hmenu;

hmenu = GetSystemMenu(hwnd, FALSE);

AppendMenu(hmenu, MF_SEPARATOR, 0, (LPSTR) NULL);

AppendMenu(hmenu, MF_STRING, IDM_ABOUT, "About...");

- cut end

Tässä sama komento Visual basic muodossa:

- cut start

Declare Function AppendMenu Lib "User" (ByVal hMenu As Integer, ByVal_

wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As Any)_

As Integer

- cut end

Tuosta pitäsi selvittää idNewItem, mikä se on ja kuinka sen saa Visual

Basicistä. Sen olen selvittänyt, että se on jonkin proceduurin luku

(pointeriko), jota kutsutaan kun se kohta valitaan.

Myös esimerkki, kuinka PopUp menuun saadaan lisää valikkoja käy.

- Petri

Päivä: 10-10-94 (15:53)             Numero: 2465 / 2471 (Vast. nro 2449)

Knlle: PETRI SUVILA

Knltä: SAMI PITKO

 Aihe: Ongelma Visual Basicin kanssa

 Kok.: Ohjelmointi (23)           Lukumalli: Yleinen (A) (+)

>Kuinka pystyy saamaan Visul Basicillä controlboxii (eli siihen ikkunan

>vasemmassa yläkulmassa olevaan laatikkoon) lisää vaihtoehtoja.

Vastataan ensin kysymykseen ja kritisoidaan sitten...

KOE1.BAS:

---

Option Explicit

Declare Function AppendMenu Lib "User" (ByVal hMenu As Integer, ByVal

  wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As Any)

  As Integer

Declare Function GetSystemMenu Lib "User" (ByVal hWnd As Integer,

ByVal bRevert As Integer) As Integer

---

KOE1.FRM

---

Sub Form_Load ()

    Dim hMenu As Integer

    Dim i As Integer

    hMenu = GetSystemMenu(form1.hWnd, False)

    i = AppendMenu(hMenu, 0, 0, "&About")

End Sub

---

Sitten kritisointi: Nyt kun tuo menuvalinta on lisätty, niin kuinka

siihen liitetään koodia? Tietääkseni ei mitenkään. (Tai ehkä tutkimalla

hiiren sijaintia ja näppäinten asentoa ja tulkitsemalla siitä, onko

valittu tuo menu... liian hankalaa).

Visual Basic tarjoaa oman Menu Design -järjestelmän, jonka avulla

menuvalintojen taakse voidaan myös liittää koodia. Sieltä kautta voidaan

myös tehdä PopUp-menuja. Control Boxin käsittely pitää jättää matalamman

tason kielille, kuten C:lle.

Visual Basicilla voi tehdä suhteellisen nopeasti koodia, kunhan ei halua

ylittää sen raja-aitoja...

Spitco


System menus

LUOKKA: VBgen

27861 (37+)  rcw@netcom.com  27.07.95  22:40

Robert Woodcock: "Re: adding new items to control box"

Kelly Dempski (kels@sashimi.wwa.com) composed eloquently:

>Try InsertMenu and its related APIs.

>By getting the handle to the menu, you can add or remove items using these

>APIs.

Umm, that's AppendMenu, but anyway, you'll never get a Menu_Click event

without a subclassing control. You'll need something like MSGBLAST.VBX

or SpyWorks. Otherwise VB just tosses the message into the bit bucket.

Assuming you have MSGBLAST.VBX, you can use this code:

'put this in the general declarations section of your form.

Const WM_SYSCOMMAND = &H112

Const IDM_ABOUT = 100  'your choice (add more if needed)

Const mf_separator = &H800

Const mf_string = &H0

Declare Function GetSystemMenu% Lib "User" (ByVal hWnd%, ByVal

bRevert%)

Declare Function AppendMenu% Lib "User" (ByVal hMenu%, ByVal wFlags%,

ByVal wIDNewItem%, ByVal lpNewItem As Any)

'put this in form_load.

hSysMenu% = GetSystemMenu(Form1.hWnd, False)

'ok% = AppendMenu(hSysMenu%, mf_separator, 0, 0&)

ok% = AppendMenu%(hSysMenu%, mf_string, IDM_ABOUT, "&About...")

' Set up message blaster to respond to desired events...

MsgBlaster1.hWndTarget = hWnd

MsgBlaster1.MsgList(0) = WM_SYSCOMMAND

'put this in the MsgBlaster1_Message event:

If MsgVal = WM_SYSCOMMAND Then

   If wParam = IDM_ABOUT Then

      MsgBox "Information About your program", 0, "About Your Program..."

   End If

End If

--

Robert Woodcock

rcw@netcom.com


System rerources

LUOKKA: VBgen

28052 (130+)  ullrich@math.okstate.edu  28.07.95  21:18

David Ullrich: "Re: System resources?"

If there's no built-in VB function you can use the API

GetFreeSystemResources(which%). You use which=1 for GDI, which=2 for

USER, and which=0 for the minimum of the two (the number usually displayed

as "free resources".)

--

David Ullrich


System resources

LUOKKA: VBgen

28081 (103+)  rcw@netcom.com  28.07.95  20:54

Robert Woodcock: "Re: System resources?"

Tommi Ylikulju (tylikul@ratol.ratol.fi) composed eloquently:

>Is it possible to get the amount of the system resources left in Windows

>using Visual Basic?

Yes.

Declare Function GetFreeSystemResources% Lib "User" (ByVal

fuSysResource%)

Const GFSR_SYSTEMRESOURCES = 0

Const GFSR_GDIRESOURCES = 1

Const GFSR_USERRESOURCES = 2

Just pass the flag of your choice (Systemresources returns the lower of

the two) and the result will be the return value.

--

_________________________________________________________

Robert Woodcock ö Note: Your standard disclaimers apply. ö

rcw@netcom.com  ö I never forget a face (In some cases   ö

................ö it can be quite a curse) - Plucky Duck ö


System resources

LUOKKA: VBgen

9.3.7.  Running out of system resources in Visual Basic

-------------------------------------------------------

  Visual Basic is limited to 255 controls per form, but the real limit

  depends on Windows system resources, which in turn depends on what kind

  of controls they are and what else you have going on in your system at the

  time.  Here's a simplified explanation:

  Windows does indeed give you access to many megabytes of memory (16Mb

  in Windows 3.0, 256Mb in 3.1).  However, some of that memory is "special"

  because Windows reserves several 64K segments for its own purposes.

  The most significant of these segments for this discussion are the USER

  heap and the GDI heap.  This is where Windows keeps track of many of its

  internal data structures -- things like window handles, menus, (USER) and

  handles to bitmap, clipping regions, and fonts (GDI).  (Note that these are

  handles and related data structures, not the actual menus, bitmaps, or

  fonts themselves) Collectively, these two  segments are called "Windows

resources" and whichever one of the two that is closest to being exhausted

is reported as a percentage  (of 64K) in the Help / About dialog in Program

Manager.

  It should make sense then that as you approach 0% free in one of these two

  segments "strange things begin to happen" because Windows can't

allocate space for new Windows or bitmaps or whatever.

  It is unfortunate that there is this 64K limitation: it arises because of

  Windows' roots in real mode.  Future versions (both NT and perhaps a

future version of Windows for MS-DOS) will eliminate this.  Windows 3.1 was

an improvement over 3.0 because it split   the single USER heap into several

64K heaps.

  Now, getting back to Visual Basic: every form is a window.  Every control

  is a window.  Every window consumes some of the USER heap (some more

 than others).  Every bitmap consumes some of the GDI heap; every picture

box or form for which you've set AutoRedraw = True also consumes

additional space in the GDI heap.  I'm sure you can see where this is leading:

eventually, as you add controls, you run out of system resources.  The

number at which you run out depends on what the controls are (picture

controls chew up resources faster than labels), how many other forms and

controls are currently loaded in your application, and how much of your

system   resources are being consumed by other applications you may be

running at that time.

  How to work around this?  Only load the forms you need.  Unloaded forms

  (and the controls on them) don't use system resources.  Try to reduce the

  number of picture boxes.  Don't set AutoRedraw to True. If you're trying to

  display a lot of bitmaps or a grid of data, consider using a custom control

  designed to do that.  The grid control included in the Professional Toolkit

  allows you to display lots of information without using up the system

  resources you would if you placed it all in text boxes or labels.

  If you are running Windows 3.1 (and you really should be) you can call this

  function:

       Declare Function GetFreeSystemResources Lib "User" (ByVal

                        fuSysResource As Integer) As Integer

       Global Const GFSR_SYSTEMRESOURCES = &H0

       Global Const GFSR_GDIRESOURCES = &H1

       Global Const GFSR_USERRESOURCES = &H2

  This returns the percentage of free system resources For example:

       Print GetFreeSystemResources(GFSR_SYSTEMRESOURCES)

  This displays the lower of the GDI or USER heaps (this is exactly what is

  displayed in those about boxes).  If you want to find out how much space is

  left in USER, use  GFSR_USERRESOURCES; if you want to find out how

 much is left in GDI, use GFSR_GDIRESOURCES.  Using this function, you

can determine whether you're actually

  exhausting USER (probably) or GDI (less likely, unless you have a lot of

  bitmaps).

  Thanks for the explanation to Joe Robison (joero@microsoft.com).


Tab key

LUOKKA: VBgen

7. How do I get the Tab key to be treated like a normal character?

   You must set TabStop = False for ALL controls on the active form.

   Then you will be able to insert "tab" (chr 9) characters in

   controls like the text box.

   If you feel you need the Tab key to behave "normal" (ie. jump to

   next control) outside this specific control, it is trivial to

   emulate its functionality in code:

     Sub Command1_KeyDown (KeyCode As Integer, Shift As Integer)

       If KeyCode = 9 Then

         If Shift = 0 Then

            Command2.SetFocus 'Tab=Next control

         ElseIf Shift = 1 Then

            Command3.SetFocus 'Shift-Tab=Prev.ctrl.

         End If

       End If

     End Sub

   ...etc.


Tab key trap

LUOKKA: TextBox

Date: 08/12/94 (03:13)              Number: 15262 of 15271 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: TAB in a Text Box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 10 Aug 1994 10:33:43 GMT Eoin Bairead <ebairead@login.ieunet.ie>

wrote:

> How can I trap the TAB key when it's pressed in a text box?

Put the following code in the LostFocus event:

Sub Text1_LostFocus ()

    If TabPressed() Then

        Text1.SetFocus

    End If

End Sub

Put the code below in your form or in a module:

Declare Function GetKeyState Lib "user" (ByVal nVirtKey As Integer) As

Integer

Const VK_TAB = &H9

Function TabPressed () As Integer

    TabPressed  = ((GetKeyState(VK_TAB) And &HF0) = 128)

End Sub

Arjen


Tab stops

LUOKKA: ListBox

Date: 06/03/94 (11:48)              Number: 7903 of 7971 (Refer# NONE)

From: FARSHADV@TELEPORT.COM

Subj: Re: Tab widths in a list box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Tru the following :

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer,

                                         ByVal wMsg As Imteger,

                                         ByVal wp As Integer,

                                         lp As Any) As Long

Sub SetTabSpace()

Dim RetVal As Long

Static Tabs(1 to 3) As Integer

  Tabs(1)=50                    ' Location of 1st tab

  Tabs(2)=100                   ' Location of 2nd tab

  Tabs(3)=150                   ' Location od 3rd tab

  RetVal=SendMessage(List1.hWnd, (&H400 + 19), 3, Tabs(1))

End Sub

--

farshadv@teleport.COM  Public Access User --- Not affiliated with

TECHbooks

Public Access UNIX and Internet at (503) 220-1016 (2400-14400, N81)


Tab stops

LUOKKA: ListBox

Date: 06/05/94 (10:47)              Number: 8047 of 8074 (Refer# NONE)

From: EBBE@DBM.FI

Subj: Re: Tab widths in a list box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You will need to send your list box a LB_SETTABSTOPS message (using the

API call 'SendMessage'. In order to do this, you will need to define

a static array of integers, where each array is the offset of one tab

stop (in dialog base units). This array needs to be passed as the lParam

to SendMessage, and an integer denoting the number of tabstops to be set

needs to be passed as the wParam.

Like so:

' API declarations (note the line continuation character ' ' in

' the function declarations

Global Const WM_USER = &H400

Global Const LB_SETTABSTOPS = (WM_USER + 19)

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer,

      ByVal wMsg As Integer,

      ByVal wParam As Integer,

      lParam As Any) As Long

' Sample call. Assumes a list box control named <lstList>, and a

' tab stop setting of 200,300, and 400 dialog box units

dim i as integer

static TabStops(3) as integer

i=SendMessage(lstList.hWnd,LB_SETTABSTOPS,3,TabStops(1))

Please note that you'll need to do some math to figure out the tab

stops values, since they are in dialog base units, not in twips.

--

Ebbe Jonsson, Systems Mangler                            ebbe@dbm.fi

DBM Database Marketing Oy, Helsinki, FINLAND

Tel: +358 0 605 900, Fax: +358 0 605 991


Tab stops

LUOKKA: ListBox

Date: 06/20/94 (10:35)              Number: 9602 of 9631 (Refer# NONE)

From: RAMI.RASANEN@F73.N369.Z1.FIDONET.ORG

Subj: Help: Tab in ListBox  1/6

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

 Here's an example, can't recall the original author.

'------------------TABTEST.MAK---------------------

TABTEST.BAS

TABTEST.FRM

FRMHELP2.FRM

ProjWinSize=238,612,327,186

ProjWinShow=2

IconForm="TabTest"

'------------------TABTEST.BAS---------------------

'General Declarations

Option Explicit

Global mtab$, maxTabs%, sp$, msg$, AllowHelp%, IsAligned%

Global tabs() As Integer

Type JedsData

  jName       As String * 20

  jNo         As String * 8

  jJob        As String * 22

  jAddr       As String * 20

  jCity       As String * 15

  jState      As String * 2

  jPhone      As String * 8

  jFax        As String * 8

  jLastCall   As String * 9

End Type

Global Jed(1 To 5) As JedsData

'Constant values required for Windows 3.1 API routines

'to set tab stops in listboxes

Declare Function getfocus Lib "user" () As Integer

Declare Function Sendmessage Lib "user" (ByVal hWnd As Integer, ByVal

wMsg As I

'***next 2 lines go on 1 line***

Declare Function putfocus Lib "user" Alias "SetFocus" (ByVal hWnd As

Integer)

A

Global Const WM_USER = &H400

Global Const LB_SETTABSTOPS = WM_USER + 19

Global Const EM_SETTABSTOPS = WM_USER + 27

' Windows 3.1 API routines used only for minihelp windows

Global Const SW_SHOWNOACTIVATE = 4

Global Const GW_CHILD = 5         ' Needed for edit portion of combo box

Type POINTAPI       ' Stores location of cursor

  x As Integer

  y As Integer

End Type

Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)

Declare Function GetActiveWindow Lib "User" () As Integer

'***next 2 lines go on 1 line***

Declare Function WindowFromPoint Lib "user" (ByVal lpPointY As Integer,

ByVal

l

'***next 2 lines go on 1 line***

Declare Function GetWindow Lib "User" (ByVal hWnd As Integer, ByVal

wCmd As

Int

'***next 2 lines go on 1 line***

Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal

nCmdShow

A

Sub AddOneMoreItem ()

Dim b$

'add to list1 - spaces

b$ = Trim$(Jed(5).jName) & sp$ & Trim$(Jed(5).jNo) & sp$

b$ = b$ & Trim$(Jed(5).jJob) & sp$ & Trim$(Jed(5).jAddr) & sp$

b$ = b$ & Trim$(Jed(5).jCity) & sp$ & Trim$(Jed(5).jState) & sp$

b$ = b$ & Trim$(Jed(5).jPhone) & sp$ & Trim$(Jed(5).jFax) & sp$

b$ = b$ & Trim$(Jed(5).jLastCall)

TabTest!List1.AddItem b$

'add to list2 - tabs

b$ = ""

b$ = Trim$(Jed(5).jName) & mtab$ & Trim$(Jed(5).jNo) & mtab$

b$ = b$ & Trim$(Jed(5).jJob) & mtab$ & Trim$(Jed(5).jAddr) & mtab$

b$ = b$ & Trim$(Jed(5).jCity) & mtab$ & Trim$(Jed(5).jState) & mtab$

b$ = b$ & Trim$(Jed(5).jPhone) & mtab$ & Trim$(Jed(5).jFax) & mtab$

b$ = b$ & Trim$(Jed(5).jLastCall)

TabTest!List2.AddItem b$

Dim a$

a$ = "Item 4 (Malone, Sam) added. The column alignment"

a$ = a$ & " was  maintained without further API calls."

TabTest!Label1(1).Caption = a$

TabTest!cmd(2).Enabled = False

End Sub

Sub DisplayHelp (Help$)

      Dim lpPoint As POINTAPI ' Cursor Point variable

      Dim ret As Integer      ' Return value of ShowWindow() API function

      Rem Display Help String

      Rem This Function displays the Help$ if Help$ <> "".

      Rem if Help$ = "" then the Help String is removed.

      Rem FUNCTION REQUIREMENTS:

      Rem     GetCursorPos()    Windows API function

      Rem     frmHelp           Name of the Help form

      If Len(Help$) <> 0 Then  ' Double check help$

         ' Make sure help form is invisible:

         frmHelp.Hide

         ' Change caption of label:

         frmHelp.Label1.Caption = "  " + Help$ + "  "

         ' Get the cursor position so you can calculate where to place the

         ' help form:

         Call GetCursorPos(lpPoint)

         ' Offset the form from the cursor by 18 and 2 pixels (values

         ' chosen to simulate the look of Microsoft Word version 6.0)

         frmHelp.Top = (lpPoint.y + 18) * Screen.TwipsPerPixelY

         frmHelp.Left = (lpPoint.x - 2) * Screen.TwipsPerPixelY

         ' Adjust width of form to label + 4  because 2 are needed for each

         ' pixel of the border and 2 are needed to center the label (the

         ' label is inset by 1 pixel on the form). Also, adjust height of

         ' form to height of label + 2 because 2 ar needed for each pixel

         ' of the border:

         frmHelp.Width = frmHelp.Label1.Width + (4 * Screen.TwipsPerPixelX)

         frmHelp.Height = frmHelp.Label1.Height + 6 * Screen.TwipsPerPixelY

         ' Make sure form is on top:

         frmHelp.ZOrder

         ' Show form without the focus:

         ret = ShowWindow(frmHelp.hWnd, SW_SHOWNOACTIVATE)

      Else

         ' Hide the form:

         frmHelp.Hide

      End If

End Sub

Sub GetTheRighttabset (tabs%())

'Set the tab positions - this is the

'most time consuming part to build

Select Case TabTest!List2.FontBold

Case True           'jName is on the edge - no tab

  tabs%(1) = 66     'jNo

  tabs%(2) = 97     'jJob

  tabs%(3) = 178    'jAddr

  tabs%(4) = 250    'jCity

  tabs%(5) = 289    'jState

  tabs%(6) = 305    'jPhone

  tabs%(7) = 343    'jFax

  tabs%(8) = 382    'jLastCall

Case Else:  'must not be bold then

  tabs%(1) = 68     'jNo

  tabs%(2) = 100    'jJob

  tabs%(3) = 180    'jAddr

  tabs%(4) = 250    'jCity

  tabs%(5) = 290    'jState

  tabs%(6) = 308    'jPhone

  tabs%(7) = 345    'jFax

  tabs%(8) = 385    'jLastCall

End Select

End Sub

Sub main ()

mtab$ = Chr$(9)

sp$ = Space$(3)

SetJedsData

Load TabTest

SetLstBox1

SetLstBox2

TabTest!Label1(0).Caption = "This list shows items separated by 3 spaces."

TabTest!Label1(1).Caption = "List2 items are separated by tab. Press Align."

TabTest.Show

End Sub

Sub SetJedsData ()

  Jed(1).jName = "Smith, John"

  Jed(1).jNo = "33526"

  Jed(1).jJob = "TD Bank Manager"

  Jed(1).jAddr = "123 Mockingbird Ln"

  Jed(1).jCity = "Baltimore"

  Jed(1).jState = "OH"

  Jed(1).jPhone = "123-4567"

  Jed(1).jFax = "765-4321"

  Jed(1).jLastCall = "Dec 15/93"

  Jed(2).jName = "Johnson, Margaret"

  Jed(2).jNo = "5512"

  Jed(2).jJob = "Customer Service Rep"

  Jed(2).jAddr = "5 Amway Place"

  Jed(2).jCity = "Pyramid"

  Jed(2).jState = "OH"

  Jed(2).jPhone = "555-5545"

  Jed(2).jFax = "555-2323"

  Jed(2).jLastCall = "Jan 1/94"

  Jed(3).jName = "Birch, Randy"

  Jed(3).jNo = "12345"

  Jed(3).jJob = "Graphic Artist"

  Jed(3).jAddr = "81 Resources Rd"

  Jed(3).jCity = "Toronto"

  Jed(3).jState = "ON"

  Jed(3).jPhone = "555-9009"

  Jed(3).jFax = "555-9010"

  Jed(3).jLastCall = "Mar 13/94"

  Jed(4).jName = "Alley, Kirstie"

  Jed(4).jNo = "101010"

  Jed(4).jJob = "Actress, Looking Good"

  Jed(4).jAddr = "1234 Godiva Lane"

  Jed(4).jCity = "Hollywood"

  Jed(4).jState = "CA"

  Jed(4).jPhone = "000-5555"

  Jed(4).jFax = "000-6666"

  Jed(4).jLastCall = "Jan 5/94"

  Jed(5).jName = "Malone, Sam"

  Jed(5).jNo = "37"

  Jed(5).jJob = "Ex Pitcher/Barkeep"

  Jed(5).jAddr = "555 Cheers St"

  Jed(5).jCity = "Anytown"

  Jed(5).jState = "US"

  Jed(5).jPhone = "323-3345"

  Jed(5).jFax = "323-5332"

  Jed(5).jLastCall = "Nov 30/93"

End Sub

Sub SetListTabs ()

'set the no. of tabs required

'in this case, 8 (the first item is not tabbed)

'and DIM the tabs array to Maxtabs

maxTabs% = 8

ReDim tabs%(maxTabs%)

'get the tabset corresponding to the listbox FontBold

GetTheRighttabset tabs%()

'call the setTab API routine

Dim hOldWin%, lbhWnd%, retVal&, r%, limit%, a$

hOldWin% = getfocus()

limit% = UBound(tabs%) 'limit% = how many stops to set

TabTest!List2.Enabled = True  'make sure it won't crash

TabTest!List2.SetFocus

lbhWnd% = getfocus()

'the tabs%(1) at the end indicate the array only - always set to 1

retVal& = Sendmessage(lbhWnd%, LB_SETTABSTOPS, limit%, tabs%(1))

TabTest!List2.Refresh

r% = putfocus(hOldWin%)    'restore previous focus

Select Case TabTest!List2.FontBold

Case True:  a$ = "Sendmessage API call has aligned the tabbed items"

            a$ = a$ & " into columns based on the BOLD font-width"

            a$ = a$ & " tabs set in GetTheRighttabset (tabs%())"

Case Else:  a$ = "Sendmessage API call has aligned the tabbed items"

            a$ = a$ & " into columns based on the NORMAL font-width"

            a$ = a$ & " tabs set in GetTheRighttabset (tabs%())"

End Select

IsAligned% = True

TabTest!Label1(1).Caption = a$

TabTest!cmd(2).Enabled = TabTest!List2.ListCount <> 5

End Sub

Sub SetLstBox1 ()

Dim b$, x%

sp$ = Space$(3)

'this is broken down to allow code to fit on message line

For x% = 1 To 4

b$ = Trim$(Jed(x%).jName) & sp$ & Trim$(Jed(x%).jNo) & sp$

b$ = b$ & Trim$(Jed(x%).jJob) & sp$ & Trim$(Jed(x%).jAddr) & sp$

b$ = b$ & Trim$(Jed(x%).jCity) & sp$ & Trim$(Jed(x%).jState) & sp$

b$ = b$ & Trim$(Jed(x%).jPhone) & sp$ & Trim$(Jed(x%).jFax) & sp$

b$ = b$ & Trim$(Jed(x%).jLastCall)

TabTest!List1.AddItem b$

b$ = ""

Next x%

End Sub

Sub SetLstBox2 ()

Dim b$, x%

'this is broken down to allow code to fit on message line

For x% = 1 To 4

b$ = Trim$(Jed(x%).jName) & mtab$ & Trim$(Jed(x%).jNo) & mtab$

b$ = b$ & Trim$(Jed(x%).jJob) & mtab$ & Trim$(Jed(x%).jAddr) & mtab$

b$ = b$ & Trim$(Jed(x%).jCity) & mtab$ & Trim$(Jed(x%).jState) & mtab$

b$ = b$ & Trim$(Jed(x%).jPhone) & mtab$ & Trim$(Jed(x%).jFax) & mtab$

b$ = b$ & Trim$(Jed(x%).jLastCall)

TabTest!List2.AddItem b$

b$ = ""

Next x%

End Sub

'--------------- TABTEST.FRM ----------

VERSION 2.00

Begin Form TabTest

   Caption         =   "Text List"

   ClientHeight    =   5316

   ClientLeft      =   1368

   ClientTop       =   1788

   ClientWidth     =   11496

   Height          =   5712

   Left            =   1332

   LinkTopic       =   "Form1"

   ScaleHeight     =   5316

   ScaleWidth      =   11496

   Top             =   1428

   Width           =   11568

   Begin CommandButton cmd

      Caption         =   "Help off"

      Height          =   375

      Index           =   4

      Left            =   7080

      TabIndex        =   8

      Top             =   4680

      Width           =   1395

   End

   Begin Timer Timer1

      Left            =   10920

      Top             =   4200

   End

   Begin CommandButton cmd

      Caption         =   "Font Style"

      Height          =   375

      Index           =   3

      Left            =   4410

      TabIndex        =   7

      Top             =   4680

      Width           =   2055

   End

   Begin CommandButton cmd

      Caption         =   "Add"

      Height          =   375

      Index           =   2

      Left            =   2280

      TabIndex        =   6

      Top             =   4680

      Width           =   2055

   End

   Begin CommandButton cmd

      Caption         =   "Align"

      Height          =   375

      Index           =   1

      Left            =   120

      TabIndex        =   3

      Top             =   4680

      Width           =   2055

   End

   Begin ListBox List2

      FontBold        =   0   'False

      FontItalic      =   0   'False

      FontName        =   "MS Sans Serif"

      FontSize        =   7.8

      FontStrikethru  =   0   'False

      FontUnderline   =   0   'False

      Height          =   1785

      Left            =   120

      Sorted          =   -1  'True

      TabIndex        =   2

      Top             =   2310

      Width           =   11265

   End

   Begin ListBox List1

      FontBold        =   0   'False

      FontItalic      =   0   'False

      FontName        =   "MS Sans Serif"

      FontSize        =   7.8

      FontStrikethru  =   0   'False

      FontUnderline   =   0   'False

      Height          =   1785

      Left            =   120

      Sorted          =   -1  'True

      TabIndex        =   1

      Top             =   360

      Width           =   11265

   End

   Begin CommandButton cmd

      Caption         =   "End"

      Height          =   375

      Index           =   0

      Left            =   8670

      TabIndex        =   0

      Top             =   4680

      Width           =   1305

   End

   Begin Label Label1

      BackStyle       =   0  'Transparent

      Caption         =   "AlignList"

      Height          =   405

      Index           =   1

      Left            =   135

      TabIndex        =   5

      Top             =   4245

      Width           =   5745

   End

   Begin Label Label1

      AutoSize        =   -1  'True

      Caption         =   "SpaceList"

      Height          =   195

      Index           =   0

      Left            =   90

      TabIndex        =   4

      Top             =   90

      Width           =   855

   End

End

Option Explicit

Sub cmd_Click (Index As Integer)

Select Case Index%

Case 0: End

Case 1: SetListTabs

Case 2: AddOneMoreItem

Case 3: TabTest!List1.FontBold = Not TabTest!List1.FontBold

        TabTest!List2.FontBold = Not TabTest!List2.FontBold

Case 4: AllowHelp% = Not AllowHelp%

       If AllowHelp% Then cmd(4).Caption = "Help on" Else cmd(4).Caption =

"Hel

Case 5: frmHelp!Label1.WordWrap = Not frmHelp!Label1.WordWrap

Case Else:

End Select

    If AllowHelp% = False Then frmHelp.Hide

End Sub

Sub Form_Load ()

  Timer1.Interval = 100

  Timer1.Enabled = True

End Sub

Sub Timer1_Timer ()

  Dim curhWnd As Integer      'Current hWnd

  Dim p As POINTAPI

  Static LasthWnd As Integer  'Hold previous hWnd

' Make sure the program has the input focus:

If GetActiveWindow() = TabTest.hWnd And AllowHelp% Then

' Initialize point structure:

  Call GetCursorPos(p)

' Which window is the mouse cursor over?

  curhWnd = WindowFromPoint(p.y, p.x)

' Same as last window? If so, don't need to redraw:

  If curhWnd <> LasthWnd Then

    LasthWnd = curhWnd   ' Store the current hWnd:

    Timer1.Interval = 1  ' Decrease timer interval

    Select Case curhWnd  ' Which control is the cursor over?

      Case cmd(0).hWnd

         msg$ = "You'll never guess what this button does :)"

         DisplayHelp msg$

      Case cmd(1).hWnd

         msg$ = "The 'Align' button will align the tabstops"

         msg$ = msg$ & " according to the values set in"

         msg$ = msg$ & " GetTheRighttabset by calling SetListTabs."

         DisplayHelp msg$

      Case cmd(2).hWnd

         msg$ = "When enabled, this will add 1 more entry to"

         msg$ = msg$ & " the list (into position 4) maintaining"

         msg$ = msg$ & " the columns without further API calls."

         DisplayHelp msg$

      Case cmd(3).hWnd

         msg$ = "Use this to toggle between Bold and Normal fonts."

         msg$ = msg$ & " Because of increased letter widths, you may"

         msg$ = msg$ & " need to realign the colums using Align."

         DisplayHelp msg$

      Case cmd(4).hWnd

         msg$ = "Use this to toggle this help window on and off."

         msg$ = msg$ & " This code is contained in 3 routines;"

    msg$ = msg$ & " General Declarations, the Timer and DisplayHelp subs."

         DisplayHelp msg$

      Case List1.hWnd

         msg$ = "The list contains items separated by 3 spaces."

         msg$ = msg$ & " Nothing you could do would align this mess."

         DisplayHelp msg$

      Case List2.hWnd

        Select Case IsAligned%

          Case True:

             msg$ = "This list is now aligned into colums with a call"

             msg$ = msg$ & " to the SendMessage API.  Further entries"

             msg$ = msg$ & " to the list will maintain the columns. "

             msg$ = msg$ & " You can always reset the tab stops in code"

             msg$ = msg$ & " by assigning new values to the tabs%() array"

             msg$ = msg$ & " and calling SendMessage again (see the"

             msg$ = msg$ & " FontStlye button for more info.)"

         Case False:

             msg$ = "The list contains items separated by one tab stop."

             msg$ = msg$ & " Pressing Align will call SendMessage to"

             msg$ = msg$ & " align the columns."

        End Select

           DisplayHelp msg$

      Case frmHelp.hWnd ' If it moves onto the help window, hide it:

           frmHelp.Hide

      Case Else

' Cursor is over the form or something else, so change interval back to 1

'sec delay:

           DisplayHelp ""

           Timer1.Interval = 100

    End Select

  End If

End If

End Sub


Task killing

LUOKKA: VBgen

Date: 09/11/94 (02:17)              Number: 19004 of 19086 (Refer# NONE)

From: SHOWELL@CRL.COM

Subj: Re: Killing another Windows task from VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here is a exerpt from KB Q80186

1. Create a form called Form1.

2. Create two command buttons called Command1 and Command2.

3. Within the Command1 Click event, add the following code:

   Sub Command1_Click()

      X% = Shell("Calc.exe")

   End Sub

4. Within the Command2 Click event, add the following code:

   Sub Command2_Click()

      Const NILL = 0&

      Const WM_SYSCOMMAND = &H112

      Const SC_CLOSE = &HF060

      lpClassName$ = "SciCalc"

      lpCaption$ = "Calculator"

      '* Determine the handle to the Calculator window.

      Handle = FindWindow(lpClassName$, lpCaption$)

      '* Post a message to Calc to end it's existence.

      X& = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)

   End Sub

5. In the Declarations section, declare the following two API functions:

   ' Enter each of the following Declare statements on one, single line:

   Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any,

      ByVal lpCaption As Any)

   Declare Function SendMessage& Lib "user" (ByVal hwnd%, ByVal wMsg%,

      ByVal wParam%, ByVal lParam As Long)

6. Run the program. Click the Command1 button to bring up an instance of

    the Calculator program. Click the Command2 button to close the window.

To kill a process without an API do:

Sub KillProces ()

On Error GoTo ErrorHandler

    AppActivate "IRMAforWindows"  'Sample name that appears in the title

    SendKeys " enter ", True      'bar of the app you want to close.

    SendKeys "% f4 ", True        'this will close most windows apps alt-f4

    TxtDDEIncoming.LinkMode = 0

    End ErrorHandler:

    If (Err = 5) Then

        End

    End If

End Sub

showell@crl.com


Task list

LUOKKA: vbx

24238 (91+)  ian.carter@almac.co.uk  07.07.95  19:50

IAN CARTER: "Re: Applicatio  missing from"

In a previous message, mdh@sas.dk said:

MD>Sometimes the application is missing from the alt tab lsit but is

MD>still in the task list given by CTRL ESC.

Yes, If you close a VB application with the Close option of the Control

box, Windows closes that window, but doesn't terminate your application.

What you need to do is place an End statement in the

Form_Unload/Form_QueryUnload event of your main form.

Regards,  Email: ianc@retrac.nildram.co.uk

Ian C.    Compuserve: 100435,3040     FidoNet Netmail: (2:257/112)

          Tel/Fax: (+44)(0)1909-773689


Text search fuzzy

LUOKKA: VBgen

Date: 09/07/94 (12:10)              Number: 18530 of 18530 (Refer# NONE)

From: EMMETTH@NETCOM.COM

Subj: Re: FUZZY Text Search ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Article: 549 of comp.databases.theory

Subject: Re: SOUNDEX

Date: 21 Oct 92 16:58:07 GMT

Soundex is a method for coding words, mainly surnames in English, so that

names that sound alike have the same code.  (I assume the poster knew

this.)

I've heard the term "soundex" applied to several different coding methods,

which is like using "xerox" to refer to copiers from other companies.

According to Don Knuth in "Sorting and Searching - The Art of Computer

Programming - Vol 3", the Soundex mthod was originally developed by

Margaret Odell and Robert Russell and was patented  U.S. Patents 1261167

(1918), 1435663 (1922) .  Knuth describes the method as:

 1) Retain the first letter of the name.

    Drop all occurrences of A, E, H, I, O, U, W, and Y in other positions.

 2) Assign the following numbers to the remaining letters after the first:

    B, F, P, V -> 1                L -> 4

    C, G, J, K, Q, S, X, Z -> 2    M, N -> 5

    D, T -> 3                      R -> 6

 3) If two or more letter with the same code were adjacent in the original

    name, omit all but the first.

 4) Convert to the form "letter, digit, digit, digit" by adding trailing

    zeros or dropping rightmost digits.


Text search fuzzy

LUOKKA: VBgen

Date: 09/09/94 (21:50)              Number: 18903 of 18922 (Refer# NONE)

From: SLAGEL@UXA.CSO.UIUC.EDU

Subj: Re: FUZZY Text Search ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

   I did something like this a while back that worked great, but is

   not too speedy....

   Find all matching substrings between the two strings. For every

   matching substring add the length of that substring to the score.

   The string with the highest score is the closest.

   Or something to that effect... I actually used a subroutine that

   was in a book by Microsoft, I think, here it is in a really crappy

   format (my downloading isn't so good), but you should be able

   to make sense of it.  In basic.

   FUNCTION CompareStrings (x$, y$)

       score = 0

       x1$ = UCASE$(x$)

       y1$ = UCASE$(y$)

       lenx1 = LEN(x1$)

       FOR i = 1 TO lenx1

          FOR j = 1 TO lenx1 - i + 1

             t$ = MID$(x1$, j, i)

             IF INSTR(y1$, t$) THEN

                score = score + i + i

             END IF

          NEXT

       NEXT

       CompareStrings = score

   END FUNCTION


TextBox <--> label

LUOKKA: TextBox

Date: 07/18/94 (02:05)              Number: 12283 of 12384 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: MultiLine textbox questio

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

C>What I want is for the text which the user can edit to be

C>distinguished from the text which the user can't edit. When the form

C>Any suggestions as to how I can either make the MultiLine text gray

C>until I want to set the Enabled property?

Have you considered using label controls for those boxes which the user

will never be able to edit?  You can make a label control look just like

a textbox.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


TextBox > 32K

LUOKKA: TextBox

Date: 07/01/94 (11:10)              Number: 10965 of 11050 (Refer# NONE)

From: MAURICE1@DELPHI.COM

Subj: Re: How to handle text larger than 32K ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

     Once again, MS is a bit stingy with the information. Hidden away on page

41 of the Programmer's Guide - Bottom 2.1 lines.

     MaxLength lets you determine how many characters can be typed in the

textbox. After MaxLength is exceeded, the text box beeps and does not

accept any further characters.

     This property (Text.MaxLength) ties into the EM_LIMITTEXT edit control

message. Values can be from 0-65535 (0 defaults to 32k, 65535 is 64k).

There does seem to be some overhead however. I tried a couple files...

     63k would not go, but I got 50k in no problem.

     Hope this helps a bit, although I know it's not a solution, just buying

some time. I'll see if I can put together an exeptable work around.

-------------------------------------------------------------------------------

  Maurice1@delphi.com


TextBox > 32k

LUOKKA: TextBox

Date: 09/16/94 (10:33)              Number: 19537 of 19727 (Refer# NONE)

From: EXUIAN@EXU.ERICSSON.SE

Subj: Re: More than 32K in a textbox?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can use an API call to increase the size of your text box to 64K, but

since the text box is sharing a DS with VB, it will never give you 64K,

the best I have seen is 52K. Also, how this translates to lines is important,

since 52K is achieved with a lot of short lines, but if I used fewer longer

lines then the limit dropped to about 40K. The API is SendMessage with

EM_LIMITTEXT = 64K for your textbox hWnd - but this is a dead end unless

you are sure 40-52K is always going to be enough. Another option is to

create a virtual view space by using muliple text boxes - there is an example

of this on compuserve called VIRTXT or something close to that. It works,

but it is slow to load big files, and there is some flickering when one text is

box is being hidden and another one displayed. And this has to be read only !

The best solution is to use a VBX e.g. EMEDIT (shareware), ALLTEXT or

HIGHEDIT (commercial). EMEDIT is available in a demo form on CICA. For

the others, refer to the VBX list FAQ or the MSVB companion products guide

from microsoft.

/Ian


TextBox > 64k

LUOKKA: TextBox

22757 (87+)  dickdono@interramp.com  28.06.95  10:44

"Re: looking for text box > 64K shareware vbx's"

In article <3sqb7m$efq@er5.rutgers.edu>, <dlefgnal@er5.rutgers.edu> writes:

> hi, im looking for a shareware vbx or one at least that can

> be distributed royalty free that does text box handling...

> hopefully with multi colored text and stuff like that...

> im sure there are a few out there... anyone have recommendations

> and where to ftp them...?

> please email... thanks!

I know that there is some freeware VB basic code called "bigfoot.zip" that

handles reading big files (>64k).  Via WWW, you can get it from Gary

Beene's VB

Home Page (http://www.iadfw.net:80/gbeene/visual.html).  Hope this helps!

Dick Donohue

dickdono@interramp.com


TextBox align ignored

LUOKKA: TextBox

Date: 05/29/94 (23:21)              Number: 7327 of 7455 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Problems with VB3.0 text

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

<<***** On 29/5/94, Arndt Baer wrote to ALL: *****>>

AB>        1. the "alignment" property of text boxes doesn*t work.

AB>        Text in these boxes is always aligned left.

As it says in the manual under Alignment Property "If the Multi-Line

property of a text box is False, the alignment property is ignored"

Annoying, isn't it!


TextBox append 1

LUOKKA: TextBox

Date: 05/12/94 (11:22)              Number: 5579 of 5645 (Refer# NONE)

From: CZ_HOWER@DELPHI.COM

Subj: Re: Append to textbox without flashing?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Try this, add a timer control.

Sub tmrUpdate_Timer ()

    If text$ <> "" Then

        frmText!Text1 = Right$(frmText!Text1 + text$, 2048)

        waits$ = Right$(waits$ + text$, 512)

        frmText!Text1.SelStart = Len(frmText!Text1)

        text$ = ""

    End If

End Sub

The text$ is a global variable, to add text to the text box, now use

text$=text$+a$, where a$ is the new text.


TextBox append 2

LUOKKA: TextBox

Date: 05/12/94 (11:36)              Number: 5585 of 5645 (Refer# NONE)

From: MILLERA@MCS.COM

Subj: Re: Append to textbox without flashing?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If you're not (perhaps justifiably) afraid of API calls, you may also be able to

disable repaints of the textbox while you add, then reenable them and repaint

it.

ajm


TextBox append 3

LUOKKA: TextBox

Date: 05/13/94 (12:35)              Number: 5780 of 5791 (Refer# NONE)

From: ROBIN@FTP.HEALTH.ORG

Subj: Re: Append to textbox without flashing?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

How about just setting the SelText property instead of the Text property.

This will not only update the scroll bar but will also prevent the rapid

update flicker (I think)

Robin.


TextBox append 5

LUOKKA: TextBox

Date: 05/29/94 (09:35)              Number: 7345 of 7455 (Refer# NONE)

From: GSBRANDE@ACS.UCALGARY.CA

Subj: Re: Append to textbox without flashing?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2021900018@cdp> Jeff Dean <jeff@igc.apc.org> writes:

>>You can create a memory dc, draw the text on the memory dc, and bitblt it

>>to the screen. This may sound like a lot of work, but it is pretty easy. I may

>>be misunderstanding the problem though <g>.

>I'm trying to frequently update a text box (edit control) with information

>that is arriving from a serial port.  Creating my own bitmap would make

>sense if this were my own custom control, but I'm interested in using

>the standard control.  Also, I do want the scroll bar to be updated.

I've come into this discussion half-way, so I don't know what the exact

problem is.  If you are trying to elegantly add information to a text box,

what I do is:

1) Turn off repaints to the control (NOT a .Enabled=False--use an API call).

2) Update the control.

3) Turn on repaints to the control (API call)

4) Repaint the control (NOT a .Refresh--use an API call).

I can't remember which API calls they are, since I wrapped them all

in procedures a long time ago and I'm not on my development machine at

the moment.  Send me mail if you want me to find out what they are.

Incidentally, this is an excellent way to load controls on a form:

Set frm = New Form1

frm.Refresh   ' Displays all of the empty controls.

SetRepaints frm.hWnd, False ' Turn off repaints.

' Fill all of the controls.

SetRepaints frm.hWnd, True ' Turn on repaints.

RepaintObject frm.hWnd ' Redraws form with filled controls.

This speeds up the creation of the form and also makes it look

much snappier.

--

Sean Brandenburg

gsbrande@acs.ucalgary.ca


TextBox center text

LUOKKA: TextBox

============================================================

Date:         Sun, 25 Sep 1994 10:23:00 EST

From:         Animal Rescue League of Boston <0004587389@MCIMAIL.COM>

Subject:      Centering text in a msg box?

>If you are using a proportional font then that will involve a much

>more complicated solution, that I'm afraid I can't help you with,

>but if someone can I'd like to know how myself.

As far as I know, for a proportional font you'll have to create

your own msg box procedure and use code like this:

Sub Form_Click ()

   Msg1$ = "This is a first line of text"

   Msg2$ = "This is second line of text which is longer than the first line"

   HalfHeight = TextHeight(Msg1$) / 2    ' Calculate half height.

   CurrentY = ScaleHeight / 2 - HalfHeight ' Set Y.

   HalfWidth = TextWidth(Msg1$) / 2  ' Calculate half width.

   CurrentX = ScaleWidth / 2 - HalfWidth   ' Set X.

   Print Msg1$   ' Print message.

   HalfWidth = TextWidth(Msg2$) / 2  ' Calculate half width.

   CurrentX = ScaleWidth / 2 - HalfWidth   ' Set X.

   Print Msg2$   ' Print message.

End Sub

Ed Leonard <0004110565@MCIMAIL.COM>


TextBox color disable

LUOKKA: TextBox

Date: 04-10-95    Time: 02:33p     Number: 301

From: corgan@interaccess.com        Refer:

Subject: ForeColor of disabled             0: comp.lang.ba   Status: Public

-------------------------------------------------------------------------------

:>> Flum@depot.fps.mayn.sub.de (Matthias Rodic) writes:

:>>   How can I change the forecolor of a disabled textbox ? It is

:normally gray. I want it being black.

:>

:>Well, you have two choices.  You could go to your "Colors" control

:>panel, and change the color of disabled text to black.  Or you could

:>take advantage of a textbox bug, and set Multiline to Yes.

:>

:>You should be aware that making disabled text gray is a *feature*.

:>You may be confusing your user by making something that's disabled

:>look enabled.

:

:He could also leave the text box enabled, but discard any keystrokes to

:it by executing this line in its _KeyDown event...

:

:    KeyCode = 0

:

:If you want it to not always be disabled, declare a global variable for

:use as a flag and make the line's execution conditional on the variable's

:value being true.

There is also another choice:

Put a panel behind the text box, and you can control wether it is

enabled/disabled by setting the Panel3D1.Enabled property.  This way you

don't touch the text box, but if the Panel3D1.Enabled = False, than the text

box is disabled, yet the text is still black, and vice versa.  It's a nice

little trick.

~~~~~~~~~~~~~~

Dave Bost                    	corgan@interaccess.com

Consultant - Windows Development & Design

Origin Technology in Business	Phone:  (708)

318-9800

Rosemont, Illinois	Fax:    (708) 318-9808


TextBox cursor to end

LUOKKA: TextBox

Date: 05/27/94 (16:03)              Number: 7246 of 7249 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Adding to default text

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 05-27-94 DSTECKEL@SILVER.SDSMT.EDU  wrote:

D>     So the big question is:  How would you put the cursor at the

D>end of the default text string at the moment the text field gets focus?

text1.SelStart = len(text1.Text)

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


TextBox cursor to end

LUOKKA: TextBox

Date: 07/07/94 (22:21)              Number: 11495 of 11683 (Refer# NONE)

From: WHM@PLAZA.DS.ADP.COM

Subj: Re: cursor in textbox

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Paul Langemeijer (lmeijer@phys.uva.nl) wrote:

: When text in a textbox is extended by:

: text1.text = text1.text & "string"

: I would like the cursor to move to the end of the string.

: How can this be done?

   text1.text=text1.text & "string"

   text1.SetFocus

   SendKeys "äENDå"

_________

   Bill Morrison                                whm@plaza.ds.adp.com


TextBox cursor to end

LUOKKA: TextBox

Date: 07/08/94 (01:34)              Number: 11511 of 11683 (Refer# NONE)

From: RIENSCHE@BETA.TRICITY.WSU.EDU, Roderick M. Riensche

Subj: Re: cursor in textbox

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>: I would like the cursor to move to the end of the string.

>: How can this be done?

>

>   text1.text=text1.text & "string"

>   text1.SetFocus

>   SendKeys "äENDå"

Or, alternatively (since I know some people don't seem to like to use

SendKeys..

text1.text = text1.text & "string"

text1.SelStart = len(text1.text)

--

 -Roderick (Rick) M. Riensche


TextBox diff.colors

LUOKKA: TextBox

Date: 10/28/94 (16:11)              Number: 24865 of 24888 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: TextBox/Form Colors for each word?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (-)

> I want to ask if it is possible to have different colors for each

>separate word in a textbox/form. If not for standard ones, what 3rdparty

>ones could provide such function?

Textbox no, Form yes. Setting the ForeColor property for a textbox resets

the colour of the contents. With a form, it just affects all subsequent

Print and graphic methods.

--

Luke Webber


TextBox disabling etc

LUOKKA: TextBox

Date: 06/25/94 (11:30)              Number: 10444 of 10514 (Refer# NONE)

From: SOFTDEV@CODESMTH.DEMON.CO.UK

Subj: Re: Disabled text?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <oi2n_j_00iV0E540lN@andrew.cmu.edu>

           jgraves+@CMU.EDU "James T Graves" writes:

> I've been trying to make my forms the trendy grey & "3d" type, but when

> I set the form background to grey, disabled labels disappear.

Tricky, isn't it ? The problem is that if you disable a control (e.g. black

text on grey background), the foreground colour gets "greyed" out -- if

you're old and grizzled, just think of it as clearing the high intensity bit.

There is *nothing* you can do about this, and I will offer large drinks

(within geographical limits !) to anyone who can tell me how to get round

this. Life would be *much* simpler if it were so.

So, you can't use a text control for this -- what else is there ?

   A label

   A text control with a white background. Readable, but ugly.

   A text control which is made "read only", by other means than the

   .Enabled property

These are the main ones, although you can also play other tricks such as

using italics (not bad) or single-line borders (Ugly, IMHO)

Our "corporate" UMI standards are as follows:

Ignore the Windows system colours. They're a great idea, but don't seem to

co-exist too well with the "3D grey form" approach.

   Editable text controls:

Black text on white, inset on a narrow 3D panel. The relative sizes are

always the same.

      txtXXXX.Left = 35

      txtXXXX.Top = 30

      pnlXXXXSink.Width = txtXXXX.Width + 80

      pnlXXXXSink.Height = txtXXXX.Height + 75

   Temporarily read-only text controls:

Set .Enabled to False, producing a still-readable grey on white in a recessed

panel

   Displays that will never be editable

Labels, black text on grey

Where these are text controls, not labels (there may historical reasons or

something why they can't be), they need to be disabled. An

EM_SETREADONLY message stops any changes being made, and setting

.TabStop = False prevents users tabbing into the control. I don't know any

way of disabling mouse navigation to a control, so it's necessary to trap the

_GetFocus event and call txtSomeEnabledControl.SetFocus.

   Labels

Exactly as for the labels used for non-editable displays.

--

Codesmiths                                softdev@codesmth.demon.co.uk

Software Development Team                                Newcastle, UK


TextBox ENTER

LUOKKA: TextBox

Date: 06/23/94 (14:21)              Number: 9977 of 10157 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: HELP!  Using KeyAscii

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 06-21-94 GF@RNCB.DEMON.CO.UK  wrote:

G>What I want is for the user to be able to press ENTER in a text box

G>and the cursor to move to hte next text box according to the TAB index.

G>Sub RecipeCode_KeyPress (KeyAscii as integer)

G>KeyPreview = true

G>if KeyAscii = 13 then

G>   KeyAscii = 9

G>end if

G>end sub

First off, you'll need to locate the KeyPreview statement in the

Form_Load event, otherwise the form won't know to intercept the

keystroke.  Secondly, the way you've set it up will just replace

carriage returns with tab characters - not what you want.  In fact,

you'll have to do something like:

 If KeyAscii = 13 then NextTextBox.SetFocus

Lastly, you'll probably have to move the whole shebang to the _KeyDown

event, and test for KeyCode.  To do this, add

Global Const KEY_RETURN = &HD

to your Global .BAS module (whatever you've named it).  Then, in the

_KeyDown event, test for it like this

 If KeyCode = KEY_RETURN then NextTextBox.SetFocus

Give it a shot - if it doesn't work correctly (entirely likely, since

I'm typing off the top of my head and not testing as I go), email back

with your code and I'll be happy to look a little closer.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


TextBox Find & Scroll

LUOKKA: TextBox

Date: 09/20/94 (17:15)              Number: 20108 of 20148 (Refer# NONE)

From: OYVINDK@TROLL.VESTNETT.NO

Subj: Re: Finding text and scro

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

:Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,_

:   ByVal wParam%, lParam As Any)

:Sub ScrollToSelect (c As Control)

:Dim LinesVisible%, LineChar&, LineFirst&, i&

:    LinesVisible = Int(c.Height / (c.Parent.TextHeight("A") *

Screen.TwipsPerP

:

:    LineChar = SendMessage(c.hWnd, EM_LINEFROMCHAR, -1, 0)

:    LineFirst = SendMessage(c.hWnd, EM_GETFIRSTVISIBLELINE, 0, 0)

:

:    If (LineChar < LineFirst) Or (LineChar >= LinesVisible) Then

:        'outside visible area - scroll to center of text control

:        i = LineChar - LineFirst - Int(LinesVisible / 2)

:        i = SendMessage(c.hWnd, EM_LINESCROLL, 0&, ByVal i)

:    End If

To make this work, add the following constants:

Global Const WM_USER = &H400

Global Const EM_LINEFROMCHAR = (WM_USER + 25)

Global Const EM_GETFIRSTVISIBLELINE = (WM_USER + 30)

Global Const EM_LINESCROLL = (WM_USER + 6)

I had a hard time finding these constants. I found it on the

Development Library CD 8 (message blaster).

      Oyvind Kaldestad         Internet Address: oyvindk@vestnett.no

      Bergen - Norway                     Phone:  + 47 55 29 45 92

      Sysop 7Net - Bergen             BBS Phone:  + 47 55 29 68 60


TextBox find/scroll

LUOKKA: TextBox

Date: 09/19/94 (17:50)              Number: 20006 of 20037 (Refer# NONE)

From: TAYLOR@SATURN.BROOKS.AF.MIL, William D. Taylor

Subj: Re: Finding text and scrollin

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,_

   ByVal wParam%, lParam As Any)

Sub ScrollToSelect (c As Control)

Dim LinesVisible%, LineChar&, LineFirst&, i&

    LinesVisible = Int(c.Height / (c.Parent.TextHeight("A") *

Screen.TwipsPerPixelY))

    LineChar = SendMessage(c.hWnd, EM_LINEFROMCHAR, -1, 0)

    LineFirst = SendMessage(c.hWnd, EM_GETFIRSTVISIBLELINE, 0, 0)

    If (LineChar < LineFirst) Or (LineChar >= LinesVisible) Then

        'outside visible area - scroll to center of text control

        i = LineChar - LineFirst - Int(LinesVisible / 2)

        i = SendMessage(c.hWnd, EM_LINESCROLL, 0&, ByVal i)

    End If

End Sub

-WDT


TextBox forc. left

LUOKKA: TextBox

Date: 05/27/94 (08:53)              Number: 7236 of 7249 (Refer# NONE)

From: BIT@HALCYON.COM

Subj: RE left aligned boxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here is a method that might work.

Keep around a a hidden text box that is left aligned. When the user gives

focus to whatever box, hide the "real one" and place the left aligned one in

it's place.  Or just place the left aligned one on top of the real one.  The

control would flash changing alignment anyway if you could do it in a

straigtforward manner.  I bet that the user wouldn't be able to tell this from

the real thing.

Cheers

John


TextBox forc. left

LUOKKA: TextBox

Date: 05/25/94 (00:11)              Number: 6821 of 6934 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: Text Box Forced Left Align

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

m.   roshan (mroshan@julian.uwo.ca) wrote:

: How do I force the cursor in a text box to ALWAYS start at the left

: hand side, regardless of where the mouse clicks, even if the .Text

: properoperty is not empty?

MyTB.SelStart = 0

gt


TextBox ForeColor

LUOKKA: TextBox

Date: 07/28/94 (13:31)              Number: 13593 of 13893 (Refer# NONE)

From: CGR@HPLB.HPL.HP.COM

Subj: Re: MultiLine textbox question

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Luke Webber (webber@werple.apana.org.au) wrote:

: cgr@hplb.hpl.hp.com ( Chris Romans) writes:

: >Any suggestions as to how I can either make the MultiLine text gray until I

: >want to set the Enabled property?

: How about the ForeColor (sic) property? Don't you wish Microsoft wrote

: their products using English (ie ForeColour) 8^)

Having looked in the Knowledge Base I found the answer to my question in

the BUGS section. It also contained a workaround:

'*** In the global moduel: ***

Global Const WINDOW_TEXT = &H80000008    ' from CONSTANT.TXT

Global Const GRAY_TEXT = &H80000011    ' from CONSTANT.TXT

'*** in the form: ***

'to disable a multi-line box

text1.Enabled = 0  ' disable

text1.ForeColor = GRAY_TEXT ' gray

'to enable a multi-line text box

text1.Enabled = -1  ' enable

text1.ForeColor = WINDOW_TEXT ' black

-------------------------------------------------------------------------

Chris Romans.  HP Labs, Filton Road, Stoke Gifford, Bristol BS12 6QZ, UK.


TextBox highlight

LUOKKA: TextBox

Date: 12/02/94 (00:40)              Number: 142102 of 142735 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: showing highlighted text w/o focus

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

To: Multiple recipients of list VISBAS-L <VISBAS-L@TAMVM1.TAMU.EDU>

>Does anyone know how to allow text to be selected in a tex box (or

anything)

>and still show the text as highlighted when the text box does not have

>focus?

I just ran into this the other day. You need to set the HideSelection

property on the text box to False.

Paul


TextBox highlight

LUOKKA: TextBox

Date: 12/02/94 (00:45)              Number: 142105 of 142735 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: showing highlighted text w/o focus

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>Try Text1.SelStart and Text1.SelLength

Thanks for the reply, but this won't work.  That's what I thought would

work too.  The .SelStart and .SelLength values are still maintained and

can be set when the text box does not have focus, but the text is not

highlighted.  Try it on any window.  Select some text in a window and then

click on a different window.  The text will not be highlighted until you

make the first window active again.

I was thinking I could make it look like the text was selected by

setting the background and foreground colors when it did not have focus.

My problem there (assuming it would work), is that I don't have a text

box in which I can change the color of only part of the text.

Is there a freeware or CHEAP control which would allow me to do this?

I need it to be small too.  My project distribution is getting too large.

ANY one else have a shot at this?

                               --Brian

bl7385@isoa.sbc.com


TextBox highlighting

LUOKKA: TextBox

Date: 04/14/94 (17:01)              Number: 3434 of 3514 (Refer# NONE)

 From: MICHAEL.RUBIN@PCGFX.COM

Subj: Text Box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 04-13-94 HOONG TENG wrote:

HT>Question: I have finish the code for finding the keywords in the

HT>document. But I don't know how to display or highlight the keywords

HT>in the document inside the text box.

I can't help you with your first question, but here's how I solved your

second question.  Use Instr to search the text for your target string:

     TargetStr$ = "SearchForThisString"

     Pos% = Instr(Text1.Text, TargetStr$)

If it exists, Pos% will be the location of the first character in

TargetStr$.  Use SelStart and SelLength to highlight the text:

     If Pos% Then

          Text1.SelStart = Pos%

          Text1.SelLength = len(TargetStr$)

     End If

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatetot.com


TextBox indiv. lines

LUOKKA: TextBox

11782 (70+)  rschwarz@edcen.ehhs.cmich.edu  01.04.95  03:22

Ron Schwarz: "Re: Lines of Text in a Textbox"

>Could some good Samaritan please share me a piece of API code that would

>allow me to get individual lines of text from a textbox.

DeclarFunction SendMessage% Lib "user" (ByVal hwnd%, ByVal wMsg%,

ByVal   wParam%, ByVal lParam As Any)

Dim Buf String

Dim resizing As Integer

Const EM_GETLINE = &H400 + 20

Const EM_GETLINECOUNT = &H400 + 10

Const MAX_CHAR_PER_LINE = 80  ' Scale this to size of text box.

Sub Command1_Click ()

   '* Pop up an inputbox$ to allow user to specify which line

   '* in the text box to print or print all lines.

   '* Also check bounds so that a valid line number is printed.

   OK = 0                     ' Zero the Do Loop flag.

   NL$ = Chr$(13) + Chr$(10)

   prompt$ = "Which line would you like to print?"

   prompt1$ = prompt$ + NL$ + "Enter -1 for all"

   prompt2$ = "Too many lines" + NL$ + "Try again!" + NL$ + prompt1$

   prompt$ = prompt1$

   Do

      response$ = InputBox$(prompt$, "Printing", "-1")

      If response$ = "" Then Exit Sub  ' If user hits cancel, then exit.

      If Val(response$) > fGetLineCount&() Then

         prompt$ = prompt2$

      Else

         OK = -1        ' Line chosen is in valid range, so exit DO.

      End If

   Loop Until OK

   If Val(response$) = -1 Then  ' Print all lines...

      ndx& = fGetLineCount&()

      For N& = 1 To ndx&

         Buffer = fGetLine(N& - 1)

         printer.Print Buffer       ' ...or print to the screen.

      Next N&

   Else                         ' Print a line...

      Buffer = fGetLine(Val(response$) - 1)

      printer.Print Buffer       ' ...or print to the screen.

   End If

End Sub

Function fGetLine$ (LineNumber As Long)

  ' This function fills the buffer with a line of text

  ' specified by LineNumber from the text-box control.

  ' The first line starts at zero.

   byteLo% = MAX_CHAR_PER_LINE And (255)  'Žchanged 5/15/92�

   byteHi% = Int(MAX_CHAR_PER_LINE / 256) 'Žchanged 5/15/92�

   Buffer$ = Chr$(byteLo%) + Chr$(byteHi%) + Space$(MAX_CHAR_PER_LINE

- 2)

   ' ŽAbove line changed 5/15/92 to correct problem.�

   x% = SendMessage(text1.hwnd, EM_GETLINE, LineNumber, Buffer$)

   fGetLine$ = Left$(Buffer$, x%)

End Function

Function fGetLineCount& ()

   ' This function will return the number of lines

   ' currently in the text-box control.

   ' Setfocus method illegal while in resize event,

   ' so use global flag to see if called from there

   ' (or use setfocus before this function call in general case).

   lcount% = SendMessage(text1.hwnd, EM_GETLINECOUNT, 0&, 0&)

   aGetLineCount.caption = "GetLineCount = " + Str$(lcount%)

   fGetLineCount& = lcount%

End Function

Sub Form_Load ()

   ' Size form relative to screen dimensions.

   ' Could define all in move command but recursive definition causes

   ' extra paints.

   form1.width = screen.width * .8

   form1.height = screen.height * .6

   form1.Move screen.width ™ 2 - form1.width ™ 2, screen.height ™ 2 -

form1.height ™ 2

End Sub

Sub Form_Resize ()

   resizing = -1      ' Global  flag for fGetLineCount function call.

   ' Dynamically scale and position the controls in the form.

   ' This code also is executed on first show of form.

   text1.Move 0, 0, form1.width, form1.height ™ 2

   text1.SelStart = text1.SelStart    ' To avoid UAE, see Q80669.

   command1.Move form1.width ™ 2 - command1.width ™ 2, form1.height -

form1.height ™ 4

   aGetLineCount.Move form1.width ™ 2 - command1.width ™ 2, text1.height

   x% = fGetLineCount() ' Update to reflect change in text-box size.

   resizing = 0

End Sub

Sub Text1_Change ()

   x% = fGetLineCount() '* Update label to reflect current line

End Sub


TextBox Input filter

LUOKKA: TextBox

Date: 07/27/94 (23:06)              Number: 13486 of 13548 (Refer# NONE)

From: MICHAEL.COWAN@ALMAC.CO.UK

Subj: Input Filter for Text Box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

JM>Does anyone know of a modifiable input filter for text boxes, that will

JM>limit the user's input to a set formula (e.g. AAA999, or some such)?  If

JM>there's one built in, they've got the help pretty well hidden!

JM>

Sub Text1_KeyPress (KeyAscii As Integer)

    If KeyAscii = 8 Then Exit Sub

    If Len(text1) = 6 Then KeyAscii = 0: Exit Sub

    Select Case Len(text1)

        Case 0 To 2

            If KeyAscii < 65 Or KeyAscii > 90 Then KeyAscii = 0

        Case Else

            If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0

    End Select

End Sub

michael.cowan@almac.co.uk nottingham, england


TextBox ins/overwrite

LUOKKA: TextBox

Date: 11/03/94 (18:16)              Number: 25692 of 25696 (Refer# NONE)

From: WEIKKO.IKOLA@CSC.FI

Subj: Re: Edit control with overwrite mode

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>We are writing an application that requires a multiline

>edit control with Insert and Overwrite capabilities and we

>are using Visual Basic 3.0. The standard Windows edit control

>(as it is used by VB) does NOT support Overwrite mode...

Hold your horses, here is:

Dim insmode As Integer

Const KEY_INSERT% = &H2D

-----------------

Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)

If KeyCode = KEY_INSERT Then

    insmode = IIf(insmode, False, True)

End If

End Sub

-----------------

Sub Text1_KeyPress (KeyAscii As Integer)

    If insmode Then Text1.SelLength = 1

End Sub

-----------------

Greetings,

Wende (weikko.ikola@csc.fi)


TextBox moving around

LUOKKA: TextBox

Date: 08/28/94 (17:12)              Number: 17565 of 17567 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Moving around in a te

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I don't know about setting the line number, but you can get the text at the

desired line and goto it using some of the following code:

Global Const WM_USER = &H400

Global Const EM_GETLINECOUNT = WM_USER + 10

Global Const EM_LINEINDEX = WM_USER + 11

Global Const EM_LINELENGTH = WM_USER + 17

Global Const EM_LINEFROMCHAR = WM_USER + 25

Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%,

ByVal wParam%, lParam As Any)

Function GetLineNumber% (txtIn as Control, ByVal intCharPos%)

'Returns the line number where intCharPos resides

    If intCharPos <= 1 then

        GetLineNumber = SendMessage(txtIn.hWnd, EM_LINEFROMCHAR,

           intCharPos, 0&)

    Else

        GetLineNumber = SendMessage(txtIn.hWnd, EM_LINEFROMCHAR,

           txtIn.SelStart, 0&)

    End If

End Function

Function GetCharFromLine% (txtIn as Control, ByVal intLinePos%)

'Returns the character number where line number intLineNum resides

    GetLineNumber = SendMessage(txtIn.hWnd, EM_LINEINDEX, intLinePos,

        0&)

End Function

Function GetLineLength% (txtIn as Control, ByVal intLineNum%)

'Returns the length of line number intLineNum

    GetLineLength = SendMessage(txtIn.hWnd, EM_LINELENGTH,

intLineNum, 0&)

End Function

Function GetNumLines% (txtIn as Control)

'Returns the number of lines in the text control

    GetNumLines = SendMessage(txtIn.hWnd, EM_GETLINECOUNT, 0, 0)

End Function

__________

                           Bradley S. Murray


TextBox printing

LUOKKA: TextBox

TEXTBOXIN PRINTTAUS

1.) Tapa printata TextBoxin sisältö softbreakit säilyttäen.

Function fGetLine$ (lineNumber As Long)

  ' This function fills the buffer with a line of text specified by LineNumber

  ' from the text box control. The first line starts at zero.

  Dim Buffer As String

  Buffer = String$(87 + 2, 0)               'rivin pituus 87 + alkuun pituus 2tavua:

  Mid$(Buffer, 1, 1) = Chr$(89 And &HFF)    '1.tavu intin low-order, *255

  Mid$(Buffer, 2, 1) = Chr$(89 / &H100)     '2.tavu intin high-order /256...

  g_iResult = SendMessageByString(txtTeksti.hWnd, EM_GETLINE,

lineNumber, Buffer)

  fGetLine$ = Left$(Buffer, g_iResult)

End Function

Function fGetLineCount& ()

  ' This function will return the number of lines

  ' currently in the text box control.

  g_iResult = SendMessage(txtTeksti.hWnd, EM_GETLINECOUNT, 0&, 0&)

  fGetLineCount& = g_iResult

End Function

  txtTeksti = T("TEKSTI")

  lRiviAll = fGetLineCount&()        'rivien määrä TextBoxissa

  For lInd = 1 To lRiviAll

    g_sBuffer = fGetLine(lInd - 1)   'alkaa 0-riviltä

    Print #nFileNum, g_sBuffer

  Next lInd

2.) Ei säilytä ihan aivan samana TextBoxin word-wrappeja

    ' kerrotaan, TextBoxille, että säilyttää soft-breakit eli CR+CR+LF(!)

    ' TextBoxissahan word-wrap eli rivinvaihto onkin CR+CR+LF...

    g_iResult = SendMessage(txtTeksti.hWnd, EM_FMTLINES, -1, 0&)

    txtTeksti = T("TEKSTI")    ' siirretään tavara TextBoxiin

    Print #nFileNum, txtTeksti ' 1-kertaisesti printataan TextBox...

3.) Printtausformille voi kopioida printattavan TextBoxin. Sitten vain formi

pienennetään, ettei käyttäjä näe printtavaa TextBoxia...


TextBox printing

LUOKKA: TextBox

Date: 11/13/94 (16:58)              Number: 26688 of 26691 (Refer# NONE)

From: AJM@GEAC.CO.NZ

Subj: Re: Text Parser

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>HELP!  I need to take text from a multiline textbox and convert it to

lines

>of 78 chars maximum and then write then into a file.  I also cannot have

>words cut in half, I have been banging my head on this for 2 days and

>cannot get the entire text box parsed correctly.

There is a knowledge base article which shows how to do this. You have to

send EM_GETLINE messages to the text box to retrieve the lines

individually. It cannot be done without using the SendMessage API.

Here is a fragment of code from an app I wrote that does it:-

   Declare Function GetFocus% Lib "user" ()

   ' Enter the following Declare statement on one, single line:

   Declare Function SendMessage% Lib "user" (ByVal hWnd%, ByVal wMsg%,

     ByVal wParam%, ByVal lParam As Any)

   Global Buffer As String

   Global resizing As Integer

   Global Const EM_GETLINE = &H400 + 20

   Global Const EM_GETLINECOUNT = &H400 + 10

   Global Const MAX_CHAR_PER_LINE = 78  ' Scale this to size of text box

 Function fGetLine$ (LineNumber As Long)

     ' This function fills the buffer with a line of text

     ' specified by LineNumber from the text box control.

     ' The first line starts at zero.

     ' any non-printable character is translated to a space

      byteLo% = MAX_CHAR_PER_LINE And (255)  ' changed 5/15/92

      byteHi% = Int(MAX_CHAR_PER_LINE / 256) ' changed 5/15/92

      buffer$ = Chr$(byteLo%) + Chr$(byteHi%) +

Space$(MAX_CHAR_PER_LINE- 2)

      '  Above line changed 5/15/92 to correct problem.

      text1.SetFocus 'Set focus for API function GetFocus to return

                              handle

      X% = SendMessage(GetFocus(), EM_GETLINE, LineNumber, buffer$)

      ' translate non-printable chars to a space.

      For i% = 1 To X%

        c$ = Mid$(buffer$, i%, 1)

        If c$ < Chr$(32) Or c$ > Chr$(127) Then

            Mid$(buffer$, i%, 1) = " "

        End If

      Next i%

      fGetLine$ = Left$(buffer$, X%)

   End Function

This is ripped off straight out of the Kbase article; I think it makes

sense ripped out of context; if you get stuck, let me know.

PS: I see rereading this that they called a routine GetFocus(). This was

to get the hwnd property of the control, something you couldn't do easily

in VB1. Just replace that with the hwnd.

rgds


TextBox read file

LUOKKA: TextBox

Date: 08/04/94 (20:58)              Number: 14401 of 14404 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: moduleless forms / quick textboxes

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Even better tip - if your doing a while loop to read until the end of the file,

concatating strings together there is a still faster method.  Instead of

"Open Filename for Input as 1" use "Open Filename for Binary as 1" then

a$ = Space$(FileLen(FileName))  and Get #1,,a$  Then Text1.Text = a$ is

the fastest way to fill a text box with text from a file.

Stephen Johnston


TextBox read file

LUOKKA: TextBox

Date: 08/20/94 (00:33)              Number: 16323 of 16389 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: read .txt file and place in text box ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Open the file as binary, and read either the length of the file or 32000

characters, which ever is lesser, into a string and assign it to the text

property of a text box.  This is the fastest way to do what you want.

You could also open "For Input" and use LineIn to concatenate strings

together, but using the Binary method is about 500% faster for large files.

Stephen Johnston


TextBox read files

LUOKKA: TextBox

Date: 08/10/94 (13:16)              Number: 15060 of 15159 (Refer# NONE)

From: MCARDACI@ESRIN.BITNET

Subj: Re: Long ASCII -> 80 column ascii

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If the file is less that 64kb, just read it in one issue and put it into the

textbox: it will wrap around automatically (no word-wrap, unfortunatly).

If You want to be more clean, read it to a string and:

1) get the 80th char

2) if it is a blank:

      2.1) get all the chars up to the char You extracted

   else

      2.1) examine the previous char and go to 2)

3) add cr+lf to the extracted line

4) append it to the listbox

5) remove from the big string the part you extracted (MID$ or RIGHT$...)

6) if the big string is not empty goto 1)


TextBox readonly

LUOKKA: TextBox

7. How do you make a TEXTBOX read only? Or, how do I prevent the user

   from changing the text in a TEXTBOX?

   There's a lot of ideas on this one. You can grab the _KeyPress and

   _KeyDown events and set them to zero. However, the best idea is to

   use the Windows API SendMessage function to tell the control to

   become read-only:

     'After making the following declarations...

     Global Const WM_USER = &H400

     Global Const EM_SETREADONLY = (WM_USER + 31)

     Declare Function SendMessage Lib "User" (ByVal hWnd As

     "Integer ByVal wMsg As Integer, ByVal wParam As

     "Integer, lParam As Any) As Long

     'Then Try:

     SendMessage(Text1.hWnd, EM_SETREADONLY, 1, 0)

      Pete Jones (pjones@csi.compuserve.com)

   This will still allow the user to copy *from* the text box. If you

   need to disable this (why?), steal the Ctrl-C in the _KeyPress

   event.


TextBox right justify

LUOKKA: TextBox

Date: 08/25/94 (09:51)              Number: 16968 of 17020 (Refer# NONE)

From: WJ5A@AOL.COM

Subj: Right Justify text in Text Box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

From the MSDN CD 8

PSS ID Number: Q111952

Article last modified on 04-25-1994

SUMMARY

To center or right justify (align) the text in a text control that contains

a single line of text, set the multiline property to True and the Alignment

property to the desired value. Then trap the KeyPress event and use the

multiline and MaxLength properties to trap the carriage return and convert

it to another character.

MORE INFORMATION

1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)

   if Visual Basic is already running. Form1 is created by default.

2. Add a text control (Text1) to Form1. Set its Alignment property to

   1 - Right Justify. Set the Multiline property to True. Set the MaxLength

   property to some arbitrary value equal to the width of the text box

   in characters (15). Be sure to make the text control s height

   property large enough to display the first line of text. The actual

   height of the text box may need to be a little bigger than normal.

3. Add the following code to the KeyDown event procedure of Text1:

   '============== Form1.frm ==================

   Sub Text1_KeyPress (KeyAscii As Integer)

      If KeyAscii = 13 Then

         KeyAscii = 7            ' Beep - no effect on text

      End If

   End Sub

4. From the Run menu, choose Start (ALT, R, S) to run the program. Type

    text into the text control, and press the ENTER key. The keystroke is

    trapped, and the text does not change.

Chuck

Mesquite TX


TextBox tabstops

LUOKKA: TextBox

Date: 11/18/94 (11:27)              Number: 131487 of 131870 (Refer# NONE)

From: PBH@KCC.CO.UK

Subj: Re: Tabs in textbox

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>I run in to a problem whit text box.

>I have an ascii file, in which I have

>printed lines, tab stops between words.

>(Print #1,"word";tab(10);"another word";tab(30);"word")

>When I read that file into a textbox, those tab stops

>are not in their places. What to do?

Teppo:  I think it is because you are using a proportional font in

VB.  Your file contains spaces in place of the tabs, and spaces are

thinner that letters and numbers.  Try changing to a font such as

Courier.

If you don't want to change the font, you will have to read each data

line from the file and use MID$() to split it into columns, TRIM()

each column, and print each item with TABS in VB.

- - Pete


TextBox text parser

LUOKKA: TextBox

Date: 11/13/94 (20:52)              Number: 26729 of 26823 (Refer# NONE)

From: ELIJAH@BGA.COM

Subj: Re: Text Parser

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: >HELP!  I need to take text from a multiline textbox and convert it to lines

: >of 78 chars maximum and then write then into a file.  I also cannot have

: >words cut in half, I have been banging my head on this for 2 days and

: >cannot get the entire text box parsed correctly.

boy did you ask the right question. I have now written and rewritten this

code in VB Director and Toolbook about 4 times each to mactch a changing

design spec.

dim textstring$,tempstring$,writestring$,endchar$

dim a%,b%,i%,l%,x

textstring$ = text1.text

a% = 1

b% = 0

l%= len(textstring$)

i% = l%Ö78

if l% mod 78 > 0 then i% = i% + 1

for x = 1 to i%

tempstring$ = mid$(textstring$,b%+ 1, 78)

endchar$ = " "

do while a% <> 0

b% = a%

a%=instr(b%+1,tempstring$,endchar$)

loop

writestring$ = left$(tempstring$, b%)

'write this baby off and start again

next x


TextBox transparent

LUOKKA: TextBox

Date: 07/16/94 (09:18)              Number: 12217 of 12223 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Transparent TextBoxes?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 07-14-94 DEREK=JACOBY%HF%PCPD=HOU@  wrote:

D> Does anyone out there know how to make a transparent text box. What I

D>mean is that I would like to be able to display a bitmap as the

D>background to a large textbox. Of

D>course, I know how to change the background color, but a solid color

D>is not sufficient. Thanks!

How about loading your bitmap into a paintbox, then painting your text

on top?

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com


TextBox txt to PicBox

LUOKKA: TextBox

Date: 06/25/94 (12:08)              Number: 10465 of 10514 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Text 2 PictureBox?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 23 Jun 1994 22:40:15 GMT brianf <brianf@halcyon.halcyon.com> wrote:

> Is there a way to port some text from a text box over to a picturebox??

Try this:

Const WM_USER = &H400

Const EM_GETLINECOUNT = WM_USER + 10

Const EM_GETLINE = WM_USER + 20

    hwndText% = Text1.hWnd

    ' Get the number of lines in the text box

    iNumLines% = SendMessage(hwndText%, EM_GETLINECOUNT, 0, 0&)

    ' Clear the picture control

    Picture1.AutoRedraw = True

    Picture1.Cls

    Picture1.CurrentY = 3

    ' Loop through all lines of text

    For i% = 0 To iNumLines% - 1

        sLine$ = Space$(100)

        ' Get next line of text

        iNumChars% = SendMessage(hwndText%, EM_GETLINE, i%, sLine$)

        ' Print sLine$ to the picture control

        Picture1.CurrentX = 3

        Picture1.Print sLine$

   Next i%

   Picture1.AutoRedraw = False

--

Arjen Broeze                                   Telephone: (+33)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13


TextBox uppercase

LUOKKA: TextBox

Date: 04/16/94 (04:10)              Number: 3668 of 3757 (Refer# NONE)

From: RSCHWARZ@EDCEN.EHHS.CMICH.EDU, Ron Schwarz

Subj: Re: Text box

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In a previous article, ronnybs@dhhalden.no (RONNY BRATBERG STAVEM)

says:

>I hava a small problem I hope someone can help me with. I'm making a

>database, and in the textboxes to insert names and all that, I want the text

>to be uppercase. I was trying to use: ex: Text.1Text=UCase$(Text1.text),

>but the result of this (stupid) command was that when I was inserting a

>name in the textbox it came out backwords !"!)=?????? Instead of TOM it

>became MOT.

In the KeyPress event, use the KeyAscii parameter.

Something like:

 KeyAscii = Asc(Ucase$(Chr$(KeyAscii)))

Or, you can test if KeyAscii is a lowercase ASCII code, and convert it to

uppercase, without having to go through string conversions.

Ron


Time 100th's of sec

LUOKKA: Time

Date: 09/07/94 (11:40)              Number: 18521 of 18530 (Refer# NONE)

From: WEBBER@WERPLE.APANA.ORG.AU, Luke Webber

Subj: Re: Storing time format to hundredths of a second

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

wilder@falcor.enet.dec.com (Jim Wilder) writes:

>I need to be able to store timing information for a swim team. This

>must keep time down to the hundredths of a second. Currently, the

>"time" format only has resolution to seconds. Is this possible without

>doing some obscene math on long numbers? If I could keep actual time

>of say  2:33.44, then I could do some easy math (such as what comes

>with VB and MS Access). Does anyone know if this can be done, or have

>sample code to do it?

I don't know what you mean by 'obscene math'. The numbers you're talking

about here don't really need to be time format. A long integer should

have ample precision for your requirements. Simply store a value

representing the number of hundredths of a second. You only really need

to format hundredths, seconds and minutes. Hours? Perhaps, but the maths

is all pretty cut and dried.

You obviously overrate the level of difficulty of time formatting. Dates

now, they're another story entirely.

For example...

 Hours% = Tm& mod 100

 Secs% = (Tm&   100) mod 60

 Mins% = (Tm&   6000) mod 60

 Hours% = Tm&   360000

Not so bad, surely?

--

Luke Webber


Time 100th's of sec

LUOKKA: Time

Date: 09/08/94 (20:35)              Number: 18729 of 18922 (Refer# NONE)

From: WHM@PLAZA.DS.ADP.COM

Subj: Re: Storing time format to hundredths of a second

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Jim Wilder (wilder@falcor.enet.dec.com) wrote:

: I need to be able to store timing information for a swim team. This

: must keep time down to the hundredths of a second. Currently, the

: "time" format only has resolution to seconds. Is this possible without

: doing some obscene math on long numbers?

 Jim, I'd store the time and hundredths separately.  Then, I'd

 use a simple algorithm like:

   Dim Time1

   Dim Tick1%

   Dim Time2

   Dim Tick2%

   Dim DiffTime

   Dim DiffTick%

   Time1 = "23:33:10"

   Tick1% = 87

   Time2 = "23:32:11"

   Tick2% = 90

   DiffTime = DateDiff("s", Time2, Time1)

   If Tick1% < Tick2% Then

      DiffTime = DiffTime - 1

      Tick1% = Tick1% + 100

   End If

   DiffTick = Tick1% - Tick2%

_________

   Bill Morrison                                whm@plaza.ds.adp.com


Timer increase interv

LUOKKA: timer

Date: 06-28-95 (03:06)              Number: 373772 of 374318 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: How to increase the timer interval

From: Paul Treffers <treffers@XS4ALL.NL>

I had the same problems with the timer. I needed a user-configurable

timer from 15 secs to 60 minutes. My solution for this problem was

to set the timer interval to 1 second, and used the datediff function

to calculate the elapsed time.

First i set the start of the timer in a var. : StartTime = Now

Example for timer code

Timer1_Timer()

        CurrentTime = Now

         If DateDiff("n",StartTime,CurrentTime) > 120 then

                 'Action

                StartTime = Now

        Else

                'Nothing or a do event

        Endif

End Timer

--------------------------------------------------------------------------

Email address : treffers@xs4all.nl

Visit my homepages at http://www.xs4all.nl/~treffers

for VB information


Timer unreliable

LUOKKA: timer

Date: 06/05/94 (04:11)              Number: 8000 of 8074 (Refer# NONE)

From: GAT@CSN.ORG

Subj: Re: another interesting note... Timer

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Alan Miller (millera@MCS.COM) wrote:

: An interesting note about the Timer control:  It's apparently sensitive

: to what else you have running.  I've got an application that's supposed

: to fire every 20 minutes and write to a file, but when I have a DOS

: window open and fullscreened, it doesn't trip.  Admittedly, the DOS

There's a good article on timers on the MSDN.  Here's a clip.

Enhanced Mode Virtualization

When running in enhanced mode, Windows takes advantage of the virtual

machine (VM) capabilities of the Intel386  hardware. All MS-DOS®-based

 applications run as if each had the entire system to itself. All

Windows-based applications run together in a sing

le VM. All VMs, if none are paged, reside simultaneously in

physical memory, but only one at a time is active.

To arbitrate among the VMs, Windows loads a virtualization layer

when running in Enhanced mode. This layer acts as a traffic cop, directing

hardware events to the appropriate VM on the basis of which VM is active.

One of the many hardware events that is virtualized is INT 8, the timer.

When a VM is not the active VM, it does not receive INT 8 events at the

standard 18.2 Hz rate. The Windows VM not receiving INT 8 events at a

standard rate plays havoc with the value returned by the GetTickCount

function as well as with any active timers set by Windows-based applications.

In this environment, WM_TIMER messages are at the mercy of the Enhanced

mode scheduler and the relative priority of the Windows VM. Probably more

problematic is the value returned from GetTickCount. Because this value

increments by 55 only when the Windows VM sees an INT 8, it is not at all

accurate in Enhanced mode. Applications that require accurate event

timing must not use GetTickCount to determine time delays. Instead, they

must use the clock maintained by MS-DOS (INT 21H, function 2CH),

TOOLHELP.DLL services, or the VTD (described below).

Tip:

Windows timers operate erratically in enhanced mode when MS-DOS-based

applications are active.

The GetTickCount function cannot be used to time events accurately

because it is not regularly updated when the MS-DOS VMs are active.

GetTickCount is inaccurate in both standard mode and enhanced mode.

--------------end clip-------------

gt


TimerCount

LUOKKA: timing

Date: 11/20/94 (13:00)              Number: 27387 of 27407 (Refer# NONE)

From: JEREMYK@NETCOM.COM

Subj: Re: Multimedia Timers = RealTime Timers ?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The TimerCount API function may be useful. It returns an apparantly-

accurate real-time clock.  The following shows how to use it:

Type TIMERINFO                      ' for TimerCount function

    dwSize          As Long         ' size of structure - set to 12

    dwmsSinceStart  As Long         ' ms since task start

    dwThisVM        As Long         ' ms since virtual machine start

End Type

Declare Function TimerCount Lib "toolhelp.dll" (lpti As TIMERINFO) As

Integer

Function RightNow () As Long

'   Returns the current millisecond clock

    Dim i       As Integer

    Dim ttime   As TIMERINFO

    ttime.dwSize = 12

    If TimerCount(ttime) Then       ' call toolhelp function

 RightNow = ttime.dwThisVM

    Else

 MsgBox "TimerCount function unavailable. Terminating."

 End

    End If

End Function

My experiments with it have shown it to run in < 200 microseconds on

a 486/66. You could get fairly accurate timing by looping calling

TimerCount and calling DoEvents until the millisecond you want comes

around.

---

Jeremy Knight :: Berkeley, CA :: jeremyk@netcom.com


Titlebar remove

LUOKKA: VBgen

Date: 06-03-95 (17:08)              Number: 350547 of 352584 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Getting ride of Title bar

>

>        Is there any way to get ride of the title bar but keeping the

>        menu bar visible(File, Edit, Etc)?

Below is the answer to your question. The tip can be found in the VB Tips &

Tricks newsletter.

Removing Title Bar

I thought that I would submit the following routine that allows one to

dynamically remove the title bar from a VB form.  I have seen several

programs (e.g. CLOCK.EXE and Norton's SYSWATCH.EXE) that do this and

after seeing an article in PC Magazine, I put together this routine.

'==============================================================

===

' TITLEBAR.BAS

' Written by Bruce Guthals

' InterNet: BGuthals@nyx.cs.du.edu

'

' Version 1.0             Date: 6/15/94

'

' Summary:

'    This routine allows you the dynamically remove the title bar

'    from a VB form.

'    Patterned after the PC Tech column in PC Magazine 6/14/94

'    Volume 13, Number 11

'

' Syntax:

'    TitleBar Form1, False        This will remove the title bar

'    TitleBar Form1, True         This will restore the title bar

'==============================================================

===

DefInt A-Z

Option Explicit

Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal

nIndex%)

Declare Function SetWindowWord% Lib "User" (ByVal hWnd%, ByVal

nIndex%, ByVal w NewWord%)

Declare Function GetWindowLong& Lib "User" (ByVal hWnd%, ByVal

nIndex%)

Declare Function SetWindowLong& Lib "User" (ByVal hWnd%, ByVal

nIndex%, ByVal dwNewLong&)

Const GWW_ID = (-12)

Const GWL_STYLE = (-16)

Const WS_DLGFRAME = &H400000

Const WS_SYSMENU = &H80000

Const WS_MINIMIZEBOX = &H20000

Const WS_MAXIMIZEBOX = &H10000

Sub TitleBar (frm As Form, ShowTitle)

   Static Oldhmenu, SavedStyle&

   Dim NewStyle&, t&

   If ShowTitle Then

      'get the current style attributes

      NewStyle& = GetWindowLong&(frm.hWnd, GWL_STYLE)

      'set only the attributes that were removed earlier

      NewStyle& = NewStyle& Or SavedStyle&

      're-establish the menu

      If Oldhmenu <> 0 Then

         t& = SetWindowWord%(frm.hWnd, GWW_ID, Oldhmenu)

      End If

      'set the new style

      t& = SetWindowLong&(frm.hWnd, GWL_STYLE, NewStyle&)

      'force VB to update the form

      frm.Left = frm.Left

      frm.Refresh

   Else

      'get the current style attributes

      NewStyle& = GetWindowLong&(frm.hWnd, GWL_STYLE)

      'determine whether the form has a dialog frame, a ControlBox,

      'a minimize button, or a maximize button and save this info.

      'for later use

      SavedStyle& = 0

      SavedStyle& = SavedStyle& Or (NewStyle& And WS_DLGFRAME)

      SavedStyle& = SavedStyle& Or (NewStyle& And WS_SYSMENU)

      SavedStyle& = SavedStyle& Or (NewStyle& And WS_MINIMIZEBOX)

      SavedStyle& = SavedStyle& Or (NewStyle& And WS_MAXIMIZEBOX)

      'remove the attributes for a dialog frame, a ControlBox, a minimize

      'button and a maximize button

      NewStyle& = NewStyle& And Not WS_DLGFRAME

      NewStyle& = NewStyle& And Not WS_SYSMENU

      NewStyle& = NewStyle& And Not WS_MINIMIZEBOX

      NewStyle& = NewStyle& And Not WS_MAXIMIZEBOX

      'is there a menu associated with this form?

      Oldhmenu = GetWindowWord%(frm.hWnd, GWW_ID)

      If Oldhmenu <> 0 Then

         'yes-zero it the menu handle

         t& = SetWindowWord%(frm.hWnd, GWW_ID, 0)

      End If

      'set the new style

      t& = SetWindowLong&(frm.hWnd, GWL_STYLE, NewStyle&)

      'force VB to update the form and get rid of the title bar

      frm.Left = frm.Left

      frm.Refresh

   End If

End Sub

TIP SUBMITTED BY: BRUCE GUTHALS

============================================

=David McCarter - dpmcs@cts.com            =

=Editor-In-Chief Visual Basic Tips & Tricks=


Titlebar small

LUOKKA: VBgen

15.How do I create a window with a small title bar as in a floating

   toolbar?

   Download the MSGBLAST VBX from ftp.microsoft.com (filename

msgblast.zip)

   or (better) from ftp.cica.indiana.edu or mirrors. The example files

   provide an example of a form with a small title. When you see it, you'll

   understand why I haven't include a full explanation here!


Toolbar floating

LUOKKA: VBgen

Australia                               E-Mail: R.Czerwonka@cowan.edu.au

DOCUMENT:Q114594  31-MAY-1994  [B_VBASIC]

TITLE   :How to Create a Floating Toolbar in Visual Basic

PRODUCT :Microsoft Visual Basic

PROD/VER:2.00 3.00

OPER/SYS:WINDOWS

KEYWORDS:

SUMMARY

=======

This article contains code and instructions that show you how to

create a floating toolbar in Visual Basic. A toolbar is a modeless dialog box

owned by a parent window but not confined to the area of the parent.

This article combines methods that are described in more detail in

the following articles in the Microsoft Knowledge Base:

ARTICLE-ID: Q114775

TITLE     : How to Create a Modeless Dialog or Form in Visual Basic

ARTICLE-ID: Q114593

TITLE     : How to Move a Form that Has No Titlebar or Caption

MORE INFORMATION

================

Instead of offering this article in a number of steps, we have

modified our usual format to make it easier for you to create and use this

Visual Basic application. Therefore, the three files you need (TOOLBAR.BAS,

TOOLBAR.FRM, and PARENT.FRM) are listed below, so you can easily copy

them into a text editor, and save them as separate files. Instructions for

how to use the files are embedded in the files as comments.

TOOLBAR.BAS

-----------

' Place the following code in a single text file called TOOLBAR.BAS

'

' NOTE: After copying this into a file in a text editor, modify each

' Declare statement so that each one uses only one, single line.

Option Explicit

Type POINTAPI

    X As Integer

    Y As Integer

End Type

Type ConvertPOINTAPI

    xy As Long

End Type

Declare Function Sendmessage Lib "User" (ByVal hwnd As Integer,

   ByVal wMsg As Integer, ByVal wParam As Integer,

   ByVal lParam As Any) As Long

Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)

Declare Function GetSysColor Lib "User" (ByVal nIndex As Integer) As

Long

Declare Function SetWindowWord Lib "User" (ByVal hwnd As Integer,

   ByVal Index As Integer, ByVal wNewWord As Integer) As Integer

Declare Function BitBlt Lib "GDI" (ByVal hDestDC%, ByVal X%, ByVal

Y%,

   ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal

Ysrc%,

   ByVal dwRop&) As Integer

Global Const WM_LBUTTONUP = &H202

Global Const WM_SYSCOMMAND = &H112

Global Const MOUSE_MOVE = &HF012

Global Const COLOR_APPWORKSPACE = 12

Global Const COLOR_ACTIVECAPTION = 2

Global Const COLOR_CAPTIONTEXT = 9

Global Const COLOR_GRAYTEXT = 17

Global Const DSTINVERT = &H550009   ' (DWORD) dest = (NOT dest)

Global Const GWW_HWNDPARENT = (-8)

Global ToolbarLoaded As Integer

TOOLBAR.FRM

-----------

' The following is a text dump of the TOOLBAR form. It includes the

' form

' and control description as well as necessary Function and Sub

' procedures.

' Save the code in a single TEXT file called TOOLBAR.FRM and you will

' be able to load it as a form in Visual Basic.

' NOTE: To make the code fit in this article, some of the statements

' are shown in multiple lines. Be sure to modify the lines in the text

' editor to ensure that all lines of code exist as one, single line of code

' in the file. Otherwise, you will receive errors when loading the

' form in Visual Basic.

'

' Also, this program loads some bitmaps from your Visual Basic directory.

' It assumes Visual Basic is installed in C:\VB.  If this is incorrect

' search for all the LoadPicture commands and change the path.

VERSION 2.00

Begin Form Toolbar

   ClientHeight    =   2160

   ClientLeft      =   1692

   ClientTop       =   1464

   ClientWidth     =   2928

   ControlBox      =   0   'False

   Height          =   2580

   KeyPreview      =   -1  'True

   Left            =   1644

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   180

   ScaleMode       =   3  'Pixel

   ScaleWidth      =   244

   Top             =   1092

   Width           =   3024

   Begin PictureBox Picture1

      Height          =   780

      Left            =   0

      ScaleHeight     =   756

      ScaleWidth      =   636

      TabIndex        =   1

      Top             =   0

      Width           =   660

   End

   Begin Image Image3

      Height          =   612

      Index           =   0

      Left            =   600

      Top             =   1320

      Width           =   972

   End

   Begin Image Image2

      Height          =   852

      Index           =   0

      Left            =   1680

      Top             =   480

      Width           =   852

   End

   Begin Image Image1

      Height          =   612

      Index           =   0

      Left            =   720

      Top             =   600

      Width           =   852

   End

   Begin Label Label1

      BackColor       =   &H00FFFFFF&

      Caption         =   "Label1"

      Height          =   372

      Left            =   720

      TabIndex        =   0

      Top             =   0

      Width           =   1332

   End

End

Option Explicit

Dim MDown As Integer

Dim InvertedImage As Integer

Dim OriginalParenthWnd As Integer

Dim MinHeight As Long

Dim MinWidth As Long

Sub Form_Activate ()

   If Not MDown Then parent.SetFocus

End Sub

Sub Form_Load ()

   ToolbarLoaded = True

   Me.ScaleMode = 3   ' Pixels

   picture1.ScaleMode = 3

   picture1.AutoSize = True

   ' Load the picture

   picture1.Picture = LoadPicture("C:\VB\BITMAPS\OUTLINE\MINUS.BMP")

   ' NOTE: You can load the MINUS.BMP bitmap into paintbrush and

   ' change its background color from white to gray. To do this,

   ' load the bitmap into paintbrush, and click the light gray in

   ' the color palette. Then select the paint roller icon, and

   ' click the area between the hyphen and the border to fill

   ' the area with light gray. Save it as MINUS2.BMP. If you do this,

   ' use the following statement to load the picture box:

   ' picture1.Picture =

LoadPicture("C:\VB\BITMAPS\OUTLINE\MINUS2.BMP")

   ' Get the users system color for the active window caption:

   label1.BackColor = GetSysColor(COLOR_ACTIVECAPTION)

   ' Position picturebox and label:

   picture1.Left = -1                ' Use -1 to put the controls

   picture1.Top = -1                 ' border behind the edge of

   label1.Top = -1                   ' the form.

   ' Overlap edge of label with pictu

   label1.Left = picture1.Left + picture1.Width - 1

   label1.Height = picture1.Height

   ' Load and locate the image controls:

   Call InitToolbox

   ' The guesswork on height and width could be replaced with a call

   ' to the GetSystemMetrics Windows API function to get the borderwidth

   ' of the form. Change the following two lines to one, single line:

   Me.Height =

      (picture1.Height + image1(0).Height + 12) * screen.TwipsPerPixelY

   ' Change the following two lines to one, single line:

   Me.Width =

      (image3(0).Left + image3(0).Width + 10) * screen.TwipsPerPixelX

   MinHeight = Me.Height

   MinWidth = Me.Width

   ' Set up the label:

   label1.Alignment = 2               ' Centered

   label1.BorderStyle = 1             ' Single

   label1.Caption = "Toolbar"

   ' Choose a small font or whatever looks best on your system:

   label1.FontName = "Small Fonts"

   label1.FontSize = 6

   label1.FontBold = False

   ' Use active caption color for label's caption:

   label1.ForeColor = GetSysColor(COLOR_CAPTIONTEXT)

   ' Color the background of the form to the MDI client area color:

   Me.BackColor = GetSysColor(COLOR_APPWORKSPACE)

   ' Set parent for the toolbar to display on top:

   OriginalParenthWnd = SetWindowWord(Me.hWnd, GWW_HWNDPARENT,

      parent.hWnd)

End Sub

Sub Form_Resize ()

   ' Check minimums for resize:

   If Me.Width < MinWidth Then Me.Width = MinWidth

   If Me.Height < MinHeight Then Me.Height = MinHeight

   ' Change size of label:

   label1.Width = Me.ScaleWidth - label1.Left + 1

End Sub

Sub Form_Unload (Cancel As Integer)

   Dim ret As Integer

   ' Return the original parent handle:

   ret = SetWindowWord(Me.hWnd, GWW_HWNDPARENT,

OriginalParenthWnd)

   ' Clear the global flag:

   ToolbarLoaded = False

End Sub

Sub Image1_Click (Index As Integer)

   Clipboard.SetText parent.Text1.SelText

   parent.Text1.SelText = ""

End Sub

' Change the following two lines to one, single line:

Sub Image1_MouseDown (Index As Integer, Button As Integer,

   Shift As Integer, X As Single, Y As Single)

   If Button And 1 Then

      MDown = True

      image1(0).Picture = image1(2).Picture  ' Down

   End If

End Sub

' Change the following two lines to one, single line:

Sub Image1_MouseMove (Index As Integer, Button As Integer,

   Shift As Integer, X As Single, Y As Single)

   If Button And 1 Then                ' Left button down

      X = X \ screen.TwipsPerPixelX    ' x and y are in twips

      Y = Y \ screen.TwipsPerPixelY    ' Convert to pixels

      ' Change the following two lines to one, single line:

      If (X < 0) Or (X > image1(0).Width) Or (Y < 0) Or

         (Y > image1(0).Height) Then

         image1(0).Picture = image1(1).Picture  ' Up

      Else

         image1(0).Picture = image1(2).Picture  ' Down

      End If

   End If

End Sub

' Change the following two lines to one, single line:

Sub Image1_MouseUp (Index As Integer, Button As Integer, Shift As

Integer,

   X As Single, Y As Single)

   If Button And 1 Then

      image1(0).Picture = image1(1).Picture  ' Up

      MDown = False

      parent.SetFocus

   End If

End Sub

Sub Image2_Click (Index As Integer)

   ' Code for copy he

   Clipboard.SetText parent.Text1.SelText

End Sub

' Change the following two lines to one, single line:

Sub Image2_MouseDown (Index As Integer, Button As Integer,

   Shift As Integer, X As Single, Y As Single)

   If Button And 1 Then

      MDown = True

      image2(0).Picture = image2(2).Picture  ' Down

   End If

End Sub

' Change the following two lines to one, single line:

Sub Image2_MouseMove (Index As Integer, Button As Integer,

   Shift As Integer, X As Single, Y As Single)

   If Button And 1 Then       ' Left button down

      X = X \ screen.TwipsPerPixelX

      Y = Y \ screen.TwipsPerPixelY

      ' Change the following two lines to one, single line:

      If (X < 0) Or (X > image2(0).Width) Or (Y < 0) Or

         (Y > image2(0).Height) Then

         image2(0).Picture = image2(1).Picture  'up

      Else

         image2(0).Picture = image2(2).Picture  'down

      End If

   End If

End Sub

' Change the following two lines to one, single line:

Sub Image2_MouseUp (Index As Integer, Button As Integer, Shift As

Integer,

   X As Single, Y As Single)

   If Button And 1 Then

      MDown = False

      image2(0).Picture = image2(1).Picture  ' Up

      parent.SetFocus

   End If

End Sub

Sub Image3_Click (Index As Integer)

   ' Code for paste here

   parent.Text1.SelText = Clipboard.GetText()

End Sub

' Change the following two lines to one, single line:

Sub Image3_MouseDown (Index As Integer, Button As Integer,

   Shift As Integer, X As Single, Y As Single)

   If Button And 1 Then

      MDown = True

      image3(0).Picture = image3(2).Picture  ' Down

   End If

End Sub

' Change the following two lines to one, single line:

Sub Image3_MouseMove (Index As Integer, Button As Integer,

   Shift As Integer, X As Single, Y As Single)

   If Button And 1 Then               ' Left button down

      X = X \ screen.TwipsPerPixelX   ' Convert to pixels

      Y = Y \ screen.TwipsPerPixelY

      ' Change the following two lines to one, single line:

      If (X < 0) Or (X > image3(0).Width) Or (Y < 0) Or

         (Y > image3(0).Height) Then

         image3(0).Picture = image3(1).Picture  'up

      Else

         image3(0).Picture = image3(2).Picture  'down

      End If

   End If

End Sub

' Change the following two lines to one, single line:

Sub Image3_MouseUp (Index As Integer, Button As Integer, Shift As

Integer,

   X As Single, Y As Single)

   If Button And 1 Then

      MDown = False

      image3(0).Picture = image3(1).Picture  'up

      parent.SetFocus

   End If

End Sub

Sub InitToolbox ()

   ' This procedure initializes the toolbox with three controls.

   ' Most of this could be done at design time.

   ' Load extra imagecontrol arrays

   Load image1(1)

   Load image1(2)

   Load image2(1)

   Load image2(2)

   Load image3(1)

   Load image3(2)

   ' Load the bitmaps - CHANGE PATHS AS NEEDED!!!!!

   image1(1).Picture =

LoadPicture("c:\vb\bitmaps\toolbar3\cut-up.bmp")

   image1(2).Picture =

LoadPicture("c:\vb\bitmaps\toolbar3\cut-mds.bmp")

   image2(1).Picture =

LoadPicture("c:\vb\bitmaps\toolbar3\copy-up.bmp")

   image2(2).Picture =

LoadPicture("c:\vb\bitmaps\toolbar3\copy-mds.bmp")

   image3(1).Picture =

LoadPicture("c:\vb\bitmaps\toolbar3\pste-up.bmp")

   image3(2).Picture =

LoadPicture("c:\vb\bitmaps\toolbar3\pste-mds.bmp")

   image1(0).Picture = image1(1).Picture

   image2(0).Picture = image2(1).Picture

   image3(0).Picture = image3(1).Picture

   ' Position image controls:

   image1(0).Left = 2

   image2(0).Left = image1(0).Left + image1(0).Width + 1

   image3(0).Left = image2(0).Left + image2(0).Width + 1

   image1(0).Top = label1.Height + 1

   image2(0).Top = image1(0).Top

   image3(0).Top = image1(0).Top

End Sub

' Change the following two lines to one, single line:

Sub Label1_MouseDown (Button As Integer, Shift As Integer, X As

Single,

   Y As Single)

   Dim mpos As POINTAPI

   Dim p As ConvertPOINTAPI

   Dim ret As Integer

   Call GetCursorPos(mpos)  ' Get the current position of the cursor

   LSet p = mpos            ' and convert it for API calls.

   ' Send buttonup to finish the impending buttondown. This line of

   ' code does invoke the Label1_MouseUp() event, so be careful what

   ' code you place the

   ret = Sendmessage(Me.hWnd, WM_LBUTTONUP, 0, p.xy)

   ' Tell the form someone is clicking the window caption:

   ret = Sendmessage(Me.hWnd, WM_SYSCOMMAND, MOUSE_MOVE, p.xy)

   parent.SetFocus

End Sub

Sub Picture1_MouseDown (Button As Integer, Shift As Integer, X As

Single,

                        Y As Single)

Dim ret As Integer

If Button And 1 Then      'if left button pressed

    MDown = True          'set flag and invert bitmap

    ret = BitBlt(picture1.hDC, 0, 0, picture1.ScaleWidth,

                 picture1.ScaleHeight, picture1.hDC, 0, 0, DSTINVERT)

    InvertedImage = True  'set flag for inverted bitmap

End If

End Sub

' Change the following two lines to one, single line:

Sub Picture1_MouseMove (Button As Integer, Shift As Integer, X As

Single,

   Y As Single)

   Dim ret As Integer   ' Hold return value of BitBlt

   If MDown Then

      ' If left button is down, locate where mouse is:

      ' Change the following two lines to one, single line:

      If (X < picture1.ScaleLeft) Or (X >= picture1.ScaleWidth) Or

         (Y < picture1.ScaleTop) Or (Y >= picture1.ScaleHeight) Then

         ' Outside picturebox, make sure image is normal:

         If InvertedImage Then

            picture1.Refresh

            InvertedImage = False

         End If

      Else

         ' Inside picturebox, make sure image is inverted:

         If Not InvertedImage Then

            ' Change the following two lines to one, single line:

            ret = BitBlt(picture1.hDC, 0, 0, picture1.ScaleWidth,

               picture1.ScaleHeight, picture1.hDC, 0, 0, DSTINVERT)

            InvertedImage = True

         End If

      End If

   End If

End Sub

' Change the following two lines to one, single line:

Sub Picture1_MouseUp (Button As Integer, Shift As Integer, X As

Single,

   Y As Single)

   If (Button And 1) Then        ' If left mouse

      MDown = False              ' Clear flag

      picture1.Refresh           ' Refresh image

      If InvertedImage Then      ' If over image

         InvertedImage = False   ' Clear flag

         Me.Hide                 ' Hide toolbar - faster loading next

time

      End If

   End If

   parent.SetFocus

End Sub

PARENT.FRM

----------

' The following is a text dump of the PARENT form. It includes the form

' and control description as well as necessary Function and Sub procedures.

' Save the code in a single TEXT file called PARENT.FRM and you will

' be able to load it as a form in Visual Basic.

VERSION 2.00

Begin Form Parent

   Caption         =   "Form2"

   ClientHeight    =   2724

   ClientLeft      =   1320

   ClientTop       =   1608

   ClientWidth     =   3816

   Height          =   3144

   Left            =   1272

   LinkTopic       =   "Form2"

   ScaleHeight     =   2724

   ScaleWidth      =   3816

   Top             =   1236

   Width           =   3912

   Begin CommandButton Command1

      Caption         =   "Show Toolbar"

      Height          =   372

      Left            =   840

      TabIndex        =   1

      Top             =   2160

      Width           =   1932

   End

   Begin TextBox Text1

      Height          =   1932

      HideSelection   =   0   'False

      Left            =   240

      MultiLine       =   -1  'True

      TabIndex        =   0

      Text            =   "Text1"

      Top             =   120

      Width           =   3252

   End

End

Sub Command1_Click ()

   Toolbar.Show

End Sub

Sub Form_Load ()

   Me.Caption = "Toolbar Sample"

End Sub

Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)

   If ToolbarLoaded Then

      Unload Toolbar

   End If

End Sub

How to Create and Run the Program

---------------------------------

1. Start a new project in Visual Basic. Form1 is created by default.

2. From the File menu, choose Remove File to remove Form1.

3. From the File menu, choose Add File, and add TOOLBAR.BAS

4. Repeat step 3 to add TOOLBAR.FRM and PARENT.FRM to the project.

5. From the Options menu, choose Project, and set Start Up Form to Parent.

6. Run the application.

7. The example allows the user to choose three clipboard operations

(cut, copy, and paste) from the toolbar. These operations are available

by default in a standard Visual Basic text box control but were

chosen to demonstrate the functionality of the floating toolbar.


Toolbox horiz. ide

LUOKKA: VBgen

Date: 08/26/94 (01:04)              Number: 17086 of 17164 (Refer# NONE)

From: DHUNT@INS.INFONET.NET

Subj: Re: VB Toolbox Orientatio

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <1994Aug25.134747.28752@roadie.uucp>, stever@cbis.com (S.B.

Raulerson) writes:

>Can anyone shed some light on a matter of great (in)significance?

>

>I noticed in a VB training guide I was evaluating that the Toolbox

>was in a horizontal orientation rather than the vertical one I'm

>used to. I'm curious as to how they did this since the window can't

>be resized and the Environment Options don't address it. I looked

>at the Toolbox entry in the VB.ini file and noticed some parameters

>that could be set, but I haven't been able to find an explanation

>of the parameters anywhere.

Just move it so the top four or so icons are visible at the bottom of your

screen then stop and restart VB. Until you move it back, you will have a

horizontal Toolbox instead of a vertical one.

Dave Hun


Tooltip

LUOKKA: tooltips

9717 (53+)  ajm@geac.co.nz  17.03.95  00:18

Andrew Mayo: "Re: Tooltip VB problem"

The problem is that you want the tooltip to vanish when you leave the button

client area. Unless the mouse button is held down, leaving the button client

area causes mousemove events to cease. So what you want to do is have a

timer which you continually reset during mousemoves i.e you set enabled to

false and then back to true in the mousemove event.

Now the timer will expire only if you (a) sit still for 1 second or (b)

leave the button client area.

If you also trap form mousemoves, and assuming you are putting the button

straight on the form, then as soon as you get a form mousemove you turn the

timer off and zap the tooltip. So the timer won't expire if you leave the

button client area.

When you move onto the button again, the timer will get turned back on and

when the timer expires you put up the tooltip if it isn't already visible.

I think this'll work; I have been meaning to implement tooltips this way but

haven't gotten round to it yet. Since it is off the top of my head,

apologies if I've forgotten some vital point

PS: a 3d panel is a good tooltip container because you can use zorder to

float it over anything whereas you can't do that with labels. However,

remember that the panel itself will trap any mouse events while you're over

it. In this instance, I don't *think* it'll matter because once the tooltip is up,

losing mouse events won't hide it; the form has to see a mousemove before

the tooltip vanishes. However, if your tooltip is partially over the button, then

clicking the tooltip won't click the button. You'll have to handle that - best to

keep the tooltip off the button, I'd think. Of course if you move directly from

the button to the tooltip, it won't vanish because the underlying form won't

see the mousemoves. You *could* however pass them back to the form if you

want. Remember to be nice and adjust the coordinates (which are

tooltip-relative) before doing that, if you want to use mousemoves for

anything else.

You might say, why not disable the tooltip. Unfortunately this grays the

caption - I wish CC vendors wouldn't always do this - it is sometimes very

handy to have disabled controls but *not* gray captions.


Tooltips

LUOKKA: tooltips

17995 (1+)  alan.popow@canrem.com  20.05.95  07:42

Alan Popow: "ToolTips for Visual"

<** On 05-19-95, RiCH said to ALL: **>

RR>  I have also written some tooltips code - mainly because the Knowledge

RR>  example was pretty poor - I wanted mine to 'expand' to the correct

RR>  size for the Tooltip text, which made it look a bit more slick.

RR>  The problem I had was that I couldnt get my Tooltip (this was a

RR>  label) to appear over the top of a 3D panel - it always seem to go

RR>  behind it. So positioning the Tooltip next to the mouse pointer was

RR>  resort to having the tooltip appear just below the icons/pictures,

RR>  and just use a horizontal value relative to the mouse pos - pathetic

I posted this once before, but never heard anything one way or t'other; so

either it works for others too, or it's junk, but it really does work for

me pretty well.

First I create picture box called 'ToolTip' to act as the tooltip with

yellow background, and visible set to false. I use a picture box so that

Zorder works properly. I put the text for the tooltip in the control's tag

property.

In my funcs.bas I have a sub called ToolTips as follows:

(The 40 twips is pretty arbitrary, but it seems to be reasonable for my

purposes.)

===============================

Sub ToolTips (Frm As Form, Ctl As Control, OnOff As Integer)

 If OnOff Then  ' turn on the tooltip

   Frm.ToolTip.Cls ' clear it first

   Frm.ToolTip.Print " " & Ctl.Tag & " "   ' get the tag property

   Frm.ToolTip.Width = Frm.ToolTip.TextWidth(Ctl.Tag & "  ") ' set width

   ' make sure tooltip displays properly above or below, to the left or

   ' right depending on location of control

   If Ctl.Top + Ctl.Height + Frm.ToolTip.Height + 40 < Frm.ScaleHeight

Then

      Frm.ToolTip.Top = Ctl.Top + Ctl.Height + 40

   Else

      Frm.ToolTip.Top = Ctl.Top - Frm.ToolTip.Height - 40

   End If

   If Ctl.Left + Frm.ToolTip.Width < Frm.ScaleWidth Then

      Frm.ToolTip.Left = Ctl.Left

   Else

      Frm.ToolTip.Left = Ctl.Left - Frm.ToolTip.Width + Ctl.Width

   End If

   Frm.Timer1.Enabled = True   ' timer controls when to actually display

it

 Else

   Frm.ToolTip.Visible = False ' turn it off

   Frm.ToolTip.ZOrder 1     ' move it to the back (not really necessary)

   Frm.Timer1.Enabled = False  ' turn off the timer

 End If

End Sub

==================================

In the timer on the form, I have:

==================================

Sub Timer1_Timer ()

      ToolTip.Visible = True ' show it

      ToolTip.ZOrder 0          ' move it to the front of the pack

      Timer1.Enabled = False

End Sub

==================================

In the MouseMove event of any control for which I want the tooltip to

show, I call the tooltip sub with:

   ToolTips Me, Command1, True

(Command1 will actually be the name of the control itself)

In the Form.MouseMove I have the opposite ( I also have it in any control

for which I don't want a tooltip if it abuts the ones where I do)

   ToolTips Me, ToolTip, False

(in the Else portion - the 'off' code - of the ToolTips sub, the control

is not used, so I just send a control name - ie 'ToolTip' so it doesn't

choke on the call).

I also use the above False call in the control click event so it turns off

(at least momentarily) if the control is clicked.

Except for the fact that I always feel like I've forgotten something and

that formatting vb code with the restriction of screen width for the

newsgroup makes it look like the pits, that's about it, and it does seem

to work satisfactorily.

Alan                  email: alan.popow@canrem.com


Tooltips capture mouse

LUOKKA: tooltips

Date:         Tue, 9 Aug 1994 09:40:00 CET

From:         Titov Pavel <titov@NEPO1.IAEA.OR.AT>

Subject:      Capturing mouse messages  XE "Capturing mouse messages"

You can easily do it using a timer.

Type POINTAPI

    x As Integer

    y As Integer

End Type

Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)

Declare Function WindowFromPoint Lib "user" (ByVal lpPointY As Integer,

ByVal lpPointX As Integer) As Integer

Declare Function GetActiveWindow Lib "User" () As Integer

 ----------------------

Sub Timer1_Timer ()

    Dim curhWnd As Integer      'Current hWnd

    Dim p As POINTAPI

    Static LasthWnd As Integer  'Hold previous hWnd

    If GetActiveWindow() = Me.hWnd Then

        ' Initialize point structu

        Call GetCursorPos(p)

        ' Which window is the mouse cursor over?

        curhWnd = WindowFromPoint(p.y, p.x)

        ' Same as last window? If so, don't need to redraw:

        If curhWnd <> LasthWnd Then

        ' Store the current hWnd:

        LasthWnd = curhWnd

        ' Decrease timer interval to 5 ms (could choose 1 ms):

        Timer1.Interval = 5

        ' Which control is the cursor over?

        Select Case curhWnd

            Case Image1(0).hWnd

                DisplayHelp "Cut"

            Case Image2(0).hWnd

                DisplayHelp "Copy"

            Case Image3(0).hWnd

                DisplayHelp "Paste"

            Case frmHelp.hWnd

                ' If it moves onto the help window, hide it:

                frmHelp.Hide

            Case Else

                ' Cursor is over the form or something else, so

                ' change interval back to 1 sec delay:

                DisplayHelp ""

                Timer1.Interval = 1000

        End Select

        End If

    End If

end sub


Tooltips demo

LUOKKA: tooltips

Date: 03-07-95 (22:01)              Number: 248956 of 251087 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: TooLTips Code

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

         '****** FORM1.FRM

         VERSION 2.00

         Begin Form Form1

            Caption         =   "Tool Tips Demo"

            ClientHeight    =   3510

            ClientLeft      =   3585

            ClientTop       =   1740

            ClientWidth     =   2940

            Height          =   3915

            Left            =   3525

            LinkTopic       =   "Form1"

            ScaleHeight     =   3510

            ScaleWidth      =   2940

            Top             =   1395

            Width           =   3060

            Begin Timer Timer1

               Interval        =   1000

               Left            =   2160

               Top             =   3000

            End

    Begin CheckBox Check1

               Caption         =   "Check1"

               Height        255

               Left            =   240

               TabIndex        =   5

               Top             =   3120

               Width           =   1215

            End

            Begin Frame Frame1

               Caption         =   "Frame1"

               Height          =   1215

               Left            =   600

               TabIndex        =   2

               Top             =   1680

               Width           =   1815

               Begin OptionButton Option2

                  Caption         =   "Option2"

                  Height          =   255

                  Left            =   240

                  TabIndex        =   4

                  Top             =   840

                  Width           =   1215

               End

               Begin OptionButton Option1

                  Caption         =   "Option1"

                  Height          =   255

                  Left            =   240

                  TabIndex        =   3

                  Top             =   360

                  Width           =   1335

               End

            End

            Begin CommandButton Command1

               Caption         =   "Command1"

               Height          =   375

               Left            =   600

               TabIndex        =   1

               Top             =   960

               Width           =   1815

            End

            Begin TextBox Text1

               Height          =   375

               Left            =   600

               TabIndex        =   0

               Text            =   "Text1"

               Top             =   360

               Width           =   1695

            End

         End

         Option Explicit

         Sub Command1_Click ()

             ShowTT " "

             Timer1.Interval = 1000

         End Sub

         Sub Timer1_Timer ()

             Dim CurhWnd, LasthWnd As Integer

             Dim P As POINTAPI

             Dim NL As String

             NL$ = Chr$(13) + Chr$(10)

             Static LastWnd As Integer

             If GetActiveWindow() = Form1.hWnd Then

                 Call GetCursorPos(P)

                 CurhWnd = WindowFromPoint(P.Y, P.X)

                 If CurhWn?>+ayd <> LastWnd Then

                     LasthWnd = CurhWnd

                     Timer1.Interval = 1

                     Select Case CurhWnd

                         Case text1.hWnd

                             ShowTT "This is" + NL$ + "a text box"

                         Case command1.hWnd

                             ShowTT "This is" + NL$ + "a command"

                         Case option1.hWnd

                             ShowTT "This is" + NL$ + "a option 1"

                         Case option2.hWnd

                             ShowTT "This is" + NL$ + "a option 2"

                         Case check1.hWnd

                             ShowTT "This is" + NL$ + "a check box"

                         Case Else

                             ShowTT ""

                             Timer1.Interval = 1000

                     End Select

                 End If

             End If

         End Sub

         '-- End of Form 1

         '****   TOOLTIPS.FRM

         VERSION 2.00

         Begin Form ToolTips

            BorderStyle     =   1  'Fixed Single

            Caption         =   "80B Demo"

            ClientHeight    =   1005

            ClientLeft      =   3180

            ClientTop       =   3300

            ClientWidth     =   2535

            ControlBox      =   0   'False

            Height          =   1410

            Left            =   3120

            LinkTopic       =   "Form2"

            MaxButton       =   0   'False

            MinButton       =   0   'False

            ScaleHeight     =   1005

            ScaleWidth      =   2535

            Top             =   2955

            Width           =   2655

            Begin Label Label1

               Caption         =   "Label1"

               FontBold        =   0   'False

               FontItalic      =   0   'False

               FontName        =   "Arial"

               FontSize        =   8.25

               FontStrikethru  =   0   'False

               FontUnderline   =   0   'False

               Height          =   375

               Left            =   240

               TabIndex        =   0

               Top             =   240

               Width           =   2175

            End

         End

         Option Explicit

         Sub Form_Load ()

             ToolTips.Caption = ""

             ToolTips.BackColor = &H80FFFF

             label1.BackColor = &H80FFFF

             label1.Left = 1 * screen.TwipsPerPixelX

             label1.Top = 0

         End Sub

         '-- End of ToolTips.Frm

         '****  TT.BAS

         Type POINTAPI

             X As Integer

             Y As Integer

         End Type

         Declare Function ShowWindow% Lib "user" (ByVal Handle As Integer,

         ByVal Cmd As Integer)

         Declare Sub GetCursorPos Lib "user" (lpPoint As POINTAPI)

         Declare Function GetActiveWindow Lib "user" () As Integer

         Declare Function WindowFromPoint Lib "user" (ByVal lpPointY As

         Integer, ByVal lpPointX As Integer) As Integer

         Declare Function ShowWindow Lib "user" (ByVal hWnd As Integer,

         ByVal Cmd As Integer) As Integer

         'Declare Function WinHelp Lib "User" (ByVal hWnd, ByVal HelpFile$,

         ByVal wCommand, ByVal dwData As Long) As Integer

         Declare Function WritePrivateProfileString Lib "Kernel" (ByVal

         Appname As String, ByVal KeyName As String, ByVal NewString As

         String, ByVal FileName As String)

         Global Const SW_SHOWNOACTIVATE = 4

         Sub ShowTT (Help$)

             Dim lpPoint As POINTAPI

             Dim ret As Integer

             If Len(Help$) <> 0 Then

                 ToolTips.Hide

                 ToolTips.Label1.Caption = Help$

                 Call GetCursorPos(lpPoint)

                 ToolTips.Top = (lpPoint.Y + 18) * screen.TwipsPerPixelY

                 ToolTips.Left = (lpPoint.X - 2) * screen.TwipsPerPixelY

                 ToolTips.Width = ToolTips.Label1.Width + (4 *

         screen.TwipsPerPiexlX)

                 ToolTips.Height = ToolTips.Label1.Height + (2 *

         screen.TwipsPerPixelX)

                 ToolTips.ZOrder

                 ret = ShowWindow(ToolTips.hWnd, SW_SHOWNOACTIVATE)

             Else

                 ToolTips.Hide

             End If

         End Sub

         '-- End of tt.bas


Tooltips sample

LUOKKA: tooltips

Date: 04/06/94 (10:40)              Number: 2760 of 2790 (Refer# NONE)

  To: ALL

From: RAMI.RASANEN@P1.F73.N369.Z1.FIDONET.ORG

Subj: Sample Toolbar

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Here's a sample "tooltips" app, which uses labels to "simulate" the

appearance of "tooltips" as the mouse moves over the control.

VERSION 2.00

Begin Form frmDetailGrid

   BackColor       =   &H00C0C0C0&

   BorderStyle     =   1  'Fixed Single

   Caption         =   "Detail Grid (Typical)"

   ClientHeight    =   5436

   ClientLeft      =   540

   ClientTop       =   1692

   ClientWidth     =   8640

   Height          =   6156

   Left            =   504

   LinkTopic       =   "Form1"

   ScaleHeight     =   5436

   ScaleWidth      =   8640

   Top             =   1008

   Width           =   8712

   Begin SSRibbon gpbSaveData

      AutoSize        =   0  'None

      Height          =   375

      Left            =   2445

      PictureDisabled =   T.FRX:0000

      PictureUp       =   T.FRX:0322

      Top             =   45

      Width           =   375

   End

   Begin SSRibbon GroupPush3D7

      AutoSize        =   0  'None

      Height          =   375

      Left            =   2805

      PictureUp       =   T.FRX:0414

      Top             =   45

      Width           =   375

   End

   Begin SSRibbon gpbAttachment

      AutoSize        =   0  'None

      Height          =   375

      Left            =   1605

      PictureDisabled =   T.FRX:055A

      PictureUp       =   T.FRX:087C

      Top             =   45

      Width           =   375

   End

   Begin SSRibbon GroupPush3D5

      AutoSize        =   0  'None

      Height          =   375

      Left            =   1125

      PictureUp       =   T.FRX:096E

      Top             =   45

      Width           =   375

   End

   Begin SSRibbon gpbSendMail

      AutoSize        =   0  'None

      Height          =   375

      Left            =   1965

      PictureDisabled =   T.FRX:0AB4

      PictureUp       =   T.FRX:0DD6

      Top             =   45

      Width           =   375

   End

   Begin SSRibbon GroupPush3D4

      AutoSize        =   0  'None

      Height          =   375

      Left            =   765

      PictureUp       =   T.FRX:0EF8

      Top             =   45

      Width           =   375

   End

   Begin SSRibbon GroupPush3D1

      AutoSize        =   0  'None

      Height          =   375

      Left            =   45

      PictureUp       =   T.FRX:103E

      Top             =   45

      Width           =   375

   End

   Begin SSRibbon GroupPush3D2

      AutoSize        =   0  'None

      Height          =   375

      Left            =   405

      PictureUp       =   T.FRX:1184

      Top             =   45

      Width           =   375

   End

   Begin SSPanel Panel3D1

      Height          =   480

      Left            =   -15

      TabIndex        =   0

      Top             =   0

      Width           =   9015

   End

   Begin Grid grdMPS

      BackColor       =   &H00FFFFFF&

      Cols            =   14

      FixedCols       =   2

      Height          =   4095

      Left            =   120

      Rows            =   20

      TabIndex        =   9

      Top             =   1200

      Width           =   8350

   End

   Begin Label Label1

      BackStyle       =   0  'Transparent

      Caption         =   "1991 Product Sales for Beverages Division"

      FontBold        =   -1  'True

      FontItalic      =   0   'False

      FontName        =   "Arial"

      FontSize        =   15

      FontStrikethru  =   0   'False

      FontUnderline   =   0   'False

      Height          =   375

      Left            =   1200

      TabIndex        =   10

      Top             =   720

      Width           =   6255

   End

   Begin Label lblExit

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Finished"

      Height          =   255

      Left            =   2820

      TabIndex        =   7

      Top             =   510

      Visible         =   0   'False

      Width           =   780

   End

   Begin Label lblSaveData

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Save Data"

      Height          =   255

      Left            =   2460

      TabIndex        =   6

      Top             =   510

      Visible         =   0   'False

      Width           =   1005

   End

   Begin Label lblSendMail

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Send Mail"

      Height          =   255

      Left            =   1980

      TabIndex        =   5

      Top             =   510

      Visible         =   0   'False

      Width           =   915

   End

   Begin Label lblAttachment

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Attachment"

      Height          =   255

      Left            =   1620

      TabIndex        =   3

      Top             =   510

      Visible         =   0   'False

      Width           =   1005

   End

   Begin Label lblDetail

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Detail"

      Height          =   255

      Left            =   1140

      TabIndex        =   4

      Top             =   510

      Visible         =   0   'False

      Width           =   540

   End

   Begin Label lblProductSales

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Product Sales"

      Height          =   255

      Left            =   780

      TabIndex        =   8

      Top             =   510

      Visible         =   0   'False

      Width           =   1245

   End

   Begin Label lblDivisionSales

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Division Sales"

      Height          =   255

      Left            =   420

      TabIndex        =   2

      Top             =   510

      Visible         =   0   'False

      Width           =   1245

   End

   Begin Label lblMonthlySales

      BackColor       =   &H0080FFFF&

      BorderStyle     =   1  'Fixed Single

      Caption         =   "Monthly Sales"

      Height          =   255

      Left            =   60

      TabIndex        =   1

      Top             =   510

      Visible         =   0   'False

      Width           =   1245

   End

   Begin Line Line2

      X1              =   0

      X2              =   9120

      Y1              =   480

      Y2              =   480

   End

   Begin Menu mnuFileMain

      Caption         =   "&File"

   End

   Begin Menu mnuEditMain

      Caption         =   "&Edit"

   End

   Begin Menu mnuViewMain

      Caption         =   "&View"

      Begin Menu mnuViewBtnBar

         Caption         =   "&Button Bar Form"

      End

      Begin Menu mnuViewToolbar

         Caption         =   "&Toolbar Form"

      End

      Begin Menu mnuViewSmallToolbar

         Caption         =   "&Small Toolbar"

      End

   End

   Begin Menu mnuHelpMain

      Caption         =   "&Help"

   End

End

Option Explicit

Sub Form_Load ()

   'Purpose: Dimension and add data to a grid control

   'Declare the required object and conventional variables

   Dim dsMPS As Dynaset

   Dim qdfMPS As QueryDef

   Dim strSQL As String

   Dim strCategory As String

   Dim intCol As Integer

   Dim intRow As Integer

   'Add the column headers to the grid (Product ID, Product Name, and

months)

   grdMPS.Row = 0

   For intCol = 0 To 13

      grdMPS.Col = intCol

      If intCol = 0 Then

         'Product ID column

         grdMPS.Text = "ID"

         grdMPS.ColWidth(intCol) = 300

         grdMPS.FixedAlignment(intCol) = 1

      ElseIf intCol = 1 Then

         'Product Name column

         grdMPS.Text = "Product Name"

         grdMPS.ColWidth(intCol) = 2000

         grdMPS.FixedAlignment(intCol) = 0

      Else

         '12 monthly data columns

         grdMPS.Text = strMonths(intCol - 1, 1)

         grdMPS.ColWidth(intCol) = 742

         grdMPS.FixedAlignment(intCol) = 2

         grdMPS.ColAlignment(intCol) = 1

      End If

   Next intCol

   'Open the QueryDef and provide the value of the CategID parameter

   Set qdfMPS =

dbDecSupport.OpenQueryDef("qryMonthlyProductSalesParam")

   qdfMPS!CategID = "BEVR"

   'Create the Dynaset object to supply data for the grid

   Set dsMPS = qdfMPS.CreateDynaset()

   dsMPS.MoveLast

   'Set the vertical dimensions of the grid control

   grdMPS.Rows = dsMPS.RecordCount + 1

   grdMPS.Height = grdMPS.RowHeight(0) * grdMPS.Rows + 460

   'Don't exceed the space available on the form

   If grdMPS.Height > 4095 Then

      grdMPS.Height = 4095

   End If

   'Add the data from the Dynaset object to the grid

   intRow = 1

   dsMPS.MoveFirst

   Do Until dsMPS.EOF

      'Process one record at a time

      For intCol = 0 To 13

         'The table data is arranged in rows of columns

         grdMPS.Row = intRow

         grdMPS.Col = intCol

         If Not IsNull(dsMPS.Fields(intCol)) Then

            'Attempting to insert Null values causes an error

            If intCol > 1 Then

               grdMPS.Text = Format(CCur(dsMPS.Fields(intCol)), "#,##0")

            Else

               grdMPS.Text = dsMPS.Fields(intCol)

            End If

         End If

      Next intCol

      dsMPS.MoveNext

      intRow = intRow + 1

      DoEvents

   Loop

   dsMPS.Close

   qdfMPS.Close

End Sub

Sub gpbAttachment_MouseMove (Button As Integer, Shift As Integer, X As

Single,

Y As Single)

   Call HideLabels

   lblAttachment.Visible = True

End Sub

Sub gpbSaveData_MouseMove (Button As Integer, Shift As Integer, X As

Single, Y

As Single)

   Call HideLabels

   lblSaveData.Visible = True

End Sub

Sub gpbSendMail_MouseMove (Button As Integer, Shift As Integer, X As

Single, Y

As Single)

   Call HideLabels

   lblSendMail.Visible = True

End Sub

Sub GroupPush3D1_Click (Value As Integer)

   frmButtonBar.Show

   DoEvents

   frmDetailGrid.Hide

End Sub

Sub GroupPush3D1_MouseMove (Button As Integer, Shift As Integer, X As

Single,

Y As Single)

   Call HideLabels

   lblMonthlySales.Visible = True

End Sub

Sub GroupPush3D2_Click (Value As Integer)

   frmToolbar.Show

   DoEvents

   frmDetailGrid.Hide

End Sub

Sub GroupPush3D2_MouseMove (Button As Integer, Shift As Integer, X As

Single,

Y As Single)

   Call HideLabels

   lblDivisionSales.Visible = True

End Sub

Sub GroupPush3D4_Click (Value As Integer)

   frmSmallToolbar.Show

   DoEvents

   frmDetailGrid.Hide

End Sub

Sub GroupPush3D4_MouseMove (Button As Integer, Shift As Integer, X As

Single,

Y As Single)

   Call HideLabels

   lblProductSales.Visible = True

End Sub

Sub GroupPush3D5_Click (Value As Integer)

   'Enable Attachment, Send Mail and Save Data buttons

   frmSmallToolbar!gpbAttachment.Enabled = True

   frmSmallToolbar!gpbSendMail.Enabled = True

   frmSmallToolbar!gpbSaveData.Enabled = True

End Sub

Sub GroupPush3D5_MouseMove (Button As Integer, Shift As Integer, X As

Single,

Y As Single)

   Call HideLabels

   lblDetail.Visible = True

End Sub

Sub GroupPush3D7_Click (Value As Integer)

   End

End Sub

Sub GroupPush3D7_MouseMove (Button As Integer, Shift As Integer, X As

Single,

Y As Single)

   Call HideLabels

   lblExit.Visible = True

End Sub

Sub HideLabels ()

   'Hide the MouseMove labels

   lblMonthlySales.Visible = False

   lblDivisionSales.Visible = False

   lblProductSales.Visible = False

   lblDetail.Visible = False

   lblAttachment.Visible = False

   lblSendMail.Visible = False

   lblSaveData.Visible = False

   lblExit.Visible = False

End Sub

Sub lblProductSales_MouseMove (Button As Integer, Shift As Integer, X As

Single, Y As Single)

   lblProductSales.Visible = True

End Sub

Sub lblSaveData_MouseMove (Button As Integer, Shift As Integer, X As

Single, Y

As Single)

   lblSaveData.Visible = True

End Sub

Sub mnuViewBtnBar_Click ()

   frmButtonBar.Show

End Sub

Sub mnuViewSmallToolbar_Click ()

   frmSmallToolbar.Show

End Sub

Sub mnuViewToolbar_Click ()

   frmToolbar.Show

End Sub

Sub Panel3D1_MouseMove (Button As Integer, Shift As Integer, X As Single,

Y As

Single)

   Call HideLabels

End Sub

....Damn the documentation, full speed ahead!


Tooltips sample

LUOKKA: tooltips

============================================================

Date:         Wed, 21 Sep 1994 09:00:43 -0400

From:         Scott Seighman <sseighma@CLEVELAND.MR.COM>

Subject:      Flashing Icons.....

I have an application which ultilizes a tooltip (those little yellow boxes used

in MS-Word, etc.). I have some bitmaps in a 'toolbar' which reveal the 'box'

when the mouse is moved over the bitmaps.  My problem is the 'toolbar' and

it's bitmaps "flash" when I move from one to another.  I recall seeing

something on this list recently about this same quirk.  Could some one refresh

my memory?

By the way, I use the mousemove event to trigger the 'tooltip':

I've set up an Index of Images (MouseMove), and use the following code:

Dim OldTip

If OldTip = Index Exit Sub

 Tooltip.Caption = Image1(Index).Tag

 Tooltip.Move Image1(Index).Left + Image1(Index).Height * .2,

Image1(Index).Top +

 Image1(Index).Height * 1.1

 ToolTip.Visible = True

End Sub

In the Form (MouseMove)I use this method to hide the tooltip:

 OldTip = -1

 ToolTip.Visible = False

-----------------------------------------------------------------------------

Scott Seighman

CyberAccess, Inc.

sseighma@cleveland.mr.com


Transparent

LUOKKA: forms

Date: 08/17/94 (03:16)              Number: 15897 of 15901 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: A transparent form??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If you know where your form is to be positioned you could BitBlt the

background (the current desktop contents) in the form before showing it.

Small example:

' look these up the in Win api helpfile

Declare Function GetDC(...)

Declare Sub ReleaseDC(...)

Declare Function BitBlt(...)

Const SRCCOPY = ...

Sub Form_Load

Dim hDC as Integer

    Me.AutoRedraw = TRUE

    ' Get a handle to the Desktop

    hDC = GetDC(NULL)

    ' Bitblit the desktop to the form

    iRes = BitBlt(Me.hDC, 0, 0, hDC, Me.Left/Screen.TwipsPerPixelX,

      Me.Top/Screen.TwipsPerPixelY, Me.Width/Screen.TwipsPerPixelX,

      Me.Height/Screen.TwipsPerPixelY, SRCCOPY)

    Me.AutoRedraw = FALSE

    Me.Show

End Sub

--

Arjen Broeze                                   Telephone: (+31)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13


Trap alt + F4

LUOKKA: VBgen

Date: 07-05-95 (07:46)              Number: 379274 of 379770 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: How do I trap ALT+F4???

From: Alan Roberts <aroberts@UNIWA.UWA.EDU.AU>

> I'm writing a program that displays a notice when the user clicks on

> "EXIT".  But the problem is that if they just hit ALT+F4, the program

> will quit without displaying that notice.  How can I trap ALT+F4 and

> then make the  program display the notice before quitting?

You need to use the forms QueryUnload event.  This event is triggered

whenever a form is sent a message to unload.  The event provides you

with 2 arguments 1) - Cancel (setting this to true ie Cancel=True) will

abort the unloading 2) - UnloadMode (this tells you what triggered

the unload eg Alt F4 or close from the command menu, code, windows

session ending etc).  You should place any code you need for

displaying your message in this (or the form unload) event.  The

advantage of placing it in this event is that you can check the

reason for the unload and display an appropriate message only when

necessary.

Good Luck

Alan Roberts

Zoology Dept

UWA

Australia

------------------------------------------

Date: 07-05-95 (10:09)              Number: 379333 of 379770 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: How do I trap ALT+F4???

From: Keith Baugher <s077962@JAGUAR1.USOUTHAL.EDU>

Set your form KeyPreview to True

In your Form_KeyDown event, check for the following. . .

If Shift = 4 Then 'user pressed Alt

   If KeyCode = 11 Then 'user also pressed F4 key

      'DisplayExitScreen

      ' or completly disable Alt+F4

      'KeyCode = 0

      'Shift = 0

   End If

End If

Keith Baugher

s077962@jaguar1.usouthal.edu


Trap alt + tab

LUOKKA: VBgen

22469 (15+)  dscabra@gulf.net  26.06.95  18:45

"David S. Cabral": "Re: How do intercept/disable the ÄALTÅ+ÄTABÅ

feature??"

 I wrote a network login program that obviously needed to prevent

fast-switching. I tried several things before coming up with the following

solution.  Make sure the keyPreview property is turned on for the form and

then do something like this:

Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)

'This routine detects the pressing of the keyboard modifyers

'and prevents their use while this program is running.  This

'is necessary to prevent the user from bypassing this

'program by using the fast switching capabilities of

'Windows - ie. Alt+Tab to switch to the next application.

    Const KEY_ESCAPE = &H1B        'Visual Basic constants

    Const KEY_TAB = &H9

    Const KEY_SHIFT = &H10

    Const KEY_CONTROL = &H11

    Const SHIFT_MASK = 1

    Const CTRL_MASK = 2

    Const ALT_MASK = 4

'If the user attempts to use any of these key combinations,

'make an entry in the audit log.

Start:

  If KeyCode = KEY_ESCAPE Or KeyCode = KEY_TAB Or KeyCode =

KEY_SHIFT Or

KeyCode =

KEY_CONTROL Then

    CheckLog$ = Dir$(App.Path & "Öaudit.log")

    If CheckLog$ <> "" Then

      Open App.Path & "ÖAudit.log" For Append As #1

      Write #1, Text1.Text, Date$, Time$, "Attempted to bypass Winlogin."

      Close #1

    Else

      Open "c:ÖwinloginÖAudit.log" For Output As #1

      Write #1, Text1.Text, Date$, Time$, "Attempted to bypass Winlogin."

      Close #1

    End If

    KeyCode = 0

    GoTo Start

  End If

  KeyCode = 0

End Sub

Dave Cabral

P.S. - If you would like a copy of my SHAREWARE program, please let me

know.


Trap alt + tab

LUOKKA: VBgen

Date: 07-05-95 (23:44)              Number: 379878 of 380561 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: disabling alt + tab

From: Al Balzowski <AlBal@IX.NETCOM.COM>

>        Is there a way to disable alt + tab in the form's keydown event ?.

>    I can detect any other combination except this one. I want to prevent

>    the user from alt-tabbing to a dos program which causes conflicts

>    with my vb app.

In the Windows section of WIN.INI there is a line "CoolSwitch=x."

A value of 1 enables ALT-TAB, and 0 disables it. By modifying this value

from your application you can change its behavior as you wish.

                      _/_/  Alphonse Balzowski  _/_/

                    _/_/  AlBal@ix.netcom.com _/_/


TT-fonts install

LUOKKA: DDE

Date: 01/04/95 (09:43)              Number: 31548 of 31612 (Refer# NONE)

From: GRAHAM.IRONS@EAGLE.ASSTDC.COM.AU, Graham Irons

Subj: Install TT fonts using VB???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

JC>nguyentu@aspen.uml.edu wrote:

JC>: I've just started to learn VB for Windows by myself, and I want to wr

JC>: program that will install new TT fonts for Windows so that they will

JC>: effective immediately (just like you install them from the Control Pa

JC>Well, I haven't tried this, but it looks like you should try using DDE

JC>between your app and control panel, so that you *are* installing them

JC>through the control panel.  I assume that you can handle the actual

JC>copying across alright.

I didn't know that Control Panel supported DDE!

Use the CreateScaleableFontResource and AddFontResource APIs and then

SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0).

Regards, Graham.

CIS# 100033,3647

FidoNet @3:712/704

INTERNET:girons@ozemail.com.au

INTERNET:graham.irons@eagle.asstdc.com.au


Undo

LUOKKA: VBgen

14.How do I implement Undo?

   For most controls, you will have to keep track of changes yourself.

   There's no magic involved, just some coding. However, if you use

   the standard Text box or Combo box, Windows provides a "free" undo

   function for you!

     'Do the following declares:

     Declare Function SendMessage Lib "User" (ByVal hWnd As

     "Integer, ByVal wMsg As Integer, ByVal wParam As

     "Integer, lParam As Any) As Long

     Global Const WM_USER = &h400

     Global Const EM_UNDO = WM_USER + 23

     'And in your Undo Sub do the following:

     UndoResult = SendMessage(myControl.hWnd, EM_UNDO, 0, 0)

     'UndoResult = -1 indicates an error.


Variant

LUOKKA: coding

4. Is the Variant type slower than using other variable types?

   Generally, yes, if we are talking numeric variable types. The

   Variant type also increases memory overhead. To test the speed

   difference, try the following piece of code in something like a

   button_click event and keep the debug window on the screen:

     Dim Va As Variant

     Dim In As Integer

     T1! = Timer

     For i% = 1 To 32766

       Va = i%

     Next i%

     T2! = Timer

     Debug.Print "With variant:  "; Format$((T2! - T1!), "0.0000")

     T1! = Timer

     For i% = 1 To 32766

       In = i%

     Next i%

     T2! = Timer

     Debug.Print "With integer:  "; Format$((T2! - T1!),"0.0000")

   This test shows (on our test system) that integers are ~60% faster!

   However, for strings there where no real difference, or in some

   instances, variants were faster than strings for routines with

   heavy conversion usage. For the best result in your application,

   test your routines directly.


VB .Frm to .Rc

LUOKKA: VBgen

Date: 12/14/94 (09:28)              Number: 152907 of 153328 (Refer# NONE)

Subj: Translate .FRM to .RC

From: Brian Larson <BL7385@ISOA.SBC.COM>

Subject: Translate .FRM to .RC

>     Does anyone know of an app that will take VB .FRM files (in text

>     format, of course!), and translate them into .RC format so that

>     Borland C++ or MSVC++ could understand them?

Sheridan's VB Assist can do this.  Their number is (516) 753-0985.  VB Assist

goes for a little over $100, but it has many other things which make it worth

every penny (IMHO).

                                        --Brian

bl7385@isoa.sbc.com


VB 2 copies VB

LUOKKA: VBgen

Date: 02-22-95 (04:22)              Number: 229599 of 231964 (Refer# NONE)

From: AF02@CITYSCAPE.CO.UK

Subj: Two copies of VB on One Computer!!

If you copy VB.EXE to VB2.EXE, you can run two copies of Visual

basic at the same time.

I know it's very confusing, but it does give you the ability to

investigate one project and copy routines to another.

The question is, is it safe!

If this is OK, then my program VB Launch (was VB Runner) could do

the copy and then open the second project. Yesterday's offer still

holds!

James Miller

Daisy@CityScape.co.uk


VB 4.0

LUOKKA: VBgen

Date: 07-06-95 (21:15)              Number: 380715 of 381583 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: VB4 - all is revealed

From: Cyberia1 London <cybercafe@EASYNET.CO.UK>

I have got a copy of VB4 without signing any NDA, so here we go...

Good news and bad: new features such as objects (sort of), but need

to carefully check VB3 code as there are quite a few incompatiblities.

It comes on 1 CD or 17 floppies (using the new DMF format) Has "class

modules", you can create your own classes or add custom properties to form

and class modules.

There is a Collection object - an ordered group of items.

32-bit support, extended filenames.

Conditional compilation, using #const (equiv to #define in C)

#if ... then

#else

#endif

New bound controls: list box, combo box and grid

Uses the Jet 2.5 engine: allows cascading updates & deletes

The name of the project file has changed from .MAK to .VBP, this

is a great help to C/C++ developers with associations in File Manager.

New controls: Tabbed control.

There is supposed to be an RTF text box with drag and drop capabilities,

but I have not been able to find it. Does anyone know where it is?????

The ! symbol can no longer be used to access properties as in VB3.

It now provides access to members of a collection.

There is now a line continuation character _ (underscrore), however this

cannot be used within a string literal. Great that massively long lines

are no longer required :-)

I can't work out how to modify the default project. In VB3, you just

changed autoload.mak, in VB4 there is an equivalent called auto16ld.vbp

but changing this doesn't seem to help. Any ideas ????????

In answer to a recent question regarding a problem someone had with

mscomm in VB4: try loading the new comms control MSCOMM16.OCX instead.

The DIM statement still requires a separate "as type" for each variable.

Feel free to post questions and I will try to answer them when I can.

Zach

Date: 07-12-95 (21:42)              Number: 385896 of 386776 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: VB4 - more details and answers

From: Cyberia9 London <cybercafe@EASYNET.CO.UK>

More VB4 info for whoever wants it....

Pat Martin asks if Cascading Update/Delete is already in VB3/Jet 2.0.

Whoops, yes. I missed that one!

He also asked if Referential Integrity errors are reported back in VB4 with

Jet 2.5: Nope. No error is generated. In fact, even the RecordsAffected

property is wrong!

-----------------------------------------------

Don Shelman asks "Native compiler?"

If by this you mean are VB4 exe's compiled rather than interpreted, then yes.

-----------------------------------------------

Ian Ornstein asks "Has it got a global error handler...?"

Nope. Doesn't seem to be any change from VB3.

-----------------------------------------------

Further observations/notes:

You are no longer supposed to use the OpenDatabase() function. Instead you

should use the OpenDatabase method on the Workspace object, although

the function is still supported for backward compatibility.

-----------------------------------------------

The MsgBox function now has 2 more parameters: helpfile and context_id

-----------------------------------------------

VB4 gives symbolic names to modules now (in VB3 only forms had a name

property). This can be a *big* compatibility problem if you have a function

with the same name as the module it is in (eg. function foo() in module

foo.bas) because the VB4 compiler gives the error message that the function

name refers to a module name: "Expected variable or procedure, not

module".

To fix this, you have to open a code window for the module, and then switch

to the Properties window to change the Name property of the module! What a

pain if you have lots of these!!!

-----------------------------------------------

When forms are saved as text, the version is now correctly stated as 4.00

(in VB3 it said 2.00)

-----------------------------------------------

Background color for labels is grey - this has led to a lot of work

correcting the color for all labels on all my screens. Baaahhh !!!!!

-----------------------------------------------

Speed relative to VB3:

Okay, this may be slightly unfair as it is only in beta....BUT:

In debug (within the IDE)                 VB3          VB4

Time from pressing F5 to first screen   11 secs     147 secs*

Time from first to second screen        13 secs      48 secs

* this is because it first loads all modules, then compiles, then starts the

debug sesion, then ....... yawn!!!

I don't think I will be using VB4 for vital projects just yet !

Certainly not when I am in a hurry!

-----------------------------------------------

HELP: After producing an EXE for my program, running it from outside of the

IDE, I get the error "Component DWSPYDLL not loaded successfully". Any

ideas what the problem is ?????

Zach

Cafe Cyberia!!!!

London ENGLAND


VB 4.0

LUOKKA: VBgen

25541 (133+)  andy@axiomati.demon.co.uk  15.07.95  22:29

Andrew Cheshire: "VB4"

This article posted to the MSBASIC forum on Compuserve may

be of interest :-

=========================================================

The following a list of topics to be covered in  VB 4

workshop titled "Visual Basic 4:  Buidling Great Win32

Applications"  hosted by Kieth Pleas at an upcoming

software conference in October.

"This workshop shows developers how to use VB4 to develop

powerful 32-bit applications that run on both Windows 95

and Windows NT.  (What about Win 3.x?)  The advacements in

VB4 are covered including: new class modules to create

object classes and encapsulate functionality, new DAO with

Jet 3.0, new IDE capabilities including add-ins, full OLE

container support and the ability to create OLE automation

controllers AND servers, new type libraries of object

methods and properties, new bound controls, new language

features like: collection objects, named and optional

parameters, parameter arrays, form parameters, error object

and collection, object extension with custom properties,

and the use of true OLE, and greatly enhanced graphic

manipulation for pictures, forms, and the printer object."

Funny how NDA work.  I wish MS would be more open with

future product direction, to us working stiffs who use VB

on a daily basis, yet aren't among the beta test group.

----------------------------------------------

Andrew Cheshire      andy@axiomati.demon.co.uk

Axiomatic Software   CIS: 100273,154


VB 4.0

LUOKKA: VBgen

Date: 07-25-95 (18:57)              Number: 395674 of 395921 (Refer# NONE)

From: VISBAS-L@EVA.DC.LSOFT.COM

Subj: VB 4.0

From: ppcamus@apm2.msae.wisc.edu

The most recent issue (7/31) of Information Week has a cover story on VB

4.0. Will probably not be too enlightening for beta testers, but may answer a

few ques tions for the rest of us.

Note, they also have a web page (although I could not find this week's issue

yet:

http://techweb.cmp.com/iwk

Patrick Camus

University of Wisconsin


VB 4.0

LUOKKA: VBgen

Date: 24.07.95 (22:57)              Number: 3621 of 3621 (Refer# NONE)

From: MATTI HARJU

Subj: VB 4.0

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: PC-Ohjelmointi (8)         Read Type: GENERAL (A) (+)

---------------------------------------------------------------------

  1.)

  Joku joskus kyseli VB 4.0:stä. Kv.alueilla ei ole paljoa tietoa

  näkynyt (NDA=NonDiscl.Agr.). Tässä joitain tiedon murusia:

  - alkuaan piti ilmestyä marraskuussa, sitten helmikuussa,

    nyt ilmestymispäivä syyskuun 12.

  - 17 pakattua korppua/CD

  - 16/32-bittiset ympäristöt samassa eli 3.1/95/NT

  - VBA (visual basic for applications) mukana

  - std $99, pro $339, client/server $1000

  - ehdollinen kääntäminen (yksi viimeisten betojen käyttäjistä

    kertoi, että (muka) tekisi compiled exejä. Joka puolella

    muualla on kuitenkin kerrottu, että vb4 olisi edelleen tulkkaava)

  - tabbikontrolli (propertysheet)

  - 3d

  - rivin jatkumismerkki

  - Jet 2.5/3.0 (cascading deletet/updatet, ei kuitenkaan ref.check)

  - ole-jutut molempiin suuntiin

  - kontrollien paikat lukittavissa

  - tooltipsit

  - rajoitetusti luokat

  2.) Kyseltiin system menuihin lisäämisestä...

  - lisääminen tapahtuu muutamalla api-kutsulla

  - jos haluaa, että muutettuun system menuun pystyy reagoimaan,

    niin vaaditaan joku subclassing-työkalu, esim. MsgBlaster/

    Spyworks jne...

  - MsgBlasterin 1. versio oli ihan puhdas freeware, on saatavilla

    monesta boxista tai vaikka suoraan Microsoftilta...

    terveisin matti...

----------------------------------------------------------------------


VB 4.0

LUOKKA: VBgen

Päivä: 07-28-95 (20:36)             Numero: 536 / 536 (Vast.nro EI OLE)

Knltä: MATTI HARJU

 Aihe: VB 4.0

 Kok.: fi.atk.ohjelmointi (23)    Lukumalli: Yleinen (A) (+)

  Vähänlaisesti on tietoa liikkunut VB 4.0:sta kv.alueilla:

  - alkuaan piti ilmestyä marraskuussa, sitten helmikuussa, nyt

    ilmestymispäivä syyskuun 12. päivä

  - cd/17 pakattua korppua, 16/31 bittiset ympäristöt samassa

    eli 3.1/NT/Win95

  - VBA eli Visual Basic Applications mukana (esim. Excelin VBA

    käy sellaisenaan VB 4.0:aan

  - std $99, pro $399, client/server $1000

  - tabbikontrolli(propertysheet), uusi outlinekontrolli jne...

  - rivin jatkumismerkki

  - ole-jutut molempiin suuntiin, tooltipsit, rajoitetusti luokat

  - tuki *.res-tdstoille

  - 48 kpl kontrolleita

  - jet 2.5/3.0 (cascading delete/update, ei kuitenkaan ref.check)

  - ehdollinen kääntäminen tyyliin c ifdef jne...

  - luokat rajoitetusti

  terveisin matti.....


VB 4.0

LUOKKA: VBgen

Nro: 536 / 536 (Vast. nro EI OLE)

 Aihe: VB 4.0

 Kok.: fi.atk.ohjelmointi (23)    Lukumalli: Yleinen (A) (+)

  Vähänlaisesti on tietoa liikkunut VB 4.0:sta kv.alueilla:

  - alkuaan piti ilmestyä marraskuussa, sitten helmikuussa, nyt

    ilmestymispäivä syyskuun 12. päivä

  - cd/17 pakattua korppua, 16/31 bittiset ympäristöt samassa

    eli 3.1/NT/Win95

  - VBA eli Visual Basic Applications mukana (esim. Excelin VBA

    käy sellaisenaan VB 4.0:aan

  - std $99, pro $399, client/server $1000

  - tabbikontrolli(propertysheet), uusi outlinekontrolli jne...

  - rivin jatkumismerkki

  - ole-jutut molempiin suuntiin, tooltipsit, rajoitetusti luokat

  - tuki *.res-tdstoille

  - 48 kpl kontrolleita

  - jet 2.5/3.0 (cascading delete/update, ei kuitenkaan ref.check)

  - ehdollinen kääntäminen tyyliin c ifdef jne...

  - luokat rajoitetusti

  terveisin matti.....


VB 4.0

LUOKKA: VBgen

Date: 11/15/94 (00:55)              Number: 26850 of 26882 (Refer# NONE)

From: RONNYONG@UNICOMP.NET

Subj: VB 4.0

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The November 14, 1994 issue of PC Week reports that Microsoft's original

internal schedule called for a January 1995 release of Visual Basic 4.0, but

it has been pushed back until later in the year. It will still be shown at

Comdex, but only in a suite (i.e. closed to general public), which is already

what Microsoft appears to be doing around the world with selected invitees.

PC Week reported that debugging facilities have been reworked, and there

will strong emphasis on integration with a new 32-bit Jet engine. The article

also confirmed that the product will include both a 16-bit compiler and 32-bit

compiler.

In a packaging note, PC Week says Microsoft is considering pricing a

low-end version of Visual Basic at $99 (U.S.). I presume that this merely

suggests that there will continue to be Standard and Professional packages,

and that street pricing for the Standard version will remain in its present

range (approximately).

Before anyone asks: sorry, I can neither post nor email the actual text

without violation of Ziff Publishing copyright.


VB 4.0

LUOKKA: VBgen

Date: 11/29/94 (18:09)              Number: 28338 of 28357 (Refer# NONE)

From: JAKOBF@COLOSSUS.PING.DK

Subj: VB 4.0

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I've just been to a VB4.0 conference today, and here's the things I was told

that I didn't know before (from info in this group):

* It's possible to create something called Object Application DLL's that

can be used in all windows programs

* Classes: A kind of reusable code, where you can use one set of code to

do the same thing to a lot of different processes (kinda hard to understand)

* VB4 can act as an OLE server (but cannot support in-place editing when

acting as an OLE server)

* The setup wizard now setups standard things such as registration of user

names, ID code, etc, etc

* Add-ins in VB (that give certain capabilities such as the ability to create

forms automatically from databases, etc)

* ALL (100%) of the Access Jet v2.5

* Ability to include strings (Company name, version, program name, etc) in

EXEs (like MS programs, etc)

* Has compiler commands in programs: Can react upon Win16 or Win32

environment, and then do certain things for that environment

* Lockable control positions (a la VBAssist)

* Ability to create automatic 3D forms (Auto3D property)

* Lots of other things already mentioned in this group

I saw the 16-bit version of it.. It ran under Win3.1 but could create programs

that would run under Win16 AND Win32...

The user interface was almost exactly the same as VB3, except for the

addition of ToolTips..

Oh: VB4 applications running under Win32 CAN use 16-bit VBXs! (But 32-bit

OCXs run faster, and can be shared with other Win32 OCXs.....)

................: Jakob Faarvang :...........................................

............................................: jakobf@colossus.ping.dk :......

Date: 11/29/94 (19:30)              Number: 28351 of 28357 (Refer# NONE)

From: IANHAR@U09002.SKM09.SVSKT.SE, Ian Harcourt

Subj: Visual Basic 4.0

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Why do we need 32 Bits ?

Well of course we wish to break the 64KB barrier for textboxes etc.. Of

course the advantage with 32-bits only becomes apparent when we use Long

Integers.

What does Win32s give us ?

This allows us to run and develop 32-bit programmes on 16-bit machines, but

not all the functionality of Win95 or Windows NT is supported. Win32s (for

Windows 3.x) allows 32.bit memory management, File Mapping, Networking

(NetBios, Windows sockets) and OLEE 2.0 automation.

However, what you don't get is : piping (client side only), advanced graphics

GDI (Bezier curves, OpenGL, paths, strking and filling) and Remote

Procedure Calls (RPC).

Furthermore, if you have Windows NT you will be able to do GDI Transforms,

Event Logging, performed enhanced security functions and they'll be support

for Unicode (character sets for many minority languages)

16-bit / 32-bit Verions !

When VB is finally released alongside Win95 it'll exist both as a 16- and

32-bit version. The functionality of the two versions will be the same. The

limitations on you will depend more on the platform you use, i.e. WIN32s,

Win95 or NT.

Here's something else that might interest you, originally posted to :

        <VISBAS-L@TAMVM1.TAMU.EDU> a few weeks ago,

        an article which briefly mentions the 16- & 32-bit

        future which awaits us.

>        V I S U A L    B A S I C    4.0

>If you want to know about VB 4.0 just buy a Swedish Magazine !

>Here in Sweden there is no shortage of information on VB 4.0. For example

>in the September issue of Computer Sweden ( No. 39 /Part 1 / Page 19

):

>        QUOTE

>        "       Good Refinements in Visual Basic

>

>In the new version of Visual Basic it's possible to use both OLE- and  VBX-

>controllers in an application.

>

>It is even possible to create a programme with full OLE automation, nd more

>importantly there is support for 32-bit programmes.

>

>There alot of other interesting news in Visual Basic 4.0, which is xpected to

>be ready for delivery during the beginning of 1995.

>

>        Sneak Preview

>

>Visual Basic has become a very popular development tool over the last

>few years. During the beginning of 1995 Visual Basic 4.0 is due for release,

>now it will be possible to generate 16- and 32-bit applications. Computer

Sweden

>has been able to test a Beta Version of the development tool which

definatetly has alot of fine tuning left to do.

>

>OLE in your own programmes

>

>However, even now we there are many spectacular refinements.

>How about being able use whatever OLE object you want in your own

>application ?

>

>Just choose the object you require from a list and then an icon appears,

>just like common VBX (Visual Basic eXtension). Then all you have to do

>is place the object in which ever formular you wish, and then everything is

>ready.

>

>                In the 16-bit version of Visual Basic 4.0 one can use VBX's

>and OLE controls, however, in the 32-bit version one can only use

>OLE-controls. With the recent release of Visual C++ 2.0 it's now easy to

>convert VBX files to OLE controls.

>

>                Microsoft has dedicated the majority of its time to develop

>support for OLE controls. In Visual Basic 4.0 it's possible to use OLE

>automation, not only can one direct other OLE 2.0 adapted programmes, but

>even create OLE automation server programmes. Also included is VBA

>(Visual Basic for Applications), the new macro language which is now

>included in Excel 5.0 and Project 4.0, this will eventually be included in all

>of Microsoft's products.

>

>We can conclude, that there are a number of points which clearly

>improve the developemnt enviroment for programmer.

>

>Earlier its been very easy to move an object on a formular by misstake,

>in the new version one is able to lock individual objects to certain

>position on the screen. It's also possible to mark many rows  without having

>to mark all of the row, an annoying problem in earlier versions.

>

>When Microsoft finaly releases Visual Basic 4.0 this new version will

>certainly please many software developers, that there's no dobt.

>

>The price is expected to be approximately the same version 3.0

>is today."

>

>        END QUOTE

>        Written by Karl-Henry Martinsson and hurriedly translated for you by

me

Futhermore, Richard Czerwonka <RCZERWON@WASP.CS.COWAN.EDU.AU>

said this about a recent Visual Basic 4.0  Seminar:

        " Just got back from the VB4 seminar. They didn't mention anything

about the NDA, so I suppose I am safe in posting this. It looks Ok

though not hugely different. Guaranteed to run you existin VB3

applications. Here are some rough notes I took, in no particular

order:

- Will not ship until Windows 95

- 100 percent compatible with VBA. Take an Excel VBA program, put it

  into VB4 and it will run.

- Run multiple instances of VB4 (useful for debugging)

- Lock controls to forms

- Context sensitive help on the right mouse button in the IDE

- All controls are OCX.

- Place OLE objects on the toolbar. This was demonstrated by placing

  Word For Windows onto the toolbar. You can then place a WFW object

  on a form like any other control

- New TLB and OLB libraries. OLB files are reference files, so VB4

  can be made aware of other objects such as Excel objects. You can

  then define things like:

            Dim XlWorksheet as New Excel.Worksheet

  and VB4 will know what you are talking about.

- Support for .RES files

- Uses Jet 2.5

     Improved speed for many queries

     Programatic access to security

     Cascading updates and deletes

     New workspace object (same as in Access Basic)

     New recordset object

       - supports caching

       - PercentPosition property (to let you know where you are in

                                   a recordset)

       - fill cache method for ODBC (e.g get the next X records only)

     User and Group objects (for maintaining users)

     User defined properties on objects.

- New data-bound controls:

        List box,

        combo box,

        grid (a real one, with pre and post trigger events)

- New outline control

- Conditional compilation

- Editor is now like VBA in Excel

- Object browser to look at objects

- Create OLE servers and clients

- IDE extendable through OLE (i.e. VB/Assist-like products can be

  added through OLE)

- Both 16 and 32 bit versions

They also talked about class modules, but I can't make sense of the

notes I quickly scribbled down. Has to do with the OLE server side

of things I think. They also said that the next versions of Word and

SQL Server will have VBA built in, and there is a possibility that a

non-compiling VB will be relased with Windows. "

END QUOTE

        Written by Richard Czerwonka.

        Best Wishes

        Ian

--------------------------------------------------------------------------

   Ian Harcourt                      Tel:   INT + 46 498 292239

   RSV DataService                   Fax:   INT + 46 498 249263

   621 87 Visby, Sweden              Email: ianhar@u09002.skm09.svskt.se

--------------------------------------------------------------------------

2189 (48+)  bmurray@pluto.njcc.com  28.12.94  14:19

Brad Murray: "Re: Q: VB4, when? what is new?"

Jin Mai (mwj@pipeline.com) in article <3do0hi$mcc@pipe2.pipeline.com>

wrote:

: When will VB4 release? Is VB 4.0 bata being

: testing? What is new in VB 4.0?

That has been talked about in great detail over the past few months.

Basically VB4 is in beta right now and is said to be coming out in

February, but of course they originally said it was coming out in

November, so who knows.  It looks like they are going to put out 4 now

and 4.1 when Win95 comes out.  For a while they were talking about

waiting until Win95 comes out, but who knows when that will be.  In other

words it looks like VB4 will be an open beta (like VB2 was).

Brad

_________

 Bradley S. Murray       Princeton Computer Consulting

 bmurray@pluto.njcc.com         20 Lorrie Lane          (609) 799-5300

                           Princeton, NJ 08543-7345     Fax:  275-5651


VB 4.0

LUOKKA: VBgen

19487 (34+)  dhunt@netins.net  02.06.95  15:56

"Some VB4 information"

There is an article in InfoWorld that reveals some information about the BIG

SECRET. Personally, I'm beginning to understand why there's been a

conspiracy of silence.

There are three Editions: Standard ($99), Professional (~$339) and

Client/Server (~$1000). Standard and Professional will ship "within weeks of

Windows 95's August debut". All three will be delivered as 16- and 32-bit

versions for Windows 3.1, NT, and 95 on the same CD-ROM.

VB 4.0 Standard

    Support for VBXes and OCXes

    Automatic conversion of VBXes to OCXes (?)

    The VBA engine

VB 4.0 Professional

    Standard additions

    Crystal Reports

    ~48 prewritten 16- and 32-bit OCXes

    More efficient ODBC and native drivers

    Application partitioning

VB Client/Server

    SourceSafe 4.0 code management and version tracker for groups

    SQL Server desktop edition

Apparently application partitioning is not supported across Client/Server

networks but Microsoft promises it will when Cairo is released.

I've checked and rechecked the article but that's all there is. I sure hope MS

is withholding tons of features from the spying eyes of the media because I

see hardly anything I want. I know I'll need it to write 32-bit apps and to use

OCXes, etc, etc, but . . . where's the beef?

Dave Hunt

Reporting from Cedar Rapids, Iowa


VB 4.0 books

LUOKKA: commercial

Date: 04-05-95 (21:56)              Number: 285286 of 286568 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: VB 4.0

For those of you who don't have access to the WWW. This is a copy of what

I found on http://www.waite.com/waite/wgp_gif/new_gif.html

Title: Visual Basic HOW-TO

Whether you're an experienced Visual Basic user upgrading to the latest

version or a programmer switching to the hottest tool on the market, Visual

Basic XX How-To shows you how to write incredible Windows applications.

Discover how to tap Windows 95 APIs, take advantage of Visual Basic's

newest OLE custom controls, construct eye-popping special effects, and

much more. With practical, self-contained example projects you'll walk

through the construction of a myriad of applications, from the profoundly

practical to the wonderfully whimsical. Create toolbars that float and roll,

make high-speed animations or create sprite objects that have built-in

intelligence. Clear descriptions, useful illustrations, helpful tips, and

carefully explained code help you understand all the techniques, and the

projects are class modularized and included on the CD so that you can easily

plug the code right into your own apps.

<h3>Publishing Information</h3>

<pre>

Publication Date: June 1995

800 pages

ISBN: 1-57169-001-8

U.S. Price: $39.95

Canadian Price: $55.95

Disk Media: 1 - CD-ROM

Level: Beginning-Advanced

Platform: Windows

Category: Programming/Visual Basic

-----------------------------------------------------------------

Title: Visual Basic XX: Objects and Classes SuperBible With the Waite Group

SuperBibles, using the newest version of Visual Basic is a breeze-every VB

object, property, method, event, and keyword is covered in exquisite detail.

No more frustrating and endless jumps from help files to reference guides to

third-party books. It's all here, and every reference entry includes real-life

programming examples with professional hints and insights on proper usage,

as well as cautions about the hidden pitfalls of each entry. Visual Basic XX

OBJECTS AND CLASSES covers all of Visual Basic's new object-oriented

features in detail, including object-oriented design and using custom classes

and class modules It also contains a tutorial on pro management, and a

comprehensive guide to Visual Basic objects and collections. It covers every

propy, event, and method of all Visual Basic controls relating to graphics,

menus and dialogs, text, fonts, printing, user-interaction, and application

appearance. It includes a CD-ROM, which contains all the source code and

sample projects

<h3>Publishing Information</h3>

<pre>

Publication Date: June 1995

800 pages

ISBN: 1-57169-006-9

U.S. Price: U.S. $39.95

Canadian Price: $55.95

Disk Media: none

Level: Beginning-Advanced

Platform: Windows

Category: Programming/Visual Basic

-----------------------------------------------------------------------

title: Visual Basic XX: OLE, Database & Controls SuperBible

Book Two of this complete Visual Basic XX reference covers advanced

topics such as DDE, the OLE container control, OLE automation, data bound

controls, data access objects, and the database engine. It documents all the

new features of the Add-in manager including coding for the 32-bit

environments, conditional compilation, advance debugging, resources and

globalization, and object-oriented error trapping. It contains a completely

updated Visual Basic language tutorial and reference, and a guide to the new

Professional Edition controls. This massive two-volume set is based on the

best-selling Bible series from Waite Group Press. The books contain

comprehensive overviews, numerous examples, and thousands of lines of

Visual Basic code. and a CD-ROM, which contains all the source code and

sample projects from both volumes.

<h3>Publishing Information</h3>

<pre>

Publication Date: June 1995

800 pages

ISBN: 1-57169-007-7

U.S. Price: $44.95

Canadian Price: $62.95

Disk Media: 1 - CD-ROM

Level: Beginning-Advanced

Platform: Windows

Category: Programming/Visual Basic

Denis Careau


VB 4.0 pricing

LUOKKA: VBgen

Date: 07-27-95 (04:46)              Number: 397278 of 397320 (Refer# NONE)

Subj: VB 4.0 Pricing Informatio

From: Britton Burt <britton@iadfw.net>

I received a PC Mall catolog today and found the following information.  VB

4.0 is to ship on Sept. 7, 1995. It will cost as follows:

        1. VB Pro 4.0 Upgrade CD 79.00

        2. VB Standard Upgrade CD 79.00

        3. VB Pro 4.0 Pro/Competitive Upgrade 210.00

        4. VB Pro 4.0 CD 420.00

Britton Burt

Electronic Document Group

Office Automation Services

Dallas, TX

28061 (121+)  digallery@aol.com  28.07.95  22:19

DIGallery: "VB4 For Sale"

FYI, PC Mall catalog that just came in has a product listing "Visual Basic

4.0 Professional CD" at $209.95. The ad shows a picture of the packaging,

but does not include any specs.

28223 (76+)  mxe126@psu.edu  29.07.95  23:56

"ÄMicrosoft 's PRO CD UPGR PRICEÅ  Re: VB 4.0 ADD $209 FROM PC

MALL!"

When I called Microsfot, they said the upgrade CD for the professional

version will be $ 89.00 from them and probably cheaper from retailers.  So it

seems that $ 79 for a standard upgrade is way too much.

Mounir Elabridi


VB address of vars

LUOKKA: coding

25149 (44+)  jwgilb@ccmail.monsanto.com  13.07.95  15:49

Jim Gilbert: "Re: Pointers & Structures In VB?"

david.harrigan@umist.ac.uk (David Harrigan) wrote:

>Okay, the problem, does VBasic 3 Prof. support adt's with the

>equivalance in C being structures and records in Pascal, also, does

>VBasic 3 Prof. support pointers to these hopefully existant

>structures?

VB's method of declaring user-defined types is the Type keyword:

Type MyType

   X   as Integer

   Y   as String * 10

   etc.

End Type

While you cannot directly get the address of a variable in VB, I saw

a neat trick in the latest VB Tips & Tricks help file that shows how you can

get the address by using the LstrCpy API function in a different way:

Declare Function Lstrcpy Lib "kernel.dll" (ByVal lpString1 As String, ByVal

lpString2 As String) as Long

Lstrcpy() is a neat little API function which normally copies null terminated

strings, but when passed the same variable in both parameters, it does

nothing but return the *address of parameter*. Voila, a pointer to the variable.

An example:

Type Foo

   x as Integer

End Type

Sub Main ()

Dim I as Integer

Dim S as String

Dim F as Foo

Dim ptr as Long

  ptr = VarPtr(I,I)               ' Get the address of 'I'

  ptr = VarPtr(ByVal S, ByVal S)  ' Must use ByVal keyword w/ string

  ptr = VarPtr(F, F)              ' Works with type declarations too

End Sub

The above was taken from VB Tips & Tricks, July 1995 edition.

--

Jim Gilbert                    all normal disclaimers about my opinions

jwgilb@ccmail.monsanto.Com     not reflecting my employers, etc., apply.

Monsanto Co., St. Louis, MO


VB closing applica

LUOKKA: VBgen

Date: 06-22-95 (16:10)              Number: 370122 of 370426 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Any easy way to terminate a program ? -Reply

From: Ian Ornstein <IORNSTEI@WPO.HCC.COM>

It took me days to find this:

'+ ----

'  Close the existing MARS Task

'- ----

    Title = "M.A.R.S."

    ihWnd = FindWindow(0&, Title)

    ihTask = GetWindowTask(ihWnd)

    iRet = PostAppMessage(ihTask, WM_QUIT, 0, 0&)

' MsgBox "Look carefully, Mars should be closed"

'+ ----


VB colored buttons

LUOKKA: VBgen

Date: 12/20/94 (05:32)              Number: 157978 of 163156 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: YES - COLOURED BUTTONS

From: David Barnes <david.barnes@MKBBS.CO.UK>

A while ago there was a discussion asking about buttons You can have

buttons with coloured backgrounds without buying a new control.

Here's how:

1. Include THREED.VBX in you project

2. Use the 3D Button Control - this allows you to have a bitmap on

a button and comes with the Pro edition.

3. Run Paintbrush or other drawing package - then draw a rectangle and

fill it with the desired  background colour - add text of the desired

foreground, background combination - then save

4. The 3D Button Control has an image property - set this to YOUR_IMG.

BMP or whatever.

So that the user can select this button with the keyboard in the usual

way (eg CTRL+S for a Save button) I drew line under the relevant char

of the bitmap.  Then I gave the button a caption of "&s" using the

small-fonts font of the smallest size and the foreground colour of my

image background - thus making this caption invisible.


VB comparing ctrl var

LUOKKA: VBgen

Date: 07/26/94 (20:17)              Number: 13274 of 13548 (Refer# NONE)

From: DINGBAT@CODESMTH.DEMON.CO.UK

Subj: Re: Geez, what a language

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <154@kaulakis.win.net> ekaulaki@kaulakis.win.net  writes:

> It seems that comparison for equality is not defined for control

> variables over their range...

> dim a as control, b as control

> ...

> set a = somecontrol

> set b = nothing

> ...

> if a = b then   !NOT FALSE, BUT RUNTIME ERROR!

If I told you that control variables were really pointers, and that setting

them to Nothing was the equivalent of a null pointer, would you feel any

happier ? Testing the equivalence of a & b in the case above is just the same

as dereferencing a null pointer in C or Pascal - a run-time error. It's not a

question of the test being undefined over some part of their range, more a

question of the value "Nothing" being outside the normal range of a variable.

If you're going to make a habit of using control variables (or recordsets, or

forms) that could be set to nothing, then either trap the errors as they

arise, or use code like the following:

if a Is Nothing then

   Debug.Print "a is Nothing"

elseif b Is Nothing then

   Debug.Print "b is Nothing"

else

   if a = b then

      Debug.Print "a = b"

   else

      Debug.Print "a <> b"

   end if

end if

It's a deliberate design issue in VB. If you dumb-down the description of a

language, so as to make it approachable, then you also run the risk of

making it confusing when the real action action of the language is still more

complex.

--

Andy Dingley                             dingbat@codesmth.demon.co.uk


VB extract imag. FRX

LUOKKA: graphics

23527 (142+)  rcw@netcom.com  03.07.95  23:07

Robert Woodcock: "Re: How to extract images from .FRX-files"

Jens Balchen jr. (balchen@oslonett.no) wrote:

>I'm writing a little program to give me information on a .MAK-file, and I

>want to display the icon from "IconForm". This icon is saved in the .FRX-

>file, but I don't know how to extract it.

I haven't actually tried to do this, but I have made a couple relevant

observations:

Saving a form with one graphic (it's the icon, 766 bytes) yields an .FRX

file 770 bytes long. Running them both through a file comparison program

says that the .FRX file has a 4-byte header, with the .ICO file tacked

on to the end of that.

It works like this: (Bytes in .ICO file numbered for comparison purposes)

.FRX: Ä4B headerÅ 01 02 03 04 05 ...... 760 761 762 763 764 765 766

.ICO: 01 02 03 04 05 06 07 08 09 ...... 764 765 766

The 4-byte header, (in hex) is:

FE 02 00 00, in decimal, it's 254, 2, 0, 0.

I haven't tested this for .BMP, .RLE, or .WMF files, yet.

It appears that when there is more than one graphic, it is just piled on

top of the .FRX. I don't think there are any delimiters, just the .FRM

file saying:

   Icon            =   FRXTEST.FRX:0000

pointing to the start of the .ICO file.

Then again, it seems that the size of the binary data is stored as a long

value in the .FRX header.

(254) + (2 * &HFF) + (0 * &HFFFF) + (0 * &HFFFFFF) = 766

It seems that you'll have to read the headers of the graphic yourself to

figure out what type it is.

_________________________________________________________

Robert Woodcock ö Note: Your standard disclaimers apply. ö

rcw@netcom.com  ö I never forget a face (In some cases


VB filled polygons

LUOKKA: VBgen

Date: 09/23/94 (23:28)              Number: 20529 of 20621 (Refer# NONE)

From: WIGGI@SWINGBEAT.WIN-UK.NET, howard wiggins

Subj: Re: Drawing filled polygons question

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

 Function Name:           " Description:

 FillRgn                        " Fills a HRGN

 CreatePolygonRgn        " Creates a polygonal HRGN

 CreatePolyPolygonRgn  " Creates a HRGN of multiple polygons

 CreateRectRgn             " Creates a Rectangular HRGN

 CreateRectRgnInDirect  " Creates a Rectangular HRGN from a  RECT

                                 structure

 CreateRoundRectRgn   " Creates a Rectangular HRGN with

                                        rounded corners

FillRgn

Declare Function FillRgn Lib "GDI" (ByVal hDC As Integer,

       ByVal hRgn As Integer, ByVal hBrush As Integer) As Integer

CreatePolygonRgn

Declare Function CreatePolygonRgn Lib "GDI" (lpPoints As POINTAPI,

        ByVal nCount As Integer, ByVal nPolyFillMode As Integer) As Integer

CreatePolyPolygonRgn

Declare Function CreatePolyPolygonRgn Lib "GDI" (lpPoints As POINTAPI,

        lpPolyCounts As Integer, ByVal nCount As Integer,

        ByVal nPolyFillMode As Integer) As Integer

CreateRectRgn

Declare Function CreateRectRgn Lib "GDI" (ByVal X1 As Integer,

       ByVal Y1 As Integer, ByVal X2 As Integer,

               ByVal Y2 As Integer) As Integer

CreateRectRgnIndirect

Declare Function CreateRectRgnIndirect Lib "GDI" (lpRect As RECT) As

Integer

CreateRoundRectRgn

Declare Function CreateRoundRectRgn Lib "GDI" (ByVal X1 As Integer,

       ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer,

               ByVal X3 As Integer, ByVal Y3 As Integer) As Integer

That's the syntax. Now the down-to-earth english portion (somewhat).

For example, let's make a rectagle!

       Dim Rectangle as HRGN

       Dim Brush as HBRUSH

       Rectangle = CreateRectRgn(10,10,110,110)

       SelectObject(hDC,Rectangle)

       Brush = CreateSolidBrush(RGB(0,0,255))

       FillRgn(hDC,Rectangle,Brush)

       DeleteObject(Rectangle)


VB find exes

LUOKKA: VBgen

Date: 01/03/95 (11:12)              Number: 31486 of 31509 (Refer# NONE)

From: HARALDO@OSLONETT.NO

Subj: Re: Finding Applications.

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2JAN199523103977@pavo.concordia.ca>,

NV <n_varac@pavo.concordia.ca> wrote:

>

>I want to be able to do something like the windows setup program does,

>scan for windows executables. This leads to 2 questions.

>

>1) How do you determine if a file is a windows executable?

>2) If it is a windows exedcutable, how do you determine it's name

>   (i.e. the title that setup uses when creating program manager items)

The following is a quote from MS :

"Download EXEFMT.EXE, a self-extracting file, from the Microsoft

Software Library (MSL) on the following services:

 - CompuServe

      GO MSL

      Search for EXEFMT.EXE

      Display results and download

 - Microsoft Download Service (MSDL)

      Dial (206) 936-6735 to connect to MSDL

      Download EXEFMT.EXE

 - Internet (anonymous FTP)

      ftp ftp.microsoft.com

      Change to the ™softlib™mslfiles directory

      Get EXEFMT.EXE"

--

Harald Ommang

Delfi Data AS

Sandslimarka 55, 5049 Sandsli.

Tel:+47 55226442 Fax : +47 55229930


VB func. return array

LUOKKA: VBgen

Date: 08/19/94 (17:19)              Number: 16233 of 16280 (Refer# NONE)

From: SJJOHNST@UNDERGRAD.MATH.UWATERLOO.CA, Stephen

Johnston

Subj: Re: Function returning an array

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

You can't return an array from a function  But you can use a subroutine to

do almost the same thing

 Sub MySub (Array() as Variant)

  ReDim Array(1 to 1000)

  DoStuff

 End Sub

Of course, you can use ReDim and dimension to arbitrary bounds, and then

your function can use lBound"" uBound to determine what those bounds are.

To call, use the command "MySub ThisArray()"

To return arrays from DLLs is slightly different.  Using standard API DLLs

all you can pass and return is numeric type arrays, they won't work at all with

string or Variant types.  Unless of course the DLL is designed specifically for

use with VB.  I haven't tried using Floats, Currency, Date/Time variables, but

Longs and Integers work fine.  Make sure you pass the correct data type or

your array will get really mesed up!  The big trick here is you can't pass

the array using Array() - because that points to the "array descriptor"

Instead, pass the first element - Array(0).  Make sure that your NOT

passing it ByVal - you want to send an actual pointer to Array(0), not the

value!

This is very useful in the following situation:  Filling an array with the

indexes of selected items in a list box.  Rather than do a For/Next loop,

and manually find which items are selected, simply call an API function to

count the number of items selected, ReDim an Array, and get the API to fill

the array for you.  Couldn't be easier!


VB hiding an applicati

LUOKKA: VBgen

21637 (174+)  sgotz@ix.netcom.com  19.06.95  16:17

Steven Gotz: "Re: Hiding an App"

In <803499651snz@tsys.demon.co.uk> Tom Wheeley

<tomw@tsys.demon.co.uk> writes:

>I'm trying to hide my background application completely from the user.

>(Similar to NETDDE.EXE).  This entails removing it from the Task Manager

>List and from the Fast Alt-Tab switching display.

>I have successfully removed it from TaskMan by setting the parent form's

>caption to "".  However, although I can make the Icon and Text disappear

>from the Alt-Tab box, a blank box still appears.

Next time, check the KB before posting!

How to Hide a VB App from the Task List and ALT+TAB Order Article ID:

Q114776

---------------------------------------------------------------------

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0

---------------------------------------------------------------------

SUMMARY

=======

This article demonstrates how to create an application that is

invisible

to the Windows Task List and to the fast ALT+TAB switching order.

MORE INFORMATION

================

All Visual Basic applications have a background window that handles all

messages for the application and all calls to the VBRUN300.DLL. This

background window is also the owner and parent of all non-MDI child

forms.

You can use the GetWindow and ShowWindow Windows API functions to

hide this background window.

To be eligible for removal from the ALT+TAB order, an application cannot

have any visible forms. The background window is visible, but you can

use GetWindow to return the background or owner window's handle, and

then use the handle and ShowWindow to make the window invisible.

Step-by-Step Example

--------------------

This example hides itself from the Windows Task List and ALT+TAB order.

1. Start a New Project in Visual Basic. Form1 is created by default.

2. Add a timer control (Timer1) to the form.

3. Add the following declarations to the general declarations section:

   ' Enter each of the following Declare statements as one, single line:

   Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer,

      ByVal nCmdShow As Integer) As Integer

   Declare Function GetWindow Lib "User" (ByVal hWnd As Integer,

      ByVal wCmd As Integer) As Integer

   Const SW_HIDE = 0

   Const GW_OWNER = 4

4. Add the following code to the load event of Form1:

   Sub Form_Load ()

      Dim OwnerhWnd As Integer

      Dim ret As Integer

      ' Make sure the form is invisible:

      form1.Visible = False

      ' Set interval for timer for 5 seconds, and make sure it is enabled:

      timer1.Interval = 5000

      timer1.Enabled = True

      ' Grab the background or owner window:

      OwnerhWnd = GetWindow(Me.hWnd, GW_OWNER)

      ' Hide from task list:

      ret = ShowWindow(OwnerhWnd, SW_HIDE)

   End Sub

5. Add the following code to the Timer event of the Timer1 control to

   verify that the program is running and to allow you to exit the program:

   Sub Timer1_Timer ()

      Dim ret As Integer

      ' Display a message box:

    ret = MsgBox("Visible by Alt+Tab. Cancel to Quit", 1, "Invisible Form")

      ' If cancel clicked, end the program:

      If ret = 2 Then

         timer1.Enabled = False

         Unload Me

         End

      End If

   End Sub

6. Save the project as INVIS.MAK and create an executable entitled

   INVIS.EXE.

7. Run the program by double-clicking INVIS.EXE in File Manager or by using

   the Run option in Program Manager. When you run the program, there

   should be no visible forms and the program title should not appear in

   the Task List or in the ALT+TAB order. After five seconds, the

   application should display the message box. Then the program should be

   visible to the ALT+TAB order, but not the Task List. Click the Cancel

   button to exit the application, or click OK to allow it to continue to

   run.

Additional reference words: 2.00 3.00 hide invisable

KBCategory: kbprg kbcode

KBSubcategory: APrgOther

Copyright 1993 Microsoft Corporation. All rights reserved.


VB history

LUOKKA: VBgen

Date: 08/26/94 (00:40)              Number: 17082 of 17164 (Refer# NONE)

From: DMURPHYA@CIX.COMPULINK.CO.UK, "Dave Murphy"

Subj: Re: Questions about VB

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> Hello.

>     I have this questions about VB:

> a) When/where was VB created?

> b) Who created it?

> c) Another historical aspects.(Why it was created , etc.)

> d) Whitch are his most importants applications?

Quoting from an article in Visual Basic Developer, a new newsletter

edited by Karen Watterson.

a). An initial prototype called ruby was created in 1987, deno'd to MS

1988 and bought by them that year.  Full development strted then from the

prototypes.

b). Alan Cooper.

c).  The guy put together a proposal and prototype.  Accepted by MS.

Then re written on order from MS, and (presumably) bought by them.

d).  The only app known, he works as a consultant now.

Alan cooper has also been called the 'father of VB'.  BUt MS don't like

this - he is not oe of their guys.  Also, to be fair, the Ruby project

appears to have been primarily the 'visual' side of basic.  Bill gates

himself is very keen on the language and many other MS people have been

part of its creation and devlopment.  Alan Cooper and Bill Gates

wereprobaly the driving forces, but as with most software developments,

it is misleading to say 'one person created it'.  At the least, it does a

disservice to all the people who have had a hand in its creation and

further devlopment.

Dave.


VB Magazine

LUOKKA: internet

Date: 11/23/94 (14:00)              Number: 135043 of 136670 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: VB Magazine

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

The VB Magazine is at ftp.cts.com exactly where it should be. But there is

a little trick. When you log in and change to the /pub directory, when you

issue the dir command, for some reason the "schoon" directory is not listed.

But you can change into this directory or directly into schoon/VBWM.Issues

without any problem and get the file.

Witold

BTW, are you familiar with http://www.fagg.uni-lj.si/SHASE/


VB Magazine

LUOKKA: internet

Date: 11/23/94 (14:00)              Number: 135043 of 137031 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: VB Magazine

Conf: UUCPMAIL (31)              Read Type: GENERAL (A) (+)

The VB Magazine is at ftp.cts.com exactly where it should be. But there is

a little trick. When you log in and change to the /pub directory, when you

issue the dir command, for some reason the "schoon" directory is not listed.

But you can change into this directory or directly into schoon/VBWM.Issues

without any problem and get the file.


VB Magazine

LUOKKA: internet

Date: 03-04-95 (15:38)              Number: 244921 of 251087 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: VBWin Programmer's Magazine, February Issue Available

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

VBWin Programmer's Magazine is the complete reference to the months

postings on Discussion for Microsoft Visual Basic and Related Issues

mailing list, FAQ's, and other related Visual Basic information as

a Windows helpfile.

It is available as freeware, distribution unlimited.

VBWin Programmer's Magazine for the month of February has been uploaded

as VBWM9502.ZIP

Uploaded To: ftp.cts.com://pub/schoon/VBWM.Issues

------------------------------------------------------------------------

Mark Schoonover                            Publisher

Internet: schoon@cts.com                   VBWin Programmer's Magazine

ftp: ftp.cts.com/pub/schoon/VBWM.Issues    <-- ftp a copy from here!


VB mail reader pgm

LUOKKA: VBgen

Date: 07-08-95 (10:19)              Number: 382164 of 382713 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: The THREADER program

From: Antony.Meadley@LO007.UBS.UBS.CH

I am posting this to the list, because I am so inundated with requests

for it! Yesterday I sent out about 30 copies. Today my mail box is

crammed with more requests! So this is the only practical way of getting

it to everyone. Thank you all for your interest in it.

Antony

I knocked this program up fairly quickly, to make it easier to read and

copy/paste from the VISBAS-L list. I did NOT write it as shareware or for

sale. Therefore there may well be a few problems with it. e.g. If there are two

topics with the same name, but the 2nd one is shorter than the first, then the

program won't find the second one. This happens so rarely, I didn't bother

fixing it. i.e. if message 1 is called "How to do this in VB today" and

message 2 is "How to do this in VB".

I am sending the source code for 2 reasons:

1. you can make any fixes/changes/improvements you wish

2. my mailer here is crap and doesn't cope properly with sending

uuencoded stuff

But I assume you all have VB so it shouldn't be a problem.

Usage:

From your mailer, save the VISBAS message as the filename you specify

in the VB_NEWS.INI file. This file should start like this:

------------------ not this line --------------------------

There are 89 messages totalling 2470 lines in this issue.

Topics of the day:

  1. VB, Delphi, V-C++, V-Co

  2. msole2.vbx question

  3. Dir$(Command$) ???

  4. Form.Picture = (none), HOW TO!!!? (8)

------------------ not this line --------------------------

This is the way my mailer writes it. If yours puts extra rubbish at the top

as some do, then you will have to add a couple of lines to the program to

skip over them.

---------------------------------------------------------------------

Put this in a file called vb_news.ini

===================================================

ÄMailFileÅ

FileName="c:ÖtempÖvbmail.txt"   <- or whatever your filename is!

Put this in a file called news.mak

===================================================

FORM1.FRM

C:ÖWINDOWSÖSYSTEMÖTHREED.VBX

ProjWinSize=152,402,248,186

ProjWinShow=2

IconForm="Form1"

Title="NEWS"

ExeName="NEWS.EXE"

================ end of file ======================

Put this in a file called form1.frm

===================================================

VERSION 2.00

Begin Form Form1

   BackColor       =   &H00C0C0C0&

   Caption         =   "Ant's VB Mail Reader"

   ClientHeight    =   5445

   ClientLeft      =   1095

   ClientTop       =   1485

   ClientWidth     =   7320

   Height          =   5850

   Icon            =   FORM1.FRX:0000

   Left            =   1035

   LinkTopic       =   "Form1"

   ScaleHeight     =   5445

   ScaleWidth      =   7320

   Top             =   1140

   Width           =   7440

   Begin CommandButton cmdPrint

      Cancel          =   -1  'True

      Caption         =   "&Print"

      Height          =   300

      Left            =   3360

      TabIndex        =   5

      Top             =   1800

      Width           =   1215

   End

   Begin CommandButton cmdQuit

      Caption         =   "&Quit"

      Height          =   300

      Left            =   6000

      TabIndex        =   4

      Top             =   1800

      Width           =   1215

   End

   Begin CommandButton cmdNext

      Caption         =   "&Next in thread"

      Enabled         =   0   'False

      Height          =   300

      Left            =   1680

      TabIndex        =   3

      Top             =   1800

      Width           =   1455

   End

   Begin CommandButton cmdRetrieve

      Caption         =   "&Retrieve"

      Default         =   -1  'True

      Height          =   300

      Left            =   120

      TabIndex        =   2

      Top             =   1800

      Width           =   1335

   End

   Begin TextBox Text1

      Height          =   3135

      Left            =   120

      MultiLine       =   -1  'True

      ScrollBars      =   2  'Vertical

      TabIndex        =   1

      Top             =   2160

      Width           =   7095

   End

   Begin ListBox List1

      Height          =   1590

      Left            =   120

      TabIndex        =   0

      Top             =   120

      Width           =   7095

   End

End

Option Explicit

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal Appname As

String,

ByVal KeyName As String, ByVal DEFAULT As String, ByVal ReturnedString

As

String, ByVal MaxSize As Integer, ByVal FileName As String) As Integer

Dim TopLoc

Dim CR

Const MIN_HEIGHT = 4000

Const MIN_WIDTH = 4680

Sub cmdNext_Click ()

    Call GetNewsStory

End Sub

Sub cmdPrint_Click ()

    Printer.Print Text1

End Sub

Sub cmdQuit_Click ()

    Close 1

    End

End Sub

Sub cmdRetrieve_Click ()

    Seek #1, TopLoc

    Call GetNewsStory

End Sub

Sub Form_Load ()

Dim Char As String * 1

Dim TextData As String

Dim r

Dim DB_NAME As String

    CR = Chr$(13) & Chr$(10)

    DB_NAME = String$(255, 0)

    r = GetPrivateProfileString("MailFile", "FileName", "", DB_NAME, 100,

"VB_NEWS.INI")

    If r = 0 Then

        MsgBox "VB mail-file name not found in VB_NEWS.INI file"

        End

    End If

    If FileLen(DB_NAME) = 0 Then

        MsgBox "File (" & DB_NAME & ") does not exist. Check this is the

correct

name and change your VB_NEWS.INI file if neccessary."

        End

    End If

    Open DB_NAME For Input Access Read As 1

    TextData = GetLine()

    TextData = GetLine()

    TextData = GetLine()

    TextData = GetLine()

    TextData = GetLine()

    While (Val(TextData))

        list1.AddItem TextData

        TextData = GetLine()

    Wend

    TopLoc = Seek(1)

End Sub

Sub Form_Resize ()

    If windowstate = 1 Then Exit Sub ' do nothing if minimized

    If Height >= MIN_HEIGHT Then

        Text1.Height = Height - 2715

    Else

        Text1.Height = MIN_HEIGHT - 2715

    End If

    If Width >= MIN_WIDTH Then

        Text1.Width = Width - 390

        list1.Width = Width - 390

        cmdQuit.Left = Width - 1485

    Else

        Text1.Width = MIN_WIDTH - 390

        list1.Width = MIN_WIDTH - 390

        cmdQuit.Left = MIN_WIDTH - 1485

    End If

End Sub

Function GetLine () As String

Dim Char As String * 1

Dim TextData As String

    Do While Not EOF(1)

    Char = Input(1, #1) ' Get one character

    If Char <> Chr(13) Then ' If not cr

        TextData = TextData & Char

    Else    ' If linefeed,

        Char = Input(1, #1) ' Get linefeed character

        Exit Do

    End If

    Loop    ' Loop if not end of file

    GetLine = TextData

End Function

Sub GetNewsStory ()

Dim DataLine As String

Dim SearchText As String

Dim PresentLoc

Dim OutputText 'need this buffer to prevent multiple redraw of textbox

    SearchText = RemoveStartNums((list1.Text)) 'strip off leading number

    SearchText = RemoveTrailBrackets(SearchText)'strip off trailing brackets

    On Error GoTo BeyondEOF

    Do While Not EOF(1)

        Line Input #1, DataLine

        'Debug.Print DataLine

        If DataLine = "------------------------------" Or DataLine =

"----------------------------------------------------------------------" Then

            Line Input #1, DataLine  'blank line

            PresentLoc = Seek(1)

            Line Input #1, DataLine  'Date:

            Line Input #1, DataLine  'From:

            Line Input #1, DataLine  'Subject:

            If InStr(DataLine, SearchText) Then

                Exit Do

            End If

            Line Input #1, DataLine  'repeat because From: can take 2 lines

sometimes

            If InStr(DataLine, SearchText) Then

                Exit Do

            End If

        End If

    Loop

    If EOF(1) Then

        Text1.Text = "Subject not found in file."

    Else

        Text1.Text = ""

        OutputText = ""

        Seek #1, PresentLoc

        Do While Not EOF(1) And DataLine <> "------------------------------"

            Line Input #1, DataLine

            OutputText = OutputText & DataLine & CR

        Loop

        Text1.Text = OutputText

    End If

    Exit Sub

BeyondEOF:

    Select Case Err

    Case 14

        MsgBox Error$(Err) & Chr$(13) & "Too much text in this story,

incomplete

text will be shown.", 16

        Text1.Text = OutputText

        Exit Sub

    Case 62

        MsgBox "Story not found.", 16

        Exit Sub

    Case Else

        MsgBox Error$(Err) & Chr$(13) & "** This is an unexpected error. Modify

code. **", 16

        Resume Next

    End Select

End Sub

Sub List1_Click ()

    If Right$(list1.Text, 1) = ")" Then

        cmdNext.Enabled = True

    Else

        cmdNext.Enabled = False

    End If

End Sub

Sub List1_DblClick ()

    cmdRetrieve_Click

End Sub

Function RemoveStartNums (InText As String) As String

Dim Off%

    Off = 1

    While Mid$(InText, Off, 1) = " "

        Off = Off + 1

    Wend

    While Val(Mid$(InText, Off, 1))

        Off = Off + 1

    Wend

    Off = Off + 1

    RemoveStartNums = Right$(InText, Len(InText) - Off)

End Function

Function RemoveTrailBrackets (InText As String) As String

Dim Off

    Off = Len(InText)

    If Right$(InText, 1) = ")" Then

        Off = Off - 1

        While Val(Mid$(InText, Off, 1))

            Off = Off - 1

        Wend

        Off = Off - 2 'remove space and first bracket

    End If

    RemoveTrailBrackets = Left$(InText, Off)

End Function

================ end of file =========================


VB on CDROM

LUOKKA: VBgen

Date: 08/23/94 (17:17)              Number: 16724 of 16734 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: VB Pro on CDROM or 3.

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 8/22/94 7:47 PM car@mcs.com wrote:

>I called MS and they said that the full CDROM package does not include

the

>manuals (maybe you got a configuration that they discontinued).  They said

>that you don't need the manuals because everything is online.

If you buy VB on disk and get the books, you can buy the CD for like $10.

__________

                           Bradley S. Murray

 Princeton Computer Consulting, Inc.      Phone: (609) 799-5300

 20 Lorrie Lane  Box 7345                   Fax: (609) 275-5651

 Princeton, NJ 08543-7345              Internet: bmurray@pluto.njcc.com


VB on CDROM

LUOKKA: VBgen

Date: 08/24/94 (16:18)              Number: 16837 of 16870 (Refer# NONE)

From: CAR@MCS.COM

Subj: Re: VB Pro on CDROM or 3.

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <33ctiv$gc1@pluto.njcc.com> bmurray@pluto.njcc.com (Brad

Murray) writes:

>>I called MS and they said that the full CDROM package does not include

the

>>manuals (maybe you got a configuration that they discontinued).  They said

>>that you don't need the manuals because everything is online.

>If you buy VB on disk and get the books, you can buy the CD for like $10.

I called, $15 + tax + shipping = < $21!  I got it !  Best of both worlds, I

guess.  :-)

----------------------------------------------------------------------

Chris A. Rodgers             Software Engineer             car@mcs.com


VB pass ctrl-arrays

LUOKKA: VBgen

Date: 01/17/95 (11:58)              Number: 188634 of 188847 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Passing a control array to a subprocedure

I need to pass a control array reference to a subprocedure.  I have no

problem passing a control, but get an error trying to pass a control array.  I'm

doing something similar to the following:

sub chkCheck1_click()

     AllChecked chkCheck1, chkCheckAll    ' chkCheck1 is a check box,

chkCheckAll is an array of check boxes

end sub

sub AllChecked(chkCheck1 as CheckBox, chkCheckAll as CheckBox)

    code in here

end sub

Obviously, I need to reference chkCheckAll differently.  Ideas??

-------

Answer:

Here is one example of how to overcome the problem:

Sub Form_Load ()

    ReDim ctlA(2) As Control

    Dim i As Integer

    For i = 0 To UBound(ctlA)

        Set ctlA(i) = Label1(i)

    Next i

    LabelAll ctlA()

End Sub

Sub LabelAll (lblArr() As Control)

    lblArr(0) = "aa"

    lblArr(1) = "bb"

End Sub

Good luck

titov@nepo1.iaea.or.at


VB personalization

LUOKKA: VBgen

Date: 10/16/94 (14:41)              Number: 23205 of 23297 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Personalization - How To?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Michael Trigoboff (mlt.software@ortel.org) wrote:

>How do I personalize an application?

> In other words, I want the app to ask for name, company, and serial

> number

> the first time it runs, and then store the information inside itself.

There's a simple way to install a name and a serial number into an

application. Create some empty variables (filled with spaces) and scan your

exe file for the variables and insert the new text. I've done it in an

application of mine that puts a name and a crypted version of that name in a

VB-executable. If the user changes either of these, the program doesn't

work.

If you need example code (it's relatively small), I'll be glad to e-mail

it to you.

--

Arjen Broeze                                   Telephone: (+31)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13

                                                          7533 VR Enschede, NL


VB Power ToolKit

LUOKKA: commercial

2754 (34+)  mark@dfcuk.demon.co.uk  23.03.95  20:31

Mark Fleeson: "Re: Encryption VBX or Code"

I just picked up a brilliant book called Visual Basic Power ToolKit It contains

a chapter on Encryption and includes sample VB code to create encyrption

routines. It also has source for graphic FX code, you know wipes and all the

stuff that FXtools charge >200 quid for! The book is by Richard Mansfield &

Evangelos Petroutsos. It includes a CD with all of the sample code and is

brilliant.

---------------------------------------------------------------------------

" Mark Fleeson    EMail mark@dfcuk.demon.co.uk

" DFC

" +(44) 1442 827838


VB prog Name & Path

LUOKKA: VBgen

Date: 07/01/94 (10:24)              Number: 10839 of 10897 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: How can I find out the name and path of my running progr

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

If you're using VB 2.0 or 3.0 check the App object (App.Path, App.ExeName)

If you're using VB 1.0 you can use GetModuleFileName and GetWindowWord:

Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal

  nIndex As Integer) As Integer

Declare Function GetModuleFileName% Lib "kernel" (ByVal hModule%, ByVal

  FileName$, ByVal nSize%)

Const GWW_HINSTANCE = (-6)

Function GetApplicationPath (ByVal ihWnd As Integer) As String

Dim sBuffer As String

Dim hModule As Integer

Dim iLength As Integer

    ' Get instance handle of application

    hModule = GetWindowWord(ihWnd, GWW_HINSTANCE)

    ' Get the name and path of this instance

    sBuffer = Space$(255)

    iLength = GetModuleFileName(hModule, sBuffer, Len(sBuffer))

    GetApplicationPath = Left$(sBuffer, iLength)

End Function

This function returns the full-name and path of the application. You can

call it with the hWnd property of any window in your program. E.g.

    sCompletePath = GetApplicationPath(frmMain.hWnd)

--

Arjen Broeze                                   Telephone: (+33)53-311950

arjen@shear.iaf.nl                             Address:   Oostveenweg 55-13


VB Prog.Manager

LUOKKA: VBgen

Date:         Thu, 25 Aug 1994 19:00:44 EDT

From:         Gerry Hull

<"xanadu::mrgate::add::xanadu::am::hull"@XANADU.ENET.DEC.COM>

Subject:      Code FreeBee - Getting All Group Info from Progman  XE "Code

FreeBee - Getting All Group Info from Progman"

From:   NAME: Gerry Hull <HULL@AM@XANADU@ADD>

To:     NAME: VISBAS-L@tamvm1.tamu.edu

 <"VISBAS-L@tamvm1.tamu.edu"@US2RMC@MRGATE@XANADU>

I was helping out a friend who could'nt figure out how to get all the program

manger group information, so that he could modify program manager groups

via a VB application.  The Win31 API Help file provides the basic information

 Here is a little form which shows you how to get the groups and properties of

each item in a group - icon, appname, startup directory, location, etc.

With this, you can modify Progman stuff to your hearts content.

To use, just copy the text below the line info notepad,

save as XXX.FRM, then load into VB and make it the

startup form.

Gerry Hull

Consulting Software Engineer

Hull Associates

gerry@ha.mv.com

hull@xanadu.enet.dec.com

-----------------------------------------------------------------------

VERSION 2.00

Begin Form Form1

   BorderStyle     =   3  'Fixed Double

   Caption         =   "Progman Show Group Properties Example"

   ClientHeight    =   4956

   ClientLeft      =   1416

   ClientTop       =   2160

   ClientWidth     =   7368

   Height          =   5376

   Left            =   1368

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   4956

   ScaleWidth      =   7368

   Top             =   1788

   Width           =   7464

   Begin CommandButton Command1

      Caption         =   "Bye!"

      Height          =   732

      Left            =   60

      TabIndex        =   4

      Top             =   60

      Width           =   1752

   End

   Begin ListBox List2

      Height          =   2520

      Left            =   60

      TabIndex        =   1

      Top             =   2280

      Width           =   7032

   End

   Begin ListBox List1

      Height          =   1176

      Left            =   1920

      TabIndex        =   0

      Top             =   420

      Width           =   5352

   End

   Begin Label Label1

      Caption         =   "Hidden (DDE Use)"

      Height          =   252

      Left            =   60

      TabIndex        =   5

      Top             =   1080

      Visible         =   0   'False

      Width           =   1812

   End

   Begin Label Label2

      Caption         =   "Program Manager Groups (Double-Click for

                                  Properties:)"

      Height          =   312

      Left            =   2280

      TabIndex        =   3

      Top             =   60

      Width           =   4992

   End

   Begin Label Desc

      Caption         =   "Properties:"

      Height          =   252

      Left            =   60

      TabIndex        =   2

      Top             =   1920

      Width           =   2892

   End

End

Sub Command1_Click ()

Hide

End

End Sub

Sub Form_Load ()

Show

DoEvents

x$ = GetProgmanGroupsOrItems(Me, "")

pos = 1

Do While pos <> 0

    pos = InStr(pos, x$, Chr$(13) + Chr$(10))

    If pos = 0 Then Exit Do

    y$ = Left$(x$, pos - 1)

    List1.AddItem y$

    x$ = Mid$(x$, pos + 2)

    pos = 1

    DoEvents

Loop

End Sub

Function GetProgmanGroupsOrItems (x As Form, GroupID As String) As String

    Screen.MousePointer = 11

    '----------------------------------------------------------------------

    ' Windows requires DDE in order to create a program group and item.

    ' Here, a Visual Basic label control is used to generate the DDE messages

    '----------------------------------------------------------------------

    'On Error Resume Next

    '---------------------------------

    ' Set LinkTopic to PROGRAM MANAGER

    '---------------------------------

    x.Label1.LinkTopic = "ProgMan|Progman"

    If GroupID = "" Then

        x.Label1.LinkItem = "Groups"

    Else

        x.Label1.LinkItem = GroupID

    End If

    x.Label1.LinkMode = 2

    For i% = 1 To 10    ' Loop to ensure that there is enough time to

      z% = DoEvents()  ' process DDE Execute.  This is redundant but needed

    Next                     ' for debug windows.

    x.Label1.LinkTimeout = 100

    'Request the groups

    x.Label1.LinkRequest

    '-----------------

    ' Reset properties

    '-----------------

    x.Label1.LinkTimeout = 50

    x.Label1.LinkMode = 0

    Screen.MousePointer = 0

    GetProgmanGroupsOrItems = x.Label1.Caption

End Function

Sub List1_DblClick ()

x$ = GetProgmanGroupsOrItems(Me, (List1.List(List1.ListIndex)))

pos = 1

List2.Clear

Do While pos <> 0

    pos = InStr(pos, x$, Chr$(13) + Chr$(10))

    If pos = 0 Then Exit Do

    y$ = Left$(x$, pos - 1)

    List2.AddItem y$

    x$ = Mid$(x$, pos + 2)

    pos = 1

    DoEvents

Loop

End Sub


VB reboot & start Win

LUOKKA: VBgen

Date: 10/10/94 (11:29)              Number: 22498 of 22522 (Refer# NONE)

From: CRISJ@XNET.COM

Subj: Re: Reboot in VB?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Global Const EW_RESTARTWINDOWS = &H42

Global Const EW_REBOOTSYSTEM = &H43

Declare Function ExitWindows% Lib "User" (ByVal dwReturnCode, ByVal

Reservered%)

Reserved% is Set to zero.

If an app  will not terminate the returned value  will be zero


VB Systems Journal

LUOKKA: commercial

Date: 03-29-95 (08:57)              Number: 275570 of 277779 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Announcing "VB Systems Journal"

We are pleased to announce the release of a new monthly publication for

Visual Basic programmers entitled "VB Systems Journal."

HARDCORE VB. Each issue of VB Systems Journal delivers comprehensive

articles that teach in-depth programming techniques for tackling problems

head-on, without resorting to third-party VBXs.  Packed with source code and

expert advice, VB Systems Journal will help you create slick, professional

applications every time.  Shipped in a pre-drilled, 3-ring format for easy

storage and convenient research.  All source code available on diskette and

via our FTP site.

FEATURES:

Client/Server, Multiuser/ODBC/SQL Database Development,

Mainframe/Midrange Connectivity, System Programming, Advanced Windows

API, Windows 95 Development, DDE/OLE, MAPI, Network Connectivity,

DLL/VBX Development, Data Encryption, 3D Solid Modeling, Interactive

Graphics, Fractals, Artificial Intelligence, X10 Home Control,

Scientific/Engineering Applications, Multimedia, Utilities, Code Optimization,

Tips & Techniques

NO RISK! SATISFACTION GUARANTEED.

Send check or money-order for $39.95(U.S.) for a full year (12

feature-packed issues) of VB Systems Journal.  If you're not completely

satisfied, simply cancel your subscription, and a refund on the unused portion

of your subscription will be issued.  At just over $3/month this is an offer you

can't afford to miss.  ORDER NOW!

VB Systems Journal

800 Lasalle Blvd., Suite 105

Sudbury, ON P3A 4V4

For further information, forward e-mail to:  vbsj@mcd.on.ca


VB text to speech

LUOKKA: VBgen

Date: 11/10/94 (01:04)              Number: 26400 of 26484 (Refer# NONE)

From: TJT@NP.AC.SG

Subj: Re: Text to Speech Engine

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>I am looking for a vbx or dll that will allow me to convert text to

>speech.  The application I am working on is for someone who cannot

>speak but can see and hear.  If anyone knows of anything, I would

>appreciate any info.

The following is for the monologue software that comes with Creative Labs

Sound Blaster Pro. This is what I tried.

1. Run the speech-engine in Windows. "c: monologw fb_ngn.exe"

2. Try the following code:

'''START OF CODE

'General-declarations section

Declare Function OpenSpeech Lib "c: monologw fb_spch.dll" (ByVal

  hWnd%, ByVal mode%, ByVal Type1&) As Long

Declare Function CloseSpeech Lib "c: monologw fb_spch.dll" (ByVal

  lpSCB&) As Integer

Declare Function Say Lib "c: monologw fb_spch.dll" (ByVal lpSCB&,

  ByVal phrase As String) As Integer

Dim lpSCB As Long

Sub Form_Load ()

   Dim i%

   ChDir "c: monologw"

   lpSCB = OpenSpeech(0, 4000, 0&)

   i% = Say(lpSCB, "HELLO")

   i% = CloseSpeech(lpSCB)

End Sub

'''END OF CODE

In the dictionary that you have designed, use the first byte phonetics as

listed in Appendix B of Text-To-Speech User's Guide. Use the right phoneme

and phonetic modifier which can control the duration, pitch and volume of

that particular syllable so you can lay stress on that syllable.

Use the dictionary manager in the same directory to put in new words and

change the current words which may not sound too right.

For general pitch, volume and speed control, I suppose you set it when

running monologw.exe. I don't seem to be able to control it though.


VB Tips&Tric

LUOKKA: internet

Date: 02/11/95 (14:25)              Number: 222017 of 222168 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Visual Basic Tips & Tricks

If you open URL:

http://www.apexsc.com/vb/

you will be able to browse this site and find/download "VB Tips and

Tricks"... I have just done it now!!

If you still find any problem, please let me know!

Have a nice day,

Monica


VB vbx+dll+exe!

LUOKKA: VBgen

Date: 11/29/94 (06:51)              Number: 139201 of 139464 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Help! Need to make a standalone .EXE

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

The following is a short paragraph from Windows Tech Journal Dec 1994

issue:

"This years Start Tech winners.....

If you're responsible for supporting users who run Visual Basic

applications, you'll love VEXE.  This nifty little utility binds up Visual

Basic EXE files along with all the VBXs and DLLs that the app uses,

generating a new executable file.  This lets you install the app on a new

system by copying a single file and eliminates component

version-incompatibility problems."

VEXE is from:

Versatile Control Systems

2655 N. Ocean Dr.

Singer Island, FL  33404

(407) 881-9050

(407) 881-7345 (fax)

75144.3111@compuserve.com

I saw this entry last week and haven't had a chance to look into it.  It

sounds very interesting, especially for a setup program.  There have been

times where I wanted to distribute a non-VB app using the Setupkit, but it

seemed like such a waste to have to load VBRUN300.DLL and any other

extra

VBXs you might have incorporated to make your setup look neat.  Check it

out

and let the list know what it's capable of.


VB which app. running

LUOKKA: VBgen

25830 (42+)  aod@dodge.com  17.07.95  20:57

Andrew O. Dennison: "Re: I given much help now I want some (please)"

mappin@dircon.co.uk (Nix) wrote:

>How do i tell if another application is running. (without using the window

>title) I need to use something fixed like the exe name or the class name.....

Here are two bits which you should be able to use:

The first shows how to iterate over top level windows

The second will look up the exename from a win handle

' TASKLIST.BAS

Option Explicit

' Get the task list (or a close approximation of it) into a list box

'Windows API function declarations

'Enter each entire Declare statement on one, single line:

Declare Function GetWindow Lib "user" (ByVal hWnd%, ByVal wCmd%) As

Integer Declare Function GetWindowText Lib "user" (ByVal hWnd%, ByVal

lpString$, ByVal nMaxCount%) As Integer

Declare Function GetWindowTextLength Lib "user" (ByVal hWnd%) As

Integer

'Declare constants used by GetWindow

Const GW_CHILD = 5

Const GW_HWNDFIRST = 0

Const GW_HWNDLAST = 1

Const GW_HWNDNEXT = 2

Const GW_HWNDPREV = 3

Const GW_OWNER = 4

Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer,

ByVal nIndex As Integer) As Integer

Global Const GWW_HWNDPARENT = (-8)

Sub TaskListFIll (lstBox As ListBox)

    Dim currWnd%

    Dim length%

    Dim ListItem As String * 256

    Dim parent%

    lstBox.Clear

    lstTabs lstBox, "30,60, 90"

     lstBox.AddItem "hTask" & HT$() & "hWnd" & HT$() & "Parent" &

HT$() & "Caption"

    'Get the hWnd of the first item in the master list

    'so we can process the task list entries (top-level only).

    currWnd% = GetWindow(screen.ActiveForm.hWnd, GW_HWNDFIRST)

    'Loop while the hWnd returned by GetWindow is valid.

    While currWnd% <> 0

        length = GetWindowText(currWnd%, ListItem$, 256)

        'If there is a task name in the list, add the item to the list.

        If length > 0 Then

            parent% = GetWindowWord%(currWnd%, GWW_HWNDPARENT)

            'If parent% = 0 Then

                lstBox.AddItem Hex$(GetWindowTask(currWnd%)) & HT$() &

Hex(currWnd%) & HT$() & Hex(parent%) & HT$() & Left$(ListItem$, length)

            'End If

        End If

        'Get the next task list item in the master list.

        currWnd = GetWindow(currWnd%, GW_HWNDNEXT)

    Wend

End Sub

Option Explicit

Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer,

ByVal nIndex As Integer) As Integer

Declare Function GetModuleFileName Lib "Kernel" (ByVal hModule As

Integer, ByVal lpFilename As String, ByVal nSize As Integer) As Integer

Const GWW_HINSTANCE = (-6)

' Get ExeName From the window handle

Function ExeName$ (hWnd%)

    Dim hInstance%, fileName As String * 128

    Dim l%

    ' Get the instance handle

    hInstance% = GetWindowWord%(hWnd%, GWW_HINSTANCE)

    ' Then exename

    l% = GetModuleFileName%(hInstance%, fileName$, Len(fileName$))

    ExeName$ = TrimLen$(fileName$, l%)

End Function


VB written in VB???

LUOKKA: VBgen

Date: 06/24/94 (18:30)              Number: 10249 of 10249 (Refer# NONE)

From: JO1919G92@AUVAX1.ADELPHI.EDU

Subj: Re: VB Quiz

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>Brad Murray (jo1919g92@auvax1.adelphi.edu) wrote:

>: OK, here's a test question for all of you.  How can you tell if an app is

>: written in VB?

1. If it minimizes itself, (WindowState = 1) it doesn't go to the bottom of the

   task list.  It goes to spot number 2

2. If you tile or cascade all applications in Windows, the VB windows don't

   cascade because they all have an invisible parent window (which does

   cascade but you can't see it).

_______________

" Bradley S. Murray                     Phone: (609) 799-5300                 "

" Princeton Computer Consulting, Inc.     Fax: (609) 275-5651                 "

" PO Box 7345                        Internet: jo1919g92@auvax1.adelphi.edu   "

" Princeton, NJ 08543-7345


VB yleistä

LUOKKA: VBgen

Päivä: 06-12-94 (19:02)             Numero: 2138 / 2218 (Vast. nro 2123)

Knlle: EERO LEHIKOINEN

Knltä: SAMI PITKO

 Aihe: VB:n INI ja HELP...

Luettu: 06-12-94 (23:16)              Tila: Julkinen viesti

 Kok.: Ohjelmointi (23)           Lukumalli: Etsi tekstiä (+)

>Vaan olen saanut WAV-tiedostot soitettua mutta pitäisi joskus tarkistaa

>josko siellä olisi jo ennestään soimassa WAV! sitä ei standart VB:ssä

Harmi etten ole tarvinnut töissä koskaan äänikortteja, joten en ole

tutustunut mitenkään tuohon MMSystemiin... mutta helppitiedostosta näkyy

löytyvän tuollainen event kuin Sub MMControl_Done(NotifyCode as Long).

Sinne kun laitat jonkun globaalin muuttujan päivityksen, jotta nyt saa

taas soittaa, ja ennen jokaista soittoyritystä käyt tarkistamassa sen.

Tämä siis 3.0Pro:ssa. Mutta eipä se kai ole hirveästi muuttunut...

>Tuosta muistin kuluttamisesta, selasin tekemääni pientä harjoitelmaa

>Heditillä (HexaEditori), ja siellä on pitkin matkaa 00 kohtaa, eli

>kääntäjä voisi hieman vaikkapa pakata ohjelmaa jotenkin ;) tosin siellä

Voisi pakata, muttei pakkaa. Siksi jokainen icon ja bmp kuva, jonka

liittää mukaan formiin, lisää EXE tiedoston kokoa omalla koollaan ja

muutamalla tavulla overheadia.

Lisäksi VB:n tekemä EXE tiedosto on oikeastaan vain jonkinasteista

välikoodia, joka suorittaa kutsuja VBRUN300.DLL tiedostoon. Eli siksi

VB:llä voidaan ajaa ohjelmaa täsmälleen yhtä nopeasti (hitaasti)

kehitysympäristössä kuin lopullisena EXE tiedostonakin. Mutta "oikea"

EXE tiedosto se ei ole. Oikeastaan VB on tulkkaava kieli, kuten GWBasic.

>Tiedätkös mitään pientä resurssimittaria jolla tuota voisi seurata?

Barclock. Näyttää myös levytilan ja kellonajan. Ja uusin versio (2.3?)

osaa myös hälyyttää vaikkapa nukkumaanmenosta...

>VB:n v. 2.0 standart kun ei mokomia lisukkeita sisällä, ei myöskään

>valmiita dialogeja (OpenSaveFile... vastaavaa) hm, onnistuisikohan

Common dialogit saa käyttöönsä CMDIALOG.VBX:llä tai kutsumalla

COMMDLG.DLL suoraan.

>Ainiin, piti kysymän: miten nuo VB:n projectiin liitetyt moduulit (*.bas

>ym.) käännettäessä, kääntääkö VB ne mukaan vaikkei kaikkia rutiineja

>käytettäisikään, tuo rajaisi rutiinien keräämisen yhteen tiedostoon :(

Kääntää kaikki mukaan.

>Onkos kokemuksia? vai pitäiskö ne kukin van laittaa omiin moduuleihinsa?

Sopiviin paloihin kun jaottelee, niin pystyy helposti pitämään projektit

kohtuullisen kokoisina. Joitakin perusfunktioita (kuten INI-tiedostojen

käsittely, ISO<->IBM skandikonversiot) kannattaa niputtaa vaikka

GENERAL.BASiksi. Siihen samaan tiedostoon sitten kannattaa laittaa noita

usein käytettyjä vakioita (MB_OK, MB_OKCANCEL, NORMAL, MINIMIZED,

MAXIMIZED).

Ja yleensä ottaen kaikki koodi, mitä tarvitsee kutsua myös muualta kuin

juuri siitä samasta formista _pitää_ laittaa omaan moduuliinsa. Vain

moduulien aliohjelmat "näkyvät" kaikkialle (ellei sitten laita Private

Sub:ia).

>Olen näemmä kysely iässä.

Se on parempi ikä, kuin turhien vastausten ikä...

Spitco


VBFAQ del pic propert

LUOKKA: graphics

19.How do I remove/change the picture property of a control at design

   time?

   Mark the (bitmap) or (icon) text in the property window and press

   Del or Backspace. "No!" I hear you cry, "It doesn't work". Well, it

   does if you first select the object from the combo box at the top

   of the Properties Window, and then immediately afterwards

   doubleclick (or paint over) the "(bitmap)" text and press Del.

   Alternatively, just click on another control, then click back to

   the first control. Now Del works. Who said "bug"?

   If you want to paste your picture directly into the VB program by

   pressing Ctrl-V when you are editing the picture property, you will

   have to use a semilar procedure: select the control, select the

   property, press Ctrl-V. If you try it again without deselecting the

   control first (or selecting it from the combo box), it doesn't

   work.


VBFAQ detect prev ins

LUOKKA: VBgen

24.How do I prevent multiple instances of my program?  ++

   In VB 3, the property App.PrevInstance is set to True if an older

   instance of the program already exist.

   The following piece of code, stolen from MS KB article Q102480,

   will activate the old instance and then terminate itself:

     Sub Form_Load ()

       If App.PrevInstance Then

          SaveTitle$ = App.Title

          App.Title = "... duplicate instance."      'Pretty, eh?

          Form1.Caption = "... duplicate instance."

          AppActivate SaveTitle$

          SendKeys "% R", True

          End

       End If

     End Sub

   As Robert Knienider(rknienid@email.tuwien.ac.at) informed me, this

   piece of code WILL NOT work for non-English versions of MS Windows

   where the word for "Restore" does not have "R" as the underlined

   word. Replace the "R" in the SendKeys line above with " ENTER " or

   "~".

   Note that you shouldn't prevent multiple instances of your

   application unless you have a good reason to do so, since this is a

   very useful feature in MS Windows. Windows will only load the code

   and dynamic link code *once*, so it (normally) uses much less

   memory for the later instances than the first.


VBFAQ general info

LUOKKA: VBgen

2. Where to get the VB/Win FAQ

   Most FAQs (including this one) are available at the anonymous ftp

   archive site "rtfm.mit.edu". All parts of the VB FAQ may be found here:

     ftp://rtfm.mit.edu/pub/usenet/comp.lang.basic.visual.misc/

   **Alternative Sites**:

   The following are alternative sites to rtfm:

   N. America: ftp.uu.net             /usenet/news.answers

   Europe:     ftp.uni-paderborn.de   /pub/FAQ

               ftp.Germany.EU.net     /pub/newsarchive/news.answers

               grasp1.univ-lyon1.fr   /pub/faq

               ftp.win.tue.nl         /pub/usenet/news.answers

               ftp.sunet.se           /pub/usenet

   Asia:       nctuccca.edu.tw        /USENET/FAQ

               hwarang.postech.ac.kr  /pub/usenet/news.answers

   (FYI:  "rtfm" stands for "Read The ******* Manual".  I kid you not!)

   ÄAndre van Meulebrouck (vanmeule@ils.nwu.edu)Å

   You can also have the VB FAQs e-mailed to you by sending a message to

   "mail-server@rtfm.mit.edu" with ONLY the text

     send usenet/comp.lang.basic.visual.misc/*

   in the BODY of the message.

   Alternative mailservers for those who have no ftp access

     ftpmail@decwrl.dec.com or ftpmail@cs.uow.edu.au

     bitftp@pucc.princeton.edu or ftpmail@lth.se

     bitftp@dearn or to bitftp@vm.gmd.de (Europe only)

     ftpmail@ftp.uni-stuttgart.de

     ftpmail@grasp.insa-lyon.fr or ftpmail@ieunet.ie

     bitftp@plearn.edu.pl or bitftp@plearn (Europe)

     ftpmail@doc.ic.ac.uk or ftpmail@sunsite.unc.edu

   Äthanks to Jakob Faarvang (jakobf@colossus.ping.dk)Å

   For all mailservers:

   Use the "index" command to get a list of files available at the site.

   Use the "help" command to get more detailed instructions.

   (NOTE: commands are in BODY of mail message!)

3. Where can I get updated VB and other Microsoft files?

   Microsoft Software Library (MSL) is accessible from the following

   services:

   - Compu$erve

     GO MSL

     Search for <filename.EXE>

   - Microsoft Download Service (MSDL)

     Dial (206) 936-6735 to connect to MSDL

   - Internet (anonymous FTP)

     ftp ftp.microsoft.com

     Change to the ÖsoftlibÖmslfiles directory

     (There are a LOT of files in this directory! It is not

     advisable to list all the files unless you have good time.

     See map below.)

4. Help! I am lost on ftp.microsoft.com.

   You no longer have to be! The site have been reorganised, and you'll

   find the file DIRMAP.TXT in root (or whatever it's called on a 3.5 NT

   server). Here's the file as I found it (stolen ruthlessly from the

   server for yoru convenience):

   *-------------------------------------------------------------------*

   This file is to help you find your way around ftp.microsoft.com. This

   file only covers the directory structure two levels deep. If you see a

   'kb' directory in a second level directory, it contains all of the

   information regarding that second level directory.  For example, the

   /developr/win32dk directory has a kb directory in it.  This kb directory

   contains all of the articles for any 32 bit development kit.

   ROOT DIRECTORY         SUB DIRECTORY         CONTENTS

   -----------------------------------------------------------------------

   ADVSYS                          Advanced Systems, Networks, Mail

                       LANMAN      LanMan & other networks

                       MAIL        Mail and Schedule+

                       MSCLIENT    Microsoft Networking Client

                       SQL_ODBC    SQL and ODBC

                       WINNT       Windows NT

                       WINSOCK     Windows Sockets information

   DESKAPPS                        Desktop Applications

                       ACCESS      Access

                       DOSWORD     Word for MS-DOS

                       EXCEL       Excel

                       GAMES       Entertainment Packs, Flight Sim, etc.

                       HOMEAPPS    Home applications

                                   (Fine Artist, Creative Writer)

                       MISCAPPS    Other applications

                       MMAPPS      Multimedia Titles

                       OFFICE      Microsoft Office

                       POWERPT     PowerPoint

                       PROJECT     Project

                       PUBLISHER   Publisher

                       WORD        Word for Windows & Macintosh

                       WRKS_MNY    Works and Money

   DEVELOPR                        Developer Tools and Information

                       BASIC       Quick Basic & other Basics

                       DEVCAST     DevCast information

                       DEVUTIL     MS Test, Delta, EXEMOD, EXEPACK,

                                   & LIB Utility

                       DRG         Developer Relations Group

                       FORTRAN     Fortran and Fortran PowerStation

                       FOX         FoxPro and FoxBase

                       MAPI        Messaging API information

                       MASM        Macro Assembler

                       MSDN        Microsoft Developer Network

                       MSJ         Microsoft Systems Journal

                       OLE         OLE

                       TAPI        Telephony API information

                       VB          Visual Basic

                       VISUAL_C    Visual C++, MFC, & other C products

                       WIN_DK      Windows SDK, DKs & At Work

                       WIN32DK     32 bit Development Kits

   MSEDCERT                        Microsoft Education and Certification

                       EDUCATIO    Microsoft Education information

                       CERTIFIC    Microsoft Certified Professional info

   MSFT                            Microsoft shareholder information

                       ANNREPT     Microsoft Annual Report

                       BACKGRND    Background information on Microsoft

                       PRESSREL    Microsoft Press Releases

                       SEC         Recent filings with the Securities and

                                   Exchange Commission

   SOFTLIB                         Instructions & index for software

                                   library

                       MSLFILES    Software library files (> 1500 files)

   PEROPSYS                        Personal Operating Systems and Hardware

                       HARDWARE    Mouse & other Hardware

                       MSDOS       MS-DOS

                       WINDOWS     Windows (all versions)

                       WIN_NEWS    Information on Windows "Chicago"

   TECHNET                         Information on TechNet

                       SERVDIR     Microsoft Services Directory

   *-------------------------------------------------------------------*

   NOTE: Directory and file names at ftp.microsoft.com are NOT case

   sensitive.

   Thanks to Richard Mason (richard@whitney.demon.co.uk) for the map he

   made for us before this long overdue reorganisation, and thanks for

   bringing this to my attention.

5. Where can I get good up-to-date information about VB?

   If you do any VB programming at all, you really should get the latest

   copy of the Microsoft Knowledge Base from one of the sources listed

   above!  The filename is VBKB.EXE or VBKB_FT.EXE for the version with

   full text searching. The Knowledge Base is a Windows help formatted

   document that is updated almost monthly. (Beware: The files are huge!)

   The EXE files on ftp.microsoft.com (and other places) are simple self-

   extracting files. They don't do any automatic updating of your system,

   just dump the file(s) inside them in the current directory on your disk,

   uncompressed and ready for use. Just replace the old files on your

   system with the new files (same name, usually).

   This FAQ (ahem) is a pretty good source as a digest of many of the VB

   issues that are discussed in the comp.lang.basic.visual.* newsgroups,

   but as such the information contained in this FAQ may not have been

   thoroughly tested or verified.

   For easier access to and use of this FAQ document, get the Windows Help

   file format FAQ doc by anonymous ftp to quasar.sba.dal.ca and look under

   /www/hlp. The .HLP version is made by Tim Roberts

   (TJR@SBACOOP.SBA.DAL.CA). This is HIGHLY RECOMMENDED.

   WWW pages for VB? Carl 'n Gary's Visual Basic HomePage is a good place

   to start:

      http://www.apexsc.com/vb/

   This page has hotlinks to lots of goodies, including the FAQs, clbv.*

   archives (with search tool), etc. ÄGary Wisniewski (gary@apexsc.com)Å

   Dave McCarter puts out a nice Windows help formatted document called

   "Visual Basic Tips and Tricks". A good resource with information that

   isn't found in the Knowledge Base. It can be found by anonymous ftp to

   ftp.cica.indiana.edu /pub/pc/win3/programr/vbasic/ as VBTIPS??.ZIP,

   where '??' is the version number (yes, get the one with the highest

   number).

   Mark Schoonover has started a monthly magazine called _VBWin

   Programmer's Magazine_ that is compiled around the Discussion of

   Microsoft Visual Basic and Related Issues mailing list. This magazine is

   available at the usual ftp sites like cica and at his BBS (619) 571-

   2846. Mark can be contacted at schoon@cts.com. It also has its own

   anonymous ftp site: ftp.cts.com in the /pub/schoon/VBWM.Issues

   directory.

   There is presently an effort to put together a VB code library so that

   VB users can share their best - and trickiest - programming work. The

   code library project is being spear headed by Hein Ragas who has

managed

   to get a directory on CICA for code snippets to be deposited. Stayed

   tuned to comp.lang.basic.visual.misc for more information.

   There's a VISBAS-L mailing list for Visual Basic (Thanks to David Liden

   (DL9U@Virginia.EDU) for tracking it down for me when it moved). You can

   subscribe to this mailing list by sending an email to

     listserv@listserv.tamu.edu

   Place the following text in the *body* of the message (no, not the

   subject line):

     SUB VISBAS-L Real Name

   Where Real Name is just that, *your full real name* not your email

   address. Note that the traffic on this list may overflow your mailbox if

   you have a limited mail buffer. Expect around 40-50 messages every

   weekday, a bit less during weekends. Also, to unsubscribe, do as above

   but with "UNSUB" in the body of the message to the LISTSERV address,

   *not* to the VISBAS-L list address itself (Believe it or not, we usually

   receive 2-3 sub/unsub mails every day on the list, and we're really fed

   up!) Also, this mail server was split and a new list called VBDATA-L was

   made for Vb database (Jet) related topics. Same procedure for

   registering (SUB VBDATA-L Real Name).

   The address for the MS ACCESS listserver is listserv@indycms.bitnet or

   listserv@indycms.iupui.edu The list name is ACCESS-L. To subscribe, you

   follow the same procedure as for the other lists.

   Sorry, I know no mailservers or other Internet resources dedicated to

   VBA specifically. Send me any information you may have, and I'll bring

   it on.

   There are several Usenet newsgroups dedicated to MS Windows

programming

   and use. Those groups that may be of special interest to VB programmers

   are marked with *:

   comp.os.ms-windows.misc

   comp.os.ms-windows.programmer.misc

   comp.binaries.ms-windows

   comp.os.ms-windows.advocacy

   comp.os.ms-windows.announce

   comp.os.ms-windows.apps

   comp.os.ms-windows.nt.misc

   comp.os.ms-windows.nt.setup

   comp.os.ms-windows.programmer.tools     *

   comp.os.ms-windows.programmer.win32

   comp.os.ms-windows.setup                *

   comp.os.ms-windows.programmer.winhelp   *

   comp.os.ms-windows.programmer.networks

   comp.os.ms-windows.programmer.graphics

   comp.os.ms-windows.programmer.controls  *

   The latest groups have been added to split the enormous traffic on the

   *.misc groups down in managable chunks. However, the second group

   (.programmer.misc) contains lots of interesting info (mostly C related),

   if you have the time to read it all!

   Also note comp.lang.pascal which is a very good newsgroup for Pascal,

   including Borland Pascal, Turbo Pascal for Windows and Delphi.

   Please don't use this guide to find out where you should crosspost VB

   questions. Check the charter for each group before posting to it. If you

   are sure that your crosspost is legitimate, please note the crossposting

   in the text.

   NOTE: PLEASE don't post VB stuff to comp.lang.visual. This group has

   *nothing* to do with Visual Basic, and the academics discussing "real"

   visual programming there are very, very annoyed at what they call

   "quasi-visual" stuff and postings about those languages to their group.

   There are magazines dedicated to VB. The best known is Fawcett

Technical

   Publications' _Visual Basic Programmer's Journal_ (VSPJ). Phone 800-848-

   5523 (for US credit card orders) or 303-541-0610 (int'l and US other

   orders), Email 74003.224@compuserve.com to Shirley Modric for

   subscription info. Address is 280 Second Street, Suite 200, Los Altos,

   CA 94022-3603 USA.

   From Randy Coates (rcoates@telerama.lm.com):

   I currently subscribe to "Inside Visual BASIC for Windows" from the Cobb

   Group.  Although it is a helpful monthly paper (about 14 pages per

   publication), I find it to be overpriced when compared to VB Programmers

   Journal.  Here is the information anyway: Domestic $59/yr ($7.00 each);

   Outside US $79/yr ($8.50 each)

   Phone: Toll Free: 800-223-8720),  Local: 502-491-1900, Customer

   Relations Fax: 502-491-8050, Editorial Department Fax: 502-491-4200.

   Address: _Inside Visual BASIC for Windows_, 9420 Bunsen Parkway, Suite

   300, Louisville, KY  40220.

   (Note: for completeness other VB magazines should be listed, and I would

   like to receive info on those!)

I.    Structure of the COMP.LANG.BASIC.VISUAL Hierarchy

      The fall of 1994 brought about some drastic changes in the

      structure of the Comp.Lang.Basic.Visual Hierarchy. These changes

      were due to the creation of 4 new newsgroups and the eventual

      status change of the original group.

      The New groups divide up the discussions concerning specific

      applications of Visual Basic and types of tools used in the

      development process. The basic outline of groups is shown below:

      COMP.LANG.BASIC.VISUAL             Holding Group

        ö--------- .DATABASE             Un-Moderated

        ö--------- .3RDPART              Un-Moderated

        ö--------- .MISC                 Un-Moderated

        ö--------- .ANNOUNCE             Moderated

      The original CLBV newsgroup will eventually be phassed out as a

      discussion group and will be a hierarchy name used to contain the

      child groups. Please make a concerted effort to use the new

      groups as soon as they are available at your site. Although it

      has been quite some time since the creation, I understand that

      some sites are just now (mid-November of '94) beginning to see

      the new groups. Once the new groups "arrive" at your site, please

      refrain from posting to the actual comp.lang.basic.visual group;

      please use the new .misc group for general postings.

      The DATABASE sub-group is dedicated to the discussion of the uses

      of Visual Basic in database applications, and various database

      specific tools.

      The 3RDPARTY sub-group is dedicated to discussions and questions

      concerning add-ons to the Visual Basic environment. These add-ons

      can take the form of VBX or OCX controls, DLL Libraries or LIB

      Libraries, or development utilities which enhance the IDE.

      The MISC sub-group replaces the current clbv newsgroup. This is

      the place for discussion not appropriate in the other un-

      moderated groups.

      The ANNOUNCE group is a moderated group which is the appropriate

      place to post announcements concerning bug fixes (from vendors),

      new product announcements, Usenet management postings (such as

      RFD's, CFV's, and such for related groups), and other vendor

      support postings.

II.   The COMP.LANG.BASIC.VISUAL Charter:

      COMP.LANG.BASIC.VISUAL is an unmoderated forum to share

      information about Microsoft's Visual Basic for Windows and

      MS-DOS, as well as the new "Application Basic" embedded in MS

      applications such as Word for Windows, Excel, and Access.

      Microsoft provides no Internet support channel for Visual Basic,

      so this group will let Visual Basic users get together to help

      each other, without requiring them to filter through unrelated,

      broader Windows programming issues.

III.  The COMP.LANG.BASIC.VISUAL.DATABASE Charter:

      This group will contain discussion about the various database

      programming issues using Visual Basic. Disucssions should be

      limited to topics pertaining only to database applications and

      tools. Discussions will not be limited in any way to specific

      database engines (however, the applications of the built-in JET

      engine will most like dominate).

      This will be an unmoderated group.

IV.   The COMP.LANG.BASIC.VISUAL.3RDPARTY Charter:

      The creation of a dedicated group to hold postings concerning

      various tools which add on to the basic Visual Basic product.

      These tools would include additional controls (VBX's), both

      commercial, shareware, and freeware. Discussions will also cover

      additional .DLL's and their applications in the Visual Basic

      environment. Note that discussion concerning API's should _NOT_

      be posted to this group as they are inherent to the VB base

      product. Discussions about API calls should be taken up in the

      .misc group (see below). This group would also house discussions

      on various development tools (eg SPYWORKS, etc...) and their

      uses.

      This group will also contain questions and answers to people

      looking for various tools to accomplish specific tasks.

      Additionally, it is hoped that various commercial vendors that

      supply such tools would take part in discussions concerning their

      respective products as a forum for general tech support for those

      tools.

      This will be an unmoderated group.

V.    The COMP.LANG.BASIC.VISUAL.ANNOUNCE Charter:

      It has become apparent that an "official" information group could

      benefit all participants in the various subgroups of the

      comp.lang.basic.visual hierarchy. Acceptable posts to this group

      would include FAQ posts, shareware announcements, other usenet

      administrative posts (like this entire discussion), etc...

      This will be a moderated group.

VI.   The COMP.LANG.BASIC.VISUAL.MISC Charter:

      The .misc group is required by Usenet guidelines, and will be a

      place for any discussions of topics which are not covered by the

      other three groups. Topics might include queries on Visual Basic

      methods, or API commands, applications of the standard set of

      controls, general use of the BASIC language, general discussion

      about programming techniques, general concepts of event-driven

      programming, etc...

      The .misc group would basically replace the current

      comp.lang.basic.visual discussion group where all of the above

      topics (and more) are being discussed daily. The split of the

      other groups should drastically reduce the amount of volume in

      this "catch all" group.

      This will be an unmoderated group.


VBFAQ index&db&dctrl

LUOKKA: Access

1. Why can't I use an index with my VB accessed database?

   There is a mistake in the docs which says you can set the active index

   for a recordset. You can't. The data control uses the primary key for

   tables and physical order (I think) for dynasets.

   Nic Gibson (nic@skin.demon.co.uk)

   NOTE: You can of course set the indexes yourself using code in VB/Pro

   (Table objects), but Data Control's can't. Sorry for the problems this

   possible misunderstanding caused!

   Thanks to John McGuire (jmcguire@jax.jaxnet.com) for clarifying this.


VBFAQ install.ISAM

LUOKKA: Access

2. "Can't find installable ISAM" or Why does my compiled VB database app

   generate an error when it ran just fine in the design environment?

   You can thank Microsoft for documenting this topic so poorly. When you

   compile your VB database application, you must also have an INI file for

   it which provides the correct pointers to the appropriate database

   drivers. Therefore, if your application is named "INVOICE.EXE", you will

   need to have a properly configured "INVOICE.INI" file in your Windows

   directory. The file, EXTERNAL.TXT, that came with VB should explain all

   about it.


VBFAQ text/binary

LUOKKA: VBgen

3. Why does everybody say I should save in TEXT not BINARY?

   Actually, saving in binary mode is a bit faster, so why do we

   recommend you to save in text?

   If you save the source and the project as text, it becomes ASCII

   (or really, ANSI) code that you can edit with any text editor or

   (if you are careful when you save) word processor. If you save in

   binary, only the VB development environment, current or later

   versions, will understand the code. The Setup Wizard can not scan

   binary projects. Also, source documenters and other programming

   tools usually require text mode. If you use text, you can use a

   simple text editor (ie. notepad) to cut and paste code from other

   source/form modules into your current project. Some 'tricks' (like

   making an array of 1 control into a single non-array control again)

   is easily done with an editor but not that easy in the environment.

   If you want to print your project to paper the file"print option in

   the VB environment is often not good enough; you may want to import

   the text files into your word processor. And, finally, if something

   goes wrong (only one byte is changed!) you may be out of luck in

   binary mode. In text mode you will more easily be able to fix it.


VBFAQ where?

LUOKKA: VBgen

Date: 01/14/95 (15:13)              Number: 32495 of 32710 (Refer# NONE)

From: WHM@PLAZA.DS.ADP.COM

Subj: Re: Help on Accessing Visual Basic Files

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

   Most FAQs (including this one) are available at the anonymous ftp

   archive site "rtfm.mit.edu". All parts of the VB FAQ may be found

   in the directory "pub/usenet/comp.lang.basic.visual".

   Bill Morrison                                whm@plaza.ds.adp.com


VBPJ European subscri

LUOKKA: VBgen

9571 (196+)  Alain.Nadeau@unifr.ch  16.03.95  20:31

"Nad": "Re: VB Technical Journal"

Robert Scoble writes:

>Thanks for the comments. I think you'll all like the April issue of

>our magazine which shows how to use VB to access/use/abuse/program

>the net. Maybe even a few of you will stop calling us idiots <g>.

>It should be on your doorstep in a week or two.

For USA subscribers, that is; add a few weeks if you happen

to live in Europe, as VBPJ's *air mail only* service to Europe

appears to mean sending the Mags in bulk to Rotterdam, from

where individual issues are then remailed.  Since this last leg of

the Mag's journey (from Rotterdam to Switzerland) usually takes

around 10 days, I normally get my copy three weeks after

people have started discussing (or should I say flaming) it here.

I wouldn't mind the delay  if VBPJ did not charge (almost)

4 US$ an issue for delivery...  At that price one should

expect *real* air mail service, that is four or five days...

That is MY major gripe with the magazine (which I otherwise

rather enjoy).

Alain.


VBPJ listings internet

LUOKKA: VBgen

Date: 09/30/94 (12:05)              Number: 21278 of 21392 (Refer# NONE)

From: PETER@SKEL.DEMON.CO.UK

Subj: VBPJ aug/sept listings announce

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The listings for the August September issue of Visual Basic Programmers

Journal is available on the net as

  vbpj.augsept.zip

in the directory

  /pub/ibmpc/windows/vbasic/vbpj

on

  ftp.demon.co.uk

enjoy!

--

Peter Dyson


VBPJ news

LUOKKA: VBgen

Date: 09/09/94 (03:30)              Number: 18801 of 18922 (Refer# NONE)

From: 74774.305@COMPUSERVE.COM

Subj: Re: VBPJ News!

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Message-ID: <34o24d$n7h$2@mhade.inhouse.compuserve.com>

Newsgroup: comp.lang.basic.visual

Organization: Visual Basic Programmer's Journal

Just wanted to let you know about some things we're announcing:

1) starting with the December issue we're going monthly!

2) Starting later this month we're opening a CompuServe forum

(actually two forums). One will be so you can get product support

from the leading VBX and OCX vendors (about 20 vendors have

already signed up) and another forum for Visual Basic and

magazine discussion. We'll be posting our code there in

electronic format so you won't have to type it anymore. It'll

open around September 20 and you'll get to both by typing GO VBPJ

at the prompt.

3) We're going to start a VB-CD subscription in late fall. This

will have a lot of sample code, goodies, and all of the VBPJ

issues is Adobe Acrobat format.

To inquire about the CD, please send a fax to 415-948-7332.

Thanks. Hopefully I haven't broken too many rules about

advertising on the Internet <g>.

Robert Scoble

Visual Basic Programmer's Journal


Vbx Borland

LUOKKA: vbx

Date: 03-09-95 (04:26)              Number: 250705 of 251087 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: control development kit

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

    In order to build a .vbx control using Borland C++ 3.1, you must first

build the project as a .dll, and then rename the resulting .dll file to the

.vbx extension. A .vbx control really is just a special .dll for Visual

Basic. If you build the control as a .dll, and then rename it to .vbx

extension, that will work.

    To edit the resources of an existing .vbx control using the Borland C++

3.1 version of Resource Workshop, you must first rename the file to .dll

extension, and then you can load it into Resource Workshop. However, you

can't install a .vbx custom control in the 3.1 version of Resource Workshop.

    I hope this has been of help, and everything I have described here I have

actually tried, and it works.

Richard Buttars


Vbx create

LUOKKA: vbx

8. How can I create a VBX?

   VBXs (Visual Basic eXtensions) are practically always written is C

   (Borland C++, but mainly MS VC++). You should refer to the _Control

   Development Guide_ (in VB Professional Features Vol. I) and any

   relevant documentation for your compiler. Followup questions should

   normally be directed to comp.os.ms-windows.programmer.* or

   comp.lang.c*.

   There are some example VBX's with C code supplied with VB3 Pro.

   You'll find them under the directory  VB  CDK.


Vbx create Borland

LUOKKA: vbx

Date: 04/16/94 (17:56)              Number: 3745 of 3757 (Refer# NONE)

From: ENG359@NOF.ABDN.AC.UK

Subj: Re: How to make VBX's with Borland C

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

labenrsa@icil64.cilea.it wrote:

: In article <2ojhg9$f98@nof.abdn.ac.uk>, eng359@nof.abdn.ac.uk (a.boyd)

writes:

: > I've heard that VBX's can be created using Borland C/C++; the VB FAQ

: >file even mentions it. Could anyone please tell me how?

: It's much more simple than what is told in an article that is available

: on cica (it referred to the VB1 CDK). Forget it.

: Say you're trying to rebuild CIRC1 (the 1st example from the MS CDK).

: Just make a project in compact or large model, for a Windows DLL.

: Include VBAPI.LIB, the .RC script, the .DEF file together with the

: sources in the project. DO NOT DO NOT DO NOT use the startup code

: provided with the CDK. If you do it, the BC RTL functions linked in

: will happily overwrite your unwary data segment with their static data.

: Just let BC link in its default DLL startup code. Compile and link,

: that's all. (well, rename the dll file to a .vbx).

Thanks for the response. However, the trouble I'm having occurs when I try

to link vbapi.lib. My version of Borland C (v3.1) won't accept it. If I include

it specifically I get a 'vbapi.lib is not an object file' type error. If I just supply

the linker with the appropriate lib directory it ignores vbapi.lib as if it isn't

even there. Am I doing something obviously silly? Am I missing something?

Does anyone else have this problem?

Allan.


Vbx create Borland

LUOKKA: vbx

Date: 04/16/94 (20:53)              Number: 3761 of 3818 (Refer# NONE)

From: LABENRSA@ICIL64.CILEA.IT

Subj: Re: How to make VBX's with Borland C

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>: that's all. (well, rename the dll file to a .vbx).

>Thanks for the response. However, the trouble I'm having occurs when I try

>to link vbapi.lib. My version of Borland C (v3.1) won't accept it. If I include

>it specifically I get a 'vbapi.lib is not an object file' type error. If I

>just supply the linker with the appropriate lib directory it ignores vbapi.lib

>as if it isn't even there. Am I doing something obviously silly? Am I missing

>something? Does anyone else have this problem?

Methinks I moved vbapi.lib to  borlandc lib, and included it by the full path in

the project file. I don't recall having any further trouble.

Andy


Vbx create Borland

LUOKKA: vbx

Date: 04/25/94 (19:23)              Number: 4220 of 4220 (Refer# NONE)

From: PAPABEAR@ANDOSRV.SAS.UPENN.EDU, Joe Barber

Subj: Re: How to make VBX's with Borland C

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

labenrsa@icil64.cilea.it wrote:

: In article <2p3du6$7or@olymp.informatik.uni-bonn.de>,

rattay@athene.informatik.uni-bonn.de (Robin Rattay) writes:

: >a.boyd (eng359@nof.abdn.ac.uk) wrote:

: >:  I've heard that VBX's can be created using Borland C/C++; the VB FAQ

: >: file even mentions it. Could anyone please tell me how?

: >

: >You need BC++ Verion _4.0_ !

: >: >Robin

: Wrong. I succesfully created a couple of VBXs of my own with BC++ 3.1,

: besides recompiling those that come with the CDK. I already posted

: some info on how to do it a few days back. However....

: 1 - Copy vbapi.lib to  borlandc lib, vbapi.h to  borlandc include or whatever.

: 2 - Go into the VBX dir (let's say CIRC1 from the MS CDK). Make

:     a project for a Windows DLL, large or compact model.

: 3 - Include .rc, .c .def files in the project. Include vbapi.lib. DO NOT, for

:     any reason, include the start-up code that comes with the CDK. BC++   :

    RTL requires its own, or it will trash the DLL data segment.

: 4 - Make, then rename the .DLL to a .VBX. You are done.

: Other, more sophisticated samples in the CDK use special MSC keywords

: for segment manipulation that you can easily replace with FP_SEG and

: some intelligent casts.

I had a lot of problems creating my first VBX using BC 3.1.  The only

way I could get the VBAPI.LIB to be properly incorporated, was to

turn off the case matching.  Other than making me very nervous, and

forcing me to look for other solutions, this worked fine.

-Joe

--

papabear@econ.sas.upenn.edu            Joe Barber

                                       Department of Economics

                                       University of Pennsylvania

                                       Philadelphia, PA  19104


Vbx create Borland

LUOKKA: vbx

Date: 04/29/94 (02:12)              Number: 4632 of 4664 (Refer# NONE)

From: XADRG@LEVELS.UNISA.EDU.AU

Subj: Re: How to make VBX's with Borland C

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <2ojhg9$f98@nof.abdn.ac.uk>, eng359@nof.abdn.ac.uk (a.boyd)

writes:

> I've heard that VBX's can be created using Borland C/C++; the VB FAQ

> file even mentions it. Could anyone please tell me how?

I have seen some replies, but they seem BC3.1 specific.

I have successfully made VBXs with BC4.0.

Things to note:

        1) Don't link in any C++ (I haven't found a way around this).

           MSVC could handle cpp modules ok, but not BC.

        2) Turn off case-sensitive linking.

        3) Change _segment to FP_SEG, and include <dos.h>

        4) Pack all the code into one segment. I haven't figured out a

           nicer way around this, but at the moment if I want a VBX to

           work, and there are multiple .c files, then it seems to need

           a reasonable value in the "Code Pack Size" option.

I would appreciate any further hints others may have about BC4.0. In

particular, ways to use .cpp files.

--------------------------------------------------------------------------

David Gardiner <>< Smarthouse Project - Uni of South Australia & Clipsal.

Also Asst Admin for Centre for Sensor Signal & Information Processing.

Internet: gardiner@cssip.edu.au  Ph: +61 8 302 3606  Fax: +61 8 302 3873


Vbx create w, MS VC++

LUOKKA: vbx

Date: 02-23-95 (13:59)              Number: 33200 of 33200 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Do you need VC++ Pro 1.5 to write VBX?

On 16 Feb 1995 22:55:40 -0800 Jym Barnes <jybarnes@crl.com> wrote:

> I am trying to write a VBX with Standard VC++ 1.5 and VB Pro 3.0.  The

> link is bombing out because the libraries lafxdwd.lib and ldllcew.lib

> can not be found.  Are these libraries included with VC++ 1.5 Pro?

> Has anyone sucessfully written VBX with this setup?

I do it all the time, so it must be something with your setup. Two things:

- if you're trying to create a plain C VBX (no C++) uncheck the option

  'Use Microsoft foundation classes' in the Options-Project dialog.

- if you're trying to create a C++ VBX, make sure the MFC libraries are

  installed.

- As for the linker that misses the lafxdwd.lib (MFC lib) and the

  lddlcew.lib (DLL compact model library), you should check the paths

  in the Options-Directories dialog, for something like:

  Include path: c:™msvc™include;c:™msvc™mfc™include;c:™vb™cdk

  Library path: c:™msvc™lib;c:™msvc™mfc™lib;c:™vb™cdk

- You also need to add the library VBAPI.LIB to the linker-options dialog

  in the Options-Project dialog. Something like:

    Libraries: oldnames, libw, ldllcew, vbapi

--

Arjen Broeze                                   Telephone: (+31)53-338666

arjen@shear.iaf.nl                             Address:   Gronausevoetpad 104

                                                          7511 BN Enschede, NL


Vbx free db2stff.zip

LUOKKA: misc

5706 (20+)  Alan Roberts  18.07.95  06:52

"Re: hot spot vbx tool?"

>Does anybody know if there is a vbx that allows you to create 'hot spots'

>on images that you can incorporate into your applications?

Try DB2STFF.ZIP from cica.  Its freeware and contains

4 great VBXs, 1 of which allows the creation of hotspots

of any shape and allows you to define custom cursors

to be displayed when the mouse moves over them

Alan Roberts

aroberts@uniwa.uwa.edu.au


Vbxs 0$!

LUOKKA: vbx

CTLWhWnd

Control: ctlwhwnd.dll                  Archive: vbhwnd.zip

 Author: Jonathan Zuck                   Price: $0.00

    Ver:

 Keywds: api

One function, ControlhWnd, which returns the hWnd for a given control.

       =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                              Four Controls

Control: <see below>                   Archive: vb4ctrls.zip

 Author: Jeng Long Jiang                 Price: $0.00

    Ver:

 Keywds: graphic, status

Four graphic controls:  vmeter.vbx and hmeter.vbx are "flooding" status

gauge controls; spin.vbx (!) is a spin tool.  The best of the lot seems

to be 3dlabel.vbx, which is actually a button which holds states like a

toolbar button.  No documentation.

      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                 GT Icon

Control: gticon.dll                    Archive: gticon.zip

 Author: George R. Torralba              Price: $0.00

    Ver:

 Keywds: icon, drag-drop

Assigns and retrieves the DragIcon property of controls.

      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                  InpOut

Control: inpout.dll                    Archive: inpout.zip

 Author: Jay Munro                       Price: $0.00

    Ver:

 Keywds: io

An INP and OUT replacement, written in assembler and used like the

QuickBasic routines.  Includes source.  (For some reason Mr. Munro saw

fit to include Software Assist's SCFILE package -- the dll is actually

very small.)

      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                             Message Blaster

Control: msgblast.vbx                  Archive: tbox100.zip

 Author: Ed Staffin                      Price: $0.00

    Ver: 1.1

 Keywds: toolbar, graphic

Provides a floating palette, complete with tiny title bar, which you can

use in conjunction with an MDI form.  Message notification is rather

crude and hacky.

       =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                               MhFormScroll

Control: mhfs200.vbx                   Archive: mhfs200.zip

 Author: MicroHelp                       Price: $0.00

    Ver: 2.0

 Keywds: scroll

Add scroll bars to a form or a container.  Crashed my computer, so I

don't know if it works.

       =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                 MListBox

Control: mlistbox.vbx                  Archive: mlist110.zip

 Author: Mike Warning                    Price:

    Ver: 1.1

 Keywds: list

Multiple selection list box with ability to find strings, associate

numeric data with list items, and set tabs with some precision.

Variable pricing scheme.

       =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                MouseWatch

Control: mwatch.dll                    Archive: mwatch.zip

 Author: User Friendly, Inc.             Price: $0.00

    Ver:

 Keywds: mouse, status

Dynamically tracks mouse position, emitting _KeyDown events to the

form.  Good for dynamic hinting, a la Word Perfect.

       =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                 OpenDlg

Control: opendlg.vbx                   Archive: opendl.zip

 Author: Zane Thomas                     Price: $0.00

    Ver:

 Keywds: graphic

Does the same thing as cmdialog.vbx.

      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

       =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                ToolButton

Control: toolbutn.vbx                  Archive: vbtool20.zip

 Author: Brett Foster                    Price: $0.00

    Ver: 2.0b

 Keywds: toolbar, help, graphic

Full-feature toolbar buttons, with up to 6 states (for attributes).  Use

your own image and break it into cells of graphic buttons, or use the

suite of standard buttons.  Also includes ContextHelp control (same vbx)

to assist with help management.

      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                 VBPoint

Control: vbpoint.dll                   Archive: vbptr.zip

 Author: Jonathan Zuck                   Price: $0.00

    Ver:

 Keywds: api

Two routines: convert long pointers (LP) to VB strings, and copy strings

to another address (another LP).


Version stamp

LUOKKA: VBgen

Date: 09/10/94 (20:45)              Number: 18988 of 19086 (Refer# NONE)

From: ARJEN@SHEAR.IAF.NL

Subj: Re: Embedding a version number within a VB application?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 9 Sep 1994 00:27:13 -0400 MJCOATS <mjcoats@aol.com> wrote:

> I would like to somehow embed a version number (like 3.1) somewhere

inside

> my custom VB application so that my setup program can detect previously

> installed  versions of my application by their version numbers.

> Any ideas on how I can accomplish this. Thanks.

Unfortunately VB does have the possibility to store extra resources into

your exe *yet), but you can do it yourself though.

You'll need to use a resource editor of some kind (AppStudio works perfectly)

and create a VERSION_INFO resource and add that to the created

executable.

A VERSION_INFO resource has a very strict layout and it is readable by the

every good setup program by calling some functions in VER.DLL (the example

that comes with VB does that) . If you need more information on how to do

this, or for a VERSION_INFO sample, don't hesitate to drop me a note.

Hope this helps,

Arjen


Video mode

LUOKKA: display

Date: 10/28/94 (21:01)              Number: 24897 of 25182 (Refer# NONE)

From: ROBERTW@NETCOM.COM

Subj: Re: Video mode at run time?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

: N >What's a good way to tell what video mode a user is in at run-time?  I'

: N >using TwipsPerPixelX, but that returns the same value for 1024x768 and

: Use GetSystemMetrics

: Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As

:   Integer

: Global Const SM_CXSCREEN = 0

: Global Const SM_CYSCREEN = 1

: X% = GetSystemMetrics(SM_CXSCREEN)

: Y% = GetSystemMetrics(SM_CYSCREEN)

Or, if you feel like doing it the easy way: Screen.Width / TwipsPerPixelX

and Screen.Height / TwipsPerPixelY.

Robert Wallace

robertw@netcom.com


Virtual forms

LUOKKA: forms

Date: 05/01/94 (03:55)              Number: 4762 of 4802 (Refer# NONE)

From: MILLERA@MCS.COM

Subj: Multiple 'forms' to a single data control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Use one form holding two 'virtual' forms.  These would be frames with a

variety of fields on them.  So:

Form

  Data Control

  Text Box (for tabbing between forms, explained later)

  Frame 1

    Assorted Labels

    Assorted Text Boxes

    Assorted Other Stuff

  Frame 2

    Assorted Labels

    Assorted Text Boxes

    Assorted Other Stuff

The reason to use two frames rather than a single one on top of the other

fields is to simplify your tabbing.  With all fields in frames, you can hide all

the frames except the current one, with the effect of making the fields on

them unreachable.  If you don't want the user to tab from screen to screen,

you're done now (and you can take out the Form-level Text Box).  If you want

screen-to-screen tabbing, it should be only slightly more complex.  In the

_GotFocus event of the text box, you can put code that will hide the old

frame and display the new one.  You should be able to deal with Shift-TAB by

using an API call to check the status of the Shift key, so you could also

move backward.

Don't try to put too many, forms are limited in the number of objects they can

hold.  Anyway, if you've got that much stuff in a single table, you probably

need to examine the structure and layout of your database tables anyway.

Cautionary note:  I haven't tried this (not the tabbing at least), but

                  the frame bit has worked well for me.  The rest of it

                  is off the top of my head as I type.  I still think

                  it'll work.


Virtual ListBox

LUOKKA: ListBox

22300 (88+)  royfran@statcan.ca  23.06.95  16:04

Francois Roy: "Re: need a precise information on VB Listboxes"

David Excoffier (excoffier@lyon.cemagref.fr) wrote:

: Do someone know exactly how many lines can be displayed on a listbox in :

VB3.0 I've a listbox with about 3500 lines displayed. Is there a limit ?

 There is no exact limit: I believe there is a 5400-line upper limit, but

there is also a 64K limit: the length of your lines will determine which

you will hit first.

 There are 3rd party listboxes out there that break that 64K barrier, but

since I never pursued the issue, I couldn't give you any names.  The way I

got around the limits (I needed 6700 lines of 40 characters each) was with

a RANDOM file:

 1- Create a list box and determine exactly how many lines will display

    on the screen WITHOUT a scrollbar appearing

 2- Add your own scrollbar, with the limits set to the number of records

    in the RANDOM file

 3- Use the scrollbar's value and the number of items that you know fit

    in your list box, and only load those items.

 You now have effectively created a "virtual list box"; not only can it have

upwards of 32000 lines if needed, but the perception by the user is that it

also loads very fast, since you are really loading only a handful of items

at a time.


Virtual ListBox

LUOKKA: ListBox

Date: 08/15/94 (08:50)              Number: 15616 of 15669 (Refer# NONE)

From: D.HELEY@BOM.GOV.AU

Subj: ***** CREATING A VIRTUAL LIST BOX FROM EXISTING VB

CONTROLS

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I created a virtual listbox by using  listbox, textbox and vscroll controls

and linking their operation together.

I set the vscroll.max to the max number of records in my database

Depending on the vscroll value, I cleared the list box and displayed a

5 record window in that list box ie; list1.additem record  5 times

This procedure was triggered when vscroll changed.

When I clicked on an item from the listbox, in its click() event,

it would copy the list1.text to the textbox

All objects were strategically placed to give the visual effect of One control

ie the vscroll bar was placed over where the listbox vscroll would have been

The text box was placed over where the 1st item in the list1.text would have

been ie; at the top of the list box

The controls assumed two diff sizing states, ie .height

When not focused, the highset were minimised

When focused the heights were enlarged to the desired size of the list box

There are a few minor tricky code bits but nothing overwhelming !

Once grasped, its a breeze


Virtual ListBox

LUOKKA: ListBox

Date: 08/23/94 (10:27)              Number: 16702 of 16734 (Refer# NONE)

From: RLANGBP@CC.CURTIN.EDU.AU

Subj: Re: Reading large amounts of data

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

George Tatge will suggest the virtual list box from Quick-

Pak Pro, (Cresent Software and I'm beginning to think he

wrote it :-) ), but if you don't want to spend the US$200

try the following:

Create a list box, List1, and a vertical scroll bar, Scroll1.

Get L ' = number of items visible in list box

Set Scroll1.LargeChange = L

Set Scroll1.max to (the total number of records - L - 1)

ReDim a huge array of fixed-length strings:

Dim StringArray() as String * 40

ReDim StringArray(0 to L-1) as String * 40 ' (or whatever)

Include code in the Scroll1_Scroll and _Change events

to detect whether user has clicked or dragged and update

the list box accordingly.

This works well enuff for small list boxes (<20 items), but

has some minor problems.

I'll e-mail some code tomorrow if you need it.

 ----------------------------------------------------------

" Cheers,                " Curtin University of Technology "

" Brad Lang              " email: rlangbp@cc.curtin.edu.au "


Virtual ListBox

LUOKKA: ListBox

===========================================================

Date:         Wed, 21 Sep 1994 12:40:00 BST

From:         "S.Bannister -Stephen Bannister" <S.Bannister@OPEN.AC.UK>

Subject:      'virtual' list-boxes...

>So, do we get to see this code or not? I for one would be very interested.

>If you are agreeable, post it to visbas-l, don't mail direct.

Most of the following text was just cut from a form which uses the virtual

listbox. Hopefully I have not cut anything from the code by accident. I

use a DLL to fetch the words from a file which contains all the data for

the list box, although it will probably work just as fast using VB file

operations (I haven't tried it though).

My DLL calls a

1) THSEEK(n)  which moves the file pointer to word n (1st word is 0,

   2nd is 1 etc)

2) THNODE just fetches the next word from the file.

The words are loaded into an array words() which I have defined globally

elsewhere.

 -------------------------------------------------------------------------

Steve Bannister        (s.bannister@open.ac.uk)

The Open University,   Milton Keynes,   England

 -------------------------------------------------------------------------

Vertical Scrollbar placed next to list box:

      Name            =   vscroll1

      LargeChange     =   16

      Min             =   1

      Value           =   1

A Timer:

      Name            =   Timer1

      Enabled         =   0   'False

      Interval        =   100

A list box big enough to display 16 items

      Name            =   list1

      Height          =   3150

In the form Declarations section:

     Option Explicit

     Dim vis%, lpos%, batch%, VSR%

     Dim ListhWnd as integer

Sub Form_load

    Dim i%, l&

    vscroll1.Max = Maximum_nodes       'Maximum items in virtual listbox

    i% = THSEEK(0)

    readdata

    batch% = 1

    For i% = 1 To 16

        list1.AddItem words(i%)

    Next i%

    vis% = 1

    VSR% = 0

End Sub

Sub Form_Paint ()

    If ListHwnd > 0 Then Exit Sub

    list1.SetFocus

    ListHwnd = GetFocus()

    text1.SetFocus

End Sub

Sub List1_Click ()

    VSR% = 1

    text1.Text = list1.Text

    text1.SelStart = Len(text1.Text)

    VSR% = 0

End Sub

Sub List1_MouseDown (Button As Integer, Shift As Integer, X As Single, y As

Single)

    If Button = 1 Then

        lpos% = y

        timer1.Enabled = True

    End If

End Sub

Sub List1_MouseMove (Button As Integer, Shift As Integer, X As Single, y As

Single)

    lpos% = y

End Sub

Sub List1_MouseUp (Button As Integer, Shift As Integer, X As Single, y As

Single)

    timer1.Enabled = False

    If list1.ListIndex >= 0 Then

        vscroll1.Value = vis% + list1.ListIndex

    End If

End Sub

Sub movedownone ()

    Dim e%

    If vis% < batch% + 84 Then

        list1.RemoveItem 0

        vis% = vis% + 1

        list1.AddItem words$(vis% - batch% + 16)

        e% = SendMessage(ListHwnd, LB_SETCURSEL, 15, 0&)

        vscroll1.Value = vis% + 15

        Exit Sub

    End If

    If batch% + 99 = Maximum_nodes Then Exit Sub

    vis% = vis% + 1

    batch% = vis%

    If batch% > Maximum_nodes - 99 Then

        batch% = Maximum_nodes - 99

    End If

    e% = THSEEK(batch% - 1)

    If e% <> 0 Then

        MsgBox "Unexpected error 1", 16, "COB1.FRM"

        End

    End If

    readdata

    list1.RemoveItem 0

    list1.AddItem words(vis% - batch% + 16)

    e% = SendMessage(ListHwnd, LB_SETCURSEL, 15, 0&)

End Sub

Sub moveupone ()

    Dim e%

    If vis% > batch% Then

        list1.RemoveItem 15

        vis% = vis% - 1

        list1.AddItem words$(vis% - batch% + 1), 0

        e% = SendMessage(ListHwnd, LB_SETCURSEL, 0, 0&)

        vscroll1.Value = vis%

        Exit Sub

    End If

    If vis% = 1 Then Exit Sub

    vis% = vis% - 1

    batch% = vis% - 84

    If batch% < 1 Then

        batch% = 1

    End If

    e% = THSEEK(batch% - 1)

    If e% <> 0 Then

        MsgBox "Unexpected error 2", 16, "COB1.FRM"

        End

    End If

    readdata

    list1.RemoveItem 15

    list1.AddItem words(vis% - batch% + 1), 0

    e% = SendMessage(ListHwnd, LB_SETCURSEL, 0, 0&)

End Sub

Sub readdata ()

    Dim l&, i%

    Dim term As String * 30

    term$ = String(30, " ")

    l& = THNODE(1, term$)

    i% = 1

    While l& >= 0 And i% < 101

        words(i%) = Trim$(term$)

        If i% < 100 Then

            l& = THNODE(1, term$)

        End If

        i% = i% + 1

    Wend

End Sub

Sub Timer1_Timer ()

    If lpos% > list1.Height Then

        movedownone

    End If

    If lpos% < 0 Then

        moveupone

    End If

End Sub

Sub VScroll1_Change ()

    If VSR% = 1 Then Exit Sub

    Dim e%, p%

    p% = vscroll1.Value

    If p% >= vis% And p% < vis% + 16 Then

        list1.ListIndex = p% - vis%

        Exit Sub

    End If

    If p% = vis% - 1 And list1.ListIndex = 0 Then

        moveupone

        text1.Text = list1.Text

        text1.SelStart = Len(text1.Text)

        Exit Sub

    End If

    If p% = vis% + 16 And list1.ListIndex = 15 Then

        movedownone

        VSR% = 1

        text1.Text = list1.Text

        VSR% = 0

        text1.SelStart = Len(text1.Text)

        Exit Sub

    End If

    If p% >= batch% And p% < batch% + 86 Then

        list1.Clear

        vis% = p%

        For p% = vis% To vis% + 15

            list1.AddItem words(p% - batch% + 1)

        Next p%

        list1.ListIndex = 0

        Exit Sub

    End If

    batch% = p%

    vis% = p%

    If vis% > Maximum_nodes - 15 Then

        vis% = Maximum_nodes - 15

    End If

    If batch% > Maximum_nodes - 99 Then

        batch% = Maximum_nodes - 99

    End If

    e% = THSEEK(batch% - 1)

    If e% <> 0 Then

        MsgBox "Unexpected error 3", 16

        End

    End If

    readdata

    list1.Clear

    For e% = vis% To vis% + 15

        list1.AddItem words(e% - batch% + 1)

    Next e%

    p% = p% - vis%

    e% = SendMessage(ListHwnd, LB_SETCURSEL, p%, 0&)

End Sub


VisBas-l

LUOKKA: internet

Date: 07-24-95 (17:23)              Number: 394658 of 394700 (Refer# NONE)

From: Nathan Brindle <NATHAN@LSOFT.COM>

To: Multiple recipients of list VISBAS-L

              <VISBAS-L@eva.dc.LSOFT.COM>

I've been inundated with requests on how to set the list to DIGEST format,

so here is the method:

Make a new mail message addressed to

LISTSERV@PEACH.EASE.LSOFT.COM

In the body of the message type SET VISBAS-L DIGEST

Send it.

If this results in a "You are not subscribed to VISBAS-L" message, you

will need to contact me so that I can fix your subscription address.

Sometimes sysadmins make changes and don't bother to tell their users,

and since the old address forwards automagically to the new one, no

one notices until they have to unsubscribe or change options.

Also:  Your thank-you notes for taking over the list are appreciated, but

<PLEASE> stop sending them!  I get the idea already...:))))

Nathan

242 (2+)  dwilliams@dwilliams.seanet.com  23.07.95  21:07

David Williams: "VB Listserver Moved"

Here is a copy of some email I just received announcing the VISBAS-L and

VISDATA-L listservers have moved.

==

VISBAS-L and VBDATA-L have been moved to a new LISTSERV host

because of Rick Huff's unfortunate departure.  (Unfortunate for us, that is.:)

Here are the new addresses you will need:

To send mail to VISBAS-L:  VISBAS-L@PEACH.EASE.LSOFT.COM

To send mail to VBDATA-L:  VBDATA-L@PEACH.EASE.LSOFT.COM

To subscribe/unsubscribe/set options:

                           LISTSERV@PEACH.EASE.LSOFT.COM

I am your new list owner, Nathan Brindle (nathan@ubvm.cc.buffalo.edu is

the direct route; nathan@lsoft.com goes through Sweden first.  But they

both designate the same account, so please don't send mail to both of

them just to make sure I get it.:)  I am the list owner for quite a

number of other lists, plus I am the postmaster for four LISTSERV

servers here in our office.  So if I don't get right back to you if

there is a problem, please understand that I am <extremely> busy.

I will be looking for at least two co-list owners for both lists to

take some of the error-handling load off of my shoulders.  Please

contact me directly if you have experience with deciphering bounced

mail errors and would like to help out.

Let the games begin...

Sincerely,

Nathan Brindle

Date: 07-24-95 (23:30)              Number: 394997 of 395921 (Refer# NONE)

From: VISBAS-L@EVA.DC.LSOFT.COM

From: Nathan Brindle <NATHAN@LSOFT.COM>

Rick has uploaded the VISBAS-L archives to me and they are available

for GETs from LISTSERV.

Here are the commands that you send to

LISTSERV@PEACH.EASE.LSOFT.COM :

To get the list of notebooks:     INDEX VISBAS-L

To get a specific notebook:       GET VISBAS-L LOGyymm  (for monthly

archives)

                               or GET VISBAS-L LOGyymmw (for weekly archives)

                                  where yy= year, mm=month, and w= week.

                                  For instance LOG9507D for the 4th week

                                  of July, 1995.

The archives are stored monthly from July 1992 through the 3rd week of

July, 1994, and weekly after that starting with LOG9407D.

I can't make them available via anonymous ftp because our server is

somewhat limited and is primarily for the use of our customers.  If

we get a bigger box for ftp, I'll see what I can do.

Nathan


VisBas-l

LUOKKA: internet

Date: 07-31-95 (21:56)              Number: 400792 of 400801 (Refer# NONE)

From: "L-Soft list server at PEACH.EASE.LSOFT.COM (1.8b)"

Your  subscription to  the VISBAS-L  list  (Visual Basic  List) has  been

accepted.

Please save this message for future  reference, especially if you are not

familiar with LISTSERV.  This might look like a waste  of disk space now,

but in  6 months  you will be  glad you saved  this information  when you

realize that  you cannot remember what  are the lists you  are subscribed

to, or  what is the command  to leave the  list to avoid filling  up your

mailbox while you are on vacations. In fact, you should create a new mail

folder for subscription confirmation messages  like this one, and for the

"welcome  messages"  from the  list  owners  that you  will  occasionally

receive after subscribing to a new list.

To send  a message to  all the people  currently subscribed to  the list,

just send mail to  VISBAS-L@PEACH.EASE.LSOFT.COM. This is called

"sending mail to the list", because you send mail to a single address and

LISTSERV makes  copies  for all  the  people  who  have subscribed.  This

address (VISBAS-L@PEACH.EASE.LSOFT.COM) is  also called  the "list

address". You must  never try  to send  any command  to that  address, as  it

would  be distributed to all  the people who have subscribed. All  commands

must be sent to the "LISTSERV address",

LISTSERV@PEACH.EASE.LSOFT.COM. It is very important to understand

the difference between the  two, but fortunately it is not complicated. The

LISTSERV address is like a FAX number, and the list address  is like  a

normal  phone line.  If you  make your  FAX call someone's  regular phone

number by  mistake,  it will  be an  unpleasant experience for  him but you will

 probably be excused the  first time. If you do it regularly,  however, he will

probably get upset  and send you a nasty complaint. It  is the same with

mailing lists,  with the difference that you are calling hundreds or thousands

of people at the same time, so a lot more people get annoyed if you use the

wrong number.

You  may leave  the list  at  any time  by sending  a "SIGNOFF  VISBAS-L"

command to LISTSERV@PEACH.EASE.LSOFT.COM. You  can also tell

LISTSERV how you want it to  confirm the receipt of messages you send  to

the list. If you do  not trust  the system,  send a "SET  VISBAS-L REPRO"

command and LISTSERV will send you  a copy of your own messages, so

that you can see that the  message was  distributed and  did not get

damaged on  the way. After a while  you may find that this is  getting

annoying, especially if your mail program does not tell you  that the message

is from you when it informs you that new  mail has arrived from VISBAS-L. If

you send a "SET VISBAS-L  ACK   NOREPRO"  command,  LISTSERV   will

mail  you   a  short acknowledgement  instead,  which  will  look different  in

your  mailbox directory. With most mail programs you will know immediately

that this is an  acknowledgement  you  can  read  later. Finally,  you  can

turn  off acknowledgements completely with "SET VISBAS-L NOACK

NOREPRO".

Following  instructions from  the list  owner, your  subscription options

have been set  to "DIGESTS" rather than the usual  LISTSERV defaults. For

more  information about  subscription  options, send  a "QUERY  VISBAS-L"

command to LISTSERV@PEACH.EASE.LSOFT.COM.

Contributions sent to this list are automatically archived. You can get a

list  of the  available  archive  files by  sending  an "INDEX  VISBAS-L"

command to LISTSERV@PEACH.EASE.LSOFT.COM. You  can then order

these files with  a "GET  VISBAS-L  LOGxxxx" command,  or  using

LISTSERV's  database search facilities. Send  an "INFO DATABASE"

command  for more information on the latter.

Please note that  it is presently possible for anybody  to determine that

you are signed  up to the list  through the use of  the "REVIEW" command,

which returns the e-mail address and  name of all the subscribers. If you

do not want your name to be  visible, just issue a "SET VISBAS-L CONCEAL"

command.

More  information on  LISTSERV  commands  can be  found  in the

LISTSERV reference  card, which  you can  retrieve  by sending  an "INFO

REFCARD" command to LISTSERV@PEACH.EASE.LSOFT.COM.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                          Welcome to VISBAS-L!

               The Microsoft Visual Basic Discussion List

       Coordinator:  Nathan Brindle (NATHAN@UBVM.CC.BUFFALO.EDU)

     Please read this entire posting before sending any commands to

     LISTSERV.  Otherwise you will miss important points.

     PLEASE NOTE:  VISBAS-L is a high volume list.  As such, the default

     for new subscribers has been set to DIGEST--in other words, you

     will get one posting per day from the list that is a compilation

     of all postings to the list for that day.  (If the digest runs

     over a certain size, "special issues" will also be distributed

     during the day.  Experience shows that you will most likely

     receive between 1 and 3 of these digests on a typical day.)

     If you wish to change the setting from DIGEST to individual

     postings, you should issue the command:

     SET VISBAS-L NODIGEST

     in the body of a new mail message addressed to

     LISTSERV@PEACH.EASE.LSOFT.COM.

     If you feel that VISBAS-L is too much for you to handle and

     would like to opt out now, please send the command

     UNSUB VISBAS-L

     in the body of a new mail message addressed to

     LISTSERV@PEACH.EASE.LSOFT.COM

     PLEASE ALSO NOTE:  DO NOT reply to this welcome message with the

     LISTSERV commands noted below--they must go to the listserver,

     LISTSERV@PEACH.EASE.LSOFT.COM.  If you reply to this message, it

     does not go to LISTSERV--it goes to me, and I do not have time to

     forward commands to LISTSERV for people unless you are having a

     major problem getting LISTSERV to respond.

     What the above paragraph means is DO NOT HIT THE REPLY KEY AND

TYPE SET VISBAS-L DIGEST or any other command!  You MUST make a

NEW message, otherwise IT WILL NOT WORK!!!!!!!!!!

     AOL subscribers should also note that there is a USENET-style

     newsgroup on AOL echoing this list, for your convenience.  Use

     your AOL newsreader and look for the group aol.lists.visbas-l.

     For more in-depth information about VISBAS-L, please send the

     command GET VISBAS-L ADMIN to

LISTSERV@PEACH.EASE.LSOFT.COM.

     VISBAS-L is an open, unmoderated discussion list relating to

     Microsoft's Visual Basic programming environment. Virtually any

     topic related to Visual Basic, from the novice level to

     professional tips/advice, is germane.  Please note that the

     list is NOT sponsored or otherwise recognized by MICROSOFT,

     although MS professionals are certainly welcome to subscribe and

     participate.

     Available by free subscription from

LISTSERV@PEACH.EASE.LSOFT.COM.

     Users new to the use of L-Soft's LISTSERV are encouraged to read

     the online files LISTSERV REFCARD and LISTSERV GENINTRO, which

can

     be obtained by sending the following commands in the body of a

     mail message to LISTSERV@LISTSERV.NET:

     INFO REFCARD

     INFO GENINTRO

The following guidelines apply to VISBAS-L.  Please read them.  If you

have any questions, please contact the list coordinator at the network

address listed above.  The guidelines are derived from network policies,

netiquette, and a great deal of experience with what does and does not

work.

1.  Netiquette dictates private responses to private e-mail.  Please

    do not post private mail to VISBAS-L, even if you cannot find a

    mailing path.  If all else fails, contact your local postmaster

    or the list coordinator for help.  The list coordinator will keep

    all communications confidential.

2.  When replying to the list, please make sure that your reply does

    not include a space between the character '>' and any headers

    you wish to include.  Your mail will be rejected by LISTSERV.  The

    list administrator will not forward it to the list.  The safest

    route is to not include ANY header information in your return

    mail to the list--and most users will thank you for deleting

    material from your reply that is not of the essence anyway.

3.  Please do not "flame" (insult) another subscriber over VISBAS-L.

    Flames belong in private mail.  Discussions will naturally bring

    disagreements; however, rebuttals should always be made in a

    rational, logical and mature manner in public.

4.  Please refrain from using any language that might be considered

    questionable (even by the most liberal of us) on VISBAS-L.

5.  Do not post commercial advertisements or "chain letters" of any

    kind to the list.  Such are against appropriate network usage

    policies on many Internet networks.  Violators will be removed

    from the list.  "Spamming" VISBAS-L (that is, including VISBAS-L

    in a multiple-list attack) will be considered cause for removal

    from this list as well.

Thank you for adhering to these guidelines.  Following them will

ensure that the majority of people subscribed can and will stay

involved.

VISBAS-L communications are archived weekly.  You may retrieve these

notebooks by sending the command

  GET VISBAS-L LOGyymmx    (for weekly archives, i.e., LOG9409A)

to LISTSERV@PEACH.EASE.LSOFT.COM, where yy is the year and mm is

the month of the requested notebook.  For weekly notebooks, add a letter

corresponding to the week you want, i.e., A for week 1, B for week 2,

etc.

Please note that we do not have the old notebooks from

LISTSERV.TAMU.EDU. I am working on transferring them but it may take

some time.

VISBAS-L is also available in digest form to those who are subscribed

directly.  Send the command

     SET VISBAS-L DIGEST

to LISTSERV@PEACH.EASE.LSOFT.COM to activate this feature.  Digests

are sent daily, after midnight.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Revised:  95/07/23


VisBas-l

LUOKKA: internet

Date: 03-15-95 (20:34)              Number: 259125 of 262621 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: VB.FAQ

The first draft of a VisBas-L FAQ is available for comments/additions/etc.

Thanks to the few who have already contributed. I have not done much

editing to the typography yet, so please be forgiving (I have to squeeze

this between bouts of real work).

To get the FAQ:

anonymous ftp to jupiter.willamette.edu

cd outgoing/tmassa

get VB.FAQ

==========

Tod R. Massa                                            tmassa@willamette.edu

Asst. Registrar for Institutional Research              Willamette University

                                   www: http://www.willamette.edu:80/~tmassa/


VisBas-l

LUOKKA: internet

Date: 04-20-95 (09:49)              Number: 297076 of 297114 (Refer# NONE)

From: VISBAS-L-REQUEST@LISTSERV.TAMU.EDU

Subj: You are now subscribed to the VISBAS-L list

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

Tue, 18 Apr 1995 09:46:57

Your subscription to the VISBAS-L list (Visual Basic List) has been accepted.

Please  save this  message  for future  reference, especially  if  you are  not

familiar with LISTSERV. This might look like  a waste of disk space now, but

in 6 months you will be glad you  saved this information when you realize that

you cannot  remember what  are the  lists you  are subscribed  to, or  what is

 the command to  leave the list to  avoid filling up  your mailbox while you

are on vacations.  In fact,  you  should create  a new  mail  folder for

subscription confirmation messages  like this one, and  for the "welcome

messages"  from the list owners that you will occasionally receive after

subscribing to a new list.

To send a message to all the people currently subscribed to the list, just send

mail to VISBAS-L@LISTSERV.TAMU.EDU. This is  called "sending mail to

the list", because you send mail to a single address and LISTSERV makes

copies for all the people who  have subscribed. This address

(VISBAS-L@LISTSERV.TAMU.EDU) is also called the  "list address".  You

must  never try  to send  any command  to that nsaddress, as it would be

distributed to  all the people who have subscribed. All commands must be

sent to the "LISTSERV address", LISTSERV@LISTSERV.TAMU.EDU. It

is very important to understand the difference between the two, but

fortunately it is not complicated. The LISTSERV address  is like a FAX

number, and the list  address  is like  a normal  phone line.  If you  make your

FAX call  someone's regular phone  number by mistake, it  will be an

unpleasant  experience for him but  you will  probably be  excused the  first

time.  If you  do it  regularly, however, he will probably  get upset and send

you a nasty  complaint. It is the same with mailing  lists, with the difference

that you  are calling hundreds or thousands of people at  the same time, so a

lot more people  get annoyed if you use the wrong number.

You may leave the  list at any time by sending a  "SIGNOFF VISBAS-L"

command to LISTSERV@LISTSERV.TAMU.EDU.  You can  also tell

LISTSERV  how you  want it  to confirm the receipt of  messages you send to

the list. If you  do not trust the system, send a "SET  VISBAS-L REPRO"

command and LISTSERV will  send you a copy of your own messages, so

that you  can see that the message was distributed and did not get damaged

on the way. After a while you may find that this is getting annoying,

especially if your mail program does not tell you that the message is from you

when  it informs you that  new mail has arrived from  VISBAS-L. If you send  a

"SET  VISBAS-L ACK  NOREPRO" command,  LISTSERV will  mail you  a

short acknowledgement instead, which  will look different in  your mailbox

directory. With  most   mail  programs  you  will   know  immediately  that  this

is  an acknowledgement you can read later.  Finally, you can turn off

acknowledgements completely with "SET VISBAS-L NOACK NOREPRO".

Contributions sent to this list are  automatically archived. You can get a list

of  the available  archive  files by  sending an  "INDEX  VISBAS-L" command

 to LISTSERV@LISTSERV.TAMU.EDU. You can then order these files with a

"GET VISBAS-L LOGxxxx" command, or using LISTSERV's database search

facilities. Send an "INFO DATABASE" command for more information on the

latter.

Please note that it is presently possible for anybody to determine that you are

signed up to  the list through the  use of the "REVIEW"  command, which

returns the e-mail  address and name of  all the subscribers.  If you do not

want your name to be visible, just issue a "SET VISBAS-L CONCEAL"

command.

More information  on LISTSERV commands can  be found in the  LISTSERV

reference card,  which  you  can  retrieve  by  sending  an  "INFO

REFCARD"  command  to LISTSERV@LISTSERV.TAMU.EDU.


Visbas-l

LUOKKA: internet

Date: 06-10-95 (12:56)              Number: 359867 of 361206 (Refer# NONE)

From: VISBAS-L-REQUEST@LISTSERV.TAMU.EDU

Subj: Your request to sign off the VISBAS-L list

No  entry for  your matti.harju@PCB.COMPART.FI  address could  be found

in the VISBAS-L list at  LISTSERV.TAMU.EDU. Here are a number of

possible reasons why you might still be getting mail from the list:

1.  You could  be subscribed  under a  different, but  equivalent address.  For

instance, if your e-mail address as it  appears in the 'From:' line of messages

coming from  you has the misfortune  of depending on the  distance between

your workstation and  the terminal room  door, you  were probably subscribed

 from a different address and, while your mail  system knows that the two

addresses are equivalent, LISTSERV has no  way to know that. In this case

the only thing you can  do, beyond  contacting the  list  owner, is  to send  a

"REVIEW  VISBAS-L" command to find out under what address you are

subscribed, and try to duplicate it with the help of your user support people.

2.  If you  are a  BITNET user,  you might  be subscribed  under your

Internet address and sending  this command via BITNET, or vice  versa.

Most BITNET sites have registered their Internet addresses  in the BITNET

nodes database, BITEARN NODES (the "tag" containing this information  is

called ':internet' - if you do not understand  any of this,  just bring  a copy of

 this message to  your user support people).  Unfortunately, some sites  have

still  not done that,  and in such cases  LISTSERV has no  way to determine

that, for instance,  BITNET node XYZCOL1 is the same as Internet host

VM3.XYZ.EDU. If you suspect this might be your problem,  try resending  your

request via  both interactive  message (SEND under VMS, TELL under VM)

and e-mail.

3. You  might be  subscribed under  an equivalent yet  different address  - for

instance,  one with  explicit gatewaying,  or an  X.400 address  with different

ordering of  the various components,  etc. You  could send a  "REVIEW

VISBAS-L" command and inspect the  list membership to find out whether

this is the case, and ask the list owners to remove that address from the list.

4. You could be  subscribed to the list under another  account, from which

mail is being automatically forwarded to your matti.harju@PCB.COMPART.FI

account. In that case you should be able to leave the list by resending the

signoff request from the account in question.

5. You could be subscribed to the list indirectly, via a "redistribution" list.

That is, one of the subscribers to the LISTSERV list is in fact a mailing list,

to  which  you are  yourself  subscribed  (note  that  this "sub-list"  is  not

necessarily managed  by LISTSERV and,  in fact,  such lists are  often

manually maintained, in  which case the  only way  to leave the  list is to

contact the person who  maintains it). Since you  are not directly subscribed

to VISBAS-L, the  only  way  for  you  to  stop getting  the  postings  is  to

contact  the administrator of this sub-list and ask him to sign you off.

You  should be  able to  contact the  list owners  by simply  replying to  this

message (if you do not know how to  reply to a message in your mailbox, you

can send a new message to 'VISBAS-L-Request@LISTSERV.TAMU.EDU'

instead).


VisBas-l (long)

LUOKKA: internet

Date: 07-28-95 (01:19)              Number: 398131 of 398304 (Refer# NONE)

Subj: VISBAS-L Administrative Posting (Please Read)

From: Nathan Brindle <NATHAN@LSOFT.COM>

(Sorry to take so long getting this out to the list.  It's been a hectic

week. :)  I would particularly appreciate your attention to Netiquette

item number 6 regarding attached binaries sent to the list.)

PLEASE READ AND KEEP A COPY OF THIS POSTING.

VISBAS-L Administrative Posting

For VISBAS-L@PEACH.EASE.LSOFT.COM

Microsoft Visual Basic Discussion List

Version 1.0, 95/07/24

CONTENTS

1.  Netiquette

2.  What is VISBAS-L?  Q&A about the list

3.  Who uses VISBAS-L?

4.  LISTSERV Technicalities--How To Use A List

5.  HELP-NET--for the new LISTSERV and Internet user

***********************************************************************

1.  NETIQUETTE

***********************************************************************

One hopes that there isn't a need for many rules on this list.  However,

in the past the general netiquette guidelines have not been well-adhered

to, and there are a couple of points that need to be covered for

everyone's happiness.

1.  The language used on this list is English.  Whether it is

grammatical or not is a question of semantics.  :)  Please restrict your

postings to English unless you simply cannot communicate what you need

to say in that language.

    On the same token, given the multinational nature of the Internet

and VISBAS-L subscribers (see 3.  WHO USES VISBAS-L?), English is a

second language to many posters.  If you take offense to the grammar or

spelling of a post to VISBAS-L, take into consideration the poster's origin.

Please do not insult or flame a person whose grasp of the English language is

lacking. hey deserve credit for the effort to post in a foreign language

as well as the knowledge they have to provide to list discussion.

2.  The list is set to distribute any reply you make to the entire list.

If you wish to make a private comment, you must ensure that you reply to

the original author of the message (the person in the "From:" header

field) rather than to the list itself (the "Sender:" field).  In CMS

(Rice) Mail, REPLY FROM is the command used for this.  You may have a

similar command in your mail package.

    If you are sending a "thanks" message or similar message that is

directed at one or two people only, please reply to those people

directly rather than to the list.

3.  It is recognized that quoting messages is sometimes important in

order to preserve context.  However, please limit your quoting to that

which is absolutely necessary to the thread--and PLEASE delete all

included header lines if your mailer includes them in the body of your

reply.

4.  Discussions that compare other languages to Visual Basic should be

avoided as a general rule.  Mentioning differences or capabilities in

messages with other subjects is allowed,  but long language vs. language

discussions, especially those in which subscribers of the list resort to

personal insults and obnoxious behavior will NOT be tolerated.  Given the

number of subscribers to the list, a discussion of this type has the potential to

generate thousands of messages with absolutely no relevance to the list.

This would be abusive to other subscribers of the list and to the hosts of this

list who provide the hardware and software for VISBAS-L. Subscribers who

repeatedly participate in this kind of discussion and behavior will be removed

from the list permanently.

5.  Apropos of number 4, off-topic discussions are not permitted.  If a

subscriber persists in posting off-topic messages, the list owner reserves the

right to cut off that subscriber's privilege to post. Please note that you do not

have a RIGHT to post anything to this list.  A PRIVILEGE has been extended

to you--do not abuse it.

6.  Please, Please, PLEASE do not post large uuencoded binaries or MIME

attachments to this list.  Even the smallest file is going to be larger

than most people want to find in their mailbox, particularly since the

file is going to be somewhat larger than it would be in binary format

anyway.  Also remember that some people are paying for their messages

and may not be particularly appreciative of receiving a long file they

didn't ask for.

    If you wish to share a file with the rest of the list, you are

encouraged to upload it to CICA or to send it to the list manager

in private mail with a request that he include it in the list archives.

(Such requests should include an abstract of what the file does and/or

what it includes.)  If the file is already on an FTP site, simply mention

the FTP address.

7.  Please DO NOT post transcriptions of reviews or articles from

copyrighted publications--even if they relate to a discussion taking

place.  You can always cite the article in question so others can look

it up.  Or, feel free to summarize the review or article in your own

words.  COPYRIGHTED ARTICLES POSTED VIA VISBAS-L WILL BE

DELETED FROM THE LIST ARCHIVES.

8.  Commercial advertisements or any other postings not germane to the

mission of the list (see below, "What is VISBAS-L?") are prohibited and

subscribers who post such materials will be removed permanently from the

list.

    If the list is "spammed" by a commercial service, such as Canter and

Siegel (the initiators of the "Green Card" spam), please direct any

response to the sender of the spam and/or the postmaster at that site

rather than to the list.  Most of the time, spammers are not subscribed

to the list and will not receive your complaint if you send it to the

list.

***********************************************************************

2.  WHAT IS VISBAS-L?  Q&A ABOUT THE LIST

***********************************************************************

Q. What is VISBAS-L?

A. VISBAS-L@PEACH.EASE.LSOFT.COM is an Internet distribution list

running under LISTSERV(tm) 1.8b on a Windows NT(tm) server at the offices

of L-Soft international, Inc. in Wheaton, Maryland, USA.  VISBAS-L is

provided for the open discussion of Microsoft Visual Basic among interested

parties.

   DISCLAIMER:  L-Soft international, Inc. is <not responsible> for

either the content or the management of the list.  The list owner's

responsibilities are limited to keeping the list focused and tending to

various administrative duties related to the list.  Those who post to

VISBAS-L are solely responsible for the content of their posts.  Any and

all software, either posted across VISBAS-L or residing in the list

archives is downloaded and used at the downloader's own risk.

============================================================

Q. Does Microsoft Corporation sponsor VISBAS-L?

A. No.  The list is not sponsored in any way by Microsoft, although

Microsoft employees and particularly Visual Basic design staff are welcome

and encouraged to subscribe.

***********************************************************************

3.  WHO USES VISBAS-L?

***********************************************************************

VISBAS-L is truly an international list.  As of the 24th of July, 1995,

the subscriber list included over 1900 addresses (since some addresses

are redistribution lists, the actual subscriber count is probably some-

what higher).  Here's the breakdown:

*  Country        Subscribers   *  Country        Subscribers

*  -------        -----------   *  -------        -----------

*  Argentina              4     *  Israel                 7

*  Australia             93     *  Italy                 26

*  Austria               10     *  Japan                  2

*  Bahrain                1     *  Korea                  2

*  Belgium               12     *  Kuwait                 3

*  Brazil                17     *  Malaysia               7

*  Canada                78     *  Mexico                10

*  Chile                  5     *  Mozambique             1

*  China                  2     *  Netherlands           23

*  Colombia               1     *  New Zealand           14

*  Croatia                2     *  Norway                13

*  Cuba                   1     *  Poland                 3

*  Denmark                8     *  Portugal               8

*  Egypt                  4     *  Saudi-Arabia           6

*  Finland               13     *  Singapore             15

*  France                 4     *  Slovenia               1

*  Germany               12     *  South Africa          21

*  Great Britain        104     *  Spain                  6

*  Greece                 5     *  Sweden                26

*  Hongkong               7     *  Switzerland            5

*  Hungary                1     *  Taiwan                 6

*  Iceland                3     *  Thailand               9

*  India                  4     *  Turkey                 6

*  Indonesia              3     *  USA                 1301

*  Iran                   2     *  Venezuela              5

*  Ireland                2

*

* Total number of users subscribed to the list: 1936

* Total number of countries represented:          51

***********************************************************************

4.  LISTSERV TECHNICALITIES--HOW TO USE A LIST

***********************************************************************

Q. What is the format for sending commands to LISTSERV?

A. First of all, be sure you send them to LISTSERV and not to the list.

For specifics on LISTSERV commands, send the command GET LISTSERV

REFCARD to LISTSERV@LISTSERV.NET.

To send commands by mail, simply address a message to LISTSERV@

PEACH.EASE.LSOFT.COM with a blank subject line and the command you

want to send as the body of the message.  You can send up to five

commands at a time in this way, but be forewarned--if one of the commands

triggers an error, all subsequent commands in the message will be flushed

without being processed.  (LISTSERV will count your signature line (if any) as

an error but this should not cause a problem since it comes last.)

============================================================

Q. Should the situation arise, how do I unsubscribe from VISBAS-L?

A. You may leave the list at any time by sending a "SIGNOFF VISBAS-L"

command to LISTSERV@PEACH.EASE.LSOFT.COM. Please note that this

command must NOT be sent to the list address (VISBAS-L) but to the

VISBAS-L LISTSERV address (LISTSERV).

To repeat: this command must NOT be sent to the list address (VISBAS-L).

                        ~~~~~~~~

Please note it is SIGNOFF or UNSUBSCRIBE or UNSUB, not the common

mis- spellings unsubscrobe or unsubscrube or whatever else your fingers

type.

PLEASE note the address: LISTSERV@PEACH.EASE.LSOFT.COM

~~~~~~

============================================================

Q. What if I try to unsubscribe and am told I do not appear in the list?

A. It is most likely that your Internet address has changed slightly and

LISTSERV does not recognize your ID.  Contact the list owner.

   If you can't figure the problem out, do <NOT> post a message to the

list at large to unsubscribe you or to confirm you.  Send all such mail

directly one of the list owners.  See below.

============================================================

Q. Who are the list owners and how do I contact them?

A. The list owner is Nathan Brindle, NATHAN@UBVM.CC.BUFFALO.EDU.

============================================================

Q. How do I get a copy of old postings (list archives)?

A. Some of the list archives are in monthly compendia, others

(newer ones) are in weekly compendia.

For archives from July 1992 through the third week of July, 1994:

Send 'GET VISBAS-L LOGyymm' to LISTSERV@PEACH.EASE.LSOFT.COM,

where 'yymmw' is the year and month of the archive you want

(i.e., LOG9207 is for July 1992).

For archives beginning the 4th week of July, 1994:

Send 'GET VISBAS-L LOGyymmw' to LISTSERV@PEACH.EASE.LSOFT.COM,

where 'yymmw' is the year, month and week number of the archive you want

(i.e., LOG9507D is for the 4th week of July 1995).

============================================================

Q. How do I get an index of list archives and other files

   related to the list?

A. Send the command IND VISBAS-L to

LISTSERV@PEACH.EASE.LSOFT.COM.

***********************************************************************

5.  HELP-NET--FOR THE NEW LISTSERV AND INTERNET USER

***********************************************************************

   There is a LISTSERV list that was created expressly to welcome and

teach new BITNET and Internet users about the new world of electronic

communication.  If you know of anyone (even yourself) who is confused

about BITNET and/or Internet services (not just LISTSERV), ask them to

subscribe to Help-Net.  It is available by subscription from

LISTSERV@TEMPLEVM or LISTSERV@VM.TEMPLE.EDU, and can be read

on the Usenet news network as bit.listserv.help-net.  To subscribe to

Help-Net, send the command

    SUB HELP-NET <Your Name>

to  LISTSERV@TEMPLEVM.BITNET

or  LISTSERV@VM.TEMPLE.EDU

   Help-Net is also a storehouse of documents which describe various

services that are available on both BITNET and the Internet.  Some of

these include a network-related FAQ file, information on E-mail,

LISTSERV, network etiquette, how to find E-mail addresses, and so on.

These are all written at very basic levels of knowledge from a technical

standpoint.  The documentation is available three ways:  via the

traditional LISTSERV archive method, via Gopher, and via anonymous ftp.

   Many novice Internet and BITNET users over the last 5-6 years have

increased their knowledge of various network services considerably,

thanks to the kind and generous help that is provided by more

sophisticated Help-Net subscribers.

   If you want more information about Help-Net, send mail to Stan

Horwitz, STAN@VM.TEMPLE.EDU.

   (This information on Help-Net was current as of 5/6/94)


VSVBX general

LUOKKA: VBgen

1026 (45+)  gleng@crl.com  10.01.95  23:56

Glen G. Gordon: "Re: Review: VSVBX vs ErgoTab; Comments on Visual

Suite"

David H Dennis (dhd@netcom.com) put forth:

>... The ŽVideoSoft� elastic lets controls grow and

>shrink as a form is re-sized by the user.  The good news is that this

>does in fact work; the bad news is that the results look so hideous

>that you're unlikely to appreciate them.  If you have a form with

The best situations to use the elastic in are:

1. You have a single large control (textbox, grid, etc.) and you don't

want to put code in the resize event

2. You have a series of controls that you want to maintain the same

proportions when the form is resized

Two good features not mentioned about the elastic are

1. it can turn any control placed on it into a 3-d control,  so you can

use the regular text boxes, listboxes, etc.

2. It can place the tag of a control as an identifying label (complete

with mnemonic access key) next to the control without you having to draw

a label.

>I was unable to try out AWKSOME, mainly because I am unfamiliar with

>AWK, the Unix-based pattern matching language on which it is based.

>(I use C and Perl on my Linux box at home).  The documentation for

>the package appeared to pre-suppose a knowledge of AWK.

*snip*

>The VideoSoft Index Tab was the most useful of the controls.  Its main

>deficiency is aesthetic; the tab does not look nearly as attractive as

>the ErgoTab reviewed below.  I tried several different modes and

>several different angles, and none of them looked frightfully good.

I have had no problem duplicating exactly the look of Word's dialog

boxes. Make sure the FontBold property is False, and you are using the

chamfered 3-d style, with a FrontTabColor of grey.

>2  In the case of VSVBX, the first elastic you select will expand

>to fill the first tab.  For the remaining elastics, you must draw tiny

>elastic images on each tab.  They will promptly vanish, making you

>wonder what's going on.  You can then right-click each tab to select

>it and its controls.

Also, double-clicking the right mouse button on any tab will cause the

current tab to become 0, so you can see all the containers side-by-side,

and easily rearrange them

>4  The deciding factor for me between VideoSoft's and ErgoTab's tab

>controls was appearance.  I could not get VideoSoft's tab to look at

>all attractive; it did the job, but suffered in comparison to the

>dialogue boxes in programs such as Microsoft Word for Windows.  The

>ErgoTab look was identical to Word for Windows' dialogue boxes, which

>have a crisp, sleek three-dimensional effect.

see above

I really love the VSVBX collection, and would definitely recommend it to

anyone as one of their first custom controls.

Glen


VSVBX Lic.file

LUOKKA: VBgen

Date: 08/18/94 (12:06)              Number: 16127 of 16174 (Refer# NONE)

From: MICHAEL.RUBIN@PCGFX.COM

Subj: Re: Re: Getting Form B's

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 08-16-94 D1CAMERO@BCSC02.GOV.BC.CA  wrote:

D>I have used the VSVBX to create multiple "pages" per form. The only

D>restriction is the max of 255 controls per form.  BUT, since the

D>elastic controls use the TAG as the field label, I have effectively

D>doubled the number of data fields per form.

I've used this control successfully for some time.  There's one real

pain-in-the-ass problem, though.  A license file must be distributed

with the .VBX or the end-user gets the nag-screen.  It gets worse - it

_MUST_ be in the user's .. WINDOWS SYSTEM directory.  Shareware users

often dump all files into a temp directory t test-ride the app, and I've

had several of my beta testers complain about the popup.  I finally had

to write a sub that looks for the license file and copies it to the

user's .. WINDOWS SYSTEM directory, thus alowing the popup to occur only

once.

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                                m_rubin@tatertot.com


VSVBX tab controls

LUOKKA: VBgen

Date: 09/24/94 (16:48)              Number: 20640 of 20702 (Refer# NONE)

From: IAN@MONTY.DEMON.CO.UK

Subj: Re: Have I gone crazy??

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

> Anyhow, onto my problem.  I am attempting to make my forms resizable with

> the elastic feature.

>   I create a form

>     add elastic (align = 5, autosize = 1, style = 0)

>     add indextab control

>     Now I want to add an elastic to each tab.  I have tried and tried

>      and cannot figure out how I pin this elastic to a certain tab.

>    I have tried starting with only one tab and adding the elastic.

>    I have tried starting with 3 tabs and adding the elastic

>    I have tried adding the elastic to the -1 (index) tab

>    I have used the PAGE control array setting the index to the tab number

When you want to add any control to a specific page on a multi-page

tab control with VSVBX, this is what you do:

1. Select the tab control which you have created in your VB form.

2. Double-right-button-click the tab of the page you are interested in.

This brings it to the front.

3. Click the toolbar button of the control you want to appear on that

page.

4. Important! Move the mouse pointer to the **** current tab **** of

the tab control and draw a marquee in the ** tab ** area. Don't draw

the marquee in the normal client area of the tab's page.

Do this for each page. Run the program and you will see each container

control on the right page.

The control as you download it is the full kit, not disabled in any way

- all it lacks is the documentation and the developer file which allows

you to edit without the guilt screen popping up.

VSVBX is a real time-saver. Take a look at SentMail (ftp.demon.co.uk

/pub/ibmpc/windows/sentmail) for an example with source code of an

Internet sent mail reader written in one afternoon using VSVBX.

Ian Piper

--------------------------------------------------------------------------

Don't feel like the Lone Ranger. I also recommend VSVBX without

reservation--

but it ain't perfect. Yet. I think what you need to do is:

    1.) Make VSIndexTab1=false

    2.) Then draw as many elastics from left to right as you have tabs for

    3.) Make VSIndexTab1=true

    4.) The tab folder will fill up with the elastic for the current tab

    5.) You can double-RIGHT-click on any tab to see it's elastic

I was able to have the same problems you had until I did the above. The doc

could be a lot more clearer on this. Good luck.

Dave Hunt

Source Data Systems


VSVBX tab ctrls

LUOKKA: VBgen

Date: 08/02/94 (20:57)              Number: 14161 of 14165 (Refer# NONE)

From: MAILMAN@TELFON.ENET.DEC.COM, Steven M. Mailman

Subj: Re: VideoSoft's IndexTab control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

In article <Ctws75.JMx@freenet.carleton.ca>, ae613@FreeNet.Carleton.CA

(Christopher King) writes...

>Ok, so I got ahold of VideoSoft's set of custom controls (IndexTab,

>Elastic, and some AWK thing) and they look pretty good, but...

>I'm having a problem with the IndexTab control.  The help file says to

>create one elastic (or picture control) per tab.  Okay, sounds reasonable

>but when I do the tab control doesn't understand that the elastics are

>supposed to 'go with' each individual tab.  What I mean to is that I can

>create as many tabs as I want but the main tab area remains contant

>regardless of what tab I click on during runtime.

 VideoSoft's tab and elastic are, in general, very impressive. I did have the

same problem with the tab control and was ready to toss them into the

garbage until I found the trick.  After creating the control with multiple tabs,

drop an elastic into each tab by selecting the tab (double click right mouse

button) and drop elastic into the little tab, not the body.

 Another solution is to cut & paste the entire tab control

 out of the example program and then modify to fit your needs.

------

Steve Mailman

Digital Equipment Corporation

mailman@tle.enet.dec.com


VSVBX tab ctrls

LUOKKA: VBgen

Date: 08/02/94 (21:17)              Number: 14164 of 14165 (Refer# NONE)

From: D1CAMERO@BCSC02.GOV.BC.CA

Subj: Re: VideoSoft's IndexTab control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

ae613@FreeNet.Carleton.CA (Christopher King) writes:

>Ok, so I got ahold of VideoSoft's set of custom controls (IndexTab,

>Elastic, and some AWK thing) and they look pretty good, but...

>I'm having a problem with the IndexTab control.  The help file says to

>create one elastic (or picture control) per tab.  Okay, sounds reasonable

>but when I do the tab control doesn't understand that the elastics are

>supposed to 'go with' each individual tab.  What I mean to is that I can

>create as many tabs as I want but the main tab area remains contant

>regardless of what tab I click on during runtime.

Draw the tab control.

Click on the elastic control and draw inside the tab control

   it should expand to the whole tab control size.

Copy the newly created elastic to the clipboard. (ctl-c)

Click on the tab control and paste in the elastic from the clipboard.

Answer YES when asks to create a control array.

Continue to paste into the tab control as many elastics as there are

tabs.

Don Cameron

d1camero@bcsc02.gov.bc.ca


Wallpaper

LUOKKA: MDI

>This is to answer all the persistent queries about how to

>have a 'wall paper' on an MDI form. The solution is taken

>from VBPJ Aug/Sept 1994 isuue, and reproduced here for

>everyone's benefit :

>

>1. Create the Wallpaper form. Set the border style to none,

>   and MDIChild property to true, and the picture property

>   to the bitmap or metafile of your choice. (or set the

>   background color to a color you want the MDI to have).

>2. Add this code to the form's activate event :

>        Sub Form_Activate()

>                ZOrder 1

>        End Sub

>3. Add this to the Form Resize event :

>        Sub Form_Resize()

>            If WindowState = 0 Then

>                Move 0,0,frmMDI.ScaleWidth,frmMDI.ScaleHeight

>                ZOrder 1

>            End If

>        End Sub

>4. Finally, add the follwoing code to the form resize event

>   of the MDI parent form :

>        Sub Form_Resize()

>            frmWallPaper.Move 0,0,frmMDI.ScaleWidth,frmMDI.ScaleHeight

>        End Sub

>

>

I have used a similar way of creating a wallpaper in a mdi form.  It

works OK except when I tried to tile other child forms using the

Arrange method. This will cause the wallpaper form to be tiled together

with the others.  Cascading the other child forms is not a problem -

the wallpaper form remains in the background.

Has anybody encountered this problem?

Solution:

    Minimize backround from before doing Arrange.

        bck.WindowState = 1

        mdi.Arrange 1

        bck.WindowState = 0

        bck.Zorder 1


Wallpaper

LUOKKA: VBgen

23.How do I set the Windows wallpaper at runtime?

   I'm surprised this isn't in the FAQ yet. ÄED: now it is!å You need the

   SystemParametersInfo API function and the SPI_SETDESKWALLPAPER

constant.

   For this you will need the following constants and function

   declaration...

     Const SPI_SETDESKWALLPAPER = 20

     Const SPIF_SENDWININICHANGE = &H2

     Const SPIF_UPDATEINIFILE = &H1

     Declare Function SystemParametersInfo Lib "User" (ByVal uAction As

      öInteger, ByVal uParam As Integer, lpvParam As Any, ByVal fuWinIni As

      öInteger) As Integer

     'You then call the function as follows...

     Result% = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal

BMPFile$,

      öSPIFlags%)

     '... where SPIFlags% is 0 if the change is not to be made permanent, or

     '(SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE) if it is to be

carried across

     'into future Windows sessions.

   NOTE: Please be certain to include the ByVal keyword before the bitmap

   filename, as this argument is declared as Any, NOT as ByVal String.

   Luke Webber(webber@werple.apana.org.au)


Wav

LUOKKA: sounds

22527 (115+)  rossflem@u.washington.edu  27.06.95  02:36

"R. Fleming": "Re: DAMN SOUND !!!!"

On Mon, 26 Jun 1995, Stuart J Dawson wrote:

> I've tried this, I've tried that and the VB home pages

> but still can't get VB to play a short piece of sound.

>

> All I want is my form to load up and when I click on the

> command button the "rifle.wav" file should play.

This was copied from Visual Basic Tips and Tricks 95 which is an

excellent guied advailable from

Where To Find New Issues:

InterNet FTP Sites:

CICA: ftp.cica.indiana.edu Ä129.79.20.17Å

 Directory: ~ftp/pub/pc/win3/programr/vbasic

World Wide Web:

Carl 'n Gary's Visual  Basic Home Page: http://www.apexsc.com/vb

The trick is a real cheat. It doesn't require the MCI.VBX and is pretty

fast.

Using The Beep Statement To Play A Wave

In my company, even though we each have a PC on our desk running

Windows, the company doesn't supply sound cards and speakers.

Consequently, all of the PCs run the Microsoft Windows Speaker Driver.  This

affords us the ability to hear a crude approximation of sound.

When we wrote our first Visual Basic application, we wanted several

custom sounds to play to alert the user.  After some digging, we found out

that the Multimedia MCI control does not play .WAV files through the speaker

driver.  After looking in the Knowledge Base, we found a method using the

OLE control to link to Sound Recorder which worked, but was slow, put the

Sound Recorder on the screen, and was cumbersome to use.  We searched

for a better way.

It occurred to me, that the Visual Basic Beep command played the

DING.WAV file just fine,  so why couldn't we use the same mechanism to play

our own sounds.  I then wrote playsound  which is simplicity itself.  First, I

read WIN.INI and save off whatever the current  default sound is.  Next I

replace that default sound with the .WAV file that we are trying to play.

Then just call Beep!  Finally, the original sound is written back to WIN.INI.

Simple, easy, and effective.

I was surprised that this method plays the .WAV files just as fast as the

MCI control does on those machines that have a sound card.  Consequently,

it has become my default method of playing sounds in all my programs.

Included is the source to a project I call WAVPLAY which allows you to

browse for .WAV files, and play them with a simple click.  It also takes a

command line argument, so it is perfect for Associating with .WAV files in File

Manager.  Enjoy.

Sub playsound (s As String)

    Dim orgstr As String

    Dim R As Integer

        'Save your original sound

    orgstr = sReadINI("sounds", "SystemDefault", "win.ini")

        'Replace it with the wave file passed

    WriteINI "sounds", "SystemDefault", s, "win.ini"

        'Make the noise

    Beep

        'Return to the original sound

    WriteINI "sounds", "SystemDefault", orgstr, "win.ini"

End Sub

TIP SUBMITTED BY: LARRY WRIGHT

The sReadINI and WriteINI functions can be found in the INIFILES.BAS that

comes with VB Tips & Tricks.

Ross Fleming

Seattle, Washington


Wav

LUOKKA: sounds

Date: 01/19/95 (14:38)              Number: 33002 of 33020 (Refer# NONE)

From: ZETA@SKYPOINT.COM

Subj: VB Project: How to play WAVE files with API calls

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Below is a program that demonstrates playing wav files with API calls.  It

also includes a procedure and subroutine useful for any program.

Featured routines:

     Function SoundEnabled()

          Returns a TRUE/FALSE if any WAVE devices are detected in the

system

     Sub PlayWave(ByVal WaveFile$, Wait%, Repeat%, Interupt%)

          Plays a wave file with the API call and provides other features...

          WaveFile is a string with    drive:™path™filename.wav

          Wait - true or false - Wait for WAVE to finish playing before

               returning

          Repeat - Repeatedly play the song (warning, if you play repeatedly

               and have Wait enabled it may play a wav repeatedly in an

               infinite loop)

          Interupt - Do not interupt a WAV if it is playing

This code is Copyright 1995 Gregory S. Youngblood

This code will shortly be featured in the Visual Basic Project.

------

VERSION 2.00

Begin Form Form1

   Caption         =   "Visual Basic Project - Play Wave Demo"

   ClientHeight    =   1365

   ClientLeft      =   1140

   ClientTop       =   1500

   ClientWidth     =   5865

   Height          =   1770

   Left            =   1080

   LinkTopic       =   "Form1"

   ScaleHeight     =   1365

   ScaleWidth      =   5865

   Top             =   1155

   Width           =   5985

   Begin CommandButton Command2

      Caption         =   "E&xit"

      Height          =   615

      Left            =   3240

      TabIndex        =   1

      Top             =   480

      Width           =   2055

   End

   Begin CommandButton Command1

      Caption         =   "&Play Demo"

      Height          =   615

      Left            =   600

      TabIndex        =   0

      Top             =   480

      Width           =   2055

   End

   Begin Label Label1

      Alignment       =   2  'Center

      Caption         =   "Don't forget to click on the form for a single

sound."

      Height          =   255

      Left            =   600

      TabIndex        =   2

      Top             =   120

      Width           =   4695

   End

End

Option Explicit

Declare Function sndPlaySound Lib "MMSYSTEM.DLL" (ByVal

lpszSoundName$, ByVal

wFlags%) As Integer

Declare Function waveOutGetNumDevs Lib "mmsystem.dll" () As Integer

Sub Command1_Click ()

  If SoundEnabled() Then

    Call PlayWave("c:™windows™tada.wav", True, False, False)

    Call PlayWave("c:™windows™chord.wav", True, False, False)

    Call PlayWave("c:™windows™tada.wav", True, False, False)

  Else

    MsgBox "Unabled to detect WAV device in this system."

  End If

End Sub

Sub Command2_Click ()

  End

End Sub

Sub Form_Click ()

  If SoundEnabled() Then

    Call PlayWave("c:™windows™tada.wav", True, False, False)

  Else

    MsgBox "Unable to detect WAV device in this system."

  End If

End Sub

Sub PlayWave (ByVal WaveFile$, Wait%, Repeat%, Interupt%)

Const SND_SYNC = &H0       ' Function returns at end of play

Const SND_ASYNC = &H1      ' Function returns immediately after beginning

play

Const SND_NODEFAULT = &H2  ' If sound not found, return silently without

playing default sound

Const SND_LOOP = &H8       ' Sound plays repeatedly until stopped

Const SND_NOSTOP = &H10    ' If sound is currently playing, returns false

Dim tmpFlags%, Success%

  tmpFlags = SND_NODEFAULT

  If Wait Then

    tmpFlags = tmpFlags + SND_SYNC

  Else

    tmpFlags = tmpFlags + SND_ASYNC

  End If

  If Repeat Then

    tmpFlags = tmpFlags + SND_LOOP

  End If

  If Not Interupt Then

    tmpFlags = tmpFlags + SND_NOSTOP

  End If

  Success = sndPlaySound(WaveFile, tmpFlags)

End Sub

Function SoundEnabled () As Integer

Dim tmpBool%

  tmpBool% = waveOutGetNumDevs()

  If tmpBool = 0 Then

    SoundEnabled = False

  Else

    SoundEnabled = True

  End If

End Function

----

The Complete Solution                           Gregory S. Youngblood

(612) 572-1691                                      zeta@skypoint.com

Check out our new WWW page:  http://www.skypoint.com/subscribers/zeta

VISUAL BASIC PROJECT     http://www.skypoint.com/members/zeta/vb.html


Wav Beep cmds

LUOKKA: sounds

Date: 06-29-95 (02:30)              Number: 374740 of 377040 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Answer: Sound out of Speaker.Wav

From: Timothy Kulig <tkulig@IGLOU.COM>

In the Visual Basic Tips & Tricks 95:

Using The Beep Statement To Play A Wave

In my company, even though we each have a PC on our desk running

Windows, the company doesn't supply sound cards and speakers.

Consequently, all of the PCs run the Microsoft Windows Speaker Driver.  This

affords us the ability to hear a crude approximation of sound.

When we wrote our first Visual Basic application, we wanted several custom

sounds to play to alert the user.  After some digging, we found out that the

Multimedia MCI control does not play .WAV files through the speaker driver.

After looking in the Knowledge Base, we found a method using the OLE

control to link to Sound Recorder which worked, but was slow, put the Sound

Recorder on the screen, and was cumbersome to use.  We searched for a

better way.

It occurred to me, that the Visual Basic Beep command played the

DING.WAV file just fine,  so why couldn't we use the same mechanism to play

our own sounds.  I then wrote playsound  which is simplicity itself.  First, I

read WIN.INI and save off whatever the current default sound is.  Next I

replace that default sound with the .WAV file that we are trying to play.

Then just call Beep!  Finally, the original sound is written back to WIN.INI.

Simple, easy, and effective.

I was surprised that this method plays the .WAV files just as fast as the

MCI control does on those machines that have a sound card.  Consequently,

it has become my default method of playing sounds in all my programs.

Included is the source to a project I call WAVPLAY which allows you to

browse for .WAV files, and play them with a simple click.  It also takes a

command line argument, so it  is perfect for Associating with .WAV files in

File Manager.  Enjoy.

Sub playsound (s As String)

    Dim orgstr As String

    Dim R As Integer

        'Save your original sound

    orgstr = sReadINI("sounds", "SystemDefault", "win.ini")

        'Replace it with the wave file passed

    WriteINI "sounds", "SystemDefault", s, "win.ini"

        'Make the noise

    Beep

        'Return to the original sound

    WriteINI "sounds", "SystemDefault", orgstr, "win.ini"

End Sub

TIP SUBMITTED BY: LARRY WRIGHT

The sReadINI and WriteINI functions can be found in the INIFILES.BAS that

comes with VB Tips & Tricks.


Wav play

LUOKKA: sounds

Date: 01/18/95 (20:42)              Number: 32910 of 33020 (Refer# NONE)

From: /DD.ID=MSUSCL35.MCELEN01@EDS.COM, Mike Celentano

Subj: Re: How to play a .wav file in VB???

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

>

...Here is a way of doing it without using the MCI Custom Control.

global.bas

   Declare Function sndPlaySound Lib "MMSYSTEM.DLL" (ByVal

lpszSoundName$,

ByVal wFlags%) As Integer

   Global Const SND_SYNC = &H0

   Global Const SND_ASYN = &H1

   Global Const SND_NODEFAULT = &H2

   Global Const SND_LOOP = &H8

   Global Const SND_NOSTOP = &H10

' the form has a DirListBox, a DriveListBox and a FileListBox on it.

Sub file1_DblClick ()

Dim SoundName As String

Dim wFlags As Integer

Dim Ret As Integer

   MousePointer = HOURGLASS

   SoundName = dir1.Path & "™" & file1.FileName

   wFlags = SND_SYNC And SND_NODEFAULT

   Ret = sndPlaySound(SoundName, wFlags)

   MousePointer = DEFAULT

End Sub

...Here is the MCI solution....

global.bas

    frmSound.MMControl1.Notify = False

    frmSound.MMControl1.Wait = True

    frmSound.MMControl1.Shareable = False

    frmSound.MMControl1.DeviceType = "WaveAudio"

' the form has a DirListBox, a DriveListBox, a FileListBox and a MCI custom

control on it.

Sub file1_DblClick ()

        screen.MousePointer = 11

        frmSound.MMControl1.FileName = dir1.Path & "™" & file1.FileName

        ' Open the MCI WaveAudio device.

        frmSound.MMControl1.Command = "Open"

        frmSound.MMControl1.Command = "sound"   'Plays the select file

        frmSound.MMControl1.Command = "Close"

        screen.MousePointer = 0

End Sub

both need the constants.txt file in the project.  Good luck.... Mike Celentano


Wav play

LUOKKA: sounds

Date: 03-22-95 (15:01)              Number: 267159 of 268871 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: HELP: MCI.VBX

> I'm new at VB.  I'm trying to play sound file, one after another but

> don't know how.  Here is what I'm trying to do: I want to play a numbers

> of WAVE files, one after another but it just play the last one, e.g.,

>

>    MMControl1.FileName = "tada.wav"

>    MMControl1.Command = "open"

>    MMControl1.Command = "play"

>    MMControl1.FileName = "chimes.wave"

>    MMControl1.Command = "open"

>    MMControl1.Command = "play"

>

> and the only sound I heard was of the "chimes.wave".  Please help!

Declare Function sndPlaySound Lib "MMSystem.dll" (ByVal WavFile$, ByVal

Flags%) As Integer

Sub Command1_Click ()

Dim Dummy As Integer

Dummy = sndPlaySound("C:™Widows™tada.wav", 0)

Dummy = sndPlaySound("C:™Windows™chimes.wav", 0)

Dummy = sndPlaySound("C:™Windows™chord.wav", 0)

Dummy = sndPlaySound("C:™Windows™ding.wav", 0)

Dummy = sndPlaySound("C:™Windows™elvis.wav", 0)

Dummy = sndPlaySound("C:™Windows™porky.wav", 0)

Dummy = sndPlaySound("C:™Windows™shazam.wav", 0)

End Sub


Wav vol.ctrl

LUOKKA: sounds

Date: 11/10/94 (15:17)              Number: 26579 of 26597 (Refer# NONE)

From: DUNCAN_SMITH@MINDLINK.BC.CA, Duncan Smith

Subj: Re: VB 3.0 WAV File Volume Control

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I was experimenting with something like this about a year ago and uncovered

an API call to set the volume of a soundcard, the call goes like this:

CALLING EXAMPLE

        result = waveOutSetVolume(DeviceID, WaveVolume)

WHERE

        result          is the result code of the API call

        DeviceID        is the internal handle of the soundcard (try 0)

        WaveVolume      is the volume level to set the card to.

... this is based-upon the following MMSYSTEM.DLL API calls:

Declare Function waveOutGetVolume Lib "mmsystem" (ByVal udeviceid As

  Integer, lpdwvolume As Long) As Integer

Declare Function waveOutSetVolume Lib "mmsystem" (ByVal udeviceid As

  Integer, ByVal dwVolume As Long) As Integer

Declare Function waveOutGetPlayBackRate Lib "mmsystem" (ByVal

hWaveOut As Integer, lpdwrate As Long) As Integer

Declare Function waveOutSetPlayBackRate Lib "mmsystem" (ByVal

hWaveOut As Integer, ByVal dwrate As Long) As Integer

Declare Function waveOutGetID Lib "mmsystem" (ByVal hWaveOut As

Integer, lpudevice As Integer) As Integer

Declare Function waveOutGetNumDevs Lib "mmsystem" () As Intege

... you can wreak havoc with a WAV files using these API calls.  Hope this

helps you out!

=============

Duncan S. Smith

duncan_smith@mindlink.bc.ca


Wav/Mid

LUOKKA: sounds

10.How do I play MID, WAV or other multimedia files?

   Use the MSMCI.VBX, provided with VB/Win Pro 3.0. You can also declare

   and call the MM-functions manually:

     Declare Function mciExecute Lib "MMSystem"

     ö(ByVal FileName as String) As Integer

     Sub Form1_Click ()

         iResult = mciExecute("Play c:ÖwindowsÖmkmyday.wav")

     End Sub

   Also:

   Playing a WAV file is covered in the VB Tips help file (there is a

   Windows call that is for this specificially; see below). The routine

   won't play MIDI files or other sound formats, however.

   Declare Function sndPlaySound Lib "MMSYSTEM.DLL"

    ö(ByVal WavFile$, ByVal Flags%) As Integer

   Global Const SND_SYNC = &H0

   Global Const SND_ASYNC = &H1

   Global Const SND_NODEFAULT = &H2

   Global Const SND_LOOP = &H8

   Global Const SND_NOSTOP = &H10

   Global Const SND_USUAL = SND_ASYNC And SND_NODEFAULT

   ÄJohn McGuire (jmcguire@jax.jaxnet.com)Å


WHAT6

LUOKKA: WinHelp

6344  techstaf@resdyn.com  11.07.95  18:14

Branch Archer) (Fred B. "Branch"  Archer: "Re: WHAT6 Won't load"

kkyler@netcom.com (Ken Kyler) wrote:

>I downloaded WHAT6 from Microsoft, followed the instructions explicidely

>and can't get the WHPE program to run.  I get a "WHPE.exe or one of its

>components is missing" error.  I got another copy from Microsoft thinking

>a file was corrupted in the transfer but that didn't help.

You need to place a copy of VBRUN100.DLL in your Windows/System

directory.  This program is an _old_ VB shell but performs very well

for me.


WHAT6

LUOKKA: WinHelp

Windows Help Authoring Tool (WHAT6) for Use with Word 6.0

------------------------------------------------------------------------

The information in this article applies to:

- Microsoft Word for Windows, version 6.0

- Microsoft Windows operating system version 3.1

- Microsoft Visual Basic programming system for Windows, version 3.0

------------------------------------------------------------------------

SUMMARY

=======

Microsoft has developed an internal tool called the Windows Help

Authoring Toolkit for Microsoft Word for Windows version 6.0 (WHAT6).

This tool is used within Microsoft to help create Help files. Microsoft

is now providing this internal tool to our customers.

   THIS TOOL IS NOT SUPPORTED BY MICROSOFT CORPORATION. IT IS

   PROVIDED "AS IS" BECAUSE WE BELIEVE IT MAY BE USEFUL TO

   YOU. WE REGRET THAT MICROSOFT IS UNABLE TO SUPPORT OR

   ASSIST YOU, SHOULD YOU HAVE PROBLEMS USING THIS TOOL.

Please refer all your questions on WHAT6 to the WHAT6 Help menu.

How to Obtain WHAT6 and Related Files

-------------------------------------

WHAT6.EXE contains WHAT6.DOT and related files. You can download

WHAT6.EXE, a self-extracting file, from the Microsoft Software Library

(MSL) on the following services:

 - CompuServe

      GO MSL

      Search for WHAT6.EXE

      Display results and download

 - Microsoft Download Service (MSDL)

      Dial (206) 936-6735 to connect to MSDL

      Download WHAT6.EXE

 - Internet (anonymous FTP)

      ftp ftp.microsoft.com

      Change to the \softlib\mslfiles directory

      Get WHAT6.EXE

After downloading it, run WHAT6.EXE in an empty directory to decompress

the component files contained within it.

MORE INFORMATION

================

What Is WHAT6

-------------

The Windows Help Authoring Toolkit for Microsoft Word for Windows

version 6.0 (WHAT6) consists of a Microsoft Word version 6.0 template

(.DOT file)and various tools that modify Microsoft Word for Windows.

You can use WHAT6 to create and edit Help topic files. WHAT6 makes

creating Help files easier by providing dialog boxes to add Help

features that would otherwise need to be created using specialized Help

coding and word-processing functions. For example, instead of entering

footnotes for a topic's context string and title, you can simply type

the information into a dialog box. WHAT6 also has Help Files to assist

you and Windows programs for creating bitmap hotspots and managing your

Help project.

The Help Authoring Template (WHAT6.DOT) makes it easier for you to:

 - Create and edit topic files.

 - Insert and edit topics, graphics and hot spots.

 - Format topic text and graphics.

 - Save topic files in RTF format.

 - View partial or complete builds of the topic file in Windows Help.

 - Insert bitmaps into your help file.

 - Apply help styles.

 - Format Lists.

How the WHAT6.DOT Template Works

--------------------------------

The Help Authoring Template is similar to other Word for Windows

templates. It contains a set of specialized macros and styles that

become available when you open a document based on the template. The

template modifies existing commands and adds new commands to the Word

for Windows menus. The result is a version of Word for Windows that has

all the word-processing functionality and yet is optimized for creating

Help files.

Requirements

------------

The WHAT6.DOT template requires Microsoft Word version 6.0 for Windows

and Windows Help version 3.10.505, which is fully compatible with Word

for Windows 6.0 Rich Text Format (RTF).

What WHAT includes: / 32 files  / 2.72 MB

-----------------------------------------

The below list provides the names of all the files that are a part of

the WHAT6 utility.  In addition this list also indicates how each of

these filed should be installed on your system (there is not SETUP

utility for this tool).

The directories to which you will be asked to copy files to are:

\WINDOWS          This is your Windows directory (i.e. C:\WINDOWS)

\WINDOWS\SYSTEM   This is your System directory (i.e.

C:\WINDOWS\SYSTEM)

\WINWORD          This is where you have WinWord installed

                  (i.e. C:\WINWORD).

\WINWORD\TEMPLATE This is where you have your templates stored for

                  WinWord (i.e. c:\WINWORD\TEMPLATE).

\HELP             This is your help working directory.  You can place

                  this directory any where you want and name it anything

                  you want (i.e. C:\WINWORD\HELP). You will need

                  to create this directory.

\HELP\SAMPLE      This is where the help samples will be placed. It is

                  usually set up as a directory off of your \HELP

                  directory (i.e. C:\WINWORD\HELP\SAMPLE). You will need

                  to create this directory.

Template Files:

---------------

WHAT6.DOT     WHAT6 template used by WORD6. Copy to your

              \WINWORD\TEMPLATE directory.

WHAT6.STY     Style sheet used by the WHAT6 template. Copy to your

              \WINWORD\TEMPLATE directory

WHAT6.INI     Initialization file for WHAT6. Copy to your \WINDOWS

              directory.

STYLES.DLL    Collection of function used by the WHAT6 template. Copy to

              the \WINDOWS\SYSTEM directory

Help Tools:

-----------

WHPE.EXE      Help Project Editor. Copy to your \HELP directory.

HCPARSE.DLL   Parses the HPJ file into a format used by WHPE.EXE

SHED.EXE      HotSpot Editor. Copy to your \HELP directory.

MRBC.EXE      Multiple Resolution Bitmap Compiler. Copy to your \HELP

              directory.

Help Authoring Help Files:

--------------------------

WHPE.HLP      Project Editor Help. Copy to your \HELP directory.

WHAT6.HLP     Help on WHAT6.DOT. Preferably, where your template is

              stored (in your \WINWORD\TEMPLATE directory).

BLDERROR.HLP  Help Compiler Errors. Copy to your \HELP directory.

HAG.HLP       Help Authoring Guide. Copy to your \HELP directory.

Help Compiler Files:

--------------------

HC.EXE        Version 3.10.505. Copy to your \HELP directory

HC.ERR        Help Compiler Error file. Copy to same directory as

              HC.EXE.

HCP.EXE       Protect Mode Version 3.10.505. Copy to your \HELP

              directory.

HCP.ERR       Help Compiler Error file. Copy to same directory as

              HCP.EXE.

Sample Files:

-------------

HELPEX.HPJ    Copy to your \HELP\SAMPLE directory.

HELPEX.RTF    Copy to your \HELP\SAMPLE directory.

Help Bitmaps:

-------------

BIGBUT.BMP    Copy to your \HELP\SAMPLE directory.

BOOK.BMP      Copy to your \HELP\SAMPLE directory.

BULLET.BMP    Copy to your \HELP\SAMPLE directory.

CHICLET.BMP   Copy to your \HELP\SAMPLE directory.

CLOSED.BMP    Copy to your \HELP\SAMPLE directory.

DOC.BMP       Copy to your \HELP\SAMPLE directory.

EMDASH.BMP    Copy to your \HELP\SAMPLE directory.

LEAF.BMP      Copy to your \HELP\SAMPLE directory.

MINUS.BMP     Copy to your \HELP\SAMPLE directory.

NEXT.BMP      Copy to your \HELP\SAMPLE directory.

OPEN.BMP      Copy to your \HELP\SAMPLE directory.

PLUS.BMP      Copy to your \HELP\SAMPLE directory.

Misc:

-----

WHAT6.ICO     Icon for use with Program Manager. Copy to your \HELP

              directory.

HAG.ICO       Icon for the Help Authoring Guide. Copy to your \Help

              directory.

CMDIALOG.VBX  Common Dialog Custom control used by WHPE.EXE. Copy

to

              your \WINDOWS\SYSTEM directory.

WHAT6.TXT     This Article

WHAT6.HLP Help File

-------------------

After you copy the WHAT6.HLP file to your hard-drive, note which

directory it is in. Then modify the macro called HelpOnWhat to point to

this location by following these steps:

1. From within Word 6.0 Choose New... from the File Menu.

2. From the "New" dialog select the Document radio button in the lower

   left and then select What6 from the "Template" Combo Box.

3. Choose Macro from the Tools menu.

4. Select HelpOnWhat from the "Macro Name" Combo Box and choose Edit.

5. Find the line of code that reads:

   t = WinHelp(hwnd,"\\merlin\winhelp\what\help\what6.hlp", hlpINDEX, 0)

6. Edit the command line so that it matches the location of the help

   file (i.e. "C:\WINWORD\TEMPLATE\WHAT6.HLP").

7. From the File menu Close and save the macro.

8. Close your document and when prompted if you want to save changes to

   the .DOT template choose YES.

Setting up Icons in Program Manager

-----------------------------------

After you have the above files copied to all the correct location you

may want to setup icons for some of the files in a group in Program

Manager.

1. Select or create a new group in Program Manager. To create a new

group choose New... form the File menu in Program Manager. Select

Program Group and select OK. Next enter in a Description for the new

group and select OK.

2. Once you have a program group selected choose New... form the File

menu in Program Manager. Select Program Item and Select OK. Next enter

in the Description, Command Line and Working Directory, then select OK.

Repeat this process for each of the item listed below.

Description:         Help Project Editor

Command Line:        C:\WINWORD\HELP\WHPE.EXE

Working Directory:   C:\WINWORD\HELP

Description:         HotSpot Editor

Command Line:        C:\WINWORD\HELP\SHED.EXE

Working Directory:   C:\WINWORD\HELP

Description:         Help Compiler Errors

Command Line:        C:\WINWORD\HELP\BLDERROR.HLP

Working Directory:   C:\WINWORD\HELP

Description:         Help Authoring Guide

Command Line:        C:\WINWORD\HELP\HAG.HLP

Working Directory:   C:\WINWORD\HELP

For this last item (HAG.EXE) there is a separate icon file that is

provided that you can associate with it in Program Manager. To do this,

select (click once) the current icon in the program group in Program

Manager that you just created. Next Select Properties... from the File

menu. Then select 'Change Icon...' and in the 'File Name' field type in

the path and file name of the desired icon (i.e.

C:\WINWORD\HELP\HAG.ICO) and then select OK.

Getting Started

---------------

The following steps will get you started with how to use the Project

Editor and the WHAT template to create a new Windows Help File.

1. Assuming you have set up icons for the installed components as

described above, double click on the Help Project Editor.

2. Once the Project Editor is up choose 'Project...' from the Edit menu.

3. In the Project Dialog you can set the Title and Contents description

for your project, however it is most important that you '3.1' as your

help version, without this et properly the WHAT6 template will not be

used.  Select OK when done.

4. Choose 'Add New or Existing File...' from the Edit menu.

5. When the dialog appears type in a new file name with .RTF extension.

Select OK.

6. If a dialog appears with the following message:

        "<filename>.RTF does not exist. Create it, based on WHAT30.DOT?"

select Cancel. Return to step 2. The project editor has not been set up

properly. Make sure that you have selected '3.1' as the help version.

If a dialog appears with the following message:

        "<filename>.RTF does not exist. Create it, based on WHAT6.DOT?"

Then everything is OK. Select OK to continue. The file will then be

added to the project list.

7. Select the file in the project list and then choose 'Edit File' from

the Edit Menu. This will load WinWord6 if not already loaded and open

your file using the WHAT6 template.

8. For further instruction on how to use the Help Project Editor or the

WHAT6 template, please see the on-line help file provided for each of

these tools. These files can be accessed through the Help menu while in

either of these tools.

Multiple Resolution Graphics

----------------------------

In addition to the .DOT and .HLP files, the self-extracting file also

contains tools (SHED.EXE and MRBC.EXE) to help you compile multi-

resolution bitmaps (MRBMs) into your help file. You can use these tools

to make your graphics look good on monitors of various resolutions.

To create MRBMs, first take screen dumps of your graphic in each of the

resolutions you need (EGA, VGA, and 8514). Then create three separate

.SHG files using SHED.EXE (hotspot editor). Even if you don't have

hotspots in your graphic, create the separate *.SHG files. Then combine

the three .SHG graphics into one .MRB using MRBC.EXE.

When making this kind of file, you should make sure to archive the

original .BMP and .SHG files, in case you need to modify anything later.

It is useful to use SHED even if you're not putting hotspots in the

graphic. SHED interprets graphics the same way WINHELP.EXE does. You

can be reasonably sure that once the graphics are saved in SHED, they will

look good in your Help file.


Window manipulation

LUOKKA: API

Date: 02-09-95    Time: 02:13a     Number: 9

     From: n_varac@pavo.concordia.ca     Refer:

  Subject: Code Snippet: hInst->hWnd         0: comp.lang.ba   Status: Public

Since I want this code snippet thing to gain some momentum, here is another

snippet which a lot may find useful. It basically does two things.

1) Converts a hInstance (returned from Shell, ShellExecute, or WinExec)

   to a hWnd, which is what most windows api calls need when manipulating

   a window.

2) Moves the window to a specified location on screen.

The code could be improved by a) returning a value to indicate the window

was not found. b) checking the height and width values for validity...

c) checking that x & y don't specify coord's off screen (although this is a

great workaround for launching the app hidden... guarenteed to annoy some

users...)

No guarentees, warranties, promises... etc...

NV

8<-----------------------------------------------------------------

' In the general section of a module paste these functions and constants...

Declare Function GetParent% Lib "User" (ByVal hWnd%)

Declare Function GetWindow% Lib "User" (ByVal hWnd%, ByVal wCmd%)

    Global Const GW_HWNDFIRST = 0

    Global Const GW_HWNDNEXT = 2

Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal

nIndex%)

    Global Const GWW_HINSTANCE = (-6)

    Global Const GCW_HMODULE = (-16)

Declare Sub SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal

hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal

cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)

    Global Const SWP_NOSIZE = &H1

    Global Const SWP_NOMOVE = &H2

    Global Const SWP_NOZORDER = &H4

    Global Const SWP_NOACTIVATE = &H10

    Global Const SWP_SHOWWINDOW = &H40

Sub MoveApp (ByVal hInst%, ByVal X%, ByVal Y%, ByVal nWidth%, ByVal

nHeight%)

    Dim hWndParent%

    Dim hWndTemp%

    Dim result%

    Dim hWndCurrent%

    Dim hInstCurrent%

    ' Find a top level window (as opposed to a child window

    ' You could also use the GetDeskTopWindow function here...

    ' also, use your own formname here instead of me, if you want

    hWndTemp% = Me.hWnd

    hWndParent% = GetParent(hWndTemp%)

    ' A result of 0 means that our current hWnd is that of a top level window

    While hWndParent% <> NONE

hWndTemp% = hWndParent%

hWndParent% = GetParent(hWndTemp%)

    Wend

    hWndParent% = hWndTemp%

    ' Get the first window in the window order.

    hWndCurrent% = GetWindow(hWndParent%, GW_HWNDFIRST)

   ' Break when the current hWnd is 0 (end of windows)

    ' Or when we have found our window.

    While hWndCurrent% <> 0 And hInstCurrent% <> hInst%

        ' Find the hInstance of the current Window

hInstCurrent% = GetWindowWord(hWndCurrent%,

GWW_HINSTANCE)

' If it is a match then move the window

If hInstCurrent% = hInst% Then

    Call SetWindowPos(hWndCurrent%, NONE, X%, Y%, nWidth%,

nHeight%,

                     SWP_NOZORDER OrSWP_SHOWWINDOW)

    Exit Sub

End If

' Set the hWnd variable to point to the next window

hWndCurrent% = GetWindow(hWndCurrent%, GW_HWNDNEXT)

    Wend

End Sub


Window resources

LUOKKA: VBgen

Date:         Tue, 30 Aug 1994 11:36:21 +0930

From:         Prime Rat <shelps@ACHE.MAD.ADELAIDE.EDU.AU>

Subject:      VB and windows resources  XE "VB and windows resources"

>VB slowly eats away at my windows resources until after about 1-2 hours of

>work, I have like 20% of my resources left and windows crashes. It only

>happens while testing applications during development, not while running

>the executable.

>Has anyone else had this problem and is there a reason why VB does not

>release100% of the resources that it initially ties up? We've had this problem

>on more than one PC with 16mb of memory.

Try putting MaxBPs (maximum breakpoints) in your SYSTEM.INI file

[386Enh]

MaxBPs=768


Windows directory

LUOKKA: API

Date: 06/10/94 (11:19)              Number: 8560 of 8618 (Refer# NONE)

From: ZBEM04@CAL.AMOCO.COM

Subj: Re: HELP: GetWindowsDirectory(...)

Read: (N/A)                         Status: PUBLIC MESSAGE

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

*make sure the declare below is all on one line...

Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As

String,  ByVal nSize As Integer) As Integer

'--------------------------------------------------

' Calls the windows API to get the windows directory

'--------------------------------------------------

Function GetWindowsDir () As String

    temp$ = String$(145, 0)              ' Size Buffer

    x = GetWindowsDirectory(temp$, 145)  ' Make API Call

    temp$ = Left$(temp$, x)              ' Trim Buffer

    If Right$(temp$, 1) <> " " Then      ' Add   if necessary

        GetWindowsDir$ = temp$ + " "

    Else

        GetWindowsDir$ = temp$

    End If

End Function

'the call to get the windows dir

WinDir$ = UCase$(GetWindowsDir$())


Windows directory

LUOKKA: API

Date: 09/19/94 (19:09)              Number: 20009 of 20037 (Refer# NONE)

From: BMURRAY@PLUTO.NJCC.COM

Subj: Re: Finding the PATH of W

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Declare Function GetSystemDirectory% Lib "Kernel" (ByVal lpBuffer$, ByVal

nSize%)

Declare Function GetWindowsDirectory% Lib "Kernel" (ByVal lpBuffer$, ByVal

nSize%)

Function WindowsDirectory$ ()

'Returns the Windows directory

Static intSize%, intRes%

Static strTemp As String * 144

    intSize = 144

    intRes = GetWindowsDirectory(strTemp, 144)

    WindowsDirectory = Left$(strTemp, intRes)

End Function

Function SystemDirectory$ ()

'Returns the Windows system directory

Static intSize%, intRes%

Static strTemp As String * 144

    intSize = 144

    intRes = GetSystemDirectory(strTemp, 144)

    SystemDirectory = Left$(strTemp, intRes)

End Function

__________

                           Bradley S. Murray


WinHelp

LUOKKA: WinHelp

Date: 06/22/94 (11:50)              Number: 9840 of 9875 (Refer# NONE)

 From: MICHAEL.RUBIN@PCGFX.COM

Subj: Help in WinHelp API

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

On 06-20-94 KCCHEN@ERIS.CS.UMB.EDU  wrote:

K>I'd like to display certain help information by using the WinHelp API

K>and help ID. Here is my codes

K>Global Const HELP_CONTEXT = &h1

K>   nTemp% = WinHelp( Form1.hWnd, "help.hlp", HELP_CONTEXT, 24 )

Your problem is most likely because the WinHelp function expects a Long

Integer for the pointer to the topic.  You might try it this way (a

typesafe alias for the WinHelp function):

Declare Function WinHelpBynum% Lib "User" Alias "WinHelp" (ByVal --->

  <--- hWnd%, ByVal lpHelpFile$, ByVal wCommand%, ByVal dwData&)

response% = 6 Then temp% = WinHelpBynum%(Form1.hWnd, "help.hlp", --->

  <--- HELP_CONTEXT, CLng(24))

------------------------------------------------------

Michael Rubin   Internet: michael.rubin@pcgfx.com

                          m_rubin@tatertot.com


WinHelp

LUOKKA: WinHelp

Calling WINHELP

-----------------------

Listed below are keywords used by WINHELP and an example on how to use

it.

'Help engine declarations.

'Commands to pass WinHelp()

Global Const HELP_CONTEXT = &H1 ' Display topic identified by number in

Data

Global Const HELP_QUIT = &H2 ' Terminate help

Global Const HELP_INDEX = &H3 ' Display index

Global Const HELP_HELPONHELP = &H4 ' Display help on using help

Global Const HELP_SETINDEX = &H5 ' Set an alternate Index for help file

with   more than one index

Global Const HELP_KEY = &H101 ' Display topic for keyword in Data

Global Const HELP_COMMAND = &H102 ' Execute Help macro

Global Const HELP_MULTIKEY = &H201  ' Lookup keyword in alternate table

  and display topic

Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal

lpHelpFile   As String, ByVal wCommand As Integer, dwData As Any) As

Integer

Type MULTIKEYHELP

mkSize As Integer

mkKeylist As String * 1

szKeyphrase As String * 253

End Type

Case 2 ' Help Search Command

HelpCmd = HELP_COMMAND ' Set help command to bring up

                       search box

curFile = App.HelpFile

curData = "Search()" ' Data is macro to be executed by WinHelp

' To make this work, we need to do two help commands in succession, so

we'll do one here and one down below. The commented line 2nd below is the

command to be executed to bring up the search dialog.

result = WinHelp(hWnd, curFile, HELP_INDEX, 0&)

result = WinHelp(hWnd, curFile, HELP_COMMAND, ByVal "Search()")

Submitted By: Gary Ferguson


WinHelp 4.0

LUOKKA: WinHelp

6134 (2+)  stefan@olson.manawatu.gen.nz  28.06.95  11:20

Stefan Olson: "Re: WinHelp 4.0 Features"

From the HWA 2.0 help file section on creating WinHelp 4.0 files

(based on Microsoft information):

WinHelp 4.0 includes many new features for the end user and many new

features for the help author!

New features include:

Secondary Windows

+	multiple windows (up to 9)

+	button bar (optional)

+	auto-size height (optional)

Graphics

+	any number of colors (mono, 16, 256, etc.)

+	16 color with optimized palette

+	16 color with transparent background

Contents File

+	Contents Tab providing table-of-contents like navigation

+	Combined Index from multiple help files

Full-text search (indexing provided by WinHelp -- i.e., it works on existing

help files)

Topic items

+	Support for multimedia files (.AVI, .WAV, .MIDI)

+	Authorable buttons (create and place a real button anywhere in

your text).

Macros

+	20+ new macros (not including the ones we documented this time

<g>)

+	Can run macros when a user selects author-defined keywords from

the index

Associative link (associates a jump to multiple topics resolved at runtime

based on what help files are actually installed/available at the time of the

jump) Window footnote specifying what window to display a topic in

Almost all the limits have been dramatically increased:

Other improvements

In addition both Windows 95 and NT 3.51 have made changes to the

operating system to make it much easier to provide help for individual

controls in a dialog box. The user can click a question mark on the

title bar and then the control, or right click the control and click the "What's

this?" menu command, or just press F1.

The compiler is now windows-based, runs 3-10 times faster, generates smaller

help files, provides testing functionality, and talks to WinHelp so you can find

out what's going on in your help file while its running.

------------------------------------------------------------------------

   Stefan Olson               Internet Mail: stefan@olson.manawatu.gen.nz

   Olson Software                Compuserve: 100352,1315

   Ask about Help Writer's Assistant for Windows - the visual

   and easy way to *edit* Windows Help files.

   (ftp://gmutant.wrlc.org/pub/incoming/hwa20.zip)

   Also ask about the Olson Software Help Tools (OSHTLS13.ZIP) - buttons,

   256 color bitmaps, button bars in secondary windows and much more!

------------------------------------------------------------------------


WinHelp 4.0

LUOKKA: WinHelp

25585 (89+)  stu@cuyahoga.demon.co.uk  16.07.95  01:00

Stu Churchill: "Re: VB KB Full Text"

In article: <805829049snz@tsys.demon.co.uk>  Tom Wheeley

<tomw@tsys.demon.co.uk> writes:

>However, IF you are running Win95, you only need get the standard

>version, as the Win95 Help engine is able to create it's own "full text

>search" index. To give you an idea of the potential savings on file size,

>take a look at this dir list; vb_bugs.fts    375296   3/05/95  21:50  **

>Created by Win95 Help engine vb_bugs.hlp    308966  20/04/95  13:16  ##

>Downloaded from ftp.microsoft.com vb_tips.fts   1448448   3/05/95  21:54

>** Created by Win95 Help engine vb_tips.hlp   1560283  20/04/95  13:10

>## Downloaded from ftp.microsoft.com. Yes, but wouldn't this imply the

>indexing isn't as good perhaps? Unless it's a whole new format of course.

It's found everything I've looked for ... so far :)

The Win 95 Help engine creates two types of indexes, one by default, the

other at your request. The former is simply an index of every single topic, and

is the default index presented to you when clicking on the "Search" button.

The full text index is created via a Wizard, and can be a basic full text index,

or can also be made to include "phrases" (i.e. you could tell it to specifically

look for "Novell Netware" in it's entirity, rather than as two seperate words).

As an example, searching for "EW_RESTARTWINDOWS" resulted in 2 topics

being found, searching for "DDE" gave me a choice of 53 topics.


WinHelp 4.0

LUOKKA: WinHelp

6452 (18+)  hhlk@tiac.net  19.07.95  05:55

HHLK: "Re: Windows95 help files, how to write/compile?"

Windows 95 comes with its own WinHelp 4.0 Help Compiler.  The file name is

HWC.EXE and it is currently included on the Windows 95 Beta CD.

Windows 95 help has a new look that uses a .CNT file, which organizes the

help into book icons.  Before you dive into developing Windows 95 help

system, take a look at the help for the Windows 95 operating system.  You

should be impressed.  It is very clean and has training cards.  I am

currently developing a large help system for a client and I am following

the style of the Win 95 help system.

One limitation - there is currently no hard copy documentation (only

online, which is part of HCW.EXE) for Win 95 help except a new book from

Blue Sky software.  I ended up printing my online version, which took me

about four hours.  But it was worth it.  There are some fantastic macros to

take advantage of that I never knew about.


WinHelp bullets W6

LUOKKA: WinHelp

5942 (30+)  erik@and.nl  19.06.95  12:24

Erik Buitenhuis: "Re: Bullet lists."

In article <3rql6c$d3l@nitrogen.mankato.msus.edu>

fishhead@krypton.mankato.msus.edu

(David D Rand) writes:

>Erik Buitenhuis (erik@and.nl) wrote:

>

>: I have a problem creating bullet lists and numbered lists in a help file.

>

>: I am using MS-Word 6.0 for editing a rtf file.

>: In MS-Word my bulletlists are displayed correctly. When I compile the file

>: (hc31.exe) the resulting help file displays some lists with the first item

>: correctly indented and the other items _not_ indented (bullets at the edge

>: of the window). I can see no differences in MS-Word between a correctly

>: and an not-correctly displayed list, even if I display everything possible

>: (hidden text, tabs, etc.)..

>

>The help compiler needs the tabs to be reset for each line.

>Word only saves tab and indent codes to the RTF file when a line is

>different than the preceeding line.

>

>Place a tab at 0" for EVERY OTHER line in your list.

>

>Example:

>

>..L...L..1.........2.........3.........4.........5.........6.........7

>  o   This is line one.

>

>

>L.L...L..1.........2.........3.........4.........5.........6.........7

>  o   This is line two. Notice the tabs at 0", .2", and .7".

>

>

>..L...L..1.........2.........3.........4.........5.........6.........7

>  o   This is line three.


WinHelp embedded wnds

LUOKKA: WinHelp

5621 (5+)  Ed_Guy@mindlink.net  30.05.95  22:36

Ed Guy: "Re: Embedded windows and DLL's in Winhelp"

>jason (jasonw@org.au) wrote:

>Does anyone know where are docs on the Embedded Window functionality

>in Winhelp. I am trying to write a DLL to work with winhelp and display

>a custom window - but I can't find anywhere - exactly how to do it?

>I know a file on America Online, EMBWW.ZIP but that doesn't help you -

>anyone know if this is on FTP?

EWDLL.DLL is available through the auspices of the Free Software

Foundation. The DLL may be obtained from many sources including

Compuserve (GO WINSDK, Section 16 library) and the Internet (including

ftp.harding.edu in the directory /pub/pacheco).


WinHelp general

LUOKKA: WinHelp

Date: 11/30/94 (01:52)              Number: 140025 of 140258 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Intergrating Helpfile...

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

The following code sample is my "HELPAPI.BAS", callable from forms that

use help.  Remember to set up your HelpContextID's in all your Visual

Basic controls.  Hope this helps :-)

' help system API

' code from "Inside Visual Basic for Windows" Jan. 1994 Vol.4 No.1

'

' Usage -> Form_Load ()

'              App.HelpFile = App.Path + "<>.hlp"

'         Form_Unload ()

'              HelpQuit

'         HContents_Click()

'              Help 0

'         HSearch_Click()

'              HelpSearch

Declare Function WinHelp Lib "User" (ByVal hWind As Integer, ByVal

HelpFile$, ByVal wCommand As Integer, ByVal dwData As Any) As Integer

'Help Constants from Constants.txt

' Global Const HELP_CONTEXT = &H1           'Display topic in ulTopic

' Global Const HELP_QUIT = &H2              'Terminate help

' Global Const HELP_INDEX = &H3             'Display index

' Global Const HELP_CONTENTS = &H3

' Global Const HELP_HELPONHELP = &H4        'Display help on using help

' Global Const HELP_SETINDEX = &H5 'Set the current Index for multi index

                                                                      help

' Global Const HELP_SETCONTENTS = &H5

' Global Const HELP_CONTEXTPOPUP = &H8

' Global Const HELP_FORCEFILE = &H9

' Global Const HELP_KEY = &H101        'Display topic for keyword in

offabData

' Global Const HELP_COMMAND = &H102

' Global Const HELP_PARTIALKEY = &H105  'call the search engine in

winhelp

Sub Help (Context As Long)

    HelpGet HELP_CONTEXT, Context

End Sub

Sub HelpForceFile ()

' This will make sure correct help file is displayed and

' will also make the first seek find the currect topic

x% = WinHelp(Screen.ActiveForm.hWnd, App.HelpFile, HELP_FORCEFILE, "

")

DoEvents

End Sub

Sub HelpGet (Cmd As Integer, Context As Long)

    Screen.MousePointer = 11

    HelpForceFile

    ' Display context sensitive help

    x% = WinHelp(Screen.ActiveForm.hWnd, App.HelpFile, Cmd, ByVal

Context)

    Screen.MousePointer = 0

End Sub

Sub HelpKey (Context As String)

    HelpForceFile

    x% = WinHelp(Screen.ActiveForm.hWnd, App.HelpFile, HELP_KEY, ByVal

Context)

End Sub

Sub HelpQuit ()

    x% = WinHelp(Screen.ActiveForm.hWnd, App.HelpFile, HELP_QUIT, " ")

End Sub

Sub HelpSearch ()

    HelpGet HELP_PARTIALKEY, 0

End Sub

== Gregory J. Patterson

== Director of Information Systems Design  Phone: 412-237-3165

== Community College of Allegheny County   Fax  : 412-237-3091

== 800 Allegheny Ave.

== Pittsburgh, Pennsylvania  15233 USA

==                Internet:  gpatters@ccac.edu


WinHelp nonscr.paragr

LUOKKA: WinHelp

6450 (20+)  jcarroll@pcug.org.au  19.07.95  02:31

John Carroll: "Re: Winding me up!"

u2i06@teach.cs.keele.ac.uk (Yasin Poptani) wrote:

>This niggling problem has been winding me up for quite a while, the

>error is barely covered in the help compiler help file;

>Warning 4792: topic...1 of QURAN.RTF : Non-scrolling region defined

>after scrolling region.

>This has not produced any real problems on the final product (I don't

>think so anyway), but I get about 35 of these errors when compiling.

>I am using Word for Windows 6, to produce my RTF file, and using HCP505

>to compile the beast.

Look for a paragraph marker which is formatted as hidden text - change

it to 'not hidden'.

_

John Carroll                           GPO Box 3123

jcarroll@pcug.org.au            Canberra ACT 2601 Australia


WinHelp partial key

LUOKKA: WinHelp

Date: 10/22/94 (15:13)              Number: 24050 of 24188 (Refer# NONE)

From: RMCNEE@HOASYS.ISD1.TAFENSW.EDU.AU

Subj: Answer: Help/ContextId WinHelp

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

How to get context sensitive help using the WinHelp function.

No-one has yet provided any answers and it was assumed impossible.

The trick I finally discovered thanks to reading someones msg re: partial key

help is this...

Instead of

 Function Declaration

 Init Variables etc

 Ret% = WinHelp(Form1.hWnd, HelpFile$, HELP_CONTEXT, dwdata%)

Do

 Function Declaration

 Init Variables etc

 Ret% = WinHelp(Form1.hWnd, HelpFile$, HELP_CONTEXT, ByVal dwdata%)

---------------

I noticed even within Vb knowledge base article for the Partial Key

(Search Help Dialog) they are passing a blank string _not_ ByVal - as such

you get small amount of crap (1 char) in search for entryfield. If you copy

thier code and use ByVal then it is also cleaner.

rmcnee@tafensw.edu.au


WinHelp resources

LUOKKA: WinHelp

6241 (2+)  tomh@metrics.com  03.07.95  07:01

Tom Haapanen: "Windows Programmer FAQ: How to get it"

Archive-name: ms-windows/faqprg.how-to

Last-modified: 1995-07-02

Related-archives: ms-windows/faqprg.asc,ms-windows/faqprg.zip

Last-FAQ-Update: Mar 24 1994

This is a regularly scheduled weekly posting, which explains how you can

obtain a copy of the Microsoft Windows Programmer FAQ (Frequently Asked

Questions) list.  The Windows Programmer FAQ is an extensive compilation of

Windows software development facts, tips, techniques, and other useful

information.  The FAQ is about 5800 lines long (in ASCII format) or 140K (as

a ZIP archive of a Windows Help file).

The Windows NT FAQ, authored by Adam Hamilton, is currently only

available

in ASCII format.

There are two separate Windows 95 FAQs; here are their locations:

http://www.whidbey.net/~mdixon/win40001.htm

http://www.primenet.com/~markd

All updates to the Windows FAQ and Windows Programmer FAQs are posted

to the

The Microsoft Foundation Class (MFC) FAQ is available as:

http://www.unx.com/~scot/mfc_faq.html

ftp://www.unx.com/pub/mfc_faq

All updates to the Windows FAQ and Windows Programmer FAQs are posted

to the

following two newsgroups:

comp.binaries.ms-windows	WinHelp format

comp.os.ms-windows.announce	ASCII text format

The updates are usually 2-3 months apart, depending on the amount of new

information and the maintainer's workload.

You can also FTP the FAQs from the following sites:

ftp://ftp.nimh.nih.gov/pub/win3/FAQ/

ftp://wuarchive.wustl.edu/usenet/comp.binaries.ms-windows/faqs/

ftp://ftp.metrics.com/faq/

The FAQs will have filenames in the format of FAQWINxx.ZIP (Windows),

FAQPRGxx.zip (Windows Programmer), and FAQWNTxx.zip where xx is the

version

number.  Please do not abuse these sites; limit your FTP activity to time

outside business hours (8 PM EST through 9 AM EST, or 0100 GMT through

1400

GMT).

If you wish to retrieve the FAQs using Gopher, you can locate them at

gopher.nimh.nih.gov.

Another highly useful programming FAQ (created by David Wihl), Porting from

Unix to Windows NT, is available on the web as

http://www.shore.net/~wihl/unix2nt.html

If the news postings have expired on your site, and you have no FTP access,

you can obtain it using the decwrl ftp mail server.  For instructions, send

a mail message to ftpmail@decwrl.dec.com with a body containing simply:

       help

You will receive a full set of instructions by return mail.

--

Ä /tom haapanen -- tomh@metrics.com -- software metrics inc -- waterloo, ont

Å

Ä "what a giftless bastard!"                  -- tchaikovsky on brahms, 1886 Å

6242 (1+)  tomh@metrics.com  03.07.95  07:01

Tom Haapanen: "INFO: A guide to the Windows newsgroups ÄFAQÅ"

Archive-name: ms-windows/newsgrp.guide

Last-modified: 1995-07-02

This is a regularly scheduled weekly posting, which explains the purpose

of the usenet newsgroups for Microsoft Windows.  Please follow these

guidelines when posting your articles, and make life easier for all of

us.

NOTE: Binary files (whether programs, bitmaps or others) are not to be

      posted to any of the groups listed below, with the exception of

      comp.binaries.ms-windows.

These are the current Windows newsgroups:

GENERAL:

    comp.os.ms-windows.advocacy   Comparisons and arguments about

Windows &

                                  Windows NT vs. other operating systems

    comp.os.ms-windows.announce   MODERATED.  Announcements and

news about

                                  Windows applications, drivers, events etc.

    comp.os.ms-windows.setup      Questions and problems with setting up

                                  and configuring Windows.

    comp.os.ms-windows.video      Video display cards, drivers and monitors

                                  for use with Windows

    comp.os.ms-windows.misc       All other Windows discussions except

                                  advocacy with other operating systems.

APPLICATIONS:

    comp.os.ms-windows.apps.comm       Communications and fax applications

    comp.os.ms-windows.apps.financial  Financial applications

    comp.os.ms-windows.apps.utilities  Utilities, desktops and accessories

    comp.os.ms-windows.apps.word-proc  Word processing and desktop

publishing

    comp.os.ms-windows.apps.misc       Miscellaneous Windows & NT

applications

    comp.os.ms-windows.apps            ÄSuperceded by apps.miscÅ

NETWORKING:

    comp.os.ms-windows.networking.tcp-ip  TCP/IP-based networking for

                                          Windows, includign NFS and apps

    comp.os.ms-windows.networking.windows Windows' native networking:

WFWG,

                                          NT, NTAS and LAN Manager

    comp.os.ms-windows.networking.misc    All other networks, such as

Netware,

                                          Banyan Vines and LANtastic

WINDOWS NT:

    comp.os.ms-windows.nt.setup   Setting up and configuring Windows NT

and

                                  Windows NT Advanced Server

    comp.os.ms-windows.nt.misc    All other Windows NT-specific discussions

                                  except programming and advocacy

PROGRAMMING AND SOFTWARE DEVELOPMENT:

    comp.os.ms-windows.programmer.controls   Using controls, custom

controls,

                                             VBXs, OCXs and dialogs

    comp.os.ms-windows.programmer.drivers    Driver and  VxD development

for

                                             Windows 3.1, NT and Chicago

    comp.os.ms-windows.programmer.graphics   Graphics and GDI

programming in

                                             Windows

    comp.os.ms-windows.programmer.memory     Memory and process

management,

                                             threads and IPC in Windows

    comp.os.ms-windows.programmer.multimedia Development of multimedia

and

                                             video applications

    comp.os.ms-windows.programmer.networks   Network-specific application

                                             development for Windows

    comp.os.ms-windows.programmer.ole        Creating OLE, COM and

DDE-based

                                             applications

    comp.os.ms-windows.programmer.tools      Windows development tools,

class

                                             libraries and compilers

    comp.os.ms-windows.programmer.win32      Developing for the Win32 API

                                             (including NT and Win32s)

    comp.os.ms-windows.programmer.winhelp    Developing WinHelp and

Multimedia

                                             Viewer files and applications

    comp.os.ms-windows.programmer.misc       All other Windows programming

and

                                             development discussions

OTHER RELATED GROUPS:

    comp.lang.basic.visual        Visual Basic programming issues for both

                                  Windows and MS-DOS

    comp.apps.spreadsheets        Spreadsheets and related applications,

                                  including Excel, Quattro and 1-2-3.

    comp.os.msdos.mail-news       Administering mail and news software

                                  on Windows and MS-DOS.

    comp.binaries.ms-windows      MODERATED.  Shareware, freeware,

drivers and

                                  other binary files.

    comp.protocols.tcp-ip.ibmpc   Discussions about the use of TCP/IP on PC

                                  systems

    alt.winsock                   Applications and development for Winsock

                                  (TCP/IP)

    bit.listserv.win3-l           This newsgroup is a copy of the BITNET WIN3-L

                                  mailing list for all Windows discussions

NON-WINDOWS NEWSGROUPS: (Do not use for Windows-specific topics!)

    comp.lang.visual   Visual programming languages, *not* Visual Basic or

C++

    comp.lang.pascal.* The language itself; not appropriate for Windows

topics

    comp.lang.c        The language itself; not appropriate for Windows topics

    comp.lang.c++      The language itself; not appropriate for Windows topics

    comp.windows.news  For the NeWS windowing system

    comp.windows.misc  For other windowing systems, not Microsoft Windows

GENERAL GUIDELINES:

    Please try to post to the appropriate newsgroup, and try to avoid

    crossposting whenever possible. This makes it easier for everyone

    to find the information they are looking for without wading through

    irrelevant articles.

    Second, please do not get involved in arguments about Windows vs.

    OS/2 vs. Macintosh vs. NeXTSTEP *except* in the .advocacy group.

    Don't post any comparison or argument, and if someone else posts one

    -- don't post a followup! Ignore this flamebait, and help increase

    the signal-to-noise ratio of the newsgroups.

SUBSCRIBING AND UNSUBSCRIBING:

    To subscribe to a Usenet newsgroup, you can use the "gnewsgroupname"

    command at the newsgroup level in rn, trn and strn.  To unsubscribe,

    hit "u" while in that newsgroup, if you are using rn, trn or strn.

    To subscribe to a LISTSERV mailing list, send a mail message to the

    LISTSERV at the mailing list address (ie LISTSERV@uicvm.bitnet for the

    WINHLP-L@uicvm.bitnet list) containing just the text "SUBSCRIBE

listname"

    in the body.  To unsubscribe, send mail to that same LISTSERV with the

    body "UNSUBSCRIBE listname" or "SIGNOFF listname".

WINDOWS FAQS:

    The Windows FAQs are available by anonymous ftp from ftp.metrics.com

and

    other sites; see the companion posting "How to get ..." posted simulta-

    neously with this one for further details.

MICROSOFT FTP SITE:

    Microsoft also maintains an ftp site (ftp.microsoft.com) with drivers,

    patches and utilities on it for all of Microsoft's operating systems,

    including Windows, Windows for Workgroups and Windows NT.

MORE INFORMATION:

    If you have questions about these guidelines, you can email to Tom

    Haapanen (maintainer of the FAQ, tomh@metrics.com) or Sean Graham

    (moderator of the .announce group, sgraham@shiloh.nimh.nih.gov).

--

Ä /tom haapanen -- tomh@metrics.com -- software metrics inc -- waterloo, ont

Å

Ä "what a giftless bastard!"                  -- tchaikovsky on brahms, 1886 Å


WinHelp resources

LUOKKA: WinHelp

5695 (29+)  kittyba@netcom.com  05.06.95  21:08

The Kitty: "Internet Winhelp Resource List (6/5/95)"

Below is the latest release of the IWRL.  Please send changes to

dsmjb@aol.com.  Its also regularly posted to my ftp site listed at the end of

the message.   Mike

Internet WinHelp Resource List              Update: June 5, 1995

Researched & Published by Mike (dsmjb@aol.com)

Gopher

OAK Repository (WinHelp files)

   gopher.oakland.edu  Menus: OAK.oakland.edu, SimTel, win3, winhelp

World Wide Web (WWW)

OAK Repository (WinHelp files)

   http://www.acs.oakland.edu/oak/SimTel/win3/winhelp.html

WINHLP-L Mailing List Home Page (updated May 8, 1995)

   http://www.humberc.on.ca/~byrnes/winhelp.html

Word for Windows Files (inc. WinHelp aids)

   http://coyote.csusm.edu/cwis/winworld/word.html

Olson Software (Help Writers Assistant, WinHelp DLLs, etc)

   http://www.actrix.gen.nz/commercial/olson/olson.html

   e-mail stephen@olson.manawatu.gen.nz

Altura Software (WinHelp/MV to MAC programs)

   http://www.altura.com/jordanz/home.html

   e-mail quickhelp@altura.com or altura@aol.com

KNOWware (Help Authoring Resource Page & pointers to others)

   http://www.metainfo.com/knowware/ or http://204.29.28.2/knowware/

   e-mail marymd@halcyon.com

Lamaura Development (SOS Help! Info Author tool & links to Winhelp

sources)

   http://www.lamaura.com/~lamaura

   e-mail pdelisle@lamaura.com

HyperAct (HLPDK/PA, Interactive Help, Cat5Make developer)

   http://www.hyperact.com

   e-mail rloewy@panix.com

Cascadilla Press (Help Browser)

   http://www.shore.net/~cascadil/HelpBrowser.html

   e-mail info@cascadilla.com

Microsoft Article on Winhelp 4.0

   http://www.microsoft.com/pages/developer/msdn/

     OFFRAMP/NEWS/FEATURES/WINHELP3.HTM (type all on 1 line)

Bristol Help (Hyperhelp & Forehelp for Unix)

   http://www.bristol.com/

   e-mail amy@bristol.com

Anonymous File Transfer Protocol (FTP) Site Information

Site:      ftp.microsoft.com   Ä198.105.232.1Å

Operator:  Microsoft Corporation, Redmond, Washington USA

Available: WHAT6 templates, HC Version 3.10.505, Knowledge Base

Directory: Softlib/MSLFILES (don't do a ls or dir in this directory)

Files:     WHAT6.EXE, HC505.EXE

Directory: developr/MSJ

Files:     Microsoft Journal Articles

Directory: developr/drg/Multimedia/RTFMOD

Files:     RTFMOD.ZIP  (fixes quote/bullet RTF problems Word 6)

Directory: KBHelp

Files:     Fully searchable help files on apps, etc

Uploading: No

Comments:  Don't expect much help - what's here is usually at your

           own risk.

Site:      ftp.cica.indiana.edu  Ä129.79.26.27Å

Operator:  Center for Innovative Computer Applications

           Indiana University, Bloomington, Indiana USA

           E-mail: ftp@cica.indiana.edu (automated)

                   ftp-admin@cica.indiana.edu

Available: Many WinHelp Utilities

Directory: /pub/pc/win3/util

Files:     HLPDK40.ZIP, HELPED19.ZIP, VH.ZIP

Directory: /pub/pc/win3/misc

Files:     HC505.ZIP (Help compiler version 3.10.505)

Directory: /pub/pc/win3/programr

Files:     WHAT.ZIP      (Windows Help Authoring Templates)

           WINAPI3.ZIP   (Paul Arnote's API tips - EXCELLENT)

Uploading: Yes (/pub/pc/win3/uploading)

Comments:  This is THE site for Windows software

           Usually VERY busy (cap. 45 sessions day, 75 at night)

           Mirror sites listed below

 ** USA Sites:   wuarchive.wustl.edu (MO); archive.orst.edu (OR);

    gatekeeper.dec.com; ftp.cdrom.com (CA);  ftp.marcam.com;

    mrcnext.cso.uiuc.edu (IL); ftp.dataplex.net Äor 199.183.109.245Å (TX);

    mirrors.aol.com Ä198.81.1.25Å (VA); ftp.pht.com Ä198.60.59.5Å (UT)

 ** Non-USA Sites:  ftp.monash.edu.au (Australia); ftp.funet.fi (Finland);

    ftp.uni-paderborn.de, ftp.uni-stuttgart.de, ftp.uni-koeln.de, and

    ftp.uni-regensburg.de (Germany); ftp.iij.ad.jp (Tokyo); ftp.nectec.or.th

    (Thailand); ftp.technion.ac.il (Israel); nic.switch.ch (Zurich);

    src.doc.ic.ac.uk (London); ntuix.ntu.ac.sg (Singapore); nctuccca.edu.tw

    (Taiwan); ftp.cyf-kr.edu.pl (Cracow, Poland); cuinfo.netserv.chula.ac.th

    (Bankok, Thailand) and info.nic.surfnet.nl (Netherlands);

    ftp.puc-rio.br (Brazil); ftp.cau.ac.kr (Seoul, South Korea);

    ftp.hk.super.net (Hong Kong SuperNet); ftp.unipd.it (Padova, Italy).

Site:      gmutant.wrlc.org  Ä198.91.36.126Å

Operator:  Library Systems Office of Fenwick Library

           (with grant from GMUtant Software)

Available: WinHelp Utilities

Directory: /pub/winhelp

Files: (as of 4/10/95)

  1415263 Oct 12  1994 ForeHelp104.zip

   207400 Sep  6  1994 apps.zip

   368972 Apr  5  1994 drhelpe5.zip

  1366320 Apr  6 17:12 ew256bmp.zip  256 col BMPs, multiple printing DLL

    57156 Nov 30 13:16 fbla1094.zip

    67185 Jul 14  1994 glossary.zip

   922248 Apr  4 13:44 ha40a.exe

  1052581 Apr  4 13:44 ha40b.exe

   269018 Feb 19 16:46 hactcat.zip

   123000 Jan 27 07:11 hbdemo.zip

   228685 Mar 31  1994 hc505.exe     Latest version MS Help Compiler

   290263 Apr 12  1994 helllpe.exe

   214916 Apr  5  1994 helped.zip

   101777 Apr  5  1994 helpinfo.zip

     9554 Nov 13 01:44 helpmon.zip

    13576 Nov 15 23:18 helpmon2.zip

   370003 Oct 14 14:08 hhelp10.zip

    21122 Apr  6  1994 hlpcol.zip

    45110 Aug  5  1994 hlpdc137.zip

   351952 Apr  5  1994 hlpdk80.zip

   264367 Apr  6  1994 hyptrk40.zip

   289584 Apr  6 17:11 mhplus32.zip  MiniHelp+ V3.2 Help Author Tool

    12131 Oct 14 14:10 msa2rtf.zip

   546457 Dec 23 04:29 oshtls11.zip

     4818 Jul 14  1994 patch6.txt

   153325 Apr 12  1994 qdhelp31.zip

    29518 Mar 31  1994 rtfgen10.zip

   126870 Mar 31  1994 rtfgen20.zip

    89501 Mar 31  1994 rtfspec.doc   RTF Specification Document

    44070 Oct 23 15:53 shed-w-r.zip

   138440 Oct  4  1994 showbmp.zip

   382299 Mar 28 21:24 sl1013.zip

   172511 Feb 20 20:14 srchald.zip

    20863 Apr  5  1994 toc.zip

    70812 Apr 15  1994 topicdmp.zip

   125060 Oct  6  1994 vbaha124.zip

   575972 Dec 14 07:19 vishelp.exe

   551900 Apr  6  1994 whag_doc.zip  WinHelp Authoring Guide Word fmt

   556421 Mar 31  1994 whag_hlp.zip  WinHelp Authoring Guide HLP format

  1308637 Apr  5  1994 what.zip      MS WHAT authoring tool/templates

   954096 Apr  5  1994 what6.exe     MS WHAT authoring version 6

   194600 Apr  6  1994 whdemo.zip

    43213 Oct 14 14:04 whfaq.hlp     Windows Help FAQ (somewhat dated)

  1239856 Feb 14 19:18 whndb2a.zip   Database of comp.os..winhelp pt. 1

  1048868 Feb 14 19:19 whndb2b.zip   Part 2

   923996 Feb 14 19:20 whndb2c.zip   Part 3

    15600 Apr 15  1994 whstruct.doc

   533370 Apr  6 17:13 winapi3.zip   Help file with system DLL tricks

    41723 Oct 14 14:04 winhelp.faq

Uploading: Yes (/pub/incoming)

Comments:  Lots of stuff here for WinHelpers

           Directory read problem now fixed

Site:      oak.oakland.edu

Operator:  OAK Repository, Oakland University, Rochester, Michigan USA

           w8sdz@SimTel.Coast.net or w8sdz@vela.acs.oakland.edu

Available: WinHelp Files

Directory: /SimTel/win3/winhelp

Files:

 Filename  Type Length  Date  Description

=============================================

00_index.txt A    1677 950326 This list of files

dynahlp.zip  B 2024775 950307 Dynamic Text/Graphic/Video in WinHelp

demo

gatt_1.zip   B  399742 940706 Text of GATT agreement as WinHelp

Guidebook

hag.zip      B  557117 931116 Windows Help Authoring System (WinHelp

vers.)

hbdemo.zip   B  123000 950127 Adds full text search and map to help files

hm423.zip    B   71924 950322 HelpMaker: WinHelp authoring aid for Ami Pro

hpgn12.zip   B  193460 940909 HelpGen Windows Help File Generator, v1.20

hyptrk41.zip B  255607 940504 WIN3: Makes WinHelp files w/tracking/word

srch

rc2hdk30.zip B   39358 940502 Create Help Template from RC definition files

review.zip   B  154651 941224 Help file review demo, using Interactive Help

smtdoc15.zip B   47988 950324 SmartDoc: Print/extract txt from WinHelp

files

vbaha124.zip B  125060 940420 Easily create Windows 3.x help files

wh_ed100.zip B   14887 941229 Edits WINHELP file windows' size and

colors

whag-toc.zip B   13183 931115 Table of Contents for MS Help Authoring

Guide

whag.zip     B  484014 931116 Windows Help Authoring System (.DOC

version)

whndb2a.zip  B 1239856 950214 comp.os.ms-windows.programmer.winhelp

dB, 1/3

whndb2b.zip  B 1048868 950214 comp.os.ms-windows.programmer.winhelp

dB, 2/3

whndb2c.zip  B  923996 950214 comp.os.ms-windows.programmer.winhelp

dB, 3/3

Uploading: Unknown - incoming directory is write protected for anon ftp

Comments:  Primary mirror for SimTel software repository

           Mirror sites are:

  wuarchive.wust1.edu   directory /systems/ibmpc/simtel/win3/winhlp

  archive.orst.edu      directory /pub/mirrors/simtel/win3/winhlp

  micros.hensa.ac.uk    directory /mirrors/simtel/win3/winhlp

  nic.funet.fi          /pub/mirrors/oak.oakland.edu/Simtel/win3/winhlp

  ftp.sunet.se          directory /pub/pc/mirror/SimTel/win3/winhelp

Site:      192.75.71.35

Operator:  Humber College, Ontario, Canada

Available: WinHelp Utilities

Directory: /winhlp

Files:

  236422   Apr 01 15:14    ewdll011.zip

  195056   Mar 29 13:33    whdemo.zip

   20863   Mar 29 13:36    toc.zip

  551900   Apr 04 13:12    whag.zip

  604467   Apr 04 13:12    hag.zip

  228685   Apr 04 13:12    hc505.exe

   11786   Apr 05 07:19    helpful.zip

   21122   Apr 05 07:19    hlpcol.zip

  101777   Apr 05 07:19    helpinfo.zip

  368972   Apr 05 07:19    drhelpe5.zip

  264367   Apr 05 07:19    hyptrk40.zip

 1308637   Apr 04 13:11    what.zip

  954096   Apr 05 07:19    what6.exe

   27607   Apr 15 06:28    dwhat.zip

   81441   Apr 07 07:33    qdhelp.zip

   16997   Apr 07 07:33    qdtool.zip

  329579   Apr 07 07:33    hdk110l.zip

  250510   Apr 07 07:33    hdk110b.zip

  295005   Apr 07 07:33    hdk110a.zip

   13183   Apr 07 07:33    whag-toc.zip

  351952   Apr 07 07:33    hlpdk80.zip

  214916   Apr 07 07:33    helped.zip

   36419   Apr 07 07:33    help30.exe

  200817   Apr 15 06:28    hwab330.zip

  290941   Apr 15 06:28    xantippe.zip

Uploading: No (they get files from gmutant site)

Comments:  Home of George Byrnes, founder of WINHLP-L mail list

Site:      cutl.city.unisa.edu.au

Operator:  Center for University Teaching and Learning, Allan Christie

           University of South Australia

Available: Winhelp alternate archive - many files

Directory: /pub/windows/winhelp

Files:     Many including humber & gmutant mirrors

Directory: /pub/internet/winhelp

Files:     Sample Help files - internet info in HLP format

Uploading: /uploads

Comments:  Very promising site for comprehensive file retrieval

Site:      blue-sky.com

Operator:  Blue Sky, makers of RoboHelp & other utilities

Available: Access mostly

Directory: /download

           /download/robohelp   /download/winmaker

           /download/winhelp3   /download/winhelp4

Files:     Not many

Uploading: Yes (/uploads)

Comments:  Where's the beef?

Site:      ftp.smartcode.com

Operator:  Smartcode through Worldwide Access

Available: SmartDoc Help Utility

Directory: /pub/oakley

Files:     smtdoc.zip

Uploading: No (/pub/incoming write protected for anon ftp)

Comments:  SmartDoc HLP to text utility

Site:      emwac.ed.ac.uk

Operator:  European Microsoft Windows NT Academic Consortium

Available: comp.os.ms-windows.programmer.winhelp USENET newsgroup

           messages as files

Directory: /news/programmer/winhelp

Files:     Numbered message files

Directory: /mirrors/indiana

Files:     CICA mirror site (see CICA above)

Uploading: Yes (/incoming)

Comments:  Further comments solicited

Site:      ftp.mv.com

Operator:  MV Communications  New Hampshire, USA

           mv-admin@mv.mv.com

Available: Magazine Archives for Dr. Dobb's Journal

Directory: /pub/ddj

Files:     199x.mm directories for each issue

Uploading: No

Comments:  See Sept/Oct 1993 issue files for WinHelp internal

           format documentation

           /pub/ddj/1993.09/1993-sep.zip (file undoc.asc)

           /pub/ddj/1993.10/undoc.zip

Site:      ftp.uu.net

Operator:  UUNET Technologies, Falls Church, Virginia USA

Available: Magazine Archives

Directory: /published/windowsdos

           Windows/DOS Developer's Journal Archive

Files:     /published/windowsdos/1993/mar93.zip

           /published/windowsdos/1994/feb94.zip

           Contain good stuff - there are others

Directory: /published/dr-dobbs

Files:     ddj<yy><mm>.zip   <yy> = year <mm> = month

Uploading: Not that I saw

Comments:  Several different publications archived here

Site:      ftp.csn.net

Operator:  User R. Mashlan

Available: Word 6 RTF quote/bullet code converter

Directory: /rmashlan

Files:     fixrtf.zip

Uploading: None

Comments:  Anyone try this?

Site:      ftp.win.net

Operator:  Michael Cessna, Infosoft Online Publishing

           (mcessna@infosoft.win.net)

Available: WinHelp archive (in development)

Directory: /winnet/infosoft/winhelp

Files:

ew256bmp.zip  WinHelp .dll/16 new macros/256c bitmap support

ewdll011.zip  WinHelp .dll/256c+ bitmap support

hbdemo.txt    WinHelp/Information about hbdemo.zip

hbdemo.zip    WinHelp/Adds a "Browser" window and full text search

hlpcol.zip    WinHelp-Viewer/Edits JumpColor etc. for .hlp-.mvb files

mhplus32.zip  WinHelp/Help Authoring Tool/MiniHelp Plus v3.21

rtfg203a.zip  WinHelp/Help Authoring Tool/RTFGEN v2.03a/freeware

rtfmod.zip    WinHelp-Viewer/Edits WinWord .rtf/Fixes many problems

shgrez11.zip  Creates fixed-resolution .shg files (Requires VBRUN300.DLL)

showbmp.zip   WinHelp .dll/256c+ bitmap support and more

smtdoc.zip    WinHelp/Standalone utility to print all .hlp topics

s4w211d.exe   WinHelp/Help Authoring Tool/SOS! Help InfoAuthor v2.11

srchal.zip    WinHelp/Creates "multiple .hlp" keyword capability

wfwhlp.zip    WinHelp/How to create .hlp with only WinWord and compiler

wh_ed111.zip  WinHelp/Edits position, size, colors and macros of .hlp files

whfaq.zip     WinHelp/FAQ for comp.os.ms-windows.programmer.winhelp (old)

winapi3.zip   WinHelp/Using the Windows API as custom macros

Directory: /winnet/infosoft/winhelp/showcase.

 343159 May  6/1995  aesop12.zip   Aesop's Fables

 157789 May  6/1995  const1_1.zip  The Constitution

 538694 May  6/1995  physicst.zip  Potter's Physics Tutorial

 684883 May  6/1995  ucook10a.zip  The USENET Cook Book

  57164 May  6/1995  yaptable.zip  Periodic Table

        Last updated: 05/10/95

Uploading: Not at this time

Comments:  Lots of good stuff - note use full cd to path specified

Site:      ftp.netcom.com

Operator:  Mike (maintainer of this list)

           dsmjb@aol.com

Available: This list & some WinHelp Info (to grow)

Directory: /pub/ki/kittyba

Files:     winhelp-on-net.txt    This list as updated

Uploading: Not at this time

Comments:  Worth a look ;^)

Please e-mail changes/additions to dsmjb@aol.com

I cannot guarantee this info as accurate or that

submissions will be entered.  Hope this is useful.


WinHelp smart quotes

LUOKKA: WinHelp

Date: 02/06/95 (13:14)              Number: 214444 of 215077 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: Help compiler removes apostrophes?

Conf: UUCPMAIL (31)              Read Type: MAIL FOR YOU (A) (+)

>      Does anyone have any idea why the help compiler would not show

> apostrophes that are present in my Word 6.0 RTF file?  I'm using HC.EXE,

>not the HC31.EXE that originally shipped with VB -- HC31.EXE had some

> compatibility problems with Word 6.0 RTF files.

Go to Tools then AutoCorrect and uncheck the "Change straight quotes to

Smart quotes" option.  You'll also have to do a global replace so it changes

all the Smart Quoted apostrophes with normal ones.

Shan Moldrich

Systems Support and Development (Melbourne)

Telecom Australia


WMF handle

LUOKKA: PictureBox

Date: 06/26/94 (14:28)              Number: 10640 of 10664 (Refer# NONE)

From: PETER@SKEL.DEMON.CO.UK

Subj: Re: how can i get a metafile handle?

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

           webber@werple.apana.org.au "Luke Webber" writes:

> >How can I get a Windows handle for a metafile in a PictureBox control?

> >I want to draw multiple copies of a metafile from one PictureBox

> >onto another PictureBox.  I would prefer to do this using the

> >Windows API call "PlayMetaFile", which requires a device context

> >handle and the metafile handle.  Currently I don't know how to

> >do this by any method - API or VB commands - so any help would be

> >greatly appreciated.

>

> You can't. The metafile will already be deleted after the being loaded

> into the picturebox. You either have to build your own metafile DC via

> the API or use LoadPicture for each of the picture boxes.

Not so, for a metafile to be continued to be displayed it must have a

handle somewhere. One kludgy way to get hold of the handle is to paste

the picture to the clipboard using normal VB commands then use API calls

Type METAFILEPICT

    mm as Integer

    xExt as Integer

    yExt as Integer

    hMF as Integer

End Type

dim Meta as METAFILEPICT

hMetaPict% =  GetClipboardData(CF_METAFILEPICT)

this only gets us a handle to the METAFILEPICT struct and as it belongs

the clipboard we cannot do anything with it other than look at it.

First we find out were it is;

Address& = GlobalLock(hMetaPict%)

It gets a bit more kludgy here as VB alone has no way of PEEKing into

memory, so to keep it pure VB and not use third party PEEK/POKE type

DLL's we will have to write 8 bytes out to a temp file and read them

back in;

DosFileHandle% = lopen("tempfile", WRITE OR OF_SHARE_EXCLUSIVE)

ret% = lwrite(DosFileHandle%, Address&, 8)

ret% = lclose(DosFileHandle%)

Must give the memory block back to Windows and the clipboard

ret% = GlobalUnlock(hMetaPict%)

All that is needed now is to open the file through VB as binary, get

META and you have the hMF as META.hMF . Although it looks kludgy it's

quite quick and you do not have two metafiles floating about in memory.

The one thing you must watch out for is that VB owns that handle and

you are just using it so you do NOT need to free it up with

DeleteMetafile() as you would have to if you created the metafile.

--

Peter Dyson


WMF print

LUOKKA: printing

Date: 06/26/94 (10:41)              Number: 10573 of 10664 (Refer# NONE)

From: GARDINER@MILLI.CS.UMN.EDU

Subj: Re: WMF-Printing problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

The following code should help.  This prints MetafileName at X = .25,

Y = 1.4 inches, 3.75 inches high, proportional scaling.  Sorry if

the code formatting is a bit hacked - I am not too fluent in vi.

David Gardiner

gardiner@cs.umn.edu

Sub PrintMetafile ()

    Dim oldMode As Integer, oldOrg As Long, oldExt As Long, ApiError As

Integer

    Dim GraphWidth As Integer, GraphHeight As Integer

    Dim GraphLeft As Integer, GraphTop As Integer, HtoWRatio As Double

    Dim oldDC As Integer

    Dim hMF As Integer

    hMF = GetMetaFile(MetafileName)

    If hMF = 0 Then

        MsgBox "Could not find graph file '" & MetafileName & "'.", MB_OK,

"System Error"

        Exit Sub

    End If

    Printer.Print " "

    oldDC = SaveDC(Printer.hDC)

    oldMode = SetMapMode(Printer.hDC, MM_ANISOTROPIC)

    GraphHeight = 3.75 * 1440 / Printer.TwipsPerPixelY

    GraphWidth = GraphHeight * (MFwidth / MFheight)

    GraphLeft = .25 * 1440 / Printer.TwipsPerPixelY

    GraphTop = 1.4 * 1440 / Printer.TwipsPerPixelY

    oldOrg = SetViewportOrg(Printer.hDC, GraphLeft, GraphTop)

    oldExt = SetViewportExt(Printer.hDC, GraphWidth, GraphHeight)

    ApiError = PlayMetafile(Printer.hDC, hMF)

    If ApiError = 0 Then

        MsgBox "PlayMetafile failed."

    End If

    ApiError = DeleteMetafile(hMF)

    oldDC = RestoreDC(Printer.hDC, -1)

End Sub


WMF print

LUOKKA: printing

Date: 06/26/94 (12:02)              Number: 10596 of 10664 (Refer# NONE)

From: PETER@SKEL.DEMON.CO.UK

Subj: Re: WMF-Printing problem

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

Sure have and it took a long time to figure it out. It wasn't in the

KBase so MS were of no help at all.

It all revolves around there being two types of metafile, a standard

(which no one uses),this is the type that GetMetaFile plays with and

Placeable (or Aldus) which has an extra structure prefixed to the

standard type.

Type MetaFileHeader

  Key As Long

  hMF As Integer

  bbox As RECT

  inch As Integer

  reserved As Long

  checksum As Integer

End Type

This is the routine I wrote to get a valid hMF from either type from

a disk file;

Function GetDiskMetafile (FileName$) As Integer

  Dim ret As Long                ' general function return value

  Dim Flen As Long               ' File length

  Dim Address As Long            ' 32 bit memory address

  Dim Head As MetaFileHeader     ' MetaFileHeader structure

  Dim FileNum As Integer         ' VB file number

  Dim hFile As Integer           ' DOS file handle

  Dim hGlobmem As Integer        ' Global memory handle

  Dim hMF As Integer             ' MetaFile handle

' no error handling for a bad filename or bad returns for clarity of method

' A valid filename will return a Metafile handle if it is a

' valid metafile,( either placeable or standard) or 0

' if it not a valid Metafile get next free file number

    FileNum = FreeFile

' get file length

    Flen = FileLen(FileName)

' open file

    Open FileName For Binary As FileNum

' strip first 22 bytes to find out if it has a METAFILEHEADER

' structure at the start of the file

     Get FileNum, 1, Head

' get dos file num for API calls that need to access the file

    hFile = FileAttr(FileNum, 2)

'if no placeable header reset pointer to start of file

    If Head.key <> &H9AC6CDD7 Then

        ret = llseek(hFile, 0, 0)

    End If

' allocate some memory

    hGlobmem = GlobalAlloc(gmem_moveable, Flen)

' stop windows from moving it about while we use it

' and get the address of the memory

    Address = GlobalLock(hGlobmem)

' read rest of file into memory

    ret = hread(hFile, Address, Flen)

' finished with disk file now

    Close FileNum

' unlock memory back to floating block

' keep Windows happy

    ret = GlobalUnlock(hGlobmem)               '  error if this fails

                                               ' a block of memory is lost

' create metafile handle from the memory block

    hMF = SetMetafileBits(hGlobmem)

' If a MetaFile handle is not returned then free the global

' memory block

    If hMF = 0 Then

        ret = GlobalFree(hGlobmem)

    End If

    ' if we return a handle then

    ' memory does not have to be released as it is now a normal

    ' memory metafile and will be released when hMF is finished

    ' with. This MUST be done with DeleteMetaFile() from the

    ' calling program.

' return the handle to the Metafile or 0 if no MetaFile handle

' has been returned

    GetDiskMetafile = hMF

End Function

This will give you a hMF to the metafile on disk which will work with

PlayMetaFile. I am assuming that since you have been using the API calls

that you have all the declarations required for the above functions.

--

Peter Dyson


Word 6.0 -> WinHelp

LUOKKA: WinHelp

Date: 01/19/95 (06:48)              Number: 190804 of 191526 (Refer# NONE)

From: VISBAS-L@TAMVM1.TAMU.EDU

Subj: Re: Word 6 & HELP file

The following code is a cut from AutoDog (with a last name that

suggests that I'm the son of Lassie, i.e. the son of a 'female dog',

what do you expect ...) that converts multiples doc (SQL Script,

VB,VBA, Access, Doc Files (any one that can be read by Winword), Mail

files etc etc) into Winhelp or full text search multimedia viewer or

MediaView (MSDN Technology Viewer) automatically:

Sub Convert_document (ByVal UNCFile$, byval NameOfRTF$)

'(c)1994 Microsoft Developer's Network, MSDN

CnvText!fname = UNCFile$

CnvText.Caption = "Converting Documents"

CnvText.Show

CnvText.Refresh 'Put up status dialog

Dim wORD As Object

Set wORD = CreateObject("Word.Basic")

wORD.CHDIR CurDir$

wORD.Fileopen UNCFile$

wORD.ToolsRevisions -1  'Word revisions ON can cause images to remain in

RTF

wORD.ToolsRevisions 0, 0, 0

wORD.StartofDocument

wORD.EndOfLine 1

wORD.CharLeft 1, 1

Title$ = txt2RTF(wORD.ŽSelection$�)

wORD.InsertFootnote "$", 0       'Insert Title

wORD.Insert Title$ + " Ž" + UNCFile$ + "�"

wORD.ClosePane

wORD.InsertFootnote "#", 0        'Insert context ID

wORD.Insert hlpGetNextcontext$()

wORD.ClosePane

wORD.InsertFootnote "K", 0       'Insert Keywords

wORD.Insert Title$ + ";Documents"

wORD.ClosePane

wORD.InsertFootnote "+", 0    'Insert Grp Browse

wORD.Insert DocNextGrp$()

wORD.ClosePane

wORD.StartofDocument

wORD.paradown 2 'we've done the first topic already!

wORD.EditFindClearFormatting

wORD.EditReplaceClearFormatting

'For headings 1-4 we will put in page breaks before each heading

'this will then convert these headings into separate topics

For i% = 1 To 4

    wORD.EditFindStyle "heading" + Str$(i%)

    wORD.StartofDocument

    wORD.paradown 2

    wORD.EditFind "", "", 0, 0, 0, 0, 0, 0, 0

    While wORD.EditFindFound

        wORD.CharLeft 1     'Move to start of line

        wORD.insertbreak 0  'PageBreak

        wORD.paradown 2     'Move beyond heading line

        wORD.EditFind "", "", 0, 0, 0, 0, 0, 0, 0

    Wend

Next i%

wORD.StartofDocument

wORD.EditFindClearFormatting

wORD.EditReplaceClearFormatting

Call hlpIncrContext

'Find all page breaks

wORD.EditFind "^m", "", 0, 0, 0, 0, 0, 0, 0

While wORD.EditFindFound

    wORD.CharRight 1

    wORD.EndOfLine 1

    wORD.CharLeft 1, 1

    Title$ = txt2RTF$(wORD.ŽSelection$�) 'remove or change ™ „ and

characters > 127

    If Len(Title$) Then

        wORD.InsertFootnote "$", 0

        wORD.Insert Title$ + " Ž" + UNCFile$ + "�"

        wORD.ClosePane

        wORD.InsertFootnote "K", 0

        wORD.Insert Title$

        wORD.ClosePane

    End If

    wORD.InsertFootnote "#", 0

    wORD.Insert hlpGetNextcontext$()  'Returns Strings H1,H2 H37485

with each call incrementing

    wORD.ClosePane

    wORD.InsertFootnote "+", 0

    wORD.Insert "10000"  'browse sequence

    wORD.ClosePane

    Call hlpIncrContext  'Actually increments hlpGetNextcontext$()

    wORD.EditFind "^m", "", 0, 0, 0, 0, 0, 0, 0

Wend

wORD.StartofDocument

wORD.EditFind "^g", "", 0, 0, 0, 0, 0, 0, 0

While wORD.EditFindFound

    wORD.Editcut

    If clipboard.GetFormat(3) Then

        graphFile$ = adpGetNextGraphic$() + ".wmf"  'like

hlpGetNextcontext$() above, ie. B1,b2,b7763

        SavePicture clipboard.GetData(3), graphFile$

        wORD.Insert "„bmc " + graphFile$ + "†"

    ElseIf clipboard.GetFormat(2) Then

        graphFile$ = adpGetNextGraphic$() + ".bmp"

        SavePicture clipboard.GetData(3), graphFile$

        wORD.Insert "„bmc " + graphFile$ + "†"

    Else

        wORD.Insert "ŽUnknown Graphics�"

    End If

    clipboard.Clear

    wORD.insertpara

    wORD.EditFind "^g", "", 0, 0, 0, 0, 0, 0, 0

Wend

wORD.FileSaveAs NameOfRTF$, 6

wORD.FileClose

Unload CnvText

End Sub

Many of the functions missing should be obvious.  This will be coming

out on a future issue of MSDN CD (April 95 is the target issue).  This

will handle any word doc and divide it into topics according whenever a

Heading 1 - 4 occurs.  This is the simple version --- there's a

separate tech note in the works which is far more advanced (creates

table of contents page with jumps, etc).

Ken


Word 6.0 removing Tip

LUOKKA: misc

Date: 10/23/94 (03:18)              Number: 24144 of 24188 (Refer# NONE)

From: RMOR92@CONTROL.AUC.DK

Subj: "Tip of the day" prb. in Word:The solution

Conf: co.la.bas.vis (1562)       Read Type: GENERAL (A) (+)

I have read several postings, asking about how to execute Word 6.0 AND (if

nesecary) remove the "Tip of the day" window. This must be done before

doing any DDE communication with Word. At the end of this posting, I have

included a module file, that can do just that. Just call the function

ExecuteWord().

Rene' Mortensen

---------------- put this code into a module (BAS) file -------------

Option Explicit

' Latest upgrade: 19/10-94

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal

lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As

String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal

lpFilename As String) As Integer

Declare Function GetActiveWindow Lib "User" () As Integer

' The following Declares and constants were taken from WIN30API.TXT

' that ships with the Visual Basic Professional Edition.

' Enter each of the following Declare statements on one, single line:

Declare Function SetFocusAPI Lib "User" Alias "SetFocus" (ByVal hwnd As

  Integer) As Integer

Declare Function GetDeskTopWindow Lib "User" () As Integer

Declare Function GetWindow Lib "User" (ByVal hwnd As Integer, ByVal

wCmd As Integer) As Integer

Declare Function GetWindowText Lib "User" (ByVal hwnd As Integer, ByVal

  lpString As String, ByVal aint As Integer) As Integer

Declare Function GetClassName Lib "User" (ByVal hwnd As Integer, ByVal

  lpClassName As String, ByVal nMaxCount As Integer) As Integer

Declare Function GetParent Lib "User" (ByVal hwnd As Integer) As Integer

Declare Function GetWindowWord Lib "User" (ByVal hwnd As Integer, ByVal

  nIndex As Integer) As Integer

Global Const GW_HWNDNEXT = 2

Global Const GW_CHILD = 5

Global Const GWW_ID = (-12)

Private Sub CheckForDagensTipsWin ()

    ' Function description:

    '   After Word is executed, then this function is called. This function

    '   checks wether or not the windows "Tip of the day" is displayed. If this

    '   window is displayed,

    '   then a õRETURNÕ is send to that window, to get it away.

    Dim r As Integer, ActivehWnd As Integer, i%, NoDagensTip%

    Static hWnds() As Integer

    Dim Search$

    ' Function taken from Microsoft KB article Q113475

    ' The Function returns the number of windows, where the title bar matches

    ' "Microsoft Word*". In the array hWnds the matching window handles is

    ' stored.

    r = FindWindowLike(hWnds(), 0, "Microsoft Word*", "*", Null)

    ' Get handle (hWnd) for the active window (maybee the "Tip of the day"

    '  handle)

    ActivehWnd = GetActiveWindow()

    NoDagensTip% = False

    For i% = 1 To UBound(hWnds, 1)

        If ActivehWnd = hWnds(i%) Then

            ' If the active window is one of the windows matching "*Microsoft

             ' Word*"

            ' This means, that the active window is not the window with "Tip of

            ' the day"

            NoDagensTip% = True

        End If

    Next i%

    ' If the active window didn't match "*Microsoft Word*"

    If NoDagensTip% = False Then

        SendKeys "õENTERÕ"

        DoEvents

         DoEvents

        DoEvents

    End If

End Sub

Function ExecuteWord () As Integer

    ' Function description:

    '   This function executes WINWORD.EXE

    '

    ' Returns:  True  - no error

    '           false - error occurred executing WINWORD.EXE

    Dim StrLen%

    Dim WordPrgPath2 As String * 255, WordPrgPath$

    Dim Dummy As Variant

    ' Retreive path to WINWORD.EXE (Microsoft Words EXE file) from word's

    ' ini file

    StrLen% = GetPrivateProfileString("Microsoft Word", "PROGRAMDIR", "",

        WordPrgPath2, 255, "WINWORD6.INI")

    If StrLen% <= 0 Then

        Beep

        MsgBox "Can't find Micosoft Word's INI file. Make sure that Microsoft

           Word 6.0 is installed on your computer!", 0 + 16, "Word error"

        ExecuteWord = False

        Exit Function

    End If

    WordPrgPath$ = Left$(WordPrgPath2, StrLen%)

    ' Check for trailing backslash (just to be sure)

    If Not StrComp(Right(WordPrgPath$, 1), "Í", 0) = 0 Then

        WordPrgPath$ = WordPrgPath$ & "Í"

    End If

    On Error GoTo WordNotPresentError

    Dummy = Shell(WordPrgPath$ & "WINWORD.EXE", 3)

    DoEvents

    DoEvents

    DoEvents

    DoEvents

    DoEvents

    DoEvents

    DoEvents

    DoEvents

    ' Check for "Tip of the day" window

    Call CheckForDagensTipsWin

    ExecuteWord = True

    Exit Function

WordNotPresentError:

    Beep

    MsgBox "Can't execute Micosoft Word. Make sure that Microsoft Word is

       installed on your computer!", 0 + 16, "Word error"

    ExecuteWord = False

    Exit Function

End Function

Function FindWindowLike (hWndArray() As Integer, ByVal hWndStart As

Integer, WindowText As String, Classname As String, ID) As Integer

   'FindWindowLike  (Function from MS KB article Q113475)

   ' - Finds the window handles of the windows matching the specified

   '   parameters

   '

   'hwndArray()

   ' - An integer array used to return the window handles

   '

   'hWndStart

   ' - The handle of the window to search under.

   ' - The routine searches through all of this window's children and their

   '   children recursively.

   ' - If hWndStart = 0 then the routine searches through all windows.

   '

   'WindowText

   ' - The pattern used with the Like operator to compare window's text.

   '

   'ClassName

   ' - The pattern used with the Like operator to compare window's class

   '   name.

   '

   'ID

   ' - A child ID number used to identify a window.

   ' - Can be a decimal number or a hex string.

   ' - Prefix hex strings with "&H" or an error will occur.

   ' - To ignore the ID pass the Visual Basic Null function.

   '

   'Returns

   ' - The number of windows that matched the parameters.

   ' - Also returns the window handles in hWndArray()

   '

   '----------------------------------------------------------------------

   ' Enter the following two lines as one, single line:

   Dim hwnd As Integer

   Dim sWindowText As String

   Dim sClassname As String

   Dim sID

   Dim r As Integer

   ' Hold the level of recursion:

   Static level As Integer

   ' Hold the number of matching windows:

   Static iFound As Integer

   ' Initialize if necessary:

   If level = 0 Then

      iFound = 0

      ReDim hWndArray(0 To 0)

      If hWndStart = 0 Then hWndStart = GetDeskTopWindow()

   End If

   ' Increase recursion counter:

   level = level + 1

   ' Get first child window:

   hwnd = GetWindow(hWndStart, GW_CHILD)

   Do Until hwnd = 0

      DoEvents ' Not necessary

      ' Search children by recursion:

      r = FindWindowLike(hWndArray(), hwnd, WindowText, Classname, ID)

      ' Get the window text and class name:

      sWindowText = Space(255)

      r = GetWindowText(hwnd, sWindowText, 255)

      sWindowText = Left(sWindowText, r)

      sClassname = Space(255)

      r = GetClassName(hwnd, sClassname, 255)

      sClassname = Left(sClassname, r)

      ' If window is a child get the ID:

      If GetParent(hwnd) <> 0 Then

         r = GetWindowWord(hwnd, GWW_ID)

         sID = CLng("&H" & Hex(r))

      Else

         sID = Null

      End If

      ' Check that window matches the search parameters:

      If sWindowText Like WindowText And sClassname Like Classname Then

         If IsNull(ID) Then

            ' If find a match, increment counter and add handle to array:

            iFound = iFound + 1

            ReDim Preserve hWndArray(0 To iFound)

            hWndArray(iFound) = hwnd

         ElseIf Not IsNull(sID) Then

            If sID = CLng(ID) Then

               ' If find a match increment counter and add handle to array:

               iFound = iFound + 1

               ReDim Preserve hWndArray(0 To iFound)

               hWndArray(iFound) = hwnd

            End If

         End If

      End If

      ' Get next child window:

      hwnd = GetWindow(hwnd, GW_HWNDNEXT)

   Loop

   ' Decrement recursion counter:

   level = level - 1

   ' Return the number of windows found:

   FindWindowLike = iFound

End Function


Www books

LUOKKA: internet

25489 (185+)  gbeene@iadfw.net  15.07.95  11:26

Gary Beene: "Re: Any suggestion on VB books?"

Check out my web page for a review and table of contents of a few

books.

As always, I'm a big fan of the VB Programmer's Guide that came with

the VB software.  All the other books for beginners covers the same

material, not always in a clearer fashion.

-------------------------

Gary L. Beene

gbeene@iadfw.net

Gary Beene's Visual Basic Home Page

http://www.iadfw.net/gbeene/visual.html


Www home pag

LUOKKA: internet

Date: 03-21-95 (02:54)              Number: 265177 of 266122 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: WWW VB Home page

For those who may be interested, I have compiled a home page dedicated to

VB programming issues, and internet goodies.

        http://www.tiac.net/users/efields


Www Q/A db

LUOKKA: internet

Date: 05-31-95 (05:09)              Number: 347185 of 347854 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: New Online WWW VB Q/A Database

It's here! The Visual Basic Question / Answer / Information / Database

ö NEW ö  (QAID) is online and ready. This WWW home page is now 100K

and growing daily with questions, answers and information on Visual Basic for

Windows arranged by topic for ease of use. Check it out and drop me e-mail

and let me know what you think. (Windows 95 QAID also is here)

This hypertext database makes finding an answer very easy. It will also be

available in a stand-alone version for Windows. (Free)

        http://www.whidbey.net/~mdixon/qaid0001.htm

The standalone version will feature: (available in June sometime)

HYPERTEXT INTERFACE: Like Windows Help on steroids! Better "looking"

than the WWW home page version.

BUTTONS for the following actions:

SEARCH: Fully indexed text search, every word in the database is indexed.

NOTES: Add your own personal notes to each topic area.

PRINT: Topics can be printed. Printed topics are formatted just like they

appear on the screen.

EXPORT: Topics can be exported as Text or Word Perfect 4.2 or 5.0

w/codes. Even tag names can be exported.

BOOKMARK: Add as many personal bookmarks as you like, makes it easy to

get back to where you left off.

  +-+-------------------------------------------------+-+-+-+

  ö&ö    From the Windows 95 Desktop of Mike Dixon    ö_öOöXö

  +-+-------------------------------------------------+-+-+-+

  ö  Windows 95 Question/Answer/Information Database & the  ö

  ö  Visual Basic 95 Question/Answer/Information Database - ö

  ö  http://www.whidbey.net/~mdixon/qaid0001.htm            ö

  ö  E-Mail - mdixon@whidbey.net                            ö

  ö  My BBS - (360)675-7683 (Excalibur based)               ö


Www sites

LUOKKA: internet

10667 (87+)  andyb@utmdacc.mda.uth.tmc.edu  20.03.95  20:38

Andy Blight: "Re: FTP & WWW?"

Here is a list of VB related WWW sites edited from "WebCrawler" -

(http://webcrawler.cs.washington.edu/WebCrawler/WebQuery.html)

I use the keywords "Visual Basic" and "VBX" and I filtered out the "useless"

ones...

WWW Address	Page Title

--------------------------------------------------------------------------------------

http://www.transport.com/~jseger/prof.html	John Seger's Professional

Information

http://www.apexsc.com/vb	Visual Basic Home Page

(The "two guys")

http://199.165.143.153/press.html	Press Releases

http://www.halcyon.com/mabry

Mabry Software's Home Page

http://131.107.1.189/devmsj.htm

Microsoft Systems Journal

http://www.biochem.abdn.ac.uk/~john/amaze.html	Amaze

http://199.165.143.153/dca.html

DynaComm/Elite v3.5

http://av.avc.ucl.ac.uk/av	AV Dept - IT Handbook

ftp://kestrel.edu/www/vizo.html

Visualization Synthesis System

http://www.calsoft.com/interap/scripts.html	NetScripts

http://krumsee-pc.acs.ohio-state.edu/software™software.htm

Software Download Page

http://academy-www.bu.edu/~arts.html	Arts Program

http://www.bayne.com/hall/barcodes

HALLoGRAM Publishing - Barcode Products

http://www.dtcc.edu/~flat">	Frank's World

http://stardust.jpl.nasa.gov:8007/tutor.html	Getting Started Tutorial

http://www.iftech.com/classes/vcpp/vcpp1.htm

Part 1: Visual C++ 1.5 Introduction

http://141.211.90.103/art.html

SCHOOL OF ART

VBX Keyword...

http://quasar.sba.dal.ca:2000/download.html	Download Central

http://loki.borland.com:8080/delphi™delphi.htm	Delphi Q&A

http://www.blue-sky.com/wmpr.htm

WinMaker product description

ftp://interport.net/pub/pbrooks/slipknot/sntfaq1.txt

ftp://interport.net/pub/pbrooks/slipknot/sntfaq1.txt

http://www.teknowledge.com/M4/proddesc.html

M.4 - The Embeddable Expert System Solution

http://www.blue-sky.com/rhpr.htm

RoboHelp press release.

http://www.teknowledge.com/M4/techdesc.html

Technical Description

http://coyote.csusm.edu/cwis/winworld/winworld.html

CSUSM Windows World

ftp://ftp.einet.net/einet/pc/README.HTM

EINet Shareware winWAIS Software Version 2.04

http://loki.borland.com:8080/delphi™delphbks.htm

http://loki.borland.com:8080/delphi™delphbks.htm

http://www.lth.se/faq

http://www.lth.se/faq

http://futures.wharton.upenn.edu/~ahrens26/ivc.faq

http://futures.wharton.upenn.edu/~ahrens26/ivc.faq

http://www.iadfw.net/gbeene/visual.html.

http://www.alisa.com/win-httpd/index.html

Windows httpd - Check this one out!

http://www.peachnet.edu/usenetfaqs.html

List of USENET FAQs

-----------------------------------------------

Andy Blight - andyb@utmdacc.mda.uth.tmc.edu

Software Systems Specialist II

University of Texas M.D. Anderson Cancer Center

Houston, TX


Www sites

LUOKKA: internet

4550 (13+)  sgotz@ix.netcom.com  29.05.95  02:51

Steven Gotz: "Re: VB site"

"http://www.apexsc.com/vb/","Visual Basic Home Page"

"http://www.microsoft.com/pages/kb/indexes/vb.htm","Visual Basic

for Windows Knowledge Base"

"http://www.cdrom.com/pub/cica/programr/vbasic/","Index of

/pub/cica/programr/vbasic/"

"http://www.skypoint.com/subscribers/zeta/vb.html","The Complete

Solution Visual Basic Project"

"http://coyote.csusm.edu/cwis/winworld/vbasic.html","VBASIC Section

- CSUSB Shareware"

"http://www.apexsc.com/vb/clbv-digest/","CLBV Digest

(Comp.Lang.Basic.Visual.* Digest) Home Page"

"http://www.ziff.com:8019/~cobb/","Welcome to The Cobb Group"

"http://www.iadfw.net/gbeene/visual.html","Gary Beene's Visual Basic

Home Page"

"http://calweb.calweb.com/~wahle/vbmag/","VB'ers Electronic Magazine"

"http://www.tiac.net/users/efields/","Ed Fields' VB Info and Resource

Page"

"http://hoosier.com/~easmith/vb.html","Eric's Internet Depot -

Programming Sites"

"http://coyote.csusm.edu/cwis/winworld/winworld.html","CSUSM Windows

World ShareWare Archive"

http://www.cyber.net/~grinch

Ask Dr. VB!

  http://www.crl.com/~cicero/drvb/askdrvb.html

Carl & Gary's Visual Basic Home Page

  http://www.apexsc.com/vb/

Cobb Group, The

  http://www.ziff.com:8019/~cobb/

FTP "cica" (AOL Mirror)

  ftp://mirrors.aol.com/pub/cica/pc/win3/programr/vbasic

Gary Beene's Visual Basic Home Page

  http://www.iadfw.net/gbeene/visual.html

Microsoft

  http://www.microsoft.com/

Visual Basic for Windows Knowledge Base

  http://www.microsoft.com/pages/kb/indexes/vb.htm

Visual Basic Programming Sites

  http://hoosier.com/~easmith/vb.html

www.apexsc.com/vb/

www.skypoint.com/members/zeta/vb.html

www.crl.com/~cicero/vbjunct.html

http://www.xs4all.nl/~treffers  VB homepage

VB Junction has moved!  The new URL is:

http://www.ticllc.net/~bobrob/vbj/

Some of the new things added:

  - Searchable VB Helpers

  - Automated addition of Helpers via a form

  - Automated link addition

  - The new VBJ Sounding Board, a place for Q&A, updated hourly


Www VBIT

LUOKKA: internet

108  idb@vestnett.no  12.04.95  14:52

Dag Haugen: "VBIT 1.20  Visual Basic Invisible Tools"

VBIT: Tools for Visual Basic Programmers.

Simple, powerful routines for string

handling, formatting, editing,  data

management. Extremely flexible TABLES

for handling huge amounts of data in

RAM - unique sorting algorithm, fast

searching and a lot more.

http://www.vestnett.no/~idb/

ftp://ftp.vestnett.no/pub/pro/idb/vbit120.zip

The Complete Solution                                  greg@tcscs.com

Check out our new WWW page:  http://www.skypoint.com/subscribers/zeta

---------------------------------------------------------------------

VISUAL BASIC PROJECT     http://www.skypoint.com/members/zeta/vb.html


Www-link

LUOKKA: WinHelp

6453 (17+)  wai@primenet.com  19.07.95  07:47

Ben Weisner: "New WinHelp Universe Info"

I've just updated the WinHelp Universe page

(http://www.primenet.com/~wai/Universe.html) to include a link to the

WinHelp Office review in PC Week, and to all WinHelp related files in

Microsoft's FTP-able software library, including SHED, WHAT, and other

goodies. Also added a cool links page, and a page with links to technical

info for WinHelp developers (includes link to SHED spec).

Thanks for all the kind comments, and the bug reports. I fixed the download

problem people were having with the demos, and consequently created a

new WinHelp-related FTP site which will soon expand considerably

(ftp.primenet.com/users/w/wai/). Also thanks to Philip De Lisle for the heads

up on Netscape vs. Mosaic issues. I'll try to maintain the WinHelp Universe

as the most comprehensive collection of WinHelp-related info on the net, but

need your help to do it!

==

Weisner Associates, Inc.                                       800-646-9989

*Information Delivery Solutions*                           benw@weisner.com

"Home of the Windows Help Universe"

http://www.primenet.com/~wai


Www-magazine

LUOKKA: internet

236  jakobf@apexsc.com  19.07.95  02:17

Jakob Faarvang: "CLBV Digest"

--------------------------------------------------

CLBV Digest Issue #6

--------------------------------------------------

The latest issue of CLBV Digest is now online via World

Wide Web at http://www.apexsc.com/vb/clbv-digest/. Sorry,

but no WinHelp version will be available due to lack of

time.

CLBV Digest is a monthly magazine dedicated to Visual Basic.

This issue features the following articles:

Ramblings from the 'Spyre by Jason Kaczor

Application Subclassing in Microsoft Visual Basic by Tapio K. Vocadlo

VBTrace 2.0 by Chuck Stuart

Encryption by Ian Lynagh

Dearming the time bomb - part 4 by Chad Z. Hower

Reviews:

PDQComm vs. MicroHelp Comm Lib by Rick Kolesar

SilverWare Communications Library Review by Jakob Faarvang

Distinct TCP/IP Tools Review by Jakob Faarvang

Teratech Review by Jakob Faarvang

IMPORTANT NOTE: This CLBV Digest issue is the *last* issue. Instead,

a new magazine will be premiering September 1st. This new magazine,

called "Visual Basic Online", will feature some of the best Visual Basic

writers. Not only will it feature articles covering Visual Basic, but also

advanced topics such as using C++ and Delphi to create VB add-ons, etc.

This new magazine will be entirely free for readers. It will be set up

at its own domain, http://www.vb-online.com/. Please note that this domain

is not set up yet, but will be done so soon.

Yours sincerely,

Jakob Faarvang

Editor, CLBV Digest


Www-site

LUOKKA: internet

Date: 06-30-95 (03:32)              Number: 375791 of 377040 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: VB Code Corner

From: Paul Treffers <treffers@XS4ALL.NL>

Some weeks back i've started the VB Code Corner.  I am looking for

contributors for the VB Code Corner. Do you have a really nice sub,

function, a real nasty function or dazzling forms and you

would like to contribute them to the VB WWW community, drop me

a mail with your code. I'll add them to the list that is already there.

Your name and e-mail address will be also mentioned in that list, so

it not something anonymous.

Check it out at http://www.xs4all.nl/~treffers

Email address : treffers@xs4all.nl

--------------------------------------------------------------------------

Visit my homepages at http://www.xs4all.nl/~treffers for VB information

--------------------------------------------------------------------------


Www-site

LUOKKA: WinHelp

5919 (2+)  lguevara@earth.execpc.com  16.06.95  17:55

Larry Guevara: "New Winhelp web and ftp site"

There's a new web site, RTFGEN Windows Help Authoring,

http://www.luhsd.k12.ca.us/lhs/rtfgen.html, along with

an FTP site at ftp://ftp.luhsd.k12.ca.us/pub/win/winhelp.

RTFGEN 2.03 is a freeware help authoring program by David

Baldwin. Completed help files and other programs are

available, along with a bibliography of help resources.

David Baldwin does not endorse or support this

site.

For more information contact Larry Guevara at

lguevara@luhsd.k12.ca.us.


Www-sites

LUOKKA: internet

Date: 06-20-95 (09:03)              Number: 367417 of 368169 (Refer# NONE)

From: VISBAS-L@LISTSERV.TAMU.EDU, Visual Basic List

Subj: Re: CRYSTAL e-mail address (and others)? KEEP!

Crystal Services: 74774.3025@compuserve.com

I had this address in my database

(http://www.whidbey.net/~mdixon/qaid0001.htm), it might be the same

company.

AS a matter of fact, here is the whole list. KEEP FOR FUTURE REFERENCE.

Visual Basic related vendors E-mail and Home Pages

    A&G Graphics: 74.273@compuserve.com

    Aardvark Software, Inc: 74431.3330@compuserve.com

    Advanced Micro Technology: 74774.3102@compuserve.com

    Apex Software: 71053.1062@compuserve.com

    Home Page: http://www.apexsc.com/

    Application Development Training: 74777.400@compuserve.com

    Avanti Software: 74774.711@compuserve.com

    Bennet-Tec Info Systems: 74774.651@compuserve.com

    Crescent Software: 74774.237@compuserve.com

    Home Page: http://www.progress.com/crescent/

    Internet Mail: crescent@progress.com

    Crystal Services: 74774.3025@compuserve.com

    Desaware: 74431.3534@compuserve.com

    DPM Computer Solutions: 74777.447@compuserve.com

    FoxHall Publishing: 76702.1605@compuserve.com

    ImageFX: 74431.3331@compuserve.com

    Jetstream Software: 74777.3362@compuserve.com

    London Software: 74774.2224@compuserve.com

    Mabry Software: 74431.3332@compuserve.com

    Home Page: http://www.halcyon.com/mabry/

    Media Architects: 74774.707@compuserve.com

    Home Page: http://www.teleport.com/~mediarch/

    Microhelp: 74774.55@compuserve.com

    Technical Support <technical.support@microhelp.com

    Opaque Software: 74777.3227@compuserve.com

    Pinnacle Software: 72600.140@compuserve.com

    ProNexus: 74777.406@compuserve.com

    Sax Software: 74774.710@compuserve.com

    Sheridan Software Systems: 74774.547@compuserve.com

    Simply Solutions: 74777.3221@compuserve.com

    Software FX: 74777.3361@compuserve.com

    Stylus Innovation: 74431.3533@compuserve.com

    SuccessWare International: 74774.2240@compuserve.com

    Sylvan Ascent: 74774.3322@compuserve.com

    Synergy Technologies: 74777.757@compuserve.com

    Teknowledge: 74774.2525@compuserve.com

    The Young Software Works: 74774.2237@compuserve.com

    VBxtras: glen@vbxtras.com

Home Page: http://www.vbxtras.com/

    VideoSoft: 74774.420@compuserve.com

    ViewPoint Technologies: 74774.2154@compuserve.com

    Visual Basic Programmer's Journal: 74774.305@compuserve.com

    Visual Components: 74774.443@compuserve.com

Visual Basic Publications

Access/Visual Basic Advisor

Customer Service Dept.

4010 Morena Blvd.

P.O. Box 17902

San Diego, CA 92177

(619)483-6400

70007.1614@compuserve.com

12 issues US$29

Visual Basic Programmer's Journal

P.O. Box 58872

Boulder, CO 80322-8872

(303) 541-0610

8 issues US$34.97

  +-+-------------------------------------------------+-+-+-+

  &    From the Windows 95 Desktop of Mike Dixon    _OX

  +-+-------------------------------------------------+-+-+-+

    Windows 95 Question/Answer/Information Database & the

    Visual Basic 95 Question/Answer/Information Database -

    http://www.whidbey.net/~mdixon/qaid0001.htm

    mdixon@whidbey.net    My excalibur BBS - (360)675-7683

  +---------------------------------------------------------+

 http://metro.turnpike.net/~smiths


Www/ftp site

LUOKKA: internet

Checkout Carl 'n' Gary's VB Home Page. I think the URL is

( http://www.apexsc.com/vb/ ). Very Good!

If you find them, DL "vbtt95.zip".

-----------------------------------------------------------------------

Another good location for vbx's etc. is this ftp site...

( ftp.csusm.edu./pub/winworld/vbasic/ ). Ie: you'll find VSVBX here etc.

------------------ - - - - -

http://www.apexsc.com/vb

http://coyote.csusm.edu/cwis/winworld/vbasic.html

-------------------- - - - -

Try the following WWW sites:

Carl n' Gary's VB Home Page -

   http://www.apexsc.com/vb

CSU VB Shareware Archive -

   http://coyote.csusm.edu/cwis/winworld/vbasic.html

Visual Basic FAQ -

   http://www.cis.ohio-state.edu/hypertext/faq/usenet/

   visual-basic-faq/top.html

CICA VB Archive -

   gopher://pub.vse.cz:7077/11/msdos/simtel/visbasic

Got these out of VB Programmers Journal 4/95.  There is an article

on surfing the net with VB that is pretty interesting.

Chris Chandler

L064719@PO200.APPL.GE.COM

--------------------------- - - - - --

Check out this webpage :        http://www.vestnett.no/~idb

Petter Eldoeen

--------------------- - - - - - - -

http://www.skypoint.com/members/zeta/vb.html

http://www.apexsc.com/vb/

--

Maurizio Dal Re (MurriWare) from Bologna, Italy

Via Signorini 17              Tel. +39-51-389616 / +39-51-6195766

40133 Bologna               Fax +39-51-6192501

ITALY                            murri@murriws.dsnet.it

--------------------------------- - - - - -