Anda di halaman 1dari 105

Preface

The Cyber Caf Management System


Cyber Caf Management System is a popular, powerful and easy to use Internet Caf billing and Management software. In cyber Caf Management System We can Manage the cyber caf very efficiently and effective. We can keep the track of all the computers by Cyber Caf Management system. In Cyber Caf management system We can create new users who can use this software. We can change the user password and login name of the system. We can enter the system details Like Machine number and Configuration and this details can be used for billing of particular system.

Project Report :: Cyber Caf Management System

Visual Basic Environment


What is Visual Basic?

Visual Basic is a tool that allows you to develop Windows (Graphic User Interface - GUI) applications. The applications have a familiar appearance to the user. As you develop as a Visual Basic programmer, you will begin to look at Windows applications in a different light. You will recognize and understand how various elements of Word, Excel, Access and other applications work. You will develop a new vocabulary to describe the elements of Windows applications. Visual Basic is event-driven, meaning code remains idle until called upon to respond to some event (button pressing, menu selection, ...). Visual Basic is governed by an event processor. Nothing happens until an event is detected. Once an event is detected, the code corresponding to that event (event procedure) is executed. Program control is then returned to the event processor.

All Windows applications are event-driven. For example, nothing happens in Word until you click on a button, select a menu option, or type some text. Each of these actions is an event. The event-driven nature of Visual Basic makes it very easy to work with. As you develop a Visual Basic application, event procedures can be built and tested individually, saving development time. And, often event procedures are similar in their coding, allowing re-use (and lots of copy and paste).

Project Report :: Cyber Caf Management System

Some Features of Visual Basic Full set of controls - you 'draw' the application Lots of icons and pictures for your use Response to mouse and keyboard actions Clipboard and printer access Full array of mathematical, string handling, and graphics functions Can handle fixed and dynamic variable and control arrays Sequential and random access file support Useful debugger and error-handling facilities Powerful database access tools ActiveX support Package & Deployment Wizard makes distributing your applications simple

Drawing the User Interface and Setting Properties Visual Basic operates in three modes. *0 Design mode - used to build application *1 Run mode - used to run the application *2 Break mode - application halted and debugger is available We focus here on the design mode. Six windows appear when you start Visual Basic. Each window can be viewed (made visible) by selecting menu options, depressing function keys or using the toolbar. Use the method you feel most comfortable with.
*3 The Main Window consists of the title bar, menu bar, and toolbar. The title

bar indicates the project name, the current Visual Basic operating mode, and the current form. The menu bar has drop-down menus from which you control the *4 operation of the Visual Basic environment. The toolbar has buttons that provide shortcuts to some of the menu options. The main window also shows the location of the current form relative to the upper left corner of the screen (measured in twips) and the width and length of the current form. Of particular interest is the Help menu item. The Visual Basic on-line help system is invaluable as you build

Project Report :: Cyber Caf Management System

applications. Become accustomed with its use. Usually just pressing <F1> can get you the help you need.

*0 The Form Window is central to developing Visual Basic applications.

It is where you draw your application.

Project Report :: Cyber Caf Management System

*0 The Toolbox is the selection menu for controls used in your

application. Help with any control is available by clicking the control and pressing <F1>.

Project Report :: Cyber Caf Management System

*0

The Properties Window is used to establish initial property values for objects (controls). The drop-down box at the top of the window lists all objects in the current form. Two views are available: Alphabetic and Categorized. Under this box are the available properties for the currently selected object. Help with any property can be obtained by highlighting the property of interest and pressing <F1>.

Project Report :: Cyber Caf Management System

Feasibility study
Depending on the problem defined the project is expanded to a more detailed feasibility study. A feasibility study is a test of the system proposal according to its work ability impact on the organization ability to meet user need and effective use of resources.

Different feasibility study:


It centers on the existing computer system i.e. hardware& software etc. and determines whether. These technical resources are sufficient for the proposed system.

Technical Feasibility :-

Economic Feasibility :-

Economic feasibility is the most important study that determines the cost and benefits of the proposed system and compares with the budget. The cost of the project is not out weighted the budget. The cost of the project includes the cost of hardware, software development and implementation.

Operational Feasibility :-

In the operational feasibility, determines that the system will operate in the way that user wants. Our system is working in the way of the user wants, so our system is operational feasible.

Project Report :: Cyber Caf Management System

i) SYSTEM ANALYSIS ii) iii) Introduction


System analysis & Design forms a major part of the project work. It involves many steps where detailed study of the concerned topic needs to be done. System Analysis and Design is the core of System Development Life Cycle (SDLC). System Analysis & Design includes various stages: - Analysis - Preliminary Design - Detailed Design - Coding - Testing - Implementation & Support The first one is the Analysis phase, which includes detailed study of the proposed system. The aim of this stage is to get prepared for the development phase. The various activities that are involved while going through Analysis phase are: - Analysing the Current System - Getting user requirements and converting them to Requirement Specifications - Feasibility study of the New Proposed System - Cost Benefit analysis - Arrangement of Resources required. - Planning for time management As stated above Analysis phase is the first stone towards the building of the Proposed System, so it needs to be efficiently and perfectly performed.

a. b. Analysis Done
For the Analysis of the Clinic Management System (CAS) various nearby Clinics were visited and a detailed study of the current system was performed. Various staff personnel were questioned about the prevailing system and problems related to it. Their requirements were taken and understood for the design of the proposed system. The Directors/Owners of Clinics were also part of the analysis. They were asked about the amount that they could spend on the proposed System and about the scope of the proposed system.
Project Report :: Cyber Caf Management System

At last all of them were clubbed together to perform feasibility study, requirement specifications and further things.

iv) Requirement Specifications


Now after the Current System was understood its the time for getting requirements for the user that what the user wants in the new online system. What are his requirements and which of them are analysed perfectly and which one needs more study. Requirements were taken from various people like Doctors, Directors, Compounders, Receptionist and Office Assistants. The requirements that they give and were understood are - There should be a provision for recording and retrieval of information about every Patient who visits the Clinic. - There should be a provision for recording every Diagnosis given to the Patient which would be helpful in future - Bill generation should be provided so as to perform the work of Billing Department - Most of the Clinics required some system for maintaining the Immunisation record of children. - There was also a requirement to maintain information about Doctors, there contact information and area of Specialisation. - Requirements included the storage of information about diseases and medicines related to them so that the doctor can refer it while providing diagnosis. - They also require some access control over the system. - Some of them required having some provision for finding out the amount collected in a certain period of time to be retrieved. These were the various requirements that were obtained from the would be End Users. These requirements were satisfied by various subsystems that were proposed and discussed before. These systems were than designed and them coded to perform these operations. They will follow as the report moves further

Project Report :: Cyber Caf Management System

1) Feasibility analysis
A) Time feasibility: This feasibility says that the system should be developed

within a reasonable period of time .A reliable Clinic Automation Software can be developed in considerable amount of time
B) Technical feasibility: This feasibility says that the system should be developed

with the current available technology. Clinic Automation Software can be developed using current available technology with efficiency and effectiveness. For the technical perspective licensed software like Visual studio 6.0 for Visual Basics 6.0 used for front-end interface development, Microsoft Office for Microsoft Access for Back Hand Database management will be required. C) Economical feasibility: This feasibility checks weather the system can be developed with the available funds or not. Clinic Automation Software does not require enormous amount of money to be developed. This can be done economically if planned judicially, so it is economically feasible. The cost of project depends upon the number of man hours required.
D) Operational feasibility: The system is operationally feasible as it is very easy for

the End users to operate it. It only needs basic information about Windows platform.

The system is fully operational, economical, socially and technically feasible. Time Sheet The time schedule of the project work, which is done in the period of time). 3 month (full

The project was started on 10th July 2008 and was completed on 21th August 2008. The distribution of time into various tasks is given as under.

Project Report :: Cyber Caf Management System

1. Analysis & User requirement Gathering 15 days (10th July 2008to 24th July

2004) During this period of time various nearby Clinics were visited and a detailed analysis of the current system was done. Then various user requirements were take n and then freezed as per the final requirements.
2.

Preliminary Design 15 days (25th Jul 2008 to 8th Aug 2008) Database Design was made and was then normalised. While designing the database care was taken for updation / deletion and insertion anomalies as well as utmost care was taken to design a non-redundant database. Primary key and Foreign Keys are used as and when required. During this period various Processes specifications were done. During this period various alternative solutions were also studied for every process and then the best suitable solution was taken out from it. This included very rigorous work both from developers end and users end as each design was then sent to the end user for approval and then finalized.

3. Detailed Design 30 days (9th Aug 2008 to 17th Aug 2008)

During this period the detailed design of the project was undertaken. Various modules were made and finalized as per requirements and then Input and Output Screens were designed for them. Designing of Input and Output screens includes - Forms - Reports - Menus After all this the detailed design of the project was finalized and the project is then ready for coding.
4. Coding 5days (18th Aug 2008 to 23rd Aug 2008)

Project Report :: Cyber Caf Management System

During this period of actual coding of the modules designed in the Detailed Design stage were done. Coding for performed for various user actions and inputs as well as for the outputs like reports that user required. Coding was performed in Visual Basics 6.0 with back end support of Microsoft Access 97.
5. Testing 9 days (9th Aug 2008 to 12th Aug 2008)

During the testing phase test data was generated first and then this data was used to test various forms, reports and other modules. It was the Alpha Testing performed at Developers site, which took around 7 days to get completed. Beta testing was done at a nearby Clinic and it took 2 days only because the Software was almost up to mark as per user requirements.
6. Support & Implementation 2 days (21th Aug 2008 to 22th Aug 2008)

During this time period the Software was installed properly at users site and End users were trained how to use the software. It took such a less time because the End users were familiar with Windows environment thus only menus and some forms were needed to be taught to them. The User manual was created during the coding and testing phase collectively so it is not stated separately.

Project Report :: Cyber Caf Management System

Details of Hardware & Software used Hardware and Software used while developing this project are : Operating System : Windows Xp Visual Basics 6.0 (Visual Studio 6.0) Microsoft Word 2007 (Microsoft Office 2007) Microsoft Access Intel Celeron Processor 512 MB Ram Intel 810 chipset Colored Monitor Resolution 800 x 600

Software for Front End : Software used for Documentation RDBMS : :

Hardware Configuration :

Rest of the things are same as that of normal Personal Computers. No special or additional Hardware or Software was used in project work.

Project Report :: Cyber Caf Management System

2)MAIN REPORT
Database
Description of database Tables and its Fields Table :: MachineDetails
Field Name Machine no Processor Ram Motherboard Casing Monitor SoundCard AgpCard KeyBoard Mouse CdromDrive FloppyDrive Speaker Amount Data Type Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Table :: Machine Records


Field Name Machine no MachineName CurrentStatus Data Type Text Text Yes/No

Table :: NewMachineRecord
Field Name MachineNo MachineName Data Type Number Text

Project Report :: Cyber Caf Management System

MEntryDate

Date/Time

Table :: RateSetting
Field Name OneHour StartingDate EndingDate Comment Data Type Number Date/Time Date/Time Text

Table :: Tran
Field Name StartTime MachineNo Amount BillNo Date Mounth Year EndTime Hour Minute Dt Data Type Date/Time Text Text Currency Date/Time Number Number Date/Time Number Number Text

Table :: Users
Field Name UserName UserId EndingDate Comment Data Type Text Text Text Date/Time

Table :: Chek
Field Name Count Data Type Number

Table :: Chek
Field Name last_date Data Type Date/Time Project Report :: Cyber Caf Management System

current_date hours_consumed

Date/Time Number

Decription of Forms And Their Code 1). Create New User (frmAddnewUser) ::
Dim rs As New ADODB.Recordset Private Sub cmdCancel_Click() Unload Me End Sub Private Sub cmdOK_Click() If txtUserName.Text = "" Then txtUserName.SetFocus MsgBox "Please Enter User Name" Exit Sub ElseIf txtUserId.Text = "" Then txtUserId.SetFocus MsgBox "Please Enter User Id" Exit Sub ElseIf txtPassword.Text = "" Then txtPassword.SetFocus MsgBox "Please Enter Password" Exit Sub ElseIf txtConfirmPassword.Text = "" Then txtOldPassword.SetFocus Exit Sub MsgBox "Please Confirm Your Password" End If If Not txtPassword.Text = txtConfirmPassword.Text Then MsgBox "Password doesn't match", vbOKOnly, Password End If If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users", CN While rs.EOF = False If LCase(txtUserId.Text) = rs("UserId") Then MsgBox "User Id Already Exists" txtUserId.SetFocus txtUserId.SelStart = 0 Project Report :: Cyber Caf Management System

