changed from OnCommand to OnMessage for more flexiblity with plugins

import/tags/kmeleon03
binaryc 22 years ago
parent 4fd80d2c98
commit b2303650a7
  1. 10
      k-meleon/MainFrm.cpp
  2. 1
      k-meleon/MainFrm.h
  3. 8
      k-meleon/Plugins.cpp
  4. 2
      k-meleon/Plugins.h
  5. 30
      k-meleon/ie_favorites/ie_favorites.cpp
  6. 6
      k-meleon/ie_favorites/ie_favorites.dsp
  7. 5
      k-meleon/kmeleon_plugin.h
  8. 24
      k-meleon/kmeleon_winamp/kmeleon_winamp.cpp
  9. 8
      k-meleon/ns_bookmarks/ns_bookmarks.cpp

@ -335,11 +335,15 @@ void CMainFrame::Dump(CDumpContext& dc) const
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
LRESULT CMainFrame::WindowProc( UINT message, WPARAM wParam, LPARAM lParam ){
theApp.plugins.OnMessage(this->m_hWnd, message, wParam, lParam);
return CFrameWnd::WindowProc(message, wParam, lParam);
}
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) {
if (nCode == CN_COMMAND){
if (!pHandlerInfo){
theApp.plugins.OnCommand(nID);
}else if (theApp.plugins.OnUpdate(nID)){
if (pHandlerInfo && theApp.plugins.OnUpdate(nID)){
return true;
}
}

@ -152,6 +152,7 @@ protected:
DECLARE_MESSAGE_MAP()
BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam );
};
/////////////////////////////////////////////////////////////////////////////

@ -74,17 +74,19 @@ int CPlugins::OnUpdate(UINT command){
}
// TODO: when a plugin calls GetCommandIDs, register it, then only send them those messages
void CPlugins::OnCommand(UINT command){
void CPlugins::OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam){
/*
if (!OnUpdate(command)){
return;
}
*/
POSITION pos = pluginList.GetStartPosition();
kmeleonPlugin * kPlugin;
CString s;
while (pos){
pluginList.GetNextAssoc( pos, s, kPlugin);
if (kPlugin && kPlugin->OnCommand){
kPlugin->OnCommand(command);
if (kPlugin && kPlugin->OnMessage){
kPlugin->OnMessage(wnd, message, wParam, lParam);
}
}
}

@ -39,7 +39,7 @@ public:
int FindAndLoad(char *pattern);
kmeleonPlugin * Load(const char *pattern);
void OnCommand(UINT command);
void OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam);
int OnUpdate(UINT command);
void DoRebars(HWND rebarWnd);

