The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: rodderswank on December 08, 2005, 05:12:12 PM

Title: Just a bitmap
Post by: rodderswank on December 08, 2005, 05:12:12 PM
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?
Title: Re: Just a bitmap
Post by: G`HOST on December 08, 2005, 07:23:11 PM
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
Title: Re: Just a bitmap
Post by: rodderswank on December 09, 2005, 05:09:50 AM
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.
Title: Re: Just a bitmap
Post by: G`HOST on December 09, 2005, 09:54:21 AM
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]
Title: Re: Just a bitmap
Post by: rodderswank on December 09, 2005, 10:04:19 AM
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.
Title: Re: Just a bitmap
Post by: LL on December 09, 2005, 12:17:44 PM
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
Title: Re: Just a bitmap
Post by: rodderswank on December 09, 2005, 03:43:53 PM
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.
Title: Re: Just a bitmap
Post by: sheep on December 10, 2005, 02:55:14 AM
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.
Title: Re: Just a bitmap
Post by: rodderswank on December 10, 2005, 01:19:29 PM
ill try that.
Title: Re: Just a bitmap
Post by: G`HOST on December 10, 2005, 06:46:59 PM
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
Title: Re: Just a bitmap
Post by: hutch-- on December 10, 2005, 11:40:16 PM
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.
Title: Re: Just a bitmap
Post by: zooba on December 11, 2005, 11:30:44 PM
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'.
Title: Re: Just a bitmap
Post by: hutch-- on December 11, 2005, 11:49:45 PM
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.
Title: Re: Just a bitmap
Post by: zooba on December 12, 2005, 02:30:32 AM
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.
Title: Re: Just a bitmap
Post by: rodderswank on December 12, 2005, 09:05:31 PM
Im just looking for a way to get rid of the border around the buttons and the size focus when clicking between buttons.
Title: Re: Just a bitmap
Post by: zooba on December 12, 2005, 10:36:30 PM
We know what you're trying to do, and we're discussing possibilities. If it's all way above your head perhaps you are being a little ambitious at the moment and would do well to attempt something simpler first.
Title: Re: Just a bitmap
Post by: hutch-- on December 13, 2005, 06:35:28 AM
rodderswank,

If you look in the masm32 example code in the latest version under exampl04 in the subdirectory, there is an example called bmpbutn that does exactly what you want. If you only want one bitmap just load the same one twice.
Title: Re: Just a bitmap
Post by: rodderswank on December 13, 2005, 03:42:12 PM
Ive just made a new project for testing and i keep getting bmpbutton undefined symbol.
Title: Re: Just a bitmap
Post by: G`HOST on December 13, 2005, 06:05:12 PM
Here is an another example of buttons+bmps,Hope it will help,
Its not mine work,But it is a good one.
dont remember where I Downloaded it from. :toothy

[attachment deleted by admin]