| View previous topic :: View next topic |
| Author |
Message |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Mon Jul 11, 2005 2:51 am Post subject: Graphics on button element |
|
|
I seem to remember that this has been asked before (perhaps more than once) - but did anyone ever find a way to include a graphic on top of a button element? I would like to include a "dropdown arrow" (that indicates a menu will drop down when the button is pressed) on a button in my app.
I can use a BITBTN element, but for this a regular button will work better.
If anyone has an idea, thanks.
If it isn't possible, then would that be a possible new element for VDS somewhere down the line? Even better - a "split" button like a lot of applications have - the main part performs an action, while the dropdown portion gives a menu of choices.
_________________ Joe Floyd |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Jul 11, 2005 3:32 am Post subject: |
|
|
| jwfv wrote: |
...Even better - a "split" button like a lot of applications have - the main part performs an action, while the dropdown portion gives a menu of choices.
|
What you're referring to is actually a button from a windows toolbar. The
VDS BitBtn works similiar to a regular toolbar button, but I believe that the
BitBtn is a custom control or Delphis own implementation.
As for adding a graphic to a button, if you're using VDS 5 you can use the
windows API to change the style of a push button so that it displays an
icon or bitmap instead of text.
I don't have a sample for you right off hand. But you can also use the
VDSUG.DLL to change the buttons style and add an icon or bitmap image
to it. If you wish to refrain from using an external dll, look into the
following APIs::
| Code: |
GetWindowLong() - To get the buttons style bits
SetWindowLong() - To set the buttons style bits
And the following message::
BM_SETIMAGE
You will need to XOR together the value returned from GetWindowLong()
with the value of either BS_BITMAP or BS_ICON. Actually I think you can
ADD the value of BS_BITMAP or BS_ICON to the value returned from the
call to GetWindowLong().
Then call SetWindowLong() with the new value you've obtained in the
step above. The property that you'll be setting is the value of
GWL_STYLE. That is also the value you'll be querying with the call to
GetWindowLong().
|
Hope this explains a little. If not, just say so and I'll come up with a
snippett for you.
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Mon Jul 11, 2005 1:03 pm Post subject: |
|
|
Hey! Thanks for the tip -
If you get a chance, I would love an example of what you mean. I have used some API calls, but only after other people have done the coding of them. That is a little bit above my abilities.
Just to be clear, I will attach my existing button (using "...") and an example of what I would like to use.
Thanks for your help.
| Description: |
|
| Filesize: |
17.09 KB |
| Viewed: |
27485 Time(s) |

|
| Description: |
|
| Filesize: |
17.09 KB |
| Viewed: |
27485 Time(s) |

