Module API / Example

New SDK files can be downloaded here:

http://mpj.tomaatnet.nl/AveDesk12_sdk_files.zip

Documentation should come really soon, still too busy with real life.

// AveDesk 1.2 Module Example

// (c) Andreas Verhoeven 2005



// Please use an .aveinst package for distributing

// your modules. AveInst packages can be configured

// to automatically install and run the module for the user.

// check out the Documents/Installer folder in the AveDesk 1.2

// directory.





#define UNICODE

#include <windows.h>



// optional

//include "DeskletSDK.h"

//include "DeskletSDK.cpp" //- or better, add it to your project





//

// This struct will be used to store variables used by an

// instance of this module.

//

struct MODULE_STRUCT

{

BOOL wasVisible;

HWND listView;

};





//

// helper function

//

HWND FindIconsListView()

{

// post: the handle of the desktop's listview has been returned.



HWND progMan = FindWindow(TEXT("Progman"),NULL);

if(NULL == progMan)

return NULL;



HWND defView = FindWindowEx(progMan,NULL,TEXT("SHELLDLL_DefView"),NULL);

if(NULL == defView)

return NULL;



HWND listView = FindWindowEx(defView,NULL,TEXT("SysListView32"),NULL);



return listView;

}



//

// This function is used to collect information about your module. It is _not_

// mandatory, but it's nice towards the users.

// The parameters and it's working is trivial.

// NOTE THAT THIS FUNCTION IS ANSI, NOT UNICODE.

//

// You should export this function in a .def file if you use it.

//

void __stdcall OnGetInformation(char* name, char* author, int* version, char* descr)

{

strcpy(name,"Hide Desktop Icons");

strcpy(author,"Andreas Verhoeven");

strcpy(descr,"This module will hide your desktop icons when it's loaded.");

*version = 100;

}



//

// This function is mandatory and will be called when an instance

// of your module is be created.

// You can return a pointer to anything actually. Here, we choose

// to use a pointer to a just allocated MODULE_STRUCT structure

// so we can hold some variables. All callback functions called

// in the context of this module instance will get this pointer

// again as an argument.

//

// You should export this function in a .def file.

//

MODULE_STRUCT* __stdcall OnCreate()

{

// create a new MODULE_STRUCT structure to store some variables.

MODULE_STRUCT* ms = new MODULE_STRUCT;



// also, initialize the variables we use.

ms->wasVisible = FALSE;

ms->listView = FindIconsListView();



// if the desktop's listview that holds the icons was found,

// we hide it.

if(ms->listView != NULL)

{

ms->wasVisible = IsWindowVisible(ms->listView);

ShowWindow(ms->listView,SW_HIDE);

}





return ms;

}



//

// This function will be called when an instance of

// your module is destroyed. You should release all memory,

// exit all threads, destroy all windows, you created and

// perform other cleanups.

// The only argument is the pointer you returned in the matching

// OnCreate() call.

//

// You should export this function in a .def file.

//

void __stdcall OnDestroy(MODULE_STRUCT* ms)

{

if(NULL == ms)

return;



// if the listview was actually visible before and was there,

// we make it visible again.

if(ms->wasVisible && ms->listView != NULL)

{

ShowWindow(ms->listView,SW_SHOW);

}



delete ms;

};











//

// This function will be called when a user wants to configure

// an instance of your module.

// The only argument is the pointer you returned in the matching

// OnCreate() call.

//

// You should export this function in a .def file.

//

void __stdcall OnConfigure(MODULE_STRUCT* ms)

{

// maybe show a configure dialog here?

}

#266119

damn :)

no weekend now... trying this....

#267011