Raise an event when I hover the mouse over a ComboBox item

You can create a Custom Control, derived from ComboBox, override its WndProc method to intercept the CB_GETCURSEL message. Call base.WndProc(ref m) first. When the message is processed, the Message object’s m.Result property is set to a value (as IntPtr) that represents the Item currently tracked in the ListBox (the Item highlighted when the Mouse Pointer … Read more

Custom UITableViewCell programmatically using Swift

Let’s make a few assumptions: You have an iOS8 project with a Storyboard that contains a single UITableViewController. Its tableView has a unique prototype UITableViewCell with custom style and identifier: “cell”. The UITableViewController will be linked to Class TableViewController, the cell will be linked to Class CustomTableViewCell. You will then be able to set the … Read more

Android – Way to appear bordered text on the TextView?

I would suggest to extend TextView See Android Custom Component Guide package samples.test; public class MyTextView extends TextView { public MyTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public MyTextView(Context context, AttributeSet attrs) { super(context, attrs); } public MyTextView(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Rect rect … Read more

Blackberry – fields layout animation

This effect may be easily achived with custom layout: class AnimatedManager extends Manager { int ANIMATION_NONE = 0; int ANIMATION_CROSS_FLY = 1; boolean mAnimationStart = false; Bitmap mBmpBNormal = Bitmap.getBitmapResource(“blue_normal.png”); Bitmap mBmpBFocused = Bitmap.getBitmapResource(“blue_focused.png”); Bitmap mBmpRNormal = Bitmap.getBitmapResource(“red_normal.png”); Bitmap mBmpRFocused = Bitmap.getBitmapResource(“red_focused.png”); Bitmap mBmpYNormal = Bitmap.getBitmapResource(“yellow_normal.png”); Bitmap mBmpYFocused = Bitmap.getBitmapResource(“yellow_focused.png”); Bitmap mBmpGNormal = Bitmap.getBitmapResource(“green_normal.png”); Bitmap … Read more

Custom button template in WPF

You can do this easily with a style and attached property: <ResourceDictionary xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:ap=”clr-namespace:MyProject.Namespace.Path.To.ButtonProperties”> … <Style x:Key=”ImageButton” TargetType=”Button”> <Setter Property=”ContentTemplate”> <Setter.Value> <DataTemplate> <StackPanel Orientation=”Horizontal”> <Image Source=”{Binding Path=(ap:ButtonProperties.Image), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}”></Image> <ContentPresenter Content=”{Binding Path=Content, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}”></ContentPresenter> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style> … </ResourceDictionary> and public class ButtonProperties { public static ImageSource GetImage(DependencyObject … Read more

What is the difference between a User Control Library and a Custom Control Library?

In practice custom controls are something you implement on the code level while you can use XAML for user controls. The custom controls extend one of the WPF control base classes and provide additional functionality through code so all the added logic and representation must be implemented inside the code. A user control is technically … Read more

Using Custom Colored Cursors in a C# Windows Application [closed]

The Cursor class is rather poorly done. For some mysterious reason it uses a legacy COM interface (IPicture), that interface doesn’t support colored and animated cursors. It is fixable with some fairly ugly elbow grease: using System; using System.ComponentModel; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Reflection; static class NativeMethods { public static Cursor LoadCustomCursor(string path) { … Read more