Aston Shell plug-in SDK

Creating plug-ins for Aston 1.9.2

This document is copyrighted © 2006 by Gladiators Software.

Distributed under the terms of CC Attribution-NonCommercial-ShareAlike 2.5.

Changes in Aston 1.9.2 SDK

Here, in short, we'll repeat some new features of Aston 1.9.2.

In Aston 1.9.2 we have implemented a new graphical resource type, 3PIC, which can consist out of 6 pictures:

There can be less layers, so an 3PIC could have just one picture or two.

Refer to our skinning tutorial for more information about 3PIC, ANK and other specific skinning-related information.

What's needful in order to draw a 3PIC:

C++
TPicture pic = {0}; // define TPicture type variable

RECT r;             // we need a rectangle to draw the skin in
pic.FileName = "c:\\aston\\pictures\\test.3pic";   // set path to a 3PIC
LoadImageEx(&pic);                                 // load image
pic.FileName = NULL;
SetRect(&r, 0, 0, 200, pic.Height);		// define a draw rectangle's coordinates
    
    ...

    if (pic.IconType == PICTURE_3PIC)
    {
        DrawSkin(DC, DC, r, r, r, &pic,  0, DPEx_TILED); // draw main layer
    ...                                                  // draw something between the main and glass layers
        DrawSkin(DC, DC, r, r, r, &pic,  1, DPEx_TILED); // draw glass layer
    }

    ...

FreePicture(&pic); // don't forget to free the resource when it's no longer required
Pascal/Delphi
var
    pic:TPicture;
    r:TRECT;
begin
    pic.FileName := 'c:\aston\pictures\test.3pic';
    LoadImageEx(@pic);
    pic.FileName := nil;
    SetRect(@r, 0, 0, 200, pic.Height);

    ...

    if (pic.IconType = PICTURE_3PIC) then
    {
    DrawSkin(DC, DC, r, r, r, @pic,  0, DPEx_TILED); // draw layer, 0 is a brush which is used to fill the rectangle
    ... 
    DrawSkin(DC, DC, r, r, r, @pic,  1, DPEx_TILED); // draw glass; as glass needs no infill, this parameter works 
    //as a flag, i.e with brush=1 the layer is glass.
    }

    ...

    FreePicture(@pic);
end;

In a new version of Aston we've tried to ease the process of creating plug-ins as much as possible. For example, now it performs all the drawing routine by itself.

There's a special function for creating the plug-in's window.

LRESULT __cdecl CreateAstonWND(int x, int y, HWND parent, int zorder, int flag, WNDPROC proc, HWND desktop, int transparency);

This function creates a window and returns the pointer to the window's class.

If the window is successfully created, it would return a pointer to the class and 0 if it has not been created.

C++

AstonWND* ii;

void InitWnd()
{
	ii = NULL;
	ii = (AstonWND *)CreateAstonWND(0,0, 0, 2, AWS_LAYERED | AWS_FADESTYLE, NULL, 0, 10);
	if (ii == NULL) return; // no window created
	// window created
}
		

Pascal/Delphi
 var
ii:AstonWND; // 

procedure InitWnd()
begin
	ii := AstonWND(CreateAstonWND(0,0, 0, 2, AWS_LAYERED or AWS_FADESTYLE, nil, 0, 10));
	if (ii = nil) then exit; // no window created
	// window created
end;
		

After successful window creation you may add layers and perform additional operations with them through a special interface.
As you might have noticed, no window size is set when the window is created, it's calculated automatically depending on existing layers.

Layers are placed one on another, their order is regulated by the ZOrder value which you can adjust. Usually this is the first parameter (index) returned by the layer creation function but it's easier to add layers in a required order and set index to 0 (bottommost layer) so Aston calculates the value itself.

