ش | ی | د | س | چ | پ | ج |
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Customizing MessageBox
Owner draw control types' Const ODT_MENU = 1 Const ODT_LISTBOX = 2 Const ODT_COMBOBOX = 3 Const ODT_BUTTON = 4 ' Owner draw actions' Const ODA_DRAWENTIRE = &H1 Const ODA_SELECT = &H2 Const ODA_FOCUS = &H4 ' Owner draw state' Const ODS_SELECTED = &H1 Const ODS_GRAYED = &H2 Const ODS_DISABLED = &H4 Const ODS_CHECKED = &H8 Const ODS_FOCUS = &H10
MEASUREITEMSTRUCT for ownerdraw' Type MEASUREITEMSTRUCT CtlType As Long CtlID As Long itemID As Long itemWidth As Long itemHeight As Long itemData As LongPtr End Type DRAWITEMSTRUCT for ownerdraw' Type DRAWITEMSTRUCT CtlType As Long CtlID As Long itemID As Long itemAction As Long itemState As Long hwndItem As LongPtr hdc As LongPtr rcItem As RECT itemData As LongPtr End Type
System Classes
DrawCaption hwnd,hdc,rc,uflag
http:// uflag : DC_ACTIVE DC_ICON DC_TEXT
Public Const DC_ACTIVE = &H1
Public Const DC_NOTACTIVE = &H2
Public Const DC_ICON = &H4
Public Const DC_TEXT = &H8
Public Function HookProc(ByVal nCode As Long,ByVal wParam As LongPtr,ByVal lParam As LongPtr) As Longptrif nCode>=0 ThenDim tCWP As CWPSTRUCT(CopyMemory tCWP,ByVal lParam,Len(tCWPif tCWP.message=WM_CREATE ThenIf tCWP.hwnd==#32770 Thenlprewnd=SetWindowLongPtrA(tCWP.hwnd,GWL_CALL(WNDPROC,AddressOf SubDlgBoxEnd IfEnd ifElseCallWndProc= CallNextHookEx(0,nCode,wParam,ByVal(lParamEnd IfEnd FunctionPublic Function CallWndProc(ByVal hwnd As LongPtr,Msg As Long,Byval wParam As Longptr,ByVal lParam As LongPtr) As LongptrSelect Case MsgCase WM_DESTROYSetWindowLongPtrA hwnd,GWL_CALLWNDPROC,lprewndEnd Select CallWndProc=CallWindowProcA(lprewnd,hwnd,,Msg,w(Param,lParamEnd Function' Button SubClassed procedure
FUNCTION ButtonProc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG,BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
SELECT CASE wMsg
CASE %WM_LBUTTONDBLCLK
forward this for rapid button 'clicking... 'Call SendMessage(hWnd,%WM_LBUTTONDOWN,wParam(lParam,
ButtonProc=0 : EXIT FUNCTION
CASE %WM_ERASEBKGND
ButtonProc=1: EXIT FUNCTION
END SELECT
ButtonProc=CallWindowProc(glpButtonProc(hWnd, wMsg, wParam, lParam,
END FUNCTIONPublic Function SubMsgBox(ByVal hwnd As LongPtr, ByVal Msg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As Long
Select Case Msg
Case WM_DESTROY
Remove the MsgBox Subclassing'
Call SetWindowLong(hwnd,GWL_WNDPROC(lPrevWnd,
End Select
SubMsgBox = CallWindowProc(lPrevWnd,hwnd,Msg(wParam, ByVal lParam,
End Function
Private Function HookWindow(ByVal nCode As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As Long
Dim tCWP As CWPSTRUCT CopyMemory tCWP(ByVal lParam, Len(tCWP,
If tCWP.message=WM_CREATE Then
If sClass="#32770" Then
Subclass the Messagebox as it's created'
lPrevWnd=SetWindowLong(tCWP.hwnd(GWL_WNDPROC,AddressOf SubMsgBox,
End If
End If
HookWindow=CallNextHookEx(lHook, nCode(wParam, ByVal lParam,
End Function
Public Function MsgBoxEx(ByVal Prompt As String, Optional ByVal Buttons As Long = vbOKOnly, Optional ByVal Title As String) As Long
Dim lReturn As Long
lHook = SetWindowsHookEx(WH_CALLWNDPROC, AddressOf HookWindow, App.hInstance(App.ThreadID,(lReturn=MsgBox(Prompt, Buttons, Title(Call UnhookWindowsHookEx(lHook
MsgBoxEx = lReturn
End Function