News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Superclassing problem

Started by Neil, February 06, 2010, 04:02:05 PM

Previous topic - Next topic

Neil

I've been playing around with subclassing & have had no problems with the code or the filter in EditWndProc which only accepts decimal digits, that piece of code is below :-

       .ELSEIF ax==1310

          mov icount,0
          invoke CreateWindowEx,NULL, ADDR ButtonClassName,ADDR ButtonText,\
                        WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
                        75,70,140,25,hWnd,ButtonID,hInstance,NULL
          mov  hwndButton,eax
          invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR EditClass,NULL,\
            WS_CHILD+WS_VISIBLE+WS_BORDER,380,\
            300,25,25,hWnd,NULL,hInstance,NULL
          mov hwndEdit,eax
          invoke SetFocus,eax
          invoke SetWindowLong,hwndEdit,GWL_WNDPROC,addr EditWndProc
          mov OldWndProc,eax
          invoke DefWindowProc,hWnd,uMsg,wParam,lParam
          ret

But when I tried to superclass 10 edit boxes using the same filter the edit boxes don't display, there is no error assmbling & If I uncomment the MessageBox that dislays OK so I know it's getting to the correct menu item. Can anyone see whats wrong :( Code below :-

         .ELSEIF ax==1200

      mov wc.cbSize,sizeof WNDCLASSEX
      invoke GetClassInfoEx,NULL,addr EditClass,addr wc
      push wc.lpfnWndProc
      pop OldWndProc
      mov wc.lpfnWndProc, OFFSET EditWndProc
      push hInstance
      pop wc.hInstance
      mov wc.lpszClassName,OFFSET OurClass
      invoke RegisterClassEx, addr wc
      xor ebx,ebx
      mov edi,20
      .while ebx<11
         invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR OurClass,NULL,\
                 WS_CHILD or WS_VISIBLE or WS_BORDER,20,75,edi,25,hWnd,NULL,\
                hInstance,NULL
         mov dword ptr [hwndEdit+4*ebx],eax
         add edi,25
         inc ebx
      .endw
      invoke SetFocus,hwndEdit

            ;invoke MessageBox,hWnd,NULL,ADDR szDisplayName,MB_OK 

donkey

An error message would be useful, if you could give us the error message or code it would make it a lot easier than building a skeleton and plugging in your code.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Tight_Coder_Ex

I agree with Edgar, where is the error occuring.  There are two possibilities and either the window is not being created at all, or there is a problem in the handler.

I don't believe it's necessary to create a new class.

1.  Create the control
2. SetWindowLong, NewControl, GWL_WNDPROC, Your_Handler

After that, all controls of that class EDIT, BUTTON, STATIC or whatever will respond to your handler

hutch--

Neil,

The trick is to get the first control and subclass working properly then use the same SetWindowLong() for the handle of each additional control.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

donkey

Actually I agree with Neil, with 11 controls or so he's better off superclassing them, his code seems to do the creation based on a button being pressed or something so they are dynamically created and probably destroyed. A superclass makes sense in this situation especially because he is changing a particular behaviour of the control.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Neil

Thanks for your comments, this is a 'TEST' piece written so that I can learn all the ins & outs of writing a GUI.
Back to the problem, the edit boxes should display when a menu item is clicked - they don't & there is no error message & as I said if the message box is uncommented that displays correctly, so I'm a bit baffled :dazzled:

jj2007

There will be no error message unless you display one. Instead of your message box, you might use MsgBox 0, LastError$(), "Test", MB_OK.

Neil

Tried that JJ & there is no error message. It's as if the edit boxes are being displayed & then immediately destroyed before I have time to see them?

jj2007

What do you mean by "no error messsage"? No error or no message? The problem could be solved in no time if you simply posted your complete code...

Neil

JJ yes the message box displays & says that "The application completed successfully". I'm still playing with it at the moment, if I can't get anywhere I'll post the source.

jj2007

What happens if you comment mov wc.lpfnWndProc, OFFSET EditWndProc ?

Neil

I get 1 long edit box which accepts only decimal digits, EDIT my mistake it accepts all characters

Neil

The 1 long Edit Box could be 10 edit boxes side by side, maybe I haven't left enough space in between.

Neil

No, it is one long Edit Box. It doesn't get focus as the message box displays as well, or is that normal behaviour?

jj2007

WS_BORDER,20,75,edi,25,

You have ten boxes, but the last one covers all previous ones.