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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#Compile Exe
#Include "Win32api.inc"
#Include Once "Atl.inc"
#Include Once "MSFlexGrid.inc"
%ID_CONTAINER = 1250
Global oEvents As DMSFlexGridEvents
Type WndEventArgs
wParam As Long
lParam As Long
hWnd As Dword
hInst As Dword
End Type
Class Class_DMSFlexGridEvents $CLSID_Event_DMSFlexGridEvents As Event
Interface DMSFlexGridEvents $IID_DMSFlexGridEvents : Inherit IDispatch
Method KeyDown <-602> (ByRef KeyCode As Integer, ByRef PB_Shift As Integer)
MsgBox("You Pressed Some Key!")
End Method
Method DblClick <-601> ()
MsgBox("You Double Clicked Somewhere In The Grid!")
End Method
End Interface
End Class
Sub GridSetup(Byval oGrid As IMSFlexGrid)
Local vCols As Variant,vRows As Variant
Local vVnt As Variant,vText As Variant
Local vCol As Variant,vRow As Variant
Local Grid As Dispatch
Grid=oGrid
vCols=4 : Object Let Grid.Cols=vCols
vRows=20 : Object Let Grid.Rows=vRows
vVnt=200:vCol=0 : Object Let Grid.ColWidth(vCol)=vVnt
vVnt="Times New Roman" : Object Let Grid.FontName = vVnt
vVnt=10 : Object Let Grid.FontSize=vVnt
vCol=1:vVnt=1200:vRow=0: : Object Let Grid.ColWidth(vCol)=vVnt
Object Let Grid.Col=vCol : Object Let Grid.Row=vRow
vText="Column 1" : Object Let Grid.Text=vText
vCol=2:vRow=0:vVnt=1200 : Object Let Grid.ColWidth(vCol)=vVnt
Object Let Grid.Col=vCol : Object Let Grid.Row=vRow
vText="Column 2" : Object Let Grid.Text=vText
vCol=3:vRow=0:vVnt=1200 : Object Let Grid.ColWidth(vCol)=vVnt
Object Let Grid.Col=vCol : Object Let Grid.Row=vRow
vText="Column 3" : Object Let Grid.Text=vText
End Sub
Function fnWndProc_OnCreate(Wea As WndEventArgs) As Long
Local lpCreateStruct As CREATESTRUCT Ptr
Local pStream,ppUnkContainer As IUnknown
Local hContainer,hCtrl As Dword
Local oGrid As IMSFlexGrid
Local strCtrl As String
lpCreateStruct=Wea.lParam
[email protected]
Call AtlAxWinInit()
hContainer=CreateWindowEx _
( _
%WS_EX_OVERLAPPEDWINDOW,"static","",%WS_CHILD OR %WS_VISIBLE,10,10,280,250,Wea.hWnd,%ID_CONTAINER,Wea.hInst,Byval %NULL _
)
strCtrl=UCode$("MSFlexGridLib.MSFlexGrid") 'Program ID
hCtrl=AtlAxCreateControl(Strptr(strCtrl),hContainer,pStream,ppUnkContainer)
oEvents=Class "Class_DMSFlexGridEvents"
oGrid=AtlAxGetDispatch(hContainer)
If IsObject(oGrid) Then
Events From oGrid Call oEvents
Call GridSetup(oGrid)
End If
fnWndProc_OnCreate=0
End Function
Function fnWndProc_OnDestroy(Wea As WndEventArgs) As Long
Events End oEvents
Call PostQuitMessage(0)
fnWndProc_OnDestroy=0
End Function
Function fnWndProc(ByVal hWnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Long) As Long
Local Wea As WndEventArgs
Select Case As Long wMsg
Case %WM_CREATE
Wea.hWnd=hWnd : Wea.wParam=wParam : Wea.lParam=lParam
fnWndProc=fnWndProc_OnCreate(Wea)
Exit Function
Case %WM_DESTROY
Call PostQuitMessage(0)
fnWndProc=fnWndProc_OnDestroy(Wea)
Exit Function
End Select
fnWndProc=DefWindowProc(hWnd,wMsg,wParam,lParam)
End Function
Function WinMain(ByVal hIns As Long,ByVal hPrev As Long,ByVal lpCL As Asciiz Ptr,ByVal iShow As Long) As Long
Local winclass As WndClassEx
Local szAppName As Asciiz*16
Local Msg As tagMsg
Local hWnd As Dword
szAppName="OCX Test" : winclass.cbSize=SizeOf(winclass)
winclass.style=%CS_HREDRAW Or %CS_VREDRAW : winclass.lpfnWndProc=CodePtr(fnWndProc)
winclass.cbClsExtra=0 : winclass.cbWndExtra=0
winclass.hInstance=hIns : winclass.hIcon=LoadIcon(%NULL,ByVal %IDI_APPLICATION)
winclass.hCursor=LoadCursor(%NULL, ByVal %IDC_ARROW) : winclass.hbrBackground=%COLOR_BTNFACE+1
winclass.lpszMenuName=%NULL : winclass.lpszClassName=VarPtr(szAppName)
Call RegisterClassEx(winclass)
hWnd=CreateWindow(szAppName,"Try MSFlexGrid",%WS_OVERLAPPEDWINDOW Xor %WS_MAXIMIZEBOX,200,100,300,300,0,0,hIns,ByVal 0)
Call ShowWindow(hWnd,iShow)
While GetMessage(Msg,%NULL,0,0)
TranslateMessage Msg
DispatchMessage Msg
Wend
Function=msg.wParam
End Function
|