C++
__interface AstonWND: IUnknown
{   
    HWND __stdcall hwnd();
    UINT  __stdcall GetVer();
    void __stdcall Show(int ShowFlag);
    void __stdcall ReDraw();
    void __stdcall SetFixedSize(int w, int h);
    void __stdcall MoveWindow(int x, int y);
    int __stdcall  SetBG(CHAR* path);
    void __stdcall SetANKState(int index, int newstate);
    int __stdcall  AddLayer(int index, int x, int y, CHAR* pic_path, int flag, int transparency);
    bool __stdcall RemoveLayer(int index);
    int __stdcall  CreateCustomLayer(int index, int x, int y, int w, int h, int flag, int transparency);
    bool __stdcall SetANKFrame(int index, int newframe);
    bool __stdcall SetLayerFlag(int index, int flag);
    int  __stdcall GetLayerFlag(int index);
    paint __stdcall LayerPaint_Begin(int index);
    void __stdcall LayerPaint_End(Ppaint p);
    void __stdcall DrawText(HDC dc, CHAR* text, RECT* r, HFONT font, DWORD flag, COLORREF fontColor, BOOL shadow, COLORREF shadow_color);
    void __stdcall DrawTextOnLayer(int index, CHAR* text, RECT* r, HFONT font, DWORD flag, COLORREF fontColor, BOOL shadow, COLORREF shadow_color);
    HWND __stdcall CreateChildWnd(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight,
    HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
    bool __stdcall GetLayerRect(int index, RECT* rect);
    bool __stdcall SetLayerRect(int index, RECT* rect);
    void __stdcall Free();
    int __stdcall  AddLayerPic(int index, int x, int y, PPicture pic, int flag);
    int __stdcall  AddLayerPic3(int index, int x, int y, PPicture pic,PPicture pic2, PPicture pic3, int flag);
    void __stdcall MoveLayer(int index, int x, int y, bool SENDCHANGING);
    void __stdcall AddHintOnLayer(int index, CHAR* Hint);
    int __stdcall  AddLayer3Pic(int index, int x, int y, int w, int h, CHAR* path_3pic, int flag, int transparency);
    PPicture __stdcall GetLayerPic(int index);
    BOOL __stdcall LayerOnPoint(int index, POINT p);
    void __stdcall SetUserData(long dwNewLong);
    long __stdcall GetUserData();
    void __stdcall SetDebugMode(bool flag);
    bool __stdcall MakeScrollBar(int scrollbar, int slider, int flag);
};
	

Pascal/Delphi
AstonWND = interface
    function wnd():HWND;stdcall;
    function GetVer():UINT;stdcall;	
    procedure Show(ShowFlag:integer);stdcall;
    procedure RedRaw();stdcall;
    procedure SetFixedSize(w,h:integer);stdcall;
    procedure MoveWindow(x,y:integer);stdcall;
    function  SetBG(pic:PChar):integer;stdcall;
    procedure SetANKState(index,newstate:integer);stdcall;
    function  AddLayer(index, x, y:integer; pic_path:PChar; flag, trans:integer):integer;stdcall;
    function  RemoveLayer(index:integer):bool;stdcall;
    function  CreateCustomLayer(index, x, y, w, h, flag, trans:integer):integer;stdcall;
    function  SetANKFrame(index, newframe:integer):bool;stdcall;
    function  SetLayerFlag(index, flag:integer):bool;stdcall;
    function  GetLayerFlag(index:integer):integer;stdcall;
    function  LayerPaint_Begin(index:integer):Ppaint;stdcall;
    procedure LayerPaint_End(ps:Ppaint);stdcall;
    procedure DrawText(dc:HDC; text:PCHAR; r:PRECT; font:HFONT; flag:DWORD;fontColor:COLORREF; shadow:bool;shadow_color: COLORREF);stdcall;
    procedure DrawTextOnLayer(index:integer; text:PCHAR; r:PRECT; font:HFONT; flag:DWORD;fontColor:COLORREF; shadow:bool;shadow_color: COLORREF);stdcall;
    function CreateChildWnd(dwExStyle:DWORD; lpClassName,lpWindowName:Pchar;
                            dwStyle:DWORD;x, y, nWidth,nHeight:integer;
                            hMenu:HMENU;hInstance:Cardinal;lpParam:pointer):HWND;stdcall;
    function  GetLayerRect(index:integer; rect:PRECT):bool;stdcall;
    function  SetLayerRect(index:integer; rect:PRECT):bool;stdcall;
    procedure Free();stdcall;
    function  AddLayerPic(index, x, y:integer; pic:PPicture; flag:integer):integer;stdcall;
    function  AddLayerPic3(index, x, y:integer; pic1, pic2, pic3:PPicture; flag:integer):integer;stdcall;
    procedure MoveLayer(index, x, y:integer; NoSend:boolean);stdcall;
    procedure AddHintOnLayer(index:integer; Hint:PCHAR);stdcall;
    function  AddLayer3Pic(index, x, y, w, h:integer; path_3pic:Pchar; flag, transparency:integer):integer;stdcall;
    function  GetLayerPic(index:integer):PPicture;stdcall;
    function  LayerOnPoint(index:integer; p:TPOINT):bool;stdcall;
    procedure SetUserData(dwNewLong:longint);stdcall;
    function  GetUserData():longint;stdcall;
    procedure SetDebugMode(flag:bool);stdcall;
    function  MakeScrollBar(scrollbar, slider, min, max, pos, flag:integer):bool;stdcall;
end;
	

hwnd

HWND __stdcall hwnd();

If CreateAstonWND has not returned NULL, this function returns the window's HWND.

GetVer

Returns version number of AstonEx.dll library.

UINT  __stdcall GetVer();

The function returns integer value. For example, for version 1.9.2 the value is 19200.
It is required for plug-in compatibility check.

Plug-ins are forward compatible, i.e. if the function returns a higher value, the plug-in should work flawlessly. At least in theory ;)

