Трудно найти человека, которые не знает или не использует Far - IMHO лучший клон NC для Windows. Кроме того, что это просто очень хороший файл менеджер, к нему есть огромное количество plug-in модулей. Plug-in модуль это DLL-файл, который вместо стандартных Windows функций по работе с монитором, клавиатурой и т.д. обращается к функциям Far-а.
Far поддерживает весь набор функций для работы в текстовом режиме. Установка plug-in модуля происходит предельно просто - DLL файл и файлы данных копируются в каталог в каталоге FarPlugins и Far перезапускается.
FAR распространяется с полным набором файлов для написания самим plug-in на любом С компиляторе для Windows. Темой этой статьи является написание этих модулей самим на Visual C++ (я использовал Visual C++ 5.0). При установке в каталог Far копируется PlugDoc.rar, в нем есть примеры plug-in-ов и header файл. Все примеры используются Еще там есть VCReadme.txt, в котором описываются тонкости работы с Visual C++. Потом поразбираетесь с примерами.
Мы с вами напишем plug-in, который получает список открытых окон Windows, он может пригодиться как заготовка для своих. И вообще - стоит начать - все это не так сложно, как можно подумать. Вот, а теперь - поехали:
1) Запускает VC, делаем новый проект типа "Win32 Dynamic-Link Library" по имени SimpleFP. Создает файл simplefp.cpp - здесь, собственно, мы и будем писать. В каталог SimpleFP копируем header файл plugin.hpp из архива PlugDoc.rar.
2) Теперь нам надо сделать .def файл - это файл, в котором описываются функции, которые вызываются из внешних модулей. Мы должны описать функции Far-а, которые мы будем использовать в нашем модуле. Делаем текстовый файл simplefp.def, в котором пишем:
LIBRARY
EXPORTS
GetPluginInfo=_GetPluginInfo@4
OpenPlugin=_OpenPlugin@8
SetStartupInfo=_SetStartupInfo@4
Здесь мы описываем 3 функции, которые нам пригодятся. А теперь добавим simpledef.def к файлам проекта (Project - Add to project - Files - simplefp.def).
3) Теперь пишем сам plug-in - работаем с файлом simplefp.cpp. Я решил дать текст самой программы с комментариями - можно скопировать в С++ и начать с ним возиться. Но сначала о основах.
Far работает по тем же принципам, что и Windows - вы ссылаетесь в программе на те функции, уже имеющиеся в системе, которые хотите использовать. Far предоставляет функции для работы с экранными формами в режиме console application. При запуске plug-in-а Far запускает функцию OpenPlugin, мы будем ее рассматривать как аналог main() или WinMain(). Но кроме этого надо еще сообщить Far-у данные о нашем plug-in-е. Это делает функция GetPluginInfo.
/*
* SimpleFP - простой plug-in к Far-у. (С) 2000 Phoenix, Moscow
*/
#include // для вызова sprintf
#include // для функций Windows
#include "plugin.hpp" // для функций Far
#define PLUGIN_NAME "Open windows" // Название plug-in-а
#define WINDOW_HEAD "Open windows list" // Заголовок меню, которое мы сделаем
//
// Описываем функции Far, которые с которыми мы работаем.
//
extern "C"
{
void WINAPI _export SetStartupInfo(struct PluginStartupInfo *Info);
HANDLE WINAPI _export OpenPlugin(int OpenFrom,int Item);
void WINAPI _export GetPluginInfo(struct PluginInfo *Info);
};
static struct PluginStartupInfo Info; // Информация о нашем plug-in-е
//
// Информация о модуле определена нами в структуре Info
//
void WINAPI _export SetStartupInfo(struct PluginStartupInfo *Info)
{
::Info=*Info;
}
// Эта функция вызывается для получения информации о plug-in.
// Мы должны заполнить поля структуры Info.
//
void WINAPI _export GetPluginInfo(struct PluginInfo *Info)
{
Info->StructSize=sizeof(*Info); // Размер структуры Info
Info->Flags=0; // Это нам не нужно
Info->DiskMenuStringsNumber=0; // Это нам тоже не нужно
// Определяем строку с названием модуля
static char *PluginMenuStrings[1];
PluginMenuStrings[0]= PLUGIN_NAME;
// Определяем название plug-in модуля
Info->PluginMenuStrings=PluginMenuStrings;
Info->PluginMenuStringsNumber=sizeof(PluginMenuStrings)/sizeof(PluginMenuStrings[0]);
Info->PluginConfigStringsNumber=0; // Это нам не нужно
}
// Эта функция вызывается при запуске plug-in модуля.
//
HANDLE WINAPI _export OpenPlugin(int OpenFrom,int Item)
{
HWND hwnd; // Используем для получения handle
char p[128], o[128]; // Для создания строк меню
int i=0; // Счетчик
struct FarMenuItem MenuItems[64]; // Описание меню, которое создаст для нас Far
memset(MenuItems,0,sizeof(MenuItems)); // Инициализируем наше меню
MenuItems[0].Selected=TRUE;
hwnd = GetDesktopWindow(); // Получаем handle для desktop
hwnd = GetWindow(hwnd, GW_CHILD); // Получаем его handle
while (hwnd !=0) // Пока оно не последнее
{
hwnd = GetWindow(hwnd, GW_HWNDNEXT); // получим handle окна
GetWindowText(hwnd,p,128); // и его заголовок
if (strlen(p)>0) // если заголовок есть
{
sprintf(o,"%0.8xld %s", hwnd, p); // сделаем строчку
strcpy(MenuItems[i++].Text, o); // скопируем эту строчку в массив MenuItems
}
}
// вызываем созданное нами меню, получаем номер выбранного пункта - MenuCode
//
int MenuCode=Info.Menu(Info.ModuleNumber,
-1,-1,0,
FMENU_AUTOHIGHLIGHT|FMENU_WRAPMODE,
WINDOW_HEAD,
NULL,
"Menu content",
NULL,
NULL,
MenuItems,
i);
return(INVALID_HANDLE_VALUE);
}
Компилируйте, копируйте в FarPlugin и перезапускайте Far. В Far-е нажмите F11 - это список plug-in модулей. Теперь в нем должна появиться строка Open windows. Посмотрите на результат. Теперь можно развивать, например - обрабатывая результат MenuCode посылать выбранному окну сообщение WM_CLOSE, или сделать еще что-нибудь нетривиальное :) Создание plug-in модулей к Far-у документирована замечательно, разбирайтесь.
Другие работы по теме:
Завадостійке кодування на основі циклічних кодів
Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CRC32", "CRC32CRC32.csproj", "{EE28F805-6DA0-4E7B-89A5-A3B245E1441D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {EE28F805-6DA0-4E7B-89A5-A3B245E1441D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EE28F805-6DA0-4E7B-89A5-A3B245E1441D}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE28F805-6DA0-4E7B-89A5-A3B245E1441D}.Release|Any CPU.ActiveCfg = Release|Any CPU {EE28F805-6DA0-4E7B-89A5-A3B245E1441D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE
Пример использования MFC в Visual C
В этой статье будет показано как включить потдержку MFC в Visual C++ на примере двух типов приложений: 1. Консольное приложение 2. Приложение типа Windows Application
Process Essay How To Change Essay
, Research Paper How to Change Your Oil Frequent oil changes are the best preventative maintenance the home mechanic can give the engine, because old oil becomes contaminated and or burnt, which leads to premature engine wear. Performing simple maintenance such as changing the oil can save hundreds of dollars over time, as well as building self-confidence in one s mechanical abilities.
Light Matter Essay Research Paper Inner LightIn
Light Matter Essay, Research Paper Inner Light In order to understand what light is one has to understand how vision works. The process of visual perception is incredibly complex, involving many functions of the brain. In Arthur Zajonc’s book “Catching the Light,” he writes, “?vision requires far more than a functioning physical organ.
Memory Techniques Essay Research Paper Psychology 345Research
Memory Techniques Essay, Research Paper Psychology 345Research paperObjective: I will relate three memories from my experiences at Texas A&M University to three different memory techniques discussed in the book. One memory that I will remember occurred this semester. It involved a girl who was killed in a car accident.
Musics Influence On People Essay Research Paper
Music is said to have a strong influence on how young impressionable minds live, think and act. However this can t be too much of a contreversy if tv. allows our minds not only be subject to the same ideas, but also it allows our young and innocent to have visual picture of what is going on. To the untrained this would seem like a crime, however this is just a process of growing up and we need to realize that kids will be kids and if we dont allow them to be explorative to what is going on in the world how will they ever be able to make rational grown decisions when their parents arent around?
Senseless A False Sense Of Perception Essay
, Research Paper Senseless: A False Sense of Perception I feel as though I have no choice but to be a skeptic about our ability to know the world on the sense experience given the information that is being
Convergence Of The Twain Essay Research Paper
“The Convergence of the Twain” Personification is “endowing inanimate objects or abstract ideas with life or human characteristics” (Kirszner 2058). In the poem “The Convergence of the Twain” the author?s use of personification allows the reader to make a more fluid transition from the past to the present.
Internet Usage Essay Research Paper Are Mainstream
Internet Usage Essay, Research Paper Are Mainstream Scientific Researchers Using the Internet to its full Multimedia Potential? As a research presentation medium, the Internet has been designed to offer vastly more to publishers than easy text access. It’s astoundingly simple to incorporate photographs, diagrams, illustrations, sounds, animations, movies and all kinds of non-text content into a website using today’s user-friendly web development software.
Technololgy Revealed Essay Research Paper
“Technology Revealed” The computer is no longer something new and special to many people nowadays, because many families now have at least one computer in their homes. When most
All My Flowers Are Gone Essay Research
Paper all my flowers are gone, to pools of faded colours. lost in seas of ripples each time I reach to touch. all my flowers are withered, dying, void of guidance.
Costa Sakellariou Essay Research Paper Costa Sakellariou
Costa Sakellariou Essay, Research Paper Costa Sakellariou Visual art can definitely be seen as a language. With every artist there is always some sort of meaning that they are trying to convey to the viewers of their work. The means of how they deliver that message is the language in which their work uses. In Costa Sakellariou?s work I especially felt there was some sort of language being spoken.
Learning Styles Compare
& Contrast Essay, Research Paper Learning Styles The purpose of this paper is to identify and compare the meaning as well as the differences of two learning styles as they relate to both the academic and professional realm. I have chosen these two styles because I believe the majority of people are either visual or auditory learners.
Tarzan Of The Apes Essay Research Paper
Tarzan of the Apes When I was reading the story, ?Tarzan of the Apes,? I realized that throughout the whole story he describes the characters very narrative. He describes specifically the characters feelings, movements and characteristics. On the following, I will write about how the author describes the characters to us readers and how it makes this story feel more realistic than what it is.
Visual Art Essay Research Paper VISUAL ARTS
Visual Art Essay, Research Paper VISUAL ARTS “The physical impossibility of death in the mind of someone living” By Damien Hirst (photo courtesy of the saatchi collection)
Visual Perception Development Essay Research Paper Devlopment
Visual Perception Development Essay, Research Paper Devlopment of Visual Perception The development of visual perception changes through the caurse of life time from birth through adulthood. Sight is produced by taking ?stimulation in the form of light and converting it to electrochemical signals to the brain.? Most of the development of visual perception takes place in infants and then declines in old age.
Dover Beach Essay Research Paper Dover Beachby
Dover Beach Essay, Research Paper ?Dover Beach? by: Matthew Arnold In the poem ?Dover Beach? by: Matthew Arnold there is a lot of irony, appeal to the auditory and visual sense, and illusions. The tone in this poem is very sad and dismal, but he shows us how to keep faith and hope in spite of that and how important being honest, true, and faithful to one another, really is.
Romeo Juliet- Comparison Between The Screenplay
And The 199 Essay, Research Paper Films are made with the directors different personal opinions based on the original screenplay. For the movie version of Romeo + Juliet (1996), the quote above illustrates this perfectly. For this essay, I will discuss contrasts between the original screenplay, and the film.
Television Essay Research Paper Televised debates between
Television Essay, Research Paper Televised debates between the nominees of the two major parties have become standard fare in contemporary presidential election campaigns. The authors of this important volume maintain that television has altered the very nature of presidential debates profoundly, that the demands of television have dictated the structure and formats of contemporary debates, and that the visual content of presidential debates plays an important role in the way that candidates exercise influence in televised debates.
Art 5 Essay Research Paper ArtArt comes
Art 5 Essay, Research Paper Art comes in many different forms. It isn t just visual work done on canvas using a certain medium, like pencils, watercolors, or oils. Art is just a way in which an individual expresses his or her inner most self, so that others can understand that individuals personality or feelings to their fullest.
What Are Visual Defects And How Common
Are They ? Essay, Research Paper What Are Visual Defects and How Common Are They ? Nate Schackow 2nd Period December 17, 1996 The human eye does alot more than allowing you to see. It is very
Windows 98 Vs Windows Me Essay Research
Paper Microsoft has remained at the top of the personal computer industry. It is the bar that other companies in their field must measure up to. The strong hold Microsoft has established is due in great part to the strength and popularity of their operating systems. Over the past year Microsoft has released Windows 2000, a network based OS to replace older Windows NT systems.
Pull The Plug Essay Research Paper Just
Pull The Plug Essay, Research Paper Just for a minute, imagine yourself no longer in control of your body. Your mind is not really very useful anymore either. You can t recognize anyone, you don t know who you are, and you will only get worse. You are in pain and the medicine is not doing the trick, but you can no longer communicate that fact.
Television
? – The Plug-In Drug? Essay, Research Paper Reader Response to: ?Television – The Plug-In Drug? I found this whole essay written by, Marie Winn, to be extremely interesting, and I also felt it was a very true reflection on today?s society. Who, in the past, would ever have thought that the television would be seen as a necessity in today?s household.
Plug And Play Essay Research Paper Plug
Plug And Play Essay, Research Paper Plug And Play Technological advances have swept our society into the twenty-first century. Many accessories have become easily compatible to take personal PC s to new heights. Windows 95 was the first operating system to offer the feature of plug and play. Adding new hardware to your computer is easier than ever because it is set up to communicate by means of an I/O address, interrupt request, and a direct memory access channel.
How To Change Oil In Your Car
Essay, Research Paper Jovon Moore English 110, order paper Mrs. Reeher 04-06-00 How to change oil in your car Many people may think changing the oil in your vehicle is a difficult and lengthy procedure. In fact, it?s not that tough if you follow a few basic steps. Draining the oil, placing the oil pan in the right place and putting on the new filter, shouldn?t be to hard after following these easy steps.
Windows 95 Beats Mac Essay Research Paper
Windows 95 Beats Mac Over the years, there has been much argument over which computer platform to buy. The two contenders in theis competions have been the PC , with its Windows
Aquarium Set Up Essay Research Paper Setting
Aquarium Set Up Essay, Research Paper Setting up an aquarium This is a step-by?step instruction for setting up an aquarium. We will discuss pertinent topics such as location, purpose, and setup. There are a several items you will need for your aquarium. I recommend at least a 20-gallon aquarium to start, but the size is up to you.
Procedure Essay Building Your Own Pc Essay
, Research Paper Building Your Own PC In the following paragraphs I will be instructing you step by step on how to build your own PC (Personal Computer). It is recommended that you have general knowledge on computers. This means that you need to know what the different parts are and what they do.
The Job Of A Graphic Designer Essay
, Research Paper Graphic designers create the visual presentation and design of goods, from gravestone markers to detergent boxes, from album covers to dog food cans (The Princeton Review Guide to Your Career.) Graphic artists, or graphic designers, are the bases of the graphic world. It is their designs that are sent to layout artists and then to the printers and then onto the outside world on cd covers, cereal boxes, billboards, posters, and basically anything that has to do with a visual representation.
Osmosis
Introduction: Osmosis is a net diffusion of water between two solutions that differ in solute concentration and that are separated by a selectively permeable membrane.