txtUserId.SelLength = Len(txtUserId.Text) Exit Sub End If rs.MoveNext Wend If txtPassword.Text <> txtConfirmPassword.Text Then txtConfirmPassword.SetFocus txtConfirmPassword.SelStart = 0 txtConfirmPassword.SelLength = Len(txtConfirmPassword.Text) MsgBox ("Your Supplied Pasword Does Not Match") Exit Sub End If If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users", CN ' 'While rs.EOF = False 'If txtUserId.Text = rs("UserId") Then 'MsgBox "User Id Already Exists" 'txtUserId.SetFocus 'txtUserId.SelStart = 0 'txtUserId.SelLength = Len(txtUserId.Text) ' 'Exit Sub 'End If 'rs.MoveNext 'Wend rs.AddNew rs("UserName") = txtUserName.Text rs("UserId") = LCase(txtUserId.Text) rs("Password") = txtPassword.Text rs("CreationDate") = Date rs.Update R = MsgBox("Successfully Created.Any More?", vbYesNo, "Questions") If R <> vbYes Then cmdOk.Enabled = False Exit Sub End If txtUserName.Text = "" txtUserId.Text = "" txtPassword.Text = "" txtConfirmPassword.Text = ""

Project Report :: Cyber Caf Management System

txtUserName.SetFocus ' 'rs.EditMode End Sub Private Sub Form_Load() txtUserName.Text = "" txtPassword.Text = "" txtConfirmPassword.Text = "" 'txtUserName.SetFocus End Sub Private Sub txtConfirmPassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdOk.SetFocus End If End Sub Private Sub txtPassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtConfirmPassword.SetFocus End If End Sub Private Sub txtUserId_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtPassword.SetFocus End If End Sub Private Sub txtUserName_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtUserId.SetFocus End If End Sub

Project Report :: Cyber Caf Management System

2). Billing (frmBilling) ::


Private Sub cmdOK_Click() If Text1.Text = "" Then MsgBox "Please Enter PC No." Else txttotal.Caption = Val(text2.Text) * Val(20) MsgBox "Transaction Complete", vbOKOnly End If Unload Me End Sub Private Sub Command4_Click() Unload Me End Sub

Project Report :: Cyber Caf Management System

3). Calender (frmCalander.frm) ::


Option Explicit Dim date0, date1, date2, date3 As String Dim x, first, tel As Integer Private Sub Command1_Click() HScroll1.Value = 0 HScroll2.Value = 0 date0 = DateAdd("m", HScroll1.Value, Date) date1 = DateSerial(Format(date0, "yyyy"), Format(date0, "mm"), 1) End Sub Private Sub Form_Activate() Me.Top = 1600 Me.Left = 4500 date0 = Date Command1_Click SetDate End Sub Private Sub SetDate() Label2.Caption = UCase(Format(date0, "mmmm")) Label211.Caption = (Format(date0, "yyyy")) For x = 0 To 36 Label3(x).Visible = False Label3(x).ForeColor = vbBlue 'RGB(170, 238, 235) Label3(x).BorderStyle = 0 Next x first = Val(Format(date1, "w")) - 1 date2 = date1: tel = 0 For x = first To 36 date2 = DateAdd("d", tel, date1) If DateDiff("m", date1, date2) > 0 Then Exit For Label3(x).Caption = Day(date2) Label3(x).Visible = True tel = tel + 1 Next x If date0 = Date Then Label4.Caption = Format(Date, "dddd, dd mmmm yyyy") For x = 0 To 36 If Label3(x).Caption = Day(Date) Then Label3(x).ForeColor = vbRed Label3(x).BorderStyle = 1 Exit For End If

Project Report :: Cyber Caf Management System

Next x End If HScroll1.SetFocus End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Unload Me End Sub Private Sub HScroll1_Change() date0 = DateAdd("m", (HScroll2.Value * 12) + HScroll1.Value, Date) date1 = DateSerial(Format(date0, "yyyy"), Format(date0, "mm"), 1) SetDate End Sub Private Sub HScroll2_Change() date0 = DateAdd("m", (HScroll2.Value * 12) + HScroll1.Value, Date) date1 = DateSerial(Format(date0, "yyyy"), Format(date0, "mm"), 1) SetDate End Sub

Project Report :: Cyber Caf Management System

4). Change Password (frmChangePassword.frm) ::


Dim rs As New ADODB.Recordset Private Sub cmbUserId_Click() If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users where UserId='" & cmbUserId & "'", CN txtOldPassword.Text = rs("Password") txtUserName.Text = rs("UserName") txtNewPassword.SetFocus End Sub Private Sub cmdOK_Click() If User = True Then ' If txtOldPassword.Text = "" Then ' txtOldPassword.SetFocus ' MsgBox "Please Enter a Value" ' Exit Sub If txtNewPassword.Text = "" Then txtNewPassword.SetFocus MsgBox "Please Enter a Password" Exit Sub ElseIf txtConfirmPassword.Text = "" Then txtOldPassword.SetFocus Exit Sub MsgBox "Please Confirm Your Password" End If If txtConfirmPassword.Text <> txtNewPassword.Text Then txtConfirmPassword.SetFocus txtConfirmPassword.SelStart = 0 txtConfirmPassword.SelLength = Len(txtConfirmPassword.Text) MsgBox "Both Password Doesn't Match" Exit Sub End If If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient

Project Report :: Cyber Caf Management System

rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users where UserId='" & cmbUserId.Text & "'", CN If rs.RecordCount > 0 Then GoTo Correct ' Data1.DatabaseName = App.Path & "\Cyber.mdb" ' Data1.RecordSource = "select * from user_id" 'Data1.Refresh 'Data1.Recordset.FindFirst "password='" & Form1.txtOldPassword.Text & "'" 'If Data1.Recordset.NoMatch = True Then 'txtOldPassword.SetFocus 'txtOldPassword.SelStart = 0 'txtOldPassword.SelLength = Len(txtOldPassword.Text) 'MsgBox "Please Enter a Correct Password" 'Exit Sub 'Else 'Data1.Recordset.Edit Correct: 'Data1.Recordset("password") = txtConfirmPassword.Text 'Data1.Recordset.Update rs("Password") = txtConfirmPassword.Text rs.Update MsgBox "Your Password hass Changed", , "Change Pass" txtOldPassword.Text = "" txtNewPassword.Text = "" txtConfirmPassword.Text = "" 'cmbUserId.ListIndex (0) 'txtOldPassword.SetFocus Exit Sub End If If txtConfirmPassword.Text <> txtNewPassword.Text Then txtConfirmPassword.SetFocus txtConfirmPassword.SelStart = 0 txtConfirmPassword.SelLength = Len(txtConfirmPassword.Text) MsgBox "Both Password Doesn't Match" Exit Sub End If If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users where UserId='" & txtUserId.Text & "'", CN If rs.RecordCount > 0 Then GoTo Correct End Sub

Project Report :: Cyber Caf Management System

Private Sub cmdCancel_Click() 'Data1.Recordset.Edit 'Unload Me 'Data1.Recordset.CancelUpdate End Sub Private Sub cmdExit_Click() Unload Me 'Unload frmLogin End Sub Private Sub Form_Load() If User = True Then txtUserId.Visible = False cmbUserId.Visible = True 'cmdDelete.Visible = True If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users", CN While rs.EOF = False 'If IsNull(rs("TotalTime")) Then cmbUserId.AddItem rs("UserId") ' End If rs.MoveNext Wend Else ' cmdExit.Appearance = AlignmentConstants cmbUserId.Visible = False txtUserId.Visible = True txtUserId.Text = UserNa If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users where UserId='" & UserNa & "'", CN If rs.RecordCount > 0 Then txtUserName.Text = rs("UserName") txtOldPassword.Text = rs("Password") End If

Project Report :: Cyber Caf Management System

End If

End Sub Private Sub txtConfirmPassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdOk.SetFocus End If End Sub Private Sub txtNewPassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtConfirmPassword.SetFocus End If End Sub

Project Report :: Cyber Caf Management System

5). Delete (frmDelete.frm) ::


Dim rs As New ADODB.Recordset Private Sub cmbUserId_Click() If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users where UserId='" & cmbUserId.Text & "'", CN If rs.RecordCount > 0 Then txtUserName.Text = rs("UserName") txtUserName.Visible = True txtPassword.Text = rs("Password") txtPassword.Visible = True txtCreationDate.Text = rs("CreationDate") txtCreationDate.Visible = True Label2.Visible = True Label3.Visible = True Label4.Visible = True cmdRefresh.Enabled = True End If End Sub Private Sub cmdDelete_Click() Label1.Visible = True Label5.Visible = True cmbUserId.Visible = True 'cmdRefresh.Enabled =True End Sub Private Sub cmdRefresh_Click() R = MsgBox("Are U Confirm to Delete", vbYesNo, "Warning") If R <> vbYes Then Label1.Visible = False Label2.Visible = False Label3.Visible = False Label4.Visible = False Label5.Visible = False cmbUserId.Visible = False

Project Report :: Cyber Caf Management System

txtUserName.Visible = False txtPassword.Visible = False txtCreationDate.Visible = False cmdRefresh.Enabled = False Exit Sub End If If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users where UserId='" & cmbUserId.Text & "'", CN If rs.RecordCount > 0 Then rs.Delete adAffectCurrent MsgBox "Record has been Deleted" Else MsgBox "No Record Found", , "Message" Exit Sub End If ' txtOldPassword.Text = "" 'txtMachineName.Text = "" 'cmdUserId.un cmbUserId.Clear Form_Load 'Label1.Visible = False 'Label2.Visible = False 'Label3.Visible = False 'Label4.Visible = False 'Label5.Visible = False 'cmdUserId.Visible = False 'txtUserName.Visible = False 'txtPassword.Visible = False 'txtCreationDate.Visible = False End Sub Private Sub Command1_Click() Unload Me End Sub Private Sub Form_Load() Label1.Visible = False Label2.Visible = False Label3.Visible = False Label4.Visible = False Label5.Visible = False

Project Report :: Cyber Caf Management System

cmbUserId.Visible = False txtUserName.Visible = False txtPassword.Visible = False txtCreationDate.Visible = False cmdRefresh.Enabled = False If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users ", CN If rs.RecordCount > 0 Then While rs.EOF = False cmbUserId.AddItem rs("UserId") rs.MoveNext Wend End If End Sub

Project Report :: Cyber Caf Management System

6). Intialization (frmInitialization.frm) ::


Option Explicit Dim a As Integer Dim flag As Boolean Dim rs As New ADODB.Recordset Private Sub Command1_Click() 'frmSplash.Show frmLogon.Show 'Unload Me Me.Hide End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Form_Load() flag = True 'Label1.Visible = False 'Label5.Visible = False modconn.AttendConn 'modconn.counted 'Label5.Caption = Count TimerCheck.Enabled = False Call check 'Label5.Caption = frmmain.Text1.Text End Sub Private Sub Form_Unload(Cancel As Integer) Unload frmLogon Unload MDIForm1 modconn.CloseConn End Sub Private Sub Label6_Click() End Sub Private Sub Label7_Click() End Sub Project Report :: Cyber Caf Management System