Show

Displays (ShowFlag = 1) or hides (ShowFlag = 0) the window.

void __stdcall Show(
	int ShowFlag	// show window's state
	);
	

If the window has a AWS_FADESTYL style, it would be shown and hidden with animation.

SetFixedSize

Sets fixed window size.

void __stdcall SetFixedSize(
	int w, 		// window width
	int h		// window height
	);
	
These values are independent from layer sizes i.e. layer sizes are not taken into account when the window's size is calculated.

MoveWindow

Move the window to a defined point.

void __stdcall MoveWindow(
	int x, 		// horizontal position of the layer
	int y		// vertical  position of the layer
	);
	
All coordinates are defined relatively to the window's left top corner. The coordinates can be negative but this way Aston would adjust the window's size so it's fully visible.

SetBG

Set window background (In fact, a new layer with a defined background image is created):

int __stdcall  SetBG(
	CHAR* path
	);

where path is the path to the background image.

The function returns the added layer number. If failed, the value is -1.

C++
int index = ii.SetBG("c:\\Aston\\picture\\pic.png");
Pascal/Delphi
index := ii.SetBG('c:\Aston\picture\pic.png');

SetANKState

Defines the animated layer's state (if the background is ANK or ANKz).

void __stdcall SetANKState(
	int index, 		    // layer index
	int newstate		// new layer state
	);

newstate defines the layer state which can be:

SetANKFrame

Defines, which ANK frame is to be displayed when it's set as a layer image.

bool __stdcall SetANKFrame(
	int index, 		// layer index
	int newframe		// frame number in ANK file
	);

AddLayer

Adds a new layer with the size of defined image and ZOrder equal to index. Set index to 0 for automatic ZOrder calculation.

int __stdcall  AddLayer(
	int index, 		// layer index
	int x, 			// layer horizontal position
	int y			// layer vertical position
	CHAR* pic_path, 	// path to the image
	int flag, 		// layer style
	int transparency	// layer transparency
	);

You may set different flags (layer styles) on adding new layers:

Information above is important!

The function returns -1 if it fails, otherwise correct layer index is returned. You may use this value later, if required.

RemoveLayer

Removes certain layer.

bool __stdcall RemoveLayer(
	int index 		// layer index
	);

Returns true if deletion is successful, otherwise - false.

CreateCustomLayer

Create custom layer with x,y coordinates and sized w,h; no image is used.