@ -48,7 +48,7 @@ void Config(HWND parent);
void Quit();
HGLOBAL GetMenu();
void DoMenu(HMENU menu, char *param);
void OnCommand(UINT command);
void OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam);
kmeleonPlugin kPlugin = {
KMEL_PLUGIN_VER,
@ -57,7 +57,8 @@ kmeleonPlugin kPlugin = {
Config,
Quit,
DoMenu,
OnCommand
NULL,
OnMessage
};
CMenu m_menuFavorites;
@ -263,17 +264,20 @@ void DoMenu(HMENU menu, char *param){
}
}
void OnCommand(UINT command){
if (command == nConfigCommand){
Config(NULL);
return;
}
if (command == nAddCommand){
//AppendMenu(mainMenu, MF_STRING, nFirstFavoriteCommand, "New Item");
return;
}
if (command >= nFirstFavoriteCommand && command < (nFirstFavoriteCommand + MAX_FAVORITES)){
kPlugin.NavigateTo((char *)(LPCTSTR)m_astrFavoriteURLs.GetAt(command - nFirstFavoriteCommand), 0);
void OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam){
if (message == WM_COMMAND){
WORD command = LOWORD(wParam);
if (command == nConfigCommand){
Config(NULL);
return;
}
if (command == nAddCommand){
//AppendMenu(mainMenu, MF_STRING, nFirstFavoriteCommand, "New Item");
return;
}
if (command >= nFirstFavoriteCommand && command < (nFirstFavoriteCommand + MAX_FAVORITES)){
kPlugin.NavigateTo((char *)(LPCTSTR)m_astrFavoriteURLs.GetAt(command - nFirstFavoriteCommand), 0);
}
}
}

@ -53,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"c:/projects/mozilla/mozilla/dist/win32_o.obj/bin/kmeleon_favorites.dll"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"c:/projects/mozilla/mozilla/dist/win32_o.obj/bin/kmeleon_favorites.dll"
!ELSEIF "$(CFG)" == "ie_favorites - Win32 Debug"
@ -68,8 +68,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IE_FAVORITES_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IE_FAVORITES_EXPORTS" /D "_WINDLL" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IE_FAVORITES_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IE_FAVORITES_EXPORTS" /D "_WINDLL" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"

@ -33,11 +33,10 @@ typedef struct {
void (*Config)(HWND parent);
void (*Quit)();
void (*DoMenu)(HMENU menu, char *param);
void (*OnCommand)(UINT command);
// return false to disable the item
//int (*CommandUpdate)(UINT command);
void (*DoRebar)(HWND rebarWnd);
void (*OnMessage)(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam);
// Filled in by k-meleon
// this function allocates <num> successive ids for the plugin, then returns the first one.
// use it to get an unused command id. this way plugins won't step on others toes.

@ -46,8 +46,8 @@ void Config(HWND parent);
void Quit();
HGLOBAL GetMenu();
void DoMenu(HMENU menu, char *param);
void OnCommand(UINT command);
void DoRebar(HWND rebarWnd);
void OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam);
kmeleonPlugin kPlugin = {
KMEL_PLUGIN_VER,
@ -56,8 +56,8 @@ kmeleonPlugin kPlugin = {
Config,
Quit,
DoMenu,
OnCommand,
DoRebar
DoRebar,
OnMessage
};
HBITMAP prevBmp;
@ -113,16 +113,17 @@ void DoRebar(HWND rebarWnd){
for (i=0; i<numCommands; i++){
buttons[i].iBitmap = i;
buttons[i].idCommand = commandIDs + i;
buttons[i].iString = i + 1;
buttons[i].dwData = 0;
buttons[i].fsState = TBSTATE_ENABLED;
buttons[i].fsStyle = TBSTYLE_BUTTON;
buttons[i].iString = 0;
buttons[i].bReserved[0] = 0;
};
DWORD dwStyle = 0x40 | CCS_NOPARENTALIGN | CCS_NORESIZE | /*CCS_NOMOVEY | */
TBSTYLE_FLAT | /*TBSTYLE_AUTOSIZE | TBSTYLE_LIST |*/ TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT;
DWORD dwStyle = 0x40 | /*the 40 gets rid of an ugly border on top. I have no idea what flag it corresponds to...*/
CCS_NOPARENTALIGN | CCS_NORESIZE |
TBSTYLE_FLAT | TBSTYLE_TRANSPARENT /* | TBSTYLE_AUTOSIZE | TBSTYLE_LIST | TBSTYLE_TOOLTIPS */;
// Create the toolbar control to be added.
HWND hwndTB = CreateToolbarEx(rebarWnd, dwStyle,
@ -169,10 +170,13 @@ void DoRebar(HWND rebarWnd){
SendMessage(rebarWnd, RB_MAXIMIZEBAND, (WPARAM)bandPos, (LPARAM)true);
}
void OnCommand(UINT command){
if (command >= commandIDs && command < (commandIDs + numCommands)){
HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);
SendMessage(hwndWinamp, WM_COMMAND, commandTable[command - commandIDs], 0);
void OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam){
if (message == WM_COMMAND){
WORD command = LOWORD(wParam);
if (command >= commandIDs && command < (commandIDs + numCommands)){
HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);
SendMessage(hwndWinamp, WM_COMMAND, commandTable[command - commandIDs], 0);
}
}
}

@ -43,7 +43,7 @@ void Config(HWND parent);
void Quit();
HGLOBAL GetMenu();
void DoMenu(HMENU menu, char *param);
void OnCommand(UINT command);
void OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam);
kmeleonPlugin kPlugin = {
KMEL_PLUGIN_VER,
@ -52,7 +52,8 @@ kmeleonPlugin kPlugin = {
Config,
Quit,
DoMenu,
OnCommand
NULL,
OnMessage
};
HMENU mainMenu = NULL;
@ -75,8 +76,7 @@ void DoMenu(HMENU menu, char *param){
}
void OnCommand(UINT command){
void OnMessage(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam){
}
// so it doesn't munge the function name

Loading…
Cancel
Save