Example #1
0
LRESULT far pascal zDefDlgProc( HWND pp1, UINT pp2, WPARAM pp3, LPARAM pp4 )
{
    LRESULT r;

    SaveRegs();
    /*
    ** Log IN Parameters (No Create/Destroy Checking Yet!)
    */
    LogIn( (LPSTR)"APICALL:DefDlgProc HWND+UINT+WPARAM+LPARAM+",
        pp1, pp2, pp3, pp4 );

    /*
    ** Call the API!
    */
    RestoreRegs();
    GrovelDS();
    r = DefDlgProc(pp1,pp2,pp3,pp4);
    UnGrovelDS();
    SaveRegs();
    /*
    ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!)
    */
    LogOut( (LPSTR)"APIRET:DefDlgProc LRESULT+++++",
        r, (short)0, (short)0, (short)0, (short)0 );

    RestoreRegs();
    return( r );
}
Example #2
0
intptr_t WINAPI MkDirDlgProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
	switch (Msg)
	{
		case DN_LISTCHANGE:
			{
				if (Param1 == MKDIR_COMBOBOX_LINKTYPE)
				{
					SendDlgMessage(hDlg, DM_ENABLE, MKDIR_EDIT_LINKPATH, ToPtr(Param2 != 0));
				}
			}
			break;
		case DN_CLOSE:
		{
			if (Param1==MKDIR_OK)
			{
				string strDirName=reinterpret_cast<LPCWSTR>(SendDlgMessage(hDlg,DM_GETCONSTTEXTPTR,MKDIR_EDIT,0));
				Opt.MultiMakeDir=(SendDlgMessage(hDlg,DM_GETCHECK,MKDIR_CHECKBOX,0)==BSTATE_CHECKED);

				// это по поводу создания одиночного каталога, который
				// начинается с пробела! Чтобы ручками не заключать
				// такой каталог в кавычки
				if (Opt.MultiMakeDir && !wcspbrk(strDirName,L";,\""))
				{
					QuoteSpaceOnly(strDirName);
				}

				// нужно создать только ОДИН каталог
				if (!Opt.MultiMakeDir)
				{
					// уберем все лишние кавычки
					Unquote(strDirName);
					// возьмем в кавычки, т.к. могут быть разделители
					InsertQuote(strDirName);
				}

				UserDefinedList* pDirList=reinterpret_cast<UserDefinedList*>(SendDlgMessage(hDlg,DM_GETDLGDATA,0,0));

				if (!pDirList->Set(strDirName))
				{
					Message(MSG_WARNING,1,MSG(MWarning),MSG(MIncorrectDirList),MSG(MOk));
					return FALSE;
				}
			}
		}
		break;
	default:
		break;
	}

	return DefDlgProc(hDlg,Msg,Param1,Param2);
}
Example #3
0
static
LRESULT CALLBACK
_class_dlg_proc(
		HWND hwnd, 
		UINT message,
		WPARAM wparam, 
		LPARAM lparam
	)
{
	return 
		DefDlgProc(
			hwnd, message, wparam, lparam
		);
}
Example #4
0
File: cns.c Project: Akasurde/krb5
/*
 * Function: Window procedure for the Kerberos control panel dialog.
 */
LRESULT CALLBACK
kwin_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

#if 0
  if (message == wm_kerberos_changed) {       /* Message from the ccache */
    n = ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
    EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), n > 0);

    return 0;
  }
#endif

  switch (message) {
    HANDLE_MSG(hwnd, WM_GETMINMAXINFO, kwin_getminmaxinfo);

    HANDLE_MSG(hwnd, WM_DESTROY, kwin_destroy);

    HANDLE_MSG(hwnd, WM_MEASUREITEM, ticket_measureitem);

    HANDLE_MSG(hwnd, WM_DRAWITEM, ticket_drawitem);

  case WM_SETCURSOR:
    if (isblocking) {
      SetCursor(LoadCursor(NULL, IDC_WAIT));
      return TRUE;
    }
    break;

    HANDLE_MSG(hwnd, WM_SIZE, kwin_size);

    HANDLE_MSG(hwnd, WM_SYSCOMMAND, kwin_syscommand);

    HANDLE_MSG(hwnd, WM_TIMER, kwin_timer);

    HANDLE_MSG(hwnd, WM_PAINT, kwin_paint);

  case WM_ERASEBKGND:
    if (!IsIconic(hwnd))
      break;
    return 0;

  case WM_KWIN_SETNAME:
    kwin_init_name(hwnd, (char *)lParam);
  }

  return DefDlgProc(hwnd, message, wParam, lParam);
}
Example #5
0
LONG_PTR WINAPI MsgDlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2)
{
	switch (Msg)
	{
		case DN_INITDIALOG:
		{
			FarDialogItem di;

			for (int i=0; SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,i,(LONG_PTR)&di); i++)
			{
				if (di.Type==DI_EDIT)
				{
					COORD pos={0,0};
					SendDlgMessage(hDlg,DM_SETCURSORPOS,i,(LONG_PTR)&pos);
				}
			}
		}
		break;
		case DN_CTLCOLORDLGITEM:
		{
			FarDialogItem di;
			SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,Param1,(LONG_PTR)&di);

			if (di.Type==DI_EDIT)
			{
				int Color=FarColorToReal(IsWarningStyle?COL_WARNDIALOGTEXT:COL_DIALOGTEXT)&0xFF;
				return ((Param2&0xFF00FF00)|(Color<<16)|Color);
			}
		}
		break;
		case DN_KEY:
		{
			if (Param1==FirstButtonIndex && (Param2==KEY_LEFT || Param2 == KEY_NUMPAD4 || Param2==KEY_SHIFTTAB))
			{
				SendDlgMessage(hDlg,DM_SETFOCUS,LastButtonIndex,0);
				return TRUE;
			}
			else if (Param1==LastButtonIndex && (Param2==KEY_RIGHT || Param2 == KEY_NUMPAD6 || Param2==KEY_TAB))
			{
				SendDlgMessage(hDlg,DM_SETFOCUS,FirstButtonIndex,0);
				return TRUE;
			}
		}
		break;
	}

	return DefDlgProc(hDlg,Msg,Param1,Param2);
}
Example #6
0
// Каллбак для диалога редактирования имени кодовой страницы
intptr_t WINAPI EditDialogProc(HANDLE hDlg, intptr_t Msg, intptr_t Param1, void* Param2)
{
	if (Msg==DN_CLOSE)
	{
		if (Param1==EDITCP_OK || Param1==EDITCP_RESET)
		{
			string strCodePageName;
			uintptr_t CodePage = GetMenuItemCodePage();
			FormatString strCodePage;
			strCodePage<<CodePage;
			if (Param1==EDITCP_OK)
			{
				FarDialogItemData item = {sizeof(FarDialogItemData)};
				item.PtrLength = SendDlgMessage(hDlg, DM_GETTEXT, EDITCP_EDIT, 0);
				item.PtrData = strCodePageName.GetBuffer(item.PtrLength+1);
				SendDlgMessage(hDlg, DM_GETTEXT, EDITCP_EDIT, &item);
				strCodePageName.ReleaseBuffer();
			}
			// Если имя кодовой страницы пустое, то считаем, что имя не задано
			if (!strCodePageName.GetLength())
				GeneralCfg->DeleteValue(NamesOfCodePagesKey, strCodePage);
			else
				GeneralCfg->SetValue(NamesOfCodePagesKey, strCodePage, strCodePageName);
			// Получаем информацию о кодовой странице
			CPINFOEX cpiex;
			if (GetCodePageInfo(CodePage, cpiex))
			{
				// Формируем имя таблиц символов
				bool IsCodePageNameCustom = false;
				wchar_t *CodePageName = FormatCodePageName(CodePage, cpiex.CodePageName, sizeof(cpiex.CodePageName)/sizeof(wchar_t), IsCodePageNameCustom);
				// Формируем строку представления
				strCodePage.Clear();
				FormatCodePageString(CodePage, CodePageName, strCodePage, IsCodePageNameCustom);
				// Обновляем имя кодовой страницы
				int Position = CodePages->GetSelectPos();
				CodePages->DeleteItem(Position);
				MenuItemEx NewItem;
				NewItem.Clear();
				NewItem.strName = strCodePage;
				NewItem.UserData = &CodePage;
				NewItem.UserDataSize = sizeof(CodePage);
				CodePages->AddItem(&NewItem, Position);
				CodePages->SetSelectPos(Position, 1);
			}
		}
	}
	return DefDlgProc(hDlg, Msg, Param1, Param2);
}
Example #7
0
// Каллбак для диалога редактирования имени кодовой страницы
LONG_PTR WINAPI EditDialogProc(HANDLE hDlg, int Msg, int Param1, LONG_PTR Param2)
{
	if (Msg==DN_CLOSE)
	{
		if (Param1==EDITCP_OK || Param1==EDITCP_RESET)
		{
			FARString strCodePageName;
			UINT CodePage = GetMenuItemCodePage();
			FormatString strCodePage;
			strCodePage<<CodePage;
			if (Param1==EDITCP_OK)
			{
				wchar_t *CodePageName = strCodePageName.GetBuffer(SendDlgMessage(hDlg, DM_GETTEXTPTR, EDITCP_EDIT, 0)+1);
				SendDlgMessage(hDlg, DM_GETTEXTPTR, EDITCP_EDIT, (LONG_PTR)CodePageName);
				strCodePageName.ReleaseBuffer();
			}
			// Если имя кодовой страницы пустое, то считаем, что имя не задано
			if (!strCodePageName.GetLength())
				DeleteRegValue(NamesOfCodePagesKey, strCodePage);
			else
				SetRegKey(NamesOfCodePagesKey, strCodePage, strCodePageName);
			// Получаем информацию о кодовой странице
			CPINFOEX cpiex;
			if (GetCodePageInfo(CodePage, cpiex))
			{
				// Формируем имя таблиц символов
				bool IsCodePageNameCustom = false;
				wchar_t *CodePageName = FormatCodePageName(CodePage, cpiex.CodePageName, sizeof(cpiex.CodePageName)/sizeof(wchar_t), IsCodePageNameCustom);
				// Формируем строку представления
				strCodePage.Clear();
				FormatCodePageString(CodePage, CodePageName, strCodePage, IsCodePageNameCustom);
				// Обновляем имя кодовой страницы
				int Position = CodePages->GetSelectPos();
				CodePages->DeleteItem(Position);
				MenuItemEx NewItem;
				NewItem.Clear();
				NewItem.strName = strCodePage;
				NewItem.UserData = (char *)(UINT_PTR)CodePage;
				NewItem.UserDataSize = sizeof(UINT);
				CodePages->AddItem(&NewItem, Position);
				CodePages->SetSelectPos(Position, 1);
			}
		}
	}
	return DefDlgProc(hDlg, Msg, Param1, Param2);
}
Example #8
0
INT_PTR CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_INITDIALOG:
		{
			HICON hIcon=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_SETTINGSTOOL),IMAGE_ICON,32,32,LR_SHARED);
			//SetIcon(hWnd,hIcon,TRUE);
			SetClassLongPtr(hWnd,GCLP_HICON,(LONG_PTR)hIcon);
			hIcon=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_SETTINGSTOOL),IMAGE_ICON,16,16,LR_SHARED);
			//SetIcon(hWnd,hIcon,FALSE);
			SetClassLongPtr(hWnd,GCLP_HICONSM,(LONG_PTR)hIcon);
			break;
		}
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDOK:
			break;
		case IDCANCEL:
			EndDialog(hWnd,0);
			break;
		case IDC_SAVESETTINGS:
			SaveSettings(hWnd);
			break;
		case IDC_RESTORESETTINGS:
			RestoreSettings(hWnd);
			break;
		case IDC_REMOVESETTINGS:
			RemoveSettings(hWnd);
			break;
		default:
			return DefDlgProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_CLOSE:
		EndDialog(hWnd,0);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	//default:
		//return DefDlgProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #9
