Author Topic: Depressed toolbar buttons  (Read 3556 times)

0 Members and 1 Guest are viewing this topic.

bman

  • Guest
Depressed toolbar buttons
« on: July 26, 2005, 09:01:13 AM »
Is there a simple way to create on a toolbar that will depress the toolbar button to activate a setting & keep it depressed/activated until clicked again to unactivate/undepress the command?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Depressed toolbar buttons
« Reply #1 on: July 26, 2005, 09:23:00 AM »
not sure I understand your question ... but let me take a stab in the dark ...

You want to have a toolbar button that when you click it stays in a pressed state until you press it again ...

Sounds like an API function to me ... doable, but certainly not a simple task.
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

bman

  • Guest
Depressed toolbar buttons
« Reply #2 on: July 26, 2005, 09:42:47 AM »
that's correct....kind of like a toggle only using toolbars. where might I find info on an API function?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Depressed toolbar buttons
« Reply #3 on: July 26, 2005, 11:27:01 AM »
It is not that simple .... You can use something like this in VBA, VB, or C++ ..

What you would need to do is:
a) intercept the OnClick event of the toolbar button
b) use the API SendMessage to send the command to the button to make it show as depressed or not depending upon the current state

You would need to find the window being clicked, you can do it by using the EnumChildWindows API to grab the handle of the window you want to watch, then you would watch all of the messages being sent by the window to the program, then when a WM_CLICKED message is detected, use SendMessage to set the state of the button to a down state or up state.

This IS NOT something that you just decide to do ... particularly if you have no experience with API calls, VBA, or C++.
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
Depressed toolbar buttons
« Reply #4 on: July 26, 2005, 11:33:57 AM »
Would this be something that didn't need the visual? In other words, could the proggy behind the button be something that is nothing more than a binary switch? Ex. I once wrote a function that would turn mbutton pan to 0 or 1 opposing its current state and built a tool button for it.

bman

  • Guest
Depressed toolbar buttons
« Reply #5 on: July 26, 2005, 12:05:14 PM »
The visual isn't that important...if I could click it once to toggle in on & click it again to toggle off, that would work. Is there a way using lisp to associate the clicking of the tool button with toggling a particular osnap on/off?

I guess what I'm trying to do is create a toolbar with buttons that toggles each individual osnap on/off uninterupted.

bman

  • Guest
Depressed toolbar buttons
« Reply #6 on: July 26, 2005, 12:07:38 PM »
Thanks for the info Keith, but it sounds like what I was wanting to accomplish is way too complex for me too attempt.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Depressed toolbar buttons
« Reply #7 on: July 26, 2005, 12:16:18 PM »
If the visual is not important, then all you need to do is upon clicking the button, check the value of the osnap you want to set and set it to your setting..

For example
Code: [Select]

(if (=(getvar "osmode") %yourvalue%)
  (setvar "osmode" %thisvalue%)
  (setvar "osmode" %othervalue%)
)
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
Depressed toolbar buttons
« Reply #8 on: July 26, 2005, 12:16:30 PM »
Se7en wrote a neat little function that toggles the entire set on and off. Do a search on boole and see if you can find it. From that you might be able to come up with something that you desire.

Crank

  • Water Moccasin
  • Posts: 1503
Depressed toolbar buttons
« Reply #9 on: July 26, 2005, 01:23:25 PM »
Attention: This is not tested, just a bit cut'n'paste.... :P , but it's a start ;)
Code: [Select]

(vl-load-com)

; OsnapToggles.lsp - 26-07-'05 - J.J.Damstra
; Changes the button top for the specified toolbar button

; Arguments
; The name of the menu group, the name of the toolbar, the name of the toolbar button and the bitmap to use
; (If the bitmap is not in the AutoCAD search path, you must specify the full path to file)

; Example:  (BitmapToggle "acad" "dimension" "Linear Dimension" "test.bmp")
; In menu:  ID_Dimlinear [_Button("Linear Dimension", RCDATA_16_DIMLIN, RCDATA_16_DIMLIN)]^C^C_dimlinear

(defun BitmapToggle (mnuGroup tbrName btnName bitmap)
(vla-setbitmaps
(vla-item
(vla-item
(vla-get-toolbars
(vla-item (vla-get-menugroups (vlax-get-acad-object))
mnuGroup
)
)
tbrName
)
btnName
)
bitmap
bitmap
)
(princ)
)
(defun c:OM-END ()
(if (> (getvar "OSMODE")(setvar "OSMODE" (boole 6 (getvar "OSMODE") 1)))
(BitmapToggle "ACAD" "OSNAPTOGGLES" "END = off" "OM-END-OFF.bmp")
(BitmapToggle "ACAD" "OSNAPTOGGLES" "END = on"  "OM-END-ON.bmp")
)
)
(defun c:OM-MID ()
(if (> (getvar "OSMODE")(setvar "OSMODE" (boole 6 (getvar "OSMODE") 2)))
(BitmapToggle "ACAD" "OSNAPTOGGLES" "MID = off" "OM-MID-OFF.bmp")
(BitmapToggle "ACAD" "OSNAPTOGGLES" "MID = on"  "OM-MID-ON.bmp")
)
)
(defun c:OM-CEN ()
(if (> (getvar "OSMODE")(setvar "OSMODE" (boole 6 (getvar "OSMODE") 4)))
(BitmapToggle "ACAD" "OSNAPTOGGLES" "CEN = off" "OM-CEN-OFF.bmp")
(BitmapToggle "ACAD" "OSNAPTOGGLES" "CEN = on"  "OM-CEN-ON.bmp")
)
)
(defun c:OM-NOD ()
(if (> (getvar "OSMODE")(setvar "OSMODE" (boole 6 (getvar "OSMODE") 8)))
(BitmapToggle "ACAD" "OSNAPTOGGLES" "NOD = off" "OM-NOD-OFF.bmp")
(BitmapToggle "ACAD" "OSNAPTOGGLES" "NOD = on"  "OM-NOD-ON.bmp")
)
)
(defun c:OM-QUA ()
(if (> (getvar "OSMODE")(setvar "OSMODE" (boole 6 (getvar "OSMODE") 16)))
(BitmapToggle "ACAD" "OSNAPTOGGLES" "QUA = off" "OM-QUA-OFF.bmp")
(BitmapToggle "ACAD" "OSNAPTOGGLES" "QUA = on"  "OM-QUA-ON.bmp")
)
)
;.. you fill in the rest
Vault Professional 2023     +     AEC Collection

bman

  • Guest
Depressed toolbar buttons
« Reply #10 on: July 26, 2005, 01:37:53 PM »
Thanks all....this gives me a good starting point....I may be back though with more questions.