Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ClientResize(HWND hWnd, int nWidth, int nHeight)
- {
- RECT rcClient, rcWind;
- POINT ptDiff;
- GetClientRect(hWnd, &rcClient);
- GetWindowRect(hWnd, &rcWind);
- ptDiff.x = (rcWind.right - rcWind.left) - rcClient.right;
- ptDiff.y = (rcWind.bottom - rcWind.top) - rcClient.bottom;
- MoveWindow(hWnd, rcWind.left, rcWind.top, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE);
- }
- static UINT APIENTRY OFNHookProcOldStyle(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- if (uMsg == WM_INITDIALOG)
- {
- ClientResize(hWnd, 424, 255);
- RECT rect;
- GetWindowRect(hWnd, &rect);
- MoveWindow(hWnd, (GetSystemMetrics(SM_CXSCREEN) / 2) - ((rect.right - rect.left) / 2), (GetSystemMetrics(SM_CYSCREEN) / 2) - ((rect.bottom - rect.top) / 2), rect.right - rect.left, rect.bottom - rect.top, true);
- HWND bttn1 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "Button", "OK")));
- HWND bttn2 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "Button", "Cancel")));
- HWND list1 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "ListBox", NULL)));
- HWND list2 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, list1, "ListBox", NULL)));
- HWND label1 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "Static", "File &name:")));
- HWND label2 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "Static", "&Folders:")));
- HWND label3 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "Static", "List files of &type:")));
- HWND label4 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "Static", "Dri&ves:")));
- HWND label5 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, label2, "Static", NULL)));
- HWND cmbbx1 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "ComboBox", NULL)));
- HWND cmbbx2 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, cmbbx1, "ComboBox", NULL)));
- HWND txtbx1 = GetDlgItem(hWnd, GetDlgCtrlID(FindWindowEx(hWnd, NULL, "Edit", NULL)));
- SetWindowText(label1, "&Files: (*.*)");
- SetWindowText(label2, "&Directories:");
- SetWindowText(label3, "Directory &Name:");
- SetWindowText(label4, "D&rives:");
- EnableWindow(list1, FALSE);
- DestroyWindow(cmbbx1);
- DestroyWindow(txtbx1);
- MoveWindow(bttn1, 257, 225, 74, 27, true);
- MoveWindow(bttn2, 341, 225, 74, 27, true);
- MoveWindow(label1, 232, 56, 72, 16, true);
- MoveWindow(label2, 8, 56, 72, 16, true);
- MoveWindow(label3, 8, 8, 93, 16, true);
- MoveWindow(label4, 232, 176, 50, 16, true);
- MoveWindow(label5, 8, 24, 409, 16, true);
- MoveWindow(list1, 232, 72, 185, 93, true);
- MoveWindow(list2, 8, 72, 213, 123, true);
- MoveWindow(cmbbx2, 232, 192, 185, 19, true);
- ShowScrollBar(list1, SB_BOTH, FALSE);
- ShowScrollBar(list2, SB_BOTH, FALSE);
- }
- if (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK)
- {
- PostMessage(hWnd, WM_COMMAND, IDABORT, 0);
- return TRUE;
- }
- return FALSE;
- }
- DLL char *get_directory(char *dname)
- {
- OPENFILENAMEW ofn;
- HWND SitehWnd;
- SitehWnd = GetAncestor(GetActiveWindow(), GA_ROOTOWNER);
- string str_dname = dname;
- tstring tstr_filter = widen("*.*|*.*|");
- replace(tstr_filter.begin(), tstr_filter.end(), '|', '\0');
- tstring tstr_dname = widen(str_dname);
- tstring tstr_title = widen("Select Directory");
- WCHAR wstr_dname[MAX_PATH];
- wcsncpy_s(wstr_dname, tstr_dname.c_str(), MAX_PATH);
- ZeroMemory(&ofn, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = SitehWnd;
- ofn.lpstrFile = wstr_dname;
- ofn.nMaxFile = MAX_PATH;
- ofn.lpstrFilter = tstr_filter.c_str();
- ofn.nFilterIndex = 0;
- ofn.lpstrTitle = tstr_title.c_str();
- ofn.lpstrInitialDir = NULL;
- ofn.Flags = OFN_NONETWORKBUTTON | OFN_ENABLEHOOK | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES;
- ofn.lpfnHook = OFNHookProcOldStyle;
- GetOpenFileNameW(&ofn);
- DWORD attrib = GetFileAttributesW(wstr_dname);
- if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY))
- {
- static string result;
- result = shorten(wstr_dname);
- return (char *)result.c_str();
- }
- return (char *)"";
- }
Add Comment
Please, Sign In to add comment