Y'z Dock Downloads
Download Dock:
Y'z Dock v0.8.3 (923 KB)
Useful Links
Millions Of Page Faults In Ad, Od And Yz (by herd)
Sample Tutorial - Creating a leftClick Docklet for Y'z Dock
by Haitham Al-Beik - 07.03.2003
Welcome to the first tutorial for Y'z Docklets. In this tutorial we will develop
a simple docklet that only does one thing; to animate the docklet, by bouncing, when
left clicked. The main purpose of this docklet is to teach you the different
available SDK functionalities.
Download Tutorial Source Code
Download leftClick tutorial files:
leftclick.rar (35 KB)
or
leftclick.zip (38 KB)
Tutorial Information
Experience Level:
Beginner
Programming Environment:
Microsoft Visual C++ 6.0
Setting up the SDK
After downloading the SDK extract it to a folder and name it anything you want. I will name the folder SDK_FOLDER for easy reference.
<SDK_FOLDER>\
DockletSDK\
reference_en.txt
reference_jp.txt
YzDocklet.dll
YzDocklet.h
YzDocklet.lib
Setting up MS Visual C++ 6.0
After setting up the SDK launch MS Visual C++. When VC++ successfully loads go to the
File menu and select
New.
Select the
Project Dialog box, select
Win32 Dynamic-Link Library, make sure that the Location is set to your extracted SDK_FOLDER, and type
leftClick under
Project Name.
It should look something like the picture below.
Click OK. Select
An Empty DLL Project on the next appearing dialog.
The Coding
Let us start the code. Before we begin make sure to read the reference_en.txt file, included in the SDK, to understand the requirements of the functions we are going to use below.
To create our main source file, go back to the
File Menu and select
New. This time make sure to select the Files tab and highlight
C++ Source File.
The rest can be seen in the picture below.
Let us start off with the include files.
/*
* Include necessary files
*/
#include <afxwin.h>
/*
* Load Y'z Docklet library
*/
#include "../DockletSDK/YzDocklet.h"
#pragma comment(lib, "../DockletSDK/YzDocklet.lib")
Now we can setup our variables and defines.
#define INFO_AUTHOR _T("Haitham Al-Beik")
#define INFO_VER _T("Version 1")
#define INFO_MISC _T("LeftClick Tutorial\r\n \
\r\n(c) 2003-2006, Haitham Al-Beik\r\nhttp://www.dockex.com.")
/*
* Application Global Variables
*/
HINSTANCE g_hInstDock = NULL,
g_hInstDocklet = NULL;
HWND g_hWndDock = NULL,
g_hWndDocklet = NULL;
INT g_idDocklet = -1;
/*
* The Docklet Label
*/
CString g_csAppLabel = "Tutorial";
Now we need to insert the important functions that the Y'z Dock expects us to have. If you don't provide these functions, the DLL file won't show under the Add Docklet Dialog of Y'z Dock.
The first function,
wndProc(), is a CALLBACK function initiated by the
OnInitialize() function when creating the docklet.
/*
* This CallBack function is initialized with OnInitialize()
* when YzDockletCreate() is called.
*/
LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return(DefWindowProc(hWnd, message, wParam, lParam));
}
/*
* YzDocklet: OnVersion()
*/
EXPORT DWORD __cdecl OnVersion(void)
{
return YZDOCKLET_VERSION;
}
/*
* YzDocklet: OnInformations()
*/
EXPORT void __cdecl OnInformations(LPTSTR lpszAuthor, LPTSTR lpszVer, LPTSTR lpszMisc)
{
_tcscpy(lpszAuthor, INFO_AUTHOR);
_tcscpy(lpszVer, INFO_VER);
_tcscpy(lpszMisc, INFO_MISC);
}
/*
* YzDocklet: OnInitialize()
*/
EXPORT HWND __cdecl OnInitialize(HINSTANCE hInst, HWND hWndDock, int idDocklet)
{
g_hWndDock = hWndDock;
g_hWndDocklet = YzDockletCreate(hInst, idDocklet, wndProc);
g_idDocklet = idDocklet;
g_hInstDocklet = hInst;
return g_hWndDocklet;
}
/*
* YzDocklet: OnLabel()
*/
EXPORT void __cdecl OnLabel(LPCTSTR lpszLabel, BOOL bFirstTime)
{
strcpy((char *)lpszLabel, g_csAppLabel);
}
/*
* YzDocklet: OnTerminate()
*/
EXPORT void __cdecl OnTerminate(HINSTANCE hInst, HWND hWndDocklet)
{
YzDockletDestroy(hInst, hWndDocklet);
}
Most of the above functions are the same when developing different docklets. Note that you can add any destructive objects into the OnTerminate() function to make a clean exit of the docklet.
Now we can add our important function. The
OnLeftButtonClick() function. When a use left-clicks the docklet this function is called. Inside this function we are going to call
YzDockletAnimateIcon() function to make the icon bounce. This is to prove that our docklet is setup properly.
/*
* YzDocklet: OnLeftButtonClick()
*/
EXPORT BOOL __cdecl OnLeftButtonClick(int x, int y, int width, int height, UINT key,
BOOL& isMenuPopup, TypeDockletAnim& typeAnim)
{
/*
* Animate the Icon
*/
YzDockletAnimateIcon(g_hWndDock, g_idDocklet);
return TRUE;
}
Building our Docklet
After writing the above code or using the leftClick.cpp file from the downloaded package. You then need to build it. Go to the
Build menu and select
Rebuild All or press F7 on the keyboard for a quick build.
By Default, VC++ builds docklet using a Debug mode. This is useful, because if, for some reason, your docklet generates an error the docklet will show a dialog box with the file and line information where the error occured.
However, to setup VC++ to build a Release version of the docklet (which is much smaller) you have to go back to the Build and select
Set Active Configuration.
On the Set Active Project Configuration window select leftClick - Win32 Release then press OK.
Rebuild the project as stated above. The DLL files associated to each configured project can be found at there
Debug and
Release folders inside the
DOCKLET_SDK\leftClick folder.
After the building is complete without any ERRORS, you can copy the built DLL file to the Y'z Dock's docklet folder. Right click on the Y'z Dock, click
Add Docklet and select the name of the docklet you created.
Comments/Suggestions/Problems
Please email me at albeik @ gmail.com
Terms of Use
You CAN reproduce, change and distribute this source code, without permission. No liability for the contents of this source code can be accepted. Use the concepts, examples and other content at your own risk.