Hi Guys,
Working with a sample from Edwin, it works ok when I use it for a edit box.
But when I superclass a button I never get a %WM_COMMAND.
What do I overlook here ??
And I reed a lot about superclassing, but still dont get the cbWndExtra clear,
what are they used for, and do I need them when I dont use superclassing as a custom control but just for own proggie?
( I reed to much stuff last week about SDK, Subclass, SuperClass so maybe a bit mixed now
)
Working with a sample from Edwin, it works ok when I use it for a edit box.
But when I superclass a button I never get a %WM_COMMAND.
What do I overlook here ??
Code:
#Compile Exe Option Explicit #Include "win32api.inc" Function SC_RegisterClass( WC As wndClass, ByVal OldClassName As String ) As Long Dim OldWC As wndClass Dim pNewProc As Long If GetClassInfo( ByVal 0&, ByVal StrPtr( OldClassName ), OldWC ) = 0 Then Exit Function ' Don't change WC.cbClsExtra = OldWC.cbClsExtra WC.cbWndExtra = OldWC.cbWndExtra If RegisterClass(WC) = 0 Then Exit Function Function = OldWC.lpfnWndProc End Function '-------------------------------------------------------------------------------------------- Global OldwndProc As Long Function WinMain ( ByVal hCurInstance As Long, ByVal hPrevInstance As Long, ByVal lpszCmdLine As Asciiz Ptr, ByVal nCmdShow As Long ) As Long Dim hDlg As Long Dim szClassName As Asciiz * 80 Dim WC As wndClass ' Prepare the new windowclass struct szClassName = "Super" WC.lpszClassName = VarPtr( szClassName ) WC.lpfnWndProc = CodePtr(AvWinProc) WC.hInstance = hCurInstance WC.hCursor = LoadCursor ( %NULL, ByVal %IDC_IBEAM ) WC.hbrBackground = GetStockObject( %LTGRAY_BRUSH ) ' Lets register the new EDIT control. ''OldwndProc = SC_RegisterClass( WC, "EDIT" ) OldwndProc = SC_RegisterClass( WC, "BUTTON" ) If OldwndProc = 0 Then MsgBox "Could NOT register control!" Exit Function End If '------------------------------------------------------------------------------ Dialog New 0, "Superclassing example",,, 320, 320 _ , %WS_OVERLAPPED Or %WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_THICKFRAME Or %WS_CLIPSIBLINGS Or %WS_CLIPCHILDREN To hDlg If hDlg = 0 Then Exit Function 'Control Add "Super", hDlg, 100, "0123456789", 2, 2, 80, 14, %WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP, %WS_EX_CLIENTEDGE 'Control Add "Super", hDlg, 200, "0123456789", 2, 40, 80, 14, %WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP, %WS_EX_CLIENTEDGE Control Add "Super", hDlg, 100, "TestBut-01", 2, 02, 80, 20, %WS_CHILD OR %WS_VISIBLE OR %BS_PUSHBUTTON Dialog Show Modal hDlg Function = 1 End Function Function AvWinProc ( ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long ) As Long Select Case wMsg Case %WM_CREATE Case %WM_CHAR '// This is only written for example purposes. '// It is a simple piece of code to suppress the characters except numbers. Select Case Asc( UCase$( Chr$( wParam ) ) ) Case < 32 Case Asc( "0" ) To Asc( "9" ) Case Else Beep Exit Function End Select Case %WM_COMMAND msgbox "This is not fired ??" ' <<<--------------- Case %WM_CONTEXTMENU '// Prevent the context menu to popup. '// Now you can replace it for a custom one. msgbox "Right Mouse Used" Exit Function End Select Function = CallWindowProc( OldwndProc, hWnd, wMsg, wParam, lParam ) End Function
what are they used for, and do I need them when I dont use superclassing as a custom control but just for own proggie?
( I reed to much stuff last week about SDK, Subclass, SuperClass so maybe a bit mixed now

Comment