Solved

How to do a Hover button in PB?

Posted on 2001-08-29
36
2,122 Views
Last Modified: 2013-12-26
Just in the title! HOVER BUTTON!
0
Comment
Question by:DrVannacult
  • 16
  • 11
  • 5
  • +1
36 Comments
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
What do you mean in title HOVER BUTTON! Is it a Text or Control(button).
Can you explain please?
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello,

I just thought may you want to set a title text or icon on the title area.

If you want to set a text:

open your window and doubleclicked on the surface of the window. This action will open you he properties, just under title write your title.

If you want to set a icon:

open your window and doubleclicked on the surface of the window. This will open you a window properties dialog box. Click the Icon tabpage. Select the application! and click the commandbutton Browse... and select your own icon and then OK.

0
 

Author Comment

by:DrVannacult
Comment Utility
Sorry for my words. "HOVER BUTTON"
I meant the button that have a behavior like JavaScript button that handle event OnMouseOver() and OnMouseOut(), meant when mouse is over the button then the content of Button is changed (caption or picture).

That I means,
Thanks ur comments
drvannacult
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello,

Go to in any script (say clicked)  of the button and from menu Declare select the submanu "User Events..."
will open a dialogbox, write in the emply last row "ue_mousemove" and from buttom of the dialogbox Select Event ID, pbm_mousemove (doubleclicked here) will write the event ID. Clicked OK.


Now you have an Event "ue_mousemove" In run time when you will move your mouse on the button this script will run, write your actions here.


Try it and let me know how it is working.

0
 
LVL 3

Expert Comment

by:pbguy
Comment Utility
You'll probably want to use a "Picture Button" or even just a "Picture" as your control for this.  

I'm not sure that Bhatti's event will give you what you want for this (mousemove will only tell you when the mouse is moving over the control - it won't tell you when it enters or exist the area of the control -- you'll probably need to do a bit more coding and go with the "other" event and check x/y coordinates on the mouse using PointerX() and PointerY() vs the x/y coordinates of the control.  Seems like a cool little method to write ... ) Anyway, when you get the events figured out, then you can use the control's attributes and set the value when the appropriate time comes (attribute you'll probably use is PictureName.)

Hope this helps !
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello DrVannacult & pbguy,

This is only information. I don't want to intrupt but one thing is important to tell that the "Other" event is no longer useful, because you can define your own user events. You should avoid using it (it slows performance while it checks every Windows message).


THANKS
0
 

Author Comment

by:DrVannacult
Comment Utility
Thanks for all help,
I'll take sometimes to try it first and come back to this topic for a few days. (1 or 2)

Thanks experts,
drvannacult
0
 

Author Comment

by:DrVannacult
Comment Utility
hm, I've tried...

Using ue_mousemove to intercept pbm_mousemove message.
That pbguy's said is right! It'll acting on mousemoving time only I can't figure out how to detect if the mouse cursor is gone exit from the button's area.

I'll try the pbguy's comment that try to detect the mouse cursor's position in the another events, but I don't have idea which message is suit for this detection !?

Thanks all experts
Solution plz,
8)

drvannacult
0
 

Author Comment

by:DrVannacult
Comment Utility
Hi again experts,

I have some idea but don't know It'll works well or not. Pls comment, I'll try it all... 8)

1. I've posted in previous comment that I'll check on ue_mousemove and looking for another message(not "other" message that slowing app's performance) to insert the code that check the mouse co-ordinate If it out of button area.

2. I'll check on ue_mousemove If it over the button and insert the code to check if it out of button's area into w_main (windows object's name) 's ue_mousemove message. I thinks this case will works well. But I think that I'll make this button to be an User Object. So this will not work in the case of User Object, cause It must depending on window-object's ue_mousemove. Hmmmm....

3. I'll put the timer into the button, and check mouse over/out every time trigger event. But how can I set the timer into the button (User Object)? I can did it in VC++ but How can I did it in PB7.0?


ahhhh.....
PB funny world.
Thanks all experts,
waiting for every comments...
8)
drvannacult
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello DrVannacult,

If your button is on the window surface then you can also write in window's mousemove event the next text you want to give to your button(or old picture again).

Depending where you placed your button.

pbguy is on right track. PointerX() and PointerY() are the good function to know the mouse position. You can also check in window's mousemove event with these functions. (Or you can set text or picture in ue_mousemove event in button userobject and look in which control's surface you placed the button and when mouse leave the button and go to other surface say window's, then write in the mousemove event of window change the text of the button or picture.

Please let us know you want to change the text or picture and where you button is placed?

THANKS
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello, me again.

I think you want to see the time, when you move your mouse on the button. If you want to see only the current time or some special time, you need some other control not button)commandbutton or picturebutton).

