Library Documentation
Library Documentation
b
LIBRARY SYSTEM DOCUMENATION
CONTENTS
01. ACKNOWLEDGMENT…………………………………………(a)
2
PROJECT SPECIFICATIONS
Requirements: Platform:
Microsoft Windows 9x, NT and
onwards
Hardware:
32-bit Processor, 300 MHz
32 MB RAM,
Printer
3
SOFTWARE STUDY
Software used for the development of the project are:
Visual Basic developed from the old Quick Basic language that
was available under the DOS operating system. Quick Basic is
the same language as BASIC; it is just Microsoft's product name
for its version of BASIC. Visual Basic started out as the Brainchild
of Alan Cooper. Cooper developed Visual Basic and then sold the
product to Microsoft. Microsoft took the undeveloped product,
code-named it "Thunder," the proceeded to create a
programming language that would soon become one of the
premier development environments in the windows environment.
1. ActiveX documents.
2. DHTML applications that help you test browser
application.
3. IIS applications that help you build server-based
application.
4. Web browser control.
4
5. FTP / HTTP support through a custom control.
6. Winsock control.
Has an excellent integrated Help facility and Books Online?
Including good debugging facilities. It has many wizards
that help automate repetitive tasks.
Can be extended easily through the use of Windows API
calls, hundreds of third party controls and DLLs, and
integration with other Windows applications through Com
and DCOM.
Uses many database access methods to get at different
types of data.
5
MS Access 7.0
6
FORMS:
Login form: frmlogin.frm
Add books frmaddbook.frm
Add category frmaddcategory.frm
Add course frmaddcourse.frm
Returning books frmreturning.frm
Borrower frmborrowing.frm
Book catalog frmbookcatalog.frm
Add user frmadduser.frm
Find frmfind.frm
Main page frmmain.frm
Change password frmchangepass.frm
Add user frmuser.frm
About frmAbout.frm
7
The Database
Table: Book catalog
Columns
Table: charge
Columns
Table: course
This table stores the courses of the book. This can be
added or deleted.
9
MODULES
Mod drawing
Option Explicit
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA"
(_
ByVal dwFlags As Long, lpSource As Any, dwMessageID As Long, _
ByVal dwLanguageID As Long, lpBuffer As String, _
ByVal nSize As Long, Arguments As Long) As Long
'
=============================================================
========
' APIs used primarily for drawing/graphics
'
=============================================================
========
Private Declare Function StretchBlt Lib "gdi32" ( _
ByVal hDC As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, _
ByVal nSrcHeight As Long, ByVal dwRop As Long) _
As Long
Public Declare Function DrawState Lib "user32" Alias "DrawStateA" (ByVal hDC
As Long, ByVal hBR As Long, ByVal lpDrawStateProc As Long, ByVal lParam As
Long, ByVal wParam As Long, ByVal x As Long, ByVal y As Long, ByVal cx As
Long, ByVal cy As Long, ByVal fuFlags As Long) As Long
Private Declare Function RealizePalette Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function CopyImage Lib "user32" (ByVal Handle As Long, ByVal
ImageType As Long, ByVal newWidth As Long, _
ByVal NewHeight As Long, ByVal lFlags As Long) As Long
Private Declare Function OleTranslateColor Lib "oleaut32.dll" _
(ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As
Long
Private Declare Function SelectPalette Lib "gdi32" (ByVal hDC As Long, _
ByVal hPalette As Long, ByVal bForceBackground As Long) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As
Long, ByVal y As Long) As Long
Public Declare Function GetTextColor Lib "gdi32" (ByVal hDC As Long) As Long
Public Declare Function SetTextColor Lib "gdi32" (ByVal hDC As Long, ByVal
crColor As Long) As Long
Public Declare Function SetBkMode Lib "gdi32" (ByVal hDC As Long, ByVal
nBkMode As Long) As Long
Public Const NEWTRANSPARENT = 3 'use with SetBkMode()
Private Declare Function CreatePen Lib "gdi32" _
(ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As
Long
Private Declare Function MoveToEx Lib "gdi32" _
10
(ByVal hDC As Long, ByVal x As Long, ByVal y As Long, lpPoint As
POINTAPI) As Long
Private Declare Function LineTo Lib "gdi32" _
(ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function Rectangle Lib "gdi32" _
(ByVal hDC As Long, ByVal x1 As Long, ByVal Y1 As Long, ByVal X2 As
Long, ByVal Y2 As Long) As Long
' following public functions/types may not be used in these modules but are
' used in my CodeSafe program & are here for organizational reasons
Public Declare Function DrawIconEx Lib "user32" (ByVal hDC As Long, ByVal
xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As
Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal
hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Public Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As
Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal
hObject As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As
Integer
Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA"
(lpLogFont As LOGFONT) As Long
Private Declare Function SystemParametersInfo Lib "user32" Alias
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long,
lpvParam As NONCLIENTMETRICS, ByVal fuWinIni As Long) As Long
Public Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long)
As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" _
(ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long,
lpBits As Any) As Long
Private Declare Function SetBkColor Lib "gdi32" (ByVal hDC As Long, ByVal
crColor As Long) As Long
Public Declare Function GetBkColor Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function PatBlt Lib "gdi32" (ByVal hDC As Long, ByVal x As
Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
dwRop As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hDC As
Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal
wFormat As Long) As Long
Public Const DT_CALCRECT = &H400
Public Const DT_LEFT = &H0
Public Const DT_SINGLELINE = &H20
Public Const DT_NOCLIP = &H100
11
Private Const DT_CENTER = &H1
12
End Type
Private Type NONCLIENTMETRICS
cbSize As Long
iBorderWidth As Long
iScrollWidth As Long
iScrollHeight As Long
iCaptionWidth As Long
iCaptionHeight As Long
lfCaptionFont As LOGFONT
iSMCaptionWidth As Long
iSMCaptionHeight As Long
lfSMCaptionFont As LOGFONT
iMenuWidth As Long
iMenuHeight As Long
lfMenuFont As LOGFONT
lfStatusFont As LOGFONT
lfMessageFont As LOGFONT
End Type
' Other constants used for graphics
Private Const WHITENESS = &HFF0062
Private Const MAGICROP = &HB8074A
Private Const DSna = &H220326 '0x00220326
'Color constants for GetSysColor
Public Enum ColConst
COLOR_ACTIVEBORDER = 10
COLOR_ACTIVECAPTION = 2
COLOR_ADJ_MAX = 100
COLOR_ADJ_MIN = -100
COLOR_APPWORKSPACE = 12
COLOR_BACKGROUND = 1
COLOR_BTNFACE = 15
COLOR_BTNHIGHLIGHT = 20
COLOR_BTNLIGHT = 22
COLOR_BTNSHADOW = 16
COLOR_BTNTEXT = 18
COLOR_CAPTIONTEXT = 9
COLOR_GRAYTEXT = 17
COLOR_HIGHLIGHT = 13
COLOR_HIGHLIGHTTEXT = 14
COLOR_INACTIVEBORDER = 11
COLOR_INACTIVECAPTION = 3
COLOR_INACTIVECAPTIONTEXT = 19
COLOR_MENU = 4
COLOR_MENUTEXT = 7
COLOR_SCROLLBAR = 0
COLOR_WINDOW = 5
COLOR_WINDOWFRAME = 6
COLOR_WINDOWTEXT = 8
End Enum
' local variables
13
Private m_hDC As Long ' reference to DC being drawn in
Private m_Font(0 To 1) As Long ' local copy of menu font
Private m_FontOld As Long ' font of DC prior to replacing with menu font
'
=============================================================
========
' Prints text to current DC in the coodinates & colors provided
'
=============================================================
========
If m_hDC = 0 Then Exit Sub
'Equivalent to setting a form's property FontTransparent = True
SetBkMode m_hDC, NEWTRANSPARENT
Dim OT As Long, x1 As Long
' set text color and set x,y coordinates for printing
OT = GetTextColor(m_hDC)
SetTextColor m_hDC, Clr
x1 = tRect.Right
' print the caption/text
If bCenter Then
14
DrawText m_hDC, hStr, Len(hStr), tRect, DT_NOCLIP Or DT_CALCRECT Or
DT_CALCRECT Or DT_SINGLELINE
tRect.Left = (x1 - iOffset - tRect.Right) \ 2 + iOffset
tRect.Right = tRect.Left + tRect.Right
Else
tRect.Left = x + iOffset
End If
tRect.Top = y
tRect.Bottom = tRect.Bottom + y
DrawText m_hDC, hStr, Len(hStr), tRect, DT_SINGLELINE Or DT_NOCLIP Or
DT_LEFT
If Len(hAccel) Then
' here we will print an acceleraor key if needed
tRect.Left = tRect.Left + iTab - iOffset
tRect.Top = y
DrawText m_hDC, hAccel, Len(hAccel), tRect, DT_LEFT Or DT_NOCLIP Or
DT_SINGLELINE
End If
'Restore old text color
SetTextColor m_hDC, OT
End Sub
15
' select colors, offset when set indicates erasing
iOffset = Abs(CInt(bSelected)) + 1
If Sunken = False Then
CurPen = GetPen(1, GetSysColor(Choose(iOffset, COLOR_MENU,
COLOR_BTNHIGHLIGHT)))
Else
CurPen = GetPen(1, GetSysColor(Choose(iOffset, COLOR_MENU,
COLOR_BTNSHADOW)))
End If
OldPen = SelectObject(m_hDC, CurPen)
'
=============================================================
========
' Draws imagelist image on destined DC
16
'
=============================================================
========
17
Else
'
=============================================================
========
' This function is from Paul DiLascia's DrawEmbossed function
' which draws colored disabled pictures.
' To be fair to him, I modified several lines of code so
' it is customized for CodeSafe & should it fail -- not his fault
'
=============================================================
========
18
Call SelectObject(m_hDC&, hOldBrush&)
Call SetBkColor(m_hDC&, hOldBackColor&)
Call SelectObject(hmemDC&, hOldBitmap&)
Call DeleteObject(hOldBrush&)
Call DeleteObject(hbrHilite&)
Call DeleteObject(hbrShadow&)
Call DeleteObject(hOldBackColor&)
Call DeleteObject(hOldBitmap&)
Call DeleteObject(hBitmap&)
Call DeleteDC(hmemDC&)
End If
End Sub
19
If destDC = 0 Then destDC = m_hDC
hdcSrc = CreateCompatibleDC(hdcScreen)
hbmMemSrcOld = SelectObject(hdcSrc, imgHdl)
RealizePalette hdcSrc
20
'all pixels that match the background color of the source DC.
'All other bits are set to 0.
SetBkColor hdcColor, lMaskColor
SetTextColor hdcColor, vbWhite
BitBlt hdcMask, 0, 0, Width, Height, hdcColor, 0, 0, _
vbSrcCopy
'Paint the rest of the cover bitmap.
'
'What we want here is black at the transparent color,
'and the original colors everywhere else. To do this,
'we first paint the original onto the cover (which we
'already did), then we AND the inverse of the mask onto
'that using the DSna ternary raster operation
'(0x00220326 - see Win32 SDK reference, Appendix,
'"Raster Operation Codes", "Ternary
'Raster Operations", or search in MSDN for 00220326).
'DSna [reverse polish] means "(not SRC) and DEST".
'
'When bitblt'ing from monochrome to color, Windows
'transforms all white bits (1) to the background color
'of the destination hdc. All black (0)
'bits are transformed to the foreground color.
SetTextColor hdcColor, vbBlack
SetBkColor hdcColor, vbWhite
BitBlt hdcColor, 0, 0, Width, Height, hdcMask, 0, 0, DSna
'Paint the Mask to the Screen buffer
BitBlt hdcScnBuffer, 0, 0, Width, Height, hdcMask, 0, 0, vbSrcAnd
'Paint the Color to the Screen buffer
BitBlt hdcScnBuffer, 0, 0, Width, Height, hdcColor, 0, 0, vbSrcPaint
'Copy the screen buffer to the screen
BitBlt destDC, xDest, yDest, Width, Height, hdcScnBuffer, 0, 0, vbSrcCopy
'All done!
DeleteObject SelectObject(hdcColor, hbmColorOld)
SelectPalette hdcColor, hPalOld, True
RealizePalette hdcColor
DeleteDC hdcColor
DeleteObject SelectObject(hdcScnBuffer, hbmScnBufferOld)
SelectPalette hdcScnBuffer, hPalBufferOld, True
RealizePalette hdcScnBuffer
DeleteDC hdcScnBuffer
21
End Sub
22
SelectObject m_hDC, m_FontOld
End If
End Sub
'=============================================================
==========
23
lNewColor = lColor
' loop thru each line & color it
For i = 1 To tRect.Bottom - 1
' this line is used to subtract/add colors
' for a more dramatic fade, increment the #2 below
lColorStep = (2 / tRect.Bottom) * i
' modify the current color
B = ((lNewColor \ &H10000) Mod &H100) - lColorStep
G = ((lNewColor \ &H100) Mod &H100) - lColorStep
R = (lNewColor And &HFF) - lColorStep
' ensure the Red, Green, Blue values are in acceptable ranges
If R < 0 Then
R=0
ElseIf R > 255 Then
R = 255
End If
If G < 0 Then
G=0
ElseIf G > 255 Then
G = 255
End If
If B < 0 Then
B=0
ElseIf B > 255 Then
B = 255
End If
lNewColor = RGB(R, G, B) ' cache the color & draw the line
tmpSB.Line (0, i - 1)-(tRect.Right, i - 1), lNewColor, BF
Next
' now that the gradient has been drawn, copy it to the menu panel
BitBlt m_hDC, 0, 0, tRect.Right, tRect.Bottom, .hDC, 0, 0, vbSrcCopy
End With
GradientErrors:
On Error Resume Next
' clean up
Forms(formID).Controls.Remove "pic___tmp_s_b"
Set tmpSB = Nothing
End Sub
=============================================================
========
' Simple little check mark drawing, looks good 'nuf I think
24
'
=============================================================
========
xOffset = 6 + xtraOffset
yOffset = pRect.Top + 6
Mod global
Public libCON As ADODB.Connection
Public borrowerRS As ADODB.Recordset
Public catRS As ADODB.Recordset
Public bookRS As ADODB.Recordset
Public borrowRS As ADODB.Recordset
Public currentRS As ADODB.Recordset
Public courseRS As ADODB.Recordset
Public returnRS As ADODB.Recordset
Public feeRS As ADODB.Recordset
Public userRS As ADODB.Recordset
25
Public returnCMD As ADODB.Command
Public bookCMD As ADODB.Command
Public borrowerCMD As ADODB.Command
Public currentCMD As ADODB.Command
Public feeCMD As ADODB.Command
Public userCMD As ADODB.Command
Public courseCMD As ADODB.Command
Public catCMD As ADODB.Command
Public SQLstr As String
Public auto As Boolean
Sub main()
frmLogin.Show
End Sub
Sub dbconnect()
Set libCON = New ADODB.Connection
libCON.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\Databases\lib_db.mdb;Persist Security Info=False"
End Sub
Mod menus
Option Explicit
26
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As Long
cch As Long
End Type
Private Type MEASUREITEMSTRUCT
CtlType As Long
CtlID As Long
ItemId As Long
ItemWidth As Long
ItemHeight As Long
ItemData As Long
End Type
Private Type DRAWITEMSTRUCT
CtlType As Long
CtlID As Long
ItemId As Long
itemAction As Long
itemState As Long
hwndItem As Long
hDC As Long
rcItem As RECT
ItemData As Long
End Type
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Type ICONINFO
27
fIcon As Long
xHotSpot As Long
yHotSpot As Long
hbmMask As Long
hbmColor As Long
End Type
28
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetGraphicsMode Lib "gdi32" (ByVal hDC As Long,
ByVal iMode As Long) As Long
Private Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
' Subclassing & Windows Message Constants
Public Const GWL_WNDPROC = (-4)
Private Const WM_DRAWITEM = &H2B
Private Const WM_MEASUREITEM = &H2C
Private Const WM_INITMENU = &H116
Private Const WM_INITMENUPOPUP = &H117
Private Const WM_ENTERIDLE = &H121
Private Const WM_MDICREATE = &H220
Private Const WM_MDIACTIVATE = &H222
Private Const WM_ENTERMENULOOP = &H211
Private Const WM_EXITMENULOOP = &H212
lMenus = MenuData(CStr(Form_hWnd)).MainMenuID
If Err Then ' then new form to subclass
29
' Initialize a collection of classes if needed
If MenuData Is Nothing Then Set MenuData = New Collection
Dim NewMenuData As New clsMyMenu
' save the ImageList & Handle to the form's menu
With NewMenuData
.SetImageViewer MenuImageList
.MainMenuID = GetMenu(Form_hWnd)
' used to redirect MDI children to parent for submenu info (see
MsgProc:MDIactivate)
.ParentForm = Form_hWnd
End With
' Add the class to the class collection & remove the instance of the new class
MenuData.Add NewMenuData, CStr(Form_hWnd)
Set NewMenuData = Nothing
Else
' form is already subclassed, do nothing!
Exit Sub
End If
Err.clear
ActiveHwnd = CStr(Form_hWnd) ' set collection index to current form
CleanMDIchildMenus
lMenus = GetMenuItemCount(MenuData(ActiveHwnd).MainMenuID)
For Looper = 0 To lMenus - 1
'GetMenuMetrics GetSubMenu(MenuData(ActiveHwnd).MainMenuID, Looper)
Next
SetFreeWindow True ' hook the window so we can intercept windows
messages
End Sub
30
If MenuData.Count = 0 Then
' here we clean up a little when all subclassed forms have been unloaded
Set MenuData = Nothing ' erase the collection of classes which will unload the
class
DestroyMenuFont ' get rid of memory font
modDrawing.TargethDC = 0 ' get rid of refrence in that module
End If
ByPassRelease:
End Sub
'
=============================================================
========
' Here we determine which messages will be processed, relayed or
' skipped. Basically, we send anything thru unless we are measuring
' or drawing an item.
'
=============================================================
========
31
' this will prevent unnecessary reads each time the submenu is displayed
Set VisibleMenus = New Collection
Case WM_MDIACTIVATE
'Debug.Print "MDI child created"
' MDI children get their menus subclassed to the parent by Windows
' We set the class's parentform value to the MDI's parent & when
' submenus are processed, they are redirected to the parent
' The ChildStatus is set to clean out the parent's class when the
' child window is closed
' The GetSetMDIchildSysMenu command is run to store the system menu
' with the parent form. When the child is maximized its system menu
' shows up on the parent form & needs to be compared so the class
' doesn't draw for the system menu which it can't do!
MenuData(ActiveHwnd).ParentForm = GetParent(GetParent(hwnd))
MenuData(CStr(MenuData(ActiveHwnd).ParentForm)).GetSetMDIchildSysMen
u GetSystemMenu(hwnd, False), True
MenuData(ActiveHwnd).ChildStatus = 1
Case WM_MEASUREITEM
'Debug.Print "measuring"
' occurs after menu initialized & before drawing takes place
' send to drawing routine to measure the height/width of the menu panel
' If we measured it, don't let windows measure it again
If CustomDrawMenu(wMsg, lParam, wParam) = True Then Exit Function
Case WM_INITMENUPOPUP ', WM_INITMENU
If wParam = 0 Then Err.Raise 5 ' ignore these messages & pass them thru
'Debug.Print "Popup starts"
' Occurs each time a menu is about to be displayed, wMsg is the handle
' Send flag to drawing routine to allow icons to be redrawn
CustomDrawMenu wMsg, 0, 0
GetMenuMetrics wParam ' get measurements for menu items
' allow message to pass to the destintation
Case WM_DRAWITEM
'Debug.Print "drawing"
' sent numerous times, just about every time the mouse moves
' over the menu. Send flag to redraw menu if needed
' If we drew it, don't let windows redraw it
If CustomDrawMenu(wMsg, lParam, wParam) = True Then Exit Function
Case WM_EXITMENULOOP
'Debug.Print "exiting loop"
' When a menu is clicked on or closed, we remove the collection of submenus
' so they can be redrawn again as needed
Set VisibleMenus = Nothing
Case WM_ENTERIDLE
'Debug.Print "Popup ends"
' occurs after the entire menu has been measured & displayed
' at least once. Send flag to not redraw icons
CustomDrawMenu wMsg, 0, 0
End Select
SendMessageAsIs:
32
MsgProc = CallWindowProc(MenuData(ActiveHwnd).OldWinProc, hwnd, wMsg,
wParam, lParam)
End Function
33
If MenuData(ActiveHwnd).GetSetMDIchildSysMenu(hSubMenu, False) = True Then
Exit Sub
If Not VisibleMenus Is Nothing Then
' here we track which submenus are currently visible so we don't
' re-process data which isn't needed until after the submenu is closed
lMenus = VisibleMenus(CStr(hSubMenu))
If lMenus Then Exit Sub
End If
On Error GoTo 0
meDC = GetDC(CLng(ActiveHwnd))
hWndRedirect = MenuData(ActiveHwnd).ParentForm
' Get the ID for the next submenu item
lMenus = GetMenuItemCount(hSubMenu)
lSubMenu = hSubMenu
modDrawing.TargethDC = meDC
DetermineOS
With MenuData(hWndRedirect) ' class for this form
For Looper = 0 To lMenus - 1 ' loop thru each subitem
' get the submenu item
bSpecialSeparator = False
iSeparator = 0: iTransparency = 0
sHotKey = ""
' now set some flags & stuff to return the caption, checked & enabled status
' by referencing the dwTypeData as a byte array vs long or string,
' we bypass the VB crash that happens on Win98 & XP & probably others
ReDim mI(0 To 255)
mII.cbSize = Len(mII)
mII.fMask = &H10 Or &H1 Or &H2
mII.fType = 0
mII.dwTypeData = VarPtr(mI(0))
mII.cch = UBound(mI)
' get the submenu item information
GetMenuItemInfo hSubMenu, Looper, True, mII
'Debug.Print lmnuID; "has submenus"; mII.hSubMenu
If Abs(mII.wID) = 4096 Or mII.wID = -1 Then Exit Sub
lmnuID = mII.wID
bNewItem = .SetMenuID(lmnuID, hSubMenu, False, True)
sCaption = Left$(StrConv(mI, vbUnicode), mII.cch)
If Len(Replace$(sCaption, Chr$(0), "")) = 0 Then sCaption = .OriginalCaption
If Left(UCase(sCaption), 9) = "{SIDEBAR:" Then sBarCaption = sCaption
'Debug.Print hWndRedirect; hSubMenu; lmnuID; " Caption: "; sCaption
If .OriginalCaption = sCaption And bNewItem = False Then
' here we can get cached info vs reprocessing it again
lMetrics(1) = lMetrics(1) + .ItemHeight
lMetrics(10) = .ItemWidth
If LoWord(lMetrics(10)) > lMetrics(0) Then lMetrics(0) =
LoWord(lMetrics(10))
If HiWord(lMetrics(10)) > lMetrics(9) Then lMetrics(9) =
HiWord(lMetrics(10))
lMetrics(4) = .SideBarWidth
34
If .Icon <> 0 Then bHasIcon = True
If InStr(sCaption, Chr$(9)) Then bTabOffset = True
'Debug.Print "reading existing " & Looper + 1, sCaption
Else
bNewItem = True
If Len(sBarCaption) > 0 And bRecalcSideBar = 0 Then bRecalcSideBar =
lmnuID
.OriginalCaption = sCaption
.Status = 0
' new item or change in caption, let's get some measurements
' first extract the caption, controlkeys & icon
If InStr(sCaption, Chr$(9)) Then bTabOffset = True
' when Win98 encounters a hotkey above, it automatically
' increases the menu panel width. We need to note that
' so we can decrease the panel widh appropriately and
' offset the automatic increase. This helps prevent extra
' wide menu panels
If Left(UCase(sCaption), 9) = "{SIDEBAR:" Then
iSeparator = 1
.Status = .Status Or 16
.ItemHeight = 0
.ItemWidth = 0
.Icon = 0
Else
'Debug.Print "Caption "; sCaption
FindImageAndHotKey hWndRedirect, sCaption, iTransparency, sHotKey,
IconID
Debug.Print "iconid="; IconID
' identify whether or not this is a separator
iSeparator = Abs(CInt(Len(sCaption) = 0 Or Left$(sCaption, 1) = "-"))
If iSeparator = 0 Then iSeparator = Abs(CInt(mII.fType And
MF_SEPARATOR) = MF_SEPARATOR)
If iSeparator Then IconID = 0 ' no pictures on separator bars!
If Len(sCaption) > 0 And iSeparator = 1 Then
' separator bar with text
' calculate entire caption & set a few flags
sCaption = Mid$(sCaption, 2) & " " & sHotKey
bSpecialSeparator = True
sHotKey = "" ' not used for separators
End If
' start saving the information
.Caption = Trim$(sCaption & " " & sHotKey)
.Icon = IconID
.Status = .Status Or iTransparency * 4
.Status = .Status Or iSeparator * 2
If IconID Then bHasIcon = True
SetMenuFont True, , bSpecialSeparator ' add smaller menu font
' measure the caption width to help identify how wide
' the menu panel should be (greatest width of all submenu items)
35
DrawText meDC, sCaption, Len(sCaption), tRect, DT_CALCRECT Or
DT_LEFT Or DT_SINGLELINE Or DT_NOCLIP
' keep track of the largest width, this will be used to
' left align control keys for the entire panel
If tRect.Right > lMetrics(0) Then lMetrics(0) = tRect.Right
lMetrics(10) = tRect.Right
If iSeparator = 0 Or bSpecialSeparator = True Then
' set min height text menu items to match 16x16 icon height
If tRect.Bottom < 10 And bSpecialSeparator = False Then tRect.Bottom
= 10
tRect.Bottom = tRect.Bottom + 6
Else
tRect.Bottom = 5 ' make default separators 0 height
End If
' store the height of the caption text
.ItemHeight = tRect.Bottom
lMetrics(1) = lMetrics(1) + tRect.Bottom
SetMenuFont False
If Len(sHotKey) Then
.HotKeyPos = Len(sCaption) + 1
' now do the same for the hotkey
DrawText meDC, Trim(sHotKey), Len(Trim(sHotKey)), tRect,
DT_CALCRECT Or DT_LEFT Or DT_NOCLIP Or DT_SINGLELINE
' keep track of the widest control key text
' this is used w/widest caption to determine overall
' panel width including icons & checkmarks. Add 12 pixels for
' buffer between end of caption & beginning of control key
If tRect.Right > lMetrics(9) Then lMetrics(9) = tRect.Right
.ItemWidth = MakeLong(CInt(lMetrics(10)), CInt(tRect.Right))
Else
.ItemWidth = MakeLong(CInt(lMetrics(10)), 0)
End If
End If
End If
' we ensure the item is drawn by us
' force a separator status if appropriate
mII.fMask = 0
If mII.fType = MF_SEPARATOR Or iSeparator = 1 Then
mII.fType = MF_SEPARATOR Or MF_OWNERDRAW
Else ' otherwise it's normal
mII.fType = mII.fType Or MF_OWNERDRAW
End If
mII.fMask = mII.fMask Or MIIM_TYPE Or MIIM_DATA ' reset mask
' save updates to allow us to draw the menu item
SetMenuItemInfo hSubMenu, Looper, True, mII
Next
If Looper > 0 Then ' menu items processed
If bRecalcSideBar = 0 Then ' sidebar menu id
' if no sidebar was processed, then check the overall panel height
' if it changed, we need to reprocess the sidebar again since
36
' the graphics & text are centered in the panel
If .PanelHeight <> lMetrics(1) And .SideBarItem <> 0 Then bRecalcSideBar
= lmnuID
End If
lMetrics(3) = 5 + Abs(CInt(bHasIcon)) * 18
lMetrics(2) = lMetrics(0) + 12
lMetrics(0) = lMetrics(2) + lMetrics(9) + lMetrics(3) + lMetrics(4) +
CInt(bTabOffset) * iTabOffset
If bRecalcSideBar Then
.SetMenuID bRecalcSideBar, hSubMenu, False, False
ReturnSideBarInfo hWndRedirect, sBarCaption, lMetrics(), meDC
End If
.UpdatePanelID lMetrics(), sBarCaption, (bRecalcSideBar = 0)
End If
End With
If Not VisibleMenus Is Nothing Then VisibleMenus.Add 1, (CStr(hSubMenu))
' now we replace the default font & release the form's DC
SetMenuFont False, meDC
ReleaseDC CLng(ActiveHwnd), meDC
Erase lMetrics
Erase mI
End Sub
37
' N=never user transparency
' default: Icons never use transparency, Bitmaps always
If InStr(sHeader, "|Y}") Then imgTransparency = 1
If InStr(sHeader, "|N}") Then imgTransparency = 2
End If
End If
End If
' Parse the Caption & the Control Key
sAccel = ""
' First let's see if it's a menu builder supplied control key
' if so, it's easy to identify 'cause it is preceeded by a vbTab
i = InStr(sKey, Chr$(9))
If i Then ' yep, menu builder supplied control key
sAccel = Trim$(Mid$(sKey, i + 1))
sKey = Trim$(Left$(sKey, i - 1))
Else
' user supplied control key, a little more difficult to find
For i = 1 To 3 ' look for Ctrl, Alt & Shift combinations 1st
If InStr(UCase(sKey), Choose(i, "CTRL+", "SHIFT+", "ALT+")) Then
' if found, then exit routine
sAccel = Trim$(Mid$(sKey, InStr(UCase(sKey), Choose(i, "CTRL+",
"SHIFT+", "ALT+"))))
sKey = Trim$(Left$(sKey, InStr(UCase(sKey), Choose(i, "CTRL+",
"SHIFT+", "ALT+")) - 1))
Exit Sub
End If
Next
For i = 1 To 15 ' look for F keys next
If Right$(UCase(sKey), Len("F" & i)) = "F" & i Then
' if found, then exit routine
sAccel = Trim$(Mid$(sKey, InStrRev(UCase(sKey), "F" & i)))
sKey = Trim$(Left$(sKey, InStrRev(UCase(sKey), UCase(sAccel)) - 1))
Exit Sub
End If
Next
' here we look for other types of hot keys, these can be customized
' as needed by following the logic below
For i = 1 To 6
' hot key looking for, it will be preceded by a space and must
' be at end of caption, otherwise we ignore it
sSpecial = Choose(i, " DEL", " INS", " HOME", " END", " PGUP", " PGDN")
If Right$(UCase(sKey), Len(sSpecial)) = sSpecial Then
sAccel = Trim$(Mid$(sKey, InStrRev(UCase(sKey), sSpecial)))
sKey = Trim$(Left$(sKey, InStrRev(UCase(sKey), sSpecial) - 1))
Exit For
End If
Next
End If
End Sub
38
Private Sub ReturnSideBarInfo(hWndRedirect As String, sBarInfo As String,
vBarInfo() As Long, tDC As Long)
'
=============================================================
==========
' This routine returns the sidebar information for the current submenu
' Basically we are parsing out the SIDEBAR caption
'
=============================================================
==========
' here we are just adding a delimeter at end of string to make parsing easier
If Right$(sBarInfo, 1) = "}" Then sBarInfo = Left$(sBarInfo, Len(sBarInfo) - 1)
sBarInfo = sBarInfo & "|"
' stripoff the SIDEBAR header
i = InStr(UCase(sBarInfo), "{SIDEBAR:")
sBarInfo = Mid$(sBarInfo, InStr(sBarInfo, ":") + 1)
' return the type of sidebar Image or Text
i = InStr(sBarInfo, "|")
' if the next line <> TEXT then we have an image handle or image control
sImgID = Left$(sBarInfo, i - 1)
39
vBarInfo(10) = Val(sImgID) ' ref to picture if it exists
sbarType = 2 ' status: image sidebar
vBarInfo(9) = 8 ' type default as bmp
Else
If sImgID = "TEXT" Then
sbarType = 4 ' status: text sidebar
vBarInfo(9) = 0
If InStr(UCase(sBarInfo), "|CAPTION:") Then
sText = Mid$(sBarInfo, InStr(UCase(sBarInfo), "|CAPTION:") + 9)
i = InStr(sText, "|")
sText = Left$(sText, i - 1)
End If
sBarInfo = UCase(sBarInfo) ' make it easier to parse
If InStr(sBarInfo, "|FONT:") Then
' parse out the font
sTmp = Mid$(sBarInfo, InStr(sBarInfo, "|FONT:") + 6)
i = InStr(sTmp, "|")
sTmp = Left$(sTmp, i - 1)
Else
sTmp = "Arial" ' default if not provided
End If
lFontM.lfCharSet = 0 ' scalable only
lFontM.lfFaceName = sTmp
' if user wants other font attributes, then make it so
If InStr(sBarInfo, "|BOLD") Then sTmp = sTmp & " Bold"
If InStr(sBarInfo, "|ITALIC") Then sTmp = sTmp & " Italic"
lFontM.lfFaceName = sTmp & Chr$(0)
If InStr(sBarInfo, "|UNDERLINE") Then lFontM.lfUnderline = 1
' if user wants a different fontsize then make it so
If InStr(sBarInfo, "|FSIZE:") Then
i = Val(Mid$(sBarInfo, InStr(sBarInfo, "|FSIZE:") + 7))
If i < 4 Then i = 12 ' min & max fonts
If i > 24 Then i = 24
Else
i = 12 ' default font size
End If
Do
' here we are going to create fonts to see if it will
' fit in the sidebar, unfortunately we need to do this
' each time the menubar is initially displayed or resized because
' the sidebar height may have changed with adding/removing
' or making menu items invisible
lFontM.lfHeight = (i * -20) / Screen.TwipsPerPixelY
' can't rotate the font before measuring it - per MSDN drawtext won't measure
rotated fonts
lFont = CreateFontIndirect(lFontM) ' create the font without rotation
hPrevFont = SelectObject(tDC, lFont) ' load it into the DC
' see if it will fit in the sidebar
DrawText tDC, sText, Len(sText), tRect, DT_CALCRECT Or DT_LEFT Or
DT_SINGLELINE Or DT_NOCLIP Or &H800
40
' regardless we delete the font, cause we'll need to rotate it
SelectObject tDC, hPrevFont
DeleteObject lFont
If tRect.Right > vBarInfo(1) Or tRect.Bottom > vBarInfo(4) Then
' font is too big, reduce it by 1 and try again
i=i-1
If i < 4 Then Exit Do
Else ' font is ok, now we rotate it & save it
lFontM.lfEscapement = 900
lFont = CreateFontIndirect(lFontM) ' create the font
vBarInfo(10) = lFont ' save it
vBarInfo(8) = tRect.Right ' measurements
vBarInfo(5) = tRect.Bottom
Exit Do
End If
Loop
Else
' here we have an image/picturebox control containing an image
' we need to extract the image handle
Dim formID As Long, vControl As Control, bIsMDI As Boolean
' loop thru each open form to determine which is the active
formID = GetFormHandle(CLng(hWndRedirect), bIsMDI)
If formID > -1 Then
sbarType = 2 'status: image sidebar
' let's see if the control passed is indexed
If Right$(sImgID, 1) = ")" Then ' indexed image
i = InStrRev(sImgID, "(")
sTmp = Left$(sImgID, i - 1)
i = Val(Mid$(sImgID, i + 1))
If bIsMDI Then
If Forms(formID).ActiveForm Is Nothing Then
Set vControl = Forms(formID).Controls(sTmp).Item(i)
Else
' when control is in an MDIs active form, we reference it this way
Set vControl = Forms(formID).ActiveForm.Controls(sTmp).Item(i)
End If
Else
Set vControl = Forms(formID).Controls(sTmp).Item(i)
End If
Else
If bIsMDI Then
If Forms(formID).ActiveForm Is Nothing Then
Set vControl = Forms(formID).Controls(sImgID)
Else
' when control is in an MDIs active form, we reference it this way
Set vControl = Forms(formID).ActiveForm.Controls(sImgID)
End If
Else
Set vControl = Forms(formID).Controls(sImgID)
End If
41
End If
' cache the picture handle & type
vBarInfo(10) = vControl.Picture.Handle
If vControl.Picture.Type = 3 Then vBarInfo(9) = 16 Else vBarInfo(9) = 8
Set vControl = Nothing
End If
End If
End If
If vBarInfo(10) = 0 Then
'failed retrieving sidebar information
Debug.Print "Sidebar failed"
vBarInfo(4) = 0
Exit Sub
End If
sBarInfo = UCase(sBarInfo) ' make it easier to parse
'ok, let's get the rest of the attributes
If InStr(sBarInfo, "|BCOLOR:") Then
' Background color for the sidebar
Select Case Left$(Mid$(sBarInfo, InStr(sBarInfo, "|BCOLOR:") + 8), 4)
Case "NONE": vBarInfo(6) = -1
Case "BACK": ' short for background
' if a text sidebar & background was provided we change to default
If sbarType = 2 Then vBarInfo(6) = -2 Else vBarInfo(6) = -1
Case Else ' numeric background color -- use it
vBarInfo(6) = Val(Mid$(sBarInfo, InStr(sBarInfo, "|BCOLOR:") + 8))
End Select
Else
vBarInfo(6) = -1 ' default: use the menubar background color
End If
If vBarInfo(6) = -1 Then vBarInfo(6) = GetSysColor(COLOR_MENU)
If vBarInfo(10) Then
If sbarType = 2 Then
' now if an image sidebar, we call subroutine for more attributes
GoSub DrawPicture
' let's get the size of the image vs the size of the menu panel &
' either center or shrink the image to fit
' we will return the left offset, top offset & new image width, height
If vBarInfo(5) > vBarInfo(4) Or vBarInfo(8) > vBarInfo(1) Then ' image is
larger than menu panel
If vBarInfo(5) / vBarInfo(4) > vBarInfo(8) / vBarInfo(1) Then
lRatio = vBarInfo(4) / vBarInfo(5)
Else
lRatio = vBarInfo(1) / vBarInfo(8)
End If
vBarInfo(5) = CInt(vBarInfo(5) * lRatio)
vBarInfo(8) = CInt(vBarInfo(8) * lRatio)
End If
vBarInfo(7) = MakeLong(CInt(vBarInfo(5)), CInt(vBarInfo(8)))
' save the left & top offsets for the image, this way we don't have
' to remeasure when the menu is being displayed.
42
vBarInfo(5) = MakeLong((vBarInfo(4) - vBarInfo(5)) \ 2, (vBarInfo(1) -
vBarInfo(8)) \ 2)
Else
' if user want's gradient background for text sidebar then
If InStr(sBarInfo, "|GRADIENT") > 0 And sbarType = 4 Then vBarInfo(9) =
vBarInfo(9) Or 32
' text sidebar, let's get the forecolor of the text & black is default
If InStr(sBarInfo, "|FCOLOR:") Then
vBarInfo(7) = Val(Mid$(sBarInfo, InStr(sBarInfo, "|FCOLOR:") + 8))
If vBarInfo(7) < 0 Then vBarInfo(7) = 0
Else
vBarInfo(7) = 0
End If
vBarInfo(5) = MakeLong(CInt(vBarInfo(5)), CInt(vBarInfo(8)))
End If
End If
vBarInfo(9) = sbarType Or vBarInfo(9)
vBarInfo(0) = vBarInfo(0) + vBarInfo(4)
'Debug.Print "font?"; (vBarInfo(9) And 4) = 4; vBarInfo(10)
sBarInfo = sText
Exit Sub
DrawPicture:
' this routine is used when....
' 1. When we need the background color for a mask
' 2. Image passed is a control to get height/width values
'Get the info about our image
If GetObject(vBarInfo(10), Len(imgInfo), imgInfo) = 0 Then 'And vControl Is
Nothing Then
GetIconInfo vBarInfo(10), picInfo
If picInfo.xHotSpot = 0 Or picInfo.yHotSpot = 0 Then
'if the image passed was a handle vs control and not a bitmap
' sidebar fails
Debug.Print "Sidebar failed image is not a bitmap or icon type"
vBarInfo(10) = 0
vBarInfo(4) = 0
Return
End If
vBarInfo(9) = 16
vBarInfo(5) = picInfo.xHotSpot
vBarInfo(8) = picInfo.yHotSpot
Else
vBarInfo(9) = 8
vBarInfo(5) = imgInfo.bmWidth
vBarInfo(8) = imgInfo.bmHeight
End If
Err.clear
If vBarInfo(6) = -2 Then
Dim picIcon As PictureBox
Forms(formID).Controls.Add "VB.PictureBox", "pic___Ic_on_s", Forms(formID)
43
With Forms(formID).Controls("pic___Ic_on_s")
.Visible = False
.AutoRedraw = True
If vBarInfo(6) = -2 Then
If vBarInfo(9) = 8 Then i = 4 Else i = 3
' draw the image to the picturebox
If DrawState(.hDC, 0, 0, vBarInfo(10), 0, 0, 0, 0, 0, CLng(i)) = 0 Then
' drawing failed, try again with differnt picture type
If i = 4 Then i = 3 Else i = 4
DrawState .hDC, 0, 0, vBarInfo(10), 0, 0, 0, 0, 0, CLng(i)
End If
' get the mask color
vBarInfo(6) = GetPixel(.hDC, 0, 0)
End If
End With
Forms(formID).Controls.Remove "pic___Ic_on_s"
End If
Return
End Sub
44
' in the form's related class
'
=============================================================
========
45
bMenuItemDisabled = CBool((DrawInfo.itemState And 6) = 6 Or
(DrawInfo.itemState And 7) = 7)
' don't continue the process if the disabled item or separator
' was already drawn, no need to redraw it again - it doesn't change
If bDrawIcon = False And (bMenuItemDisabled = True Or IsSep = True) Then Exit
Function
bMenuItemChecked = CBool((DrawInfo.itemState And 8) = 8 Or
(DrawInfo.itemState And 9) = 9)
' set a reference in the drawing module to this menu's DC & set the font
modDrawing.TargethDC = DrawInfo.hDC
If bDrawPanel = True Or lLastSubMenu <> DrawInfo.hwndItem Then
Dim pData(0 To 10) As Long
MenuData(hWndRedirect).GetPanelInformation pData(), sCaption
lOffsets(2) = pData(3)
If lOffsets(2) Then lOffsets(2) = lOffsets(2) + 5
lOffsets(1) = pData(4)
If pData(4) Then lOffsets(1) = lOffsets(1) + 3
lOffsets(0) = lOffsets(1) + lOffsets(2)
If bDrawPanel = True Then
If pData(10) <> 0 Then
Debug.Print "panel xy:"; pData(4), pData(1)
tRect.Bottom = pData(1)
tRect.Right = pData(4)
hBR = CreateSolidBrush(pData(6))
hPen = GetPen(1, pData(6))
hOldPen = SelectObject(DrawInfo.hDC, hPen)
hOldBr = SelectObject(DrawInfo.hDC, hBR)
DrawRect 0, 0, tRect.Right, tRect.Bottom
SelectObject DrawInfo.hDC, hOldBr
DeleteObject hBR
SelectObject DrawInfo.hDC, hOldPen
DeleteObject hPen
pData(8) = CLng(HiWord(pData(5)))
pData(5) = CLng(LoWord(pData(5)))
If (pData(9) And 2) = 2 Then
modDrawing.TargethDC = DrawInfo.hDC
DrawMenuIcon pData(10), Abs(CInt((pData(9) Or 16) = 16) * 2) + 1, _
tRect, False, , 2, CInt(pData(5)), CInt(pData(8)), LoWord(pData(7)),
HiWord(pData(7)), pData(6)
Else
SetBkMode DrawInfo.hDC, NEWTRANSPARENT
DetermineOS DrawInfo.hDC
If (pData(9) And 32) = 32 Then DoGradientBkg pData(6), tRect,
CLng(hWndRedirect)
SetMenuFont True, , , pData(10)
tRect.Left = (pData(4) - pData(5)) \ 2
tRect.Top = (pData(1) - pData(8)) \ 2 + pData(8)
SetTextColor DrawInfo.hDC, pData(7)
DrawText DrawInfo.hDC, sCaption, Len(sCaption), tRect, DT_LEFT Or
DT_NOCLIP Or DT_SINGLELINE Or &H800
46
SetMenuFont False
End If
End If
End If
bDrawPanel = False
lLastSubMenu = DrawInfo.hwndItem
Erase pData
End If
If IsSideBar Then
CustomDrawMenu = True
Exit Function
End If
SetMenuFont True
' determine if this item is focused or not which also determines
' what colors we use when we are drawing
bSelected = (DrawInfo.itemState And ODS_SELECTED) = ODS_SELECTED
' Now let's set some colors to draw with
With DrawInfo
If bSelected = True And bMenuItemDisabled = False And IsSep = False Then
hBR = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT))
hPen = GetPen(1, GetSysColor(COLOR_HIGHLIGHT))
lTextColor = GetSysColor(COLOR_HIGHLIGHTTEXT)
Else
hBR = CreateSolidBrush(GetSysColor(COLOR_MENU))
hPen = GetPen(1, GetSysColor(COLOR_MENU))
If bMenuItemDisabled Or IsSep = True Then
lTextColor = GetSysColor(COLOR_HIGHLIGHTTEXT)
Else
lTextColor = GetSysColor(COLOR_MENUTEXT)
End If
End If
If bMenuItemDisabled = True Then
' for checked & disabled items, we use default back color
hChkBr = CreateSolidBrush(GetSysColor(COLOR_MENU))
Else
' here we set the back color of a depressed button
hChkBr = CreateSolidBrush(GetSysColor(COLOR_BTNLIGHT))
End If
'Select our new, correctly colored objects:
hOldBr = SelectObject(.hDC, hBR)
hOldPen = SelectObject(.hDC, hPen)
'Do we have a separator bar?
bHasIcon = False
sCaption = MenuData(hWndRedirect).Caption
If Not IsSep Then
' Ok, does this item have an icon?
' Here we do one more extra check in case the ImageViewer
' is no longer available or has no images (then handle is 0)
' we also set the offset for highlighting rectangle's left
' edge so it doesn't highlight icons
47
If MenuData(hWndRedirect).ImageViewer > 0 And _
MenuData(hWndRedirect).Icon > 0 Then
bHasIcon = True
iRectOffset = lOffsets(0) - 2
Else
'If bMenuItemChecked Then
' iRectOffset = lOffsets(0) - 2
'Else
iRectOffset = lOffsets(1)
'End If
End If
'Draw the highlighting rectangle
DrawRect .rcItem.Left + iRectOffset, .rcItem.Top, .rcItem.Right,
.rcItem.Bottom
'Print the menu item's text
If MenuData(hWndRedirect).HotKeyPos Then
' we have a control key, so identify it & its left edge
sAccelKey = Mid$(sCaption, MenuData(hWndRedirect).HotKeyPos)
sCaption = Left$(sCaption, InStr(sCaption, sAccelKey))
End If
' send the caption, control key, icon offset, etc to be printed
tRect = .rcItem
DrawCaption .rcItem.Left + lOffsets(0), .rcItem.Top + 3, _
tRect, sCaption, sAccelKey, MenuData(hWndRedirect).HotKeyEdge,
lTextColor
If bMenuItemDisabled Then ' add the engraved affect
tRect = .rcItem ' get starting rectangle &
OffsetRect tRect, -1, -1 ' offset by 1 top & left
' print text again with offsets
DrawCaption .rcItem.Left + lOffsets(0) - 1, .rcItem.Top + 2, _
tRect, sCaption, sAccelKey, MenuData(hWndRedirect).HotKeyEdge, _
GetSysColor(COLOR_GRAYTEXT)
End If
If bMenuItemChecked Then
' for checked items, since they can have icons, we do a few
' things different. We make the checked item appear in a sunken
' box and make the backcolor of the box lighter than normal
SelectObject .hDC, hChkBr
DrawRect lOffsets(1), .rcItem.Top, lOffsets(0) - 5, .rcItem.Bottom - 1
ThreeDbox lOffsets(1) - 2, .rcItem.Top, lOffsets(0) - 3, .rcItem.Bottom - 2,
True, True
If bHasIcon = False Then
' now if the checked item doesn't have an icon we draw a checkmark in
the icons' place
DrawCheckMark .rcItem, IIf(bMenuItemDisabled, lTextColor,
GetSysColor(COLOR_MENUTEXT)), False, lOffsets(1)
If bMenuItemDisabled Then DrawCheckMark .rcItem,
GetSysColor(COLOR_GRAYTEXT), bMenuItemDisabled, lOffsets(1)
End If
End If
48
End If
'If the item has an icon, selected or not, disabled or not
If bHasIcon = True Then
If bDrawIcon = True Or bMenuItemChecked = True Then ' we are redrawing
icons
' extract icon handle, type & transparency option
Dim vIconDat() As Long
MenuData(hWndRedirect).GetIconData vIconDat(),
MenuData(hWndRedirect).Icon
'set up the location to be drawn
tRect.Left = 4 + lOffsets(1)
tRect.Top = ((.rcItem.Bottom - .rcItem.Top) - 16) \ 2 + .rcItem.Top
tRect.Right = tRect.Left + 16
tRect.Bottom = tRect.Top + 16
'send the icon information to be drawn
DrawMenuIcon vIconDat(0), vIconDat(1), tRect, bMenuItemDisabled,
True, vIconDat(2)
End If
SelectObject .hDC, hBR
If bMenuItemDisabled = False And bMenuItemChecked = False Then
' here we draw or remove the 3D box around the icon
ThreeDbox lOffsets(1), .rcItem.Top, lOffsets(0) - 5, .rcItem.Bottom - 1,
bSelected
End If
End If
If IsSep Then
'Finally, draw the special separator bar if needed
' however, if the separator has text, then we need to do
' some additional calculations
If Len(sCaption) Then
' separator bars with text
SetMenuFont True, , True ' use smaller font
tRect = .rcItem ' copy the menuitem coords
' send caption to be printed in menu-select color
' of course any color can be used & if you want to use the
' standard 3D gray disabled color then Rem out the next line
' and un-rem the next 3 lines & the second DrawCapton line
DrawCaption .rcItem.Left, .rcItem.Top + 3, tRect, sCaption, "", 0,
GetSysColor(COLOR_HIGHLIGHT), True, CInt(lOffsets(1))
'DrawCaption .rcItem.Left, .rcItem.Top + 3, tRect, sCaption, "", 0,
lTextColor, True
'tRect = .rcItem ' recopy menuitem coords
'OffsetRect tRect, -1, -1 ' move coords up & left by 1
' send caption again in gray
'DrawCaption .rcItem.Left - 1, .rcItem.Top + 2, tRect, sCaption, "", 0,
GetSysColor(COLOR_GRAYTEXT), True
If bMenuItemChecked = False Then
' here we add the lines on both sides of the separator caption
ThreeDbox 4 + lOffsets(1), _
(.rcItem.Bottom - .rcItem.Top) \ 2 + .rcItem.Top, _
49
tRect.Left - 4, _
(.rcItem.Bottom - .rcItem.Top) \ 2 + 1 + .rcItem.Top, True
ThreeDbox tRect.Right + 4, _
(.rcItem.Bottom - .rcItem.Top) \ 2 + .rcItem.Top, _
.rcItem.Right - 4, _
(.rcItem.Bottom - .rcItem.Top) \ 2 + 1 + .rcItem.Top, True
End If
Else
' This will remove or add a 3D raised box for checked/non-checked items
If bMenuItemChecked = False Then ThreeDbox lOffsets(1) + .rcItem.Left,
.rcItem.Top + 2, .rcItem.Right - 4 + lOffsets(1), .rcItem.Bottom - 2, True
End If
End If
'Select the old objects into the menu's DC
Call SelectObject(.hDC, hOldBr)
Call SelectObject(.hDC, hOldPen)
'Delete the ones we created
Call DeleteObject(hBR)
Call DeleteObject(hPen)
Call DeleteObject(hChkBr)
SetMenuFont False
End With
CustomDrawMenu = True ' set flag to prevent resending to form
Case WM_MEASUREITEM
Dim MeasureInfo As MEASUREITEMSTRUCT
'Get the MEASUREITEM info, basically submenu item height/width
Call CopyMemory(MeasureInfo, ByVal lParam, Len(MeasureInfo))
' only process menu items, other windows items send above message
' and we don't want to interfere with those. Also if we didn't
' process it, we don't touch it
If MenuData(hWndRedirect).SetMenuID(MeasureInfo.ItemId, lSubMenu, False,
False) = False Then Exit Function
If MeasureInfo.CtlType <> ODT_MENU Then Exit Function
IsSep = (((MenuData(hWndRedirect).Status And 2) = 2) And (Not
MenuData(hWndRedirect).Status And 16) = 16)
'Tell Windows how big our items are.
' add height of each item, add a buffer of 3 pixels top/bottom for text
MeasureInfo.ItemHeight = MenuData(hWndRedirect).ItemHeight
MeasureInfo.ItemWidth = MenuData(hWndRedirect).PanelWidth
'Return the information back to Windows
Call CopyMemory(ByVal lParam, MeasureInfo, Len(MeasureInfo))
CustomDrawMenu = True
Case WM_ENTERIDLE ' done displaying panel, let's stop drawing icons
bDrawIcon = False
End Select
End Function
50
'
=============================================================
========
' Returns the high integer of a long variable
'
=============================================================
========
Call CopyMemory(HiWord, ByVal VarPtr(LongIn) + 2, 2)
End Function
' The following are the platform, major version & minor version of OS to date
(acquired from MSDN)
Const os_Win95 = "1.4.0"
Const os_Win98 = "1.4.10"
Const os_WinNT4 = "2.4.0"
51
Const os_WinNT351 = "2.3.51"
Const os_Win2K = "2.5.0"
Const os_WinME = "1.4.90"
Const os_WinXP = "2.5.1"
'1. Each form that is subclassing menus must have the 2 lines of code entered into the
events shown below. The imagelist
'name is optional and must be provided if icons are to be displayed. Any loaded
form's imagelist can be used.
' MDI forms: If you are using MDI forms, if a child or parent is being subclassed,
' you must subclass each child and the parent. Additionally, the MDI children use the
52
' imagelist on the MDI form and MDI children do not reference the imagelist when
' the SetMenus command is called. All subclassed forms call the ReleaseMenus on
form unload.
' a. Form_Load: the last statement in this event should be: SetMenus [form
handle (.hWnd)] , [ImageList Name for Icons]
' -- for MDI children: SetMenus [form handle (.hWnd)] << uses the parent MDI
form's imagelist
' b. Form_Unload: the 1st statement in this event should be: ReleaseMenus [form
handle (.hWnd)]
'2. DO NOT place breaks in the code when menus are subclassed or stop the code
when menus are subclassed.
'Doing so will crash VB. If you need to debug your code, set the public constant
bAmDebugging=True within the
'modModules module. This will prevent menus from being subclassed and will also
prevent menus from displaying icons.
'Be sure to set that constant = False when you want to see the icons.
'3. Do not put END statements in any of the forms that are subclassing menus. The
End statement may fire before
'the menus are released which will cause a critical error. The class and modules are
written to release themselves
'via the ReleaseMenus command.
' a. Suggestion: Small icons (16x16) are best as far as clarity goes
' b. Suggeston: If bitmaps are used, use smaller bitmaps (16x16) vs larger bitmaps
(32x32)
' c. Add the following flag immediately in front of the menu's caption: {IMG:#}
' d. The # is the listimage icon index (1 thru n)
' e. If you want to supply a manually trapped accelerator key add that to the end of
the menu caption. See para 6.
' Example: menu caption is E&xit and image number 2 will be assigned to it and
Alt+F4 will be the
' manually trapped accelerator key
'5. Optional transparency flag. By default, icons are NOT made to be transparent
since they probably are anyway.
'However, bitmaps by default ARE made to be transparentt. When transparency is
invoked, the top left pixel
'decides which color is made transparent throughout the image. Should you want to
force an icon/bitmap to
53
'be transparent or not be transparent, add the following code after the icon index in the
caption header flag:
' Example: I have a bitmap in the imagelist which has a colored background that I
do NOT want made transparent.
' Being a bitmap, by default, it will be made transparent. So I need to add then
|N option to the menu caption:
'6. Accelerator keys. The menu builder allows you to select many accelerator keys and
will automatically trap them for you.
'With this class & modules you can add other accelerator keys not provided by the
menu builder (i.e., Alt+F4) and you
'can use the same accelerator key on more than one menu -- not allowed via the menu
builder.
' a. If you add an accelerator key manually (not via menu builder), you will need to
trap those keys in the form's Key_Down
' event by testing for KeyCode and Shift values
' c. The modules will align the accelerator keys neatly before they are displayed on
the menu.
'7. To change the caption or image of a menu after the program is running, simply
change it in VB via the Caption property.
'The module will recognize the change and change the caption and/or assign the new
icon. If you want to remove the icon
'from the menu caption, do not include the {IMG:#} header or make the icon index =
zero. Note. The menu caption when
'referenced in VB will have the {IMG:#} header in the caption, but is stripped off
when displaying the menu.
' Example: Change {IMG:5}Color Option is On to read Off whle using the
same icon
' Changet to: {IMG:5}Color Option is Off << that's it!
'8. Checkmarks and enabled/disabled menu items. The modules will draw a sunken
box for menu items that are
'checked and include the icon inside the sunken box, if one is assigned; otherwise a
checkmark is placed inside
' the sunken box. Disabled menu items are made to imitate regular disabled items to
include the icon and caption.
54
'9. Separator bars. You can add text to the separator bars. While in the menu builder,
include the hyphen/dash to
'designate the menu item as a separator and then add the text immediately after.
{IMG:#} headers will not be
'recognized on separators, nor will accelerator keys be spaced with other accelerator
keys. Separator bars,
'regardless if they have text or not, are not clickable.
' a. By default, text on separator bars are one font point lower than the system menu
font and a font type of Tahoma.
' b. The color of the text on the separator will be the same color as the color used to
highlight a menu item with the mouse.
' c. If the bAmDebugging flag is set to True, then the separator bars will not be
disabled. Nor will they look disabled.
'10. These modules do not interfere with any menu events (i.e., click events, popup
position, etc, etc, etc are not affected)
'11. These modules to not draw parent level menus. In other words, menus that have
submenus are not drawn by the
'modules -- but their submenus are. The class and modules were written to use
Windows default menu style but add
'the capability of icons to submenus. Therefore, foreground colors, fonts and
background colors are not supported
'as this would not mirror the parent level menu items.
'12. The basic premis. Provide a somewhat small class and modules that can be
added to any project to support
'icons and make the subclassing easy. Other projects available on the web will draw
entire menus but come at
'a price -- large number of classes and modules added to each project or forcing DLLs
on other users.
'13. Sidebars. These are bitmaps or text along the left edge of a menu panel.
'You can add a picture or text by following these format rules. The images on
'a sidebar will be shrunk to fit if necessary, otherwise centered into the sidebar.
'When images are shrunk, they are done proportionally, therefore, there may be
'space around the image within the sidebar. If the formatted string is incorrect,
'no sidebar will be shown.
55
' Example: {SIDEBAR:image1|BCOLOR:background}
' b. For images passed as handles. You must provide much more information
' {SIDEBAR:handle | BCOLOR:color }
' (SIDEBAR:120928|BCOLOR:background}
' The values for the tags in the above strings are as follows:
' If image is passed as a control, then the following is mandatory
' control: This is the control name with a picture property
' and must exist on the same form that is subclassing menus
' This also applies to MDI parents and children
' color: optional. Default is NONE. The color is used to fill in the space
' between the image and the sidebar when the image doesn't completely
' fill up the sidebar. Values for Color can be...
' 1. The numerical value of a color (i.e., BCOLOR:65535)
' 2. NONE. This will not fill in the space between image and sidebar
' 3. BACKGROUND. This will fill the space with the images top left pixel color
' If image is passed as a handle vs a form control, then this is mandatory:
' handle: the numerical picture.handle should be a bitmap! Icons will draw at 16x16
' c. For Text: don't use spaces except in the caption if needed. Spaces below done for
readability
' {SIDEBAR:TEXT | CAPTION:caption | FONT:fontname | FCOLOR:color |
BCOLOR:color | FSIZE:font_size}
' Optional flags can be added by preceding them with a pipe |
' BOLD, ITALIC, UNDERLINE, GRADIENT
' Example: {SIDEBAR:TEXT|CAPTION:La Volpe|FONT:Algerian|
FCOLOR:16777215|BCOLOR:255|FSIZE:12|GRADIENT}
' The values for the tags in the above string are as follows:
' caption: mandatory. The text you want displayed on the sidebar. The text font size
will be
' be 11 by default but reduced to fit the sidebar if needed
' fontname: Optional. The font to use. This font should be scalable. In other words,
' if the font size can be set as an odd number then don't use it.
' The default font will be Tahoma
' forecolor color: optional. Numerical value for the color of the text. Default is black
' backcolor color: optional. Numerical value for the back color of the sidebar.
Default is menu color
' font_size: optional. Whole number of a font size. Default is 11
' BOLD: optional. If supplied, font is bolded. Default is no bolding
' ITALIC: optional. If supplied, font is italicized. Default is no italics
' UNDERLINE: optional. If supplied, font is underlined. Default is no underlining
' GRADIENT: optional. If supplied, it is the word GRADIENT and will color the
sidebar
' in the backcolor, from black to backcolor, bottom to top.
'Suggestions? I will entertain any suggestions (always have). However, I do not plan
on making this class draw
56
'entire menus. I thought of the possibility of having icons & bitmaps on menus that
are not loaded into an
'imagelist. However, I don't immediately see why that would be necessary. If you
have a need for that
'capability, let me know -- I have already ran test code to make that happen.
End Sub
57
58
Program coding with visual
shots
Login page
59
frmmain.mnusettinguser.Enabled = True
End If
Else
frmmain.mnusettingsystem.Enabled = True
frmmain.mnusettinguser.Enabled = True
End If
If Not userRS.EOF And Not userRS.BOF Then
If txtPassword.Text <> userRS!Password Then
pwctr = pwctr + 1
If pwctr = 1 Then
MsgBox "Invalid password! You have 2 tries remaining!", vbOKOnly +
vbInformation, "Information"
txtPassword.Text = ""
txtPassword.SetFocus
End Sub
60
End Sub
61
Main page
62
Program coding for main page
63
'this code is exit button to prompt a message box b4 exiting
Debug.Print "Exit Application"
pExitApp = (MsgBox("Exit system?", clMsgbxEXITAPP, "Library") = vbYes)
End Function
End Sub
64
End Sub
65
Program coding for book catalog
Dim x, y As Integer
66
Text5.Enabled = True
Combo2.Enabled = True
Combo3.Enabled = True
End Sub
67
If Combo3.Text = "" Then
MsgBox "Complete neccessary information", vbExclamation
Combo3.SetFocus
Exit Sub
End If
68
.Close
End With
MsgBox "Book Catalog Successfully Updated!", vbInformation
End If
End If
clear
disable
Command1.Enabled = True
Command2.Enabled = False
Command2.Caption = "&SAVE"
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = True
Command6.Caption = "CL&OSE"
End Sub
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = True
Command6.Caption = "CL&OSE"
Command7.Visible = False
End If
69
End Sub
70
dbconnect
clear
disable
x=1
While x <= 10
Combo2.AddItem x
x=x+1
Wend
y = 1601
While y <= 9999
Combo3.AddItem y
y=y+1
Wend
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command7.Visible = False
End Sub
Borrowers
record
71
Program coding for borrower’s record
Private Sub clear()
Text5.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Option1.Value = False
Option2.Value = False
Combo1.Text = ""
Text4.Text = ""
MaskEdBox2.Text = "( ) - "
End Sub
72
Text4.Enabled = True
'Combo1.Enabled = True
MaskEdBox2.Enabled = True
End Sub
73
If Command2.Caption = "&SAVE" Then
Set borrowerRS = New ADODB.Recordset
SQLstr = "select borrower_id from borrower_record where borrower_id='" &
Text5.Text & "'"
borrowerRS.Open SQLstr, libCON, adOpenKeyset, adLockReadOnly
If Not borrowerRS.EOF And Not borrowerRS.BOF Then
MsgBox "Borrower ID already exist!", vbExclamation
Text5.SetFocus
Exit Sub
End If
74
!course = Combo1.Text
!Add = Text4.Text
!contact = MaskEdBox2.Text
.Update
.Close
End With
MsgBox "Borrower Record Successfully Updated!", vbInformation
End If
End If
clear
disable
Command1.Enabled = True
Command2.Enabled = False
Command2.Caption = "&SAVE"
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = True
Command6.Caption = "CL&OSE"
End Sub
Command1.Enabled = True
75
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = True
Command6.Caption = "CL&OSE"
Command7.Visible = False
End If
End Sub
76
Else
Option2.Value = True
End If
Combo1.Text = !course
Text4.Text = !Add
MaskEdBox2.Text = !contact
End With
Command3.Enabled = True
Command4.Enabled = True
End Sub
dbconnect
clear
disable
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command7.Visible = False
End Sub
77
End Sub
Finding books
This is an icon which is used to find the input data by clicking on it.
78
Public Sub SetSectionViewTitle()
End Sub
79
Private Sub Option2_Click()
If Option2.Value = True Then
Label1.Caption = "Search by Author :"
End If
End Sub
Borrowing of books
80
Program coding for borrowing of books
81
Combo1.Text = ""
DTPicker1.Value = Date
End Sub
82
bookRS.Open SQLstr, libCON, adOpenKeyset, adLockReadOnly
With bookRS
Text4.Text = !Title
xcat = !category
xedition = !Edition
xauthor = !Author
xpublisher = !Publisher
xyr_publish = !yr_publish
xavail_copy = !available_copy
End With
83
Command2.Enabled = False
End If
End If
End Sub
84
Set currentRS = New ADODB.Recordset
currentRS.Open "current_borrow", libCON, adOpenKeyset, adLockOptimistic
With currentRS
.AddNew
!access_no = Combo1.Text
!Title = Text4.Text
!category = xcat
!Edition = xedition
!Author = xauthor
!Publisher = xpublisher
!yr_publish = xyr_publish
!borrow_date = Label4.Caption
If DTPicker1.Enabled = True Then
!due_date = DTPicker1.Value
End If
!borrower_id = Text1.Text
!Name = Text2.Text
!Status = Text3.Text
.Update
.Close
End With
SetSectionView
MsgBox "Library Transaction Successfully Saved!", vbInformation
If ListView1.ListItems.Count = 3 Then
'MsgBox "Borrower reach the maximum book that can be borrowed at a
time!", vbExclamation
clear
disable
ListView1.ListItems.clear
Command1.Enabled = True
Command2.Enabled = False
Command6.Caption = "CL&OSE"
Exit Sub
End If
85
Exit Sub
End If
clear
disable
ListView1.ListItems.clear
Command1.Enabled = True
Command2.Enabled = False
Command6.Caption = "CL&OSE"
End Sub
SetSectionView
If ListView1.ListItems.Count = 3 Then
MsgBox "Borrower Already Borrowed 3 Books!", vbExclamation
clear
ListView1.ListItems.clear
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "Faculty / Employee" Then
DTPicker1.Enabled = False
Else
86
DTPicker1.Enabled = True
End If
Combo1.Enabled = True
Combo1.SetFocus
Text1.Enabled = False
Command7.Visible = False
End Sub
'accession number
Set bookRS = New ADODB.Recordset
bookRS.Open "book_catalog", libCON, adOpenKeyset, adLockReadOnly
While bookRS.EOF <> True
Combo1.AddItem bookRS!access_no
bookRS.MoveNext
Wend
End Sub
Returning of books
87
This is a command button which is used
to return the borrowed books by entering the accession no the title of the book
is displayed in title box.
Then enter borrower id in borrower’s
information in borrower id box. Name of the person and status is displayed
In case of overdue the charge of the fine
charge is displayed
88
Program code for returning of books
89
If Combo1.Text <> "" And Text1.Text <> "" Then
Combo2.Enabled = True
Else
Combo2.Enabled = False
End If
End Sub
90
If KeyCode = vbKeyBack Or KeyCode = vbKeyDelete Then
auto = True
Combo1.SelText = ""
auto = False
ElseIf KeyCode = vbKeyReturn Then
Combo1_LostFocus
Combo1.SelStart = Len(Combo1.Text)
End If
End Sub
91
End If
End If
End Sub
92
Text5.Text = Date
End If
End Sub
93
Text3.Text = !Status
Text4.Text = !borrow_date
On Error Resume Next
Text5.Text = !due_date
End With
End If
End Sub
94
.Close
End With
95
Combo2.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
Command6.Caption = "CL&OSE"
End If
End Sub
End Sub
96
feeRS.Open "charge", libCON, adOpenKeyset, adLockReadOnly
Label12.Caption = feeRS!charge_fee
Label13.Caption = Val(Label11.Caption) * Val(Label12.Caption)
Label12.Caption = Format(Label12.Caption, "###.00")
Label13.Caption = Format(Label13.Caption, "###.00")
Else
Label11.Caption = "0"
Label12.Caption = "0.00"
Label13.Caption = "0.00"
End If
End Sub
Reports section
Books masters list
97
Currently borrowed books list
98
Settings section
Settings in library management systems
99
This is a command button which is used to delete
the book category in the list of books
Command2.Enabled = False
End Sub
100
User management
'users
Set userRS = New ADODB.Recordset
SQLstr = "SELECT * FROM userlist where username='" & List1.Text & "'"
101
userRS.Open SQLstr, libCON, adOpenKeyset, adLockOptimistic
frmchange.lblusername.Caption = userRS!UserName
frmchange.Show vbModal
End Sub
'users
Set userCMD = New ADODB.Command
SQLstr = "DELETE * FROM userlist where username ='" & List1.Text & "'"
With userCMD
.ActiveConnection = libCON
.CommandType = adCmdText
.CommandText = SQLstr
.Execute
End With
List1.clear
Call listrefresh
cmdDelete.Enabled = False
cmdchange.Enabled = False
End Sub
102
Private Sub listrefresh()
'users
Set userRS = New ADODB.Recordset
userRS.Open "userlist", libCON, adOpenKeyset, adLockReadOnly
End Sub
About
103
AM JAIN LIBRARY SYSTEMS
Option Explicit
104
End Sub
Dim rc As Long
Dim SysInfoPath As String
Exit Sub
SysInfoErr:
MsgBox "System Information Is Unavailable At This Time", vbOKOnly
End Sub
'------------------------------------------------------------
' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
'------------------------------------------------------------
rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open
Registry Key
105
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...
'------------------------------------------------------------
' Retrieve Registry Key Value...
'------------------------------------------------------------
rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
106
End Sub
107
SUPPORTS
• Mastering Visual Basic 6.0
• Visual Basic Programming Black Book
• MSDN Library
• Microsoft Windows Access 2003 Help
108