News:

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

Just a bitmap

Started by rodderswank, December 08, 2005, 05:12:12 PM

Previous topic - Next topic

rodderswank

Is there a way just to paint a bitmap to the screen and if anywhere on that bmp is clicked it exits. A pure bitmap button totally flat?

G`HOST

The simplest way to do it is,
1.         invoke LoadBitmap,hInstance,ADDR Bmp
            mov hwndBmp,eax
            invoke CreatePatternBrush,hwndBmp
            mov wc.hbrBackground,eax
2.        CreateWindowEx,....  With only WS_POPUP style set.
Here you are with only the bitmap showing.

Now by responding to :
WM_LBUTTONDBLCLK
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_MBUTTONDBLCLK
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_RBUTTONDBLCLK
WM_RBUTTONDOWN
WM_RBUTTONUP

you could do : say (WM_LBUTTONUP)
3. .if msg==WM_LBUTTONUP
       invoke SendMessage,hwnd,WM_DESTROY,0,0
;or
      ;invoke DestroyWindow,hwnd
    .endif

Hope you got the idea :thumbu

And yes set the window size in the CreateWindowEx to the size of the bitmap. :thumbu

rodderswank

aye i get that i just dont get how you would set that to the background of the button only. also the event wouldnt that count for anywhere within the program.

G`HOST

Here is an example,Done quickly though,just play around it and see what else you can do with it,and have a Win32.hlp around you. :U
Quote from: rodderswank on December 09, 2005, 05:09:50 AMalso the event wouldnt that count for anywhere within the program.
Didnt got you,What do you mean?it would be much help if you tell what exactly your are trying to do,

[attachment deleted by admin]

rodderswank

What im trying to do is get a borderless button such as just a bitmap when that is clicked something happens and the bitmap to not animate at at all just to be totally flat. I know how to do the bmp buttons after many trys im just trying to get rid of the silver border. So completely flat bmp buttton although i am unsure as to how to do it or whether it can be done. I've checked the masm examples because they rock but there dont seem to be any examples of this.

nice gfx by the way.

LL

Hi rodderswank,

I'm not sure I fully understand your question ? This is what I get: The mouse cursor is pressed over your drawn BMP button and, let's say, the window reacts by closing. If this is correct, I think it can be done if you find or isolate the borders of your drawn BMP button. Maybe something like this:

   CMP     D[EBP+12D],201h   ;201h = (Is it WM_LBUTTONDOWN ?)
   JNZ      >YY3      ;If not press, then continue !

   MOV     EBX,D[EBP+14h]   ;lParam (the x & y -coordinates of the cursor)
   MOV     EAX,EBX
   SHR      EAX,10h
   AND     EBX,0FFFFh
   CMP     EAX, ??      ;(Top line of drawn BMP button)
   JB        >NotInButtonArea
   CMP     EAX, ??      ;(Bottom line of drawn BMP button)
   JA       >NotInButtonArea
   CMP     EBX, ??      ;(Left side of drawn BMP button)
   JB       >NotInButtonArea
   CMP     EBX, ??      ;(Right side of drawn BMP button)
   JA       >NotInButtonArea

YY3: rest of your program...

I'm very new to programing under windows 32 bits enviroments. So you will have to work on this idea to make it  work on your program.

LL

rodderswank

Im just looking for a way to get rid of the grey border around a button with a bitmap drawn on to it. Also when the button is clicked and clicked again on the backgroud of the program its size is out of sync till another buttons pressed and the same for the next one being pressed. oO I'm just trying to somehow a totally flat button or events ploted to certain pixels of the screen for just a bitmap being displayed.

sheep

Use a static control, make it one that uses a bitmap image, set the image with STM_SETIMAGE, and subclass it to do whatever on WM_BUTTONDOWN.

rodderswank


G`HOST

Yoy dont even need the static control,Since you dont want any attributes of button other the the response to the mouse click.
just create a window with the bitmap like in my earliar example and just respond to different mouse messages.
Thats it. :U
Happy coding

hutch--

rodderswank,

I have tried to tell you that what you are after cannot be done with normal buttons with a bitmap loaded into them. The only method of having complete control is a custom control that uses 2 bitmaps for the up and down position. You either write one yourself or you use an existing one. The one in the masm32 library does exactly what you need so unless you want to write your own, that is what I recommend.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

The window idea from G'HOST should work fine. If you check the origin of the message (ie. the hWnd value passed to the window proc) then you can be sure the click originated from the 'button'.

hutch--

You do need to do a bit more than that or you get strange behaviour with some mouseclicks over the window. For example if you held the mouse button down, dragged it over the window then released it, it would register in the window. You need to use SetCapture with the window so you get the correct relationship with the mouse being clicked and released.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

Perhaps there may be a suitable button style which will create a flat button... is ownerdrawn what you are looking for?

That way you can just process WM_COMMAND clicks.

rodderswank

Im just looking for a way to get rid of the border around the buttons and the size focus when clicking between buttons.