User Event you can place almost in all controls. Please let us know, when you move you mouse the control(may button or other control) what action should happened. You want to see another text or time.

THANKS
0
 

Author Comment

by:DrVannacult
Comment Utility
Hi, Bhatti

I want to change the picture of the button when user move the mouse over the button, and then change back to original picture if the mouse is out of button area. I thinks that ur 2nd previous comment is also can works well. But I want to make it reusable like User Object (Or somethings like ActiveX, that I can use it for another project too) So 'cause this reason the window's mousemove event handler method will not work with my wanna it to be.

So u/someone have any ideas?

Thanks experts,
drvannacult
0
 

Author Comment

by:DrVannacult
Comment Utility
Hi again,

I just want to make the button independence from window's code. If it can, It'll be a reusable button.

8)

Thanks,
drvannacult
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello DrVannacult,

I spend a little time on weekend on Picturebutton, but I reached to the point it is better to make a pair of the userobject picturebutton and window. That mean if some one want to use this button in an other project, can use with this window. It is just normal way. I am not saying that it is impossible to create a such picturebutton object could be inharited in other projects. But I want to say the prformance of this button will be unprofessional. If we will use it with window (making a pair of the window and picturebutton userobject) can give us the professional results.

You can make an object (  visual standard ) picturebutton and declaring a user event mousemove and let the picture which you want to show when mousemove on it. and when mousemove in the window (leave the surface of the object) change the picture to the old one.

Now is question of the pictures when mousemove on the object and when on the window can be different in different projects. If they remain same then no problem.

Please let me know your opinion.
0
 

Author Comment

by:DrVannacult
Comment Utility
Hi Bhatti,

I feel ur later comments is very useful, But I thinks in most case I've to use different pictures. So I thinks to add a member variable of the button that stored the current picture's filename. Yup! Maybe It can works but I don't have any idea how to add the member variable into the Visual Object(The button we making). I'll work harder on this topic in these few days. And I'll reporting in the progress.

I thinks this topic will longer and longer, So I should increase the point of this question better. Happy all!

Did u have any idea?
Please let me know ur opinion/idea.

Thanks expert,
DrVannacult
8)
0
 

Author Comment

by:DrVannacult
Comment Utility
Did u have any ideas? pbguy!

8)
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello DrVannacult ,

I thought about this object(picturebutton object). We are not calling it but we want to adjust in diferent projects. We have a pair, picturebutton and window object, they work together. You know "tag propertiy", have a picturebutton object and also window object.

1. we can put the name of the  picture in the tag value without Path(only name e.g. picture1.bmp).
2. save   this picture in the current library(where your pbls are saved). So put the name of your .BMP file(only name e.g picture1.bmp) in the tag property of the object,


(IMPORTANT: Windows are different types as child window, responce window, main window etc. you should know in which window you need always).

When you start your program and open this window the picture button show the picture you wrote in the "wndow's tag prperty" and when you  moved mouse on the picturebutton the picturebutton will show the picture saved with name in the tag property of the object.

Whenever you put the picturebutton object and window, First change the tag properties of the both with the BMP file names you want to use here. the rest will be remain.

In the Window: open event read the tag propertiy and save the name in instance var. and in mousemove event of the window use the picturename property and set the picture to the object of the tag property text(which is the name of the picture).

In the picturebutton object tag property write the name of the BMP file. constructor event will read the tag property of the object and save the name of the file in the variable. In the ue_mousemove event tite the picturename property of the picturebutton.

PICTUREBUTTON:

constructor:

is_firstpic = THIS.tag

ue_mousemove:

THIS.picturename = is_firstpic


WINDOW:

open:

is_secondpic = THIS.Tag

mousemove:

uo_1.picturename = is_secondpic


You need to make a window having a object in it(picturebutton object.

You need only to change the tag porperties of the window and object.

IMPORTANT: In tag properties write the name of the file as "picture1.bmp" an you should have this BMP file in your current library(if not copy it or move it to your current Lib where your all pbls saved). this will help in future when you will make a run(EXE) file of your project.

If you need more explanation or any help please do ot hesitate, if I can or others will help you.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:DrVannacult
Comment Utility
Hi Bhatti,
Thanks much for ur comments.
I'll try it first...

8)
DrVannacult
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hello DrVannacult ,

Sorry I forgot to write that is_firstpic and is_secondpic are instance variables.

So in Shortcut:

Open a new object picturebutton.
Instace variable in pictureobject as is_varname1.
In tag property write the name of the bitmap file.
Write script as I mentioned obove for constructor and ue_mousemove events for the picturebutton object.
Save it.

