This document is copyrighted © 2006 by Gladiators Software.
Distributed under the terms of CC Attribution-NonCommercial-ShareAlike 2.5.
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:
What's needful in order to draw a 3PIC:
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
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.
x,y
- window's coordinatesparent
- parent windowzorder
- window's Z-order:
0
- Desktop1
- Normal window2
- Always on topflag
:AWS_LAYERED
- layered window, i.e. the window has a WS_EX_LAYERED
styleAWS_DRAWWALLPAPER
- wallpaper and Desktop icons are visible through this windowAWS_NOAUTORESIZE
- do not resize the window automatically, use manual settings insteadAWS_FADESTYLE
- show and hide the window with fade effects appliedAWS_LOCKPOS
- lock the window, i.e. it could only be dragged with SHIFT pressed (unless unlocked)AWS_HIDEONMOUSEMOVE
- hide the window on mouse overAWS_GHOSTMODE
- it's possible to click "through" the window; it's set into a so-called "ghost mode"proc
: pointer to a message processing procedure, can be set to NULL (nil)LONG WINAPI AstonWindowProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { POINT p; switch (message) { case WM_COMMAND: { }; break; } return 0; }
function AstonWindowProc(Window: HWnd; Msg:UINT; WParam: WParam; LParam: LParam): Longint; stdcall; begin case Msg of WM_COMMAND: begin end; end; result := 0; // return 0, not DefWindowProc !!!! end;
desktop
- desktop's handle, must always present if a plug-in is located on the Desktop or has a AWS_DRAWWALLPAPER
styletransparency
- window's transparency in percentage terms, i.e. when set to 0
the vindow is fully visible and with 100
- invisible
If the window is successfully created, it would return a pointer to the class and 0
if it has not been created.
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 }
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.
__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); };
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 __stdcall hwnd();
hwnd()
- returns the window's handleHWND __stdcall hwnd();
If CreateAstonWND
has not returned NULL
, this function returns the window's HWND.
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.
Displays (ShowFlag = 1
) or hides (ShowFlag = 0
) the window.
void __stdcall Show( int ShowFlag // show window's state );
ShowFlag = 0
- hides the window and activates another oneShowFlag = 1
- activates the window and displays it with current size and positionAWS_FADESTYL
style, it would be shown and hidden with animation.
Sets fixed window size.
void __stdcall SetFixedSize( int w, // window width int h // window height );
Move the window to a defined point.
void __stdcall MoveWindow( int x, // horizontal position of the layer int y // vertical position of the layer );
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
.
int index = ii.SetBG("c:\\Aston\\picture\\pic.png");
index := ii.SetBG('c:\Aston\picture\pic.png');
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:
ANK_NORMAL
- default stateANK_OVER
- mouse is over the ANK objectANK_LEAVE
- mouse leaves the ANK object areaANK_CLICK
- clicking ANK objectDefines, 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 );
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 );
int index
- layer index; if the layer is busy, the function fails; set 0
for automatic calculationint x, int y
- layer coordinates relatively to the windowCHAR* pic_path
- path to the imageint flag
- layer flagsYou may set different flags (layer styles) on adding new layers:
LAYER_DEFAULT
- just a layer; seriously, an ordinary layer ;)LAYER_NOANIMATION
- disable animation for ANK files defined in this layerLAYER_TRANSPARENT
- "click-transparent" layer, i.e. a layer below gets all mouse messages insteadLAYER_DRAG
- the window is draggable by this layerLAYER_DRAGITEM
- the layer itself can be dragged inside the windowLAYER_DRAWWALLPAPER
- wallpaper and icons located below the window are drawn in this layerLAYER_LAYERED
- layered window with alpha channelLAYER_3PIC_STRETCH
- stretch 3PIC's central part (don't tile, like in default settings)LAYER_HIDE
- hide the layer
The function returns -1
if it fails, otherwise correct layer index is returned. You may use this value later, if required.
Removes certain layer.
bool __stdcall RemoveLayer( int index // layer index );
Returns true
if deletion is successful, otherwise - false
.
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 );
int index
- layer index; set 0
for automatic calculation.int x, int y
- layer coordinates relatively to the windowint w, int h
- layer width and heightint flag
- layer flagsint transparency
- layer transparencyIf function fails, it returns -1
, otherwise - layer index.
Set layer flag
bool __stdcall SetLayerFlag( int index, // layer index int flag //layer style );
OR
.Get layer flag value
int __stdcall GetLayerFlag( int index // layer index );
If function fails, it returns -1
, otherwise - layer index.
In order to draw something on the layer you can call the LayerPaint_Begin
function, 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 );
LayerPaint_End
is called.
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 );
dc
- identifies the device contexttext
- points to the text to drawr
- pints to a RECT
structure that cointains the bound box in which the text is to be placed.font
- points to font structureflag
- specifies the method of formatting the text; it can be any combination of the following values:DT_BOTTOM
- justifies the text to the bottom of the rectangle; this value must be combined with DT_SINGLELINE
DT_CALCRECT
- determines the width and height of the rectangle; if there are multiple lines of text, DrawText
uses the width of the rectangle pointed to by the lpRect
parameter and extends the base of the rectangle to bound the last line of text; if there is only one line of text, DrawText
modifies the right side of the rectangle so that it bounds the last character in the line; in either case, DrawText
returns the height of the formatted text but does not draw the textDT_CENTER
- centers text horizontally in the rectangleDT_END_ELLIPSIS
or DT_PATH_ELLIPSIS
- replaces a part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle; the given string is not modified unless the DT_MODIFYSTRING
flag is specified; you can specify DT_END_ELLIPSIS
to replace characters at the end of the string, or DT_PATH_ELLIPSIS
to replace characters in the middle of the string; if the string contains backslash (\) characters, DT_PATH_ELLIPSIS
preserves as much as possible of the text after the last backslashDT_EXPANDTABS
- expands tab characters; the default number of characters per tab is 8
DT_EXTERNALLEADING
- includes the font external leading in line height; normally, external leading is not included in the height of a line of textDT_LEFT
- aligns text to the leftDT_MODIFYSTRING
- modifies the given string to match the displayed text; this flag has no effect unless the DT_END_ELLIPSIS
or DT_PATH_ELLIPSIS
flag is specifiedDT_NOCLIP
- draws without clipping; DrawText
is somewhat faster when DT_NOCLIP
is usedDT_NOPREFIX
- turns off processing of prefix characters; normally, DrawText
interprets the mnemonic-prefix character & as a directive to underscore the character that follows, and the mnemonic-prefix characters && as a directive to print a single &; by specifying DT_NOPREFIX
, this processing is turned offDT_RIGHT
- aligns text to the rightDT_RTLREADING
- layout in right to left reading order for bi-directional text when the font selected into the hdc is a Hebrew or Arabic font; the default reading order for all text is left to rightDT_SINGLELINE
- displays text on a single line only; Carriage returns and linefeeds do not break the lineDT_TABSTOP
- sets tab stops; bits 15-8 (high-order byte of the low-order word) of the uFormat
parameter specify the number of characters for each tab; the default number of characters per tab is 8
DT_TOP
- top-justifies text (single line only)DT_VCENTER
- centers text vertically (single line only)DT_WORDBREAK
- breaks words; lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect
parameter; a carriage return-linefeed sequence also breaks the line
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
.
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
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.
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.
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 );
int index
- layer index; if the layer is busy, the function fails; set 0
for automatic calculationint x, int y
- layer coordinates relatively to the windowpic
- pointer to the picture (the image must be loaded)flag
- refer to AddLayer
The function returns -1
if it fails, otherwise correct layer index is returned. You may use this value later, if required.
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
int index
- layer index; if the layer is busy, the function fails; set 0
for automatic calculationint x, int y
- layer coordinates relatively to the windowpic
- normal state skinpic2
- skin when cursor is hovering the layerpic3
- skin when user is clicking the layerflag
- refer to Addlayer
The function returns -1
if it fails, otherwise correct layer index is returned. You may use this value later, if required.
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 );
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 );
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
);
int index
- layer index; if the layer is busy, the function fails; set 0
for automatic calculationint x, int y
- layer coordinates relatively to the windowint w, int h
- layer width and heightpic
- path to the 3PICflag
- refer to AddLayer
int transparency
- layer transparencyThe function returns -1
if it fails, otherwise correct layer index is returned. You may use this value later, if required.
Get pointer to the picture.
PPicture __stdcall GetLayerPic( int index, // layer index );
If function fails, it returns 0
, otherwise - pointer to Aston picture structure.
Find out if the layer is located in a certain position.
BOOL __stdcall LayerOnPoint( int index, // layer index POINT p // structure with the point );
p
- specifies a point
structure that defines the point to be checked.Function returns true
if successful and false
if not.
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.
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.
Enter the debugging mode. All layer content is to be displayed in bound boxes.
void __stdcall SetDebugMode( bool flag );
flag = true
- debug mode is onflag = false
- debug mode is offCombine 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
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) );
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 );
Have comments, questions or doubts? Let us know.