VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Trapping the GridColumnResize event (MSFlexGrid)

Bogdan Chernyachuk  (2 Submissions)   OLE/COM/DCOM/Active-X   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

The MSFlexGrid doesn't provide a ColumnResize event. However it's needed in some apps, where this grid is used. The code below shows how emulate the ColumnResize event by analizing the sequences of other windows messages.

Assumes
The knowlege of API is required. You must have MSflxgrd.ocx installed. Create a Form frmMain and place a MSFlexGrid control with name MSFlexGrid1 and a Module. The code is given below.

Side Effects
Don't ever finish the application with the Stop button of VB Environment. This will cause VBE to terminate. Application was tested under VB 5.0 (SP3)

API Declarations
' Function to retrieve the address of the current Message-Handling routine
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
' Function to define the address of the Message-Handling routine
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
' Function to execute a function residing at a specific memory address
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Windows messages constants
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_ERASEBKGND = &H14

Rate Trapping the GridColumnResize event (MSFlexGrid) (3(3 Vote))
Trapping the GridColumnResize event (MSFlexGrid).bas

Trapping the GridColumnResize event (MSFlexGrid) Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters