The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Neil on October 08, 2011, 03:58:40 PM

Title: No Button?
Post by: Neil on October 08, 2011, 03:58:40 PM
I have a finished program written in console mode & last year started  a project to see how it would perform as a gui, I've completed the 'skeleton' outline all menus working OK etc. Part of the program requires 10 superclassed edit boxes that will only accept digits 0 to 9, this works OK so I've decided now to put cancel & OK buttons also on the main window. I looked at Iczelion's tutorials & decided that it was a good place to start. I used the following piece of code, much the same as in the tutorial except for the placement, but the button doesn't show, it assembles OK & ShowLastError says success, so why can't I see a button? Here's the code :-

            invoke CreateWindowEx, NULL, ADDR ButtonClassName,ADDR ButtonText,\
                        WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
                        325,400,140,25,hWnd,ButtonID,hInstance, NULL
            mov hwndButton,eax

Title: Re: No Button?
Post by: dedndave on October 08, 2011, 04:13:40 PM
button style flags
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775951%28v=VS.85%29.aspx

then, like most windows
        INVOKE  ShowWindow,eax,SW_SHOW
Title: Re: No Button?
Post by: jj2007 on October 08, 2011, 04:33:44 PM
Quote from: dedndave on October 08, 2011, 04:13:40 PM
        INVOKE  ShowWindow,eax,SW_SHOW
WS_VISIBLE should be enough.
Title: Re: No Button?
Post by: dedndave on October 08, 2011, 04:38:14 PM
Jochen's probably right - lol
wellllll
perhaps it is the position
how big is the parent window ?
Title: Re: No Button?
Post by: ToutEnMasm on October 08, 2011, 04:39:44 PM
Verify all your arguments,the value of the returned handle (if zero call getlasterror).
Last modifie the styles ,WS_CHILD can be responsible.

Title: Re: No Button?
Post by: dedndave on October 08, 2011, 04:54:26 PM
also, make sure ADDR ButtonClassName points to a string that says "Button",0   :bg
Title: Re: No Button?
Post by: Neil on October 08, 2011, 06:05:44 PM
Thanks for all your suggestions, I'll check them out tomorrow & report back the result
Title: Re: No Button?
Post by: Neil on October 09, 2011, 07:55:46 AM
Solved! Dave it was your last post that did it, when I checked in .data I'd missed the ,0 off the end of ButtonClassName db "button". It was as simple as that, but boy did it cause me some head scratching.
Title: Re: No Button?
Post by: dedndave on October 09, 2011, 01:52:40 PM
Yves' answer would have found it for you, as well
it was looking for a class that had not been registered
it would probably have returned 0, with GetLastError of ERROR_INVALID_PARAMETER (guessing - lol)