Author Topic: Disable toolbar button  (Read 5781 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Disable toolbar button
« on: March 25, 2004, 02:22:24 PM »
Anyone know how to disable a toolbar button?
Perhaps greyed out or the like?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Disable toolbar button
« Reply #1 on: March 25, 2004, 02:34:17 PM »
None that I can see. Although you could .....
1) change the bitmap image - SetBitmaps()
2) remove the macro associated with it. -  Macro()
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
Disable toolbar button
« Reply #2 on: March 25, 2004, 02:42:17 PM »
You could write a lisp that would change the names of all files containing a specific string, i.e. acad.mns to dis-acad.mns. That would disable it. Then, when you want to enable it, you could run a command that would strip off that prefix. Just thinking out loud. Would you have to reload the custom file if you did that? Of course, you could reload it programmatically too.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Disable toolbar button
« Reply #3 on: March 25, 2004, 03:00:00 PM »
I was looking more to having a toolbar with multiple buttons. Using this scenario...

User shows toolbar...
Toolbar has 4 buttons (or more perhaps)
Buttons 2 through 4 are disabled by default
User presses button 1, then button 2 through 4 are enabled..

For example...
Button 1 loads and executes a program
Button 2 program runs when the user needs it to using information from the program in button 1.

If button 1 has not been used, then disable button 2 until it has been used.

Understand?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
Disable toolbar button
« Reply #4 on: March 25, 2004, 03:06:25 PM »
Yeah. I thought that was what you meant. I guess I took the words "...or the like" to mean that you were open for any ideas that came to mind. My reseller had a project he was working on once. It went something along the lines of when you select a button, it would load another toolbar, thus enabling the rest of the buttons. I'm not sure how he did it, but he was working on making the toolbar close when the other toolbars were selected.

SMadsen

  • Guest
Disable toolbar button
« Reply #5 on: March 25, 2004, 03:07:04 PM »
As Mark said, just have btn 1 set the macros and bitmaps for btn 2 through 4

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Disable toolbar button
« Reply #6 on: March 25, 2004, 03:26:20 PM »
But it resets the mns settings so when you close AutoCAD the buttons are enabled when you restart....
I am looking into API .... I found a button structure and property.
TB_ENABLEBUTTON

.... now if I can find the correct syntax and order to make it happen.....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

t-bear

  • Guest
Disable toolbar button
« Reply #7 on: March 25, 2004, 04:16:25 PM »
This is interesting.....
what about button 1 that enables button 2 thru 4 then, if you re-click button 1, disables 2 thru 4?
Did that make sense?  Didn't think so......

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Disable toolbar button
« Reply #8 on: March 25, 2004, 04:33:25 PM »
Well that is almost exactly what I want...

Right now I have 3 buttons (will likely reach 5)
Button1 (start)
Button2 (pause)
Button3 (stop)

Press button1, button2 and button3 become active, button1 becomes inactive
Press button2, button1 remains inactive, button3 remains active
Press button3, button1 becomes active, button2 becomes inactive

At least that is what I want to happen....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hendie

  • Guest
Disable toolbar button
« Reply #9 on: March 26, 2004, 03:32:46 AM »
ehmn... maybe I'm miles off target here but, could you use a VBA form to mimic the toolbar ? it's much easier to enable/disable buttons in there.
I'm still on 2000 here (bummer) but in leter versions can't you switch between modal and non modal forms ?

daron

  • Guest
Disable toolbar button
« Reply #10 on: March 26, 2004, 08:20:27 AM »
Yes you can.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Disable toolbar button
« Reply #11 on: March 26, 2004, 01:26:24 PM »
I suppose you could use a modal dialog for the buttons then simply enable and/or disable them....

But....(you know there is always one)

You cannot dock a VBA form to the AutoCAD window....

At least I am not aware that you can....

Anyway, I played around with the Windows API SendCommand to see if I could manipulate them. I found that I could indeed change bitmaps, resize, enable and disable them. What I have to do is use several API calls but it is simple once you get the VBA functions figured out.

I am still having a bit of difficulty disabling a single button, I can disable and enable a whole toolbar but the way the ToolbarWindow32 class handles the buttons it is proving to be a bit more of a challenge than first thought.....

The key is retrieving the AutoCAD HWND then enumerating the child windows until you find the toolbar with the name that you are looking for, then you have to retrieve the button array so you can extract the button ID... this is where I am experiencing some difficulty...getting the appropriate API call to return the button array....

When I get this conquered, I will (should) be able to simple say....

Code: [Select]

ToolBarButtonEnable (ByVal ToolbarName As String, ByVal ButtonPosition As Integer, ByVal State As Boolean) As Boolean


Until I get there I will have to live with all of the buttons being enabled...

Incedently the main reason I want to do this is for a project I am working on... If the user selects certain buttons out of sequence it will cause a fatal error in AutoCAD....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

t-bear

  • Guest
Disable toolbar button
« Reply #12 on: March 26, 2004, 02:36:01 PM »
Quote
....If the user selects certain buttons out of sequence it will cause a fatal error in AutoCAD....


Sounds like I'd be restartin' acad a lot! Lysdexic figners...  Is there a LOGICAL reason for this or do you just got an attitude?  LOL

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Disable toolbar button
« Reply #13 on: March 26, 2004, 03:09:36 PM »
Quote from: t-bear
... Is there a LOGICAL reason for this or do you just got an attitude?  LOL


Well, I am working on a seamless integration of an MP3 player that fits on a toolbar and can be docked in the AutoCAD window (or not).

I found out that if I press the stop button accidentally and their was not a file playing, that AutoCAD would crash....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

t-bear

  • Guest
Disable toolbar button
« Reply #14 on: March 26, 2004, 04:03:56 PM »
Ahhhhhh...I thought the crash feature was intentional.  Turns out it's a programming glitch.  Well, if anyone can fix it you can.  You will share it, won't you?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Disable toolbar button
« Reply #15 on: March 26, 2004, 04:39:38 PM »
I'll share what I have now.... it is functional, but you will have to remember to not press the stop or pause button when a file is not playing.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie