HPEN CreatePen( int iStyle, int cWidth, COLORREF color );
()Edit::OnNcPaint
pDC=GetDC( ) ? GetWindowDC
GetWindowRect Edithwnd,Crect
OffsetRect Crect,-rect.left,-rect.top
'Draw a single line around the outside
(brush=RGB( 255, 0, 0
FrameRect pDC,Crect,brush ReleaseDC hwnd,pDC
Const PS_SOLID = 0
Const PS_DASH = 1
Const PS_DOT = 2
Const PS_DASHDOT = 3
Const PS_DASHDOTDOT = 4
Const PS_NULL = 5
Const PS_INSIDEFRAME = 6
((hPen=CreatePen(PS_DASH,0,RGB(0,255, 0
(hOldPen=SelectObject(hDC,hPen
Ellipse hDC, 100, 150, 350, 300
SelectObject hDC, hOldPen
DeleteObject hPen
مورد زیر طبق شکل تست شده
حتما در WndProc در پیام SHOWWINDOW تابع زیر اعمال گردد
SetWindowPos hwnd,0,0,0,0,0,SWP_FRAMECHANGED
ساب کلاس کردن کنترل Edit
Public Function SubClassEdit(ByVal hwnd As LongPtr, ByVal Msg As Long, ByVal wParam As LongPtr, _
ByVal lParam As LongPtr, ByVal uId As LongPtr, ByVal dwData As LongPtr) As Long
Dim nccsp As NCCALCSIZE_PARAMS
Select Case Msg
Case WM_NCPAINT
(hdc = GetDC(hwnd
Dim rClient As RECT
GetClientRect hwnd, rClient
( hpen = CreatePen(ps_solid, 2, vbRed
( holdpen = SelectObject(hdc, hpen
RoundRect hdc, rClient.Left - 2, rClient.Top - 2, rClient.right + 2, rClient.bottom + 2, 6, 6
ReleaseDC hwnd, hdc
DeleteObject holdpen
Case WM_DESTROY
RemoveWindowSubclass hwnd, SubClassEdit, 0
End Select
(SubClassEdit = DefSubclassProc(hwnd, Msg, wParam, ByVal lParam
End Function
SWP_FRAMECHANGED 0x0020
Applies new frame styles set using the SetWindowLongfunction. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZEis sent only when the window's size
.is being changed