int __stdcall  CreateCustomLayer(
	int index, 		// layer index
	int x, 			// layer horizontal position
	int y			// layer vertical position
	int w, 			// layer width
	int h, 			// layer height
	int flag, 		// layer styles
	int transparency	// layer transparency
	);

If function fails, it returns -1, otherwise - layer index.

SetLayerFlag

Set layer flag

bool __stdcall SetLayerFlag(
	int index, 		// layer index
	int flag		//layer style
	);
Layer styles may be groupped by using OR.

GetLayerFlag

Get layer flag value

int  __stdcall GetLayerFlag(
	int index		// layer index
	);

If function fails, it returns -1, otherwise - layer index.

LayerPaint

In order to draw something on the layer you can call the LayerPaint_Beginfunction, draw somthing and then call LayerPaint_End to place the result to the layer. If you have a layered layer, use alpha channel (i.e. ARGB color coding) while drawing, otherwise the reult would be invisible.

Ppaint __stdcall LayerPaint_Begin(
	int index		// layer index
	);

This function returns pointer to the painting structure:

struct tagTpaint
{
	HDC DC;			// handle to device context
	VOID* bits;		// layer bytes, required for drawing with alpha channel
	SIZE size;		// layer size
} Tpaint, *Ppaint;

You may draw on the resulting context. In order to apply changes, call the following function:

void __stdcall LayerPaint_End(
	Ppaint p		// pointer to the drawing structure
	);
No changes are visible unless LayerPaint_End is called.

DrawText

Drawing text on the context.
This function is close to the system DrawText function except for it correctly draws text on layers with alpha channel and the text can have a shadow with defined color.

void __stdcall DrawText(
	HDC dc, 		// handle to device context 
	CHAR* text, 		// pointer to the text line to draw 
	RECT* r, 		// pointer to the structure with formatting dimensions  
	HFONT font, 		// pointer to font structure
	DWORD flag, 		// text-drawing flags 
	COLORREF fontColor, 	// text color
	BOOL shadow, 		// enable or disable shadow
	COLORREF shadow_color	// shadow color
	);

DrawTextOnLayer

Same as DrawText, but there's no need to get layer context, you may immediately specify the layer index.

void __stdcall DrawTextOnLayer(
	int index, 		// layer index
	CHAR* text, 		// pointer to string to draw 
	RECT* r, 		// pointer to structure with formatting dimensions  
	HFONT font, 		// pointer to font structure
	DWORD flag, 		// text-drawing flags 
	COLORREF fontColor, 	// font color
	BOOL shadow, 		// enable or disable shadow
	COLORREF shadow_color	// text shadow color
	);

Also refer to DrawText.

CreateChildWnd

Creates a child window. Usual layered windows cannot have the Child style, but by using this function you can make one (like a button or other windows controls).

HWND __stdcall CreateChildWnd(
	DWORD dwExStyle, 	// extended window style
	LPCTSTR lpClassName, 	// pointer to registered class name
	LPCTSTR lpWindowName, 	// pointer to window name
	DWORD dwStyle, 		// window style
	int x, 			// horizontal position of window
	int y, 			// vertical position of window
	int nWidth, 		// window width
	int nHeight, 		// window height
	HMENU hMenu, 		// handle to menu, or child-window identifier
	HINSTANCE hInstance, 	// handle to application instance
	LPVOID lpParam);	// pointer to window-creation data

GetLayerRect

Get layer size.

bool __stdcall GetLayerRect(
	int index, 		// layer index
	RECT* rect		// address of a structure for layer coordinates
	);

Function returns true if successful and false if not.

SetLayerRect

Set layer size

bool __stdcall SetLayerRect(
	int index, 		// layer index
	RECT* rect		// address of a structure for layer coordinates 
	);

Function returns true if successful and falce if not.

Free()

Removes all layers and child windows

void __stdcall Free();

AddLayerPic

Create a new layer from the added image.

int __stdcall  AddLayerPic(
	int index, 		// номер слоя.
	int x, 			// horizontal position of layer
	int y			// vertical  position of layer 
	PPicture pic, 		// pointer to Aston picture structure
	int flag		// флаги слоя. анологично AddLayer
	);