0
INT_PTR WINAPI ExcDlgProc(HANDLE hDlg,int Msg,int Param1,void* Param2)
{
	switch (Msg)
	{
		case DN_CTLCOLORDLGITEM:
		{
			FarDialogItem di;
			SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,Param1,&di);

			if (di.Type==DI_EDIT)
			{
				FarColor Color=ColorIndexToColor(COL_WARNDIALOGTEXT);
				FarDialogItemColors* Colors = static_cast<FarDialogItemColors*>(Param2);
				Colors->Colors[0] = Color;
				Colors->Colors[2] = Color;
			}
		}
		break;

		case DN_CONTROLINPUT:
		{
			const INPUT_RECORD* record=(const INPUT_RECORD *)Param2;
			if (record->EventType==KEY_EVENT)
			{
				int key = InputRecordToKey(record);
				if (Param1==10 && (key==KEY_LEFT || key == KEY_NUMPAD4 || key==KEY_SHIFTTAB))
				{
					SendDlgMessage(hDlg,DM_SETFOCUS,11,0);
					return TRUE;
				}
				else if (Param1==11 && (key==KEY_RIGHT || key == KEY_NUMPAD6 || key==KEY_TAB))
				{
					SendDlgMessage(hDlg,DM_SETFOCUS,10,0);
					return TRUE;
				}
			}
		}
		break;
	default:
		break;
	}
	return DefDlgProc(hDlg,Msg,Param1,Param2);
}
LRESULT DispDefault(EDWP   edwp, 
                    HWND   hwnd, 
                    UINT   uMessage, 
                    WPARAM wparam, 
                    LPARAM lparam)
{
    switch (edwp)
    {
        case edwpNone:
            return 0;
        case edwpWindow:
            return DefWindowProc(hwnd, uMessage, wparam, lparam);
        case edwpDialog:
            return DefDlgProc(hwnd, uMessage, wparam, lparam);
        case edwpMDIFrame:
            return DefFrameProc(hwnd, hwndMDIIPXChat, uMessage, wparam, lparam);
        case edwpMDIChild:
            return DefMDIChildProc(hwnd, uMessage, wparam, lparam);
    }
    return 0;
}
Example #11
0
LONG_PTR WINAPI EditTypeRecordDlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2)
{
	switch (Msg)
	{
		case DN_BTNCLICK:

			switch (Param1)
			{
				case ETR_COMBO_EXEC:
				case ETR_COMBO_ALTEXEC:
				case ETR_COMBO_VIEW:
				case ETR_COMBO_ALTVIEW:
				case ETR_COMBO_EDIT:
				case ETR_COMBO_ALTEDIT:
					SendDlgMessage(hDlg,DM_ENABLE,Param1+1,Param2==BSTATE_CHECKED?TRUE:FALSE);
					break;
			}

			break;
		case DN_CLOSE:

			if (Param1==ETR_BUTTON_OK)
			{
				BOOL Result=TRUE;
				LPCWSTR Masks=reinterpret_cast<LPCWSTR>(SendDlgMessage(hDlg,DM_GETCONSTTEXTPTR,ETR_EDIT_MASKS,0));
				CFileMask FMask;

				if (!FMask.Set(Masks,0))
				{
					Result=FALSE;
				}

				return Result;
			}

			break;
	}

	return DefDlgProc(hDlg,Msg,Param1,Param2);
}
Example #12
0
static LRESULT CALLBACK exceptionWndProc(
    HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam )
{
  switch( message )
  {
    case WM_DESTROY:
      PostQuitMessage( 0 );
      return( 0 );

    case WM_COMMAND:
      if( LOWORD(wparam)==IDCANCEL )
      {
        DestroyWindow( hwnd );
        return( 0 );
      }
      break;

    case WM_CLOSE:
      DestroyWindow( hwnd );
      return( 0 );
  }

  return( DefDlgProc(hwnd,message,wparam,lparam) );
}
Example #13
0
intptr_t WINAPI EditMenuDlgProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
#if defined(PROJECT_DI_MEMOEDIT)
	Dialog* Dlg=(Dialog*)hDlg;

	switch (Msg)
	{
		case DN_INITDIALOG:
		{
			break;
		}
	}

#endif

	switch (Msg)
	{
		case DN_CLOSE:

			if (Param1==EM_BUTTON_OK)
			{
				BOOL Result=TRUE;
				LPCWSTR HotKey=reinterpret_cast<LPCWSTR>(SendDlgMessage(hDlg,DM_GETCONSTTEXTPTR,EM_HOTKEY_EDIT,0));
				LPCWSTR Label=reinterpret_cast<LPCWSTR>(SendDlgMessage(hDlg,DM_GETCONSTTEXTPTR,EM_LABEL_EDIT,0));
				int FocusPos=-1;

				if(StrCmp(HotKey,L"--"))
				{
					if (!*Label)
					{
						FocusPos=EM_LABEL_EDIT;
					}
					else if (StrLength(HotKey)>1)
					{
						FocusPos=EM_HOTKEY_EDIT;

						if (Upper(*HotKey)==L'F')
						{
							int FuncNum=_wtoi(HotKey+1);

							if (FuncNum > 0 && FuncNum < 25)
								FocusPos=-1;
						}
					}
				}

				if (FocusPos!=-1)
				{
					Message(MSG_WARNING,1,MSG(MUserMenuTitle),MSG((*Label?MUserMenuInvalidInputHotKey:MUserMenuInvalidInputLabel)),MSG(MOk));
					SendDlgMessage(hDlg,DM_SETFOCUS,FocusPos,0);
					Result=FALSE;
				}

				return Result;
			}

			break;
		default:
			break;
	}

	return DefDlgProc(hDlg,Msg,Param1,Param2);
}
Example #14
0
/*
 *  Handler for dialog windows
 */
static LRESULT CALLBACK
mwDialogProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	PMWDLGDATA pData;
	LRESULT retV = 0;
	DLGPROC lpFnDlg = DLG_DLGPROC(hWnd);


	if (lpFnDlg)
		retV = lpFnDlg(hWnd, Msg, wParam, lParam);

	if (!retV)
		retV = DefDlgProc(hWnd, Msg, wParam, lParam);

	//  Some messages return the value of DLGPROC
	if (!dlgReturnLValue(Msg))
		return retV;

	if (!retV) {
		switch (Msg) {
		case WM_NCDESTROY:
			pData = DLG_PMWDLGDATA(hWnd);
			if (pData) {
				HWND hPar = GetParent(hWnd);

				dlgDestroyInitFont(hWnd, pData);
				free(pData);
				SetWindowLong(hWnd, DWL_DLGDATA, 0);
				SetWindowLong(hWnd, DWL_DLGPROC, 0);
				if (hPar)
					SetActiveWindow(hPar);
			} else
				EPRINTF("WARN: mwDialogProc: WM_NCDESTROY without dlgParams\n");
			break;

        case WM_CLOSE:
                EndDialog (hWnd, 0);
                return 0;

		case WM_SETFONT:
			pData = DLG_PMWDLGDATA(hWnd);
			if (pData == NULL)
				return 0;
			dlgDestroyInitFont(hWnd, pData);
			pData->hFnt = (HFONT) wParam;
			if (LOWORD(lParam) != 0)
				InvalidateRect(hWnd, NULL, TRUE);
			return TRUE;

		case WM_GETFONT:
			pData = DLG_PMWDLGDATA(hWnd);
			if (pData == NULL)
				return 0;
			return (LPARAM) pData->hFnt;

		case WM_SETFOCUS:
			dlgSaveCtrlFocus(hWnd, (HWND) wParam);
			dlgRestoreCtrlFocus(hWnd);
			return 0;

		case WM_SHOWWINDOW:
			if (!wParam)
				dlgSaveCtrlFocus(hWnd, GetFocus());
			break;

		case WM_ACTIVATE:
			if (LOWORD(wParam) == WA_INACTIVE)
				dlgSaveCtrlFocus(hWnd, GetFocus());
			else
				dlgRestoreCtrlFocus(hWnd);
			return 0;

		case WM_NCHITTEST:
			{
				POINT curpt;
				POINTSTOPOINT(curpt, lParam);
				if (PtInRect(&hWnd->clirect, curpt))
					return HTNOWHERE;
				return DefWindowProc(hWnd, Msg, wParam, lParam);
			}
		}
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}

	return DLG_MSGRESULT(hWnd);
}
Example #15
0
static
LRESULT CALLBACK
mainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) {
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			// test for unsaved data
			if (ARG->m_config != ARG->m_oldConfig) {
				if (!askVerify(hwnd, getString(IDS_UNSAVED_DATA_REALLY_QUIT))) {
					return 0;
				}
			}

			// quit
			PostQuitMessage(0);
			return 0;

		case IDOK:
		case IDC_MAIN_TEST: {
			// note if testing
			const bool testing = (LOWORD(wParam) == IDC_MAIN_TEST);

			// save data
			if (ARG->m_config != ARG->m_oldConfig) {
				if (!saveConfig(ARG->m_config, false)) {
					showError(hwnd, CStringUtil::format(
								getString(IDS_SAVE_FAILED).c_str(),
								getErrorString(GetLastError()).c_str()));
					return 0;
				}
				ARG->m_oldConfig = ARG->m_config;
				enableSaveControls(hwnd);
			}

			// launch child app
			DWORD threadID;
			HANDLE thread = launchApp(hwnd, testing, &threadID);
			if (thread == NULL) {
				return 0;
			}

			// handle child program
			if (testing) {
				// wait for process to stop, allowing the user to kill it
				waitForChild(hwnd, thread, threadID);

				// clean up
				CloseHandle(thread);
			}
			else {
				// don't need thread handle
				CloseHandle(thread);

				// notify of success
				askOkay(hwnd, getString(IDS_STARTED_TITLE),
								getString(IDS_STARTED));

				// quit
				PostQuitMessage(0);
			}
			return 0;
		}

		case IDC_MAIN_AUTOSTART: {
			// construct command line
			CString cmdLine = getCommandLine(hwnd, false);
			if (!cmdLine.empty()) {
				// run dialog
				CAutoStart autoStart(hwnd,
							isClientChecked(hwnd) ? NULL : &ARG->m_config,
							cmdLine);
				autoStart.doModal();
				if (autoStart.wasUserConfigSaved()) {
					ARG->m_oldConfig = ARG->m_config;
					enableSaveControls(hwnd);
				}
			}
			return 0;
		}

		case IDC_MAIN_SAVE:
			if (!saveConfig(ARG->m_config, false)) {
				showError(hwnd, CStringUtil::format(
								getString(IDS_SAVE_FAILED).c_str(),
								getErrorString(GetLastError()).c_str()));
			}
			else {
				ARG->m_oldConfig = ARG->m_config;
				enableSaveControls(hwnd);
			}
			return 0;

		case IDC_MAIN_CLIENT_RADIO:
		case IDC_MAIN_SERVER_RADIO:
			enableMainWindowControls(hwnd);
			return 0;

		case IDC_MAIN_SERVER_ADD_BUTTON:
			addScreen(hwnd);
			return 0;

		case IDC_MAIN_SERVER_EDIT_BUTTON:
			editScreen(hwnd);
			return 0;

		case IDC_MAIN_SERVER_REMOVE_BUTTON:
			removeScreen(hwnd);
			return 0;

		case IDC_MAIN_SERVER_SCREENS_LIST:
			if (HIWORD(wParam) == LBN_SELCHANGE) {
				enableScreensControls(hwnd);
				updateNeighbors(hwnd);
			}
			else if (HIWORD(wParam) == LBN_DBLCLK) {
				editScreen(hwnd);
				return 0;
			}
			break;

		case IDC_MAIN_SERVER_LEFT_COMBO:
			if (HIWORD(wParam) == CBN_SELENDOK) {
				changeNeighbor(hwnd, (HWND)lParam, kLeft);
				return 0;
			}
			break;

		case IDC_MAIN_SERVER_RIGHT_COMBO:
			if (HIWORD(wParam) == CBN_SELENDOK) {
				changeNeighbor(hwnd, (HWND)lParam, kRight);
				return 0;
			}
			break;

		case IDC_MAIN_SERVER_TOP_COMBO:
			if (HIWORD(wParam) == CBN_SELENDOK) {
				changeNeighbor(hwnd, (HWND)lParam, kTop);
				return 0;
			}
			break;

		case IDC_MAIN_SERVER_BOTTOM_COMBO:
			if (HIWORD(wParam) == CBN_SELENDOK) {
				changeNeighbor(hwnd, (HWND)lParam, kBottom);
				return 0;
			}
			break;

		case IDC_MAIN_OPTIONS:
			s_globalOptions->doModal();
			enableSaveControls(hwnd);
			break;

		case IDC_MAIN_ADVANCED:
			s_advancedOptions->doModal(isClientChecked(hwnd));
			enableSaveControls(hwnd);
			break;
		}

	default:
		break;
	}
	return DefDlgProc(hwnd, message, wParam, lParam);
}
LRESULT CALLBACK StkThreadGuiManager::StkThreadProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	StkThreadGuiManager* StkThGuiMgr = StkThreadGuiManager::GetInstance();

	// For icon information
	HICON IconHndlrS = NULL;
	HICON IconHndlrB = NULL;

	HWND BkGndWndHndl = NULL;
	HWND ButtonStart = NULL;
	HWND ButtonStop = NULL;
	HWND CheckAll = NULL;

	RECT Wrect;

	// Flag which checks whether the check box on list-view was clicked.
	static bool MasterClkFlag = false;

	switch (message) {
	case WM_CREATE:
		InitCommonControls();
		GetClientRect(hWnd, &Wrect);

		BkGndWndHndl = CreateWindow(L"STATIC", L"", WS_CHILD | WS_VISIBLE | WS_DLGFRAME, 0, Wrect.bottom - 50, Wrect.right, 50, hWnd, NULL, StkThGuiMgr->DlgInstHndl, NULL);
		StkThGuiMgr->ListWndHndl = CreateWindowEx(0, WC_LISTVIEW, L"", WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | WS_TABSTOP, 0, 190, Wrect.right, Wrect.bottom - 240, hWnd, (HMENU)IDC_THREADLIST, StkThGuiMgr->DlgInstHndl, NULL);
		CheckAll = CreateWindow(L"BUTTON", L"Check/Uncheck All (&A)", WS_CHILD | WS_VISIBLE | BS_3STATE | WS_TABSTOP, Wrect.left + 10, Wrect.bottom - 35, 180, 25, hWnd, (HMENU)IDC_ALLCHECK, StkThGuiMgr->DlgInstHndl, NULL);
		ButtonStart = CreateWindow(L"BUTTON", L"Start (&R)", WS_CHILD | WS_VISIBLE | WS_TABSTOP, Wrect.right - 170, Wrect.bottom - 35, 70, 25, hWnd, (HMENU)IDC_START, StkThGuiMgr->DlgInstHndl, NULL);
		ButtonStop = CreateWindow(L"BUTTON", L"Stop (&S)", WS_CHILD | WS_VISIBLE | WS_TABSTOP, Wrect.right - 90, Wrect.bottom - 35, 70, 25, hWnd, (HMENU)IDC_STOP, StkThGuiMgr->DlgInstHndl, NULL);
		StkThGuiMgr->Tracelog = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | WS_TABSTOP, 0, 0, Wrect.right, 190, hWnd/*BkGndWndHndl*/, (HMENU)IDC_TRACELOG, StkThGuiMgr->DlgInstHndl, NULL);
		ListView_SetExtendedListViewStyle(StkThGuiMgr->ListWndHndl, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
		SendMessage(StkThGuiMgr->Tracelog, EM_SETREADONLY, (WPARAM)true, (LPARAM)0);
		SendMessage(StkThGuiMgr->Tracelog, EM_SETLIMITTEXT, (WPARAM)0, (LPARAM)0);

		StkThGuiMgr->RefreshLog(true);

		EnumChildWindows(hWnd, SetStkThreadFontProc, NULL);

		// Sets icon information for the dialog box
		IconHndlrS = (HICON)LoadImage(StkThGuiMgr->DlgInstHndl, (LPCTSTR)MAKEINTRESOURCEW(StkThGuiMgr->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
		IconHndlrB = (HICON)LoadImage(StkThGuiMgr->DlgInstHndl, (LPCTSTR)MAKEINTRESOURCEW(StkThGuiMgr->IconId), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
		if (IconHndlrS != NULL && IconHndlrB != NULL) {
			SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IconHndlrS);
			SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)IconHndlrB);
		}

		// Init list-view
		if (StkThGuiMgr->InitListView() == -1) {
			return 0;
		}

		// Init Check box
		CheckDlgButton(hWnd, IDC_ALLCHECK, BST_CHECKED);

		SetTimer(StkThGuiMgr->DlgWndHndl, 333, 2000, (TIMERPROC)ReplaceStatus);

		break;

	case WM_COMMAND:
		// Check/Uncheck box was clicked
		if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ALLCHECK) {
			UINT Sts = IsDlgButtonChecked(hWnd, IDC_ALLCHECK);
			bool ChkUnchk;
			static bool PrevChkUnchk = true;
			if (Sts == BST_CHECKED) {
				ChkUnchk = false;
			} else if (Sts == BST_UNCHECKED) {
				ChkUnchk = true;
			} else if (Sts == BST_INDETERMINATE) {
				ChkUnchk = (PrevChkUnchk == true)? false : true;
			}
			MasterClkFlag = true;
			CheckDlgButton(hWnd, IDC_ALLCHECK, (ChkUnchk == true)? BST_CHECKED : BST_UNCHECKED);
			PrevChkUnchk = ChkUnchk;
			int RowLoop;
			for (RowLoop = 0; RowLoop < GetNumOfStkThread(); RowLoop++) {
				ListView_SetCheckState(StkThGuiMgr->ListWndHndl, RowLoop, ChkUnchk);
			}
			break;
		}

		// Close button was clicked
		if (LOWORD(wParam) == IDCANCEL) {
			DestroyWindow(hWnd);
		}

		// Start button
		if (LOWORD(wParam) == IDC_START) {
			StkThGuiMgr->StartThreads(false);
		}

		// Stop button
		if (LOWORD(wParam) == IDC_STOP) {
			StkThGuiMgr->StopThreads(false);
		}
		break;

	case WM_NOTIFY:
		if (wParam == IDC_THREADLIST) {

			// Preserve LPARAM
			NMLISTVIEW* NmListView = (NMLISTVIEW*)lParam;
			NMITEMACTIVATE* NmItemActivate = (NMITEMACTIVATE*)lParam;
			NMLVKEYDOWN* NmLvKeyDown = (NMLVKEYDOWN*)lParam;

			// Something on list-view area was clicked.
			if ((NmItemActivate->hdr).code == NM_CLICK) {
				MasterClkFlag = false;
				break;
			}

			// Check box on list-view was changed.
			if ((NmListView->hdr).code == LVN_ITEMCHANGED &&
				(NmListView->uOldState & LVIS_STATEIMAGEMASK) != (NmListView->uNewState & LVIS_STATEIMAGEMASK) &&
				MasterClkFlag == false) {
				StkThGuiMgr->SetStatusOfMasterCheckBox();
				break;
			}
		}
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return DefDlgProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #17
0
intptr_t WINAPI MsgDlgProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
	switch (Msg)
	{
		case DN_INITDIALOG:
		{
			FarDialogItem di;

			for (int i=0; SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,i,&di); i++)
			{
				if (di.Type==DI_EDIT)
				{
					COORD pos={};
					SendDlgMessage(hDlg,DM_SETCURSORPOS,i,&pos);
				}
			}
		}
		break;
		case DN_CTLCOLORDLGITEM:
		{
			FarDialogItem di;
			SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,Param1,&di);

			if (di.Type==DI_EDIT)
			{
				FarColor Color=ColorIndexToColor(IsWarningStyle?COL_WARNDIALOGTEXT:COL_DIALOGTEXT);
				FarDialogItemColors* Colors = static_cast<FarDialogItemColors*>(Param2);
				Colors->Colors[0] = Color;
				Colors->Colors[2] = Color;
			}
		}
		break;
		case DN_CONTROLINPUT:
		{
			const INPUT_RECORD* record=(const INPUT_RECORD *)Param2;
			if (record->EventType==KEY_EVENT)
			{
				int key = InputRecordToKey(record);
				switch(key)
				{
				case KEY_F3:
					if(IsErrorType)
					{
						string Txt[2];
						GetWin32ErrorString(LastError, Txt[0]);
						GetNtErrorString(NtStatus, Txt[1]);
						DialogBuilder Builder(MError, nullptr);
						Builder.AddConstEditField(FormatString() << L"LastError: 0x" << fmt::MinWidth(8) << fmt::FillChar(L'0') << fmt::Radix(16) << LastError << L" - " << Txt[0], 65);
						Builder.AddConstEditField(FormatString() << L"NTSTATUS: 0x" << fmt::MinWidth(8) << fmt::FillChar(L'0') << fmt::Radix(16) << NtStatus << L" - " << Txt[1], 65);
						Builder.AddOK();
						Builder.ShowDialog();
					}
					break;

				case KEY_TAB:
				case KEY_RIGHT:
				case KEY_NUMPAD6:
					if(Param1==LastButtonIndex)
					{
						SendDlgMessage(hDlg,DM_SETFOCUS,FirstButtonIndex,0);
						return TRUE;
					}
					break;

				case KEY_SHIFTTAB:
				case KEY_LEFT:
				case KEY_NUMPAD4:
					if(Param1==FirstButtonIndex)
					{
						SendDlgMessage(hDlg,DM_SETFOCUS,LastButtonIndex,0);
						return TRUE;
					}
					break;

				case KEY_CTRLC:
				case KEY_RCTRLC:
				case KEY_CTRLINS:
				case KEY_RCTRLINS:
				case KEY_CTRLNUMPAD0:
				case KEY_RCTRLNUMPAD0:
					{
						string* strText = reinterpret_cast<string*>(SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0));
						CopyToClipboard(*strText);
					}
					break;
				}
			}
		}
		break;
	default:
		break;
	}

	return DefDlgProc(hDlg,Msg,Param1,Param2);
}
Example #18
0
LRESULT CFileTransDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	return DefDlgProc(GetSafeHwnd(),message,wParam,lParam);
}
Example #19
0
static
LRESULT CALLBACK
mainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) {
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			// save data
			if (saveMainWindow(hwnd, true)) {
				// quit
				PostQuitMessage(0);
			}
			return 0;

		case IDOK:
		case IDC_MAIN_TEST: {
			// note if testing
			const bool testing = (LOWORD(wParam) == IDC_MAIN_TEST);

			// save data
			if (saveMainWindow(hwnd, false)) {
				// launch child app
				DWORD threadID;
				HANDLE thread = launchApp(hwnd, testing, &threadID);
				if (thread == NULL) {
					return 0;
				}

				// handle child program
				if (testing) {
					// wait for process to stop, allowing the user to kill it
					waitForChild(hwnd, thread, threadID);

					// clean up
					CloseHandle(thread);
				}
				else {
					// don't need thread handle
					CloseHandle(thread);

					// notify of success
					askOkay(hwnd, getString(IDS_STARTED_TITLE),
									getString(IDS_STARTED));

					// quit
					PostQuitMessage(0);
				}
			}
			return 0;
		}

		case IDC_MAIN_AUTOSTART: {
			CString cmdLine;
			if (saveMainWindow(hwnd, false, &cmdLine)) {
				// run dialog
				CAutoStart autoStart(hwnd, !isClientChecked(hwnd), cmdLine);
				autoStart.doModal();
			}
			return 0;
		}

		case IDC_MAIN_CLIENT_RADIO:
		case IDC_MAIN_SERVER_RADIO:
			enableMainWindowControls(hwnd);
			return 0;

		case IDC_MAIN_SCREENS:
			s_screensLinks->doModal();
			break;

		case IDC_MAIN_OPTIONS:
			s_globalOptions->doModal();
			break;

		case IDC_MAIN_ADVANCED:
			s_advancedOptions->doModal(isClientChecked(hwnd));
			break;
		}

	default:
		break;
	}
	return DefDlgProc(hwnd, message, wParam, lParam);
}
Example #20
0
intptr_t WINAPI FileFilterConfigDlgProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
    switch (Msg)
    {
    case DN_INITDIALOG:
    {
        FilterDlgRelativeDateItemsUpdate(hDlg, false);
        return TRUE;
    }
    case DN_BTNCLICK:
    {
        if (Param1==ID_FF_CURRENT || Param1==ID_FF_BLANK) //Current и Blank
        {
            FILETIME ft;
            string strDate, strTime;

            if (Param1==ID_FF_CURRENT)
            {
                GetSystemTimeAsFileTime(&ft);
                ConvertDate(ft,strDate,strTime,12,FALSE,FALSE,2);
            }
            else
            {
                strDate.Clear();
                strTime.Clear();
            }

            SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
            int relative = (int)SendDlgMessage(hDlg,DM_GETCHECK,ID_FF_DATERELATIVE,0);
            int db = relative ? ID_FF_DAYSBEFOREEDIT : ID_FF_DATEBEFOREEDIT;
            int da = relative ? ID_FF_DAYSAFTEREDIT  : ID_FF_DATEAFTEREDIT;
            SendDlgMessage(hDlg,DM_SETTEXTPTR,da,const_cast<wchar_t*>(strDate.CPtr()));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_TIMEAFTEREDIT,const_cast<wchar_t*>(strTime.CPtr()));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,db,const_cast<wchar_t*>(strDate.CPtr()));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_TIMEBEFOREEDIT,const_cast<wchar_t*>(strTime.CPtr()));
            SendDlgMessage(hDlg,DM_SETFOCUS,da,0);
            COORD r;
            r.X=r.Y=0;
            SendDlgMessage(hDlg,DM_SETCURSORPOS,da,&r);
            SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
            break;
        }
        else if (Param1==ID_FF_RESET) // Reset
        {
            SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
            intptr_t ColorConfig = SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_MASKEDIT,const_cast<wchar_t*>(L"*"));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_SIZEFROMEDIT,nullptr);
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_SIZETOEDIT,nullptr);

            for (int I=ID_FF_READONLY; I <= ID_FF_VIRTUAL; ++I)
            {
                SendDlgMessage(hDlg,DM_SETCHECK,I,ToPtr(BSTATE_3STATE));
            }

            if (!ColorConfig)
                SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_DIRECTORY,ToPtr(BSTATE_UNCHECKED));

            FarListPos LPos= {sizeof(FarListPos)};
            SendDlgMessage(hDlg,DM_LISTSETCURPOS,ID_FF_DATETYPE,&LPos);
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHMASK,ToPtr(BSTATE_CHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHSIZE,ToPtr(BSTATE_UNCHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_HARDLINKS,ToPtr(BSTATE_UNCHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHDATE,ToPtr(BSTATE_UNCHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_DATERELATIVE,ToPtr(BSTATE_UNCHECKED));
            FilterDlgRelativeDateItemsUpdate(hDlg, true);
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHATTRIBUTES,ToPtr(ColorConfig?BSTATE_UNCHECKED:BSTATE_CHECKED));
            SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
            break;
        }
        else if (Param1==ID_FF_MAKETRANSPARENT)
        {
            HighlightDataColor *Colors = (HighlightDataColor *) SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);

            for (int i=0; i<2; i++)
                for (int j=0; j<4; j++)
                {
                    MAKE_TRANSPARENT(Colors->Color[i][j].ForegroundColor);
                    MAKE_TRANSPARENT(Colors->Color[i][j].BackgroundColor);
                }

            SendDlgMessage(hDlg,DM_SETCHECK,ID_HER_MARKTRANSPARENT,ToPtr(BSTATE_CHECKED));
            break;
        }
        else if (Param1==ID_FF_DATERELATIVE)
        {
            FilterDlgRelativeDateItemsUpdate(hDlg, true);
            break;
        }
    }
    case DN_CONTROLINPUT:

        if ((Msg==DN_BTNCLICK && Param1 >= ID_HER_NORMALFILE && Param1 <= ID_HER_SELECTEDCURSORMARKING)
                || (Msg==DN_CONTROLINPUT && Param1==ID_HER_COLOREXAMPLE && ((INPUT_RECORD *)Param2)->EventType == MOUSE_EVENT && ((INPUT_RECORD *)Param2)->Event.MouseEvent.dwButtonState==FROM_LEFT_1ST_BUTTON_PRESSED))
        {
            HighlightDataColor *EditData = (HighlightDataColor *) SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);

            if (Msg==DN_CONTROLINPUT)
            {
                Param1 = ID_HER_NORMALFILE + ((INPUT_RECORD *)Param2)->Event.MouseEvent.dwMousePosition.Y*2;

                if (((INPUT_RECORD *)Param2)->Event.MouseEvent.dwMousePosition.X==1 && (EditData->MarkChar&0x0000FFFF))
                    Param1 = ID_HER_NORMALMARKING + ((INPUT_RECORD *)Param2)->Event.MouseEvent.dwMousePosition.Y*2;
            }

            //Color[0=file, 1=mark][0=normal,1=selected,2=undercursor,3=selectedundercursor]
            FarColor Color=EditData->Color[(Param1-ID_HER_NORMALFILE)&1][(Param1-ID_HER_NORMALFILE)/2];
            Global->Console->GetColorDialog(Color,true,true);
            EditData->Color[(Param1-ID_HER_NORMALFILE)&1][(Param1-ID_HER_NORMALFILE)/2]=Color;

            size_t Size = SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,0);
            FarGetDialogItem gdi = {sizeof(FarGetDialogItem), Size, static_cast<FarDialogItem*>(xf_malloc(Size))};
            SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,&gdi);
            //MarkChar это FIXEDIT размером в 1 символ
            wchar_t MarkChar[2];
            FarDialogItemData item= {sizeof(FarDialogItemData),1,MarkChar};
            SendDlgMessage(hDlg,DM_GETTEXT,ID_HER_MARKEDIT,&item);
            EditData->MarkChar=*MarkChar;
            HighlightDlgUpdateUserControl(gdi.Item->VBuf,*EditData);
            SendDlgMessage(hDlg,DM_SETDLGITEM,ID_HER_COLOREXAMPLE,gdi.Item);
            xf_free(gdi.Item);
            return TRUE;
        }

        break;
    case DN_EDITCHANGE:

        if (Param1 == ID_HER_MARKEDIT)
        {
            HighlightDataColor *EditData = (HighlightDataColor *) SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);
            size_t Size = SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,0);
            FarGetDialogItem gdi = {sizeof(FarGetDialogItem), Size, static_cast<FarDialogItem*>(xf_malloc(Size))};
            SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,&gdi);
            //MarkChar это FIXEDIT размером в 1 символ
            wchar_t MarkChar[2];
            FarDialogItemData item= {sizeof(FarDialogItemData),1,MarkChar};
            SendDlgMessage(hDlg,DM_GETTEXT,ID_HER_MARKEDIT,&item);
            EditData->MarkChar=*MarkChar;
            HighlightDlgUpdateUserControl(gdi.Item->VBuf,*EditData);
            SendDlgMessage(hDlg,DM_SETDLGITEM,ID_HER_COLOREXAMPLE,gdi.Item);
            xf_free(gdi.Item);
            return TRUE;
        }

        break;
    case DN_CLOSE:

        if (Param1 == ID_FF_OK && SendDlgMessage(hDlg,DM_GETCHECK,ID_FF_MATCHSIZE,0))
        {
            string strTemp;
            FarDialogItemData item = {sizeof(FarDialogItemData)};
            item.PtrLength = SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZEFROMEDIT,0);
            item.PtrData = strTemp.GetBuffer(item.PtrLength+1);
            SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZEFROMEDIT,&item);
            bool bTemp = !*item.PtrData || CheckFileSizeStringFormat(item.PtrData);
            item.PtrLength = SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZETOEDIT,0);
            item.PtrData = strTemp.GetBuffer(item.PtrLength+1);
            SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZETOEDIT,&item);
            bTemp = bTemp && (!*item.PtrData || CheckFileSizeStringFormat(item.PtrData));

            if (!bTemp)
            {
                intptr_t ColorConfig = SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);
                Message(MSG_WARNING,1,ColorConfig?MSG(MFileHilightTitle):MSG(MFileFilterTitle),MSG(MBadFileSizeFormat),MSG(MOk));
                return FALSE;
            }
        }

        break;
    default:
        break;
    }

    return DefDlgProc(hDlg,Msg,Param1,Param2);
}
Example #21
0
static
LRESULT CALLBACK
mainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) {
	case WM_ACTIVATE:
		if (LOWORD(wParam) != WA_INACTIVE) {
			// activated

			// see if the configuration changed
			if (isConfigNewer(s_configTime, s_userConfig)) {
				CString message2 = getString(IDS_CONFIG_CHANGED);
				if (askVerify(hwnd, message2)) {
					time_t configTime;
					bool userConfig;
					CConfig newConfig;
					if (loadConfig(newConfig, configTime, userConfig) &&
						userConfig == s_userConfig) {
						ARG->m_config = newConfig;
						s_lastConfig  = ARG->m_config;
					}
					else {
						message2 = getString(IDS_LOAD_FAILED);
						showError(hwnd, message2);
						s_lastConfig = CConfig();
					}
				}
			}
		}
		else {
			// deactivated;  write configuration
			if (!isShowingDialog()) {
				saveMainWindow(hwnd, SAVE_QUIET);
			}
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			// save data
			if (saveMainWindow(hwnd, SAVE_QUITING)) {
				// quit
				PostQuitMessage(0);
			}
			return 0;

		case IDOK:
		case IDC_MAIN_TEST: {
			// note if testing
			const bool testing = (LOWORD(wParam) == IDC_MAIN_TEST);

			// save data
			if (saveMainWindow(hwnd, SAVE_NORMAL)) {
				// launch child app
				DWORD threadID;
				HANDLE thread;
				if (!launchApp(hwnd, testing, &thread, &threadID)) {
					return 0;
				}

				// handle child program
				if (testing) {
					// wait for process to stop, allowing the user to kill it
					waitForChild(hwnd, thread, threadID);

					// clean up
					CloseHandle(thread);
				}
				else {
					// don't need thread handle
					if (thread != NULL) {
						CloseHandle(thread);
					}

					// notify of success: now disabled - it's silly to notify a success
					//askOkay(hwnd, getString(IDS_STARTED_TITLE), getString(IDS_STARTED));

					// quit
					PostQuitMessage(0);
				}
			}
			return 0;
		}

		case IDC_MAIN_AUTOSTART: {
			CString cmdLine;
			if (saveMainWindow(hwnd, SAVE_NORMAL, &cmdLine)) {
				// run dialog
				CAutoStart autoStart(hwnd, !isClientChecked(hwnd), cmdLine);
				autoStart.doModal();
			}
			return 0;
		}

		case IDC_MAIN_CLIENT_RADIO:
		case IDC_MAIN_SERVER_RADIO:
			enableMainWindowControls(hwnd);
			return 0;

		case IDC_MAIN_SCREENS:
			s_screensLinks->doModal();
			break;

		case IDC_MAIN_OPTIONS:
			s_globalOptions->doModal();
			break;

		case IDC_MAIN_ADVANCED:
			s_advancedOptions->doModal(isClientChecked(hwnd));
			break;

		case IDC_MAIN_HOTKEYS:
			s_hotkeyOptions->doModal();
			break;

		case IDC_MAIN_INFO:
			s_info->doModal();
			break;
		}

	default:
		break;
	}
	return DefDlgProc(hwnd, message, wParam, lParam);
}
Example #22
0
/*-------------------------------------------
  window procedure of CLASS_TCLOCKPROP
---------------------------------------------*/
LRESULT CALLBACK WndProcProperty(HWND hwnd, UINT message,
	WPARAM wParam, LPARAM lParam)
{
	return DefDlgProc(hwnd, message, wParam, lParam);
}
Example #23
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static HWND hList;
	static HFONT hFont;
	static DWORD dwSplitLine;
	switch (msg)
	{
	case WM_CREATE:
		InitCommonControls();
		hFont = CreateFont(26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("MS ゴシック"));
		hList = CreateWindowEx(0, TEXT("LISTBOX"), 0, WS_VISIBLE | WS_CHILD | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL | LBS_MULTIPLESEL, 0, 0, 0, 0, hWnd, (HMENU)IDC_LIST, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		SendMessage(hList, WM_SETFONT, (WPARAM)hFont, 0);
		EditDefProc = (WNDPROC)SetWindowLong(hList, GWL_WNDPROC, (LONG)ListProc);
		{
			int n;
			LPTSTR* argv = CommandLineToArgvW(GetCommandLine(), &n);
			for (int i = 1; i<n; i++)
			{
				CalcSha1(hList, argv[i]);
				const DWORD dwTempWidth = GetStringWidth(hList, PathFindFileName(argv[i]));
				if (dwTempWidth>dwSplitLine)dwSplitLine = dwTempWidth;
			}
			if (argv) GlobalFree(argv);
			const DWORD dwLastItem = SendMessage(hList, LB_GETCOUNT, 0, 0);
			SendMessage(hList, LB_SELITEMRANGE, TRUE, MAKELPARAM(0, dwLastItem - 1));
		}
		DragAcceptFiles(hWnd, TRUE);
		break;
	case WM_ERASEBKGND:
		return 1;
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case ID_COPYTOCLIPBOARD:
		{
			const int nSelItems = SendMessage(hList, LB_GETSELCOUNT, 0, 0);
			if (nSelItems > 0)
			{
				int* pBuffer = (int*)GlobalAlloc(0, sizeof(int) * nSelItems);
				SendMessage(hList, LB_GETSELITEMS, nSelItems, (LPARAM)pBuffer);
				INT nLen = 0;
				for (int i = 0; i < nSelItems; i++)
				{
					DATA* pData = (DATA*)SendMessage(hList, LB_GETITEMDATA, pBuffer[i], 0);
					nLen += lstrlen(pData->szFilePath);
					nLen += lstrlen(pData->szHashValue);
					nLen += 3;
				}
				HGLOBAL hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(TCHAR)*(nLen + 1));
				LPTSTR lpszBuflpszBuf = (LPTSTR)GlobalLock(hMem);
				lpszBuflpszBuf[0] = 0;
				for (int i = 0; i < nSelItems; i++)
				{
					DATA* pData = (DATA*)SendMessage(hList, LB_GETITEMDATA, pBuffer[i], 0);
					lstrcat(lpszBuflpszBuf, pData->szFilePath);
					lstrcat(lpszBuflpszBuf, TEXT("\t"));
					lstrcat(lpszBuflpszBuf, pData->szHashValue);
					lstrcat(lpszBuflpszBuf, TEXT("\r\n"));
				}
				lpszBuflpszBuf[nLen] = 0;
				GlobalFree(pBuffer);
				GlobalUnlock(hMem);
				OpenClipboard(NULL);
				EmptyClipboard();
				SetClipboardData(CF_UNICODETEXT, hMem);
				CloseClipboard();
			}
		}
		break;
		case ID_SELECTALL:
			SendMessage(hList, LB_SETSEL, 1, -1);
			break;
		case ID_DELETE:
		{
			const int nSelItems = SendMessage(hList, LB_GETSELCOUNT, 0, 0);
			if (nSelItems > 0)
			{
				int* pBuffer = (int*)GlobalAlloc(0, sizeof(int) * nSelItems);
				SendMessage(hList, LB_GETSELITEMS, nSelItems, (LPARAM)pBuffer);
				for (int i = nSelItems - 1; i >= 0; i--)
				{
					DeleteItem(hList, pBuffer[i]);
				}
				GlobalFree(pBuffer);
				dwSplitLine = 0;
				const int nCount = SendMessage(hList, LB_GETCOUNT, 0, 0);
				for (int i = 0; i < nCount; i++)
				{
					const DATA* pData = (const DATA*)SendMessage(hList, LB_GETITEMDATA, i, 0);
					const DWORD dwTemp = GetStringWidth(hList, PathFindFileName(pData->szFilePath));
					if (dwTemp>dwSplitLine)dwSplitLine = dwTemp;
				}
			}
		}
		break;
		}
		break;
	case WM_MEASUREITEM:
		((LPMEASUREITEMSTRUCT)lParam)->itemHeight = 32;
		return 0;
	case WM_SIZE:
		MoveWindow(hList, 0, 0, LOWORD(lParam), HIWORD(lParam), 0);
		break;
	case WM_EXITTHREAD:
	{
		DATA* pData = (DATA*)lParam;
		WaitForSingleObject(pData->hThread, INFINITE);
		CloseHandle(pData->hThread);
		pData->hThread = 0;
		InvalidateRect(hList, 0, 0);
	}
	break;
	case WM_DRAWITEM:
		if ((UINT)wParam == IDC_LIST)
		{
			LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
			if (lpdis->itemID == -1)
			{
				if (!SendMessage(hList, LB_GETCOUNT, 0, 0))
				{
					RECT rect;
					GetClientRect(hList, &rect);
					HBRUSH hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
					FillRect(lpdis->hDC, &rect, hBrush);
					DeleteObject(hBrush);
					SetTextColor(lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
					DrawText(lpdis->hDC, TEXT("ここにファイルをドラッグ"), -1, &rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_CENTER);
				}
				break;
			}
			DATA* pData = (DATA*)SendMessage(hList, LB_GETITEMDATA, lpdis->itemID, 0);
			if ((lpdis->itemState)&(ODS_SELECTED))
			{
				SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
				SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
			}
			else
			{
				SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));
				SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
			}
			RECT rect1 = lpdis->rcItem;
			rect1.right = dwSplitLine + 16;
			const LPCTSTR lpszFileName = PathFindFileName(pData->szFilePath);
			SetTextAlign(lpdis->hDC, TA_RIGHT);
			ExtTextOut(lpdis->hDC, rect1.right, rect1.top + 4, ETO_OPAQUE, &rect1, lpszFileName, lstrlen(lpszFileName), 0);
			RECT rect2 = lpdis->rcItem;
			rect2.left = dwSplitLine + 16;
			SetTextAlign(lpdis->hDC, TA_LEFT);
			ExtTextOut(lpdis->hDC, rect2.left + 32, rect2.top + 4, ETO_OPAQUE, &rect2, pData->szHashValue, lstrlen(pData->szHashValue), 0);
		}
		break;
	case WM_DROPFILES:
	{
		HDROP hDrop = (HDROP)wParam;
		TCHAR szFileName[MAX_PATH];
		UINT i;
		const DWORD dwFastItem = SendMessage(hList, LB_GETCOUNT, 0, 0);
		SendMessage(hList, LB_SETSEL, 0, -1);
		const UINT nFiles = DragQueryFile((HDROP)hDrop, 0xFFFFFFFF, NULL, 0);
		for (i = 0; i<nFiles; i++)
		{
			DragQueryFile(hDrop, i, szFileName, sizeof(szFileName));
			CalcSha1(hList, szFileName);
			const DWORD dwTempWidth = GetStringWidth(hList, PathFindFileName(szFileName));
			if (dwTempWidth>dwSplitLine)dwSplitLine = dwTempWidth;
		}
		DragFinish(hDrop);
		const DWORD dwLastItem = SendMessage(hList, LB_GETCOUNT, 0, 0);
		SendMessage(hList, LB_SELITEMRANGE, TRUE, MAKELPARAM(dwFastItem, dwLastItem - 1));
		SetForegroundWindow(hWnd);
	}
	break;
	case WM_CLOSE:
		DestroyWindow(hWnd);
		break;
	case WM_DESTROY:
	{
		const int nCount = SendMessage(hList, LB_GETCOUNT, 0, 0);
		for (int i = nCount - 1; i >= 0; i--)
		{
			DeleteItem(hList, i);
		}
	}
	DeleteObject(hFont);
	PostQuitMessage(0);
	break;
	default:
		return DefDlgProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}