Private Sub Timer1_Timer() '''a = a + 1 '''If a = 5 Then '''frmLogon.Show '''Unload Me '''End If ''Label1.Visible = True 'Label5.Visible = True If flag = True Then ''Label1.ForeColor = QBColor(12) 'Label5.ForeColor = QBColor(12) 'Shape1.Visible = True 'Shape2.Visible = False flag = False Else ''Shape2.Visible = True ''Shape1.Visible = False 'Label1.Visible = False ''Label1.ForeColor = QBColor(15) 'Label5.ForeColor = QBColor(15) flag = True End If End Sub Public Sub check() If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic 'frmmain.MnuReport.Enabled = False 'frmmain.MnuAdmin.Enabled = False 'RS1.Open "select * from status where procode= '" & procod & "'and netcode='" & netcod & "'", CN 'If txtUserName = "Administrator" Then 'frmmain.MnuReport.Enabled = True 'frmmain.MnuAdmin.Enabled = True rs.Open "select * from Chek", CN If rs.RecordCount > 0 Then 'rs.AddNew 'rs("mn") = rs("mn") + 1 rs("count") = rs("count") + 1 rs.Update End If

Project Report :: Cyber Caf Management System

' If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select count from Chek", CN If rs.RecordCount > 0 Then 'Label5.Caption = rs("count") - 1 ''MsgBox "Updated" ''Text1.Text = c ''Text1.Text = rs("count") If rs("count") > 100 Then TimerCheck.Enabled = True 'Unload frmmain End If 'If count > 10 Then 'Unload frmLogon 'Unload frmmain 'End If End If End Sub Private Sub TimerCheck_Timer() a=a+1 If a = 10 Then Unload frmInitialization End If End Sub

Project Report :: Cyber Caf Management System

7). Login Form (frmLogon.frm) ::


Dim ChrPass As String Dim rs As New ADODB.Recordset 'txtUserName.SetFocus Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdCancel_Click() Unload Me Unload MDIForm1 Unload frmInitialization End Sub Private Sub cmdCancel_GotFocus() End Sub Private Sub cmdOK_Click() 'Call check If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic 'frmmain.MnuReport.Enabled = False 'frmmain.MnuAdmin.Enabled = False 'RS1.Open "select * from status where procode= '" & procod & "'and netcode='" & netcod & "'", CN 'If txtUserName = "Administrator" Then 'frmmain.MnuReport.Enabled = True 'frmmain.MnuAdmin.Enabled = True rs.Open "select * from Users where UserId='" & txtUserName & "'and Password='" & txtPassword & "'", CN If rs.RecordCount > 0 Then 'Call check ' MsgBox "A c c e s s G r a n t e d", vbInformation + vbSystemModal, "Access Granted" ' frmmain.Enabled = True ' MainMdi.Show If rs("UserId") = "admin" Then User = True Project Report :: Cyber Caf Management System

'frmmain.SmnuComputersetting.Enabled = True 'frmmain.SmnuNewuser.Enabled = True 'frmmain.SmnuRateofbilling.Enabled = True 'frmmain.SmnuRecorddelete.Enabled = True ' .MDIForm1.mnu_int_admin.Enabled = True MDIForm1.mnu_createNUser.Enabled = True 'mnu_changeUPassword.Enabled = False MDIForm1.mnu_computerSetting.Enabled = True MDIForm1.mnu_deleteRecord.Enabled = True MDIForm1.mnu_rateOBilling.Enabled = True 'frmmain.MnuReport.Enabled = True 'frmmain.MnuAdmin.Enabled = True End If Me.Hide UserNa = txtUserName MDIForm1.Enabled = True Else MsgBox "Invalid Password ! Please try again.", vbCritical + vbSystemModal, "Invalid Password" txtPassword.Text = "" txtPassword.SetFocus Exit Sub End If End Sub Private Sub Form_Load() 'Label1.Caption = Time & " User Logon" 'modconn.AttendConn MDIForm1.Visible = True 'frmmain.MnuReport.Enabled = False 'frmmain.MnuAdmin.Enabled = False 'Timer2.Interval = 100 'Unload Me 'modconn.AttendConn 'ChrPass = "secret" Me.Top = 3200 Me.Left = 3700 lbl1.Left = 4900 ' MainMdi.Show End Sub Private Sub Form_Unload(Cancel As Integer) ' If Not txtPassword = ChrPass Then ' Unload Me '' Unload MainMdi ' ' Else ' Load MainMdi

Project Report :: Cyber Caf Management System

'frmmain.Enabled = True ' MainMdi.Show ' End If 'modconn.CloseConn Unload MDIForm1 End Sub Private Sub Timer1_Timer() 'lbl1.Left = 4900 lbl1.Move lbl1.Left - 50 If lbl1.Left <= -2850 Then 'If lbl1.Left <= -3900 Then lbl2.Visible = True lbl1.Visible = False lbl2.Move lbl2.Left - 50 If lbl2.Left <= -1500 Then lbl2.Left = 4900 lbl2.Visible = False lbl1.Visible = True lbl1.Left = 4900 End If End If End Sub 'Private Sub txtPassword_KeyPress(KeyAscii As Integer) ' If KeyAscii = 13 Then ' txtPassword = StrConv(txtPassword, vbLowerCase) ' cmdOK_Click 'End If 'End Sub Private Sub txtUserName_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtPassword.SetFocus End If End Sub Private Sub txtUserName_LostFocus() txtUserName.Text = LCase(txtUserName.Text) End Sub

Project Report :: Cyber Caf Management System

8). Computer Setting (frmpcsetting.frm)


Dim str As String Dim rs As New ADODB.Recordset Private Sub cmbMachineNo_Click() '******************************************** ' DAO Start '******************************************* 'Data1.DatabaseName = App.Path & "\Cyber.mdb" 'Data1.RecordSource = "select * from MachineRecords" 'Data1.Refresh 'Data1.Recordset.FindFirst "MachineNo='" & cmbMachineNo.Text & "'" 'txtMachineNo.Text = Data1.Recordset("MachineNo") 'txtMachineName.Text = Data1.Recordset("MachineName") 'txtMachineNo.Visible = True 'cmbMachineNo.Visible = False '************************************ 'DAO End '************************************ '********************************************** 'ADODB START '********************************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where MachineNo='" & cmbMachineNo.Text & "'", CN If rs.RecordCount > 0 Then txtMachineNo.Text = rs("MachineNo") txtMachineName.Text = rs("MachineName") txtMachineName.SetFocus txtMachineName.SelStart = 0 txtMachineName.SelLength = Len(txtMachineName.Text) txtMachineNo.Visible = True cmbMachineNo.Visible = False End If End Sub Private Sub cmdOK_Click() '**************************************************** 'DAO Start

Project Report :: Cyber Caf Management System

'**************************************************** '' If str = "AddNew" Then ''If txtMachineNo.Text = "" Then ''txtMachineNo.SetFocus ''MsgBox "Please enter a Machine No", , "Warnig" ''Exit Sub ''ElseIf txtMachineName.Text = "" Then ''txtMachineName.SetFocus ''MsgBox "Please enter a Machine Name", , "Warnig" ''Exit Sub ''End If ''Data1.DatabaseName = App.Path & "\Cyber.mdb" ''Data1.RecordSource = "select * from MachineRecords" ''Data1.Refresh ''Data1.Recordset.FindFirst "MachineNo='" & txtMachineNo.Text & "'" '' If Data1.Recordset("MachineNo") = txtMachineNo.Text Then '' txtMachineNo.SetFocus '' txtMachineNo.SelStart = 0 '' txtMachineNo.SelLength = Len(txtMachineNo.Text) '' MsgBox "Machine No already Exit", , "Login" '' Exit Sub '' End If ''Data1.Recordset.AddNew ''Data1.Recordset("MachineNo") = txtMachineNo.Text ''Data1.Recordset("MachineName") = txtMachineName.Text ''Data1.Recordset.Update ''MsgBox "New Entery Completed" '' cmbMachineNo.Clear '' Data1.DatabaseName = App.Path & "\Cyber.mdb" '' Data1.RecordSource = "select * from MachineRecords" '' Data1.Refresh '' cmbMachineNo.AddItem "Select a Machine name" '' Do While Not Data1.Recordset.EOF '' cmbMachineNo.AddItem Data1.Recordset("MachineNo") '' Data1.Recordset.MoveNext '' Loop '' cmbMachineNo.ListIndex = 0 '' cmdOK.Visible = False '' cmdAddNew.Visible = True '' cmdModify.Visible = True '' cmdDelete.Visible = True ''ElseIf str = "Modify" Then '' Data1.DatabaseName = App.Path & "\Cyber.mdb" '' Data1.RecordSource = "select * from MachineRecords" '' Data1.Refresh ''Data1.Recordset.FindFirst "MachineNo='" & cmbMachineNo.Text & "'"

Project Report :: Cyber Caf Management System

''Data1.Recordset.Edit ''Data1.Recordset("MachineNo") = txtMachineNo.Text ''Data1.Recordset("MachineName") = txtMachineName.Text ''Data1.Recordset.Update ''MsgBox "Updation Comleted" '' cmbMachineNo.Clear '' Data1.DatabaseName = App.Path & "\Cyber.mdb" '' Data1.RecordSource = "select * from MachineRecords" '' Data1.Refresh '' cmbMachineNo.AddItem "Select a Machine name" '' Do While Not Data1.Recordset.EOF '' cmbMachineNo.AddItem Data1.Recordset("MachineNo") '' Data1.Recordset.MoveNext '' Loop '' cmbMachineNo.ListIndex = 0 '' cmdOK.Visible = False '' cmdAddNew.Visible = True '' cmdModify.Visible = True '' cmdDelete.Visible = True ''End If '******************************************************** 'DAO End '******************************************************** '******************************************************** 'ADO Start '******************************************************** If str = "AddNew" Then If txtMachineNo.Text = "" Then txtMachineNo.SetFocus MsgBox "Please enter a Machine No", , "Warnig" Exit Sub ElseIf txtMachineName.Text = "" Then txtMachineName.SetFocus MsgBox "Please enter a Machine Name", , "Warnig" Exit Sub End If If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where MachineNo='" & txtMachineNo.Text & "'", CN If rs.RecordCount > 0 Then txtMachineNo.SetFocus txtMachineNo.SelStart = 0

Project Report :: Cyber Caf Management System

txtMachineNo.SelLength = Len(txtMachineNo.Text) MsgBox "Machine No already Exist", , "Login" Exit Sub End If rs.AddNew rs("MachineNo") = txtMachineNo.Text rs("MachineName") = txtMachineName.Text rs.Update MsgBox "New Entery Completed" cmbMachineNo.Clear '**************************************** 'Here Loaded Combo after Update Database '**************************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords", CN While rs.EOF = False cmbMachineNo.AddItem rs("MachineNo") rs.MoveNext Wend cmbMachineNo.ListIndex = 0 cmdOk.Enabled = False cmdAddNew.Enabled = True cmdModify.Enabled = True cmdDelete.Enabled = True cmdExit.SetFocus ElseIf str = "Modify" Then If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where MachineNo='" & cmbMachineNo.Text & "'", CN 'rs.EditMode rs("MachineNo") = txtMachineNo.Text rs("MachineName") = txtMachineName.Text rs.Update MsgBox "Updation Comleted" cmbMachineNo.Clear '*****************************************************

Project Report :: Cyber Caf Management System

'Again loaded into combo '***************************************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords", CN While rs.EOF = False cmbMachineNo.AddItem rs("MachineNo") rs.MoveNext Wend cmbMachineNo.ListIndex = 0 cmdOk.Enabled = False cmdAddNew.Enabled = True cmdModify.Enabled = True cmdDelete.Enabled = True cmdExit.SetFocus End If '******************************************************** 'ADO End '******************************************************** 'frmpcstatus.Shape2.FillColor = QBColor(11) End Sub Private Sub cmdCancel_Click() cmdAddNew.Enabled = True cmdModify.Enabled = True cmdDelete.Enabled = True 'cmdRefresh.Visible = False cmbMachineNo.Visible = False txtMachineNo.Visible = True End Sub Private Sub cmdAddNew_Click() txtMachineNo.Locked = False txtMachineNo.Text = "" txtMachineName.Text = "" txtMachineNo.SetFocus str = "AddNew" cmdAddNew.Enabled = False cmdModify.Enabled = False cmdDelete.Enabled = False 'cmdRefresh.Visible = False cmdOk.Enabled = True

Project Report :: Cyber Caf Management System

End Sub Private Sub cmdModify_Click() cmbMachineNo.Visible = True txtMachineNo.Visible = False txtMachineNo.Locked = False txtMachineName.Locked = False str = "Modify" cmdModify.Enabled = False cmdAddNew.Enabled = False cmdDelete.Enabled = False cmdRefresh.Enabled = False cmdOk.Enabled = True End Sub Private Sub cmdDelete_Click() d = MsgBox("Are you sure", vbYesNo, "Warnig") If d <> vbYes Then Exit Sub cmdOk.Enabled = False cmdAddNew.Enabled = False cmdModify.Enabled = False cmdRefresh.Enabled = True cmdCancel.Enabled = True cmdDelete.Enabled = False cmbMachineNo.Visible = True txtMachineNo.Visible = False End Sub Private Sub cmdRefresh_Click() '***************************************************** '*DAO Start '***************************************************** 'Data1.DatabaseName = App.Path & "\Cyber.mdb" ' Data1.RecordSource = "select * from MachineRecords" ' Data1.Refresh 'Data1.Recordset.FindFirst "MachineNo='" & txtMachineNo.Text & "'" 'Data1.Recordset.Delete 'MsgBox "Record has been Deleted" 'Data1.Recordset.MoveFirst 'If Data1.Recordset.RecordCount = 0 Then 'MsgBox "No Record Found", , "Message" 'Exit Sub 'End If ' txtMachineNo.Text = "" ' txtMachineName.Text = "" ' cmbMachineNo.Clear 'Data1.DatabaseName = App.Path & "\Cyber.mdb" 'Data1.RecordSource = "select * from MachineRecords"

Project Report :: Cyber Caf Management System

'Data1.Refresh ''cmbMachineNo.AddItem "Select a Machine name" 'Do While Not Data1.Recordset.EOF 'cmbMachineNo.AddItem Data1.Recordset("MachineNo") 'Data1.Recordset.MoveNext 'Loop ''cmbMachineNo.ListIndex = 0 'cmdRefresh.Visible = False 'cmdAddNew.Visible = True 'cmdModify.Visible = True 'cmdDelete.Visible = True '***************************************************** '*DAO End '***************************************************** '***************************************************** '*ADO Start '***************************************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where MachineNo='" & txtMachineNo.Text & "'", CN If rs.RecordCount > 0 Then rs.Delete adAffectCurrent MsgBox "Record has been Deleted" Else MsgBox "No Record Found", , "Message" Exit Sub End If txtMachineNo.Text = "" txtMachineName.Text = "" cmbMachineNo.Clear If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords", CN While rs.EOF = False cmbMachineNo.AddItem rs("MachineNo") rs.MoveNext Wend 'rs.Update

Project Report :: Cyber Caf Management System

cmdRefresh.Enabled = False cmdAddNew.Enabled = True cmdModify.Enabled = True cmdDelete.Enabled = True '***************************************************** '*ADO End '***************************************************** End Sub Private Sub cmdExit_Click() Unload Me End Sub Private Sub Form_Load() '***************************************************** 'DAO Start '***************************************************** 'Data1.DatabaseName = App.Path & "\Cyber.mdb" 'Data1.RecordSource = "select * from MachineRecords" 'Data1.Refresh 'cmbMachineNo.AddItem "Select a Machine name" 'Do While Not Data1.Recordset.EOF 'cmbMachineNo.AddItem Data1.Recordset("MachineNo") 'Data1.Recordset.MoveNext 'Loop 'cmbMachineNo.ListIndex = 0 '************************************ 'DAO End '************************************ '****************************************************** 'ADO Start '****************************************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords", CN While rs.EOF = False cmbMachineNo.AddItem rs("MachineNo") rs.MoveNext Wend '**************************************** 'ADO End '***************************************

Project Report :: Cyber Caf Management System

cmdRefresh.Enabled = False cmdOk.Enabled = False txtMachineNo.Locked = True 'cmdAddNew.SetFocus 'cmdCancel.SetFocus = True End Sub Private Sub txtMachineName_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdOk.SetFocus End If End Sub Private Sub txtMachineNo_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtMachineName.SetFocus End If End Sub Public Sub check() End Sub

Project Report :: Cyber Caf Management System

9). Rate Setting (frmRateSetting.frm)


Dim rs As New ADODB.Recordset Private Sub cmdOK_Click() If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from RateSetting where EndingDate is null", CN rs("EndingDate") = Date rs.Update rs.AddNew rs.Fields("OneHour") = Val(txtPerHour.Text) 'rs.Fields("15_30") = Val(txtFifteenThirty.Text) 'rs.Fields("30_45") = Val(txtZeroFifteen.Text) 'rs.Fields("45_60") = Val(txtZeroFifteen.Text) rs.Fields("StartingDate") = Date rs.Update MsgBox "Settings has benn Updated" cmdOk.Enabled = False cmdModify.Enabled = True ''txtZeroFifteen.Locked = True ''txtFifteenThirty.Locked = True ''txtThirtyFortyfive.Locked = True ''txtFortyfiveSixty.Locked = True End Sub Private Sub cmdModify_Click() s = MsgBox("Want to Modify your Settings", vbYesNo, "Settings") If s <> vbYes Then Exit Sub txtStartingDate.Visible = False Label2.Visible = False txtPerHour.Text = "" txtPerHour.SetFocus 'txtZeroFifteen.Locked = False 'txtFifteenThirty.Locked = False 'txtThirtyFortyfive.Locked = False 'txtFortyfiveSixty.Locked = False cmdOk.Enabled = True cmdModify.Enabled = False End Sub

Project Report :: Cyber Caf Management System

Private Sub cmdCancel_Click() Unload Me End Sub Private Sub Form_Load() If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from RateSetting where EndingDate is Null", CN txtPerHour.Text = rs.Fields("OneHour") txtStartingDate.Text = rs.Fields("StartingDate") cmdOk.Enabled = False End Sub

Project Report :: Cyber Caf Management System

10). Transaction (frmTransaction.frm)


Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Dim rs As New ADODB.Recordset Dim rs1 As New ADODB.Recordset Private Sub cmbMachineNo_Click() '********************************************** 'DAO Start '********************************************** 'Data1.DatabaseName = App.Path & "\Cyber.mdb" 'Data1.RecordSource = "select * from machine_records" 'Data1.Refresh 'Data1.Recordset.FindFirst "machine_no='" & cmbMachineNo.Text & "'" 'If Data1.Recordset.NoMatch = True Then 'txtMachineName.Text = "" 'cmdOk.Enabled = False ''MsgBox "Machine No doesn't exit" 'Exit Sub 'End If 'txtMachineName.Text = Data1.Recordset("machine_name") 'cmdOk.Enabled = True '*********************************************** 'ADO Start '*********************************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where MachineNo='" & cmbMachineNo.Text & "'", CN If rs.RecordCount > 0 Then txtMachineName.Text = rs("MachineName") M1.Text = Format(Now, "dd/mm/yyyy") txtStartTime.Text = Time cmdOk.Enabled = True 'MsgBox "Machine No doesn't exit" Exit Sub End If xtMachineName.Text = "" cmdOk.Enabled = False

Project Report :: Cyber Caf Management System

End Sub Private Sub cmdOK_Click() '*********************************** 'DAO Start '*********************************** ' Data2.DatabaseName = App.Path & "\Cyber.mdb" ' Data2.RecordSource = "select * from machine_records" ' Data2.Refresh ' Data2.Recordset.FindFirst "machine_no='" & cmbMachineNo.Text & "'" ' 'If Not IsNull(Data2.Recordset("hr")) Then ' 'MsgBox "Machine is Already Alloted", , "Warning" ' 'Exit Sub ' 'End If ' If Data2.Recordset("oc") = True Then ' MsgBox "Machine is Already Alloted", , "Warning" ' Exit Sub ' Else ' Data2.Recordset.Edit ' Data2.Recordset("oc") = True ' Data2.Recordset.Update ' End If ' r = MsgBox("New Entery", vbYesNo, "Entery") ' If r <> vbYes Then Exit Sub 'Data1.DatabaseName = App.Path & "\Cyber.mdb" 'Data1.RecordSource = "select * from transaction" 'Data1.Refresh 'Data1.Recordset.AddNew 'Data1.Recordset("start_time") = CDate(txtStartTime.Text) 'Data1.Recordset("machine_no") = cmbMachineNo.Text 'Data1.Recordset("date") = Format(CVDate(M1.Text), "dd/mm/yyyy") ''********** ''Data1.Recordset("end_time") = 0 ''Data1.Recordset("total_time") = 0 ''Data1.Recordset("amount") = 0 ''Data1.Recordset("bill_no") = 0 ''Data1.Recordset("mont") = 0 ''Data1.Recordset("yr") = 0 ''Data1.Recordset("hr") = 0 ''Data1.Recordset("mnts") = 0 'Debug.Print Format(CVDate(M1.Text), "dd/mm/yyyy") 'Data1.Recordset.Update 'cmdOk.Enabled = False

Project Report :: Cyber Caf Management System

'Debug.Print modconn.sa '************************************************ 'ADO Start '*********************************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where MachineNo='" & cmbMachineNo.Text & "'", CN If rs.RecordCount > 0 Then 'If rs("CurrentStatus") = True Then ' MsgBox "Machine is Already Alloted", , "Warning" ' Exit Sub ' Else rs("CurrentStatus") = True rs.Update End If ' r = MsgBox("New Entery", vbYesNo, "Entery") ' If r <> vbYes Then Exit Sub If rs1.State = adStateOpen Then rs1.Close End If rs1.CursorLocation = adUseClient rs1.CursorType = adOpenStatic rs1.LockType = adLockOptimistic rs1.Open "select * from Tran", CN ' rs1.AddNew rs1("StartTime") = CDate(txtStartTime.Text) rs1("MachineNo") = cmbMachineNo.Text rs1("Date") = Format(CVDate(M1.Text), "dd/mm/yyyy") rs1.Update 'Data1.Recordset.Update 'loadTransaction cmdOk.Enabled = False 'Form_Load 'Debug.Print modconn.sa cmbMachineNo.Clear txtMachineName.Text = "" txtStartTime.Text = "" 'M1.Text = ""

Project Report :: Cyber Caf Management System

'****************************** If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where CurrentStatus=False ", CN If rs.RecordCount > 0 Then While rs.EOF = False cmbMachineNo.AddItem rs("MachineNo") rs.MoveNext Wend 'End If 'cmbMachineNo.Text = cmbMachineNo.List(0) End If cmdOk.Enabled = False '***************************** End Sub Private Sub cmdCancel_Click() '****************************** 'DAO Start '****************************** 'Data1.DatabaseName = App.Path & "\Cyber.mdb" 'Data1.RecordSource = "select * from machine_records" 'Data1.Refresh 'Data1.Recordset.CancelUpdate '******************************* 'ADO Start '******************************* If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords", CN rs.CancelUpdate End Sub Private Sub cmdExit_Click() Unload Me End Sub

Project Report :: Cyber Caf Management System

Private Sub Command4_Click() ShellExecute 0, "Open", "http://www.rediffmail.com", 0, 0, SW_MAXIMIZE End Sub Private Sub Form_Load() '********************************************* 'DAO Start '********************************************* 'Data1.DatabaseName = App.Path & "\Cyber.mdb" 'Data1.RecordSource = "select * from machine_records" 'Data1.Refresh 'cmbMachineNo.AddItem "Select a Machine No" 'Do While Not Data1.Recordset.EOF 'cmbMachineNo.AddItem Data1.Recordset("machine_no") 'Data1.Recordset.MoveNext 'Loop 'cmbMachineNo.Text = cmbMachineNo.List(0) 'M1.Text = Format(Now, "dd/mm/yyyy") 'txtStartTime.Text = Time '************************************************** 'ADO Start '************************************************** cmdOk.Enabled = False If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from MachineRecords where CurrentStatus=False order by MachineNo", CN If rs.RecordCount > 0 Then While rs.EOF = False cmbMachineNo.AddItem rs("MachineNo") rs.MoveNext Wend 'End If cmbMachineNo.Text = cmbMachineNo.List(0) End If M1.Text = Format(Now, "dd/mm/yyyy") 'txtStartTime.Text = Time End Sub Public Sub loadTransaction() If rs1.State = adStateOpen Then rs1.Close End If

Project Report :: Cyber Caf Management System

rs1.CursorLocation = adUseClient rs1.CursorType = adOpenStatic rs1.LockType = adLockOptimistic rs1.Open "select * from Tran", CN rs1.AddNew rs1("StartTime") = CDate(txtStartTime.Text) rs1("MachineNo") = cmbMachineNo.Text rs1("Date") = Format(CVDate(M1.Text), "dd/mm/yyyy") rs1.Update End Sub

Project Report :: Cyber Caf Management System

11). MDI Form (MDIForm1.frm) ::


'Public cur_user As String 'Dim ST As Boolean 'Public cur_company_name As String 'Dim comp_saved As Boolean 'Public LOGOUT_CLICKED As Boolean Dim rs As New ADODB.Recordset Private Sub MDIForm_Load() SetMenus hwnd, SmallImages 'mnu_int_admin.Enabled = False mnu_createNUser.Enabled = False 'mnu_changeUPassword.Enabled = False mnu_computerSetting.Enabled = False mnu_deleteRecord.Enabled = False mnu_rateOBilling.Enabled = False End Sub Private Sub MDIForm_Unload(Cancel As Integer) Unload frmInitialization End Sub Private Sub mnu_about_Click() frmAbout.Show End Sub Private Sub mnu_calc_Click() On Error Resume Next Shell ("calc"), vbMinimizedFocus Exit Sub End Sub Private Sub mnu_changeUPassword_Click() frmChangePassword.Show End Sub Private Sub mnu_computerSetting_Click() frmpcsetting.Show End Sub Private Sub mnu_createNUser_Click() frmAddnewUser.Show End Sub

Project Report :: Cyber Caf Management System

Private Sub mnu_deleteRecord_Click() frmDeleteUser.Show End Sub Private Sub mnu_exit_Click() Unload Me End Sub Private Sub mnu_expense_Click() frmBilling.Show End Sub Private Sub mnu_income_Click() frmTransaction.Show End Sub Private Sub mnu_log_out_Click() Unload MDIForm1 Unload frmInitialization frmInitialization.Show End Sub Private Sub mnu_mine_Click() On Error Resume Next Shell "winmine", vbNormalFocus Exit Sub End Sub Private Sub mnu_notepad_Click() On Error Resume Next Shell ("notepad"), vbMaximizedFocus Exit Sub End Sub Private Sub mnu_osk_Click() On Error Resume Next Shell "osk", vbNormalFocus Exit Sub End Sub Private Sub mnu_rateOBilling_Click() frmRateSetting.Show End Sub Private Sub mnu_sol_Click() On Error Resume Next

Project Report :: Cyber Caf Management System

Shell "sol", vbNormalFocus Exit Sub End Sub Private Sub mnu_we_Click() On Error Resume Next Shell ("explorer"), vbMaximizedFocus Exit Sub End Sub Private Sub mnuCalender_Click() frmCalender.Show End Sub Private Sub mnucyber_Click() 'frmHelp.Show End Sub Private Sub rp_menu_int_sales_Click() If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Users", CN Set rptTotalUSer.DataSource = rs rptTotalUSer.Show End Sub Private Sub un_cr_report_Click() On Error GoTo last ' Dim db As Connection ' Set db = New Connection ' db.CursorLocation = adUseClient ' db.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=" & M.FileName & ";" ' ''''''''''''''''''''''''''''''''''''''' ' Set adoprimaryrs = New Recordset 'rs.Open "select MemberId,BooksInHand,FineBal,Tel,Email,Address from Members where FineBal>0", db, adOpenStatic, adLockOptimistic 'Set FineBalReport.DataSource = rs 'FineBalReport.Show Dte = InputBox("Enter The Date:MM/DD/YYYY") If Dte <> vbCancel Then If rs.State = adStateOpen Then rs.Close

