本文整理汇总了C++中WindowInfo::Focus方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowInfo::Focus方法的具体用法?C++ WindowInfo::Focus怎么用?C++ WindowInfo::Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowInfo
的用法示例。
在下文中一共展示了WindowInfo::Focus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindWindowInfoByFile
// Jump to page DDE command. Format:
// [<DDECOMMAND_PAGE>("<pdffilepath>", <page number>)]
static const WCHAR *HandlePageCmd(const WCHAR *cmd, DDEACK& ack)
{
ScopedMem<WCHAR> pdfFile;
UINT page;
const WCHAR *next = str::Parse(cmd, L"[" DDECOMMAND_PAGE L"(\"%S\",%u)]",
&pdfFile, &page);
if (!next)
return false;
// check if the PDF is already opened
WindowInfo *win = FindWindowInfoByFile(pdfFile);
if (!win)
return next;
if (!win->IsDocLoaded()) {
ReloadDocument(win);
if (!win->IsDocLoaded())
return next;
}
if (!win->dm->ValidPageNo(page))
return next;
win->dm->GoToPage(page, 0, true);
ack.fAck = 1;
win->Focus();
return next;
}
示例2: args
// Open file DDE command, format:
// [<DDECOMMAND_OPEN>("<pdffilepath>"[,<newwindow>,<setfocus>,<forcerefresh>])]
static const WCHAR *HandleOpenCmd(const WCHAR *cmd, DDEACK& ack)
{
ScopedMem<WCHAR> pdfFile;
BOOL newWindow = 0, setFocus = 0, forceRefresh = 0;
const WCHAR *next = str::Parse(cmd, L"[" DDECOMMAND_OPEN L"(\"%S\")]", &pdfFile);
if (!next)
next = str::Parse(cmd, L"[" DDECOMMAND_OPEN L"(\"%S\",%u,%u,%u)]",
&pdfFile, &newWindow, &setFocus, &forceRefresh);
if (!next)
return NULL;
WindowInfo *win = FindWindowInfoByFile(pdfFile);
if (newWindow || !win) {
LoadArgs args(pdfFile, !newWindow ? win : NULL);
win = LoadDocument(args);
} else if (win && !win->IsDocLoaded()) {
ReloadDocument(win);
forceRefresh = 0;
}
assert(!win || !win->IsAboutWindow());
if (!win)
return next;
ack.fAck = 1;
if (forceRefresh)
ReloadDocument(win, true);
if (setFocus)
win->Focus();
return next;
}
示例3: LaunchFile
void LinkHandler::LaunchFile(const WCHAR *path, PageDestination *link)
{
// for safety, only handle relative paths and only open them in SumatraPDF
// (unless they're of an allowed perceived type) and never launch any external
// file in plugin mode (where documents are supposed to be self-contained)
WCHAR drive;
if (str::StartsWith(path, L"\\") || str::Parse(path, L"%c:\\", &drive) || gPluginMode) {
return;
}
ScopedMem<WCHAR> fullPath(path::GetDir(owner->dm->FilePath()));
fullPath.Set(path::Join(fullPath, path));
fullPath.Set(path::Normalize(fullPath));
// TODO: respect link->ld.gotor.new_window for PDF documents ?
WindowInfo *newWin = FindWindowInfoByFile(fullPath);
// TODO: don't show window until it's certain that there was no error
if (!newWin) {
LoadArgs args(fullPath, owner);
newWin = LoadDocument(args);
if (!newWin)
return;
}
if (!newWin->IsDocLoaded()) {
CloseWindow(newWin, true);
// OpenFileExternally rejects files we'd otherwise
// have to show a notification to be sure (which we
// consider bad UI and thus simply don't)
bool ok = OpenFileExternally(fullPath);
if (!ok) {
ScopedMem<WCHAR> msg(str::Format(_TR("Error loading %s"), fullPath));
ShowNotification(owner, msg, true /* autoDismiss */, true /* highlight */);
}
return;
}
newWin->Focus();
if (!link)
return;
ScopedMem<WCHAR> name(link->GetDestName());
if (!name)
newWin->linkHandler->ScrollTo(link);
else {
PageDestination *dest = newWin->dm->engine->GetNamedDest(name);
if (dest) {
newWin->linkHandler->ScrollTo(dest);
delete dest;
}
}
}
示例4: GotoLink
void LinkHandler::GotoLink(PageDestination *link)
{
CrashIf(!owner || owner->linkHandler != this);
if (!link || !owner->IsDocLoaded())
return;
ScopedMem<WCHAR> path(link->GetDestValue());
PageDestType type = link->GetDestType();
if (Dest_ScrollTo == type) {
// TODO: respect link->ld.gotor.new_window for PDF documents ?
ScrollTo(link);
}
else if (Dest_LaunchURL == type) {
if (!path)
/* ignore missing URLs */;
else {
WCHAR *colon = str::FindChar(path, ':');
WCHAR *hash = str::FindChar(path, '#');
if (!colon || (hash && colon > hash)) {
// treat relative URIs as file paths (without fragment identifier)
if (hash)
*hash = '\0';
// LaunchFile will reject unsupported file types
LaunchFile(path, NULL);
}
else {
// LaunchBrowser will reject unsupported URI schemes
LaunchBrowser(path);
}
}
}
else if (Dest_LaunchEmbedded == type) {
// open embedded PDF documents in a new window
if (path && str::StartsWith(path.Get(), owner->ctrl->FilePath())) {
WindowInfo *newWin = FindWindowInfoByFile(path, true);
if (!newWin) {
LoadArgs args(path, owner);
newWin = LoadDocument(args);
}
if (newWin)
newWin->Focus();
}
// offer to save other attachments to a file
else {
LinkSaver linkSaverTmp(*owner, path);
link->SaveEmbedded(linkSaverTmp);
}
}
else if (Dest_LaunchFile == type) {
if (path) {
// LaunchFile only opens files inside SumatraPDF
// (except for allowed perceived file types)
LaunchFile(path, link);
}
}
// predefined named actions
else if (Dest_NextPage == type)
owner->ctrl->GoToNextPage();
else if (Dest_PrevPage == type)
owner->ctrl->GoToPrevPage();
else if (Dest_FirstPage == type)
owner->ctrl->GoToFirstPage();
else if (Dest_LastPage == type)
owner->ctrl->GoToLastPage();
// Adobe Reader extensions to the spec, cf. http://www.tug.org/applications/hyperref/manual.html
else if (Dest_FindDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_FIND_FIRST, 0);
else if (Dest_FullScreen == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_VIEW_PRESENTATION_MODE, 0);
else if (Dest_GoBack == type)
owner->ctrl->Navigate(-1);
else if (Dest_GoForward == type)
owner->ctrl->Navigate(1);
else if (Dest_GoToPageDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_GOTO_PAGE, 0);
else if (Dest_PrintDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_PRINT, 0);
else if (Dest_SaveAsDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_SAVEAS, 0);
else if (Dest_ZoomToDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_ZOOM_CUSTOM, 0);
else
CrashIf(Dest_None != type);
}