Subscribe For Free Updates!

We'll not spam mate! We promise.

‏إظهار الرسائل ذات التسميات visual basic. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات visual basic. إظهار كافة الرسائل

الاثنين، 7 يوليو 2014

function disable the Close button to close that exists in each window visual basic codes

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
Dim a As Long, b As Long
a = GetSystemMenu(Me.hwnd, False)
b = GetMenuItemCount(a)
RemoveMenu a, b - 1, MF_BYPOSITION
DrawMenuBar Me.hwnd
End Sub 

from ----

function transfer file from the path to another path visual basic codes

Private Declare Function MoveFile Lib "kernel32" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
Private Sub Command1_Click()
MoveFile "c:WindowsDesktopa.txt", "c:a.txt"
End Sub 


from ---

download a page from the Internet -make marble form -download all computer lines in Combo Box visual basic code

To download all computer lines in Combo Box

Private Sub Form_Load() 
Dim i As Integer 
For i = 0 To Screen.FontCount - 1 
Combo1.AddItem Screen.Fonts(i) 
Next i 
Combo1.Text = Combo1.List(0) 
End Sub 

to make marble form


in General

Private Sub GradientFill()
Dim i As Long
Dim c As Integer
Dim r As Double
r = ScaleHeight / 3.142
For i = 0 To ScaleHeight
c = Abs(220 * Sin(i / r))
Me.Line (0, i)-(ScaleWidth, i), RGB(c, c, c + 30) 'Notice the bias To blue. You can be more subtle by reducing this number (try 10). Try other colours too.
Next
End Sub

in form Resize 
GradientFill


To download a page from the Internet

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
lngRetVal = URLDownloadToFile(0, "http://www.the site.com", "c:the site.htm", 0, 0)
End Sub 

from ---



Cancel button closure - to hide the program from the administration to task - Tkarchgal cancel your program at the same time visual basic codes

Cancel button closure - to hide the program from the administration to task - Tkarchgal cancel your program at the same time  visual basic codes


Cancel button closure

Private Sub Form_Unload(Cancel As Integer) 
Cancel = 1 
End Sub


hide the program from the administration to task 

Private Sub Form_Load() 
App.TaskVisible = False 
End Sub

Tkarchgal cancel your program at the same time

Private Sub Form_Load() 
If App.PrevInstance Then Unload Me 
End Sub

Interpreter and redeployed from vb4arb

Copy and transport functions through visual basic codes

Examples and codes to deal with Api functions


Copy and transport functions through visual basic codes

Private Declare Function CopyFile Lib "kernel32" Alias _
"CopyFileA" (ByVal lpExistingFileName As String, ByVal _
lpNewFileName As String, ByVal bFailIfExists As Long) As Long 

Private Declare Function MoveFile Lib "kernel32" Alias _
"MoveFileA" (ByVal lpExistingFileName As String, ByVal _
lpNewFileName As String) As Long 


Sub CopyMove() 
Dim strSource As String 
Dim strTarget As String 
Dim lngRetVal As Long 
strSource = "C:\yfile.txt" 
strTarget = "C:\indows\yfile.txt" 


'// Copy File 
lngRetVal = CopyFile(Trim$(strSource), Trim(strTarget), False) 
If lngRetVal Then 
MsgBox "File copied!" 
Else 
MsgBox "Error. File not moved!" 
End If 

'// Move File 
lngRetVal = MoveFile(Trim$(strSource), Trim(strTarget)) 
If lngRetVal Then 
MsgBox "File moved!" 
Else 
MsgBox "Error. File not moved!" 
End If 
End Sub

Interpreter and redeployed from vb4arb

visual basic code for Delay your program for a certain period Sleep

Examples and codes to deal with Api functions

visual basic code for Delay your program for a certain period Sleep

'in model
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'in form
Private Sub Form_Load()
Call Sleep(1000)
End Sub


Interpreter and redeployed from vb4arb

visual basic code to View desktop background on the form

