News:

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

Image button demo.

Started by hutch--, August 08, 2011, 01:40:36 AM

Previous topic - Next topic

dedndave

well - you include both up and down images in the resource
you could make the assumption that the pixel at 0,0 is the background colour
let the caller specify the offset distance (nXoffset, nYoffset)
then, create the second image from the first
that way, only one image per button would be needed in the resource
in this case, that would cut about 96 kb off the exe file size

you could get fancy and offer options like invert colours, etc

dedndave

you could offer other effects, too, like R, G, B shifts and XOR's

i suppose if you used 256-colour GIF or PNG, or better yet, ICO images, you wouldn't have to go through all that   :P
the files are much smaller, offer transparency, and for an icon-sized image, 256 is plenty

ToutEnMasm


Vortex

Same as ToutEnMasm. One blank window with no button. OS = Win XP SP3

dedndave

try this one guys
i took Hutch's "imgbtn2" file...
added InitCommonControls
removed a few start-up message boxes that were used in testing

ToutEnMasm


Vortex

Hi Dave,

Thanks, it works fine.

dedndave

i suspect it has something to do with which files are present in the WinSxS folder
there is a manifest, so it expects InitCommonControls with some SxS combinations and not with others
lately, i have been including InitCommonControls as a rule   :P
if i don't need it now, likely that i will later

ToutEnMasm

Quote
it expects InitCommonControls with some SxS combinations and not with others
lately, i have been including InitCommonControls as a rule   

It's a rule when use is made of the ressource with
Quote
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"

This init works also
Quote
      mov InitCtrls.dwSize,sizeof INITCOMMONCONTROLSEX
      mov InitCtrls.dwICC,0   ;remplacer 0 par un identifiant
      invoke InitCommonControlsEx,addr InitCtrls ;cumulatif

lingo

invoke InitCommonControls is slow.... :lol
Should be dd InitCommonControls
start:
    ;  invoke InitCommonControls

      mov hInstance,   rv(GetModuleHandle, NULL)
      mov CommandLine, rv(GetCommandLine)
      mov hIcon,       rv(LoadIcon,hInstance,500)
      mov hCursor,     rv(LoadCursor,NULL,IDC_ARROW)
      mov sWid,        rv(GetSystemMetrics,SM_CXSCREEN)
      mov sHgt,        rv(GetSystemMetrics,SM_CYSCREEN)
      call Main
      invoke ExitProcess,eax
      dd     InitCommonControls 

hutch--

It is pretty much the case that if you want a single image custom control, you would write it differently and it would peform something like a BS_BITMAP button but you cannot do the same things with a single bitmap control. The purpose of the test was to test RGB/Alpha bitmaps which accurately control transparency where the 8, 16 and 24 bit colour images cannot and generally have lousy edges with a notchy appearance.

RE: The use of the InitCommonControls() to initialise the common control library, I would like to see better documentation for the later OS versions and have some predictable method of knowing what works on what OS version. I started using the Ex version because it can initialise a larger number of common controls but from experience it behaves differently on different language Windows versions. Strangely enough the original example worked correctly on both my XP SP3 box and the Win7 64 bit box.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

Hutch,
for the sake of comparison, here is what i have in WinSxS...
6.0.0.0
6.0.2600.2180
6.0.2600.5512
6.0.2600.5705

i am probably missing one that you have   :P

lingo
does it really matter how many clock cylces InitCommonControls takes ?
the programs i write that call it come up plenty fast
it's not like i stick in a loop or anything   :lol

hutch--

Dave,

My WinSx has a mountain of stuff in it but nothing like you have mentioned, there are two entries for common controls that have 2 different versions of the DLL in them, could you elaborate some ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm


Test this one,I have rewite it and he use the InitCommonControlsEx to initialise

hutch--

Works OK here but no source.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php