June 16, 2024, 09:04:58 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Right click on a button in a browser program

Started by Andy, May 20, 2012, 12:44:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

I was just adding a few functions to my browser project, thought it would be nice to have some favorite sites added to the url window as buttons. I've done this, but I cannot get a right click context menu for the buttons in the browser program.

I can do this no problem in a "normal" program but not when I have the Attachbrowser command.

Basically I would like a context menu for the button "Test" (in the browser_test2 program) to give
"Edit this favorite"
"Delete this favorite"

Can this be done?

I already have context menus for the history screens in the browser.

Also, when I create a button, what command will let me re-size it and make it borderless? i.e. no box

Sorry to ask yet another question but i'm going cross eyed searching the answers.

Thanks,
Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

aurelCB

I don't get it why you use ctl.inc anyway and OOP aproach...
for speed or something else ???

Andy

ctl.inc was the way I was shown for a right click context menu.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Very interesting!

1st-  that you are using a function that was apparently designed for a LISTBOX on a button.
But it works so I suspect it is nothing more than a routine that sub-classes a control.

Anyway.  You were on the right track You had placed the conLBRightClick command inside the browsehandler() handler.
That would allow the conLBRightClick command to be executed multiple times which would cause problems.

I moved the conLBRightClick command to immediately after the buttons creation so it is only executed once each time the program is run.
And it worked for me.
Correction is attached.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

I failed to respond to this:
QuoteAlso, when I create a button, what command will let me re-size it and make it borderless? i.e. no box
To resize a control, after it is created, you use the RESIZE command

when you say:
Quoteborderless? i.e. no box
I'm assuming you mean you want it to look like static text.
If that is indeed correct, then create a @STATIC control instead of a @BUTTON control
and the line should look like this in the browser program
CONTROL (.urldlg,@static,"Test1",2,38,150,22,SS_NOTIFY|1,BUTTON_2)
The SS_NOTIFY style flag will cause the necessary messages to be generated so the right click works.
The '1' style flag will cause the text to be centered in its rectangle.  That way if you resize the control the text will remain centered.
You'll need this also;
CONST SS_NOTIFY = 0x100
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Larry,

I didn't know the function was intended for a listbox, so when I add in your suggestion it stops the listbox context menus from working - so I cannot use the above as a solution.

I found an example by Sapero (attached) which is almost perfect but - it's not exactly.

The example is a dialog box - I need it in a window
The example is in a sub routine - don't want it in a sub routine, just a simple openwindow then waituntil=0.
Also need to know which button was right clicked on.

Trying as we speak to work it out.

Thanks as always for your help.
Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Okay, I modified Sapero's code so it is a window instead of a dialog.

Since superclassing of the button does it to all buttons I added code to make it work on the 1st and 3rd but not the middle one.
It is currently set up to use the same context menu for both buttons
By creating an additional gmenu2 you could have it so the different buttons call different context menus
For sharing a menu I've added code to tell which button fired the menu so that both buttons don't have to do the exact same thing.

I also added the skeleton for @IDPAINT in the super-class in case you want to draw the buttons differently.
But remember, it will draw them all differently.

You could subclass each button separately and draw them individually to change therir looks.  You can also use rgnbuttons.

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Quote from: andy1966 on May 20, 2012, 11:54:28 PM
I didn't know the function was intended for a listbox, so when I add in your suggestion it stops the listbox context menus from working - so I cannot use the above as a solution.

the conLBRightClick command takes a window and a control id as parameters so that makes me think it should impact only that control.
Therefor I think when you use it on a button control that it should have no impact on any other control unless you've duplicate a control ID.

But we don't have the source code for ctl so we'll never know for sure.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Hi Larry,

Thanks as always for the help you have given, spent most of yesterday checking for duplicate controls but could not find any, maybe the problem is in the ctl?

Anyway, decided to change the buttons to static (your suggestion) and it looks tidy and professional - thanks!

The code examples for right clicking on a button will come to good use, and hope the code will help others!

Maybe IW3 could have a right click on a button / listbox built in - easy to say, but maybe difficult to code.

Thanks as always,  :)
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.