Project Report :: Cyber Caf Management System

End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Tran where Date=#" & Dte & "#", CN If rs.RecordCount > 0 Then Set rptDailyTotalReport.DataSource = rs rptDailyTotalReport.Show Else MsgBox "No Record Found" Exit Sub End If Exit Sub last: MsgBox "Your Supplied Criteria isn't Meaninig full" Exit Sub 'cancel: Else MsgBox "Operation Cancel" End If End Sub Private Sub un_pr_book_Click() 'CrystalReport1.ReportFileName = App.Path + "\PcStatus.rpt" 'CrystalReport1.Action = 0 On Error GoTo last Mon = InputBox("Enter The Month") 'rptMounthlyReport If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Tran where Month(Date)='" & Mon & "'", CN If rs.RecordCount > 0 Then Set rptMounthlyReport.DataSource = rs rptMounthlyReport.Show Else MsgBox "No Record Found" Exit Sub End If Exit Sub last: MsgBox "Your Supplied Criteria isn't Meaninig full"

Project Report :: Cyber Caf Management System

End Sub Private Sub un_sales_book_Click() 'On Error GoTo last: Yea = InputBox("Enter The Year:YYYY") If rs.State = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "select * from Tran where Year(Date)='" & Yea & "' order by MachineNo", CN If rs.RecordCount > 0 Then Set rptYearlyReport.DataSource = rs rptYearlyReport.Show Else MsgBox "No Record Found" Exit Sub End If Exit Sub End Sub

