forked from openlp/openlp
pptviewer mods
This commit is contained in:
parent
23b9884775
commit
e8de37f7b3
@ -140,8 +140,10 @@ class PptviewDocument(PresentationDocument):
|
|||||||
PPTviewLib creates large BMP's, but we want small PNG's for consistency.
|
PPTviewLib creates large BMP's, but we want small PNG's for consistency.
|
||||||
Convert them here.
|
Convert them here.
|
||||||
"""
|
"""
|
||||||
|
log.debug(u'create_thumbnails')
|
||||||
if self.check_thumbnails():
|
if self.check_thumbnails():
|
||||||
return
|
return
|
||||||
|
log.debug(u'create_thumbnails proceeding')
|
||||||
for idx in range(self.get_slide_count()):
|
for idx in range(self.get_slide_count()):
|
||||||
path = u'%s\\slide%s.bmp' % (self.get_temp_folder(),
|
path = u'%s\\slide%s.bmp' % (self.get_temp_folder(),
|
||||||
unicode(idx + 1))
|
unicode(idx + 1))
|
||||||
|
@ -48,10 +48,8 @@ BOOL debug = FALSE;
|
|||||||
|
|
||||||
HINSTANCE hInstance = NULL;
|
HINSTANCE hInstance = NULL;
|
||||||
|
|
||||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call,
|
||||||
DWORD ul_reason_for_call,
|
LPVOID lpReserved)
|
||||||
LPVOID lpReserved
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
hInstance = (HINSTANCE)hModule;
|
hInstance = (HINSTANCE)hModule;
|
||||||
switch (ul_reason_for_call)
|
switch (ul_reason_for_call)
|
||||||
@ -96,20 +94,14 @@ DllExport BOOL CheckInstalled()
|
|||||||
// "<n>.bmp" will be appended to complete the path. E.g. "c:\temp\slide" would
|
// "<n>.bmp" will be appended to complete the path. E.g. "c:\temp\slide" would
|
||||||
// create "c:\temp\slide1.bmp" slide2.bmp, slide3.bmp etc.
|
// create "c:\temp\slide1.bmp" slide2.bmp, slide3.bmp etc.
|
||||||
// It will also create a *info.txt containing information about the ppt
|
// It will also create a *info.txt containing information about the ppt
|
||||||
DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewpath)
|
DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
|
||||||
|
char *previewpath)
|
||||||
{
|
{
|
||||||
STARTUPINFO si;
|
|
||||||
PROCESS_INFORMATION pi;
|
|
||||||
char cmdline[MAX_PATH * 2];
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
DEBUG("OpenPPT start: %s; %s\n", filename, previewpath);
|
DEBUG("OpenPPT start: %s; %s\n", filename, previewpath);
|
||||||
DEBUG("OpenPPT start: %u; %i, %i, %i, %i\n", hParentWnd, rect.top, rect.left, rect.bottom, rect.right);
|
DEBUG("OpenPPT start: %u; %i, %i, %i, %i\n", hParentWnd, rect.top,
|
||||||
if(GetPPTViewerPath(cmdline, sizeof(cmdline))==FALSE)
|
rect.left, rect.bottom, rect.right);
|
||||||
{
|
|
||||||
DEBUG("OpenPPT: GetPPTViewerPath failed\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
id = -1;
|
id = -1;
|
||||||
for(int i = 0; i < MAX_PPTOBJS; i++)
|
for(int i = 0; i < MAX_PPTOBJS; i++)
|
||||||
{
|
{
|
||||||
@ -124,76 +116,13 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewp
|
|||||||
DEBUG("OpenPPT: Too many PPTs\n");
|
DEBUG("OpenPPT: Too many PPTs\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(&pptviewobj[id], 0, sizeof(PPTVIEWOBJ));
|
BOOL gotinfo = InitPPTObject(id, filename, hParentWnd, rect, previewpath);
|
||||||
strcpy_s(pptviewobj[id].filename, MAX_PATH, filename);
|
if(!StartPPTView(id))
|
||||||
strcpy_s(pptviewobj[id].previewpath, MAX_PATH, previewpath);
|
|
||||||
pptviewobj[id].state = PPT_CLOSED;
|
|
||||||
pptviewobj[id].slideCount = 0;
|
|
||||||
pptviewobj[id].currentSlide = 0;
|
|
||||||
pptviewobj[id].firstSlideSteps = 0;
|
|
||||||
pptviewobj[id].hParentWnd = hParentWnd;
|
|
||||||
pptviewobj[id].hWnd = NULL;
|
|
||||||
pptviewobj[id].hWnd2 = NULL;
|
|
||||||
if(hParentWnd!=NULL&&rect.top==0&&rect.bottom==0&&rect.left==0&&rect.right==0)
|
|
||||||
{
|
{
|
||||||
LPRECT wndrect = NULL;
|
|
||||||
GetWindowRect(hParentWnd, wndrect);
|
|
||||||
pptviewobj[id].rect.top = 0;
|
|
||||||
pptviewobj[id].rect.left = 0;
|
|
||||||
pptviewobj[id].rect.bottom = wndrect->bottom-wndrect->top;
|
|
||||||
pptviewobj[id].rect.right = wndrect->right-wndrect->left;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pptviewobj[id].rect.top = rect.top;
|
|
||||||
pptviewobj[id].rect.left = rect.left;
|
|
||||||
pptviewobj[id].rect.bottom = rect.bottom;
|
|
||||||
pptviewobj[id].rect.right = rect.right;
|
|
||||||
}
|
|
||||||
strcat_s(cmdline, MAX_PATH * 2, "/F /S \"");
|
|
||||||
strcat_s(cmdline, MAX_PATH * 2, filename);
|
|
||||||
strcat_s(cmdline, MAX_PATH * 2, "\"");
|
|
||||||
memset(&si, 0, sizeof(si));
|
|
||||||
memset(&pi, 0, sizeof(pi));
|
|
||||||
BOOL gotinfo = GetPPTInfo(id);
|
|
||||||
/*
|
|
||||||
* I'd really like to just hook on the new threadid. However this always gives
|
|
||||||
* error 87. Perhaps I'm hooking to soon? No idea... however can't wait
|
|
||||||
* since I need to ensure I pick up the WM_CREATE as this is the only
|
|
||||||
* time the window can be resized in such away the content scales correctly
|
|
||||||
*
|
|
||||||
* hook = SetWindowsHookEx(WH_CBT,CbtProc,hInstance,pi.dwThreadId);
|
|
||||||
*/
|
|
||||||
if(globalhook!=NULL)
|
|
||||||
UnhookWindowsHookEx(globalhook);
|
|
||||||
globalhook = SetWindowsHookEx(WH_CBT,CbtProc,hInstance,NULL);
|
|
||||||
if(globalhook==0)
|
|
||||||
{
|
|
||||||
DEBUG("OpenPPT: SetWindowsHookEx failed\n");
|
|
||||||
ClosePPT(id);
|
ClosePPT(id);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pptviewobj[id].state = PPT_STARTED;
|
if(!gotinfo)
|
||||||
Sleep(10);
|
|
||||||
if(!CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, 0, NULL, &si, &pi))
|
|
||||||
{
|
|
||||||
DEBUG("OpenPPT: CreateProcess failed\n");
|
|
||||||
ClosePPT(id);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pptviewobj[id].dwProcessId = pi.dwProcessId;
|
|
||||||
pptviewobj[id].dwThreadId = pi.dwThreadId;
|
|
||||||
pptviewobj[id].hThread = pi.hThread;
|
|
||||||
pptviewobj[id].hProcess = pi.hProcess;
|
|
||||||
while(pptviewobj[id].state==PPT_STARTED)
|
|
||||||
Sleep(10);
|
|
||||||
if(gotinfo)
|
|
||||||
{
|
|
||||||
DEBUG("OpenPPT: Info loaded, no refresh\n");
|
|
||||||
pptviewobj[id].state = PPT_LOADED;
|
|
||||||
Resume(id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
DEBUG("OpenPPT: Get info\n");
|
DEBUG("OpenPPT: Get info\n");
|
||||||
pptviewobj[id].steps = 0;
|
pptviewobj[id].steps = 0;
|
||||||
@ -209,24 +138,126 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewp
|
|||||||
}
|
}
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
}
|
}
|
||||||
DEBUG("OpenPPT: Steps %d, first slide steps %d\n",pptviewobj[id].steps,pptviewobj[id].firstSlideSteps);
|
DEBUG("OpenPPT: Steps %d, first slide steps %d\n",
|
||||||
|
pptviewobj[id].steps,pptviewobj[id].firstSlideSteps);
|
||||||
SavePPTInfo(id);
|
SavePPTInfo(id);
|
||||||
if(pptviewobj[id].state==PPT_CLOSING||pptviewobj[id].slideCount<=0){
|
if(pptviewobj[id].state == PPT_CLOSING || pptviewobj[id].slideCount <= 0)
|
||||||
|
{
|
||||||
|
// We've gone off the end and pptview is closing. We'll need to start again
|
||||||
ClosePPT(id);
|
ClosePPT(id);
|
||||||
id=-1;
|
gotinfo = InitPPTObject(id, filename, hParentWnd, rect, previewpath);
|
||||||
|
if(gotinfo)
|
||||||
|
gotinfo = StartPPTView(id);
|
||||||
|
if(!gotinfo)
|
||||||
|
{
|
||||||
|
ClosePPT(id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RestartShow(id);
|
RestartShow(id);
|
||||||
}
|
}
|
||||||
if(id>=0)
|
if(gotinfo)
|
||||||
{
|
{
|
||||||
|
DEBUG("OpenPPT: Info loaded, no refresh\n");
|
||||||
|
pptviewobj[id].state = PPT_LOADED;
|
||||||
|
Resume(id);
|
||||||
|
}
|
||||||
if(pptviewobj[id].mhook != NULL)
|
if(pptviewobj[id].mhook != NULL)
|
||||||
UnhookWindowsHookEx(pptviewobj[id].mhook);
|
UnhookWindowsHookEx(pptviewobj[id].mhook);
|
||||||
pptviewobj[id].mhook = NULL;
|
pptviewobj[id].mhook = NULL;
|
||||||
}
|
|
||||||
DEBUG("OpenPPT: Exit: id=%i\n", id);
|
DEBUG("OpenPPT: Exit: id=%i\n", id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL InitPPTObject(int id, char *filename, HWND hParentWnd,
|
||||||
|
RECT rect, char *previewpath)
|
||||||
|
{
|
||||||
|
DEBUG("InitPPTObject\n");
|
||||||
|
memset(&pptviewobj[id], 0, sizeof(PPTVIEWOBJ));
|
||||||
|
strcpy_s(pptviewobj[id].filename, MAX_PATH, filename);
|
||||||
|
strcpy_s(pptviewobj[id].previewpath, MAX_PATH, previewpath);
|
||||||
|
pptviewobj[id].state = PPT_CLOSED;
|
||||||
|
pptviewobj[id].slideCount = 0;
|
||||||
|
pptviewobj[id].currentSlide = 0;
|
||||||
|
pptviewobj[id].firstSlideSteps = 0;
|
||||||
|
pptviewobj[id].guess = 1;
|
||||||
|
for(int i = 0; i < MAX_SLIDES; i++)
|
||||||
|
pptviewobj[id].slideNo[i] = 0;
|
||||||
|
pptviewobj[id].hParentWnd = hParentWnd;
|
||||||
|
pptviewobj[id].hWnd = NULL;
|
||||||
|
pptviewobj[id].hWnd2 = NULL;
|
||||||
|
if(hParentWnd != NULL && rect.top == 0 && rect.bottom == 0
|
||||||
|
&& rect.left == 0 && rect.right == 0)
|
||||||
|
{
|
||||||
|
LPRECT wndrect = NULL;
|
||||||
|
GetWindowRect(hParentWnd, wndrect);
|
||||||
|
pptviewobj[id].rect.top = 0;
|
||||||
|
pptviewobj[id].rect.left = 0;
|
||||||
|
pptviewobj[id].rect.bottom = wndrect->bottom-wndrect->top;
|
||||||
|
pptviewobj[id].rect.right = wndrect->right-wndrect->left;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pptviewobj[id].rect.top = rect.top;
|
||||||
|
pptviewobj[id].rect.left = rect.left;
|
||||||
|
pptviewobj[id].rect.bottom = rect.bottom;
|
||||||
|
pptviewobj[id].rect.right = rect.right;
|
||||||
|
}
|
||||||
|
BOOL gotinfo = GetPPTInfo(id);
|
||||||
|
return gotinfo;
|
||||||
|
}
|
||||||
|
BOOL StartPPTView(int id)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* I'd really like to just hook on the new threadid. However this always gives
|
||||||
|
* error 87. Perhaps I'm hooking to soon? No idea... however can't wait
|
||||||
|
* since I need to ensure I pick up the WM_CREATE as this is the only
|
||||||
|
* time the window can be resized in such away the content scales correctly
|
||||||
|
*
|
||||||
|
* hook = SetWindowsHookEx(WH_CBT,CbtProc,hInstance,pi.dwThreadId);
|
||||||
|
*/
|
||||||
|
DEBUG("StartPPTView\n");
|
||||||
|
STARTUPINFO si;
|
||||||
|
PROCESS_INFORMATION pi;
|
||||||
|
char cmdline[MAX_PATH * 2];
|
||||||
|
|
||||||
|
if(globalhook != NULL)
|
||||||
|
UnhookWindowsHookEx(globalhook);
|
||||||
|
globalhook = SetWindowsHookEx(WH_CBT, CbtProc, hInstance, NULL);
|
||||||
|
if(globalhook == 0)
|
||||||
|
{
|
||||||
|
DEBUG("OpenPPT: SetWindowsHookEx failed\n");
|
||||||
|
ClosePPT(id);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if(GetPPTViewerPath(cmdline, sizeof(cmdline)) == FALSE)
|
||||||
|
{
|
||||||
|
DEBUG("OpenPPT: GetPPTViewerPath failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
pptviewobj[id].state = PPT_STARTED;
|
||||||
|
Sleep(10);
|
||||||
|
strcat_s(cmdline, MAX_PATH * 2, "/F /S \"");
|
||||||
|
strcat_s(cmdline, MAX_PATH * 2, pptviewobj[id].filename);
|
||||||
|
strcat_s(cmdline, MAX_PATH * 2, "\"");
|
||||||
|
memset(&si, 0, sizeof(si));
|
||||||
|
memset(&pi, 0, sizeof(pi));
|
||||||
|
if(!CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, 0, NULL, &si, &pi))
|
||||||
|
{
|
||||||
|
DEBUG("OpenPPT: CreateProcess failed\n");
|
||||||
|
ClosePPT(id);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
pptviewobj[id].dwProcessId = pi.dwProcessId;
|
||||||
|
pptviewobj[id].dwThreadId = pi.dwThreadId;
|
||||||
|
pptviewobj[id].hThread = pi.hThread;
|
||||||
|
pptviewobj[id].hProcess = pi.hProcess;
|
||||||
|
while(pptviewobj[id].state == PPT_STARTED)
|
||||||
|
Sleep(10);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// Load information about the ppt from an info.txt file.
|
// Load information about the ppt from an info.txt file.
|
||||||
// Format:
|
// Format:
|
||||||
// version
|
// version
|
||||||
@ -271,7 +302,8 @@ BOOL GetPPTInfo(int id)
|
|||||||
// check all the preview images still exist
|
// check all the preview images still exist
|
||||||
for(int i = 1; i <= slidecount; i++)
|
for(int i = 1; i <= slidecount; i++)
|
||||||
{
|
{
|
||||||
sprintf_s(info, MAX_PATH, "%s%i.bmp", pptviewobj[id].previewpath, i);
|
sprintf_s(info, MAX_PATH, "%s%i.bmp",
|
||||||
|
pptviewobj[id].previewpath, i);
|
||||||
if(GetFileAttributes(info) == INVALID_FILE_ATTRIBUTES)
|
if(GetFileAttributes(info) == INVALID_FILE_ATTRIBUTES)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -301,6 +333,10 @@ BOOL SavePPTInfo(int id)
|
|||||||
DEBUG("SavePPTInfo: fopen of %s failed%i\n", info, err);
|
DEBUG("SavePPTInfo: fopen of %s failed%i\n", info, err);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG("SavePPTInfo: fopen of %s succeeded\n", info);
|
||||||
|
}
|
||||||
fprintf(pFile, "1\n");
|
fprintf(pFile, "1\n");
|
||||||
fprintf(pFile, "%u\n", filestats.st_mtime);
|
fprintf(pFile, "%u\n", filestats.st_mtime);
|
||||||
fprintf(pFile, "%u\n", filestats.st_size);
|
fprintf(pFile, "%u\n", filestats.st_size);
|
||||||
@ -319,13 +355,26 @@ BOOL GetPPTViewerPath(char *pptviewerpath, int strsize)
|
|||||||
LRESULT lresult;
|
LRESULT lresult;
|
||||||
|
|
||||||
DEBUG("GetPPTViewerPath: start\n");
|
DEBUG("GetPPTViewerPath: start\n");
|
||||||
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
|
if(RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
||||||
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
|
"PowerPointViewer.Show.12\\shell\\Show\\command",
|
||||||
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
|
0, KEY_READ, &hkey)!=ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
if(RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
||||||
|
"Applications\\PPTVIEW.EXE\\shell\\open\\command",
|
||||||
|
0, KEY_READ, &hkey) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
if(RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
||||||
|
"Applications\\PPTVIEW.EXE\\shell\\Show\\command",
|
||||||
|
0, KEY_READ, &hkey) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
dwtype = REG_SZ;
|
dwtype = REG_SZ;
|
||||||
dwsize = (DWORD)strsize;
|
dwsize = (DWORD)strsize;
|
||||||
lresult = RegQueryValueEx(hkey, NULL, NULL, &dwtype, (LPBYTE)pptviewerpath, &dwsize );
|
lresult = RegQueryValueEx(hkey, NULL, NULL, &dwtype,
|
||||||
|
(LPBYTE)pptviewerpath, &dwsize);
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
if(lresult != ERROR_SUCCESS)
|
if(lresult != ERROR_SUCCESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -367,7 +416,8 @@ DllExport void ClosePPT(int id)
|
|||||||
DllExport void Resume(int id)
|
DllExport void Resume(int id)
|
||||||
{
|
{
|
||||||
DEBUG("Resume: %d\n", id);
|
DEBUG("Resume: %d\n", id);
|
||||||
MoveWindow(pptviewobj[id].hWnd, pptviewobj[id].rect.left, pptviewobj[id].rect.top,
|
MoveWindow(pptviewobj[id].hWnd, pptviewobj[id].rect.left,
|
||||||
|
pptviewobj[id].rect.top,
|
||||||
pptviewobj[id].rect.right - pptviewobj[id].rect.left,
|
pptviewobj[id].rect.right - pptviewobj[id].rect.left,
|
||||||
pptviewobj[id].rect.bottom - pptviewobj[id].rect.top, TRUE);
|
pptviewobj[id].rect.bottom - pptviewobj[id].rect.top, TRUE);
|
||||||
Unblank(id);
|
Unblank(id);
|
||||||
@ -407,13 +457,17 @@ DllExport void NextStep(int id)
|
|||||||
DEBUG("NextStep:%d (%d)\n", id, pptviewobj[id].currentSlide);
|
DEBUG("NextStep:%d (%d)\n", id, pptviewobj[id].currentSlide);
|
||||||
if(pptviewobj[id].currentSlide>pptviewobj[id].slideCount)
|
if(pptviewobj[id].currentSlide>pptviewobj[id].slideCount)
|
||||||
return;
|
return;
|
||||||
PostMessage(pptviewobj[id].hWnd2, WM_MOUSEWHEEL, MAKEWPARAM(0, -WHEEL_DELTA), 0);
|
pptviewobj[id].guess = pptviewobj[id].currentSlide + 1;
|
||||||
|
PostMessage(pptviewobj[id].hWnd2, WM_MOUSEWHEEL,
|
||||||
|
MAKEWPARAM(0, -WHEEL_DELTA), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take a step backwards through the show
|
// Take a step backwards through the show
|
||||||
DllExport void PrevStep(int id)
|
DllExport void PrevStep(int id)
|
||||||
{
|
{
|
||||||
DEBUG("PrevStep:%d (%d)\n", id, pptviewobj[id].currentSlide);
|
DEBUG("PrevStep:%d (%d)\n", id, pptviewobj[id].currentSlide);
|
||||||
|
if(pptviewobj[id].currentSlide > 1)
|
||||||
|
pptviewobj[id].guess = pptviewobj[id].currentSlide - 1;
|
||||||
PostMessage(pptviewobj[id].hWnd2, WM_MOUSEWHEEL, MAKEWPARAM(0, WHEEL_DELTA), 0);
|
PostMessage(pptviewobj[id].hWnd2, WM_MOUSEWHEEL, MAKEWPARAM(0, WHEEL_DELTA), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,7 +523,9 @@ DllExport void GotoSlide(int id, int slideno)
|
|||||||
// the slideshow has focus first
|
// the slideshow has focus first
|
||||||
char ch[10];
|
char ch[10];
|
||||||
|
|
||||||
if(slideno<0) return;
|
if(slideno < 0)
|
||||||
|
return;
|
||||||
|
pptviewobj[id].guess = slideno;
|
||||||
_itoa_s(slideno, ch, 10, 10);
|
_itoa_s(slideno, ch, 10, 10);
|
||||||
HWND h1 = GetForegroundWindow();
|
HWND h1 = GetForegroundWindow();
|
||||||
HWND h2 = GetFocus();
|
HWND h2 = GetFocus();
|
||||||
@ -478,7 +534,8 @@ DllExport void GotoSlide(int id, int slideno)
|
|||||||
Sleep(50); // slight pause, otherwise event triggering this call may grab focus back!
|
Sleep(50); // slight pause, otherwise event triggering this call may grab focus back!
|
||||||
for(int i = 0; i < 10; i++)
|
for(int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
if(ch[i]=='\0') break;
|
if(ch[i] == '\0')
|
||||||
|
break;
|
||||||
keybd_event((BYTE)ch[i], 0, 0, 0);
|
keybd_event((BYTE)ch[i], 0, 0, 0);
|
||||||
keybd_event((BYTE)ch[i], 0, KEYEVENTF_KEYUP, 0);
|
keybd_event((BYTE)ch[i], 0, KEYEVENTF_KEYUP, 0);
|
||||||
}
|
}
|
||||||
@ -569,8 +626,10 @@ LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
UnhookWindowsHookEx(globalhook);
|
UnhookWindowsHookEx(globalhook);
|
||||||
globalhook = NULL;
|
globalhook = NULL;
|
||||||
pptviewobj[id].hook = SetWindowsHookEx(WH_CALLWNDPROC,CwpProc,hInstance,pptviewobj[id].dwThreadId);
|
pptviewobj[id].hook = SetWindowsHookEx(WH_CALLWNDPROC,
|
||||||
pptviewobj[id].mhook = SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,hInstance,pptviewobj[id].dwThreadId);
|
CwpProc,hInstance, pptviewobj[id].dwThreadId);
|
||||||
|
pptviewobj[id].mhook = SetWindowsHookEx(WH_GETMESSAGE,
|
||||||
|
GetMsgProc, hInstance, pptviewobj[id].dwThreadId);
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
pptviewobj[id].state = PPT_OPENED;
|
pptviewobj[id].state = PPT_OPENED;
|
||||||
}
|
}
|
||||||
@ -597,7 +656,8 @@ LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(id>=0&&nCode==HC_ACTION&&wParam==PM_REMOVE&&pMSG->message==WM_MOUSEWHEEL)
|
if(id >= 0 && nCode == HC_ACTION && wParam == PM_REMOVE
|
||||||
|
&& pMSG->message == WM_MOUSEWHEEL)
|
||||||
{
|
{
|
||||||
if(pptviewobj[id].state != PPT_LOADED)
|
if(pptviewobj[id].state != PPT_LOADED)
|
||||||
{
|
{
|
||||||
@ -610,7 +670,8 @@ LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
// This hook exists whilst the slideshow is running but only listens on the
|
// This hook exists whilst the slideshow is running but only listens on the
|
||||||
// slideshows thread. It listens out for slide changes, message WM_USER+22.
|
// slideshows thread. It listens out for slide changes, message WM_USER+22.
|
||||||
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam){
|
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
CWPSTRUCT *cwp;
|
CWPSTRUCT *cwp;
|
||||||
cwp = (CWPSTRUCT *)lParam;
|
cwp = (CWPSTRUCT *)lParam;
|
||||||
HHOOK hook = NULL;
|
HHOOK hook = NULL;
|
||||||
@ -634,9 +695,11 @@ LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam){
|
|||||||
if(pptviewobj[id].state != PPT_LOADED)
|
if(pptviewobj[id].state != PPT_LOADED)
|
||||||
{
|
{
|
||||||
if((pptviewobj[id].currentSlide > 0)
|
if((pptviewobj[id].currentSlide > 0)
|
||||||
&& (pptviewobj[id].previewpath!=NULL&&strlen(pptviewobj[id].previewpath)>0))
|
&& (pptviewobj[id].previewpath != NULL
|
||||||
|
&& strlen(pptviewobj[id].previewpath) > 0))
|
||||||
{
|
{
|
||||||
sprintf_s(filename, MAX_PATH, "%s%i.bmp", pptviewobj[id].previewpath, pptviewobj[id].currentSlide);
|
sprintf_s(filename, MAX_PATH, "%s%i.bmp", pptviewobj[id].previewpath,
|
||||||
|
pptviewobj[id].currentSlide);
|
||||||
CaptureAndSaveWindow(cwp->hwnd, filename);
|
CaptureAndSaveWindow(cwp->hwnd, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,21 +713,52 @@ LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pptviewobj[id].currentSlide = cwp->wParam - 255;
|
|
||||||
if(pptviewobj[id].state != PPT_LOADED)
|
if(pptviewobj[id].state != PPT_LOADED)
|
||||||
{
|
{
|
||||||
if(pptviewobj[id].currentSlide<pptviewobj[id].slideCount)
|
if((pptviewobj[id].currentSlide == 0)
|
||||||
|
||(pptviewobj[id].slideNo[pptviewobj[id].currentSlide] != cwp->wParam))
|
||||||
|
{
|
||||||
|
if(pptviewobj[id].slideNo[1] == cwp->wParam)
|
||||||
{
|
{
|
||||||
pptviewobj[id].state = PPT_LOADED;
|
pptviewobj[id].state = PPT_LOADED;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
if(pptviewobj[id].currentSlide>pptviewobj[id].slideCount)
|
{
|
||||||
|
pptviewobj[id].currentSlide++;
|
||||||
pptviewobj[id].slideCount = pptviewobj[id].currentSlide;
|
pptviewobj[id].slideCount = pptviewobj[id].currentSlide;
|
||||||
|
pptviewobj[id].slideNo[pptviewobj[id].currentSlide] = cwp->wParam;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((pptviewobj[id].state != PPT_CLOSED)&&(cwp->message==WM_CLOSE||cwp->message==WM_QUIT))
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(pptviewobj[id].guess > 0
|
||||||
|
&& pptviewobj[id].slideNo[pptviewobj[id].guess] == 0)
|
||||||
|
{
|
||||||
|
pptviewobj[id].currentSlide = 0;
|
||||||
|
}
|
||||||
|
for(int i = 1; i < pptviewobj[id].slideCount; i++)
|
||||||
|
{
|
||||||
|
if(pptviewobj[id].slideNo[i] == cwp->wParam)
|
||||||
|
{
|
||||||
|
pptviewobj[id].currentSlide = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pptviewobj[id].currentSlide == 0)
|
||||||
|
{
|
||||||
|
pptviewobj[id].slideNo[pptviewobj[id].guess] = cwp->wParam;
|
||||||
|
pptviewobj[id].currentSlide = pptviewobj[id].guess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((pptviewobj[id].state != PPT_CLOSED)
|
||||||
|
&& (cwp->message == WM_CLOSE || cwp->message == WM_QUIT))
|
||||||
|
{
|
||||||
pptviewobj[id].state = PPT_CLOSING;
|
pptviewobj[id].state = PPT_CLOSING;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return CallNextHookEx(hook,nCode,wParam,lParam);
|
return CallNextHookEx(hook,nCode,wParam,lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,7 +816,8 @@ VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename)
|
|||||||
}
|
}
|
||||||
DeleteObject(hBmp);
|
DeleteObject(hBmp);
|
||||||
}
|
}
|
||||||
HBITMAP CaptureWindow (HWND hWnd) {
|
HBITMAP CaptureWindow(HWND hWnd)
|
||||||
|
{
|
||||||
HDC hDC;
|
HDC hDC;
|
||||||
BOOL bOk = FALSE;
|
BOOL bOk = FALSE;
|
||||||
HBITMAP hImage = NULL;
|
HBITMAP hImage = NULL;
|
||||||
@ -730,7 +825,8 @@ HBITMAP CaptureWindow (HWND hWnd) {
|
|||||||
hDC = GetDC(hWnd);
|
hDC = GetDC(hWnd);
|
||||||
RECT rcClient;
|
RECT rcClient;
|
||||||
GetClientRect(hWnd, &rcClient);
|
GetClientRect(hWnd, &rcClient);
|
||||||
if ((hImage = CreateCompatibleBitmap (hDC, rcClient.right, rcClient.bottom)) != NULL)
|
if((hImage = CreateCompatibleBitmap(hDC, rcClient.right, rcClient.bottom))
|
||||||
|
!= NULL)
|
||||||
{
|
{
|
||||||
HDC hMemDC;
|
HDC hMemDC;
|
||||||
HBITMAP hDCBmp;
|
HBITMAP hDCBmp;
|
||||||
|
Binary file not shown.
@ -27,11 +27,14 @@ VOID SaveBitmap (CHAR* filename, HBITMAP hBmp) ;
|
|||||||
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
|
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
|
||||||
BOOL GetPPTInfo(int id);
|
BOOL GetPPTInfo(int id);
|
||||||
BOOL SavePPTInfo(int id);
|
BOOL SavePPTInfo(int id);
|
||||||
|
BOOL InitPPTObject(int id, char *filename, HWND hParentWnd,
|
||||||
|
RECT rect, char *previewpath);
|
||||||
|
BOOL StartPPTView(int id);
|
||||||
|
|
||||||
void Unhook(int id);
|
void Unhook(int id);
|
||||||
|
|
||||||
#define MAX_PPTOBJS 50
|
#define MAX_PPTOBJS 16
|
||||||
|
#define MAX_SLIDES 256
|
||||||
|
|
||||||
struct PPTVIEWOBJ
|
struct PPTVIEWOBJ
|
||||||
{
|
{
|
||||||
@ -49,7 +52,9 @@ struct PPTVIEWOBJ
|
|||||||
int currentSlide;
|
int currentSlide;
|
||||||
int firstSlideSteps;
|
int firstSlideSteps;
|
||||||
int steps;
|
int steps;
|
||||||
|
int guess;
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
char previewpath[MAX_PATH];
|
char previewpath[MAX_PATH];
|
||||||
|
int slideNo[MAX_SLIDES];
|
||||||
PPTVIEWSTATE state;
|
PPTVIEWSTATE state;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user