Writing Shells - pt1
Posted: 2002-06-01
By: ArchiveBot
Viewed: 63
Filed Under:
Title | Uploaded | Size |
---|---|---|
Writting_S3629811202001.zip | 9/3/2020 3:45:00 PM | 5,110 |
The first of my tutorials on writting Shells (like explorer) in VB
Original Author: Nick Ridley
Code
(Part1) By Nick Ridley Date: 20/11/2001 Contents: 1- Introduction I have stated to write these tutorials to try and get some more people into writing Nick Ridley Before you even start to make your shell decide on some things first: 1- Will it be free or commercial? Decide on all of these things and then write them down on a bit of paper. Below start a Now you have most the info you will need, now we can start. You must now: Create your project Now we will move on to task listing: I have re written some parts of a .bas file I got of PSC (I think this is made up of NOTE: I did not fully write this, this is a rewritten version of what was in softshell [BEGIN TaskListing.bas] 'I hope this bit encourages you newbies to [END TaskListing.bas] If you are not going to download the sample project you will need to write your own Basically the functions do this: fEnumWindows lst = the list box were the window hWnd's will be held You will also need to change a few lines (these are marked) to suit your project, You You may also find this useful to set FG windows and make your taskbar stay on top: [BEGIN modWindows.bas] Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, [END modWindows.bas] Now you can either use this info to build your own project or use mine. In the next issue I plan to describe how to make a start menu (hopefully in more detail I hope you find this useful and PLEASE VOTE and LEAVE COMMENTS. http://www.spyderhackers.co.ukWriting A Shell
2- Getting started
3- Taskbar buttons
4- Next Issue1 - Introduction
shells in VB. I know that I am not the best shell writer but I do know how to get
started in making one and these tutorials are meant to give newbies that boost of info
they need so they will start.2- Getting started
2- Will it be open source?
3- What colour scheme will you use?
4- What versions of window will it be compatible with
brainstorm of the word SHELL and come up with as much info. Now finalise what you want in
light of this info and decide on a name. Write down all this on a bit of paper and stick
it to your monitor or something. Get some paper and a pen and keep this handy at all times
to write down ideas. You may also need a calculator to do any sums and stuff.
Do your splash screen
Design the place were the task buttons will be3- The task buttons
Softshell and RepShell) and you must now add this to your project:
and repshell, although I have re-written some of it
'start new shells (use this to make a taskbar)
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long,
ByVal lParam As Long) As Long
Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd
As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As
Long) As Long
Public 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 Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const LB_ADDSTRING = &H180
Public Const LB_FINDSTRINGEXACT = &H1A2
Public Const LB_ERR = (-1)
Public Const GW_OWNER = 4
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_APPWINDOW = &H40000
Public Const WS_EX_TOOLWINDOW = &H80
Public Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Boolean
Public Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As
Long
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 Const DI_NORMAL = &H3
Public Declare Function GetClassLong Lib "user32" Alias
"GetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Integer) As Long
Public Const WM_GETICON = &H7F
Public Const GCL_HICON = (-14)
Public Const GCL_HICONSM = (-34)
Public Const WM_QUERYDRAGICON = &H37
Public Declare Function SendMessageTimeout Lib "user32" Alias
"SendMessageTimeoutA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As
Long, ByVal lParam As Long, ByVal fuFlags As Long, ByVal uTimeout As Long, lpdwResult As
Long) As Long
'This is used to get icons from windows >>>>
Public Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As
Long, ByVal y As Long, ByVal hIcon As Long) As Long
Public Function fEnumWindows(lst As ListBox) As Long
With lst
.Clear
frmTasks.lstNames.Clear ' replace this as neccessary
Call EnumWindows(AddressOf fEnumWindowsCallBack, .hwnd)
fEnumWindows = .ListCount
End With
End Function
Private Function fEnumWindowsCallBack(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim lExStyle As Long, bHasNoOwner As Boolean, sAdd As String, sCaption As String
If IsWindowVisible(hwnd) Then
bHasNoOwner = (GetWindow(hwnd, GW_OWNER) = 0)
lExStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
If (((lExStyle And WS_EX_TOOLWINDOW) = 0) And bHasNoOwner) Or _
((lExStyle And WS_EX_APPWINDOW) And Not bHasNoOwner) Then
sAdd = hwnd: sCaption = GetCaption(hwnd)
Call SendMessage(lParam, LB_ADDSTRING, 0, ByVal sAdd)
Call SendMessage(frmTasks.lstNames.hwnd, LB_ADDSTRING, 0, ByVal sCaption)color="#008040"> ' replace this as neccessary
End If
End If
fEnumWindowsCallBack = True
End Function
Public Function GetCaption(hwnd As Long) As String
Dim mCaption As String, lReturn As Long
mCaption = Space(255)
lReturn = GetWindowText(hwnd, mCaption, 255)
GetCaption = Left(mCaption, lReturn)
End Function
function to use this. In my project i have included a function to do this.
do not need to directly call the rest of the functions.
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal
cy As Long, ByVal wFlags As Long) As Long
Public Const HWND_BOTTOM = 1
Public Const HWND_NOTOPMOST = -2
Public Const HWND_TOP = 0
Public Const HWND_TOPMOST = -1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As
Long) As Long
Public Const SW_HIDE = 0
Public Const SW_NORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_SHOWDEFAULT = 10
Public Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As
Boolean
Public Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Public Function WindowPos(frm As Object, setting As Integer)
'Change positions of windows, make top most etc...
Dim i As Integer
Select Case setting
Case 1
i = HWND_TOPMOST
Case 2
i = HWND_TOP
Case 3
i = HWND_NOTOPMOST
Case 4
i = HWND_BOTTOM
End Select
SetWindowPos frm.hwnd, i, frm.Left / 15, _
frm.Top / 15, frm.Width / 15, _
frm.Height / 15, SWP_SHOWWINDOW Or SWP_NOACTIVATE
End Function
Public Sub SetFGWindow(ByVal hwnd As Long, Show As Boolean)
If Show Then
If IsIconic(hwnd) Then
ShowWindow hwnd, SW_RESTORE
Else
BringWindowToTop hwnd
End If
Else
ShowWindow hwnd, SW_MINIMIZE
End If
End SubI HIGHLY RECOMEND YOU DOWNLOAD MY SAMPLE
This DOES NOT cover everything
4- Next Issue:
than this) describing how to get icons from files and how to make menus appear and
disappear. And in further issues i will describe how to make a system tray for example.
What annoys me is when people read your code and use it but dont vote so please show your
appreciation and even if you vote poor every vote counts.Thanx for reading
Nick Ridley
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.