Project Report :: Cyber Caf Management System

Decription of Modules And Their Code 1). Module Connection (modconn.bas) ::


'Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Public sa Public ent As Boolean Public c As Integer 'count = 0 '******************************** 'This two variables are used for change password '************************ Public User As Boolean Public UserNa As Variant '***************************** Public ID As String Public CN As New ADODB.Connection Public Sub AttendConn() CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & App.Path & "\CyberCafe.mdb;Jet OLEDB:Database Password=babu;" CN.Open User = False End Sub Public Sub CloseConn() CN.Close Set CN = Nothing End Sub Public Sub counted() End Sub

Project Report :: Cyber Caf Management System

2). Module Drawing (modDrawingXP.bas) ::


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" _ (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 Project Report :: Cyber Caf Management System

' 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 Private Const DT_CENTER = &H1 ' Types used for fonts & images Public Type POINTAPI x As Long y As Long End Type Public Type LOGFONT lfHeight As Long

Project Report :: Cyber Caf Management System

lfWidth As Long lfEscapement As Long lfOrientation As Long lfWeight As Long lfItalic As Byte '0=false; 255=true lfUnderline As Byte '0=f; 255=t lfStrikeOut As Byte '0=f; 255=t lfCharSet As Byte lfOutPrecision As Byte lfClipPrecision As Byte lfQuality As Byte lfPitchAndFamily As Byte lfFaceName As String * 32 End Type Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type TEXTMETRIC tmHeight As Long tmAscent As Long tmDescent As Long tmInternalLeading As Long tmExternalLeading As Long tmAveCharWidth As Long tmMaxCharWidth As Long tmWeight As Long tmOverhang As Long tmDigitizedAspectX As Long tmDigitizedAspectY As Long tmFirstChar As Byte tmLastChar As Byte tmDefaultChar As Byte tmBreakChar As Byte tmItalic As Byte tmUnderlined As Byte tmStruckOut As Byte tmPitchAndFamily As Byte tmCharSet As Byte End Type Private Type NONCLIENTMETRICS cbSize As Long iBorderWidth As Long iScrollWidth As Long

Project Report :: Cyber Caf Management System

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 Private m_hDC As Long ' reference to DC being drawn in

Project Report :: Cyber Caf Management System

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 Public Sub DrawRect(ByVal x1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) ' ===================================================================== ' Simply draws a rectangle using the current DC's background color ' ===================================================================== If m_hDC = 0 Then Exit Sub Call Rectangle(m_hDC, x1, Y1, X2, Y2) End Sub Public Function GetPen(ByVal nWidth As Long, ByVal Clr As Long) As Long ' ===================================================================== ' Creates a colored pen for drawing ' ===================================================================== GetPen = CreatePen(0, nWidth, Clr) End Function Public Sub DrawCaption(ByVal x As Long, ByVal y As Long, tRect As RECT, _ ByVal hStr As String, hAccel As String, iTab As Integer, _ ByVal Clr As Long, Optional bCenter As Boolean = False, _ Optional iOffset As Integer = 0) ' ===================================================================== ' 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 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

Project Report :: Cyber Caf Management System

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 Public Property Let TargethDC(ByVal vNewValue As Long) ' ===================================================================== ' Maintain a local reference to the DC being drawn in ' simply prevents having to pass it to each call to a drawing routine ' ===================================================================== m_hDC = vNewValue End Property Public Sub ThreeDbox(ByVal x1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long, bSelected As Boolean, _ Optional Sunken As Boolean = False) If m_hDC = 0 Then Exit Sub Dim CurPen As Long, OldPen As Long Dim dm As POINTAPI, iOffset As Integer ' 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) 'First - Light Line MoveToEx m_hDC, x1 + 2, Y2, dm LineTo m_hDC, x1 + 2, Y1 LineTo m_hDC, X2 - 2, Y1 SelectObject m_hDC, OldPen DeleteObject CurPen ' Next - Dark line If Sunken = False Then

Project Report :: Cyber Caf Management System

CurPen = GetPen(1, GetSysColor(Choose(iOffset, COLOR_MENU, COLOR_BTNSHADOW))) Else CurPen = GetPen(1, GetSysColor(Choose(iOffset, COLOR_MENU, COLOR_BTNHIGHLIGHT))) End If OldPen = SelectObject(m_hDC, CurPen) MoveToEx m_hDC, X2 - 2, Y1, dm LineTo m_hDC, X2 - 2, Y2 LineTo m_hDC, x1 + 2, Y2 ' Replace pen & delete temp pen SelectObject m_hDC, OldPen DeleteObject CurPen End Sub Public Sub DrawMenuIcon(lImageHdl As Long, ImageType As Long, _ rt As RECT, bdisabled As Boolean, Optional bInColor As Boolean = True, _ Optional bForceTransparency As Long = 0, Optional iOffset As Integer = 0, _ Optional yOffset As Integer, Optional IMGwidth As Integer = 16, _ Optional IMGheight As Integer = 16, Optional lMask As Long = -1) ' ensure the requested image exists If lImageHdl = 0 Then Exit Sub Dim lImageSmall As Long, lDrawType As Long, lImageType As Long Const DSS_DISABLED = &H20 Const DSS_NORMAL = &H0 Const DSS_BITMAP = &H4 Const DSS_ICON = &H3 Const CI_BITMAP = &H0 Const CI_ICON = &H1 Dim rcImage As RECT If ImageType < 2 Then lDrawType = DSS_BITMAP lImageType = CI_BITMAP Else lDrawType = DSS_ICON lImageType = CI_ICON End If lImageSmall = CopyImage(lImageHdl, lImageType, IMGwidth, IMGheight, DSS_NORMAL) If lImageSmall = 0 Then ' failed to make a copy from the imagetype passed, try the other settings If lDrawType = DSS_BITMAP Then lDrawType = DSS_ICON lImageType = CI_ICON Else

Project Report :: Cyber Caf Management System

lDrawType = DSS_BITMAP lImageType = CI_BITMAP End If lImageSmall = CopyImage(lImageHdl, lImageType, IMGwidth, IMGheight, DSS_NORMAL) End If If lImageSmall = 0 Then Exit Sub If bdisabled = False Then ' if not disabled, then straightforward extraction/drawing on coords If ((lImageType = CI_ICON And bForceTransparency < 2) Or bForceTransparency = 2) Then DrawState m_hDC, 0, 0, lImageSmall, 0, rt.Left + iOffset, rt.Top + yOffset, 0, 0, lDrawType Else MakeTransparentBitmap lImageSmall, rt.Left + iOffset, rt.Top + yOffset, IMGwidth, IMGheight, , , lMask End If DeleteObject lImageSmall 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 ' // create mono or color bitmap Dim hBitmap As Long If bInColor Then hBitmap& = CreateCompatibleBitmap(m_hDC&, IMGwidth, IMGheight) Else hBitmap& = CreateBitmap(IMGwidth, IMGheight, 1, 1, vbNull) End If ' // draw image into memory DC--fill BG white first ' // create memory dc Dim hOldBitmap As Long Dim hmemDC As Long hmemDC& = CreateCompatibleDC(m_hDC&) hOldBitmap = SelectObject(hmemDC&, hBitmap&) Call PatBlt(hmemDC&, 0, 0, IMGwidth, IMGheight, WHITENESS) If (lImageType = CI_ICON And bForceTransparency < 2) Or bForceTransparency = 2 Then DrawState hmemDC&, 0, 0, lImageSmall, 0, 0, 0, 0, 0, lDrawType Else MakeTransparentBitmap lImageSmall, 0, 0, IMGwidth, IMGheight, , , lMask, hmemDC End If DeleteObject lImageSmall ' // This seems to be required. Dim hOldBackColor As Long hOldBackColor& = SetBkColor(m_hDC&, RGB(255, 255, 255)) ' // Draw using hilite offset by (1,1), then shadow Dim hbrShadow As Long, hbrHilite As Long

