No announcement yet.

SuperClass Help needed

  • Filter
  • Time
  • Show
Clear All
new posts

  • Adrian Verkuil

    You answered your own question, the same prob exist if you want to skin
    a whole bunch off buttons on a form, and thanks Patrice this is indeed what I try to do.
    And I must say it's not to easy to not just use your code, damm what a nice skin

    Leave a comment:

  • Patrice Terrier
    I have to know how you figured that out.
    Because we spoke together on the phone for more than one hour :blah:


    Leave a comment:

  • Michael Mattias
    >He wants to perform Skinning of his application.

    I have to know how you figured that out. I simply cannot relate superclassing a button to skinning.

    Leave a comment:

  • Patrice Terrier

    He wants to perform Skinning of his application.

    And on that aspect DDT wouldn't facilitate anything, because it is build upon the CreateDialog API that already defines specific behaviors, made to insulate the programmer of the lowest CreateWindowEx API.

    The "WinLIFT Simplified API" does skinning of existing DDT applications with a single line of code, but this involves massive subclassing of the DDT controls. While going the SDK way there is no need to subclass the controls. And this will produce smaller and faster code, even if you have, of course, more source code to write.

    SDK means no BlackBox and the extra work can be beautiful:

    Last edited by Patrice Terrier; 8 Jun 2008, 08:45 AM. Reason: Added more comments

    Leave a comment:

  • Michael Mattias
    .... this week I dropped DDT, so learnng as fast as I can SDK now.
    While I am a long-time advocate for "everyone should at some point learn 'SDK-style' GUI programming" , there's no reason to 'drop' DDT. DDT is a tool to be used when desired; it can help you do a great number of things.

    Unfortunately your example gives not a hint of what you are trying to acccomplish here. It may just be 'tinkering to learn' - which is fine - but it will generally enhance the quality and quantities of responses to your questions here if you include the goals of your code.

    e.g, why would you want to superclass a button? That is, what behavior does the standard button control exhibit or not exhibit, to be suppressed, changed or added?

    In my case, it was because I wanted ALL my buttons on one screen to respond to <CarriageReturn> as though it were <SpaceBar> + <Tab>. Rather than subclass each control, I created a superclass which did this and used that button class rather than the standard "button" class.

    What is it you wish to accomplish?

    Leave a comment:

  • Patrice Terrier

    As a registered user of the José Roca's forum, you can study the examples i have posted there

    Try to use them in order from [SDK] 1 to 15

    Last edited by Patrice Terrier; 8 Jun 2008, 02:47 AM.

    Leave a comment:

  • Adrian Verkuil
    Thanks MM,

    Totally stuppid from me
    A button that gives back a button press to the same procedure will make no sense afterall! On my way again, just pushed to hard this week I dropped DDT, so learnng as fast as I can SDK now.

    Leave a comment:

  • Michael Mattias
    Buttons don't get WM_COMMAND, the window owning the button does.

    The WM_RBUTTONDOWN + WM_RBUTTONUP messages the button gets are translated into a WM_COMMAND sent to hDlg, but your program has no facility to do anything with it. (No "CALL procname" on any CONTROL ADD or DIALOG SHOW statements).

    When superclassing, never change the base class' cbWndExtra except by adding to it. Trust me, this is important; I had to learn this the hard way.

    With buttons, on Win/NT+, you get 'no control created' but on Win/9x resetting this to zero causes the entire system's GDI subsytem to go out of whack, affecting everything. That's one I will never forget.

    Leave a comment:

  • Adrian Verkuil
    started a topic SuperClass Help needed

    SuperClass Help needed

    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 ??

    #Compile Exe
    Option Explicit
    #Include ""
    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 _
        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
                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
    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 )