WINDOWPLACEMENT structure
Contains information about the placement of a window on the screen.
Type WINDOWPLACEMENT
length As Long
flags As Long
showCmd As Integer
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
rcDevice As RECT
End Type
Of course you should measure/obtain the correct border size from your window style by using methods like GetSystemMetrics or GetThemeMetric, its a very simple task. I just wanted to demonstrate how you can change the border size of your frame when switching between the window states.
The size and positions of the caption buttons are now correct, as you can see here
GetWindowPlacement function
Retrieves the show state and the restored, minimized, and maximized positions of the specified window.
Parameters
hWnd
Type: HWND
A handle to the window.
lpwndpl
Type: WINDOWPLACEMENT*
A pointer to the WINDOWPLACEMENTstructure that receives the show state and position information. Before calling GetWindowPlacement, set the lengthmember to sizeof(WINDOWPLACEMENT). GetWindowPlacement fails if lpwndpl-> length is not set correctly.
Return Value
Type: Type: BOOL
If the function succeeds, the return value is nonzero.
Remarks
The flags member of WINDOWPLACEMENTretrieved by this function is always zero. If the window identified by the hWnd parameter is maximized, the showCmd member is SW_SHOWMAXIMIZED. If the window is minimized, showCmd is SW_SHOWMINIMIZED. Otherwise, it is SW_SHOWNORMAL.
The length member of WINDOWPLACEMENTmust be set to sizeof(WINDOWPLACEMENT). If this member is not set correctly, the function returns FALSE. For additional remarks on the proper use of window placement coordinates, see WINDOWPLACEMENT.
https://www.codeproject.com/Articles/1293/Control-Subclassing
هنوز تست نشده ولی نحوه ی کار به این شکل است که اندازه ی ناحیه Client رو عوض میکنند تا دو مستطیل با حالت باتن در پائین و بالای آن بکشند ، بعنوان Scroll Up/Down و NCHITTEST هم زمانی که ماوس روی آن قسمت ها قرار می گیرد یا موقعیت عوض میشود عدد ثابتی رو بر میگردونه و طبق همون و NCLBUTTONDOWN تابعی رو صدا میزنن که حالت PUSH بگیره وقتی فشرده شه یا به حالت اولش برگرده .
در NCCALCSIZE و WPARAM=1 اندازه ی دوباره داده میشود البته SWP_FRAMECHANGED نباید فراموش شود بعد از ساب کلاس کردن فرضا
Private listboxProc As LongPtr
listboxProc=0
HookWindow
در HOOKPROC زمانیکه پیام HCBT_CREATEWND دریافت میشود برای هنگ نکردن یا عدم Crash باید اگر listbox=0 و wparam برابر با کلاس پنجره با تابع GetClassName و نام پنجره ( منظور کپشن آن ) همان نام پنجره (قلاب شده) شد منظور با GETWINDOWTEXT به تابع WndProc ریفر داده شود جهت تسخیر پیام های ارسالی
WndProc
Select Case Msg
Case WM_ENABLE ' WM_SHOWWINDOW
listboxproc=SetWindowLongPtrA(hlist,GWL_WNDPROC,AddressOf
(fnlist
SetWindowpos 0,0,0,0,0,0,SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_FRAMECHANGED
WM_DESTROY
SetWindowLongPtrA hwnd,GWL_WNDOROC,listboxProc
End Function
تابعی برای Capture کردن یا تسخیر پیام های دریافتی ( لیست باکس )
Function fnlist(ByVal hwnd As LongPtr,ByVal Msg As Long,ByVal wParam As LongPtr,ByVal lParam As LongPtr) As LongPtr
Dim nccsp As NCCALCSIZE_PARAMS
Select Case Msg
Case WM_NCCALCSIZE
CallWindProcA listboxProc,hwnd,Msg,wParam,lParam
Case WM_NCPAINT
End Select
(fnlist=CallWindProcA(listboxProc,hwnd,Msg,wParam,lParam
End Function
در NCPAINT کشیدن Scroll انجام میشود
SetBkColor(COLORREF crBkColor,COLORREF
(crSelectedColor
new one '
DeleteObject m_BkBrush
Sets the brush the specified background color'
m_BkBrush=CreateSolidBrush(crBkColor)
Invalidate 'Forces Redraw
track.dwFlags=TME_LEAVE 'Notify us when the mouse leaves
track.hwndTrack=m_hWnd 'Assigns this window's hwnd
TrackMouseEvent &track
WM_NCCALCSIZE
. Add a function for it, and we get:A POINTS structure that contains the x- and y-coordinates of the cursor. The coordinates are relative to the upper-left corner of the screen.
case WM_NCCALCSIZE
ncParams=(LPNCCALCSIZE_PARAMS) lParam
ncParams.rgrc(0).top=ncParams.rgrc(0).top4
ncParams.rgrc(0).left=ncParams.rgrc(0).left+4
ncParams.rgrc(0).bottom=ncParams.rgrc(0).bottom-4
ncParams.rgrc(0).right=ncParams.rgrc(0).right-4
Function=0
case WM_NCPAINT
Crect As RECT
GetWindowRect hWnd, Crect
(hdc=GetDC(hwnd
((hpen=CreatePen(PS_INSIDEFRAME,4, RGB(255, 0, 0
(holdobj=SelectObject(dc,hpen
width=Crect.right-Crect.left
height=Crect.bottom-Crect.top
Rectangle hdc,0,0,width,height SelectObject hdc,holdobj
ReleaseDC hWnd, dc
DeleteObject hpen
Function=0
case WM_NCACTIVATE
RedrawWindow hWnd,0,0, RDW_UPDATENOW???
Function=0
lpncsp->rgrc[0].right -= 100
void CListBoxEx::SetBkColor(COLORREF crBkColor,COLORREF crSelectedColor)
{
//Deletes previous brush. Must do in order to create a new one m_BkBrush.DeleteObject();
//Sets the brush the specified background color m_BkBrush.CreateSolidBrush(crBkColor); Invalidate();
//Forces Redraw
}
Function DrawBorders()
GetClientRect hlist,Crect
InflateRect Crect,GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)
'Since we'll be using m_bOver, let's 'initialize it. Add m_bOver = 'FALSE; on PreSubclassWindow.
if (m_bOver) Then
DrawEdge hdc,Crect,EDGE_BUMP,BF_RECT
Else
DrawEdge hdc,Crect,EDGE_SUNKEN,BF_RECT
End If
ReleaseDC hdc
End Function
WM_MOUSEAVE
m_bOver=FALSE
DrawBorders()
We then set them to an initial value under PreSubclassWindow:
m_bOver = FALSE;
m_ItemHeight=18; m_crTextHlt=GetSysColor(COLOR_HIGHLIGHTTEXT);
m_crTextClr=GetSysColor(COLOR_WINDOWTEXT);
m_HBkColor=GetSysColor(COLOR_HIGHLIGHT);
m_BmpWidth=16;
m_BmpHeight=16;
MeasureItem:
lpMeasureItemStruct->itemHeight=m_ItemHeight;
we can resize the client area. This can be done by receiving the message WM_NCCALCSIZE
lpncsp->rgrc[0].top += 16; //Top
lpncsp->rgrc[0].bottom -= 16; //Bottom
OnNcPaint()
static BOOL before=FALSE
if (!before) Then
SetWindowPos(NULL,0,0,0,0,SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE before=TRUE
DrawBorders()
DrawScrolls(UINT WhichOne, UINT State)
pDC=GetDC()
CRect rect
GetClientRect hwnd,Crect)
if (IsWindowEnabled())State=SC_DISABLED; //Expands the so that it does not draw over the borders
Crect.left=Crect.left-GetSystemMetrics(SM_CYEDGE) Crect.right= Crect.right+GetSystemMetrics(SM_CXEDGE)
if (WhichOne==SC_UP)
rect.bottom=rect.top-GetSystemMetrics(SM_CXEDGE) rect.top=rect.top-16-GetSystemMetrics(SM_CXEDGE)
'Draws the scroll up
DrawFrameControl pDC,Crect,DFC_SCROLL,State Or DFCS_SCROLLUP)
else
'Needs to draw down rect.top=rect.bottom+GetSystemMetrics(SM_CXEDGE) rect.bottom=rect.bottom+16+GetSystemMetrics(SM_CXEDGE); DrawFrameControl pDC,Crect,DFC_SCROLL,State Or DFCS_SCROLLDOWN
ReleaseDC pDC
pubic const SC_UP=2
public const SC_DOWN=3
OnEnable
'SC_NORMAL will be changed to 'SC_DISABLED if the window is disabled DrawScrolls(SC_UP,SC_NORMAL) DrawScrolls(SC_DOWN,SC_NORMAL);
OnNcLButtonDown(UINT nHitTest, CPoint point)
if (nHitTest=HTVSCROLL) 'Up scroll Pressed DrawScrolls(SC_UP,SC_PRESSED) 'Scroll up 1 line SendMessage(WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0)
SetTimer(1,100,NULL)'Sets the timer ID 1
else if (nHitTest==HTHSCROLL)'Down scroll Pressed DrawScrolls(SC_DOWN,SC_PRESSED) ' Scroll down 1 line SendMessage(WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0) SetTimer(2,100,NULL) 'Sets the timer ID 2
OnTimer(UINT nIDEvent)
result=GetKeyState(VK_LBUTTON)
if (nIDEvent==1) ' Up timer If it returns negative then it is pressed
if (result<0)
SendMessage(WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0)
else ' No longer pressed
KillTimer(1) DrawScrolls(SC_UP,SC_NORMAL)
else 'Down timer
'If it returns negative then it is pressed
if (result<0)
SendMessage(WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0)
else
KillTimer(2)
DrawScrolls(SC_DOWN,SC_NORMAL)
OnNcHitTest(CPoint point)
CRect rect,top,bottom
GetWindowRect hwnd,Crect
ScreenToClient hwnd,Crect)
top=bottom=rect
top.bottom=rect.top+16 bottom.top=rect.bottom-16
'Obtains where the mouse is
UINT
where=CListBox::OnNcHitTest(point)
'Converts the point so its relative to the client area
ScreenToClient hwnd,&point)
if (where == HTNOWHERE) 'If mouse is not in a place it recognizes
if (PtInRect(top,point)) 'Check to see if the mouse is on the top
where=HTVSCROLL
else if (PtInRect(bottom,point)) 'Check to see if its on the bottom
where=HTHSCROLL
return where ' Returns where it is
WM_NCLBUTTONDOWN 0x00A1
Parameters
wParam
The hit-test value returned by the DefWindowProc function as a result of processing the WM_NCHITTEST message. For a list of hit-test values, see WM_NCHITTEST.
lParam
A POINTS structure that contains the x- and y-coordinates of the cursor. The coordinates are relative to the upper-left corner of the screen.
Type NCCALCSIZEPARAM
rgrc(3) As RECT
lpos As WINDOWPOS
End Type
lParam
If wParam is TRUE, lParam points to an NCCALCSIZE_PARAMS structure that contains information an application can use to calculate the new size and position of the client rectangle.
If wParam is FALSE, lParam points to a RECTstructure. On entry, the structure contains the proposed window rectangle for the window. On exit, the structure should contain the screen coordinates of the corresponding window client area
Function fnListSubClass(ByVal hwnd As LongPtr,ByVal msg As Long,ByVal wParam As LongPtr,ByVal lParam As LongPtr)
Select Case msg
case WM_NCCALCSIZE
CallWindowProc listboxProc,hwnd,msg, wParam, lParam
'what is doing???
RECT* pRect = (RECT*)lParam
pRect->left+=4;
pRect->top+=23;
pRect->bottom+=23;
return 0;
case WM_NCPAINT
hdc=GetDC(hwnd) GetClientRect hwnd,rect
SetRect rect,0,0,4, rect.bottom brush=LoadBitmap(GetModuleHandle(0), MAKEINTRESOURCE(IDB_BORDER))
newBrush=CreatePatternBrush(brush)
oldBrush=SelectObject(hdc, newBrush) FillRect hdc,rect,newBrush SelectObject hdc, oldBrush
DeleteObject newBrush
DeleteObject oldBrush
DeleteObject brush
UpdateWindow hwnd
ReleaseDC hwnd, hdc
Exit Function
fnListSubClass=CallWindowProc(listboxProc, hwnd
(msg, wParam, lParam,
((CreateSolidBrush(RGB(51,94,168,
((CreateSolidBrush(RGB(255,255,255,
We handle WM_NCCREATE
because we want to associate so data with the LISTBOX and make a minor modification to the LISTBOX style. Creating our data is a simple and store in the window properties.
We modify the style by adding the WS_HSCROLL
if the LISTBOX doesn't already have it. Without this style the horizontal scrollbar won't show no matter what we do.
Here we simply destroy our data structure and remove it from the window properties. Nothing exciting.
مثالی دیگر از مطالب به اشتراک گذاشته در سایت خارجی
فقط در CopyMemory سایز ۴۰ را به آرگومان سومش تخصیص دهید و از ByVal lParam استفاده کنید.
در مورد LB_GETTEXT :
The return value is the length of the string, in TCHARs, excluding the terminating null character. If wParam does not specify a valid index, the return value is LB_ERR.
If the list box has an owner-drawn style but not the LBS_HASSTRINGS style, the buffer pointed to by the lParam parameter receives the value associated with the item (the item
(data
Vb Uses Unicode For Text String hence delcare SendMessageW instead Of SendMessageA****
: Important Notes
Use -----> LBS_OWNERDRAWFIXED Or LBS_HASSTRINGS
use -----> SendMessageW, / TextoutW
To Add Item it is important to Use SendMessageA And Byval "Item" you want to add like
"SendMessageA hlist, &H180, 0, ByVal "FFF
case WM_DRAWITEM
Dim Buff As String * 255 ' important
GetClientRect pdis.hwndItem, pdis.rcItem
r = pdis.rcItem
l = SendMessageW(pdis.hwndItem, LB_GETTEXT, pdis.itemID, ByVal Buff
SendMessageA pdis.hwndItem, LB_GETITEMRECT, pdis.itemID, r
TextOutW pdis.hdc, r.Left, r.Top, ByVal Buff, l
"SendMessageA hlist, &H180, 0, ByVal "FFF
"SendMessageA hlist, &H180, 0, ByVal "HHT
"SendMessageA hlist, &H180, 0, ByVal "123E
"سلام" SendMessageA hlist, &H180, 0, ByVal
"حاجی"SendMessageA hlist, &H180, 0, ByVal
if pdis.itemid mod 2=. then SetTextColor Else SetTextColor
If pdis.itemAction = ODA_SELECT Then
( l = SendMessageW(pdis.hwndItem, LB_GETTEXT, pdis.itemID, ByVal Buff
SetWindowTextW hwnd, ByVal Buff
End If
Static OldRect
If pdis.itemAction = ODA_SELECT Then
( l = SendMessageW(pdis.hwndItem, LB_GETTEXT, pdis.itemID, ByVal Buff
SetWindowTextW hwnd, ByVal Buff
r.Left = r.Left + 15
(FillRect pdis.hdc, r, GetSysColorBrush(0
InvalidateRect pdis.hwndItem, OldRect, 1
OldRect = r
End If
%WS_CHILD Or %LBS_OWNERDRAWFIXED Or %LBS_MULTICOLUMN Or %LBS_NOTIFY Or %WS_TABSTOP Or %WS_HSCROLL, %WS_EX_CLIENTEDGE
vb Uses Unicode for text string so use SendMessageW instead Of SendMessageA Function
The list box has the LBS_OWNERDRAWFIXED and LBS_HASSTRINGS styles, in addition to the standard list box styles.
LBS_HASSTRINGS
LB_GETTEXT
The return value is the length of the string, in TCHARs, excluding the terminating
(null character ( hence buff+1
If the list box has an owner-drawn style but not the LBS_HASSTRINGS style, the buffer pointed to by the lParam parameter receives the value associated with the item the item data
Means Use Byval
If the list box has WS_HSCROLL style and you insert a string wider than the list box, send an LB_SETHORIZONTALEXTENT message to ensure the horizontal scroll bar appears.
Case WM_MEASUREITEM
Case WM_DRAWITEM
Dim pdis As DRAWITEMSTRUCT
Dim tm As TEXTMETRIC
Dim hDCMem As LongPtr
CopyMemory pdis, ByVal lParam, 40
Select Case pdis.itemAction
Case ODA_SELECT, ODA_DRAWENTIRE
Dim p As RECT
GetClientRect pdis.hwndItem, pdis.rcitem
BitBlt pdis.hdc
SetBkMode pdis.hdc, 0
SetTextColor pdis.hdc, vbRed
TextOutA pdis.hdc, pdis.rcitem.Left,pdis.rcitem.Top, buffer$, 5
CopyMemory lParam, pdis,40
End Select
گرفتن تعداد آیتم ها در لیست باکس
LB_GETCOUNT message
Gets the number of items in a list box
wParam,lParam
Not used; must be zero
Dim index As Integer
Dim textBuff As String
(textBuff = Space(255
(NumItems=SendMessage(hWndList,LB_GETCOUNT,0,0
index use GETCURSEL'
Gets the index of the currently selected item)'
(if any, in a single-selection list box'
SendMessageW hWndList, LB_GETTEXT,index, textBuff
MsgBox textBuff
docs.microsoft.com/enmeasureitemstruct
مثالی از کشیدن نقطه چین دور آیتم سلکت شده به زبان دیگر
if lpdis->itemState & ODS_SELECTED
* Set RECT coordinates to surround only the'
* bitmap.
rcBitmap.left=lpdis->rcItem.left
rcBitmap.top=lpdis->rcItem.top
rcBitmap.right=lpdis->rcItem.left+XBITMAP
rcBitmap.bottom=lpdis->rcItem.top + YBITMAP
* Draw a rectangle around bitmap to indicate'
* the selection.
DrawFocusRect lpdis->hDC, &rcBitmap
استفاده در مثال شکل بالا به زبان دیگر
Display the text associated with the item'
SendMessage lpdis->hwndItem
LB_GETTEXT,lpdis->itemID, (LPARAM) tchBuffer,
GetTextMetrics lpdis->hDC, &tm
GetClientRect lpdis.hwnditem,lpdis.rcItem'
-y=(lpdis->rcItem.bottom+lpdis->rcItem.top
tm.tmHeight) / 2
6+TextOutA lpdis->hDC,XBITMAP
(y,tchBuffer,len(tchBuffer,
SelectObject hdcMem, hbmpOld
DeleteDC hdcMem
The GetTextMetrics function fills the specified buffer with the metrics for the currently selected font
BOOL GetTextMetrics( HDC hdc, LPTEXTMETRIC lptm );
Parameters
hdc
A handle to the device context
lptm
A pointer to the TEXTMETRIC structure that receives the text metrics.
Type TEXTMETRICA
tmHeight As Long
tmWeight As Long
tmItalic As Long
tmMaxCharWidth As Long
tmUnderlined As Long
tmCharSet As Long
End Type
: case WM_MEASUREITEM
;lpmis = (LPMEASUREITEMSTRUCT) lParam
;lpmis->itemHeight=20
;return TRUE
(DrawEntire(LPDRAWITEMSTRUCT lpDStruct
;(CRect rect(lpDStruct->rcItem
;HDC dc =lpDStruct->hDC
;MYLISTITEM *a = (MYLISTITEM*)lpDStruct->itemData
TextOut(dc,rect.left+20,rect.top+2,a->title,strlen(a-
;((title<
;(SelectObject(dc,hOldFont
;(SelectObject(dc,oldpen
;(SelectObject(dc,oldbrush
;("strcpy(logFont.lfFaceName,"courier
;(hFont = CreateFontIndirect(&logFont
(hOldFont = (HFONT)SelectObject(dc,hFont
InitCommonControls
KEYBOARD FOCUS
تماما طبق داکیومنت آفیس و فروم خارجی انجام شده ماجیک نیست و بنده هم خالقش نیستم تجربه ای بود که شما را هم سهیم کردم هر چند خود شما استاد بنده هستید.
در پیام ShowWindow در WndProc
تب اوردر یا ترتیب فوکس کنترل ها در Inputbox اول Edit است و بعد Ok و نهایتا Cancel
درhbtn که JK است در EXSTYLE آن از CLIENTEDGE و STATICEDGE استفاده شده
در تابع زیر فوکس بعد از ٍ Edit به باتن JK داده شده طبق تصویر و بعد به باتن Cancel طبق تصویر پایین ترش
Et: Edit Control Handle
اگر NOSIZE را بکار نبریم سایز باتن صفر میشود پس حتما بگذارید مگر اینکه بخواهید سایز طبق آرگومانها تغییرکند همچنین جابجایی اش .
SetWindowPos hbtn, Et, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
SetWindowPos GetDlgItem(hwnd, 2), hbtn, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
lParam
Pointer to an NMUPDOWN structure that contains information about the position change. The iPos member of this structure contains the current position of the control. The iDelta member of the structure is a signed integer that contains the proposed change in position
If the user has clicked the up button, this is a positive value
If the user has clicked the down button, this is a negative value
wParam
State of the progress bar that is being set. One of the following values.
lParam
Dim nmh As NMHDR
Dim nmp As NMUPDOWN
1400UpDownControlId
Case WM_NOTIFY
چون کنترل ساخته شده پیامی را دریافت نمی کند از طریق parent خود در نتیجه
If wParam = 1400 Then nmh.code = (-722) ' UDN_DELTAPOS
SetWindowTextA Et, nmh.hwndFrom & " ID: " & nmh.idFrom & "/ code ...." & nmh.code & "... Wparam: " & wParam
If nmh.code = (-722) Then
( CopyMemory nmp, ByVal lParam, Len(nmp
nmp.hdr = nmh ' No Need'
SetWindowTextA hwnd, "Delta : " & nmp.iDelta & " Pos : " & nmp.iPos
End If
(CopyMemory lParam, nmp, Len(nmp
iPos
Type: int
Signed integer value that represents the up-down control's current position.
iDelta
Type: int
Signed integer value that represents the proposed change in the up-down control's position.
Static ddd
If nmp.iDelta = 1 Then ddd = ddd - 1 Else ddd = ddd + 1
nmp.iPos = ddd
SetWindowTextA hwnd, "Delta : " & nmp.iDelta & " Pos : " & nmp.iPos
End If
in case wm_destroy nmp.ipos=0:ddd=0'
UDM_SETRANGE message
Sets the minimum and maximum positions (range) for an up-down control
Parameters
wParam
Must be zero
lParam
The LOWORD is a short that specifies the maximum position for the up-down control, and the HIWORD is a short that specifies the minimum position
case WM_VSCROLL
delta=LOWORD(SendDlgItemMessage(dlg, IDC_SPIN1,UDM_GETPOS,0,0))
SetDlgItemText(dlg,IDC_DTRANS,mystring
WM_VSCROLL
wparam
The HIWORD specifies the current position of the scroll box
The LOWORD specifies a scroll bar value that indicates the user's scrolling request.
SB_BOTTOM
SB_TOP
lParam
If the message is sent by a scroll bar control, this parameter is the handle to the scroll bar control. If the message is sent by a standard scroll bar, this parameter is NULL.
با WS_TABSTOP فوکس میگیرد ( کیبورد) ولی برای اجرای دستور توسط پیام WM_COMMAND باید از lparam آن استفاده کرد که هندل پنجره ایجاد شده است .
Case WM_COMMAND ' wm-command
"!!!..." & ( If lParam = hbtn Then MsgBox "Clicked " & GetWindowText(hbtn
Select Case wParam
Case 2
End Select
با توجه باینکه WS_TABSTOP تنظیم شده لذا باتن JK توسط کلید TAB کیبورد فوکس خواهد گرفت و در شکل زیر نقطه چین هایی که در مستطیل آن باتن مشخص است نشاندهنده ی فوکس گرفتن است .
باعث میشود که Tooltip در مختصات پیام آخرین ماوس ارسالی نمایش داده شود.
Causes the tooltip to display at the coordinates of the last mouse message
wParam
lParam
The return value is not used
SetCursorPos 300, 300
SendMessageA hWndtoolTip,TTM_POPUP, 0,0
Private Const WM_SETCURSOR=&H20
Parameters
wParam
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
LongInt2Int wParam, iHw, iLW
up-down message'
(UDM_SETRANGE=(&H400+101
(UDM_SETPOS=(&H400+103
(UDM_SETBUDDY=(&H400+105
up-down notification use in wm_notify'
(UDN_FIRST=(-721
(UDN_LAST=(-740
(UDN_DELTAPOS=(UDN_FIRST-1
up-down styles'
UDS_ALIGNRIGHT=&H4
UDS_ALIGNLEFT=&H8
UDS_AUTOBUDDY=&H10
UDS_ARROWKEYS=&H20
UDS_HORZ=&H40
UDS_NOTHOUSANDS=&H80
UDS_HOTTRACK=&H100
msctls_trackbar32 | Slider |
msctls_updown32 | Spinner |
msctls_statusbar32 | StatusBar |
Sets the buddy window for an up-down control.
wParam
Handle to the new buddy window.
lParam
The return value is the handle to the previous buddy window.
NM_UPDOWN
Type LPNMUPDOWN
hdr As NMHDR
iPos As Long
iDelta As Long
End Type
iPos
Type: int
Signed integer value that represents the up-down control's current position.
iDelta
Type: int
Signed integer value that represents the proposed change in the up-down control's position.
HWNDTOP
تمام مطالب ذکر شده برگرفته از اینترنت و داکیومنت آفیس است و تنها یک سوم آنها تست شده
.At startup, we add the tool but do not show the balloon tooltip yet
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,
(hDlg,""
the tooltip.
SendMessage g_hwndTrackingTT, TTM_TRACKACTIVATE,(WPARAM)FALSE,
(LPARAM)&g_toolItem),
presence of the tooltip causes Windows to send the message continuously
that the tooltip does not overlap the mouse pointer
,g_hwndTrackingTT,TTM_TRACKPOSITION,0
((LPARAM)MAKELONG(pt.x+10,pt.y-20
Case WM_CHAR
)Function UserInfoProc
(hUserInfoWnd,uMsg,wParam,lParam,uIdSubclass,dwRefData
(uMsg,wParam,lParam
if uMsg =WM_SETFOCUS) '?maybe
HideCaret hUserInfoWnd
The TEXTMETRIC structure contains basic information about a physical font. All sizes are specified in logical units; that is, they depend on the current mapping mode of the display context
typedef struct tagTEXTMETRICA { LONG tmHeight; LONG tmAscent; LONG tmDescent; LONG tmInternalLeading; LONG tmAveCharWidth; LONG tmExternalLeading; LONG tmMaxCharWidth;
LONG tmDigitizedAspectX; LONG tmWeight; LONG tmOverhang; LONG tmDigitizedAspectY; BYTE tmBreakChar; BYTE tmFirstChar; BYTE tmLastChar;
BYTE tmDefaultChar; BYTE tmItalic;
BYTE tmCharSet; BYTE tmUnderlined; BYTE tmStruckOut;
BYTE tmPitchAndFamily;
} TEXTMETRICA, *PTEXTMETRICA, *NPTEXTMETRICA, *LPTEXTMETRICA;