If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Corel Paradox > Toolbar

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-03-06, 05:57
fepsy fepsy is offline
Registered User
 
Join Date: Jan 2004
Location: amsterdam
Posts: 31
Toolbar

I'd like to have a few buttons on the toolbar which resets the Working Dir to different aliases. Is it possible to have your own code under parameter 3 of AddButton? Is it possible to use your own Bitmap?
In the next example you only get the Working Dir Menu at once, which in itself is an improvement, but not really what I want.

method pushButton(var eventInfo Event)
var
tb Toolbar
endvar

if tb.create("Work Dir") then
tb.addButton(ToolbarMiscCluster, ToolbarButtonPush,
MenuFileWorkingDir, BitMapRemoveFromCat, "WD")

endif
endnethod
Reply With Quote
  #2 (permalink)  
Old 05-04-06, 15:56
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
To be honest I cannot remember fully, but am sure I've done this before.

If you assume in the example below your bitmap file is C:\tbar_icon.bmp then I believe you can use the following code:

var
tb Toolbar
endVar

if tb.create("Work dir") then
tb.addButton(ToolbarMiscCluster, ToolbarButtonPush, MenuFileWorkingDir,
readFromFile("C:\tbar_icon.bmp"), "WD")
endIf
Reply With Quote
  #3 (permalink)  
Old 05-05-06, 09:18
fepsy fepsy is offline
Registered User
 
Join Date: Jan 2004
Location: amsterdam
Posts: 31
toolbar

Thank you for the reply. HOwever, it does not work, I get a Parameter Mismatch.

ReadFromFile is a logical, the routine needs a graphic.
Reply With Quote
  #4 (permalink)  
Old 05-06-06, 15:58
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
Ok, it was almost good, try the following as an example

Code:
var
  tbHandle   Toolbar
  grHandle   Graphic
endVar

grHandle.readFromFile("C:\tbar_icon.bmp")

if tbHandle.create("Work dir") then
  tbHandle.addButton(ToolbarMiscCluster, ToolbarButtonPush,
                                 MenuFileWorkingDir, grHandle, "WD")
endIf
What this will do is load the bmp into a graphic variable and then use the graphic variable in your addbutton statement to declare the image you want in your toolbar.
Reply With Quote
  #5 (permalink)  
Old 05-07-06, 04:48
fepsy fepsy is offline
Registered User
 
Join Date: Jan 2004
Location: amsterdam
Posts: 31
programming the toolbar

Yes!

that works, thanks, are you in for the first part of my question, putting your own code into this?
Reply With Quote
  #6 (permalink)  
Old 05-08-06, 17:44
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
No i haven't put my own code against this button but you can easily do this.

The toolbar button event triggers a menuAction event using an id number, if in the menuAction event for the form you trap when this id is sent in you can call your custom method to execute.

The following is an example:

In the forms open method the following code exists:

Code:
method open(var eventInfo Event)

  if eventInfo.isPreFilter() then
    ;// This code executes for each object on the form
		
  else
    ;// This code executes only for the form

    tb.create("Test")
    tb.addButton(ToolbarMiscCluster, ToolbarButtonPush,
            UserMenu + 1, BitmapAddTable, "Custom")
    tb.show()
		
  endIf

endMethod
Within the form I have a custom method called showMyMessage which contains the following code:

Code:
method showMyMessage()

  msgInfo("showMyMessage",
    "This is a custom method called from a toolbar button")

endMethod
Within the menuAction method I trap the code and execute my own method/code as follows:

Code:
method menuAction(var eventInfo MenuEvent)
  var
    siEvent    SmallInt
  endVar

  siEvent = eventInfo.id()  ; Get the Event ID into a variable

  if eventInfo.isPreFilter() then
    ;// This code executes for each object on the form

  else
    ;// This code executes only for the form

    ; Menu/Toolbar Event Custom Processing
    switch
        case siEvent = UserMenu + 1 :
          showMyMessage()

        otherWise :
          doDefault

      endSwitch
		
  endIf

endMethod
If you want to add more custom methods to a toolbar then the trick is where you stated MenuWorkingDir you replace this with a constant value, for custom events this should always be UserMenu + <your number> and then trap for this value in the menuAction method of the form.

Hope this helps

Regards,
Jonathan
Reply With Quote
  #7 (permalink)  
Old 05-09-06, 08:05
fepsy fepsy is offline
Registered User
 
Join Date: Jan 2004
Location: amsterdam
Posts: 31
programming the toolbar

Yes! this works wonderfully. You did a great job.
Now I can avoid all those annoying mouse clicks .
Willem
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On