// Litestep calls this function after it loads the module. This is where the // module should register bang commands and create windows. If initialization // succeeds, return zero. If an error occurs, return a nonzero value. int initModuleEx(HWND hParent, HINSTANCE hInstance, const char *path) { // Ignore attempts to load the module more than once if (acidmail) { return 1; } hwndParent = hParent; hwndInstance = hInstance; // Create window for message handling WNDCLASS wc = { 0 }; wc.lpfnWndProc = WndProc; // the window procedure wc.hInstance = hInstance; // hInstance of DLL wc.lpszClassName = szAppName; // the window class name if (!RegisterClass(&wc)) { MessageBox(hwndParent, "Error: Could not register window class", szAppName, MB_OK | MB_ICONERROR); return 2; } hwndMain = CreateWindowEx(WS_EX_TOOLWINDOW, szAppName, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); if (!hwndMain) { MessageBox(hwndParent, "Error: Could create main window", szAppName, MB_OK | MB_ICONERROR); UnregisterClass(szAppName, hInstance); return 3; } // Initiate winsock WSADATA wsa; if (WSAStartup(MAKEWORD(2,2),&wsa)) { MessageBox(hwndParent, "Could not initialize winsock", szAppName, MB_OK | MB_ICONERROR); return 4; } // Register messages to Litestep SendMessage(hwndParent, LM_REGISTERMESSAGE, (WPARAM)hwndMain, (LPARAM)msgs); // Register bang commands AddBangCommand("!AcidMailCheckMail", BangCheckMail); AddBangCommand("!AcidMailClearNew", BangClearNew); AddBangCommand("!AcidMailSetPass", BangSetPass); // Create main class instance acidmail = new Acidmail(); return 0; }
void LSUtils::InsertBangs(const Bang banglist[], const int nrofbangs) { if (banglist == NULL) return; for (int i = 0; i < nrofbangs; i++) AddBangCommand(banglist[i].bangName, *banglist[i].bangFunc); }
void LSUtils::PrefixedInsertBangs(LPCTSTR prefix, const Bang banglist[], const int nrofbangs) { if (banglist == NULL) return; LPTSTR szTemp; LPTSTR bangPrefix; bool prefixed = false; if ( _tcsncmp(prefix, TEXT("!"), 1 ) != 0) { AppendSetting(TEXT("!"), prefix, bangPrefix); prefixed = true; } for (int i = 0; i < nrofbangs; i++) { AppendSetting(bangPrefix, banglist[i].bangName, szTemp); AddBangCommand(szTemp, *banglist[i].bangFunc); delete [] szTemp; } if (prefixed) delete [] bangPrefix; }
int initModuleEx(HWND hParent, HINSTANCE hInstance, const char *lsPath) { WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_GLOBALCLASS | CS_DBLCLKS; wc.lpfnWndProc = Label::windowProcedure; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(Label *); wc.hInstance = hInstance; wc.hbrBackground = 0; wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hIcon = 0; wc.lpszMenuName = 0; wc.lpszClassName = "LabelLS"; wc.hIconSm = 0; RegisterClassEx(&wc); wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_GLOBALCLASS; wc.lpfnWndProc = MessageHandlerProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hbrBackground = 0; wc.hCursor = 0; wc.hIcon = 0; wc.lpszMenuName = 0; wc.lpszClassName = "LabelMessageHandlerLS"; wc.hIconSm = 0; RegisterClassEx(&wc); messageHandler = CreateWindowEx(WS_EX_TOOLWINDOW, "LabelMessageHandlerLS", 0, WS_POPUP, 0, 0, 0, 0, 0, 0, hInstance, 0); if (!messageHandler) return 1; SendMessage(GetLitestepWnd(), LM_REGISTERMESSAGE, (WPARAM) messageHandler, (LPARAM) lsMessages); ::hInstance = hInstance; defaultSettings = new LabelSettings(); systemInfo = new SystemInfo(); StringList labelNames = GetRCNameList("Labels"); labelNames.merge(GetRCNameList("Label")); // if(labelNames.empty()) labelNames.insert(labelNames.end(), "Label"); for(StringListIterator it = labelNames.begin(); it != labelNames.end(); it++) { if(GetRCBoolean(*it, "LSBoxName")) continue; Label *label = new Label(*it); label->load(hInstance); labelList.insert(labelList.end(), label); } AddBangCommand("!LabelCreate", CreateLabelBangCommand); AddBangCommand("!LabelDebug", DebugBangCommand); //LsBox Support - blkhawk AddBangCommand("!LabelLsBoxHook", LsBoxHookBangCommand); return 0; }