Başlangıç > Kodlar > Visual Basic 6 ile Statusbar’a progressbar ve toolbar eklemek

Visual Basic 6 ile Statusbar’a progressbar ve toolbar eklemek


Status bar nesnesi uzerine progressbar ve toolbar nesnelerini nasil ekleyebiliriz?

Asagidaki kodu bir modul dosyasina kopyalayiniz ;

Option Explicit

‘Constants
‘Used to change progressbar colour
Private Const WM_USER = &H400
Private Const CCM_FIRST       As Long = &H2000&
Private Const PBM_SETBARCOLOR As Long = (WM_USER + 9)

Public Enum ScrollingType
Standart = 0
Smooth = 1
End Enum

‘API Functions
Private Declare Function SetParent Lib “user32” _
(ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Declare Function GetParent Lib “user32” (ByVal hwnd As Long) As Long

Private 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 defToolbarHwnd As Long

Public Function AddProgressbarToStatusBar(objProgressbar As ProgressBar, _
objStatusbar As StatusBar, _
lngStatusbarPanel As Long, _
Optional stProgressbarScroolingType As ScrollingType, _
Optional lngProgressbarColour As Long) As Boolean
‘******************************************************************************************
‘Purpose : Add progress bar to status bar
‘Input   : Progressbar object, Statusbar object, Statusbar panel,
‘          Progressbar scrooling type(Optional), Progressbar bar colour (Optional)
‘          objProgressbar             : Progress bar object
‘          objStatusbar               : Statusbar object
‘          lngStatusbarPanel          : Statusbar panel number
‘          stProgressbarScroolingType : Progressbar scrooling type
‘          lngProgressbarColour       : Progressbar bar colour
‘Outout  : –
‘Date    : 13.05.2003
‘Author  : Murat Aras (Algorithm : Randy Birch)
‘******************************************************************************************

‘Error handler
On Error GoTo ErrFunction

‘Control panel exists or not
If lngStatusbarPanel > objStatusbar.Panels.Count Then AddProgressbarToStatusBar = False: Exit Function
‘Control scrooling type to defuse scrooling typr and bar colour
If stProgressbarScroolingType > 1 Then AddProgressbarToStatusBar = False: Exit Function

‘Control progressbar was set
If GetParent(objProgressbar.hwnd) <> objStatusbar.hwnd Then

‘Set progress bar properties
objProgressbar.Scrolling = stProgressbarScroolingType

‘Change the parent
SetParent objProgressbar.hwnd, objStatusbar.hwnd

With objStatusbar
‘Doing it this way relieves the necessity of calculating
‘the statusbar position relative to the top of the form. It happens so fast the change is not seen.
.Align = vbAlignTop
.Visible = False

‘Change, move, set size and re-show the progress bar in the new parent
With objProgressbar
.Visible = False
.Align = vbAlignNone
.Appearance = ccFlat
.BorderStyle = ccNone
.Width = objStatusbar.Panels(lngStatusbarPanel).Width
.Move objStatusbar.Panels(lngStatusbarPanel).Left + Screen.TwipsPerPixelX * 2, _
objStatusbar.Top + Screen.TwipsPerPixelY * 3, _
objStatusbar.Panels(lngStatusbarPanel).Width – (Screen.TwipsPerPixelX * 3), _
objStatusbar.Height – (Screen.TwipsPerPixelY * 4)
.Visible = True<B


TD Software


Reklamlar
  1. Henüz yorum yapılmamış.
  1. No trackbacks yet.

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Connecting to %s

%d blogcu bunu beğendi: