Exemplo n.º 1
0
int OkToExit(WPARAM, LPARAM)
{
	int exitmode = db_get_b(NULL, MODNAME, "ShutdownMode", 2);
	DONT = 1;
	if (exitmode == 2 && session_list[0] != 0) {
		SaveSessionDate();
		SaveSessionHandles(0, 0);
		db_set_b(NULL, MODNAME, "lastempty", 0);
	}
	else if (exitmode == 1 && session_list[0] != 0) {
		DialogBox(g_hInst, MAKEINTRESOURCE(IDD_EXDIALOG), 0, ExitDlgProc);
	}
	else db_set_b(NULL, MODNAME, "lastempty", 1);
	return 0;
}
Exemplo n.º 2
0
INT_PTR CALLBACK ExitDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{
	switch(msg)
	{
		case WM_INITDIALOG:
		{
			TranslateDialogDefault(hdlg);
			LoadPosition(hdlg, "ExitDlg");
			ShowWindow(hdlg,SW_SHOW);
		}break;

	case WM_COMMAND:
		switch(LOWORD(wparam))
		{
			case IDOK:
			{
				SavePosition(hdlg, "ExitDlg");
				SaveSessionDate();
				SaveSessionHandles(0,0);
				db_set_b(NULL, MODNAME, "lastempty", 0);
				DestroyWindow(hdlg);
			}break;

			case IDCANCEL:
			{
				SavePosition(hdlg, "ExitDlg");
				db_set_b(NULL, MODNAME, "lastempty", 1);
				DestroyWindow(hdlg);
			}break;
		}

	case WM_CLOSE:
		DestroyWindow(hdlg);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return FALSE;
	}
	return TRUE;
}
Exemplo n.º 3
0
INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{
	g_hSDlg = hdlg;
	switch(msg)
	{
		case WM_INITDIALOG:
		{
			HWND hList;
			hList = GetDlgItem(hdlg, IDC_LIST);
			TranslateDialogDefault(hdlg);
			LoadSessionToCombobox(hdlg, 1, 5, "UserSessionDsc", 0);

			LoadPosition(hdlg, "SaveDlg");
			ShowWindow(hdlg, SW_SHOW);
		}break;

		case WM_CLOSE:
			DestroyWindow(hdlg);
			g_hSDlg = 0;
			break;

		case WM_NOTIFY:
		{
			switch (((LPNMHDR) lparam)->idFrom)
			{
				case IDC_CLIST:
					switch (((LPNMHDR)lparam)->code)
					{
						case CLN_CHECKCHANGED:
						{
							bSC = TRUE;
							memcpy(user_session_list, session_list, SIZEOF(user_session_list));
						}break;

					}
			}break;
		}break;

		case WM_COMMAND:
			switch(LOWORD(wparam))
			{
				case IDC_SELCONTACTS:
				{
					HANDLE hItem;
					RECT rWnd;
					int i=0, x=0,y=0,dy=0,dx=0,dd=0;

					GetWindowRect(hdlg, &rWnd);
					x=rWnd.right-rWnd.left;
					y=rWnd.bottom-rWnd.top;
					if (IsDlgButtonChecked(hdlg,IDC_SELCONTACTS))
					{
						EnableWindow(GetDlgItem(hdlg,IDC_SANDCCHECK),FALSE);
						dy=20;
						dx=150;
						dd=5;
						hClistControl = CreateWindowEx(WS_EX_CLIENTEDGE, _T(CLISTCONTROL_CLASS), _T(""),
						WS_TABSTOP |WS_VISIBLE | WS_CHILD ,
						x, y, dx, dy, hdlg, (HMENU)IDC_CLIST, hinstance, 0);

						SetWindowLongPtr(hClistControl, GWL_STYLE,
							GetWindowLongPtr(hClistControl, GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES);
						SendMessage(hClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0);
					}
					else
					{
						EnableWindow(GetDlgItem(hdlg,IDC_SANDCCHECK),TRUE);
						dy=-20;
						dx=-150;
						dd=5;
						DestroyWindow(hClistControl);
					}

					SetWindowPos(hdlg, NULL, rWnd.left,rWnd.top, x+dx, y+(dx/3), SWP_NOZORDER | SWP_NOOWNERZORDER|SWP_NOMOVE);

					SetWindowPos(hClistControl,0,x-dd,dd,dx-dd,y+(dx/12),SWP_NOZORDER/*|SWP_NOSIZE|SWP_SHOWWINDOW*/);
					SendMessage(hClistControl,WM_TIMER,TIMERID_REBUILDAFTER,0);

					for ( i = 0; session_list[i] > 0; i++)
					{
						hItem=(HANDLE)SendMessage(hClistControl,CLM_FINDCONTACT, (WPARAM)session_list[i], 0);
						SendMessage(hClistControl, CLM_SETCHECKMARK, (WPARAM)hItem,1);
					}

					OffsetWindow(hdlg, GetDlgItem(hdlg,IDC_LIST), 0, dy);
					OffsetWindow(hdlg, GetDlgItem(hdlg,IDC_STATIC), 0, dy);
					OffsetWindow(hdlg, GetDlgItem(hdlg,IDC_SANDCCHECK), 0, dy);
					OffsetWindow(hdlg, GetDlgItem(hdlg,IDOK), 0, dy);
					OffsetWindow(hdlg, GetDlgItem(hdlg,IDCANCEL), 0, dy);

				}break;

				case IDOK:
				{
					DWORD session_list_temp[255]={0};
					int lenght,i = 0;
					TCHAR szUserSessionName[MAX_PATH];
					lenght = GetWindowTextLength(GetDlgItem(hdlg, IDC_LIST));
					SavePosition(hdlg, "SaveDlg");
					if (lenght>0) {
						GetWindowText(GetDlgItem(hdlg, IDC_LIST), szUserSessionName, SIZEOF(szUserSessionName));
						szUserSessionName[lenght+1]='\0';
						if (IsDlgButtonChecked(hdlg,IDC_SELCONTACTS)&&bSC) {
							for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
								BYTE res =(BYTE)SendMessage(hClistControl, CLM_GETCHECKMARK, SendMessage(hClistControl, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
								if (res) {
									user_session_list[i] = hContact;
									i++;
								}
							}
							memcpy(session_list_temp,session_list,SIZEOF(session_list_temp));
							memcpy(session_list,user_session_list,SIZEOF(session_list));
							SaveSessionHandles(0,1);
							SaveUserSessionName(szUserSessionName);
							memcpy(session_list,session_list_temp,SIZEOF(session_list));
							DestroyWindow(hdlg);
							g_hSDlg=0;
						}
						else if (!SaveUserSessionName(szUserSessionName))
						{
							SaveSessionHandles(0,1);

							if (IsDlgButtonChecked(hdlg,IDC_SANDCCHECK))
								CloseCurrentSession(0,0);
							DestroyWindow(hdlg);
							g_hSDlg=0;
						}
						else
							MessageBox(NULL,TranslateT("Current session is empty!"),TranslateT("Sessions Manager"),MB_OK|MB_ICONWARNING);
					}
					else
						MessageBox(NULL,TranslateT("Session name is empty, enter the name and try again"),TranslateT("Sessions Manager"),MB_OK|MB_ICONWARNING);
				}break;

				case IDCANCEL:
				{
					SavePosition(hdlg, "SaveDlg");
					DestroyWindow(hdlg);
					g_hSDlg=0;
				}break;
			}
			break;

		default:
			return FALSE;
	}
	return TRUE;
}