位置没办法!
初始Color:
dlg.Color = RGB(255, 0, 0)
dlg.Flags = cdlCCRGBInit + cdlCCFullOpen
dlg.ShowColor
初始Color:
dlg.Color = RGB(255, 0, 0)
dlg.Flags = cdlCCRGBInit + cdlCCFullOpen
dlg.ShowColor
解决方案 »
- 查询语句!
- 紧急求助:vb做视频播放器
- Dictionary的一个问题!Set DicX=DicY 后,删除Dicx一个元素,为什么DicY也要跟着少一个元素?
- 请问VBA如何调用WORD
- 如何用VBA在当前光标位置插入无边框无填充的文本框
- 安装什么就在VB工程菜单中的引用菜单中会出现Microsoft Transaction server Type Library
- RICHTEXTBOX在98下为什么会中文乱码??怎么解决?急急急!
- 问题,如图所示
- 我是要和所有的文件建立关联,不管什么文件的扩展名,双击自动打开我的程序。
- 谁给我解释一下这个API!
- 狗日的len()&lenb()in VB!(NiceFeather的textout函数的回答)
- 如何实现数据库操作共享
1、这个例子是让CommonDialog居中:
'm_ofn是你的CommonDialog控件,属性名你可能要改一改!
Private Sub Command1_Click()
On Error GoTo ErrorHandle
With m_ofn
.lStructSize = Len(m_ofn)
.hInstance = App.hInstance
.hwndOwner = Me.hwnd
.lpstrFilter = "Bitmaps (*.BMP)" + Chr$(0) + "*.BMP" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
.lpstrFileTitle = Space(249) + "*.BMP"
.lpstrFile = .lpstrFileTitle
.lpstrTitle = "请选择Bmp图片..."
'.lpstrInitialDir = "C:\Windows"
.nMaxFile = 255
.nMaxFileTitle = 255
'&H51 + &H80000
.flags = OFN_EXPLORER Or OFN_READONLY Or OFN_SHOWHELP Or OFN_ENABLETEMPLATE _
Or OFN_CREATEPROMPT Or OFN_NODEREFERENCELINKS Or OFN_ENABLEHOOK .lpTemplateName = "tt"
.lpfnHook = GetProcAddress(AddressOf OpenSaveHookProc)
End With
If GetOpenFileName(m_ofn) Then
MsgBox TrimNull(m_ofn.lpstrFile), vbInformation, "你打开的文件是:"
End If
Exit Sub
ErrorHandle:
MsgBox Err.Description, vbCritical
End Sub在moudle中:Public Function GetProcAddress(ByVal Addr As Long) As Long
GetProcAddress = Addr
End FunctionPublic Function OpenSaveHookProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
Select Case uMsg
Case WM_INITDIALOG
'temporary vars for demo
Dim rc As RECT
Dim hwndParent As Long, newLeft As Long, newTop As Long, dlgWidth As Long, dlgHeight As Long, scrWidth As Long, scrHeight As Long 'obtain the handle to the parent dialog
hwndParent = GetParent(hwnd)
If hwndParent <> 0 Then
'Just to prove the handle was obtained,
'change the dialog's caption.
'Call SetWindowText(hwndParent, "I'm Hooked on Hooked Dialogs!")
'Position the dialog in the centre of
'the screen. First get the current dialog size.
Call GetWindowRect(hwndParent, rc)
'(To show the calculations involved, I've
'used variables instead of creating a
'one-line MoveWindow call.)
dlgWidth = rc.Right - rc.Left
dlgHeight = rc.Bottom - rc.Top
scrWidth = Screen.Width \ Screen.TwipsPerPixelX
scrHeight = Screen.Height \ Screen.TwipsPerPixelY
newLeft = (scrWidth - dlgWidth) \ 2
newTop = (scrHeight - dlgHeight) \ 2
'..and set the new dialog position to centre.
Call MoveWindow(hwndParent, newLeft, newTop, dlgWidth, dlgHeight, True)
End If
OpenSaveHookProc = 1
Case WM_COMMAND
……
Case WM_NOTIFY
……
End Select
End Function2、初始化color:
'm_ofn是你的CommonDialog控件
m_ofn.Flags = cdlCCRGBInit + cdlCCFullOpen
m_ofn.Color = RGB(255, 123, 213)
m_ofn.ShowColor
.lStructSize = Len(m_ofn)
.hInstance = App.hInstance
.hwndOwner = Me.hwnd
.lpstrFilter = "Bitmaps (*.BMP)" + Chr$(0) + "*.BMP" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
.lpstrFileTitle = Space(249) + "*.BMP"
.lpstrFile = .lpstrFileTitle
.lpstrTitle = "请选择Bmp图片..."
'.lpstrInitialDir = "C:\Windows"
.nMaxFile = 255
.nMaxFileTitle = 255
'&H51 + &H80000
...
总是出错,请多指教!