Examples and codes to deal with Api functions

visual basic code to View desktop background on the form 

Private Declare Function PaintDesktop Lib "user32" _
(ByVal hdc As Long) As Long

Private Sub Command1_Click()
PaintDesktop Form1.hdc
End Sub

Interpreter and redeployed from vb4arb

visual basic code for Put your program in addition to time

Examples and codes to deal with Api functions

visual basic code for Put your program in addition to time

Option Explicit
Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type

Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

Private Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid _
As NOTIFYICONDATA) As Boolean

Dim t As NOTIFYICONDATA

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

Timer1.Enabled = False

t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&

Shell_NotifyIcon NIM_DELETE, t

End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Hex(X) = "1E3C" Then
Me.PopupMenu menu1
End If

End Sub

Private Sub Timer1_Timer()
Static i As Long, img As Long
t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&
t.uFlags = NIF_ICON
t.hIcon = Picture1.Picture
Shell_NotifyIcon NIM_MODIFY, t
Timer1.Enabled = True
i = i + 1
If i = 2 Then i = 0
End Sub

Private Sub Form_Load()

t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&
t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
t.ucallbackMessage = WM_MOUSEMOVE
t.hIcon = Picture1.Picture
t.szTip = "System Tray" & Chr$(0)

Shell_NotifyIcon NIM_ADD, t

Timer1.Enabled = True

Me.Hide

App.TaskVisible = False

End Sub

Interpreter and redeployed from vb4arb

visual basic code for Zoom in and out all the windows

Examples and codes to deal with Api functions

visual basic code for Zoom in and out all the windows

Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName _
As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Const WM_COMMAND As Long = &H111
Private Const MIN_ALL As Long = 419
Private Const MIN_ALL_UNDO As Long = 416

Public Sub MinimizeAll()

Dim lngHwnd As Long

lngHwnd = FindWindow("Shell_TrayWnd", vbNullString)
Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL, 0&)

End Sub

Public Sub RestoreAll()

Dim lngHwnd As Long

lngHwnd = FindWindow("Shell_TrayWnd", vbNullString)
Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL_UNDO, 0&)

End Sub
Interpreter and redeployed from vb4arb



visual basic code for Open Control Panel

Examples and codes to deal with Api functions

Open Control Panel

Private Sub Command1_Click()
Shell ("rundll32.exe shell32.dll,Control_RunDLL")
End Sub

Interpreter and redeployed from vb4arb

visual basic code Know the user name


Examples and codes to deal with Api functions

Know the user name

Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long

Private Sub Form_Load()
Dim s As String
Dim cnt As Long
Dim dl As Long
Dim CurUser As String
cnt = 199
s = String$(200, 0)
dl = GetUserName(s, cnt)
If dl <> 0 Then CurUser = Left$(s, cnt) Else CurUser = ""
Label1.Caption = CurUser
End Sub

Interpreter and redeployed from vb4arb


visual basic code Know the coordinates of the mouse inside and outside the form

Examples and codes to deal with Api functions


Know the coordinates of the mouse inside and outside the formic