Project Report :: Cyber Caf Management System

hbrShadow& = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW)) hbrHilite& = CreateSolidBrush(GetSysColor(COLOR_BTNHIGHLIGHT)) Dim hOldBrush As Long hOldBrush& = SelectObject(m_hDC&, hbrHilite&) Call BitBlt(m_hDC&, rt.Left + 1 + iOffset, rt.Top + 1 + yOffset, IMGwidth, IMGheight, hmemDC&, 0, 0, MAGICROP) Call SelectObject(m_hDC&, hbrShadow&) Call BitBlt(m_hDC&, rt.Left + iOffset, rt.Top + yOffset, IMGwidth, IMGheight, hmemDC&, 0, 0, MAGICROP) 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 Private Sub MakeTransparentBitmap(imgHdl As Long, _ ByVal xDest As Long, _ ByVal yDest As Long, _ ByVal Width As Long, _ ByVal Height As Long, _ Optional xSrc As Long = 0, _ Optional ByVal ySrc As Long = 0, _ Optional clrMask As OLE_COLOR = -1, _ Optional destDC As Long = 0) Dim hdcSrc As Long Dim hbmMemSrcOld As Long Dim hdcMask As Long 'HDC of the created mask image Dim hdcColor As Long 'HDC of the created color image Dim hbmMask As Long 'Bitmap handle to the mask image Dim hbmColor As Long 'Bitmap handle to the color image Dim hbmColorOld As Long Dim hbmMaskOld As Long Dim hPalOld As Long Dim hdcScreen As Long Dim hdcScnBuffer As Long 'Buffer to do all work on

Project Report :: Cyber Caf Management System

Dim hbmScnBuffer As Long Dim hbmScnBufferOld As Long Dim hPalBufferOld As Long Dim lMaskColor As Long Const hPal As Long = 0 On Error Resume Next hdcScreen = GetDC(0&) If destDC = 0 Then destDC = m_hDC hdcSrc = CreateCompatibleDC(hdcScreen) hbmMemSrcOld = SelectObject(hdcSrc, imgHdl) RealizePalette hdcSrc If clrMask < 0 Then clrMask = GetPixel(hdcSrc, 0, 0) OleTranslateColor clrMask, hPal, lMaskColor 'Create a color bitmap to server as a copy of the destination 'Do all work on this bitmap and then copy it back over the 'destination when it's done. hbmScnBuffer = CreateCompatibleBitmap(hdcScreen, Width, Height) 'Create DC for screen buffer hdcScnBuffer = CreateCompatibleDC(hdcScreen) hbmScnBufferOld = SelectObject(hdcScnBuffer, hbmScnBuffer) hPalBufferOld = SelectPalette(hdcScnBuffer, hPal, True) RealizePalette hdcScnBuffer 'Copy the destination to the screen buffer BitBlt hdcScnBuffer, 0, 0, Width, Height, destDC, xDest, yDest, vbSrcCopy 'Create a (color) bitmap for the cover (can't use 'CompatibleBitmap with hdcSrc, because this will create a 'DIB section if the original bitmap is a DIB section) hbmColor = CreateCompatibleBitmap(hdcScreen, Width, Height) 'Now create a monochrome bitmap for the mask hbmMask = CreateBitmap(Width, Height, 1, 1, ByVal 0&) 'First, blt the source bitmap onto the cover. We do this 'first and then use it instead of the source bitmap 'because the source bitmap may be 'a DIB section, which behaves differently than a bitmap. '(Specifically, copying from a DIB section to a monochrome 'bitmap does a nearest-color selection rather than painting 'based on the backcolor and forecolor. hdcColor = CreateCompatibleDC(hdcScreen) hbmColorOld = SelectObject(hdcColor, hbmColor) hPalOld = SelectPalette(hdcColor, hPal, True) RealizePalette hdcColor 'In case hdcSrc contains a monochrome bitmap, we must set

Project Report :: Cyber Caf Management System

'the destination foreground/background colors according to 'those currently set in hdcSrc (because Windows will 'associate these colors with the two monochrome colors) SetBkColor hdcColor, GetBkColor(hdcSrc) SetTextColor hdcColor, GetTextColor(hdcSrc) BitBlt hdcColor, 0, 0, Width, Height, hdcSrc, xSrc, ySrc, vbSrcCopy 'Paint the mask. What we want is white at the transparent 'color from the source, and black everywhere else. hdcMask = CreateCompatibleDC(hdcScreen) hbmMaskOld = SelectObject(hdcMask, hbmMask) 'When bitblt'ing from color to monochrome, Windows sets to 1 '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

Project Report :: Cyber Caf Management System

DeleteDC hdcColor DeleteObject SelectObject(hdcScnBuffer, hbmScnBufferOld) SelectPalette hdcScnBuffer, hPalBufferOld, True RealizePalette hdcScnBuffer DeleteDC hdcScnBuffer DeleteObject SelectObject(hdcMask, hbmMaskOld) DeleteDC hdcMask ReleaseDC 0&, hdcScreen SelectObject hdcSrc, hbmMemSrcOld RealizePalette hdcSrc DeleteDC hdcSrc ReleaseDC 0&, hdcScreen End Sub Public Sub SetMenuFont(bSet As Boolean, Optional hDC As Long, _ Optional bReduced As Boolean = False, Optional otherFont As Long = 0) ' reference the current DC for all drawing If hDC Then m_hDC = hDC If bSet Then ' in order to set the font, we must first determine what it is If m_Font(0) = 0 And otherFont = 0 Then Dim ncm As NONCLIENTMETRICS, newFont As LOGFONT ncm.cbSize = Len(ncm) ' this will return the system font info along with other stuff SystemParametersInfo 41, 0, ncm, 0 ' here we create a memory font based off of system menu font newFont = ncm.lfMenuFont m_Font(0) = CreateFontIndirect(newFont) ' now we are going to try to create a scalable font for ' separator bar text just in case the computer's menu font ' is not scalable. The following is a shortcut way of creating ' the font & I hope it works on all systems! newFont.lfFaceName = "Tahoma" & Chr$(0) newFont.lfCharSet = 1 newFont.lfHeight = (7.5 * -20) / Screen.TwipsPerPixelY 'newFont.lfHeight = newFont.lfHeight + 1 m_Font(1) = CreateFontIndirect(newFont) End If ' add the font to the DC & keep reference to old font ' Calling routines responsbile for restoring original font ' with call back to this routine & a FALSE parameter If m_FontOld = 0 And otherFont = 0 Then m_FontOld = SelectObject(m_hDC, m_Font(Abs(CInt(bReduced))))

Project Report :: Cyber Caf Management System

Else If otherFont Then SelectObject m_hDC, otherFont Else SelectObject m_hDC, m_Font(Abs(CInt(bReduced))) End If End If Else ' Restoring old font If m_hDC = 0 Then Exit Sub SelectObject m_hDC, m_FontOld End If End Sub Public Sub DestroyMenuFont() ' ===================================================================== ' Simply destroy the memory font to free up resources ' ===================================================================== On Error Resume Next SelectObject m_hDC, m_FontOld DeleteObject m_Font(0) DeleteObject m_Font(1) m_Font(0) = 0 m_Font(1) = 0 End Sub Public Sub DoGradientBkg(lColor As Long, tRect As RECT, hwnd As Long) '======================================================================= '======================================================================= Dim sColor As String, i As Integer, tmpSB As PictureBox, formID As Long Dim R As Integer, B As Integer, G As Integer Dim lColorStep As Long, lNewColor As Long On Error GoTo GradientErrors ' we are going to create a picturebox to draw the gradient in ' tried drawing directly to hdc via MoveTo & LineTo APIs, but ' everytime, it failed -- maybe Win98, maybe my graphics card? ' This works though a little slower formID = GetFormHandle(hwnd) ' create the picture box in memory Set tmpSB = Forms(formID).Controls.Add("VB.PictureBox", "pic___tmp_s_b", Forms(formID)) With tmpSB ' set picturebox attributes .Visible = False

Project Report :: Cyber Caf Management System

.BorderStyle = 0 .AutoRedraw = True .DrawMode = 13 .DrawWidth = 1 .Height = .ScaleY(tRect.Bottom, vbPixels, .ScaleMode) .Width = .ScaleX(tRect.Right, vbPixels, .ScaleMode) .ScaleMode = vbPixels 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

Project Report :: Cyber Caf Management System

Public Sub DrawCheckMark(pRect As RECT, lColor As Long, _ bdisabled As Boolean, Optional xtraOffset As Long = 0) Dim CurPen As Long, OldPen As Long Dim dm As POINTAPI Dim yOffset As Integer, xOffset As Integer Dim x1 As Integer, X2 As Integer Dim Y1 As Integer, Y2 As Integer CurPen = GetPen(1, lColor) OldPen = SelectObject(m_hDC, CurPen) xOffset = 6 + xtraOffset yOffset = pRect.Top + 6 ' Here we are simply tracing the outline of a check box ' Created by opening a 8x8 bitmap editor and drawing a ' simple checkmark from left to right, bottom to top MoveToEx m_hDC, 1 + xOffset, 4 + yOffset, dm LineTo m_hDC, 2 + xOffset, 4 + yOffset LineTo m_hDC, 2 + xOffset, 5 + yOffset LineTo m_hDC, 3 + xOffset, 5 + yOffset LineTo m_hDC, 3 + xOffset, 6 + yOffset LineTo m_hDC, 4 + xOffset, 6 + yOffset LineTo m_hDC, 4 + xOffset, 4 + yOffset LineTo m_hDC, 5 + xOffset, 4 + yOffset LineTo m_hDC, 5 + xOffset, 2 + yOffset LineTo m_hDC, 6 + xOffset, 2 + yOffset LineTo m_hDC, 6 + xOffset, 1 + yOffset LineTo m_hDC, 7 + xOffset, 1 + yOffset LineTo m_hDC, 7 + xOffset, 0 + yOffset ' replace original pen SelectObject m_hDC, OldPen DeleteObject CurPen End Sub

Project Report :: Cyber Caf Management System

3) Menus (modMenus.bas) ::
Option Explicit ' Types used to retrieve current menu item information Public Type MenuDataInformation ' information to store menu data ItemHeight As Integer ' submenu item height ItemWidth As Long ' pixel width of caption and hotkey Icon As Long ' icon index HotKeyPos As Integer ' instr position for hotkey Status As Byte ' 2=Separator, 4=ForceTransparency 8=ForceNoTransparency Caption As String ' Caption OriginalCaption As String ' used to check for updated menu captions Parent As Long ' submenu ID ID As Long ' menu item ID End Type Public Type PanelDataInformation Height As Long ' height of the menu panel Width As Long ' width of the menu panel HKeyPos As Long ' left edge for all hot keys SideBar As Long ' width of SideBar (default is 32) SideBarXY As Long ' X,Y coords of image/text within sidebar PanelIcon As Long ' does 1 or more menu items have an icon Status As Byte ' icon or bitmap, 0 for text Caption As String ' Text, unless image is used instead FColor As Long ' Sidebar text fore color BColor As Long ' Sidebar back color SBarIcon As Long ' icon/bitmap ID for sidebar, Font ID for text ID As Long End Type Private Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long Project Report :: Cyber Caf Management System

wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As Long 'String 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 ' used to help identify operating system 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 fIcon As Long

Project Report :: Cyber Caf Management System

xHotSpot As Long yHotSpot As Long hbmMask As Long hbmColor As Long End Type ' APIs needed to retrieve menu information Private Declare Function WindowFromDC Lib "user32" (ByVal hDC As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (LpVersionInformation As OSVERSIONINFO) As Long Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long Private Declare Function GetMenuItemInfo Lib "user32" Alias _ "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, _ ByVal byPosition As Long, lpMenuItemInfo As MENUITEMINFO) As Boolean Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long Public Declare Sub CopyMemory Lib "kernel32" Alias _ "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen As Long) Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long Private Declare Function GetIconInfo Lib "user32" (ByVal hIcon As Long, piconinfo As ICONINFO) As Long Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long ' Subclassing APIs & stuff Public Declare Function CallWindowProc Lib "user32" Alias _ "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _ ByVal hwnd As Long, ByVal MSG As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long

Project Report :: Cyber Caf Management System

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 Private Const GMEM_FIXED = &H0 Private Const GMEM_ZEROINIT = &H40 Private Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT) ' Menu Constants Private Const MF_BYCOMMAND = &H0 Private Const MF_BYPOSITION = &H400 Private Const MF_OWNERDRAW = &H100 Private Const MF_SEPARATOR = &H800 Private Const MFT_SEPARATOR = MF_SEPARATOR Private Const ODS_SELECTED = &H1 Private Const ODT_MENU = 1 Private Const MIIM_TYPE = &H10 Private Const MIIM_DATA = &H20 Private Const MIIM_SUBMENU = &H4 Private MenuData As Collection ' Collection of clsMyMenu objects Private ActiveHwnd As String ' Index to focused form Private iTabOffset As Integer ' See DetermineOS function Private lSubMenu As Long Private lMDIchildClosed As Long Private VisibleMenus As Collection Public Sub SetMenus(Form_hWnd As Long, Optional MenuImageList As Control) If bAmDebugging Then Exit Sub ' here we set the collection index & see if it's already been subclassed Dim lMenus As Long, Looper As Integer On Error Resume Next