Example #24
0
LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	static HWND hStatic,hEdit1,hEdit2;
	static BOOL bCapture=FALSE;
	static HCURSOR hCursor;
	static COLORREF color,colorLast=GetSysColor(COLOR_3DFACE);
	static HDC hdcScreen;
	static HFONT hFont;
	TCHAR szBuffer[256];
	switch(msg)
	{
	case WM_CREATE:
		hdcScreen=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
		CreateWindow(TEXT("STATIC"),TEXT("RGB(10進):"),
			WS_VISIBLE|WS_CHILD|SS_RIGHT|SS_CENTERIMAGE,
			74,10,100,28,hWnd,0,((LPCREATESTRUCT)lParam)->hInstance,0);
		hEdit1=CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("EDIT"),0,
			WS_VISIBLE|WS_CHILD|WS_TABSTOP|ES_READONLY,
			174,10,128,28,hWnd,0,((LPCREATESTRUCT)lParam)->hInstance,0);
		CreateWindow(TEXT("STATIC"),TEXT("RGB(16進):"),
			WS_VISIBLE|WS_CHILD|SS_RIGHT|SS_CENTERIMAGE,
			74,50,100,28,hWnd,0,((LPCREATESTRUCT)lParam)->hInstance,0);
		hEdit2=CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("EDIT"),0,
			WS_VISIBLE|WS_CHILD|WS_TABSTOP|ES_READONLY,
			174,50,128,28,hWnd,0,((LPCREATESTRUCT)lParam)->hInstance,0);
		hStatic=CreateWindow(TEXT("STATIC"),0,
			WS_VISIBLE|WS_CHILD|WS_BORDER|SS_NOTIFY,
			10,12,64,64,hWnd,(HMENU)100,((LPCREATESTRUCT)lParam)->hInstance,0);
		hCursor=LoadCursor(((LPCREATESTRUCT)(lParam))->hInstance,
			MAKEINTRESOURCE(IDC_CURSOR1));
		break;
	case WM_DISPLAYCHANGE:
		DeleteDC(hdcScreen);
		hdcScreen=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
		break;
	case WM_COMMAND:
		if(LOWORD(wParam)==100)
		{
			bCapture=TRUE;
			SetCursor(hCursor);
			SetCapture(hWnd);
		}
		else if(LOWORD(wParam)==IDCANCEL)
		{
			DestroyWindow(hWnd);
		}
		break;
	case WM_MOUSEMOVE:
		if(bCapture)
		{
			POINT point;
			GetCursorPos(&point);
			color=GetPixel(hdcScreen,point.x,point.y);
			if(color!=colorLast)
			{
				colorLast=color;
				wsprintf(szBuffer,TEXT("%d,%d,%d"),
					GetRValue(color),GetGValue(color),GetBValue(color));
				SetWindowText(hEdit1,szBuffer);
				wsprintf(szBuffer,TEXT("#%02X%02X%02X"),
					GetRValue(color),GetGValue(color),GetBValue(color));
				SetWindowText(hEdit2,szBuffer);
				InvalidateRect(hStatic,NULL,0);
			}
		}
		break;
	case WM_CTLCOLORSTATIC:
		if((HWND)lParam==hStatic)
		{
			SetDCBrushColor((HDC)wParam,colorLast);
			return(INT_PTR)GetStockObject(DC_BRUSH);
		}
		break;
	case WM_LBUTTONUP:
		if(bCapture)
		{
			ReleaseCapture();
			SetCursor(LoadCursor(NULL,IDC_ARROW));
			bCapture=FALSE;
		}
		break;
	case WM_CLOSE:
		DestroyWindow(hWnd);
		break;
	case WM_DESTROY:
		DeleteDC(hdcScreen);
		PostQuitMessage(0);
		break;
	default:
		return(DefDlgProc(hWnd,msg,wParam,lParam));
	}
	return 0;
}
Example #25
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static HWND hEdit1, hEdit2, hEdit3, hButton;
	static HWND hStatic1, hStatic2;
	static HWND hCheck;
	switch (msg)
	{
	case WM_CREATE:
		hStatic1 = CreateWindow(TEXT("Static"), TEXT("対象リスト"), WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		hEdit1 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_VSCROLL | WS_HSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_WANTRETURN, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		SendMessage(hEdit1, EM_LIMITTEXT, 0, 0);
		hCheck = CreateWindow(TEXT("Button"), TEXT("HTMLエスケープ"), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTOCHECKBOX, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		hEdit3 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_TABSTOP | ES_AUTOHSCROLL, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		hButton = CreateWindow(TEXT("Button"), TEXT(">変換>"), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_DEFPUSHBUTTON, 0, 0, 0, 0, hWnd, (HMENU)IDOK, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		hStatic2 = CreateWindow(TEXT("Static"), TEXT("結果リスト"), WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		hEdit2 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_VSCROLL | WS_HSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_READONLY, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		SendMessage(hEdit2, EM_LIMITTEXT, 0, 0);
		DragAcceptFiles(hWnd, TRUE);
		break;
	case WM_DROPFILES:
		{
			const HDROP hDrop = (HDROP)wParam;
			const UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
			if (nFiles == 1)
			{
				TCHAR szFileName[MAX_PATH];
				DragQueryFile(hDrop, 0, szFileName, sizeof(szFileName));
				const HANDLE hFile = CreateFile(szFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
				if (hFile != INVALID_HANDLE_VALUE)
				{
					const DWORD dwFileSize = GetFileSize(hFile, 0);
					DWORD dwReadSize;
					LPSTR lpszText = (LPSTR)GlobalAlloc(0, dwFileSize + 1);
					ReadFile(hFile, lpszText, dwFileSize, &dwReadSize, 0);
					lpszText[dwReadSize] = 0;
					SetWindowTextA(hEdit1, lpszText);
					GlobalFree(lpszText);
					CloseHandle(hFile);
				}
			}
			DragFinish(hDrop);
		}
		break;
	case WM_SIZE:
		{
			const int button_width = 128;
			const int width = (LOWORD(lParam) - button_width - 20) / 2;
			MoveWindow(hStatic1, 0, 0, width, 32, TRUE);
			MoveWindow(hEdit1, 0, 32, width, HIWORD(lParam) - 32, TRUE);
			MoveWindow(hCheck, width + 10, HIWORD(lParam) / 2 - 16 - 10 - 32, button_width, 32, TRUE);
			MoveWindow(hEdit3, width + 10, HIWORD(lParam) / 2 - 16, button_width, 32, TRUE);
			MoveWindow(hButton, width + 10, HIWORD(lParam) / 2 + 16 + 10, button_width, 32, TRUE);
			MoveWindow(hStatic2, width + button_width + 20, 0, width, 32, TRUE);
			MoveWindow(hEdit2, width + button_width + 20, 32, width, HIWORD(lParam) - 32, TRUE);
		}
		break;
	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK)
		{
			EnableWindow(hButton, FALSE);
			SetWindowTextA(hEdit2, 0);
			const INT_PTR nEditLineCount1 = SendMessageA(hEdit1, EM_GETLINECOUNT, 0, 0);
			const INT_PTR bHtmlEscape = SendMessageA(hCheck, BM_GETCHECK, 0, 0);
			LPSTR lpszEdit3 = 0;
			const int nEditLenght3 = GetWindowTextLengthA(hEdit3);
			if (nEditLenght3)
			{
				lpszEdit3 = (LPSTR)GlobalAlloc(0, sizeof(CHAR) * (nEditLenght3 + 1));
				GetWindowTextA(hEdit3, lpszEdit3, nEditLenght3 + 1);
			}
			BOOL bIsFound;
			for (INT_PTR i = 0; i < nEditLineCount1; ++i)
			{
				bIsFound = FALSE;
				const INT_PTR nEditLineIndex1 = SendMessageA(hEdit1, EM_LINEINDEX, i, 0);
				const INT_PTR nEditLineLength1 = SendMessageA(hEdit1, EM_LINELENGTH, nEditLineIndex1, 0);
				if (!nEditLineLength1) continue;
				LPSTR lpszEditLine1 = (LPSTR)GlobalAlloc(0, sizeof(CHAR)* (nEditLineLength1 + 1 + 2)); // 改行文字2文字分追加
				*(WORD *)lpszEditLine1 = (WORD)nEditLineLength1;
				SendMessageA(hEdit1, EM_GETLINE, i, (LPARAM)lpszEditLine1);
				lpszEditLine1[nEditLineLength1] = 0;
				{
					const std::string target(lpszEditLine1);
					std::regex re(R"(https?://[-_.!~*\'()a-zA-Z0-9;/?:@&=+$,%#]+)");
					std::smatch match;
					for (auto it = target.begin(); regex_search(it, target.end(), match, re); it += match.position(0) + match.length(0))
					{
						std::string str(match.str(0));
						if (bHtmlEscape)
						{
							str = Replace(str, "&amp;", "&");
							str = Replace(str, "%3D", "=");
							str = Replace(str, "%22", "\"");
							str = Replace(str, "%20", " ");
						}
						if (!lpszEdit3 || StrStrIA(str.c_str(), lpszEdit3))
						{
							INT_PTR dwEditTextLength = SendMessageA(hEdit2, WM_GETTEXTLENGTH, 0, 0);
							SendMessageA(hEdit2, EM_SETSEL, dwEditTextLength, dwEditTextLength);
							SendMessageA(hEdit2, EM_REPLACESEL, 0, (LPARAM)str.c_str());
							SendMessageA(hEdit2, EM_REPLACESEL, 0, (LPARAM)"\r\n");
						}
					}
				}
				GlobalFree(lpszEditLine1);
			}
			if (lpszEdit3)
			{
				GlobalFree(lpszEdit3);
			}
			SendMessageA(hEdit2, EM_SETSEL, 0, -1);
			SetFocus(hEdit2);
			EnableWindow(hButton, TRUE);
		}
		break;
	case WM_CLOSE:
		DestroyWindow(hWnd);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefDlgProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}