A small wish...

Started by Elias Montoya, May 07, 2006, 02:13:47 PM

Previous topic - Next topic

Elias Montoya

Controls have special notification messages to catch, and also a CUSTOM
one to catch notifications that are not defined in the ctl file.

How about including a "notification" called Subclass, wich, if it has
code in it, the code gets added to the subclass procedure of the control?

It would get easier! :)

:)

Fred Harris

Elias,

    Would that catch keystrokes, for example?

Fred Harris

Elias Montoya

Yep. And not only keystrokes, but all of the other messages and
notifications, very helpful huh?. :)

Fred Harris

Elias,

    That sounds helpful.  A style I've fallen into is packaging the window
procedure parameters into a type and passing that type among all the event handlers (certainly, not original, I know).  Kind of like this:



Type ProgramData
 wParam As Dword
 lParam As Dword
 hWnd   As Dword
 hInst  As Dword
End Type

Sub OnCreate(dt As ProgramData)
 fp=FreeFile
 Open "Output.txt" For Output As #fp
 Print #fp, "Output.txt Opened In OnCreate() Which Processes %WM_CREATE Message."
 Print #fp, "dt.hInst  = "dt.hInst
 Print #fp, "Leaving OnCreate()"
End Sub

Sub OnPaint(dt As ProgramData)
 Local pszString As Asciiz Ptr
 Local lpPaint As PAINTSTRUCT
 Local strText As String
 Local hDC As Long

 hDC=BeginPaint(dt.hWnd,lpPaint)
 Call SetBkMode(hDC,%TRANSPARENT)
 strText="Hello, World!"
 pszString=StrPtr(strText)
 Call TextOut(hDC,0,0,@pszString,Len(strText))
 Call EndPaint(dt.hWnd,lpPaint)
End Sub

Sub OnDestroy(dt As ProgramData)
 Print #fp, "Output.txt Closed In OnDestroy() Processing %WM_DESTROY Message"
 Close #fp
 Call PostQuitMessage(0)
End Sub

Function WndProc(ByVal hWnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Long) Export As Long
 Local pCreateStruct As CREATESTRUCT Ptr
 Static dta As ProgramData

 Select Case wMsg
   Case %WM_CREATE
     pCreateStruct=lParam
     dta.hInst=@pCreateStruct.hInstance
     Call OnCreate(dta)
     WndProc = 0
     Exit Function
   Case %WM_PAINT
     dta.hWnd=hWnd
     Call OnPaint(dta)
     WndProc = 0
     Exit Function
   Case %WM_DESTROY
     Call OnDestroy(dta)
     WndProc=0
     Exit Function
 End Select

 WndProc=DefWindowProc(hWnd,wMsg,wParam,lParam)
End Function



    Couldn't you export a type like my ProgramData above?  If its getting intercepted in a edit class subclass, then the user would have the oportunity to 'eat' the message or not.

Fred Harris