|
_________________ Joe Floyd |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Jul 11, 2005 1:21 pm Post subject: |
|
|
Hi Joe,
I should mention, that using these APIs you will not be able to have any
text on the button. The only way to have text and images is to have an
owner drawn button, which you do not have and cannot have since VDS
isn't capable of working on that level.
I don't mind coming up with the snippett. What you may need to do is to
use MSPaint or something to design a graphic for your button that also
includes the required text.
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Mon Jul 11, 2005 1:46 pm Post subject: |
|
|
That sounds fine - I have done that with some BITBTNs that I wanted a little more control over - and it worked well.
The basic Paint program works the best for that, as you noted.
_________________ Joe Floyd |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Jul 11, 2005 6:58 pm Post subject: |
|
|
Hi Joe,
Sorry it took so long. I got side tracked. I think this is what you want. As I
don't use VDS 5, I'm not sure if this works. But from what I can tell, it
should. If not, one of the VDS 5er around here can prolly fix it if need be.
| Code: |
REM Define some message constants
%%BM_SETIMAGE = 247
%%WM_GETICON = 127
REM Define some style constants
%%BS_BITMAP = 128
%%BS_ICON = 64
REM Define couple other API constants
%%IMAGE_ICON = 1
%%IMAGE_BITMAP = 0
%%GWL_STYLE = -16
%%LR_LOADFROMFILE = 16
dialog create,Button API Demo,-1,0,300,200,CLASS BTNAPIDEMOWND
dialog add,BUTTON,BUseIcon,10,10,70,25,Set Icon
dialog add,BUTTON,BUseBmp,40,10,70,25,Set Bmp
dialog add,BUTTON,B1,10,90,40,40
dialog show
%%b1 = @strdel(@winexists(~B1),1)
%%hwnd = @winexists(#BTNAPIDEMOWND)
loadlib user32.dll
REM Save this value for later use. We save this so that
REM we can change form using icons or bitmaps on the fly.
%%defStyle = @lib(user32.dll, GetWindowLongA, INT:, INT: %%b1, INT: %%GWL_STYLE)
:Evloop
wait event
goto @event()
:BUseIconBUTTON
%%icoFile = @filedlg("Icons (*.ico)|*.ico")
if @not(@null(%%icoFile))
REM Get the buttons style bits.
%%style = @lib(user32.dll, GetWindowLongA, INT:, INT: %%b1, INT: %%GWL_STYLE)
if @not(@equal(%%style, %%defStyle))
REM Must restore the original style bits.
%%res = @lib(user32.dll, SetWindowLongA, INT:, INT: %%b1, INT: %%GWL_STYLE, INT: %%defStyle)
%%style = %%defStyle
end
REM Add the BS_ICON style to %%style.
%%newStyle = @sum(%%style,%%BS_ICON)
REM Now apply the changes to the buttons style.
%%res = @lib(user32.dll, SetWindowLongA, INT:, INT: %%b1, INT: %%GWL_STYLE, INT: %%newStyle)
REM Load the image we selected.
%%icon = @lib(user32.dll, LoadImageA, INT:, NIL:0, STR:%%icoFile, INT:%%IMAGE_ICON, INT:32, INT:32, INT:%%LR_LOADFROMFILE)
REM Set the image to the button.
%z = @sendmsg(~B1,%%BM_SETIMAGE,%%IMAGE_ICON,%%icon)
end
goto Evloop
:BUseBmpBUTTON
%%bmpFile = @filedlg("Bitmaps (*.bmp)|*.bmp")
if @not(@null(%%bmpFile))
REM Get the buttons style bits.
%%style = @lib(user32.dll, GetWindowLongA, INT:, INT: %%b1, INT: %%GWL_STYLE)
if @not(@equal(%%style, %%defStyle))
REM Must restore the original style bits.
%%res = @lib(user32.dll, SetWindowLongA, INT:, INT: %%b1, INT: %%GWL_STYLE, INT: %%defStyle)
%%style = %%defStyle
end
REM Add the BS_BITMAP style to %%style.
%%newStyle = @sum(%%style,%%BS_BITMAP)
REM Now apply the changes to the buttons style.
%%res = @lib(user32.dll, SetWindowLongA, INT:, INT: %%b1, INT: %%GWL_STYLE, INT: %%newStyle)
REM Load the image we selected.
%%bitmap = @lib(user32.dll, LoadImageA, INT:, NIL:, STR:%%bmpFile, INT:%%IMAGE_BITMAP, INT:32, INT:32, INT:%%LR_LOADFROMFILE)
REM Set the image to the button.
%z = @sendmsg(~B1,%%BM_SETIMAGE,%%IMAGE_BITMAP,%%bitmap)
end
goto Evloop
:B1BUTTON
goto Evloop
:CLOSE
freelib user32.dll
exit
|
Hope this helps...
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Mon Jul 11, 2005 7:49 pm Post subject: |
|
|
Thanks Bill for sending that. I appreciate you putting together that nice example.
Doesn't seem to work for me, though. Nothing happens when I try either a bitmap or an icon.
I know it is a little hard for you to troubleshoot since you don't use VDS5. Any other API gurus out there that can point me in the right direction?
_________________ Joe Floyd |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Jul 11, 2005 7:54 pm Post subject: |
|
|
Try using the UNICODE versions of the API calls.
For example, change LoadImageA, to LoadImageW. Do that for all of the
API calls. I run Windows 98 SE, which doesn't handle much UNICODE stuff.
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Mon Jul 11, 2005 8:57 pm Post subject: |
|
|
I tried that. I just changed all the "A"s on the end of the calls to "W" (I guess that is what you meant.) It still didn't change anything, though.
_________________ Joe Floyd |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Jul 11, 2005 9:40 pm Post subject: |
|
|
I think I know the problem. Any Windows OS over Window 98 SE I believe
is an NT based OS. The LR_LOADFROMFILE flag for the LoadImage() API
is not supported by the NT OSs according to Microsoft.
Sorry Joe . That's all Microsofts doing.
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Mon Jul 11, 2005 9:54 pm Post subject: |
|
|
Argh.
Well, thanks for trying, Bill. Yep, I'm on Windows XP Pro.
If anyone reading this has an idea of any other approach, please let me know. Do I remember Jules mentioning that in VDS6, you would be able to put graphics on buttons?
I may have made that up, but it seems as if he did.
_________________ Joe Floyd |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Tue Jul 12, 2005 12:19 am Post subject: |
|
|
| slightly off-topic but I don't believe Windows Me is NT based. Either way it was probably the most buggiest out of all the versions of Windows.
|
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Tue Jul 12, 2005 12:22 am Post subject: |
|
|
I think you're right Prakash. I read something a while ago about that. I
wasn't sure if it was versions of Windows after 98 SE or ME, but prolly ME.
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Jul 12, 2005 2:23 am Post subject: |
|
|
Windows ME is most definitely not NT based. It's last of the 9x series of
their system. While it is buggy, it did implement some nice improvements
over 98SE. It's a shame that they tossed it together too quickly and left
the bugs in it.
You can get a stable ME system through the use of some tweaking
programs and some by hand tweaking.
-Garrett
|
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Tue Jul 12, 2005 5:37 am Post subject: |
|
|
| I'd have to say Windows XP is one of their most stable consumer operating systems by far. But if you have tried Windows 2003, it is absolutely VERY stable and runs well. I've had it running as a server for over 6 months now with millions of visitors a month, probably with 2-3 reboots at most, and those were scheduled windows update reboots.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|