The MASM Forum Archive 2004 to 2012

Specialised Projects => Custom Interface Components => Topic started by: CObject on August 19, 2005, 04:16:48 PM

Title: ButtonEx control
Post by: CObject on August 19, 2005, 04:16:48 PM
Hi All

I wrote a custom control Dll for my needs, and I decide to share it with you.
It is custom buttons called "ButtonEx", and works fine in RadASM IDE.

[attachment deleted by admin]
Title: Re: ButtonEx control
Post by: lamer on August 19, 2005, 07:44:29 PM
Nice! :U
One wish - let the button response to keyboard events (e.g. if the button has focus I expect it will generate "click" if I press spacebar)
Title: Re: ButtonEx control
Post by: Faiseur on August 29, 2005, 10:22:14 AM
Hello,

I added your "ButtonEx" in a project and that goes really well.

Nice !


Title: Re: ButtonEx control
Post by: msmith on January 15, 2006, 06:20:51 AM
This is a very nice control.

The only prolem I am having is setting a bitmap.


invoke SendMessage, hwnd,,BTNEXM_SETBITMAP,eax,eax


where eax is the handle to a bitmap

Note:

I have now tried it with a resource ID and it works.

Is there any way to make this work with bitmap handles?
Title: Re: ButtonEx control
Post by: Jaclick on August 15, 2007, 04:34:25 PM
What a beautiful ! great
Title: Re: ButtonEx control
Post by: CObject on September 05, 2008, 09:38:19 AM
Hi there !

Minor update to my ButtonEx control.
Added keyboard support. (e.g. you can use spacebar as a click event)



[attachment deleted by admin]
Title: Re: ButtonEx control
Post by: Nordwind64 on November 28, 2008, 06:56:13 PM
Works fine on XP and Vista. Nice work!

Best regards,
Nordwind64
Title: Re: ButtonEx control
Post by: feicong on June 26, 2009, 02:47:54 AM
 thands for share !
it's great!
Title: Re: ButtonEx control
Post by: Ghandi on July 10, 2009, 07:33:39 AM
I grabbed this and included it in a MASM test project. Looks nice, but one thing puzzles me... When it comes time to assemble, i got an error about "_WinMainCRTStartup@16" being an unresolved external reference. If i make a 'dummy' function named "WinMainCRTStartup", it gets rid of the error message but the exe wont run. Then i made another 'dummy' function named "WinMain" and wrapped my "main:" code with it.

This works, but its strange now because my exe has a VC++ entrypoint which calls my code!!!

I've tried several different versions of ML and Link, the results are the same.

Btw, this is using the code in my project, not a pre-compiled dll.
Title: Re: ButtonEx control
Post by: MichaelW on July 10, 2009, 10:35:12 PM
LINK : error LNK2001: unresolved external symbol _mainCRTStartup

While it's probably not the only way, failing to set the program start address will trigger this error. The typical method of setting the start address is to define a label at the intended entry point and specify this label as the optional address parameter for the END directive. Commonly:

start:
...
end start
Title: Re: ButtonEx control
Post by: Ghandi on July 12, 2009, 09:06:12 AM
Thank you Michael, but that isnt the problem. I've successfully written assembler programs before, it is something which i enjoy doing. Because of this i understand that there must be at least a [label - end label] for an ASM file to be assembled and linked.

The issue is that it is specifically asking for the WinMain/WinMainCRTStartup label as if it were a VC++ non-console program. I can resolve the unresolved symbol by making a dummy (skeleton) routine that has the correct name, but it was just a surprise to me that my ASM project would suddenly have the C++ stub appended and used as the entrypoint.

Now i find i can't replicate it, so im going to put it down to the project i included it into. The first dialog *test* app i made was the same, but i deleted the folder and now it does complain about WinMainCRTStartup but no boilerplate code for the entrypoint,
Title: Re: ButtonEx control
Post by: MichaelW on July 12, 2009, 09:19:37 AM

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end

The above assembles OK, but when the object module is linked as a console app the linker returns:

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : error LNK2001: unresolved external symbol _mainCRTStartup
nostart.exe : fatal error LNK1120: 1 unresolved externals

Changing the end directive to end start corrects the problem.
Title: Re: ButtonEx control
Post by: Ghandi on July 12, 2009, 11:18:53 AM
I must apologize, i didnt actually notice the 'end' at the bottom of the ButtonEx file. Because this ASM file is included via "include ButtonEx.asm", i don't actually need any end directive at the end, as the main body has its own:

start:

[code is here]

end start

I must admit, i like the effect of the XP style buttons, but they dont handle being disabled and enabled too well... Using EnableWindow on a button which has this style, it loses the XP look and reverts to a normal button. This spoils the effect somewhat and using a subsequent call to SendMessage to attempt setting the style again it fails. Likely im just not utilizing the code correctly though. I do like reverse engineering, but possibly a readme explaining the proper use could have been included?

This is going on the 'to do' list. I'll look at it more when i have some time up my sleeve.

HR,
Ghandi


Title: Re: ButtonEx control
Post by: wahaha on November 12, 2009, 02:31:57 PM
first,thank you very much for your share .
and there may be a  slip of the pen:

      .if wParam==BTNEXST_PRESSED_LEFTRIGHT                 ;;
         mov [eax].STRUCT_BUTTONEX.ptPressedOffset.x,1
         mov [eax].STRUCT_BUTTONEX.ptPressedOffset.y,1
      .elseif wParam==BTNEXST_PRESSED_LEFTRIGHT             ;;
         mov [eax].STRUCT_BUTTONEX.ptPressedOffset.x,0
         mov [eax].STRUCT_BUTTONEX.ptPressedOffset.y,2
      .endif
      
      .if lParam   
         invoke InvalidateRect,NULL,hWnd,TRUE                ;;
      .endif
Title: Re: ButtonEx control
Post by: low_coder on November 24, 2009, 12:52:48 PM
the control is very nice!
but there is a problem when enabling/disabling (invoke EnableWindow...) a buttonex control (your control)
it becomes non xp style and it becomes looking disabled the whole time even after enabling it.
Title: Re: ButtonEx control
Post by: CObject on November 27, 2009, 10:29:26 AM
Hi all

I'm mush busy at work, and have no time to fix problems about ButtonEx ctrl.

You are free to modify code. Just attach new versions here.

Thanks & Best Regard.