Microsoft Office Excel ® Kod Kılavuzu

Microsoft Office Excel® Code Guide

23 Mart 2011 Çarşamba

SetWindowPos Function



'UserForm1
Option Explicit
'A. Refences List (MS Office 2010)

'A1. Name: VBA, Description: Visual Basic For Applications, FullPath: C:\PROGRA~2\COMMON~1\MICROS~1\VBA\VBA7\VBE7.DLL
'A2. Name: Excel, Description : Microsoft Excel 14.0 Object Library, FullPath: C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE
'A3. Name: stdole, Description: OLE Automation, FullPath: C:\Windows\SysWOW64\stdole2.tlb
'A4. Name: Office, Description: Microsoft Office 14.0 Object Library, FullPath: C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\MSO.DLL
'A5. Name: MSForms, Description: Microsoft Forms 2.0 Object Library, FullPath: C:\Windows\SysWOW64\FM20.DLL

'B. Additional Controls

'B1. Image1, Label1, Label2
'B2. ToggleButton

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function 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) As Long
Private hWnd As Long
Private Sub UserForm_Initialize()

On Error Resume Next
Me.Caption = "[PBİD®] SetWindowPos Function"
hWnd = FindWindow(vbNullString, Me.Caption)
Do While hWnd = 0

hWnd = FindWindow(vbNullString, Me.Caption)
DoEvents

Loop
Call Ekran_Düzenle

End Sub
Private Sub ToggleButton1_Click()

On Error Resume Next
If ToggleButton1.Caption = "UserForm in front of the TaskBar" Then

SetWindowPos hWnd, -2, 0, 0, 0, 0, &H2 Or &H1
ToggleButton1.Caption = "UserForm behind the TaskBar"

Else

SetWindowPos hWnd, -1, 0, 0, 0, 0, &H2 Or &H1
ToggleButton1.Caption = "UserForm in front of the TaskBar"

End If

End Sub
Private Sub Ekran_Düzenle()

On Error Resume Next
With Me

.Height = 174
.Width = 240
.Picture = LoadPicture("D:\MU\Back_Color\21.bmp")
With Image1

.Left = 6
.Top = 6
.Height = 24
.Width = 24
.Picture = LoadPicture("D:\MU\MU.ico")
.PictureAlignment = fmPictureAlignmentCenter
.PictureSizeMode = fmPictureSizeModeClip
.BorderColor = vbWhite
.BorderStyle = fmBorderStyleSingle
.BackStyle = fmBackStyleTransparent

End With
With Label1

.Left = 36
.Top = 6
.Height = 12
.Width = 192
.Caption = "Mustafa ULUSARAÇ"
.ForeColor = vbBlue
.Font.Bold = True
.BorderStyle = fmBorderStyleNone
.SpecialEffect = fmSpecialEffectFlat
.TextAlign = fmTextAlignLeft
.BackStyle = fmBackStyleTransparent

End With
With Label2

.Left = 36
.Top = 18
.Height = 12
.Width = 192
.Caption = "01ulusarac@superonline.com"
.ForeColor = vbBlue
.Font.Bold = True
.BorderStyle = fmBorderStyleNone
.SpecialEffect = fmSpecialEffectFlat
.TextAlign = fmTextAlignLeft
.BackStyle = fmBackStyleTransparent

End With
With ToggleButton1

.Left = 42
.Top = 72
.Height = 25.5
.Width = 156
.Font.Bold = True
.ForeColor = vbRed
.Caption = "UserForm in front of the TaskBar"
.Value = True

End With

End With

End Sub

Hiç yorum yok:

Blog Arşivi

Bu gadget'ta bir hata oluştu

Bu Blogda Ara

Contributor

Contributor
Mustafa ULUSARAÇ İstanbul, TÜRKİYE
free counters
T. C. Central Bank Indicative Exchange Rates
Currency Exchange Rate Widget,Currency Converter Widget
Borsa İstanbul