Exemple #1
0
void VDShowHelp(HWND hwnd, const wchar_t *filename) {
	try {
		VDStringW helpFile(VDGetHelpPath());

		if (!VDDoesPathExist(helpFile.c_str()))
			throw MyError("Cannot find help file: %ls", helpFile.c_str());

		// If we're on Windows NT, check for the ADS and/or network drive.
		if (VDIsWindowsNT()) {
			VDStringW helpFileADS(helpFile);
			helpFileADS += L":Zone.Identifier";
			if (VDDoesPathExist(helpFileADS.c_str())) {
				int rv = MessageBox(hwnd, "VirtualDub has detected that its help file, VirtualDub.chm, has an Internet Explorer download location marker on it. This may prevent the help file from being displayed properly, resulting in \"Action canceled\" errors being displayed. Would you like to remove it?", "VirtualDub warning", MB_YESNO|MB_ICONEXCLAMATION);

				if (rv == IDYES)
					DeleteFileW(helpFileADS.c_str());
			}
		}

		if (filename) {
			helpFile.append(L"::/");
			helpFile.append(filename);
		}

		VDStringW helpCommand(VDStringW(L"\"hh.exe\" \"") + helpFile + L'"');

		PROCESS_INFORMATION pi;
		BOOL retval;

		// CreateProcess will actually modify the string that it gets, soo....
		if (VDIsWindowsNT()) {
			STARTUPINFOW si = {sizeof(STARTUPINFOW)};
			std::vector<wchar_t> tempbufW(helpCommand.size() + 1, 0);
			helpCommand.copy(&tempbufW[0], tempbufW.size());
			retval = CreateProcessW(NULL, &tempbufW[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		} else {
			STARTUPINFOA si = {sizeof(STARTUPINFOA)};
			VDStringA strA(VDTextWToA(helpCommand));
			std::vector<char> tempbufA(strA.size() + 1, 0);
			strA.copy(&tempbufA[0], tempbufA.size());
			retval = CreateProcessA(NULL, &tempbufA[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		}

		if (retval) {
			CloseHandle(pi.hThread);
			CloseHandle(pi.hProcess);
		} else
			throw MyWin32Error("Cannot launch HTML Help: %%s", GetLastError());
	} catch(const MyError& e) {
		e.post(hwnd, g_szError);
	}
}
Exemple #2
0
VDStringW VDGetLocalAppDataPath() {
	int csidl = CSIDL_APPDATA;

	HMODULE hmodShell32 = VDLoadSystemLibraryW32("shell32");

	if (hmodShell32) {
		typedef HRESULT (CALLBACK *tpDllGetVersion)(DLLVERSIONINFO *);

		DLLVERSIONINFO dvi = {sizeof(DLLVERSIONINFO)};

		tpDllGetVersion pDllGetVersion = (tpDllGetVersion)GetProcAddress(hmodShell32, "DllGetVersion");
		if (pDllGetVersion && NOERROR == pDllGetVersion(&dvi)) {
			if (dvi.dwMajorVersion >= 5)
				csidl = CSIDL_LOCAL_APPDATA;
		}

		FreeLibrary(hmodShell32);
	}

	if (VDIsWindowsNT()) {
		wchar_t pathW[MAX_PATH];

		if (!SHGetSpecialFolderPathW(NULL, pathW, csidl, FALSE))
			return VDGetProgramPath();

		return VDStringW(pathW);
	} else {
		char pathA[MAX_PATH];

		if (!SHGetSpecialFolderPathA(NULL, pathA, csidl, FALSE))
			return VDGetProgramPath();

		return VDTextAToW(pathA);
	}
}
Exemple #3
0
void VDUIListViewW32::SetItemText(int item, int subitem, const wchar_t *text) {
	DWORD dwMask = LVIF_TEXT;

	if (VDIsWindowsNT()) {
		LVITEMW lviw={0};

		lviw.mask		= dwMask;
		lviw.iItem		= item;
		lviw.iSubItem	= subitem;
		lviw.pszText	= (LPWSTR)text;

		SendMessageW(mhwnd, LVM_SETITEMTEXTW, (WPARAM)item, (LPARAM)&lviw);
	} else {
		LVITEMA lvia={0};

		VDStringA textA(VDTextWToA(text));

		lvia.mask		= dwMask;
		lvia.iItem		= item;
		lvia.iSubItem	= subitem;
		lvia.pszText	= (LPSTR)textA.c_str();

		SendMessageA(mhwnd, LVM_SETITEMTEXTA, (WPARAM)item, (LPARAM)&lvia);
	}
}
Exemple #4
0
void VDAppendMenuW32(HMENU hmenu, UINT flags, UINT id, const wchar_t *text){
	if (VDIsWindowsNT()) {
		AppendMenuW(hmenu, flags, id, text);
	} else {
		AppendMenuA(hmenu, flags, id, VDTextWToA(text).c_str());
	}
}
Exemple #5
0
void VDFileSetAttributes(const wchar_t *path, uint32 attrsToChange, uint32 newAttrs) {
    const uint32 nativeAttrMask = VDFileGetNativeAttributesFromAttrsW32(attrsToChange);
    const uint32 nativeAttrVals = VDFileGetNativeAttributesFromAttrsW32(newAttrs);

    if (VDIsWindowsNT()) {
        DWORD nativeAttrs = ::GetFileAttributesW(path);

        if (nativeAttrs != INVALID_FILE_ATTRIBUTES) {
            nativeAttrs ^= (nativeAttrs ^ nativeAttrVals) & nativeAttrMask;

            if (::SetFileAttributesW(path, nativeAttrs))
                return;
        }
    } else {
        VDStringA pathA(VDTextWToA(path));

        DWORD nativeAttrs = ::GetFileAttributesA(pathA.c_str());

        if (nativeAttrs != INVALID_FILE_ATTRIBUTES) {
            nativeAttrs ^= (nativeAttrs ^ nativeAttrVals) & nativeAttrMask;

            if (::SetFileAttributesA(pathA.c_str(), nativeAttrs))
                return;
        }
    }

    throw MyWin32Error("Cannot change attributes on \"%ls\": %%s.", GetLastError(), path);
}
Exemple #6
0
void VDSetWindowTextW32(HWND hwnd, const wchar_t *s) {
	if (VDIsWindowsNT()) {
		SetWindowTextW(hwnd, s);
	} else {
		SetWindowTextA(hwnd, VDTextWToA(s).c_str());
	}
}
Exemple #7
0
bool IsFilenameOnFATVolume(const wchar_t *pszFilename) {
	VDStringW rootPath(VDFileGetRootPath(pszFilename));

	if (VDIsWindowsNT()) {
		DWORD dwMaxComponentLength;
		DWORD dwFSFlags;
		wchar_t szFilesystem[MAX_PATH];

		if (!GetVolumeInformationW(rootPath.c_str(),
				NULL, 0,		// Volume name buffer
				NULL,			// Serial number buffer
				&dwMaxComponentLength,
				&dwFSFlags,
				szFilesystem,
				MAX_PATH))
			return false;

		return !_wcsnicmp(szFilesystem, L"FAT", 3);
	} else {
		DWORD dwMaxComponentLength;
		DWORD dwFSFlags;
		char szFilesystem[MAX_PATH];

		if (!GetVolumeInformationA(VDTextWToA(rootPath).c_str(),
				NULL, 0,		// Volume name buffer
				NULL,			// Serial number buffer
				&dwMaxComponentLength,
				&dwFSFlags,
				szFilesystem,
				sizeof szFilesystem))
			return false;

		return !_strnicmp(szFilesystem, "FAT", 3);
	}
}
Exemple #8
0
void VDUIListViewW32::AddColumn(const wchar_t *name, int width, int affinity) {
	VDASSERT(affinity >= 0);
	VDASSERT(width >= 0);

	if (VDIsWindowsNT()) {
		LVCOLUMNW lvcw={0};

		lvcw.mask		= LVCF_TEXT | LVCF_WIDTH;
		lvcw.pszText	= (LPWSTR)name;
		lvcw.cx			= width;

		SendMessageW(mhwnd, LVM_INSERTCOLUMNW, mColumns.size(), (LPARAM)&lvcw);
	} else {
		LVCOLUMNA lvca={0};
		VDStringA nameA(VDTextWToA(name));

		lvca.mask		= LVCF_TEXT | LVCF_WIDTH;
		lvca.pszText	= (LPSTR)nameA.c_str();
		lvca.cx			= width;

		SendMessageA(mhwnd, LVM_INSERTCOLUMNA, mColumns.size(), (LPARAM)&lvca);
	}

	mColumns.push_back(Column());
	Column& col = mColumns.back();

	col.mWidth		= width;
	col.mAffinity	= affinity;

	mTotalWidth		+= width;
	mTotalAffinity	+= affinity;

	OnResize();
}
Exemple #9
0
bool VDInitiateSystemShutdownWithUITimeout(VDSystemShutdownMode mode, const wchar_t *reason, uint32 timeout) {
	if (mode != kVDSystemShutdownMode_Shutdown)
		return false;

	if (!VDIsWindowsNT())
		return false;

	HMODULE hmodK32 = GetModuleHandleA("advapi32");
	if (!hmodK32)
		return false;

	EnableShutdownPrivilegesNT();

	typedef BOOL (WINAPI *tpInitiateSystemShutdownExW)(
		LPWSTR lpMachineName,
		LPWSTR lpMessage,
		DWORD dwTimeout,
		BOOL bForceAppsClosed,
		BOOL bRebootAfterShutdown,
		DWORD dwReason
	);

	tpInitiateSystemShutdownExW pInitiateSystemShutdownExW = (tpInitiateSystemShutdownExW)GetProcAddress(hmodK32, "InitiateSystemShutdownExW");
	if (!pInitiateSystemShutdownExW)
		return false;

	return 0 != pInitiateSystemShutdownExW(NULL, (LPWSTR)reason, timeout, TRUE, FALSE, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED);
}
Exemple #10
0
bool VDAppendPopupMenuW32(HMENU hmenu, UINT flags, HMENU hmenuPopup, const wchar_t *text){
	flags |= MF_POPUP;

	if (VDIsWindowsNT())
		return 0 != AppendMenuW(hmenu, flags, (UINT_PTR)hmenuPopup, text);
	else
		return 0 != AppendMenuA(hmenu, flags, (UINT_PTR)hmenuPopup, VDTextWToA(text).c_str());
}
Exemple #11
0
void VDGetRootPaths(vdvector<VDStringW>& paths) {
    union {
        WCHAR w[512];
        CHAR a[1024];
    } buf;

    if (VDIsWindowsNT()) {
        vdfastvector<WCHAR> heapbufw;
        WCHAR *pw = buf.w;
        DWORD wlen = vdcountof(buf.w);

        for(;;) {
            *pw = 0;

            DWORD r = GetLogicalDriveStringsW(wlen, pw);

            if (!r)
                return;

            if (r <= wlen)
                break;

            heapbufw.resize(r);
            wlen = r;
            pw = heapbufw.data();
        }

        while(*pw) {
            paths.push_back() = pw;
            pw += wcslen(pw) + 1;
        }
    } else {
        vdfastvector<CHAR> heapbufa;
        CHAR *pa = buf.a;
        DWORD alen = vdcountof(buf.a);

        for(;;) {
            *pa = 0;

            DWORD r = GetLogicalDriveStringsA(alen, pa);

            if (!r)
                return;

            if (r <= alen)
                break;

            heapbufa.resize(r);
            alen = r;
            pa = heapbufa.data();
        }

        while(*pa) {
            paths.push_back() = VDTextAToW(pa);
            pa += strlen(pa) + 1;
        }
    }
}
Exemple #12
0
void VDCopyTextToClipboard(const wchar_t *s) {
	if (VDIsWindowsNT())
		VDCopyTextToClipboardW(s);
	else {
		VDStringA sa(VDTextWToA(s));

		VDCopyTextToClipboardA(sa.c_str());
	}
}
Exemple #13
0
bool VDDeletePathAutodetect(const wchar_t *path) {
    if (VDIsWindowsNT()) {
        spDeleteFileW = (tpDeleteFileW)GetProcAddress(GetModuleHandle("kernel32"), "DeleteFileW");
        VDRemoveFile = VDDeleteFileNT;
    } else
        VDRemoveFile = VDDeleteFile9x;

    return VDRemoveFile(path);
}
Exemple #14
0
uint32 VDFileGetAttributes(const wchar_t *path) {
    uint32 nativeAttrs = 0;
    if (VDIsWindowsNT())
        nativeAttrs = ::GetFileAttributesW(path);
    else
        nativeAttrs = ::GetFileAttributesA(VDTextWToA(path).c_str());

    return VDFileGetAttributesFromNativeW32(nativeAttrs);
}
Exemple #15
0
void VDMoveFile(const wchar_t *srcPath, const wchar_t *dstPath) {
    bool success;
    if (VDIsWindowsNT()) {
        success = MoveFileW(srcPath, dstPath) != 0;
    } else {
        success = MoveFileA(VDTextWToA(srcPath).c_str(), VDTextWToA(dstPath).c_str()) != 0;
    }

    if (!success)
        throw MyWin32Error("Cannot rename \"%ls\" to \"%ls\": %%s", GetLastError(), srcPath, dstPath);
}
Exemple #16
0
int VDUIListBoxW32::AddItem(const wchar_t *text, uintptr data) {
	int idx;

	if (VDIsWindowsNT())
		idx = (int)SendMessageW(mhwnd, LB_ADDSTRING, 0, (LPARAM)text);
	else
		idx = (int)SendMessageA(mhwnd, LB_ADDSTRING, 0, (LPARAM)VDTextWToA(text).c_str());

	if (idx >= 0)
		SendMessage(mhwnd, LB_SETITEMDATA, (WPARAM)idx, (LPARAM)data);

	return idx;
}
Exemple #17
0
int VDUIComboBoxW32::AddItem(const wchar_t *text, uintptr data) {
	int sel;

	if (VDIsWindowsNT())
		sel = (int)SendMessageW(mhwnd, CB_ADDSTRING, 0, (LPARAM)text);
	else
		sel = (int)SendMessageA(mhwnd, CB_ADDSTRING, 0, (LPARAM)VDTextWToA(text).c_str());

	if (sel >= 0)
		SendMessage(mhwnd, CB_SETITEMDATA, (WPARAM)sel, (LPARAM)data);

	return sel;
}
Exemple #18
0
IVDFileAsync *VDCreateFileAsync(IVDFileAsync::Mode mode) {
	switch(mode) {

		case IVDFileAsync::kModeAsynchronous:
			if (VDIsWindowsNT())
				return new VDFileAsyncNT;
			// Can't do async I/O. Fall-through to 9x method.
		case IVDFileAsync::kModeThreaded:
			return new VDFileAsync9x(true, true);

		default:
			return new VDFileAsync9x(false, true);

		case IVDFileAsync::kModeBuffered:
			return new VDFileAsync9x(false, false);
	}
}
Exemple #19
0
VDStringW VDGetMenuItemTextByCommandW32(HMENU hmenu, UINT cmd) {
	VDStringW s;

	if (VDIsWindowsNT()) {
		MENUITEMINFOW mmiW;
		vdfastfixedvector<wchar_t, 256> bufW;

		mmiW.cbSize		= MENUITEMINFO_SIZE_VERSION_400W;
		mmiW.fMask		= MIIM_TYPE;
		mmiW.fType		= MFT_STRING;
		mmiW.dwTypeData	= NULL;
		mmiW.cch		= 0;		// required to avoid crash on NT4

		if (GetMenuItemInfoW(hmenu, cmd, FALSE, &mmiW)) {
			bufW.resize(mmiW.cch + 1, 0);
			++mmiW.cch;
			mmiW.dwTypeData = bufW.data();

			if (GetMenuItemInfoW(hmenu, cmd, FALSE, &mmiW))
				s = bufW.data();
		}
	} else {
		MENUITEMINFOA mmiA;
		vdfastfixedvector<char, 256> bufA;

		mmiA.cbSize		= MENUITEMINFO_SIZE_VERSION_400A;
		mmiA.fMask		= MIIM_TYPE;
		mmiA.fType		= MFT_STRING;
		mmiA.dwTypeData	= NULL;

		if (GetMenuItemInfoA(hmenu, cmd, FALSE, &mmiA)) {
			bufA.resize(mmiA.cch + 1, 0);
			++mmiA.cch;
			mmiA.dwTypeData = bufA.data();

			if (GetMenuItemInfoA(hmenu, cmd, FALSE, &mmiA))
				s = VDTextAToW(bufA.data());
		}
	}

	return s;
}
Exemple #20
0
VDStringW VDGetRootVolumeLabel(const wchar_t *rootPath) {
    union {
        char a[MAX_PATH * 2];
        wchar_t w[MAX_PATH];
    } buf;

    DWORD maxComponentLength;
    DWORD fsFlags;
    VDStringW name;

    if (VDIsWindowsNT()) {
        if (GetVolumeInformationW(rootPath, buf.w, vdcountof(buf.w), NULL, &maxComponentLength, &fsFlags, NULL, 0))
            name = buf.w;
    } else {
        if (GetVolumeInformationA(VDTextWToA(rootPath).c_str(), buf.a, vdcountof(buf.a), NULL, &maxComponentLength, &fsFlags, NULL, 0))
            name = VDTextAToW(buf.a);
    }

    return name;
}
Exemple #21
0
uint64 VDFileGetLastWriteTime(const wchar_t *path) {
    if (VDIsWindowsNT()) {
        WIN32_FIND_DATAW fdw;
        HANDLE h = FindFirstFileW(path, &fdw);
        if (h == INVALID_HANDLE_VALUE)
            return 0;

        FindClose(h);

        return ((uint64)fdw.ftLastWriteTime.dwHighDateTime << 32) + fdw.ftLastWriteTime.dwLowDateTime;
    } else {
        WIN32_FIND_DATAA fda;
        HANDLE h = FindFirstFileA(VDTextWToA(path).c_str(), &fda);
        if (h == INVALID_HANDLE_VALUE)
            return 0;

        FindClose(h);

        return ((uint64)fda.ftLastWriteTime.dwHighDateTime << 32) + fda.ftLastWriteTime.dwLowDateTime;
    }
}
Exemple #22
0
VDStringW VDGetWindowTextW32(HWND hwnd) {
	union {
		wchar_t w[256];
		char a[512];
	} buf;

	if (VDIsWindowsNT()) {
		int len = GetWindowTextLengthW(hwnd);

		if (len > 255) {
			vdblock<wchar_t> tmp(len + 1);
			len = GetWindowTextW(hwnd, tmp.data(), tmp.size());

			VDStringW text(tmp.data(), len);
			return text;
		} else if (len > 0) {
			len = GetWindowTextW(hwnd, buf.w, 256);

			VDStringW text(buf.w, len);
			return text;
		}
	} else {
		int len = GetWindowTextLengthA(hwnd);

		if (len > 511) {
			vdblock<char> tmp(len + 1);
			len = GetWindowTextA(hwnd, tmp.data(), tmp.size());

			VDStringW text(VDTextAToW(tmp.data(), len));
			return text;
		} else if (len > 0) {
			len = GetWindowTextA(hwnd, buf.a, 512);

			VDStringW text(VDTextAToW(buf.a, len));
			return text;
		}
	}

	return VDStringW();
}
Exemple #23
0
void VDSetMenuItemTextByCommandW32(HMENU hmenu, UINT cmd, const wchar_t *text) {
	if (VDIsWindowsNT()) {
		MENUITEMINFOW mmiW;

		mmiW.cbSize		= MENUITEMINFO_SIZE_VERSION_400W;
		mmiW.fMask		= MIIM_TYPE;
		mmiW.fType		= MFT_STRING;
		mmiW.dwTypeData	= (LPWSTR)text;

		SetMenuItemInfoW(hmenu, cmd, FALSE, &mmiW);
	} else {
		MENUITEMINFOA mmiA;
		VDStringA textA(VDTextWToA(text));

		mmiA.cbSize		= MENUITEMINFO_SIZE_VERSION_400A;
		mmiA.fMask		= MIIM_TYPE;
		mmiA.fType		= MFT_STRING;
		mmiA.dwTypeData	= (LPSTR)textA.c_str();

		SetMenuItemInfoA(hmenu, cmd, FALSE, &mmiA);
	}
}
Exemple #24
0
VDStringW VDGetProgramFilePath() {
    union {
        wchar_t w[MAX_PATH];
        char a[MAX_PATH];
    } buf;

    VDStringW wstr;

    if (VDIsWindowsNT()) {
        if (!GetModuleFileNameW(NULL, buf.w, MAX_PATH))
            throw MyWin32Error("Unable to get program path: %%s", GetLastError());

        wstr = buf.w;
    } else {
        if (GetModuleFileNameA(NULL, buf.a, MAX_PATH))
            throw MyWin32Error("Unable to get program path: %%s", GetLastError());

        wstr = VDTextAToW(buf.a, -1);
    }

    return wstr;
}
Exemple #25
0
int VDUIListViewW32::AddItem(const wchar_t *text, uintptr data) {
	DWORD dwMask = LVIF_PARAM | LVIF_TEXT;

	if (mbCheckable)
		dwMask |= LVIF_STATE;

	int item;
	if (VDIsWindowsNT()) {
		LVITEMW lviw={0};

		lviw.mask		= dwMask;
		lviw.iItem		= 0x1FFFFFFF;
		lviw.iSubItem	= 0;
		lviw.state		= 0x1000;
		lviw.stateMask	= (UINT)-1;
		lviw.pszText	= (LPWSTR)text;
		lviw.lParam		= (LPARAM)data;

		item = (int)SendMessageW(mhwnd, LVM_INSERTITEMW, 0, (LPARAM)&lviw);
	} else {
		LVITEMA lvia={0};

		VDStringA textA(VDTextWToA(text));

		lvia.mask		= dwMask;
		lvia.iItem		= 0x1FFFFFFF;
		lvia.iSubItem	= 0;
		lvia.state		= 0x1000;
		lvia.stateMask	= (UINT)-1;
		lvia.pszText	= (LPSTR)textA.c_str();
		lvia.lParam		= (LPARAM)data;

		item = (int)SendMessageA(mhwnd, LVM_INSERTITEMA, 0, (LPARAM)&lvia);
	}

	return item;
}
Exemple #26
0
void VDAppendMenuSeparatorW32(HMENU hmenu) {
	int pos = GetMenuItemCount(hmenu);
	if (pos < 0)
		return;

	if (VDIsWindowsNT()) {
		MENUITEMINFOW mmiW;
		vdfastfixedvector<wchar_t, 256> bufW;

		mmiW.cbSize		= MENUITEMINFO_SIZE_VERSION_400W;
		mmiW.fMask		= MIIM_TYPE;
		mmiW.fType		= MFT_SEPARATOR;

		InsertMenuItemW(hmenu, pos, TRUE, &mmiW);
	} else {
		MENUITEMINFOA mmiA;

		mmiA.cbSize		= MENUITEMINFO_SIZE_VERSION_400A;
		mmiA.fMask		= MIIM_TYPE;
		mmiA.fType		= MFT_SEPARATOR;

		InsertMenuItemA(hmenu, pos, TRUE, &mmiA);
	}
}
Exemple #27
0
LRESULT VDDialogBaseW32::ActivateDialogDual(VDGUIHandle hParent) {
	if (VDIsWindowsNT())
		return DialogBoxParamW(g_hInst, IS_INTRESOURCE(mpszDialogName) ? (LPCWSTR)mpszDialogName : VDTextAToW(mpszDialogName).c_str(), (HWND)hParent, StaticDlgProc, (LPARAM)this);
	else
		return DialogBoxParamA(g_hInst, mpszDialogName, (HWND)hParent, StaticDlgProc, (LPARAM)this);
}
Exemple #28
0
LRESULT VDUIBaseWindowW32::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) {
	switch(msg) {
		case WM_INITDIALOG:
			{
				RECT r;
				GetWindowRect(mhwnd, &r);
				MapWindowPoints(mhwnd, ::GetParent(mhwnd), (LPPOINT)&r, 2);
				mArea.left = r.left;
				mArea.top = r.top;
				mArea.right = r.right;
				mArea.bottom = r.bottom;

				DispatchEvent(this, mID, IVDUICallback::kEventCreate, 0);

				DWORD dwStyle = GetWindowLong(mhwnd, GWL_STYLE);

				if (dwStyle & WS_THICKFRAME) {
					EnumResourceNames(VDGetLocalModuleHandleW32(), RT_GROUP_ICON, SetApplicationIconOnDialog, (LONG_PTR)mhwnd);
				}

				if (!(dwStyle & DS_CONTROL))
					Relayout();

				ExecuteAllLinks();
			}
			return FALSE;
   
		case WM_GETMINMAXINFO:
			{
				MINMAXINFO *pmmi = (MINMAXINFO *)lParam;
   
				pmmi->ptMinTrackSize.x = mLayoutSpecs.minsize.w;
				pmmi->ptMinTrackSize.y = mLayoutSpecs.minsize.h;
   
				if ((mAlignX & nsVDUI::kAlignTypeMask) != nsVDUI::kFill)
					pmmi->ptMaxTrackSize.x = mLayoutSpecs.minsize.w;
   
				if ((mAlignY & nsVDUI::kAlignTypeMask) != nsVDUI::kFill)
					pmmi->ptMaxTrackSize.y = mLayoutSpecs.minsize.h;
			}
			return 0;

		case WM_SIZE:
			if (!(GetWindowLong(mhwnd, GWL_STYLE) & WS_CHILD)) {
				vduirect r(GetClientArea());

				if (r.size() != GetArea().size()) {
					r.left   += mInsets.left;
					r.top    += mInsets.top;
					r.right  -= mInsets.right;
					r.bottom -= mInsets.bottom;

					tChildren::iterator it(mChildren.begin()), itEnd(mChildren.end());

					for(; it!=itEnd; ++it) {
						IVDUIWindow *pWin = *it;

						pWin->PostLayout(r);
					}
				}
			}
			return 0;

		case WM_CLOSE:
			if (DispatchEvent(this, mID, IVDUICallback::kEventClose, 0))
				return 0;
			goto handle_cancel;

		case WM_NOTIFYFORMAT:
			return VDIsWindowsNT() ? NFR_UNICODE : NFR_ANSI;

		case WM_COMMAND:
			// special handling for commands that have have keyboard equivalents in
			// the dialog manager; we never assign these native IDs so it's safe to
			// shortcut them
			if (LOWORD(wParam) == IDOK) {
				DispatchEvent(this, 10, IVDUICallback::kEventSelect, 0);
				return 0;
			} else if (LOWORD(wParam) == IDCANCEL) {
handle_cancel:
				if (!DispatchEvent(this, 11, IVDUICallback::kEventSelect, 0)) {
					if (mpModal)
						EndModal(-1);
					else
						Shutdown();
				}
				return 0;
			} else if (!lParam) {
				// dispatch menu/accelerator commands
				DispatchEvent(this, LOWORD(wParam), IVDUICallback::kEventSelect, 0);
				return 0;
			}
			break;
	}

	return VDUICustomControlW32::WndProc(msg, wParam, lParam);
}
Exemple #29
0
VDStringW VDGetSystemPath() {
    if (VDIsWindowsNT())
        return VDGetSystemPathNT();

    return VDGetSystemPath9x();
}
Exemple #30
0
static void ExitWindowsExDammit(UINT uFlags, DWORD dwReserved) {
	if (VDIsWindowsNT())
		EnableShutdownPrivilegesNT();

	ExitWindowsEx(uFlags, dwReserved);
}