Project Report :: Cyber Caf Management System

If GetFormHandle(Form_hWnd) = -1 Then Exit Sub lMenus = MenuData(CStr(Form_hWnd)).MainMenuID If Err Then ' then new form to subclass ' 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 Public Sub ReleaseMenus(hwnd As Long) ' Sub prepares for Forms unloading ' This must be placed in the forms Unload event in order to ' release memory & prevent crash of program If MenuData Is Nothing Then Exit Sub On Error GoTo ByPassRelease ActiveHwnd = CStr(hwnd) ' set current index SetFreeWindow False ' unhook the window On Error Resume Next If MenuData(ActiveHwnd).ChildStatus = 1 Then lMDIchildClosed = MenuData(ActiveHwnd).ParentForm End If ' remove references to that form's class & ultimately unload the class MenuData.Remove ActiveHwnd If MenuData.Count = 0 Then

Project Report :: Cyber Caf Management System

' 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 Private Sub CleanMDIchildMenus() ' reset parent's menu items (see that routine for remarks) If lMDIchildClosed = 0 Then Exit Sub Dim Looper As Long, mMenu As Long, mII As MENUITEMINFO mII.cbSize = Len(mII) mII.fMask = &H1 Or &H2 mII.fType = 0 On Error Resume Next With MenuData(CStr(lMDIchildClosed)) For Looper = .PanelIDcount To 1 Step -1 mMenu = .GetPanelID(Looper) If GetMenuItemCount(mMenu) < 0 Then .PurgeObsoleteMenus mMenu Next End With lMDIchildClosed = 0 End Sub Public Function MsgProc(ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long ' Here we determine which messages will be processed, relayed or ' skipped. Basically, we send anything thru unless we are measuring ' or drawing an item. On Error GoTo SendMessageAsIs ' the following is a tell-tale sign of a system menu If lParam = &H10000 Then Err.Raise 5 ActiveHwnd = CStr(hwnd) ' ensure index to current form is set Select Case wMsg Case WM_ENTERMENULOOP 'Debug.Print "entering loop" ' When a menu is activated, no changes can be made to the captions, enabled status, etc ' So we will save each submenu as it is opened and read the info only once, ' 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

Project Report :: Cyber Caf Management System

' 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)).GetSetMDIchildSysMenu 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: MsgProc = CallWindowProc(MenuData(ActiveHwnd).OldWinProc, hwnd, wMsg, wParam, lParam) End Function Public Function GetMenuIconID(Menu_Caption As String) As Long

Project Report :: Cyber Caf Management System

' Returns the icon assigned in the menu caption as a long value ' Example: {IMG:9}&Open would return 9 ' Note: Not used in any modules here, but provided for programmer use ' if needed in their applications Dim i As Integer On Error GoTo NoIcon i = InStr(Menu_Caption, "{IMG:") If i Then GetMenuIconID = Val(Mid$(Menu_Caption, InStr(Menu_Caption, ":") + 1)) End If Exit Function NoIcon: GetMenuIconID = 0 End Function Private Sub GetMenuMetrics(hSubMenu As Long) ' Routine gets the meaurements of the submenus & their submenus, ' their checked status, enabled status, ' control keys, icon index, etc Dim lMenus As Long, hWndRedirect As String Dim Looper As Long, meDC As Long, lmnuID As Long, sysMenuLoc As Long Dim mII As MENUITEMINFO, mI() As Byte Dim tRect As RECT, lMetrics(0 To 10) As Long Dim sCaption As String, sBarCaption As String Dim sHotKey As String, bTabOffset As Boolean Dim IconID As Integer, iTransparency As Integer Dim bSetHotKeyOffset As Boolean, bNewItem As Boolean Dim bHasIcon As Boolean, bRecalcSideBar As Long Dim iSeparator As Integer, bSpecialSeparator As Boolean On Error Resume Next 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

Project Report :: Cyber Caf Management System

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 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

Project Report :: Cyber Caf Management System

' 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) 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

Project Report :: Cyber Caf Management System

' 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 ' 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

Project Report :: Cyber Caf Management System

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 Private Sub FindImageAndHotKey(hWndRedirect As String, sKey As String, imgTransparency As Integer, sAccel As String, imgIndex As Integer) On Error Resume Next Dim i As Integer, sSpecial As String, sHeader As String imgIndex = 0 imgTransparency = 0 If Left$(UCase(sKey), 5) = "{IMG:" Then i = InStr(sKey, "}") If i Then sHeader = UCase(Left$(sKey, i)) sKey = Mid$(sKey, i + 1) ' extract the image index imgIndex = Val(Mid$(sHeader, 6)) ' if the value<1 or >nr of images, then reset it to zero Debug.Print "icon count="; MenuData(hWndRedirect).TotalIcons If imgIndex < 1 Or imgIndex > MenuData(hWndRedirect).TotalIcons Then imgIndex = 0 Else ' optional transparency flag ' Y=always use transparency ' 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))

Project Report :: Cyber Caf Management System

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 Private Sub ReturnSideBarInfo(hWndRedirect As String, sBarInfo As String, vBarInfo() As Long, tDC As Long) Dim i As Integer, sImgID As String Dim lRatio As Single, sText As String Dim bMetrics As Boolean, sTmp As String Dim lFont As Long, lFontM As LOGFONT, hPrevFont As Long Dim tRect As RECT Dim imgInfo As BITMAP, picInfo As ICONINFO Dim TempBMP As Long, ImageDC As Long, sbarType As Integer ' 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 & "|"

Project Report :: Cyber Caf Management System

' 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) On Error Resume Next ' can't leave memory fonts running around loose -- wasted memory If MenuData(hWndRedirect).SideBarIsText = True And MenuData(hWndRedirect).SideBarItem <> 0 Then ' kill the previous font for this item, if any DeleteObject MenuData(hWndRedirect).SideBarItem End If vBarInfo(10) = 0 ' reset to force no sidebar ' use with caution. Making width too small or too large ' may prevent menu from displaying or crash on memory ' suggest using between 32 & 64 If InStr(UCase(sBarInfo), "|WIDTH:") Then ' width of the sidebar (user-provided) ' undocumented! this allows the sidebar width to be modified vBarInfo(4) = Val(Mid$(sBarInfo, InStr(UCase(sBarInfo), "|WIDTH:") + 7)) Else ' however, 32 pixels wide seems to look the best vBarInfo(4) = 32 ' default width of sidebars End If If IsNumeric(sImgID) Then ' user is providing image handle vs a form picture object 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

Project Report :: Cyber Caf Management System

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 ' 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

Project Report :: Cyber Caf Management System

' 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 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

Project Report :: Cyber Caf Management System

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. 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

Project Report :: Cyber Caf Management System

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) 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

Project Report :: Cyber Caf Management System

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 Private Sub SetFreeWindow(bSet As Boolean) If MenuData(ActiveHwnd).OldWinProc = 0 And bSet = True Then ' hook only if window not already hooked MenuData(ActiveHwnd).OldWinProc = SetWindowLong(CLng(ActiveHwnd), GWL_WNDPROC, AddressOf MsgProc) Else If MenuData(ActiveHwnd).OldWinProc <> 0 And bSet = False Then ' hook only if window was already hooked SetWindowLong CLng(ActiveHwnd), GWL_WNDPROC, MenuData(ActiveHwnd).OldWinProc MenuData(ActiveHwnd).OldWinProc = 0 End If End If End Sub Private Function CustomDrawMenu(wMsg As Long, lParam As Long, wParam As Long) As Boolean Dim IsSep As Boolean, hWndRedirect As String Static bDrawIcon As Boolean, bDrawPanel As Boolean, bGetPanelData As Boolean Static lOffsets(0 To 2) As Long, lLastSubMenu As Long ' MDI children menus are subclassed to parent by Windows ' However, if the child isn't maximized in the MDI parent, then the menus are ' not subclassed (pain in the neck until this was figured out & re-thought) ' To work around this & prevent the submenus from being stored in both the parent ' and child classes, I redirect the actions to the parent via the GetMenuMetrics sub ' regardless whether or not the child is maximized ' Since each menu drawn is now stored the parent class, we redirect to the routine to ' get the info from the parent. If the form is the MDI parent or is a non-MDI form, ' then the ParentForm property is the same as the form's actual handle hWndRedirect = MenuData(ActiveHwnd).ParentForm ' here we set this flag. Select Case wMsg Case WM_INITMENUPOPUP ' menu is about to be displayed, set flag to allow drawing of icons bDrawIcon = True: bDrawPanel = True: bGetPanelData = True lLastSubMenu = 0

Project Report :: Cyber Caf Management System

Case WM_DRAWITEM Dim DrawInfo As DRAWITEMSTRUCT Dim IsSideBar As Boolean Dim hBR As Long, hOldBr As Long, hChkBr As Long Dim hPen As Long, hOldPen As Long, lTextColor As Long Dim tRect As RECT Dim iRectOffset As Integer, iSBoffset As Integer Dim sAccelKey As String, sCaption As String Dim bMenuItemDisabled As Boolean, bMenuItemChecked As Boolean Dim bSelected As Boolean, bHasIcon As Boolean 'Get DRAWINFOSTRUCT which gives us sizes & indexes Call CopyMemory(DrawInfo, ByVal lParam, LenB(DrawInfo)) ' 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 lSubMenu = DrawInfo.hwndItem If MenuData(hWndRedirect).SetMenuID(DrawInfo.ItemId, DrawInfo.hwndItem, False, False) = False Then Exit Function If DrawInfo.CtlType <> ODT_MENU Then Exit Function CustomDrawMenu = True IsSideBar = CBool((MenuData(hWndRedirect).Status And 16) = 16) If (IsSideBar = True And bDrawPanel = False) Then Exit Function IsSep = (MenuData(hWndRedirect).Status And 2) = 2 And IsSideBar = False ' get the checked & enabled status 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))

Project Report :: Cyber Caf Management System

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 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))

Project Report :: Cyber Caf Management System

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 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)

Project Report :: Cyber Caf Management System

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 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

Project Report :: Cyber Caf Management System

' 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, _ 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)

