کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی
کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی

TTM_POPUP پیامی برای ToolTip



باعث میشود که Tooltip در مختصات  پیام آخرین ماوس ارسالی نمایش داده شود.

Causes the tooltip to display at the coordinates of the last mouse message

Parameters

wParam

Must be zero

lParam

Must be zero

Return value

The return value is not used



SetCursorPos 300, 300

SendMessageA hWndtoolTip,TTM_POPUP, 0,0



Private Const WM_SETCURSOR=&H20

Parameters

wParam

با GetDlgItem
A handle to the window that contains the cursor

lParam

The low-order word of lParam specifies the hit-test code

The high-order word of lParam specifies the identifier of the mouse message

Return value

If an application processes this message, it should return TRUE to halt further processing or FALSE to continue.



?last=0

case WM_MOUSEMOVE

if (?lParam<>0) Then
SetTimer hwnd, 1,   GetDoubleClickTime   , 0
last = lParam
End if
Exit Function


case WM_TIMER

if (wParam<>1) The Exit Function

KillTimer hwnd, 1
(makeTooltip(hwnd
SendMessage tooltip, TTM_POPUP, 0, 0


TTM_SETDELAYTIME = &H403
TTM_ADDTOOLA = &H404
TTM_RELAYEVENT = &H407
TTM_SETTOOLINFOA = &H409
TTM_HITTESTA = &H40A
TTM_UPDATETIPTEXTA = &H40C
TTM_WINDOWFROMPOINT := 0x410
TTM_TRACKACTIVATE = &H411
TTM_TRACKPOSITION = &H412
TTM_SETTIPBKCOLOR = &H413
TTM_SETTIPTEXTCOLOR = &H414
TTM_SETMAXTIPWIDTH = &H418
TTM_GETMAXTIPWIDTH = &H419

TTM_SETMARGIN = &H41A

TTM_POP = &H41C
TTM_UPDATE = &H41D
TTM_ADJUSTRECT = &H41F
TTM_SETTITLEA = &H420
TTM_SETTITLEW = &H421
TTM_POPUP = &H422
TTM_ADDTOOLW = &H432
 TTM_SETTOOLINFOW = &H436

 TTM_HITTESTW = &H437

TTM_GETTEXTW = &H438

 TTM_UPDATETIPTEXTW = &H439



ChildWindowFromPoint hWndParent,Point


MapWindowPoints hWndFrom,hWndTo, lpPoints(Rect),cPoints(number of points

(POINT pt(2

MapWindowPoints hWnd1,hWnd2,pt(0), 1

MapWindowPoints(hWnd1,hWnd2,pt(1), 1




تغییر سایز Edit در پنجره 


(hEdit=GetDlgItem(hDlg,IDC_EDIT
Dim rct As RECT
GetClientRect hEdit,rct

MapWindowPoints hEdit,hDlg,rct,1

MoveWindow hEdit,rct.left,rct.top, rct.right-40,rct.bottom





 : OnCreate 

(ti.cbSize = Len(ti
ti.uFlags =TTF_TRACK Or TTF_ABSOLUTE
ti.hwnd = hwndOwner
ti.uId = '(UINT)FIT_NLSF_EDIT_FUNC
ti.hinst =0
("ti.lpszText =TEXT("hello
ti.rect.left = 0
ti.rect.right = 0
ti.rect.bottom =0
ti.rect.top =0
SetRectEmpty ti.rect'

SendMessageA hwndTT,TTM_ADDTOOL, 0,ti

SendMessageA hwndTT,TTM_SETMAXTIPWIDTH,0,80

SendMessageA hwndTT,TTM_SETTIPBKCOLOR, RGB(247, 252, 203),0

SendMessageA hwndTT,TTM_SETTIPTEXTCOLOR, RGB(0, 0, 0),0

RetVal = SendMessage(hwndTT, TTM_UPDATETIPTEXTA, 0, ti)

SendMessageA hwndTT,TTM_TRACKACTIVATE,TRUE, ti





GetCursorPos pt 'get the cursor position

if  WM_SETCURSOR Then

get the button rect'
GetWindowRect(GetDlgItem(hDlg, FIT_NLSF_SELECT_FUNC),rc1

if PtInRect(rc1, pt) Then

SendMessage hwndTT,TTM_TRACKPOSITION, 0,(LPARAM)MAKELPARAM(pt.x,pt.y)

TTM_POPUP message'
'Causes the tooltip to display at the coordinates of the' last mouse message.
SendMessage hwndTT,TTM_POPUP,0,0
Else

TTM_POP message'
Removes a displayed tooltip window from view'
SendMessage hwndTT,TTM_POP,0,0

End If


Re: TOOLTIP in win32

Tacking means that the tooltip will move with the mouse( it just explicitly send the TTM_TRACKPOSITION message to the tooltip window).
as for the handle of tooltip control window, I use the global static type. the parent window is not deconstructed.
ps,I think if I use the TTF_IDISHWND flag, then uId should be the handle to that control .
Thanks
tony



اگر درست باشد البته 

Public Function MAKELPARAM(ByVal wLow As Long, ByVal wHigh As Long) As Long

(&MAKELPARAM=(wlow And &H7FFF
(&Or (&H10000 * (wHigh And &H7FFF 

End Function

ToolTip



Private g_hwndTT As Long 
Private g_ti As TOOLINFOA

(OnCreate(hwnd
g_hwndTT=CreateWindow(TOOLTIPS_CLASS, nullptr,WS_POPUP Or TTS_ALWAYSTIP Or 
(TTS_BALLOON,0,0,0, 0,hwnd,0,0,0

g_ti.uFlags=TTF_TRACK
g_ti.hwnd = hwnd
("g_ti.lpszText=TEXT("Hi there

SendMessage(g_hwndTT, TTM_ADDTOOL,0,
(LPARAM)&g_ti,
return TRUE

  : On Char  

Dim pt As POINTAPI

Select Case wparam 

 if  GetCursorPos (pt) Then

SendMessage(g_hwndTT,TTM_TRACKPOSITION,0,MAKELPARAM(pt.x,
((pt.y,

SendMessage(g_hwndTT,TTM_TRACKACTIVATE,TRUE
((LPARAM)&g_ti,
Exit Function 

case 27  ' ESCAPE

SendMessage(g_hwndTT,TTM_TRACKACTIVATE
(FALSE,0,
Exit Function 



.At startup, we add the tool but do not show the balloon tooltip yet

When the user presses the space bar
we get the current cursor position and tell the tracking tooltip
.to appear at exactly that location
.then we activate tracking mode
  :The result
The balloon tip appears, and the tip of the balloon points directly
.at the mouse cursor

.When the user presses the ESC key
we deactivate tracking mode, which removes the tooltip from the
.screen





TTM_ACTIVEPOSITION

Parameters

wParam

.Must be zero

lParam

The LOWORD specifies the x-coordinate of the point at which the tracking tooltip will be displayed, in screen coordinates. The HIWORD specifies the y-coordinate of the point at which the tracking tooltip will be  displayed, in screen coordinates

To have tooltip windows displayed at specific coordinates, include the TTF_ABSOLUTE flag in the uFlagsmember of the TOOLINFO structure when 
.adding the tool



TTF_ABSOLUTE
Positions the tooltip window at the same coordinates provided by TTM_TRACKPOSITION. This flag must be used with the TTF_TRACK flag.

TTF_CENTERTIP
Centers the tooltip window below the tool specified bythe uId member.

TTF_IDISHWND
Indicates that the uIdmember is the window handle to the tool. If this flag is not set, uId is the tool's identifier.



(Sub CreateToolTipForRect(HWND hwndParent

'Create a tooltip. HWND

hwndTT=CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, g_hInst,NULL)

SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE)

'Set up "tool" information. In this case, the "tool" is the entire parent window.

TOOLINFO ti = { 0 }
ti.cbSize = sizeof(TOOLINFO)
ti.uFlags = TTF_SUBCLASS
ti.hwnd = hwndParent
ti.hinst = g_hInst
ti.lpszText = TEXT("This is your tooltip string.")

GetClientRect (hwndParent, &ti.rect)

' Associate the tooltip with the "tool" window.

SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti)

End Sub 








We need to show the tooltip form without activating it, so we can use the API method, 'ShowWindow' with the SW_SHOWNA parameter, which will show the form and bring it to the front without stealing focus from other windows.


ShowWindow function

Sets the specified window's show state

SW_SHOW=5
Activates the window and displays it in its current size and position.

SW_SHOWNA=8
Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated.



ToolTip










g_toolItem is a global TOOLINFO

(HWND CreateTrackingToolTip(toolID, hDlg,pText
Create a tooltip'

hwndTT=CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,WS_POPUP Or TTS_NOPREFIX Or TTS_ALWAYSTIP, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,hDlg, NULL,

(g_hInst,NULL,


g_toolItem.cbSize = sizeof(TOOLINFO) g_toolItem.uFlags=TTF_IDISHWND Or TTF_TRACK Or TTF_ABSOLUTE g_toolItem.hwnd=hDlg
g_toolItem.hinst=g_hInst g_toolItem.lpszText=pText
g_toolItem.uId=hDlg

GetClientRect  hDlg, &g_toolItem.rect) 'Associate the tooltip with the tool window.

SendMessage hwndTT,TTM_ADDTOOL,0, (LPARAM) (LPTOOLINFO) &g_toolItem
CreateTrackingToolTip=hwndTT


g_hwndTrackingTT is a global HWND variable'



case WM_INITDIALOG

()InitCommonControls
g_hwndTrackingTT=CreateTrackingToolTip(IDC_BUTTON1, 

(hDlg,""

        return TRUE

case WM_MOUSELEAVE
'The mouse pointer has left our window. Deactivate' 

the tooltip.


SendMessage g_hwndTrackingTT, TTM_TRACKACTIVATE,(WPARAM)FALSE,

(LPARAM)&g_toolItem),



g_TrackingMouse = FALSE
 return FALSE

:case WM_MOUSEMOVE

static oldX, oldY
Dim newX, newY

    if (!g_TrackingMouse) Then 'The mouse has just entered the window.
Request notification when the mouse leaves.
    
Dim tme As TRACKMOUSEEVENT 

(tme =sizeof(TRACKMOUSEEVENT
tme.hwndTrack=hDlg
tme.dwFlags=TME_LEAVE
        
TrackMouseEvent &tme

Activate the tooltip.'

SendMessage g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)&g_toolItem

g_TrackingMouse = TRUE

(newX = GET_X_LPARAM(lParam
(newY = GET_Y_LPARAM(lParam

Make sure the mouse has actually moved. The '

presence of the tooltip causes Windows to send the message continuously

    
((if ((newX <> oldX) Or  (newY<> oldY

        oldX = newX
        oldY = newY

Update the text.'
        

g_toolItem.lpszText=newX & newY

SendMessage g_hwndTrackingTT, TTM_SETTOOLINFO, 0,(LPARAM)&g_toolItem

Position the tooltip. The coordinates are adjusted so '

that the tooltip does not overlap the mouse pointer

        

{POINT pt = { newX, newY 
ClientToScreen hDlg, &pt
SendMessage 

,g_hwndTrackingTT,TTM_TRACKPOSITION,0

((LPARAM)MAKELONG(pt.x+10,pt.y-20


 return FALSE




sub CreateToolTip(ByVal hwnd as HWND,ByVal txt As 
(String,ByVal tthwnd as HWND

dim iccex As INITCOMMONCONTROLSEX
   
dim ti As  TOOLINFOA

iccex.dwICC=ICC_WIN95_CLASSES
(iccex.dwSize =sizeof(INITCOMMONCONTROLSEX

InitCommonControlsEx iccex

hwndTT=CreateWindowEx(0, TOOLTIPS_CLASS,VbNullStrinh,WS_POPUP or TTS_NOPREFIX or TTS_ALWAYSTIP,CW_USEDEFAULT, 
,CW_USEDEFAULT,CW_USEDEFAULT, 
(CW_USEDEFAULT,tthwnd,0,0, 0

SetWindowPos hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE


(ti.cbSize = 40 'sizeof(TOOLINFOW
ti.uFlags = TTF_SUBCLASS
ti.hwnd = hwnd
ti.hinst =0
(ti.lpszText=strptr(text
GetClientRect hwnd,ti.rect

SendMessage hwndTT,TTM_ADDTOOL, 0 , ti

End sub




نمایش بالن راهنما در EDIT CONTROL


EM_SHOWBALLOONTIP

displays a balloon tip associated with an edit control


Parameters

 : wParam

Not used; must be zero

lParam

این پارامتر یک نشانگر به ساختار EDITBALLONTIP ( ممبر یا عضوهای ساختار در ادامه آمده ) که حاوی اطلاعات درباره ی بالن راهنمای جهت نمایش است .
A pointer to an EDITBALLOONTIP structure that contains information about the balloon tip to display.



Type EDITBALLOONTIP
cbStruct As Long
pszTitle As String
pszText As String
ttiIcon As Integer
End Type

ttiIcon

TTI_ERROR  Use the error icon
TTI_INFOUse the information icon
TTI_NONEUse no icon
TTI_WARNINGUse the warning icon



Tooltip iconsconst
TTI_NONE = 0
TTI_INFO = 1
TTI_WARNING = 2
TTI_ERROR = 3
TTI_INFO_LARGE = 4
TTI_WARNING_LARGE = 5
TTI_ERROR_LARGE = 6


  • عدم ظهور BALLOONTIP یا بالن راهنما در Subclass کردن EDIT CONTROL


Function NoBalloonWndProc(ByVal hwnd As Long,ByVal uMsg As Long,ByVal wParam As 
(Long,Byval lParam As Long

Select Case uMsg
  case EM_SHOWBALLOONTIP
     NoBalloonWndProc=FALSE
End Select 
NoBalloonWndProc=CallWindowProc(g_Edit,hwnd,uMsg,wParam,lParam
(