This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Replacing a component class in delphi
Does anyone have any tips for modifying the VCL components and making them so they are relatively default within the IDE? This means not necessarily descending from them, but changing functionality in places that don't seem to allow such things in a descendant object. And if they can be used in place of the standard components, that's a bonus as well.
For example, one of the things I'd like to do is an alpha blended mouseover on a TButton. I notice no OwnerDraw event and the code to modify how the button was drawn seems to not be in a place that I can override. Any suggestions, or would I have to strip TButton and all its ancestors out of the VCL code and modify it directly?
You can choose one of the following methods:
Override ReadState of your form, as explained here
Use an interposer class, as explained here and here
Assign a new WindowProc, as explained here.
You are making several questions related to developing custom V.C.L. controls.
Since, its a very extended topic, you may want to browse or search the internet about it.
As a fast question, there are several ways to develop or extend a control.
Sometimes, the same control can be developed in different ways,
other, it depends the kind of control, that you want to develop.
You also mention how to make a control, interact with the Delphi I.D.E.
Delphi controls work with packages, you can make a package with plain libraries without controls, you may want to start doing that, before making a control.
You can make a control, that doesn't interact at all, and only works by running the application, and later add interaction with the Delphi I.D.E.
In Delphi, when you develop a control and want to put it on form, while designing, internally, its like Delphi was your application, and already have your control.
If you want to change the appearance of all TButtons in your application, you can do it without modifying the VCL at all. I see no necessity to modify or even subclass a VCL control yourself, when a few hundred button components exist out there. For example, for alpha-blended mouseovers, just check out the TMS controls.
However, for do-it-yourself techniques; Method one (recommended as simple) is to simply take all the TButtons out of your application and replace it with something else. VCL component replacement (globally) is easily done via gExperts. To see how to combine a standard control appearance (how a button looks) with some overlaid elements drawn in Delphi code, see TBitBtn as a sample. Rather than subclassing TButton or TCustomButton, I recommend you examine TBitBtn sources, and start from it.
Method two (not recommended as simple) is to start using a skinning system which can draw a completely different appearance over standard controls.
Related
On some programs there is an interesting possibility:
in case the work area is very large, there is the overall picture, which provided by the plan of all component.
Which component allows you to add this capability to my program?
I would like to implement this, at least for StringGrid and TChart.
To do this in a generic way, you have to do off-screen painting.
That is a lot of work, especially getting the details right.
JED Software once write something similar to show previews of forms in the IDE called Visual Forms and it took them a long time.
I have a Delphi XE2 Firemonkey application that I want to run on both iPad and iPhone. The iPad and iPhone real estate is different of course and I have been experimenting repositioning and resizing (visual) components according to the platform they are running on - triggered by the forms OnResize event. Started out changing the component "Margins" property with not much success (maybe that relates more to adjacent components...?) and then found the component "Position" property seems to do the job.
Question: Is the Position property the way to go? Or is there a more appropriate way using "Margins" (I seem to have read something about this somewhere, but can no longer find it). Or is there some other method, maybe not based on the OnResize event? (Yes, I am sure this is just 1 question.)
Brief details of the project - displays a costomer database record on the screen using around 30 components, mostly TLabel components, some buttons and search fields or 2 using TEdit's.
Thanks
Really depends on how differently you want to use the extra real-estate.
Do you want to display additional information, or just stretch everything out to use the space? If the latter, then you can use the Scale property.
Simple question. Does anyone know why Interface Builder doesn't allow for applying custom styles on UI elements? Why is it only possible to do this programmatically?
I can see how this might be difficult for custom UIView subclasses but the default controls definitely only have a tiny subset of the style options available through IB, such as background color or changing font colors. Why is this the case? Is there any way to approach a concept like application themes through IB?
My personal feeling is that Apple does this right. They provide the elements and styles that fit the HIG. If they start adding other elements/styles then where do the start, and where do they draw the line?
Also, it isn't like Apple actively prevents using custom elements/styles, they just don't include it in the tool set.
The last thing we need is a tool set full of bloat.
You'd really have to ask Apple as to the why. I'd guess that it's some combination of promoting consistent use of standard interface elements and limited development resources.
You can, of course, build interfaces using your own custom subclasses of the standard interface elements in IB. It's a little more work, since you have to change the type of each object you add from UIButton to MyGreenButton or whatever, but it's not difficult.
It's also not hard to imagine coming up with a controller-type class that could connect to all your controls and whatnot to customize their appearance in some consistent, theme-like manner. Add an instance of that to each nib, connect all the controls, and let it do it's thing. You wouldn't see the effect until you actually run the app, of course, but it sounds like you're talking about customizing colors and fonts rather than size.
Unfortunately you are at the mercy of the Almighty Apple Deity..... Bow at their feet and give thanks that you have what they give you..... lol...
Seriously tho. Apple puts in what apple wants and you can request additions, but the IB is fairly minimal in the way of features.
I think this may be by design. Somehow an Elegant Simplicity ?
The ability to customize the controls is given to the programmer however I think they want the controls standardized. I just dont know why they didnt give a little more variety in the controls that are available. Like a few more button styles for the ios devices...
If you find out otherwise I would definitely be all ears.
I think that apple should let you to customize more the controls, for games it takes too much time to make the custom control ( you can make it faster in android as you can configure it in xml)
Btw PaintCode is another option to make your own style for components, it will generate the code but its more like interface builder
http://www.paintcodeapp.com/
I wonder how difficult it would be to be able to have a custom background or be able to draw on the datamodule canvas somehow so that the relationships of all the datasets can be nicely represented with arrows and stuff. Way back in Delphi 7 or so I seem to remember some sort of datamodule designer which has disappeared (I always found it annoying anyway).
Does anyone know if this is possible through some sort of IDE plugin or something?
TDataModule is a direct descendant of TComponent, and as such, it doens't have a Canvas or any such painting provisioned in it. As is, there is no way to draw or paint on it.
It is conceivable that you could create a descendent that has a TCanvas, but you'd have to really hack into the IDE to get it to be drawn on at design-time. It is an interesting idea, however.
There used to be a "Diagram" tab on the designer for Datamodules. It did have the ability to put notes, boxes with text, and data relations. It was not very understood or used, and the feature was dropped, I guess. (Before my time at CodeGear...)
Or, you may change the datamodule to a form. Leave it visible during development, for testing, documentation and debugging; and turn it it invisible for production. On the form you may put a visio viewer component and some datagrids, accessed thru a tab rack, for quick browsing of the data.
I believe that some way to organize the components in visible groups on
screen could be nice... I have a report DM which have tons of datasets,
dataset providers and Rave DataSources (circa 40 components)....
If I could create some groups to differentiate which is used in
what report.
But this in DM designer itself, not on a separate drawing space...
Seams like this one is for real Delphi geeks only.
This is how it looks (sorry, can't post images)
Delphi IDE ugly toolbar
(source: piccy.info)
What's wrong - disabled Delphi IDE toolbar and menu buttons are ugly black/white images.
What I want to do - make them look gray-scaled.
How? I made some research. Main problem in virtual TCustomImageList.DoDraw method. When paramater Enabled = False it paints ugly things (see disabled buttons on screenshot). I created my own override for this function and it paints gray-scaled images when Enabled = False
Now I want to replace default DoDraw with my own in IDE (using design-time package):
I figured out that unit ImgList is compiled-in bds.exe, so trick with patching this function in rtlXXX.bpl will not work.
Searching for function's body content gave no result. Looks like bds.exe's implementation (I'm talikng about machine codes) of DoDraw is a bit different.
Any suggestions or ideas of how can I make this possible? As base example of runtime code patching I took Andy's Midas Speed Fix: FindMethodPtr, HookProc, UnhookProc
I made it :) Thanks to everyone who participated or viewed this question!
This is how my IDE looks now:
Fixed toolbar http://blog.frantic.im/wp-content/uploads/2009/11/delphi-ide-after.PNG
I just messed up with vclXXX.pbl, my fault. Sources can be found here. Gradient toolbars must be enabled to make it work. If you are interested in further development of this idea - read this topic
Maybe I'm understanding the problem badly but if you just want to override the DoDraw function why don't you just create your own component that inherits from TCustomImageList, override the desired function so that it does what you want and register it into the IDE?
If you don't want to make your own overriden components, you can change the realization directly in [DelphiPath]\source\Win32\vcl\ImgList.pas.
But it is really not a good way.
I've always disliked the way Delphi creates default disabled images from enabled one. This not only manifests itself in the IDE, but it does persist down to the application you're developing. The disabled images in your application look just as bad.
I have in the past tried to figure out what Delphi did to derive the disabled images and build on that. But it still is on my "things to do" list to finish that off.
None-the-less, these are some articles about the Delphi "glitch" that I encountered quite a while ago that may or may not help you:
Indistinguishable gray blobs in disabled menu items, by Vladimir S.
MenuImgList.pas
Fixing a Buttons Drawing Glitch in Delphi 5
Fixing a Menu Drawing Glitch in Delphi 4