Open a new window.
Instance variable in window as s_var2
In tag property name of the bitmapfile(Initial when mouse is not in the object(Picturebutton) boundry.
Write the script as above comment in open and mousemove events of the window.
Put picturebutton object ( just created) in the window.
Now Save the window (say   w_first).

TRY:

Craete a new window inherit from the the window       w_first .
Save it with some name   w_test.
Doubleclick on window and change the name of the bitmapfile in tag property.
Doubleclick on the object and change the bitmap filename in the tag property.
Save the window and run it.


Let me know please your oponion.


Bhatti

0
 
LVL 3

Expert Comment

by:pbguy
Comment Utility
Hi Doc and Bhatti,

Sorry for the delay in responding.  I have a working example for you that does exactly what you want it to do.  If you want it to be portable, no problem!  You can code it as a service ( but that's another subject for another day.)

BTW - I disagree slightly with Bhatti's "other" event statement - yes, the event will get hit alot once you add code but if you're smart with your implementation it shouldn't hurt performance much -- minor calculations won't be noticable.  i.e. notice in my code I only change the pic when I know the pic isn't the correct bitmap...

Also, for  "specialty" function like a hover button, you may want to consider an ActiveX control or an external object (PB supports 'em) -- it may be more appropriate but we can still getcha what you want right in Powerbuilder if you insist...

Heres what you need to do :

You will place your code in 2 places - in the picture object's mousemove event and in the window (or containing object's) "other" event.

Assume the picture control's name is p_1

-------------------------------
picture control's mousemove :


string ls_PictureOnName
string ls_PictureOffName

ls_PictureOnName      = "c:\onpic.bmp"
ls_PictureOffName = "c:\onff.bmp"
     
IF p_1.PictureName <> ls_PictureOnName THEN
     p_1.PictureName = ls_PictureOnName
END IF
         
-------------------------------
window's other event :

int li_PointerX, li_PointerY
int li_PictureX, li_PictureY
int li_PictureWidth, li_PictureHeight

string ls_PictureName
string ls_PictureOnName
string ls_PictureOffName

ls_PictureOnName      = "c:\onpic.bmp"
ls_PictureOffName = "c:\offpic.bmp"

li_PointerX      = PointerX()
li_PointerY = PointerY()
li_PictureX = p_1.x
li_PictureY = p_1.y
li_PictureWidth = p_1.width
li_PictureHeight = p_1.height

IF li_PointerX >= li_PictureX AND li_PointerX <= (li_PictureX + li_PictureWidth ) AND &
     li_PointerY >= li_PictureY AND li_PointerY <= (li_PictureY + li_PictureHeight ) THEN

     // Do Nothing
     
ELSE
         
     IF p_1.PictureName <> ls_PictureOffName THEN
          p_1.PictureName = ls_PictureOffName
     END IF

END IF


----------------------------
This code does exactly what you want.  The idea is let the picture control's mousemove handle turning the pic on , an the other event on the window handle turning it off.  It's pretty straight forward and the code is relatively short.  Try it!  

Read up on service based architecture and PB's PFD classes and they'll give you an idea on how to make it portable.  Hope this helps !



0
 

Author Comment

by:DrVannacult
Comment Utility
Thanks experts,
Plz let me sometimes to try the code u show.

I'll come...

thanks again,
drvannacult
0
 
LVL 3

Expert Comment

by:hink
Comment Utility
Hello

Your contribution are very large, but there is a very simple solution. You should to map PBM_DWNMOUSEMOVE user event instead of pbm_mousemove! You have DWO argument in that. In other hand, You can call "getobjectatpointer" and "getbandatpointer" function to get row and object there mouse pointer is on anywhere in datawindow.

With Regards
Jan Hink
0
 
LVL 3

Expert Comment

by:pbguy
Comment Utility
Hi hink,

I thought pbm_dwnmousemove is for datawindows only.  We're looking for something to handle a picture object (of course pbmdwnmousemove would be the choice if we were dealing with a pic inside a datawindow...)

Our pbm_mousemove gives us xpos and ypos as args, script should have referred to them but I got lazy.

If I misunderstood ya hink I'd love to see a working example, especially if the code is less large than mine!  

Thanks and good luck!
0
 
LVL 3

Expert Comment

by:hink
Comment Utility
Sorry, I supposed the problem is on DW button. On window button, I had such problem before. Picture buttons should write microhelp. I solved it using userobject inherited from picturebutton, that fired event to parent object (window) on ue_mousemove: parent.dynamic event(this).
0
 

Author Comment

by:DrVannacult
Comment Utility
Hi pbguy,

In ur sentences
"Read up on service based architecture and PB's PFD classes and they'll give you an idea on how to make
it portable.  Hope this helps !"

Can u tell me where can I learn more about service based architecture or PB's PFD classes, I can't find the service based architecture in the PB's help files (PB7.0) but I'm finding more info on net.

Wait for experts help,
drvannacult
0
 
LVL 3

Expert Comment

by:pbguy
Comment Utility
It's a biggie dr!  

(BTW I should have typed "PFC" instead of "PFD" )
I'm not sure of the breadth of help in PB's help files on the PFC - you'll need to go to some outside sources.

As for SBA, here is a quick synopsis and some links that may help :

The idea behind SBA is based on the inheritance model.  In the "old" way of developing PB objects, you create a huge set of ancestors with a huge mess of code that try to handle everything, then inherit from those ancestors and disable the parts you aren't using.  Your runtime objects end up bloated and slow, and typically with more than 50% of the functionality disable cuz it's not used in most places anyway -or- you end up with an insane number of base-class objects that you need to pick from (and make sure you pick the right ones...)  This model also creates many layers of inheritance, often creating gui inheritance chains based upon business rules which can be messy.

Service based architecture is based on the idea of a "service"  A service is a chunk of functionality (usually a nvo-non visual object) that can be "retrofitted" to another object.  Only when a service is requested (turned "on") is the code compiled and attached to the object. Powerbuilder's PFC is service based.  The SBA techniques tend to flatten inheritance chains, increase performance, stability, portability, blah blah blah...

Here are some places to get more info :

BUY THIS BOOK!  PowerBuilder 5: Object-Oriented Design and Development by William Green, Millard Brown (Paperback)    
This is a fantastic reference for this subject area.

http://www.woodger.ca/pfc_intr.htm

http://www.cpbug.org/conf/PFC%20Architecture%20Chi4/index.htm


Try these - you have lots of reading to do but it will be worth it!


0
 

Author Comment

by:DrVannacult
Comment Utility
Hi all,

I'm confusing about my PB's life,
How did u think that I want to spend more time to learn PB. Or better continue working on VB, VC and C++Builder?

My mine...
I come to PB cause I want to make my programming life easier, but If I want to spend more time to read a book before I can do a simple flat button. Ahhh....

Can someone guide me about where I should go now!
PB, VC, VB, C++Builder????????
I'm very confusing about these lang!
I love C++Builder but want more productivity. How I choose the proper language?

Thanks all experts,
I'm so confusing...
drvannacult
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
You must do what you can and what you like. We don't want to confuse but here write alls in  the way to help someone who needs.

PB is not not a difficult, but if you Know OOP OOD then PB is the best to do any easy to understand.

You Picture button is not a big topic it is a few minutes work. Just two lines can solve it. It is up to you which comments is best for your work. You need not to read a complete course of PB.

DrVannacult  I can help you to explain any problem in PB or related according to my knowledge with any points. My aim to help the others if I can and get a help from others if they can.

So need not to worry and come to PB and make your life easier. If I can to answer the question I will help you without any greediness.


You know the problems can be solved in different ways. This is everybody writing in his own way how he understands it. You should choose what is easy for you to undersand and few months then you can do most of userself.

Bhatti
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Sorry!
I wanted to write without any points. I shall help you without any points. If you any question that I can answer.
0
 

Author Comment

by:DrVannacult
Comment Utility
Thanks Bhatti,

I'm very happy to know u. 8)
I'll continue to make life easier with PB.
And I'll work with PB most of the time.
Hope everyone will help me.
How can I do with my 100 points? 8)

Thanks all experts,
DrVannacult
0
 

Author Comment

by:DrVannacult
Comment Utility
I feel very happy with my topic,
It's a large contribution!
I feel every PB experts is appreciate to help me.
Very very feel happy to continue with PB!

8)
DrVannacult
0
 
