News:

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

ButtonEx control

Started by CObject, August 19, 2005, 04:16:48 PM

Previous topic - Next topic

CObject

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]

lamer

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)

Faiseur

Hello,

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

Nice !


French asm Forum: http://www.asmforum.net/   Website: http://www.faiseur.net/

msmith

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

Jaclick


CObject

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]

Nordwind64

Works fine on XP and Vista. Nice work!

Best regards,
Nordwind64
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

feicong

 thands for share !
it's great!

Ghandi

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.

MichaelW

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
eschew obfuscation

Ghandi

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,

MichaelW


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    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.
eschew obfuscation

Ghandi

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



wahaha

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

low_coder

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.