Private Declare Function GetCursorPos Lib "user32" (lpPoint As _
POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type
Dim a As POINTAPI
Dim b As Long
Dim c As Long
' add labels and timer control in the form
Private Sub Form_Load()
Timer1.Interval = 1
End Sub

Private Sub Timer1_Timer()
mousepos
End Sub

Private Sub mousepos()
ret = GetCursorPos(a)
b = a.x
c = a.y
Label1.Caption = b
Label2.Caption = c
End Sub
Interpreter and redeployed from vb4arb

visual basic code Know the time that has passed on its Windows operating

Examples and codes to deal with Api functions

Know the time that has passed on its Windows operating


Declare Function GetTickCount& Lib "kernel32" ()

Private Sub cmdWinRun_Click()
MsgBox GetTickCount
End Sub

Interpreter and redeployed from vb4arb

visual basic code Close specific application know his name

Examples and codes to deal with Api  functions 

Close specific application know his name

Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long 

Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long

Public Const WM_CLOSE = &H10

Private Sub cmdClose_Click()

Dim winHwnd As Long
Dim RetVal As Long

winHwnd = FindWindow(vbNullString, Text1.Text)

Debug.Print winHwnd

If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
MsgBox "Error posting message."
End If
Else 
MsgBox Text1.Text + " is not open."
End If

End Sub

Interpreter and redeployed from vb4arb

visual basic code Checking whether your program is running


Examples and codes to deal with Api  functions 

Checking whether your program is running

Private Sub Form_Load()

'// Not the best way to check
'// Better to use the FindWindow API

If App.PrevInstance = True Then
MsgBox ("This program is already running.")
End
End If

End Sub

Interpreter and redeployed from vb4arb

visual basic Code to disable and activate the task manager

put two command putton on form 

Private Sub Command1_Click()
Dim WSH As Object
Set WSH = CreateObject("Wscript.Shell")
WSH.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr", 0, "REG_DWORD"
Me.Caption = "! Task Manager is: Enabled !"
End Sub

Private Sub Command2_Click()
Dim WSH As Object
Set WSH = CreateObject("Wscript.Shell")
WSH.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr", 1, "REG_DWORD"
Me.Caption = "! Task Manager is: Disabled !"
End Sub

Interpreter and redeployed from vb4arb

visual basic Code to limit the mouse inside the form

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, _
lpRect As RECT) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, _
lpPoint As Any) As Long
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long

Sub RestrictMouseRegion(Optional ByVal hWnd As Long = 0)
Dim recTargetWindow As RECT
If hWnd Then
GetClientRect hWnd, recTargetWindow
ClientToScreen hWnd, recTargetWindow
ClientToScreen hWnd, recTargetWindow.Right
ClipCursor recTargetWindow
Else
ClipCursor ByVal 0&
End If
End Sub

Private Sub Form_Load()
RestrictMouseRegion (Me.hWnd)
End Sub

Private Sub Form_Unload(Cancel As Integer)
RestrictMouseRegion
End Sub
Interpreter and redeployed from vb4arb

Codes visual basic run and restart the computer

Call Shell("cmd.exe /c shutdown -l", vbNormalFocus)
' restart computer under xp system
Call Shell("cmd.exe /c shutdown -r", vbNormalFocus)
' turn of computer under xp system 
Call Shell("cmd.exe /c shutdown -s", vbNormalFocus)
' close the above operation
Call Shell("cmd.exe /c shutdown -a", vbNormalFocus)
' close all open widows and prorgams
Call Shell("cmd.exe /c shutdown -f", vbNormalFocus)


   for restart and turn of codes  windows will open and you cannot close it 
and will waitting 60 seconds 

for delay this time use this code 


(Call Shell("cmd.exe /c shutdown -s -t 10", vbNormalFocus

if you want write small message use this code

(Call Shell("cmd.exe /c shutdown -s -t 10 -c By Hani", vbNormalFocus




for more information go to dos windoe and write shutdown  

Interpreter and redeployed from vb4arb

visual basic Way to make forms or program at the forefront of programs

in general put this code

Private Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)  

In Form load put 

Private Sub Form_Load()

SetWindowPos Form1.hwnd, -1, 0, 0, 0, 0, 3

End Sub


Interpreter and redeployed from vb4arb





الأحد، 6 يوليو 2014

Open the form in a very beautiful way

put timer in form and put this code in general 

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function SetLayeredWindowAttributes _
Lib "user32.dll" (ByVal hwnd As Long, ByValcrKey As _
Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Boolean
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Const LWA_ALPHA = 2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Dim i As Integer
Private Sub Form_Load()
i = 0
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()


i = i + 1
SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong _
(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes hwnd, 0, i, LWA_ALPHA
If i = 255 Then
Timer1.Enabled = False
End If

End Sub
Interpreter and redeployed from vb4arb