LVL 3

Accepted Solution

by:
pbguy earned 100 total points
Comment Utility
First of all, Powerbuilder is the best client/server development tool out there by far.  Once you learn the application and the techniques, you will be far more productive and effective than you would using any of the other packages.

I also agree with Bhatti dr -- if you understand OO then PB will come easily.  I'll take it a step further and say that if you want to learn OO, then Powerbuilder is a great place to start because you can ease yourself into it.

You do have to realize that if you want to be a GOOD PB programmer, you need to put your time in and read the books and learn the techniques - but this is true with any language or application.  My "learning" language was PASCAL.  If I tried to code PASCAL techniques in Powerbuilder, I would have a big mess. Learn the package-specific techniques and strengths and use them - you'll be better off.  Having said that, there is no reason you can't start now and learn as you go - just don't expect to be able to write portable/OO/efficient code right out of the gate.  You don't need SBA to code in PB, but it's the best way to do things and you should target the topic as a learning goal.

I suggest that you explore the "built in" functionality of PB before you embark on coding hover buttons.  Focus on what PB gives you for free before you try to make it do specialty stuff - you will become productive quickly.

Have fun!
0
 

Author Comment

by:DrVannacult
Comment Utility
Thanks pbguy,
DrVannacult
0
 

Author Comment

by:DrVannacult
Comment Utility
Hope everyone (PBs) will appreciate to help me in the future,

8)
DrVannacult
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now