Project Report :: Cyber Caf Management System

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 Public Function HiWord(LongIn As Long) As Integer Call CopyMemory(HiWord, ByVal VarPtr(LongIn) + 2, 2) End Function Public Function LoWord(LongIn As Long) As Integer Call CopyMemory(LoWord, LongIn, 2) End Function Private Function MakeLong(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long MakeLong = CLng(LoWord) Call CopyMemory(ByVal VarPtr(MakeLong) + 2, HiWord, 2) End Function Private Function DetermineOS(Optional SetGraphicsModeDC As Long = 0) As Integer ' The following are the platform, major version & minor version of OS to date (acquired from MSDN) Const os_Win95 = "1.4.0"

Project Report :: Cyber Caf Management System

Const os_Win98 = "1.4.10" Const os_WinNT4 = "2.4.0" Const os_WinNT351 = "2.3.51" Const os_Win2K = "2.5.0" Const os_WinME = "1.4.90" Const os_WinXP = "2.5.1" Dim verinfo As OSVERSIONINFO, sVersion As String verinfo.dwOSVersionInfoSize = Len(verinfo) If (GetVersionEx(verinfo)) = 0 Then Exit Function ' use default 0 With verinfo sVersion = .dwPlatformId & "." & .dwMajorVersion & "." & .dwMinorVersion End With ' those where the iTabOffset is set are systems that I have seen the ' results on; otherwise, assume no adjustment is necessary Select Case sVersion Case os_Win98: iTabOffset = 32 Case os_Win2K: iTabOffset = 0 Case os_WinNT4: iTabOffset = 0 Case os_WinNT351 ' Problems when printing rotated text 'According to MSDN, NT 3.51 only works on a setting of 2. Don't have the opportunity to test this. SetGraphicsMode SetGraphicsModeDC, 2 Case os_Win95 Case os_WinXP: iTabOffset = 0 Case os_WinME End Select End Function Public Function GetFormHandle(hwnd As Long, Optional bIsMDI As Boolean) As Long Dim i As Long For i = Forms.Count - 1 To 0 Step -1 If Forms(i).hwnd = hwnd Then Exit For Next If i > -1 Then If TypeOf Forms(i) Is MDIForm Then bIsMDI = True GetFormHandle = i End If End Function

Description of Class Modules (clsMyMenu) ::

Project Report :: Cyber Caf Management System

Private ImageLister As Control ' name of menus imagelist, can't use handle 'cause it can change per MSDN Public MainMenuID As Long ' handle to form's main menu Public OldWinProc As Long ' handle to form's window message processor Public ChildStatus As Byte ' 1 indicates a child Public ParentForm As Long ' for MDI children, this is the MDI parent -- for others it is it's own handle Private MyMI() As MenuDataInformation ' collection of menuitems Private menuIDs As Collection ' index to myMI array Private mIDcurrent As Long ' current menu item Private MyPanels() As PanelDataInformation Private PanelData As Collection Private pIDcurrent As Long Private MDIchildren As Collection Property Get TotalIcons() As Long On Error Resume Next TotalIcons = ImageLister.ListImages.Count End Property Property Let Icon(lValue As Long) MyMI(menuIDs(mIDcurrent)).Icon = lValue End Property Property Get Icon() As Long Icon = MyMI(menuIDs(mIDcurrent)).Icon End Property Property Let ItemHeight(lValue As Long) MyMI(menuIDs(mIDcurrent)).ItemHeight = lValue End Property Property Get ItemHeight() As Long ItemHeight = MyMI(menuIDs(mIDcurrent)).ItemHeight End Property Property Let ItemWidth(lValue As Long) MyMI(menuIDs(mIDcurrent)).ItemWidth = lValue End Property Property Get ItemWidth() As Long ItemWidth = MyMI(menuIDs(mIDcurrent)).ItemWidth End Property Property Let HotKeyPos(lValue As Long) MyMI(menuIDs(mIDcurrent)).HotKeyPos = lValue End Property Property Get HotKeyPos() As Long HotKeyPos = MyMI(menuIDs(mIDcurrent)).HotKeyPos End Property Property Let Status(lValue As Long)

Project Report :: Cyber Caf Management System

MyMI(menuIDs(mIDcurrent)).Status = lValue End Property Property Get Status() As Long Status = MyMI(menuIDs(mIDcurrent)).Status End Property Property Let Caption(sValue As String) MyMI(menuIDs(mIDcurrent)).Caption = sValue End Property Property Get Caption() As String Caption = MyMI(menuIDs(mIDcurrent)).Caption End Property Property Get ImageViewerObj() As Control On Error Resume Next Set ImageViewerObj = ImageLister End Property Property Get ImageViewer() As Long On Error Resume Next ImageViewer = ImageLister.hImageList End Property Public Sub SetImageViewer(vObject As Control) Set ImageLister = vObject End Sub Property Get OriginalCaption() As String OriginalCaption = MyMI(menuIDs(mIDcurrent)).OriginalCaption End Property Property Let OriginalCaption(sValue As String) MyMI(menuIDs(mIDcurrent)).OriginalCaption = sValue End Property Property Get SideBarIsText() As Boolean On Error Resume Next SideBarIsText = (MyPanels(CStr(pIDcurrent)).Status And 4) = 4 End Property Property Get SideBarItem() As Long SideBarItem = MyPanels(CStr(pIDcurrent)).SBarIcon End Property Property Get SideBarWidth() As Long SideBarWidth = MyPanels(CStr(pIDcurrent)).SideBar End Property Property Get PanelWidth() As Long PanelWidth = MyPanels(CStr(pIDcurrent)).Width End Property Property Get PanelIDcount() As Long

Project Report :: Cyber Caf Management System

On Error Resume Next PanelIDcount = PanelData.Count End Property Property Get PanelHeight() As Long On Error Resume Next PanelHeight = MyPanels(CStr(pIDcurrent)).Height End Property Property Get HotKeyEdge() As Integer HotKeyEdge = CInt(MyPanels(CStr(pIDcurrent)).HKeyPos) End Property Public Function GetSetMDIchildSysMenu(lValue As Long, bSet As Boolean) As Boolean On Error Resume Next Dim lHwnd As Long If bSet = True Then If MDIchildren Is Nothing Then Set MDIchildren = New Collection lHwnd = MDIchildren(CStr(lValue)) If lHwnd = 0 Then MDIchildren.Add MDIchildren.Count + 1, CStr(lValue) Else lHwnd = MDIchildren(CStr(lValue)) GetSetMDIchildSysMenu = (lHwnd <> 0) End If Err.Clear End Function Property Get MenuIDcount() As Integer On Error Resume Next MenuIDcount = menuIDs.Count End Property Public Sub UpdatePanelID(vData() As Long, sText As String, bPartial As Boolean) On Error Resume Next With MyPanels(CStr(pIDcurrent)) .Width = vData(0) .Height = vData(1) .HKeyPos = vData(2) .PanelIcon = vData(3) If bPartial = False Then 'Debug.Print "full update on paneldata" .SideBar = vData(4) .SideBarXY = vData(5) .BColor = vData(6) .FColor = vData(7) .Caption = sText .Status = vData(9) .SBarIcon = vData(10)

Project Report :: Cyber Caf Management System

End If End With End Sub Public Sub GetPanelInformation(vData() As Long, sText As String) On Error Resume Next ReDim vData(0 To 10) With MyPanels(PanelData(CStr(MyMI(menuIDs(mIDcurrent)).Parent))) vData(0) = .Width + 16 vData(1) = .Height vData(2) = .HKeyPos vData(3) = .PanelIcon vData(4) = .SideBar vData(5) = .SideBarXY vData(6) = .BColor vData(7) = .FColor sText = .Caption vData(9) = .Status vData(10) = .SBarIcon End With End Sub Public Function SetMenuID(iID As Long, hSubMenu As Long, byPosition As Boolean, Optional bAlwaysCreate As Boolean = True) As Boolean On Error Resume Next ' we reference passed menu item, if we don't have a reference ' an error occurs which triggers a new reference if the ' bAlwaysCreate boolean is set to true If byPosition Then ' menu item is positional (i.e., 1,2,3) mIDcurrent = iID Else ' menu item is by ID vs position mIDcurrent = menuIDs(CStr(iID) & "." & CStr(hSubMenu)) End If If Err Then ' new reference If bAlwaysCreate = True Then ' let's add a new reference & use the menu ID as a key menuIDs.Add menuIDs.Count + 1, CStr(iID) & "." & CStr(hSubMenu) mIDcurrent = menuIDs.Count ' now we will add an MyMI array ReDim Preserve MyMI(1 To menuIDs.Count) MyMI(menuIDs(mIDcurrent)).ID = iID MyMI(menuIDs(mIDcurrent)).Parent = hSubMenu ' return a value indicating this is a new add SetMenuID = True

Project Report :: Cyber Caf Management System

Err.Clear pIDcurrent = PanelData(CStr(hSubMenu)) If Err Then Err.Clear PanelData.Add PanelData.Count + 1, CStr(hSubMenu) ReDim Preserve MyPanels(1 To PanelData.Count) MyPanels(PanelData.Count).ID = hSubMenu 'Debug.Print "new panel created-count="; hSubMenu; PanelData.Count End If End If Else ' reference already exists ' if the following flag wasn't set, then the drawing/measuring ' routine wants to know if we have a reference ' so we set return to true if so ' otherwise, the menu metrics is calling this and we ' need to return false indicating this is not a new add If bAlwaysCreate = False Then SetMenuID = True End If pIDcurrent = PanelData(CStr(hSubMenu)) End Function Public Sub GetIconData(vData() As Long, IconIndex As Long) On Error Resume Next ReDim vData(0 To 2) If Not ImageLister Is Nothing Then vData(0) = ImageLister.ListImages(IconIndex).Picture.Handle vData(1) = ImageLister.ListImages(IconIndex).Picture.Type If (MyMI(menuIDs(mIDcurrent)).Status And 4) = 4 Then vData(2) = 1 Else If (MyMI(menuIDs(mIDcurrent)).Status And 8) = 8 Then vData(2) = 2 End If End If End Sub Public Function GetPanelID(iID As Long) As Long On Error Resume Next GetPanelID = MyPanels(PanelData.Item(iID)).ID End Function Public Sub PurgeObsoleteMenus(hSubMenu As Long) Dim newMyMI() As MenuDataInformation, newMyPanels() As PanelDataInformation Dim Looper As Long, lCounter As Long On Error GoTo ExitSub If menuIDs.Count Then ReDim newMyMI(1 To menuIDs.Count)

Project Report :: Cyber Caf Management System

lCounter = 1 For Looper = menuIDs.Count To 1 Step -1 If MyMI(menuIDs.Item(Looper)).Parent <> hSubMenu Then newMyMI(lCounter) = MyMI(menuIDs.Item(Looper)) lCounter = lCounter + 1 End If Next If lCounter - 1 Then Erase MyMI ReDim MyMI(1 To lCounter - 1) Set menuIDs = Nothing Set menuIDs = New Collection For Looper = 1 To lCounter - 1 MyMI(Looper) = newMyMI(Looper) menuIDs.Add Looper, CStr(newMyMI(Looper).ID) & "." & CStr(newMyMI(Looper).Parent) Next 'Debug.Print "Finished indexing menuitems" End If Erase newMyMI End If If PanelData.Count Then ReDim newMyPanels(1 To PanelData.Count) lCounter = 1 For Looper = PanelData.Count To 1 Step -1 pIDcurrent = Looper If MyPanels(PanelData.Item(Looper)).ID <> hSubMenu Then newMyPanels(lCounter) = MyPanels(PanelData.Item(Looper)) If SideBarIsText = True Then DeleteObject MyPanels(PanelData.Item(Looper)).SBarIcon lCounter = lCounter + 1 End If Next If lCounter - 1 Then Erase MyPanels ReDim MyPanels(1 To lCounter - 1) Set PanelData = Nothing Set PanelData = New Collection For Looper = 1 To lCounter - 1 MyPanels(Looper) = newMyPanels(Looper) PanelData.Add Looper, CStr(newMyPanels(Looper).ID) Next 'Debug.Print "Finished Indexing panels" End If Erase newMyPanels End If Looper = 0 Looper = MDIchildren(CStr(hSubMenu))

Project Report :: Cyber Caf Management System

If Looper Then MDIchildren.Remove Looper ExitSub: End Sub Private Sub Class_Terminate() On Error Resume Next Dim Looper As Long For Looper = 1 To PanelData.Count pIDcurrent = Looper If SideBarIsText = True Then DeleteObject MyPanels(PanelData.Item(Looper)).SBarIcon Next Set PanelData = Nothing Set MDIchildren = Nothing Set ImageLister = Nothing MainMenuID = 0 OldWinProc = 0 Set menuIDs = Nothing Erase MyMI End Sub Private Sub Class_Initialize() Set menuIDs = New Collection Set PanelData = New Collection End Sub

Project Report :: Cyber Caf Management System

Anda mungkin juga menyukai