The function returns -1 if it fails, otherwise correct layer index is returned. You may use this value later, if required.

AddLayerPic3

Add a layer, which would have 3 states (normal, highlighted, pressed) and would use certain image depending on user actions.

int __stdcall  AddLayerPic3(
	int index, 		// layer index
	int x, 			// horizontal position of layer
	int y			// vertical  position of layer 
	PPicture pic,		// pointer to Aston picture structure
	PPicture pic2, 		// pointer to Aston picture structure
	PPicture pic3, 		// pointer to Aston picture structure
	int flag);		// layer flags, similar to AddLayer

The function returns -1 if it fails, otherwise correct layer index is returned. You may use this value later, if required.

MoveLayer

Move the layer to a new position. Layer dimentions remain the same.

void __stdcall MoveLayer(
	int index, 		// layer index
	int x, 			// new horizontal position of layer
	int y			// new vertical  position of layer 
	bool SENDCHANGING	// tell the window that the layer has been moved
	);

AddHintOnLayer

Add hint to certain layer. it is displayed when mouse cursor ishovering the layer.

void __stdcall AddHintOnLayer(
	int index, 		// layer index.
	CHAR* Hint		// address of Hint string
	);

AddLayer3Pic

Add a new layer with specified size and 3PIC skin.

int __stdcall  AddLayer3Pic(
	int index, 		// layer index
	int x, 			// horizontal position of layer
	int y			// vertical  position of layer
	int w, 			// layer width
	int h, 			// layer height
	CHAR* path_3pic, 	// path to the 3PIC
	int flag, 		// refer to AddLayer
	int transparency	// layer transparency
	);

The function returns -1 if it fails, otherwise correct layer index is returned. You may use this value later, if required.

GetLayerPic

Get pointer to the picture.

PPicture __stdcall GetLayerPic(
	int index, 		// layer index
	);
Use this function for drawing a picture which is also used somewhere else in the layer.

If function fails, it returns 0, otherwise - pointer to Aston picture structure.

LayerOnPoint

Find out if the layer is located in a certain position.

BOOL __stdcall LayerOnPoint(
	int index, 	// layer index
	POINT p		// structure with the point
	);

Function returns true if successful and false if not.

SetUserData

White a constant into the window.

void __stdcall SetUserData(
	long dwNewLong
	);

Sets the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window.

GetUserData

Read the constant from the window.

long __stdcall GetUserData();

Retrieves the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window.

SetDebugMode

Enter the debugging mode. All layer content is to be displayed in bound boxes.

void __stdcall SetDebugMode(
	bool flag
	);

MakeScrollBar

Combine two layers into the scrollbar. The second layer would automatically get a needful position and start behaving like a slider knob. If scrollbar orientation is not explicitly set in the flag it would be calculated depending on the image i.e. if the height is larger than width than the scrollbar is vertical.

bool __stdcall MakeScrollBar(
	int scrollbar, 	// scrollbar background layer index
	int slider, 	// scrollbar knob layer index
	int min, 	//minimum scrolling position
	int max,  	//maximum scrolling position
	int pos, 	//current scrolling position
	int flag	// scrollbar flags
	);

SCROLL_HOR   - horizontal scrollbar position
SCROLL_VERT  - vertical scrollbar position

GetScrollBar

returns information (min, max, position, flags) about scrollbar

bool __stdcall GetScrollBar(
	int scrollbar,   // scrollbar layer index 
	int& min,	 // return value (min scrolling position)
	int& max,   	 // return value (max scrolling position) 
	int& pos 	 // current scrolling position)
	);

SetScrollBar

Sets scrollbar info (min, max, position, flags). After setting new values the scrollbar is automatically refreshed. You may change position, min, max values and scrollbar orientation.

bool __stdcall SetScrollBar(
	int scrollbar, 	// scrollbar layer index 
	int min, 	//minimum scrolling position
	int max,  	//maximum scrolling position
	int pos, 	//current scrolling position
	int flag	// scrollbar flags
	);