diff options
author | George Hazan <george.hazan@gmail.com> | 2012-12-01 13:25:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-12-01 13:25:11 +0000 |
commit | 854959cbc0a1bad2c086214be4d1a829b17a61f3 (patch) | |
tree | ee3de50f4b4e57f54ae20d139f97fa469ff90d34 /plugins/QuickMessages/src/main.cpp | |
parent | 73ddc73d92675399e4619758d4b0881418de0a6d (diff) |
icolib: icon creation quirks
git-svn-id: http://svn.miranda-ng.org/main/trunk@2588 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/QuickMessages/src/main.cpp')
-rw-r--r-- | plugins/QuickMessages/src/main.cpp | 216 |
1 files changed, 92 insertions, 124 deletions
diff --git a/plugins/QuickMessages/src/main.cpp b/plugins/QuickMessages/src/main.cpp index e13d075041..7fba5f8e4e 100644 --- a/plugins/QuickMessages/src/main.cpp +++ b/plugins/QuickMessages/src/main.cpp @@ -20,13 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "quickmessages.h"
HINSTANCE hinstance;
+int hLangpack;
WNDPROC mainProc;
-HANDLE hEventCBButtonPressed, hEventCBInit,hEventInputMenu, hEventDbOptionsInit, hEventDbPluginsLoaded,
-hEventDbPreShutdown;
-HICON hIcon;
-
int g_iButtonsCount=0;
int g_bShutDown=0;
int g_bStartup=0;
@@ -34,9 +31,6 @@ BOOL g_bRClickAuto=0; BOOL g_bLClickAuto=0;
BOOL g_bQuickMenu=0;
-
-int hLangpack;
-
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
MODULENAME,
@@ -53,16 +47,8 @@ PLUGININFOEX pluginInfo = { int PreShutdown(WPARAM wparam,LPARAM lparam)
{
- g_bShutDown=1;
+ g_bShutDown = 1;
DestructButtonsList();
-
- if(hEventCBButtonPressed) UnhookEvent(hEventCBButtonPressed);
- if(hEventCBInit) UnhookEvent(hEventCBInit);
- if(hEventInputMenu) UnhookEvent(hEventInputMenu);
- UnhookEvent(hEventDbPluginsLoaded);
- UnhookEvent(hEventDbOptionsInit);
- UnhookEvent(hEventDbPreShutdown);
-
return 0;
}
@@ -74,28 +60,28 @@ static int InputMenuPopup(WPARAM wParam,LPARAM lParam) if(mwpd->uFlags==MSG_WINDOWPOPUP_LOG||!g_bQuickMenu||!QuickList->realCount) return 0;
if(mwpd->uType==MSG_WINDOWPOPUP_SHOWING)
- {
+ {
hSubMenu = CreatePopupMenu();
InsertMenu((HMENU)mwpd->hMenu,6,MF_STRING|MF_POPUP|MF_BYPOSITION,(UINT_PTR)hSubMenu,TranslateT("Quick Messages"));
InsertMenu((HMENU)mwpd->hMenu,7,MF_SEPARATOR|MF_BYPOSITION,0,0);
qsort(QuickList->items,QuickList->realCount,sizeof(QuickData *),sstQuickSortButtons);
for(i=0;i<QuickList->realCount;i++)
- {
+ {
QuickData* qd= (QuickData *)QuickList->items[i];
if(qd->fEntryType&QMF_EX_SEPARATOR)
AppendMenu(hSubMenu,MF_SEPARATOR,0,NULL);
else
AppendMenu(hSubMenu,MF_STRING,qd->dwPos+254,qd->ptszValueName);
- }
}
+ }
else if(mwpd->uType==MSG_WINDOWPOPUP_SELECTED&&mwpd->selection>=254)
- {
+ {
for(i=0;i<QuickList->realCount;i++)
- {
+ {
QuickData* qd= (QuickData *)QuickList->items[i];
if ((qd->dwPos+254)==mwpd->selection)
- {
+ {
CHARRANGE cr;
UINT textlenght=0;
TCHAR* pszText=NULL;
@@ -116,25 +102,25 @@ static int InputMenuPopup(WPARAM wParam,LPARAM lParam) pszCBText=mir_tstrdup(chBuffer);
GlobalUnlock(hData);
CloseClipboard();
- }
}
+ }
SendMessage(mwpd->hwnd, EM_EXGETSEL, 0, (LPARAM)&cr);
textlenght=cr.cpMax-cr.cpMin;
if(textlenght)
- {
+ {
pszText = (TCHAR *)mir_alloc((textlenght+10)*sizeof(TCHAR));
ZeroMemory(pszText,(textlenght+10)*sizeof(TCHAR));
SendMessage(mwpd->hwnd,EM_GETSELTEXT, 0, (LPARAM)pszText);
- }
+ }
if(qd->ptszValue){
- ptszQValue=ParseString(mwpd->hContact,qd->ptszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(qd->ptszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ ptszQValue=ParseString(mwpd->hContact,qd->ptszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(qd->ptszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
if ((bIsService=qd->bIsService)&&ptszQValue)
CallService(mir_u2a(ptszQValue),(WPARAM)mwpd->hContact,0);
- }
+ }
if(ptszQValue)
SendMessage(mwpd->hwnd, EM_REPLACESEL, TRUE, (LPARAM)ptszQValue);
@@ -143,10 +129,10 @@ static int InputMenuPopup(WPARAM wParam,LPARAM lParam) if(ptszQValue) free(ptszQValue);
if(pszCBText) mir_free(pszCBText);
break;
- }
}
- return 1;
}
+ return 1;
+ }
return 0;
}
@@ -191,11 +177,8 @@ static int CustomButtonPressed(WPARAM wParam,LPARAM lParam) pszCBText=mir_tstrdup(chBuffer);
GlobalUnlock(hData);
CloseClipboard();
- }
}
-
-
-
+ }
qsort(sl->items,sl->realCount,sizeof(ButtonData *),sstSortButtons);
@@ -207,11 +190,11 @@ static int CustomButtonPressed(WPARAM wParam,LPARAM lParam) textlenght=cr.cpMax-cr.cpMin;
if(textlenght)
- {
+ {
pszText = (TCHAR *)mir_alloc((textlenght+10)*sizeof(TCHAR));
ZeroMemory(pszText,(textlenght+10)*sizeof(TCHAR));
SendMessage(hEdit,EM_GETSELTEXT, 0, (LPARAM)pszText);
- }
+ }
if(cbcd->flags&BBCF_RIGHTBUTTON)
state=1;
@@ -220,118 +203,105 @@ static int CustomButtonPressed(WPARAM wParam,LPARAM lParam) else
state=3;
+ switch(state) {
+ case 1:
+ if(ButtonsList[cbcd->dwButtonId]->ptszQValue)
+ ptszQValue = ParseString(cbcd->hContact,ButtonsList[cbcd->dwButtonId]->ptszQValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(ButtonsList[cbcd->dwButtonId]->ptszQValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ if ((bIsService = ButtonsList[cbcd->dwButtonId]->bIsServName) && ptszQValue)
+ CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ break;
- switch(state)
+ case 2:
{
- case 1:
- if(ButtonsList[cbcd->dwButtonId]->ptszQValue)
- ptszQValue=ParseString(cbcd->hContact,ButtonsList[cbcd->dwButtonId]->ptszQValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(ButtonsList[cbcd->dwButtonId]->ptszQValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
- if ((bIsService=ButtonsList[cbcd->dwButtonId]->bIsServName)&&ptszQValue)
-
- CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ ButtonData *bd = (ButtonData *)sl->items[0];
+ if(bd && bd->pszValue){
+ ptszQValue = ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ if ((bIsService = bd->bIsServName)&&ptszQValue)
+ CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ }
+ }
+ break;
- break;
- case 2:
- {
- ButtonData * bd=NULL;
- bd=(ButtonData *)sl->items[0];
- if(bd&&bd->pszValue){
- ptszQValue=ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
- if ((bIsService=bd->bIsServName)&&ptszQValue)
+ case 3:
+ int res=0;
+ int menunum;
+ ButtonData * bd=NULL;
+ HMENU hMenu=NULL,hSubMenu=NULL;
+ BOOL bSetPopUpMark=FALSE;
- CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ if(g_iButtonsCount){
+ hMenu = CreatePopupMenu();
+ }
+ else break;
+ for(menunum=0;menunum<sl->realCount;menunum++)
+ {
+ bd=(ButtonData *)sl->items[menunum];
+ if(bd->dwOPFlags&QMF_NEW)
+ continue;
- }
+ bSetPopUpMark=FALSE;
+ if(bd->pszValue==0&&bd->fEntryType==0)
+ {
+ hSubMenu = CreatePopupMenu();
+ bSetPopUpMark=TRUE;
}
- break;
- case 3:{
- int res=0;
- int menunum;
- ButtonData * bd=NULL;
- HMENU hMenu=NULL,hSubMenu=NULL;
- BOOL bSetPopUpMark=FALSE;
-
- if(g_iButtonsCount){
- hMenu = CreatePopupMenu();
- }
- else break;
- for(menunum=0;menunum<sl->realCount;menunum++)
- {
- bd=(ButtonData *)sl->items[menunum];
- if(bd->dwOPFlags&QMF_NEW)
- continue;
-
- bSetPopUpMark=FALSE;
- if(bd->pszValue==0&&bd->fEntryType==0)
- {
- hSubMenu = CreatePopupMenu();
- bSetPopUpMark=TRUE;
- }
-
- if(bd->pszValue&&bd->fEntryType==0)
- hSubMenu=NULL;
- if(bd->fEntryType&QMF_EX_SEPARATOR)
- AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),MF_SEPARATOR,0,NULL);
- else
- AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),
- MF_STRING|(bSetPopUpMark?MF_POPUP:0),
- (bSetPopUpMark?(UINT_PTR)hSubMenu:(menunum+1)), bd->pszName);
- }
+ if(bd->pszValue&&bd->fEntryType==0)
+ hSubMenu=NULL;
- res = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL);
- if(res==0) break;
-
- bd= (ButtonData *)sl->items[res-1];
- bCTRL=(GetKeyState(VK_CONTROL)&0x8000)?1:0;
- if(bd->pszValue){
- ptszQValue=ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
- if ((bIsService=bd->bIsServName)&&ptszQValue)
+ if(bd->fEntryType&QMF_EX_SEPARATOR)
+ AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),MF_SEPARATOR,0,NULL);
+ else
+ AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),
+ MF_STRING|(bSetPopUpMark?MF_POPUP:0),
+ (bSetPopUpMark?(UINT_PTR)hSubMenu:(menunum+1)), bd->pszName);
+ }
- CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ res = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL);
+ if(res==0) break;
- }
- }break;
+ bd= (ButtonData *)sl->items[res-1];
+ bCTRL=(GetKeyState(VK_CONTROL)&0x8000)?1:0;
+ if(bd->pszValue){
+ ptszQValue=ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ if ((bIsService=bd->bIsServName)&&ptszQValue)
+ CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
}
+ break;
+ }
-
- if(ptszQValue){
- if (!bIsService){
+ if(ptszQValue) {
+ if (!bIsService) {
SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)ptszQValue);
if ((g_bLClickAuto&&state!=1)||(g_bRClickAuto&&state==1)||cbcd->flags&BBCF_CONTROLPRESSED||bCTRL)
SendMessage(cbcd->hwndFrom, WM_COMMAND,IDOK,0);
}
free(ptszQValue);
- }
+ }
- if(pszText) mir_free(pszText);
- if(pszCBText) mir_free(pszCBText);
+ mir_free(pszText);
+ mir_free(pszCBText);
return 1;
}
-
static int PluginInit(WPARAM wparam,LPARAM lparam)
{
- g_bStartup=1;
- hEventDbOptionsInit=HookEvent(ME_OPT_INITIALISE,OptionsInit);
- hEventCBButtonPressed=HookEvent(ME_MSG_BUTTONPRESSED,CustomButtonPressed);
- hEventCBInit=HookEvent(ME_MSG_TOOLBARLOADED,RegisterCustomButton);
-
- hEventInputMenu=HookEvent(ME_MSG_WINDOWPOPUP,InputMenuPopup);
-
-
- g_bRClickAuto=DBGetContactSettingByte(NULL,PLGNAME,"RClickAuto",0);
- g_bLClickAuto=DBGetContactSettingByte(NULL,PLGNAME,"LClickAuto",0);
- g_iButtonsCount=DBGetContactSettingByte(NULL, PLGNAME,"ButtonsCount", 0);
- g_bQuickMenu=DBGetContactSettingByte(NULL, PLGNAME,"QuickMenu", 1);
+ g_bStartup = 1;
+ HookEvent(ME_OPT_INITIALISE, OptionsInit);
+ HookEvent(ME_MSG_BUTTONPRESSED, CustomButtonPressed);
+ HookEvent(ME_MSG_TOOLBARLOADED, RegisterCustomButton);
+ HookEvent(ME_MSG_WINDOWPOPUP, InputMenuPopup);
- hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_QICON));
+ g_bRClickAuto = DBGetContactSettingByte(NULL,PLGNAME,"RClickAuto",0);
+ g_bLClickAuto = DBGetContactSettingByte(NULL,PLGNAME,"LClickAuto",0);
+ g_iButtonsCount = DBGetContactSettingByte(NULL, PLGNAME,"ButtonsCount", 0);
+ g_bQuickMenu = DBGetContactSettingByte(NULL, PLGNAME,"QuickMenu", 1);
InitButtonsList();
- g_bStartup=0;
+ g_bStartup = 0;
return 0;
}
@@ -347,17 +317,15 @@ extern "C" __declspec(dllexport) int Unload(void) BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
{
- hinstance=hinst;
+ hinstance = hinst;
return 1;
}
extern "C" __declspec(dllexport) int Load(void)
{
-
-
mir_getLP(&pluginInfo);
- hEventDbPluginsLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,PluginInit);
- hEventDbPreShutdown=HookEvent(ME_SYSTEM_PRESHUTDOWN,PreShutdown);
+ HookEvent(ME_SYSTEM_MODULESLOADED,PluginInit);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN,PreShutdown);
return 0;
-}
\ No newline at end of file +}
|