Author Topic: Customizing Toolbars  (Read 1945 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Customizing Toolbars
« on: October 28, 2006, 09:45:06 PM »
Ok, this is not your "run of the mill" toolbar customization question. That would be way too easy ... what this is however, is an advanced editing technique I am working on regarding the toolbars that AutoCAD displays. The information I learn could be useful in opening up all sorts of customization areas the user never thought of doing before.

Ok .. I must admit I am stumped, and I don't like it when I am stumped ... but all of that aside,  I have conquered the basic principals of the editing process. I won't post the code here because quite frankly, it is very ugly, full of bugs, and otherwise unintelligible, but I will ooutline the process for those of you who are not of faint heart.

The steps, for example to create a textbox that the user can enter information into (much like the combo box for layers) is as follows:

Using the Windows API calls identify the container you wish to place the textbox control. This can be done with enumChildWindows and then checking each window for the proper attributes to determine it is the correct window. For example, if you wanted to add a control to the layer toolbar, while you are enumerating the windows, simply test for the control with the caption "Layer" (yes even the toolbars that are docked have captions)
Once you have identified the toolbar, use SetWindowPos API to make the toolbar the size you want it to be, making sure to use the zorder and nomove flags, else the toolbar will move and you may loose it when it changes context.
Use the CreateWindowEX API to create a child control (in this instance a "EDIT" class in the newly expanded toolbar. You can also pass some default text at that time.

Now, why you ask might I be posting this here. Well the reason is that I hope there are some kind souls with some advanced knowledge of API programming that will help me out with a sticky point I am having.

I can create the control on the toolbar, but whenever the user moves the toolbar, the toolbar reverts back to its original size .. no problem I thought ... I will remove the window class attributes "CS_HREDRAW" and "CS_VREDRAW", thus preventing the toolbar from resizing itself when it is redrawn ... the problem is, that it still resizes itself ... or more correctly, AutoCAD resizes it (the afxWnd70 class) to the size of the ToolbarWindow32 ... this is obviously no good, because you then cannot see the text box. So, what I need to be able to do is either 1) inject the "edit" class into the ToolbarWindow32 class (initially successful, but afxWnd70 still resizes to the original size of ToolbarWindow32) or 2) subclass the already subclassed afxWnd70 class so I can intercept the resize messages and change the parameters to what I need them to be  3) Setup a timer (simple) that continually updates the toolbar size (serious performance degradation) 4) place additional buttons on the toolbar to keep it as wide as needed and place my control over top (buttons maintain Zorder and as such always come to the top when the mouse moves over them)

Ok, that be the scenario ... now how do I go about acheiving it .. like I said, the basics are already working but I would do better if I had a few other brave souls who might be interested in accomplishing the same goal.

Imagine being able to place any window class (option button, edit box, combo box etc.) on a toolbar. You would be able to implement a toolbar with a graph showing the trend of a stock you enter into the textbox. ... much like the lisp program shown elsewhere on this forum for tracking a stock performance in the drawing window.

Don't be afraid ... of course you all now know exactly how stupid I really am.
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

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Customizing Toolbars
« Reply #1 on: October 28, 2006, 10:05:09 PM »

I haven't got anything to hand and I can't remember the name of how to do it (it may very well be subclassing) but yes, you can intercept the window's winproc (by assinging your winproc to the registered window class), handle what you need and send the ones you want the window to handle on to the default (for that window) winproc. This would be the best way I can think of to capture and handle the sizing/moving messages.

not much I know help but may give you or others some ideas.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien