Need an ImageButton

BlitzPlus Forums/BlitzPlus Programming/Need an ImageButton

JoshK(Posted 2005) [#1]
I have a problem. My distributor really wants my color picking interface to have an imagebutton with the currently selected color. I don't know if this is possible with B+. I cannot use a DirectX drawing surface, because it is likely that other DX applications will be run while this program is running.

Does anyone know how to modify a Blitz button so that it can display an image?


Arem(Posted 2005) [#2]
Use a toolbar.


Beaker(Posted 2005) [#3]
Use a panel with SetPanelColor().


Blaine(Posted 2005) [#4]
Well, I've got this, but we need some way to keep the panel on top of the button before it'll work...

Type colorbutton
Field button,panel
Field red,green,blue
End Type

Function CreateColorButton(x,y,w,h,parent,red=255,green=255,blue=255,style=0)
Repeat
n=n+1
s$=s+"  "
Until n=w/8
button=CreateButton(s+"| v",x,y,w,h,parent)
;Note that "style" won't do anything, it's just ther because it is in most functions.
SetGadgetLayout button,1,1,1,1
panel=CreatePanel(x+6,y+4,w-25,h-8,parent,1)
SetGadgetLayout panel,1,1,1,1
SetPanelColor panel,red,green,blue

c.colorbutton=New colorbutton
c\button=button
c\panel=panel
c\red=red
c\green=green
c\blue=blue
End Function


Unless I have the wrong idea of what you want... but anyhow, this is the type of thing you see in places like "Display Properties".


Arem(Posted 2005) [#5]
Woah dude. Use a combination of createimage and a toolbar gadget. It will save you a TON of code and work.


Blaine(Posted 2005) [#6]
Well, I MIGHT do that if it would look like the ones in the "Display Properties" window. Do you have any code for it that I could see?


Beaker(Posted 2005) [#7]
You can use panels as buttons. You don't need to put a button underneath. Panels return events when clicked. In Fontext I used them for colorchip buttons and for imagebuttons.


CS_TBL(Posted 2005) [#8]
I cannot use a DirectX drawing surface, because it is likely that other DX applications will be run while this program is running.

What's this DX issue when using canvasses anyway? I use that technique for nearly 1.5 year now, never had any issues, except going to DOS and return (images are garbled :) but that can be restored by calcing/loading the gfx again)..

Can you test this: http://quor-toth.balpol.tudelft.nl/~mvs/CS_TBL__newbutton_testapp.rar
and tell me if there's ugly stuff happening somehow, in combination with other DX apps?

Panels have the disadvantage that you need to preload them from disk, you can't animate gfx on a panel or reload new gfx to it..


Beaker(Posted 2005) [#9]
Panels have the disadvantage that you need to preload them from disk, you can't animate gfx on a panel or reload new gfx to it..

Yes you can, as long as you don't mind pulling them in from disk each time. You could even remove this (non) issue by MoleBoxing them


CS_TBL(Posted 2005) [#10]
Loading from disk, that's crap ... can't run anything from a CD then..

Anyway: what DX issues are there then, and does my exe work with or without problems? (I use canvases all the way)


Beaker(Posted 2005) [#11]
There shouldn't be any problems with DX as long as nothing is running fullscreen. Unless you know otherwise?


CS_TBL(Posted 2005) [#12]
With fullscreen, do you mean a window gadget @ full screenres (1280x1024 in my case), or the console output @ fullscreen..?


Beaker(Posted 2005) [#13]
Neither, I mean anything that goes into fullscreen mode (DX) using a Blitz style Graphics mode.

Example:
Graphics 800,600


CS_TBL(Posted 2005) [#14]
Yeah, that's what I meant with that output console.. ok, so during apps/games in a real window, there's no issue using canvases instead of panels..

btw, even if for some reason there would be a real image-button some day I still wouldn't use it. I had a bad experience with some small app I made 2 weeks ago; something related to updating a canvas after an ASyncKeyState keypress went wrong once a normal button was pressed while remaining focussed..


Arem(Posted 2005) [#15]
One word... TOOLFREAKINGBAR. USE A TOOLBAR!!!


Blaine(Posted 2005) [#16]
If you showed me some code, then MAYBE I would. But being so insistant isn't going to help you.


JoshK(Posted 2005) [#17]
The toolbar suggestion is good, but saving a temporary image to the harddrive and reloading it every time you change the color...that's crap.