├── .gitignore
├── COPYING.txt
├── PowerpointViewerDemo
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── PowerpointViewerDemo.csproj
└── Program.cs
├── PowerpointViewerLib.sln
├── PowerpointViewerLib
├── PowerpointViewerController.cs
├── PowerpointViewerDocument.cs
├── PowerpointViewerLib.csproj
└── Properties
│ └── AssemblyInfo.cs
├── README.md
└── pptviewlib
├── README.TXT
├── pptviewlib.cpp
├── pptviewlib.dll
├── pptviewlib.h
├── pptviewlib.vcxproj
└── pptviewlib.vcxproj.filters
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | */obj/*
3 | *.suo
4 | *.sdf
5 | *.opensdf
6 | *.user
7 | */Debug/*
8 | */Release/*
9 | ipch/
10 |
11 |
--------------------------------------------------------------------------------
/COPYING.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/PowerpointViewerDemo/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PowerpointViewerDemo
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
32 | this.textBoxX = new System.Windows.Forms.TextBox();
33 | this.label1 = new System.Windows.Forms.Label();
34 | this.label2 = new System.Windows.Forms.Label();
35 | this.textBoxY = new System.Windows.Forms.TextBox();
36 | this.label3 = new System.Windows.Forms.Label();
37 | this.label4 = new System.Windows.Forms.Label();
38 | this.textBoxWidth = new System.Windows.Forms.TextBox();
39 | this.textBoxHeight = new System.Windows.Forms.TextBox();
40 | this.buttonOpen = new System.Windows.Forms.Button();
41 | this.label5 = new System.Windows.Forms.Label();
42 | this.textBoxFilename = new System.Windows.Forms.TextBox();
43 | this.label7 = new System.Windows.Forms.Label();
44 | this.labelSlide = new System.Windows.Forms.Label();
45 | this.label8 = new System.Windows.Forms.Label();
46 | this.labelCount = new System.Windows.Forms.Label();
47 | this.buttonPrev = new System.Windows.Forms.Button();
48 | this.buttonNext = new System.Windows.Forms.Button();
49 | this.groupBox1 = new System.Windows.Forms.GroupBox();
50 | this.buttonChooseFile = new System.Windows.Forms.Button();
51 | this.groupBox2 = new System.Windows.Forms.GroupBox();
52 | this.groupBox3 = new System.Windows.Forms.GroupBox();
53 | this.buttonFocus = new System.Windows.Forms.Button();
54 | this.buttonMove = new System.Windows.Forms.Button();
55 | this.listBoxDocuments = new System.Windows.Forms.ListBox();
56 | this.buttonUnblank = new System.Windows.Forms.Button();
57 | this.buttonBlank = new System.Windows.Forms.Button();
58 | this.textBoxGoto = new System.Windows.Forms.TextBox();
59 | this.buttonGoto = new System.Windows.Forms.Button();
60 | this.buttonClose = new System.Windows.Forms.Button();
61 | this.buttonResume = new System.Windows.Forms.Button();
62 | this.buttonHide = new System.Windows.Forms.Button();
63 | this.pictureBoxThumb = new System.Windows.Forms.PictureBox();
64 | this.groupBox1.SuspendLayout();
65 | this.groupBox2.SuspendLayout();
66 | this.groupBox3.SuspendLayout();
67 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxThumb)).BeginInit();
68 | this.SuspendLayout();
69 | //
70 | // textBoxX
71 | //
72 | this.textBoxX.Location = new System.Drawing.Point(69, 13);
73 | this.textBoxX.Name = "textBoxX";
74 | this.textBoxX.Size = new System.Drawing.Size(57, 20);
75 | this.textBoxX.TabIndex = 0;
76 | this.textBoxX.Text = "0";
77 | //
78 | // label1
79 | //
80 | this.label1.AutoSize = true;
81 | this.label1.Location = new System.Drawing.Point(46, 16);
82 | this.label1.Name = "label1";
83 | this.label1.Size = new System.Drawing.Size(17, 13);
84 | this.label1.TabIndex = 1;
85 | this.label1.Text = "X:";
86 | //
87 | // label2
88 | //
89 | this.label2.AutoSize = true;
90 | this.label2.Location = new System.Drawing.Point(46, 42);
91 | this.label2.Name = "label2";
92 | this.label2.Size = new System.Drawing.Size(17, 13);
93 | this.label2.TabIndex = 2;
94 | this.label2.Text = "Y:";
95 | //
96 | // textBoxY
97 | //
98 | this.textBoxY.Location = new System.Drawing.Point(69, 39);
99 | this.textBoxY.Name = "textBoxY";
100 | this.textBoxY.Size = new System.Drawing.Size(57, 20);
101 | this.textBoxY.TabIndex = 3;
102 | this.textBoxY.Text = "0";
103 | //
104 | // label3
105 | //
106 | this.label3.AutoSize = true;
107 | this.label3.Location = new System.Drawing.Point(26, 68);
108 | this.label3.Name = "label3";
109 | this.label3.Size = new System.Drawing.Size(38, 13);
110 | this.label3.TabIndex = 4;
111 | this.label3.Text = "Width:";
112 | //
113 | // label4
114 | //
115 | this.label4.AutoSize = true;
116 | this.label4.Location = new System.Drawing.Point(27, 94);
117 | this.label4.Name = "label4";
118 | this.label4.Size = new System.Drawing.Size(41, 13);
119 | this.label4.TabIndex = 5;
120 | this.label4.Text = "Height:";
121 | //
122 | // textBoxWidth
123 | //
124 | this.textBoxWidth.Location = new System.Drawing.Point(69, 65);
125 | this.textBoxWidth.Name = "textBoxWidth";
126 | this.textBoxWidth.Size = new System.Drawing.Size(57, 20);
127 | this.textBoxWidth.TabIndex = 6;
128 | this.textBoxWidth.Text = "800";
129 | //
130 | // textBoxHeight
131 | //
132 | this.textBoxHeight.Location = new System.Drawing.Point(69, 91);
133 | this.textBoxHeight.Name = "textBoxHeight";
134 | this.textBoxHeight.Size = new System.Drawing.Size(57, 20);
135 | this.textBoxHeight.TabIndex = 7;
136 | this.textBoxHeight.Text = "600";
137 | //
138 | // buttonOpen
139 | //
140 | this.buttonOpen.Location = new System.Drawing.Point(11, 58);
141 | this.buttonOpen.Name = "buttonOpen";
142 | this.buttonOpen.Size = new System.Drawing.Size(252, 53);
143 | this.buttonOpen.TabIndex = 8;
144 | this.buttonOpen.Text = "Open";
145 | this.buttonOpen.UseVisualStyleBackColor = true;
146 | this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
147 | //
148 | // label5
149 | //
150 | this.label5.AutoSize = true;
151 | this.label5.Location = new System.Drawing.Point(6, 16);
152 | this.label5.Name = "label5";
153 | this.label5.Size = new System.Drawing.Size(26, 13);
154 | this.label5.TabIndex = 9;
155 | this.label5.Text = "File:";
156 | //
157 | // textBoxFilename
158 | //
159 | this.textBoxFilename.Location = new System.Drawing.Point(6, 32);
160 | this.textBoxFilename.Name = "textBoxFilename";
161 | this.textBoxFilename.Size = new System.Drawing.Size(214, 20);
162 | this.textBoxFilename.TabIndex = 12;
163 | //
164 | // label7
165 | //
166 | this.label7.AutoSize = true;
167 | this.label7.Location = new System.Drawing.Point(6, 111);
168 | this.label7.Name = "label7";
169 | this.label7.Size = new System.Drawing.Size(33, 13);
170 | this.label7.TabIndex = 13;
171 | this.label7.Text = "Slide:";
172 | //
173 | // labelSlide
174 | //
175 | this.labelSlide.AutoSize = true;
176 | this.labelSlide.Location = new System.Drawing.Point(45, 111);
177 | this.labelSlide.Name = "labelSlide";
178 | this.labelSlide.Size = new System.Drawing.Size(10, 13);
179 | this.labelSlide.TabIndex = 14;
180 | this.labelSlide.Text = "-";
181 | //
182 | // label8
183 | //
184 | this.label8.AutoSize = true;
185 | this.label8.Location = new System.Drawing.Point(84, 111);
186 | this.label8.Name = "label8";
187 | this.label8.Size = new System.Drawing.Size(38, 13);
188 | this.label8.TabIndex = 15;
189 | this.label8.Text = "Count:";
190 | //
191 | // labelCount
192 | //
193 | this.labelCount.AutoSize = true;
194 | this.labelCount.Location = new System.Drawing.Point(132, 111);
195 | this.labelCount.Name = "labelCount";
196 | this.labelCount.Size = new System.Drawing.Size(10, 13);
197 | this.labelCount.TabIndex = 16;
198 | this.labelCount.Text = "-";
199 | //
200 | // buttonPrev
201 | //
202 | this.buttonPrev.Location = new System.Drawing.Point(6, 19);
203 | this.buttonPrev.Name = "buttonPrev";
204 | this.buttonPrev.Size = new System.Drawing.Size(75, 23);
205 | this.buttonPrev.TabIndex = 17;
206 | this.buttonPrev.Text = "Previous";
207 | this.buttonPrev.UseVisualStyleBackColor = true;
208 | this.buttonPrev.Click += new System.EventHandler(this.buttonPrev_Click);
209 | //
210 | // buttonNext
211 | //
212 | this.buttonNext.Location = new System.Drawing.Point(87, 19);
213 | this.buttonNext.Name = "buttonNext";
214 | this.buttonNext.Size = new System.Drawing.Size(75, 23);
215 | this.buttonNext.TabIndex = 18;
216 | this.buttonNext.Text = "Next";
217 | this.buttonNext.UseVisualStyleBackColor = true;
218 | this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
219 | //
220 | // groupBox1
221 | //
222 | this.groupBox1.Controls.Add(this.buttonChooseFile);
223 | this.groupBox1.Controls.Add(this.groupBox2);
224 | this.groupBox1.Controls.Add(this.textBoxFilename);
225 | this.groupBox1.Controls.Add(this.label5);
226 | this.groupBox1.Controls.Add(this.buttonOpen);
227 | this.groupBox1.Location = new System.Drawing.Point(12, 12);
228 | this.groupBox1.Name = "groupBox1";
229 | this.groupBox1.Size = new System.Drawing.Size(416, 146);
230 | this.groupBox1.TabIndex = 19;
231 | this.groupBox1.TabStop = false;
232 | this.groupBox1.Text = "Setup";
233 | //
234 | // buttonChooseFile
235 | //
236 | this.buttonChooseFile.Location = new System.Drawing.Point(229, 30);
237 | this.buttonChooseFile.Name = "buttonChooseFile";
238 | this.buttonChooseFile.Size = new System.Drawing.Size(34, 23);
239 | this.buttonChooseFile.TabIndex = 14;
240 | this.buttonChooseFile.Text = "...";
241 | this.buttonChooseFile.UseVisualStyleBackColor = true;
242 | this.buttonChooseFile.Click += new System.EventHandler(this.buttonChooseFile_Click);
243 | //
244 | // groupBox2
245 | //
246 | this.groupBox2.Controls.Add(this.label1);
247 | this.groupBox2.Controls.Add(this.textBoxX);
248 | this.groupBox2.Controls.Add(this.label2);
249 | this.groupBox2.Controls.Add(this.textBoxY);
250 | this.groupBox2.Controls.Add(this.label3);
251 | this.groupBox2.Controls.Add(this.label4);
252 | this.groupBox2.Controls.Add(this.textBoxWidth);
253 | this.groupBox2.Controls.Add(this.textBoxHeight);
254 | this.groupBox2.Location = new System.Drawing.Point(269, 19);
255 | this.groupBox2.Name = "groupBox2";
256 | this.groupBox2.Size = new System.Drawing.Size(141, 121);
257 | this.groupBox2.TabIndex = 13;
258 | this.groupBox2.TabStop = false;
259 | this.groupBox2.Text = "Window";
260 | //
261 | // groupBox3
262 | //
263 | this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
264 | | System.Windows.Forms.AnchorStyles.Left)));
265 | this.groupBox3.Controls.Add(this.buttonFocus);
266 | this.groupBox3.Controls.Add(this.buttonMove);
267 | this.groupBox3.Controls.Add(this.listBoxDocuments);
268 | this.groupBox3.Controls.Add(this.buttonUnblank);
269 | this.groupBox3.Controls.Add(this.buttonBlank);
270 | this.groupBox3.Controls.Add(this.textBoxGoto);
271 | this.groupBox3.Controls.Add(this.buttonGoto);
272 | this.groupBox3.Controls.Add(this.buttonClose);
273 | this.groupBox3.Controls.Add(this.buttonResume);
274 | this.groupBox3.Controls.Add(this.buttonHide);
275 | this.groupBox3.Controls.Add(this.buttonPrev);
276 | this.groupBox3.Controls.Add(this.buttonNext);
277 | this.groupBox3.Controls.Add(this.labelCount);
278 | this.groupBox3.Controls.Add(this.label7);
279 | this.groupBox3.Controls.Add(this.label8);
280 | this.groupBox3.Controls.Add(this.labelSlide);
281 | this.groupBox3.Location = new System.Drawing.Point(12, 164);
282 | this.groupBox3.Name = "groupBox3";
283 | this.groupBox3.Size = new System.Drawing.Size(416, 136);
284 | this.groupBox3.TabIndex = 20;
285 | this.groupBox3.TabStop = false;
286 | this.groupBox3.Text = "Control";
287 | //
288 | // buttonFocus
289 | //
290 | this.buttonFocus.Location = new System.Drawing.Point(168, 19);
291 | this.buttonFocus.Name = "buttonFocus";
292 | this.buttonFocus.Size = new System.Drawing.Size(75, 23);
293 | this.buttonFocus.TabIndex = 32;
294 | this.buttonFocus.Text = "Focus";
295 | this.buttonFocus.UseVisualStyleBackColor = true;
296 | this.buttonFocus.Click += new System.EventHandler(this.buttonFocus_Click);
297 | //
298 | // buttonMove
299 | //
300 | this.buttonMove.Location = new System.Drawing.Point(168, 48);
301 | this.buttonMove.Name = "buttonMove";
302 | this.buttonMove.Size = new System.Drawing.Size(75, 23);
303 | this.buttonMove.TabIndex = 31;
304 | this.buttonMove.Text = "Move";
305 | this.buttonMove.UseVisualStyleBackColor = true;
306 | this.buttonMove.Click += new System.EventHandler(this.buttonMove_Click);
307 | //
308 | // listBoxDocuments
309 | //
310 | this.listBoxDocuments.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
311 | | System.Windows.Forms.AnchorStyles.Left)));
312 | this.listBoxDocuments.FormattingEnabled = true;
313 | this.listBoxDocuments.Location = new System.Drawing.Point(249, 22);
314 | this.listBoxDocuments.Name = "listBoxDocuments";
315 | this.listBoxDocuments.Size = new System.Drawing.Size(161, 108);
316 | this.listBoxDocuments.TabIndex = 30;
317 | this.listBoxDocuments.SelectedIndexChanged += new System.EventHandler(this.listBoxDocuments_SelectedIndexChanged);
318 | //
319 | // buttonUnblank
320 | //
321 | this.buttonUnblank.Location = new System.Drawing.Point(87, 77);
322 | this.buttonUnblank.Name = "buttonUnblank";
323 | this.buttonUnblank.Size = new System.Drawing.Size(75, 23);
324 | this.buttonUnblank.TabIndex = 29;
325 | this.buttonUnblank.Text = "Unblank";
326 | this.buttonUnblank.UseVisualStyleBackColor = true;
327 | this.buttonUnblank.Click += new System.EventHandler(this.buttonUnblank_Click);
328 | //
329 | // buttonBlank
330 | //
331 | this.buttonBlank.Location = new System.Drawing.Point(6, 77);
332 | this.buttonBlank.Name = "buttonBlank";
333 | this.buttonBlank.Size = new System.Drawing.Size(75, 23);
334 | this.buttonBlank.TabIndex = 28;
335 | this.buttonBlank.Text = "Blank";
336 | this.buttonBlank.UseVisualStyleBackColor = true;
337 | this.buttonBlank.Click += new System.EventHandler(this.buttonBlank_Click);
338 | //
339 | // textBoxGoto
340 | //
341 | this.textBoxGoto.Location = new System.Drawing.Point(167, 108);
342 | this.textBoxGoto.Name = "textBoxGoto";
343 | this.textBoxGoto.Size = new System.Drawing.Size(26, 20);
344 | this.textBoxGoto.TabIndex = 26;
345 | this.textBoxGoto.Text = "0";
346 | //
347 | // buttonGoto
348 | //
349 | this.buttonGoto.Location = new System.Drawing.Point(199, 106);
350 | this.buttonGoto.Name = "buttonGoto";
351 | this.buttonGoto.Size = new System.Drawing.Size(44, 23);
352 | this.buttonGoto.TabIndex = 25;
353 | this.buttonGoto.Text = "Goto";
354 | this.buttonGoto.UseVisualStyleBackColor = true;
355 | this.buttonGoto.Click += new System.EventHandler(this.buttonGoto_Click);
356 | //
357 | // buttonClose
358 | //
359 | this.buttonClose.Location = new System.Drawing.Point(168, 77);
360 | this.buttonClose.Name = "buttonClose";
361 | this.buttonClose.Size = new System.Drawing.Size(75, 23);
362 | this.buttonClose.TabIndex = 24;
363 | this.buttonClose.Text = "Close";
364 | this.buttonClose.UseVisualStyleBackColor = true;
365 | this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
366 | //
367 | // buttonResume
368 | //
369 | this.buttonResume.Location = new System.Drawing.Point(87, 48);
370 | this.buttonResume.Name = "buttonResume";
371 | this.buttonResume.Size = new System.Drawing.Size(75, 23);
372 | this.buttonResume.TabIndex = 23;
373 | this.buttonResume.Text = "Show";
374 | this.buttonResume.UseVisualStyleBackColor = true;
375 | this.buttonResume.Click += new System.EventHandler(this.buttonResume_Click);
376 | //
377 | // buttonHide
378 | //
379 | this.buttonHide.Location = new System.Drawing.Point(6, 48);
380 | this.buttonHide.Name = "buttonHide";
381 | this.buttonHide.Size = new System.Drawing.Size(75, 23);
382 | this.buttonHide.TabIndex = 22;
383 | this.buttonHide.Text = "Hide";
384 | this.buttonHide.UseVisualStyleBackColor = true;
385 | this.buttonHide.Click += new System.EventHandler(this.buttonHide_Click);
386 | //
387 | // pictureBoxThumb
388 | //
389 | this.pictureBoxThumb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
390 | | System.Windows.Forms.AnchorStyles.Left)
391 | | System.Windows.Forms.AnchorStyles.Right)));
392 | this.pictureBoxThumb.BackColor = System.Drawing.Color.White;
393 | this.pictureBoxThumb.Location = new System.Drawing.Point(434, 14);
394 | this.pictureBoxThumb.Name = "pictureBoxThumb";
395 | this.pictureBoxThumb.Size = new System.Drawing.Size(238, 286);
396 | this.pictureBoxThumb.TabIndex = 21;
397 | this.pictureBoxThumb.TabStop = false;
398 | //
399 | // MainForm
400 | //
401 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
402 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
403 | this.ClientSize = new System.Drawing.Size(684, 312);
404 | this.Controls.Add(this.pictureBoxThumb);
405 | this.Controls.Add(this.groupBox3);
406 | this.Controls.Add(this.groupBox1);
407 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
408 | this.MinimumSize = new System.Drawing.Size(700, 350);
409 | this.Name = "MainForm";
410 | this.Text = "Powerpoint Viewer Demo";
411 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
412 | this.groupBox1.ResumeLayout(false);
413 | this.groupBox1.PerformLayout();
414 | this.groupBox2.ResumeLayout(false);
415 | this.groupBox2.PerformLayout();
416 | this.groupBox3.ResumeLayout(false);
417 | this.groupBox3.PerformLayout();
418 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxThumb)).EndInit();
419 | this.ResumeLayout(false);
420 |
421 | }
422 |
423 | #endregion
424 |
425 | private System.Windows.Forms.TextBox textBoxX;
426 | private System.Windows.Forms.Label label1;
427 | private System.Windows.Forms.Label label2;
428 | private System.Windows.Forms.TextBox textBoxY;
429 | private System.Windows.Forms.Label label3;
430 | private System.Windows.Forms.Label label4;
431 | private System.Windows.Forms.TextBox textBoxWidth;
432 | private System.Windows.Forms.TextBox textBoxHeight;
433 | private System.Windows.Forms.Button buttonOpen;
434 | private System.Windows.Forms.Label label5;
435 | private System.Windows.Forms.TextBox textBoxFilename;
436 | private System.Windows.Forms.Label label7;
437 | private System.Windows.Forms.Label labelSlide;
438 | private System.Windows.Forms.Label label8;
439 | private System.Windows.Forms.Label labelCount;
440 | private System.Windows.Forms.Button buttonPrev;
441 | private System.Windows.Forms.Button buttonNext;
442 | private System.Windows.Forms.GroupBox groupBox1;
443 | private System.Windows.Forms.GroupBox groupBox2;
444 | private System.Windows.Forms.GroupBox groupBox3;
445 | private System.Windows.Forms.Button buttonResume;
446 | private System.Windows.Forms.Button buttonClose;
447 | private System.Windows.Forms.TextBox textBoxGoto;
448 | private System.Windows.Forms.Button buttonGoto;
449 | private System.Windows.Forms.Button buttonChooseFile;
450 | private System.Windows.Forms.Button buttonUnblank;
451 | private System.Windows.Forms.Button buttonBlank;
452 | private System.Windows.Forms.Button buttonHide;
453 | private System.Windows.Forms.ListBox listBoxDocuments;
454 | private System.Windows.Forms.Button buttonMove;
455 | private System.Windows.Forms.PictureBox pictureBoxThumb;
456 | private System.Windows.Forms.Button buttonFocus;
457 | }
458 | }
--------------------------------------------------------------------------------
/PowerpointViewerDemo/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Runtime.InteropServices;
5 | using System.Windows.Forms;
6 | using PowerpointViewerLib;
7 |
8 | namespace PowerpointViewerDemo
9 | {
10 | public partial class MainForm : Form
11 | {
12 | [DllImport("User32.dll")]
13 | private static extern int SetForegroundWindow(IntPtr hWnd);
14 |
15 | List openDocuments = new List();
16 | PowerpointViewerDocument activeDocument;
17 | int counter = 0;
18 |
19 | public MainForm()
20 | {
21 | InitializeComponent();
22 |
23 | PowerpointViewerController.DebugMode = true;
24 |
25 | }
26 |
27 | private void buttonOpen_Click(object sender, EventArgs e)
28 | {
29 | int x = int.Parse(textBoxX.Text);
30 | int y = int.Parse(textBoxY.Text);
31 | int width = int.Parse(textBoxWidth.Text);
32 | int height = int.Parse(textBoxHeight.Text);
33 | string filename = textBoxFilename.Text;
34 |
35 | if (string.IsNullOrEmpty(filename))
36 | return;
37 |
38 | Rectangle rect = new Rectangle(x, y, width, height);
39 | try
40 | {
41 | activeDocument = PowerpointViewerController.Open(filename, rect, thumbnailWidth: 200);
42 | activeDocument.Loaded += new EventHandler(activeDocument_Loaded);
43 | activeDocument.SlideChanged += new EventHandler(activeDocument_SlideChanged);
44 | activeDocument.Closed += new EventHandler(activeDocument_Closed);
45 | activeDocument.HiddenSlide += new EventHandler(activeDocument_HiddenSlide);
46 | openDocuments.Add(activeDocument);
47 | listBoxDocuments.SelectedIndex = listBoxDocuments.Items.Add("Document #" + (counter++));
48 | this.UpdateStats();
49 | SetForegroundWindow(this.Handle);
50 | }
51 | catch (PowerpointViewerController.PowerpointViewerOpenException)
52 | {
53 | MessageBox.Show("Loading failed.");
54 | }
55 | }
56 |
57 | // ATTENTION: Events arrive on a different thread, therefore we need this.Invoke(...)
58 | void activeDocument_SlideChanged(object sender, EventArgs e)
59 | {
60 | this.Invoke(new Action(this.UpdateStats));
61 | }
62 |
63 | void activeDocument_Loaded(object sender, EventArgs e)
64 | {
65 | this.Invoke(new Action(() => pictureBoxThumb.Image = (sender as PowerpointViewerDocument).Thumbnails[0]));
66 | }
67 |
68 | void activeDocument_Closed(object sender, EventArgs e)
69 | {
70 | if (openDocuments != null)
71 | {
72 | this.Invoke(new Action((doc) =>
73 | {
74 | pictureBoxThumb.Image = null;
75 | int i = openDocuments.IndexOf(doc);
76 | openDocuments.Remove(doc);
77 | listBoxDocuments.Items.RemoveAt(i);
78 | }), sender as PowerpointViewerDocument);
79 | }
80 | }
81 |
82 | void activeDocument_HiddenSlide(object sender, EventArgs e)
83 | {
84 | this.Invoke(new Action(() => MessageBox.Show("There is at least one hidden slide in the presentation. Slide indexing does not work correctly with hidden slides.")));
85 | }
86 |
87 | public void UpdateStats()
88 | {
89 | if (activeDocument == null)
90 | {
91 | labelSlide.Text = "-";
92 | labelCount.Text = "-";
93 | }
94 | else
95 | {
96 | labelSlide.Text = activeDocument.CurrentSlide.ToString();
97 | labelCount.Text = activeDocument.SlideCount.ToString();
98 | if (activeDocument.CurrentSlide != -1)
99 | {
100 | pictureBoxThumb.Image = activeDocument.Thumbnails[activeDocument.CurrentSlide];
101 | }
102 | }
103 | }
104 |
105 | private void buttonPrev_Click(object sender, EventArgs e)
106 | {
107 | if (activeDocument == null)
108 | return;
109 | activeDocument.PrevStep();
110 | }
111 |
112 | private void buttonNext_Click(object sender, EventArgs e)
113 | {
114 | if (activeDocument == null)
115 | return;
116 | activeDocument.NextStep();
117 | }
118 |
119 | private void buttonHide_Click(object sender, EventArgs e)
120 | {
121 | if (activeDocument == null)
122 | return;
123 | activeDocument.Hide();
124 | }
125 |
126 | private void buttonResume_Click(object sender, EventArgs e)
127 | {
128 | if (activeDocument == null)
129 | return;
130 | activeDocument.Show();
131 | }
132 |
133 | private void buttonClose_Click(object sender, EventArgs e)
134 | {
135 | if (activeDocument == null)
136 | return;
137 | activeDocument.Close();
138 | activeDocument = null;
139 | }
140 |
141 | private void buttonGoto_Click(object sender, EventArgs e)
142 | {
143 | if (activeDocument == null)
144 | return;
145 | activeDocument.GotoSlide(int.Parse(textBoxGoto.Text));
146 | }
147 |
148 | private void buttonChooseFile_Click(object sender, EventArgs e)
149 | {
150 | var ofd = new OpenFileDialog();
151 | if (ofd.ShowDialog() == DialogResult.OK)
152 | {
153 | textBoxFilename.Text = ofd.FileName;
154 | }
155 | }
156 |
157 | private void buttonBlank_Click(object sender, EventArgs e)
158 | {
159 | if (activeDocument == null)
160 | return;
161 | activeDocument.Blank();
162 | }
163 |
164 | private void buttonUnblank_Click(object sender, EventArgs e)
165 | {
166 | if (activeDocument == null)
167 | return;
168 | activeDocument.Unblank();
169 | }
170 |
171 | private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
172 | {
173 | var tmp = openDocuments;
174 | openDocuments = null;
175 | foreach (var doc in tmp)
176 | {
177 | doc.Close();
178 | }
179 | }
180 |
181 | private void listBoxDocuments_SelectedIndexChanged(object sender, EventArgs e)
182 | {
183 | if (listBoxDocuments.SelectedIndex == -1)
184 | activeDocument = null;
185 | else
186 | activeDocument = openDocuments[listBoxDocuments.SelectedIndex];
187 | UpdateStats();
188 | }
189 |
190 | private void buttonMove_Click(object sender, EventArgs e)
191 | {
192 | if (activeDocument == null)
193 | return;
194 |
195 | int x = int.Parse(textBoxX.Text);
196 | int y = int.Parse(textBoxY.Text);
197 | activeDocument.Move(x, y);
198 | }
199 |
200 | private void buttonFocus_Click(object sender, EventArgs e)
201 | {
202 | if (activeDocument == null)
203 | return;
204 |
205 | activeDocument.Focus();
206 | }
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/PowerpointViewerDemo/PowerpointViewerDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}
9 | WinExe
10 | Properties
11 | PowerpointViewerDemo
12 | PowerpointViewerDemo
13 | v4.0
14 | Client
15 | 512
16 |
17 |
18 | x86
19 | true
20 | full
21 | false
22 | ..\bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | x86
29 | pdbonly
30 | true
31 | ..\bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 | PowerpointViewerDemo.Program
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Form
51 |
52 |
53 | MainForm.cs
54 |
55 |
56 |
57 |
58 |
59 | MainForm.cs
60 |
61 |
62 |
63 |
64 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}
65 | PowerpointViewerLib
66 |
67 |
68 |
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/PowerpointViewerDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace PowerpointViewerDemo
5 | {
6 | public class Program
7 | {
8 | [STAThread]
9 | public static void Main()
10 | {
11 | Application.EnableVisualStyles();
12 | Application.SetCompatibleTextRenderingDefault(false);
13 | Application.Run(new MainForm());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/PowerpointViewerLib.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerpointViewerLib", "PowerpointViewerLib\PowerpointViewerLib.csproj", "{F36E815C-5B9C-4E5F-B82D-E5A718E504E6}"
5 | ProjectSection(ProjectDependencies) = postProject
6 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF} = {04CC20D1-DC5A-4189-8181-4011E3C21DCF}
7 | EndProjectSection
8 | EndProject
9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerpointViewerDemo", "PowerpointViewerDemo\PowerpointViewerDemo.csproj", "{78FE1EC7-878F-4CFD-846C-2E1C7391E272}"
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pptviewlib", "pptviewlib\pptviewlib.vcxproj", "{04CC20D1-DC5A-4189-8181-4011E3C21DCF}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Debug|Mixed Platforms = Debug|Mixed Platforms
17 | Debug|Win32 = Debug|Win32
18 | Debug|x86 = Debug|x86
19 | Release|Any CPU = Release|Any CPU
20 | Release|Mixed Platforms = Release|Mixed Platforms
21 | Release|Win32 = Release|Win32
22 | Release|x86 = Release|x86
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
28 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Debug|Mixed Platforms.Build.0 = Debug|x86
29 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Debug|Win32.ActiveCfg = Debug|x86
30 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Debug|x86.ActiveCfg = Debug|x86
31 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Debug|x86.Build.0 = Debug|x86
32 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Release|Mixed Platforms.ActiveCfg = Release|x86
35 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Release|Mixed Platforms.Build.0 = Release|x86
36 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Release|Win32.ActiveCfg = Release|x86
37 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Release|x86.ActiveCfg = Release|x86
38 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}.Release|x86.Build.0 = Release|x86
39 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Debug|Any CPU.ActiveCfg = Debug|x86
40 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
41 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Debug|Mixed Platforms.Build.0 = Debug|x86
42 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Debug|Win32.ActiveCfg = Debug|x86
43 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Debug|x86.ActiveCfg = Debug|x86
44 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Debug|x86.Build.0 = Debug|x86
45 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Release|Any CPU.ActiveCfg = Release|x86
46 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Release|Mixed Platforms.ActiveCfg = Release|x86
47 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Release|Mixed Platforms.Build.0 = Release|x86
48 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Release|Win32.ActiveCfg = Release|x86
49 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Release|x86.ActiveCfg = Release|x86
50 | {78FE1EC7-878F-4CFD-846C-2E1C7391E272}.Release|x86.Build.0 = Release|x86
51 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Debug|Any CPU.ActiveCfg = Debug|Win32
52 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
53 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
54 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Debug|Win32.ActiveCfg = Debug|Win32
55 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Debug|Win32.Build.0 = Debug|Win32
56 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Debug|x86.ActiveCfg = Debug|Win32
57 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Release|Any CPU.ActiveCfg = Release|Win32
58 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
59 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Release|Mixed Platforms.Build.0 = Release|Win32
60 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Release|Win32.ActiveCfg = Release|Win32
61 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Release|Win32.Build.0 = Release|Win32
62 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}.Release|x86.ActiveCfg = Release|Win32
63 | EndGlobalSection
64 | GlobalSection(SolutionProperties) = preSolution
65 | HideSolutionNode = FALSE
66 | EndGlobalSection
67 | EndGlobal
68 |
--------------------------------------------------------------------------------
/PowerpointViewerLib/PowerpointViewerController.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * PowerpointViewerLib - PowerPoint Viewer 2003/2007 Controller
3 | *
4 | * Copyright (c) 2012-2014 Kai Patrick Reisert
5 | * Portions copyright (c) 2008-2011 Raoul Snyman, Tim Bentley, Jonathan Corwin,
6 | * Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler,
7 | * Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout,
8 | * Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund
9 | *
10 | * This program is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * This program is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program. If not, see .
22 | */
23 |
24 | using System;
25 | using System.Drawing;
26 | using System.IO;
27 | using System.Runtime.InteropServices;
28 | using System.Text;
29 | using Microsoft.Win32;
30 |
31 | namespace PowerpointViewerLib
32 | {
33 | public class PowerpointViewerController
34 | {
35 | public class PowerpointViewerOpenException : ApplicationException { }
36 |
37 | internal const string DllName = "pptviewlib.dll";
38 |
39 | [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
40 | internal delegate int CallbackDelegate(int msg, int param);
41 |
42 | [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
43 | internal static extern int OpenPPT(StringBuilder command, CallbackDelegate func, IntPtr hParentWnd, int x, int y, int width, int height);
44 |
45 | [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
46 | internal static extern void ClosePPT(int id);
47 |
48 | [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
49 | private static extern void SetDebug(bool onOff);
50 |
51 | [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
52 | private static extern void Shutdown();
53 |
54 | private static bool debugMode = false; // this is the default set in pptviewlib.cpp
55 |
56 | public static bool DebugMode
57 | {
58 | get
59 | {
60 | return debugMode;
61 | }
62 | set
63 | {
64 | debugMode = value;
65 | SetDebug(debugMode);
66 | }
67 | }
68 |
69 | private static string viewerPath;
70 |
71 | public static string ViewerPath
72 | {
73 | get
74 | {
75 | if (viewerPath == null)
76 | viewerPath = GetPPTViewerPath();
77 | return viewerPath;
78 | }
79 | }
80 |
81 | public static bool IsAvailable
82 | {
83 | get
84 | {
85 | if (viewerPath == null)
86 | viewerPath = GetPPTViewerPath();
87 | return (viewerPath != null);
88 | }
89 | }
90 |
91 | private PowerpointViewerController()
92 | {
93 | viewerPath = GetPPTViewerPath();
94 | }
95 |
96 | ///
97 | /// Opens a powerpoint file.
98 | ///
99 | /// The file to open.
100 | /// The rectangle of the area on the screen, where to show the PowerPoint Viewer.
101 | /// Whether thumbnails should be generated.
102 | /// Whether the PowerPoint Viewer should be opened hidden (outside of the visible screen).
103 | /// If set, defines the size of the generated thumbnails.
104 | ///
105 | /// A that manages the status of the PowerPoint Viewer instance.
106 | ///
107 | /// PowerPoint Viewer could not be found (maybe it's not installed).
108 | /// The file to open could not be found.
109 | /// pptviewlib.dll could not be found.
110 | /// Something went wrong in pptviewlib.dll
111 | public static PowerpointViewerDocument Open(string filename, Rectangle rect, bool generateThumbnails = true, bool openHidden = false, int thumbnailWidth = 0)
112 | {
113 | if (!IsAvailable)
114 | throw new InvalidOperationException("Can't open a file: PowerPoint Viewer could not be found.");
115 |
116 | var file = new FileInfo(filename);
117 |
118 | if (!file.Exists)
119 | throw new FileNotFoundException(file.FullName);
120 |
121 | PowerpointViewerDocument doc = new PowerpointViewerDocument(file.FullName, rect, generateThumbnails, openHidden, thumbnailWidth);
122 | return doc;
123 | }
124 |
125 | ///
126 | /// Get the path of the PowerPoint viewer from the registry
127 | ///
128 | private static string GetPPTViewerPath()
129 | {
130 | // The following registry settings are for, respectively, (I think)
131 | // PPT Viewer 2007 (older versions. Latest not in registry) & PPT Viewer 2010
132 | // PPT Viewer 2003 (recent versions)
133 | // PPT Viewer 2003 (older versions)
134 | // PPT Viewer 97
135 |
136 | string path = TryGetPPTViewerPathFromRegKey("PowerPointViewer.Show.12\\shell\\Show\\command");
137 | if (path == null)
138 | path = TryGetPPTViewerPathFromRegKey("PowerPointViewer.Show.11\\shell\\Show\\command");
139 | if (path == null)
140 | path = TryGetPPTViewerPathFromRegKey("Applications\\PPTVIEW.EXE\\shell\\open\\command");
141 | if (path == null)
142 | path = TryGetPPTViewerPathFromRegKey("Applications\\PPTVIEW.EXE\\shell\\Show\\command");
143 |
144 | if (path != null && File.Exists(path))
145 | return path;
146 |
147 | // This is where it gets ugly. PPT2007 it seems no longer stores its
148 | // location in the registry. So we have to use the defaults which will
149 | // upset those who like to put things somewhere else
150 |
151 | // Viewer 2007 in 64bit Windows:
152 | path = "C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE";
153 | if (File.Exists(path))
154 | return path;
155 |
156 | // Viewer 2007 in 32bit Windows:
157 | path = "C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE";
158 | if (File.Exists(path))
159 | return path;
160 |
161 | // Give them the opportunity to place it in the same folder as the app
162 | path = Directory.GetCurrentDirectory() + "\\PPTVIEW.EXE";
163 | if (File.Exists(path))
164 | return path;
165 |
166 | return null;
167 | }
168 |
169 | private static string TryGetPPTViewerPathFromRegKey(string keyname)
170 | {
171 | var key = Registry.ClassesRoot.OpenSubKey(keyname);
172 | if (key != null)
173 | {
174 | string value = key.GetValue("") as string;
175 | if (value != null)
176 | {
177 | return value.Substring(0, value.Length - 4);
178 | }
179 | }
180 |
181 | return null;
182 | }
183 |
184 | ~PowerpointViewerController()
185 | {
186 | Shutdown();
187 | }
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/PowerpointViewerLib/PowerpointViewerDocument.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * PowerpointViewerLib - PowerPoint Viewer 2003/2007 Controller
3 | *
4 | * Copyright (c) 2012-2014 Kai Patrick Reisert
5 | * Portions copyright (c) 2008-2011 Raoul Snyman, Tim Bentley, Jonathan Corwin,
6 | * Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler,
7 | * Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout,
8 | * Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund
9 | *
10 | * This program is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * This program is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program. If not, see .
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Drawing;
27 | using System.Linq;
28 | using System.Runtime.InteropServices;
29 | using System.Text;
30 | using System.Threading;
31 |
32 | namespace PowerpointViewerLib
33 | {
34 | public class ErrorEventArgs : EventArgs
35 | {
36 | public Exception Exception { get; private set; }
37 |
38 | public ErrorEventArgs(Exception e)
39 | {
40 | this.Exception = e;
41 | }
42 | }
43 |
44 | public class PowerpointViewerDocument
45 | {
46 | class ThumbnailWrapper
47 | {
48 | public Bitmap Bitmap { get; set; }
49 | public int Slide { get; set; }
50 | }
51 |
52 | [DllImport("user32.dll", SetLastError = true)]
53 | private static extern IntPtr PostMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, UIntPtr lParam);
54 |
55 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError=true)]
56 | private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, UIntPtr lParam);
57 |
58 | [DllImport("user32.dll", SetLastError = true)]
59 | private static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
60 |
61 | [DllImport("user32.dll")]
62 | private static extern bool PrintWindow(IntPtr hwnd, IntPtr hdcBlt, uint nFlags);
63 |
64 | [DllImport("user32.dll")]
65 | private static extern int GetWindowRect(IntPtr hwnd, out Rectangle rc);
66 |
67 | [DllImport("User32.dll")]
68 | private static extern int SetForegroundWindow(IntPtr hWnd);
69 |
70 | const uint WM_MOUSEWHEEL = 0x020A;
71 | const uint WM_KEYUP = 0x0101;
72 | const uint WM_KEYDOWN = 0x0100;
73 | const uint WM_CHAR = 0x0102;
74 | const uint WM_SETFOCUS = 0x7;
75 | const uint VK_RETURN = 0x0D;
76 |
77 | private static IntPtr MakeWParam(int loWord, int hiWord)
78 | {
79 | return new IntPtr(loWord + hiWord * 65536);
80 | }
81 |
82 | private enum State
83 | {
84 | Starting,
85 | Loading,
86 | Resetting,
87 | Running
88 | }
89 |
90 | private State state = State.Starting;
91 | private volatile int currentSlide = -1;
92 | private Dictionary slideSteps = new Dictionary();
93 | private Dictionary slideIds = new Dictionary();
94 |
95 | private IntPtr hWnd;
96 | private IntPtr hWnd2;
97 |
98 | public IntPtr WindowHandle
99 | {
100 | get
101 | {
102 | return hWnd;
103 | }
104 | }
105 |
106 | public bool IsEndless
107 | {
108 | get
109 | {
110 | if (state != State.Running)
111 | throw new InvalidOperationException("Slideshow not loaded yet.");
112 |
113 | return endless;
114 | }
115 | }
116 |
117 | private Rectangle rect;
118 | private bool closed = false;
119 | private bool endless = false;
120 | private bool openHidden;
121 | private volatile List captureThumbs;
122 | private readonly int thumbnailWidth;
123 |
124 | public event EventHandler SlideChanged;
125 | public event EventHandler Closed;
126 | public event EventHandler Loaded;
127 | public event EventHandler Error;
128 | public event EventHandler HiddenSlide;
129 |
130 | PowerpointViewerController.CallbackDelegate del;
131 |
132 | public List Thumbnails
133 | {
134 | get;
135 | private set;
136 | }
137 |
138 | public bool HasLoaded
139 | {
140 | get
141 | {
142 | return (state == State.Running);
143 | }
144 | }
145 |
146 | private int id = -1;
147 |
148 | internal PowerpointViewerDocument(string filename, Rectangle rect, bool generateThumbnails, bool openHidden, int thumbnailWidth)
149 | {
150 | this.rect = rect;
151 | this.openHidden = openHidden;
152 |
153 | if (generateThumbnails)
154 | {
155 | this.captureThumbs = new List();
156 | this.thumbnailWidth = thumbnailWidth;
157 | }
158 |
159 | string cmd = PowerpointViewerController.ViewerPath + " /F /S \"" + filename + "\"";
160 |
161 | del = new PowerpointViewerController.CallbackDelegate(Callback);
162 |
163 | this.id = PowerpointViewerController.OpenPPT(new StringBuilder(cmd), del, IntPtr.Zero, rect.X, rect.Y, rect.Width, rect.Height);
164 | if (this.id == -1)
165 | throw new PowerpointViewerController.PowerpointViewerOpenException();
166 | }
167 |
168 | private int Callback(int msg, int param)
169 | {
170 | switch (msg)
171 | {
172 | case 1: // Receive window handle
173 | hWnd = new IntPtr(param);
174 | break;
175 | case 2: // Receive second window handle, the window is now setup completely
176 | hWnd2 = new IntPtr(param);
177 | Debug("Started, now loading ...");
178 | state = State.Loading;
179 | break;
180 | case 3: // We're moving one step further while loading
181 | if (state == State.Loading)
182 | {
183 | if (currentSlide >= 0)
184 | {
185 | slideSteps[currentSlide]++;
186 | Debug("Updating steps of slide #" + currentSlide + ": " + slideSteps[currentSlide]);
187 | }
188 | }
189 | break;
190 | case 4: // Slide change
191 | new Thread(() =>
192 | {
193 | try
194 | {
195 | Debug("Slide changed: " + param + " (" + state.ToString() + ")");
196 |
197 | if ((state == State.Starting || state == State.Loading) && param != 0)
198 | {
199 | currentSlide++;
200 | if (!slideIds.ContainsKey(param))
201 | {
202 | slideIds.Add(param, currentSlide);
203 | slideSteps.Add(currentSlide, 0);
204 | }
205 | else
206 | {
207 | endless = true;
208 | }
209 | }
210 | else if (state == State.Running || state == State.Resetting)
211 | {
212 | if (param == 0)
213 | {
214 | PrevStep();
215 | }
216 | else
217 | {
218 | if (!slideIds.ContainsKey(param))
219 | {
220 | if (state == State.Resetting)
221 | {
222 | throw new PowerpointViewerController.PowerpointViewerOpenException();
223 | }
224 | else
225 | {
226 | OnHiddenSlide();
227 | }
228 | }
229 | else
230 | {
231 | currentSlide = slideIds[param];
232 |
233 | if (state == State.Running)
234 | {
235 | OnSlideChanged();
236 | }
237 | }
238 | }
239 | }
240 |
241 | bool resetNow = false;
242 |
243 | if (state == State.Loading && currentSlide != -1)
244 | {
245 | if (param == 0 || endless) // reached last slide or noticed that slide id's are repeating
246 | {
247 | // If we don't go back every single step, PowerPoint remembers
248 | // that the slides have been animated and won't show the animations
249 | // the next time.
250 |
251 | state = State.Resetting;
252 |
253 | // If we're repeating a single slide without any steps, going one step back
254 | // won't change the slide, therefore we need to do the resetting directly
255 | // without waiting for the next event
256 | if (endless && slideIds.Count == 1 && slideSteps[0] <= 1)
257 | {
258 | currentSlide = 0;
259 | resetNow = true;
260 | }
261 | else
262 | {
263 | PrevStep();
264 | }
265 | }
266 | }
267 | else if (state == State.Resetting)
268 | {
269 | resetNow = true;
270 | }
271 |
272 | if (resetNow)
273 | {
274 | if (captureThumbs != null)
275 | {
276 | Bitmap bmp = Capture(this.thumbnailWidth);
277 | captureThumbs.Add(new ThumbnailWrapper { Bitmap = bmp, Slide = currentSlide });
278 | }
279 |
280 | int goBackSteps = currentSlide == 0 ? slideSteps[currentSlide] - 1 : slideSteps[currentSlide];
281 |
282 | for (int i = 0; i < goBackSteps; i++)
283 | {
284 | Debug("Going back (slide #" + currentSlide + ")");
285 | PrevStep();
286 | }
287 | if (currentSlide == 0) // back at the beginning
288 | {
289 | state = State.Running;
290 | if (captureThumbs != null)
291 | {
292 | this.Thumbnails = (from t in captureThumbs orderby t.Slide ascending select t.Bitmap).ToList();
293 | }
294 | Unblank();
295 | if (!openHidden)
296 | Show();
297 | OnLoaded();
298 | OnSlideChanged();
299 | Debug("Now running ...");
300 | }
301 | }
302 | }
303 | catch (Exception e)
304 | {
305 | Close();
306 | OnError(e);
307 | }
308 | }).Start();
309 | break;
310 | case 5: // Slideshow window has been closed (e.g. ESC)
311 | Debug("Window has been closed");
312 | new Thread(() => Close()).Start();
313 | break;
314 | case 6: // The slideshow is closing
315 | Debug("Close event");
316 | new Thread(() =>
317 | {
318 | OnClosed();
319 | closed = true;
320 | }).Start();
321 | break;
322 | default:
323 | Debug("Unknown message: " + msg + "(param: "+param+")");
324 | break;
325 | }
326 | return 0;
327 | }
328 |
329 | private void Debug(string p)
330 | {
331 | System.Diagnostics.Debug.WriteLine("#" + this.id + " - " + p);
332 | }
333 |
334 | private void OnLoaded()
335 | {
336 | if (Loaded != null)
337 | Loaded(this, EventArgs.Empty);
338 | }
339 |
340 | private void OnClosed()
341 | {
342 | if (Closed != null)
343 | Closed(this, EventArgs.Empty);
344 | }
345 |
346 | private void OnSlideChanged()
347 | {
348 | if (SlideChanged != null)
349 | SlideChanged(this, EventArgs.Empty);
350 | }
351 |
352 | private void OnHiddenSlide()
353 | {
354 | if (HiddenSlide != null)
355 | HiddenSlide(this, EventArgs.Empty);
356 | }
357 |
358 | private void OnError(Exception e)
359 | {
360 | if (Error != null)
361 | Error(this, new ErrorEventArgs(e));
362 | }
363 |
364 | ///
365 | /// Gets the total number of slides.
366 | ///
367 | public int SlideCount
368 | {
369 | get
370 | {
371 | if (state == State.Starting || state == State.Loading)
372 | return -1;
373 |
374 | return slideIds.Count;
375 | }
376 | }
377 |
378 | ///
379 | /// Gets the 0-based index of the current slide.
380 | ///
381 | public int CurrentSlide
382 | {
383 | get
384 | {
385 | if (state != State.Running)
386 | return -1;
387 |
388 | return currentSlide;
389 | }
390 | }
391 |
392 | ///
393 | /// Gets the number of steps of the slide with the given index.
394 | /// 1 means that there is no animation on that slide.
395 | ///
396 | /// The slide index.
397 | ///
398 | public int GetSlideStepCount(int slide)
399 | {
400 | if (state != State.Running)
401 | throw new InvalidOperationException("Slideshow not loaded yet.");
402 |
403 | if (slide < 0 || slide >= SlideCount)
404 | throw new ArgumentOutOfRangeException("slide");
405 |
406 | return slideSteps[slide];
407 | }
408 |
409 | ///
410 | /// Sets the focus to the Powerpoint Viewer window.
411 | ///
412 | public void Focus()
413 | {
414 | SetForegroundWindow(hWnd);
415 | }
416 |
417 | ///
418 | /// Moves one step back in the presentation.
419 | ///
420 | public void PrevStep()
421 | {
422 | SendMessage(hWnd, WM_SETFOCUS, IntPtr.Zero, UIntPtr.Zero);
423 | PostMessage(hWnd2, WM_MOUSEWHEEL, MakeWParam(0, 120), UIntPtr.Zero);
424 | }
425 |
426 | ///
427 | /// Moves one step further in the presentation.
428 | ///
429 | public void NextStep()
430 | {
431 | if (currentSlide >= SlideCount) return;
432 |
433 | SendMessage(hWnd, WM_SETFOCUS, IntPtr.Zero, UIntPtr.Zero);
434 | PostMessage(hWnd2, WM_MOUSEWHEEL, MakeWParam(0, -120), UIntPtr.Zero);
435 | }
436 |
437 | ///
438 | /// Moves to a given slide.
439 | ///
440 | /// The 0-based index of the slide.
441 | public void GotoSlide(int slide)
442 | {
443 | if (slide < 0)
444 | throw new ArgumentException();
445 |
446 | int num = slide + 1;
447 | char[] digits = num.ToString().ToCharArray();
448 |
449 | SendMessage(hWnd, WM_SETFOCUS, IntPtr.Zero, UIntPtr.Zero);
450 |
451 | foreach (char c in digits)
452 | {
453 | PostMessage(hWnd2, WM_KEYDOWN, new IntPtr((int)c), new UIntPtr(0));
454 | PostMessage(hWnd2, WM_KEYUP, new IntPtr((int)c), new UIntPtr(0xC0000001));
455 | }
456 | Thread.Sleep(10);
457 | PostMessage(hWnd2, WM_KEYDOWN, new IntPtr((int)VK_RETURN), new UIntPtr(0));
458 | PostMessage(hWnd2, WM_KEYUP, new IntPtr((int)VK_RETURN), new UIntPtr(0xC0000001));
459 | }
460 |
461 | ///
462 | /// Blanks the presentation (blackscreen).
463 | ///
464 | public void Blank()
465 | {
466 | // Unblank first, using any key ('A' in this case), then blank
467 | SendMessage(hWnd, WM_SETFOCUS, IntPtr.Zero, UIntPtr.Zero);
468 | PostMessage(hWnd2, WM_KEYDOWN, new IntPtr((int)'A'), new UIntPtr(0));
469 | PostMessage(hWnd2, WM_KEYUP, new IntPtr((int)'A'), new UIntPtr(0xC0000001));
470 | Thread.Sleep(10);
471 | PostMessage(hWnd2, WM_KEYDOWN, new IntPtr((int)'B'), new UIntPtr(0));
472 | PostMessage(hWnd2, WM_KEYUP, new IntPtr((int)'B'), new UIntPtr(0xC0000001));
473 | }
474 |
475 | ///
476 | /// Unblanks the presentation.
477 | ///
478 | public void Unblank()
479 | {
480 | SendMessage(hWnd, WM_SETFOCUS, IntPtr.Zero, UIntPtr.Zero);
481 | PostMessage(hWnd2, WM_KEYDOWN, new IntPtr((int)'A'), new UIntPtr(0));
482 | PostMessage(hWnd2, WM_KEYUP, new IntPtr((int)'A'), new UIntPtr(0xC0000001));
483 | }
484 |
485 | ///
486 | /// Hides the presentation by moving it outside of the screen.
487 | ///
488 | public void Hide()
489 | {
490 | MoveWindow(hWnd, -32000, -32000, this.rect.Width, this.rect.Height, true);
491 | }
492 |
493 | ///
494 | /// Shows the presentation by moving it back to it's normal position.
495 | ///
496 | public void Show()
497 | {
498 | MoveWindow(hWnd, this.rect.Left, this.rect.Top, this.rect.Width,this.rect.Height, true);
499 | }
500 |
501 | ///
502 | /// Moves the presentation window.
503 | ///
504 | /// The new x position.
505 | /// The new y position.
506 | public void Move(int x, int y)
507 | {
508 | this.rect.X = x;
509 | this.rect.Y = y;
510 | Show();
511 | }
512 |
513 | ///
514 | /// Closes the presentation.
515 | ///
516 | public void Close()
517 | {
518 | if (!closed)
519 | {
520 | PowerpointViewerController.ClosePPT(this.id);
521 | closed = true;
522 | }
523 | }
524 |
525 | ///
526 | /// Captures a screenshot of the presentation window as a bitmap
527 | /// (only works while the window is shown).
528 | ///
529 | /// The desired width of the bitmap.
530 | /// A bitmap containing the screenshow.
531 | public Bitmap CaptureWindow(int width)
532 | {
533 | return Capture(width);
534 | }
535 |
536 | ~PowerpointViewerDocument()
537 | {
538 | this.Close();
539 | }
540 |
541 | private Bitmap Capture(int thumbnailWidth)
542 | {
543 | Rectangle rc;
544 | GetWindowRect(hWnd, out rc);
545 |
546 | Bitmap bm = new Bitmap(rect.Width, rect.Height);
547 | Graphics g = Graphics.FromImage(bm);
548 | IntPtr hdc = g.GetHdc();
549 |
550 | PrintWindow(hWnd, hdc, 0);
551 |
552 | g.ReleaseHdc(hdc);
553 | g.Flush();
554 | g.Dispose();
555 |
556 | if (thumbnailWidth > 0)
557 | {
558 | double ratio = (double)rect.Width / rect.Height;
559 | int thumbnailHeight = (int)(thumbnailWidth / ratio);
560 |
561 | Bitmap result = new Bitmap(thumbnailWidth, thumbnailHeight);
562 | using (Graphics gg = Graphics.FromImage((Image)result))
563 | gg.DrawImage(bm, 0, 0, thumbnailWidth, thumbnailHeight);
564 | bm.Dispose();
565 | return result;
566 | }
567 | else
568 | {
569 | return bm; // do not resize
570 | }
571 | }
572 | }
573 | }
574 |
--------------------------------------------------------------------------------
/PowerpointViewerLib/PowerpointViewerLib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {F36E815C-5B9C-4E5F-B82D-E5A718E504E6}
9 | Library
10 | Properties
11 | PowerpointViewerLib
12 | PowerpointViewerLib
13 | v4.0
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | x86
26 |
27 |
28 | pdbonly
29 | true
30 | ..\bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | x86
35 |
36 |
37 | true
38 | ..\bin\Debug\
39 | DEBUG;TRACE
40 | full
41 | x86
42 | prompt
43 | false
44 |
45 |
46 | ..\bin\Release\
47 | TRACE
48 | true
49 | pdbonly
50 | x86
51 | prompt
52 | false
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
72 |
--------------------------------------------------------------------------------
/PowerpointViewerLib/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Allgemeine Informationen über eine Assembly werden über die folgenden
6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7 | // die mit einer Assembly verknüpft sind.
8 | [assembly: AssemblyTitle("PowerpointViewerLib")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("PowerpointViewerLib")]
13 | [assembly: AssemblyCopyright("")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
20 | [assembly: ComVisible(false)]
21 |
22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23 | [assembly: Guid("86fb682f-c7b4-4aad-bc59-36cca0b73b03")]
24 |
25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26 | //
27 | // Hauptversion
28 | // Nebenversion
29 | // Buildnummer
30 | // Revision
31 | //
32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
33 | // übernehmen, indem Sie "*" eingeben:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PowerpointViewerLib #
2 | ## PowerPoint Viewer 2003/2007 Controller ##
3 |
4 | This is a C# library to control Microsoft PowerPoint Viewer from any .NET application. It is based on and internally using a modified version of a C++ library (`pptviewlib.dll`) originally created by the [OpenLP](http://openlp.org/) team for use in their open source church worship presentation software.
5 |
6 | It does not (yet) work reliably with more recent versions of PowerPoint Viewer.
7 |
8 | `PowerpointViewerDemo` is demo GUI to showcase the library's capabilities.
9 |
10 | ## License ##
11 | This project is licensed under the terms of the GNU General Public License 3.
--------------------------------------------------------------------------------
/pptviewlib/README.TXT:
--------------------------------------------------------------------------------
1 |
2 | PPTVIEWLIB - Control PowerPoint Viewer 2003/2007 (for openlp.org)
3 | Copyright (C) 2008-2011 Jonathan Corwin (j@corwin.co.uk)
4 |
5 | This library wrappers the free Microsoft PowerPoint Viewer (2003/2007) program,
6 | allowing it to be more easily controlled from another program.
7 |
8 | The PowerPoint Viewer must already be installed on the destination machine, and is
9 | freely available at microsoft.com.
10 |
11 | The full Microsoft Office PowerPoint and PowerPoint Viewer 97 have a COM interface allowing
12 | automation. This ability was removed from the 2003+ viewer offerings.
13 |
14 | To developers: I am not a C/C++ or Win32 API programmer as you can probably tell.
15 | The code and API of this DLL could certainly do with some tidying up, and the
16 | error trapping, where it exists, is very basic. I'll happily accept patches!
17 |
18 | This library is covered by the GPL (http://www.gnu.org/licenses/)
19 | It is NOT covered by the LGPL, so can only be used in GPL compatable programs.
20 | (http://www.gnu.org/licenses/why-not-lgpl.html)
21 |
22 | This README.TXT must be distributed with the pptviewlib.dll
23 |
24 | This library has a limit of 50 PowerPoints which can be opened simultaneously.
25 |
26 | This project can be built with the free Microsoft Visual C++ 2008 Express Edition.
27 |
28 | USAGE
29 | -----
30 | BOOL CheckInstalled(void);
31 | Returns TRUE if PowerPointViewer is installed. FALSE if not.
32 |
33 | int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewpath);
34 |
35 | Opens the PowerPoint file, counts the number of slides, sizes and positions accordingly
36 | and creates preview images of each slide. Note PowerPoint Viewer only allows the
37 | slideshow to be resized whilst it is being loaded. It can be moved at any time however.
38 |
39 | The only way to count the number of slides is to step through the entire show. Therefore
40 | there will be a delay whilst opening large presentations for the first time.
41 | For pre XP/2003 systems, the slideshow will flicker as the screen snapshots are taken.
42 |
43 | filename: The PowerPoint file to be opened. Full path
44 | hParentWnd: The window which will become the parent of the slideshow window.
45 | Can be NULL.
46 | rect: The location/dimensions of the slideshow window.
47 | If all properties of this structure are zero, the dimensions of the hParentWnd
48 | are used.
49 | previewpath If specified, the prefix to use for snapshot images of each slide, in the
50 | form: previewpath + n + ".bmp", where n is the slide number.
51 | A file called previewpath + "info.txt" will also be created containing information
52 | about the PPT file, to speed up future openings of the unmodified file.
53 | Note it is up the calling program to directly access these images if they
54 | are required.
55 |
56 | RETURNS: An unique identifier to pass to other methods in this library.
57 | If < 0, then the PPT failed to open.
58 | If >=0, ClosePPT must be called when the PPT is no longer being used
59 | or when the calling program is closed to release resources/hooks.
60 |
61 | void ClosePPT(int id);
62 | Closes the presentation, releasing any resources and hooks.
63 |
64 | id: The value returned from OpenPPT.
65 |
66 | int GetCurrentSlide(int id);
67 | Returns the current slide number (from 1)
68 |
69 | id: The value returned from OpenPPT.
70 |
71 | int GetSlideCount(int id);
72 | Returns the total number of slides.
73 |
74 | id: The value returned from OpenPPT.
75 |
76 | void NextStep(int id);
77 | Advances one step (animation) through the slideshow.
78 |
79 | id: The value returned from OpenPPT.
80 |
81 | void PrevStep(int id);
82 | Goes backwards one step (animation) through the slideshow.
83 |
84 | id: The value returned from OpenPPT.
85 |
86 | void GotoSlide(int id, int slideno);
87 | Goes directly to a specific slide in the slideshow
88 |
89 | id: The value returned from OpenPPT.
90 | slideno: The number of the slide (from 1) to go directly to.
91 |
92 | If the slide has already been displayed, then the completed slide with animations performed
93 | will be shown. This is how the PowerPoint Viewer works so have no control over this.
94 |
95 | void RestartShow(int id);
96 | Restarts the show from the beginning. To reset animations, behind the scenes it
97 | has to travel to the end and step backwards though the entire show. Therefore
98 | for large presentations there might be a delay.
99 |
100 | id: The value returned from OpenPPT.
101 |
102 | void Blank(int id);
103 | Blanks the screen, colour black.
104 |
105 | id: The value returned from OpenPPT.
106 |
107 | void Unblank(int id)
108 | Unblanks the screen, restoring it to it's pre-blank state.
109 |
110 | id: The value returned from OpenPPT.
111 |
112 | void Stop(int id)
113 | Moves the slideshow off the screen. (There is no concept of stop show in the PowerPoint Viewer)
114 |
115 | id: The value returned from OpenPPT.
116 |
117 | void Resume(int id)
118 | Moves the slideshow display back onto the screen following a Stop()
119 |
120 | id: The value returned from OpenPPT.
121 |
122 |
--------------------------------------------------------------------------------
/pptviewlib/pptviewlib.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * PptViewLib - PowerPoint Viewer 2003/2007 Controller *
3 | * Originally part of OpenLP - Open Source Lyrics Projection *
4 | * --------------------------------------------------------------------------- *
5 | * Copyright (c) 2012-2014 Kai Patrick Reisert *
6 | * Original copyright (c) 2008-2011 Raoul Snyman *
7 | * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
8 | * Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
9 | * Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
10 | * Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
11 | * --------------------------------------------------------------------------- *
12 | * This program is free software; you can redistribute it and/or modify it *
13 | * under the terms of the GNU General Public License as published by the Free *
14 | * Software Foundation; version 2 of the License. *
15 | * *
16 | * This program is distributed in the hope that it will be useful, but WITHOUT *
17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
18 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
19 | * more details. *
20 | * *
21 | * You should have received a copy of the GNU General Public License along *
22 | * with this program; if not, write to the Free Software Foundation, Inc., 59 *
23 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA *
24 | ******************************************************************************/
25 |
26 | #define WIN32_LEAN_AND_MEAN
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include "pptviewlib.h"
37 |
38 | // Because of the callbacks used by SetWindowsHookEx, the memory used needs to
39 | // be sharable across processes (the callbacks are done from a different
40 | // process) Therefore use data_seg with RWS memory.
41 | //
42 | // See http://msdn.microsoft.com/en-us/library/aa366551(VS.85).aspx for
43 | // alternative method of holding memory, removing fixed limits which would allow
44 | // dynamic number of items, rather than a fixed number. Use a Local\ mapping,
45 | // since global has UAC issues in Vista.
46 |
47 | #pragma data_seg(".PPTVIEWLIB")
48 | PPTVIEW pptView[MAX_PPTS] = {NULL};
49 | HHOOK globalHook = NULL;
50 | BOOL debug = FALSE;
51 | #pragma data_seg()
52 | #pragma comment(linker, "/SECTION:.PPTVIEWLIB,RWS")
53 |
54 | HINSTANCE hInstance = NULL;
55 |
56 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall,
57 | LPVOID lpReserved)
58 | {
59 | hInstance = (HINSTANCE)hModule;
60 | switch(ulReasonForCall)
61 | {
62 | case DLL_PROCESS_ATTACH:
63 | DEBUG("PROCESS_ATTACH\n");
64 | break;
65 | case DLL_THREAD_ATTACH:
66 | //DEBUG("THREAD_ATTACH\n");
67 | break;
68 | case DLL_THREAD_DETACH:
69 | //DEBUG("THREAD_DETACH\n");
70 | break;
71 | case DLL_PROCESS_DETACH:
72 | // Clean up... hopefully there is only the one process attached?
73 | // We'll find out soon enough during tests!
74 | DEBUG("PROCESS_DETACH\n");
75 |
76 | break;
77 | }
78 | return TRUE;
79 | }
80 |
81 | DllExport void SetDebug(BOOL onOff)
82 | {
83 | printf("SetDebug\n");
84 | debug = onOff;
85 | DEBUG("enabled\n");
86 | }
87 |
88 | DllExport VOID Shutdown()
89 | {
90 | for (int i = 0; i < MAX_PPTS; i++)
91 | {
92 | if (pptView[i].state != PPT_CLOSED) // Why is this called when one process exits?
93 | ClosePPT(i);
94 | }
95 | }
96 |
97 | // Open the PointPoint, count the slides and take a snapshot of each slide
98 | // for use in previews
99 | // previewpath is a prefix for the location to put preview images of each slide.
100 | // ".bmp" will be appended to complete the path. E.g. "c:\temp\slide" would
101 | // create "c:\temp\slide1.bmp" slide2.bmp, slide3.bmp etc.
102 | // It will also create a *info.txt containing information about the ppt
103 | DllExport int OpenPPT(char *command, func_type callbackFunc, HWND hParentWnd, int x, int y, int width, int height)
104 | {
105 | STARTUPINFO si;
106 | PROCESS_INFORMATION pi;
107 | //char cmdLine[MAX_PATH * 2];
108 | int id;
109 |
110 | DEBUG("OpenPPT start: %s\n", command);
111 | DEBUG("OpenPPT start: %u; %i, %i, %i, %i\n", hParentWnd, x, y, width, height);
112 | /*if (GetPPTViewerPath(cmdLine, sizeof(cmdLine)) == FALSE)
113 | {
114 | DEBUG("OpenPPT: GetPPTViewerPath failed\n");
115 | return -1;
116 | }*/
117 | id = -1;
118 | for (int i = 0; i < MAX_PPTS; i++)
119 | {
120 | if (pptView[i].state == PPT_CLOSED)
121 | {
122 | id = i;
123 | break;
124 | }
125 | }
126 | if (id < 0)
127 | {
128 | DEBUG("OpenPPT: Too many PPTs\n");
129 | return -1;
130 | }
131 | memset(&pptView[id], 0, sizeof(PPTVIEW));
132 | pptView[id].callbackFunc = callbackFunc;
133 | pptView[id].locked = false;
134 | pptView[id].nextMsg = 0;
135 | pptView[id].state = PPT_CLOSED;
136 | pptView[id].slideCount = 0;
137 | pptView[id].currentSlide = 0;
138 | pptView[id].hParentWnd = hParentWnd;
139 | pptView[id].hWnd = NULL;
140 | pptView[id].hWnd2 = NULL;
141 | pptView[id].firstSlideNo = 0;
142 | if (hParentWnd != NULL && x == 0 && y == 0 && width == 0 && height == 0)
143 | {
144 | LPRECT windowRect = NULL;
145 | GetWindowRect(hParentWnd, windowRect);
146 | pptView[id].rect.top = 0;
147 | pptView[id].rect.left = 0;
148 | pptView[id].rect.bottom = windowRect->bottom - windowRect->top;
149 | pptView[id].rect.right = windowRect->right - windowRect->left;
150 | }
151 | else
152 | {
153 | pptView[id].rect.top = y;
154 | pptView[id].rect.left = x;
155 | pptView[id].rect.bottom = y + height;
156 | pptView[id].rect.right = x + width;
157 |
158 | DEBUG("width %d\n", pptView[id].rect.bottom - pptView[id].rect.top);
159 | DEBUG("height %d\n", pptView[id].rect.right - pptView[id].rect.left);
160 | }
161 | memset(&si, 0, sizeof(si));
162 | memset(&pi, 0, sizeof(pi));
163 |
164 | /*
165 | * I'd really like to just hook on the new threadid. However this always
166 | * gives error 87. Perhaps I'm hooking to soon? No idea... however can't
167 | * wait since I need to ensure I pick up the WM_CREATE as this is the only
168 | * time the window can be resized in such away the content scales correctly
169 | *
170 | * hook = SetWindowsHookEx(WH_CBT,CbtProc,hInstance,pi.dwThreadId);
171 | */
172 | if (globalHook != NULL)
173 | {
174 | UnhookWindowsHookEx(globalHook);
175 | }
176 | globalHook = SetWindowsHookEx(WH_CBT, CbtProc, hInstance, NULL);
177 | if (globalHook == 0)
178 | {
179 | DEBUG("OpenPPT: SetWindowsHookEx failed\n");
180 | ClosePPT(id, true);
181 | return -1;
182 | }
183 | pptView[id].state = PPT_STARTED;
184 | Sleep(10);
185 | if (!CreateProcess(NULL, command, NULL, NULL, FALSE, 0, 0, NULL, &si, &pi))
186 | {
187 | DEBUG("OpenPPT: CreateProcess failed: %s\n", command);
188 | ClosePPT(id, true);
189 | return -1;
190 | }
191 | pptView[id].dwProcessId = pi.dwProcessId;
192 | pptView[id].dwThreadId = pi.dwThreadId;
193 | pptView[id].hThread = pi.hThread;
194 | pptView[id].hProcess = pi.hProcess;
195 |
196 | pptView[id].listenerThread = CreateThread(NULL, 0, ProcessCallbackMessages, &id, 0, NULL);
197 |
198 | DEBUG("Listener thread for %d: %d\n", id, pptView[id].listenerThread);
199 |
200 | while (pptView[id].state == PPT_STARTED)
201 | {
202 | Sleep(10);
203 | DWORD exitCode;
204 | if(!GetExitCodeProcess(pi.hProcess, &exitCode) || exitCode == 0)
205 | {
206 | return -1;
207 | }
208 | }
209 |
210 | pptView[id].steps = 0;
211 | int steps = 0;
212 | while (pptView[id].state == PPT_OPENED)
213 | {
214 | if (steps <= pptView[id].steps)
215 | {
216 | Sleep(20);
217 | DEBUG("OpenPPT: Step %d/%d\n", steps, pptView[id].steps);
218 | steps++;
219 | InternalNextStep(id);
220 | }
221 | Sleep(10);
222 | }
223 |
224 | if (pptView[id].state == PPT_CLOSING
225 | || pptView[id].slideCount <= 0)
226 | {
227 | ClosePPT(id);
228 | id=-1;
229 | }
230 |
231 | if (id >= 0)
232 | {
233 | if (pptView[id].msgHook != NULL)
234 | {
235 | UnhookWindowsHookEx(pptView[id].msgHook);
236 | }
237 | pptView[id].msgHook = NULL;
238 | }
239 |
240 | DEBUG("OpenPPT: Exit: id=%i\n", id);
241 | return id;
242 | }
243 |
244 | // Unhook the Windows hook
245 | void Unhook(int id)
246 | {
247 | DEBUG("Unhook: start %d\n", id);
248 | if (pptView[id].hook != NULL)
249 | {
250 | UnhookWindowsHookEx(pptView[id].hook);
251 | }
252 | if (pptView[id].msgHook != NULL)
253 | {
254 | UnhookWindowsHookEx(pptView[id].msgHook);
255 | }
256 | pptView[id].hook = NULL;
257 | pptView[id].msgHook = NULL;
258 | DEBUG("Unhook: exit ok\n");
259 | }
260 |
261 | void ClosePPT(int id, bool force)
262 | {
263 | DEBUG("ClosePPT: start%d\n", id);
264 | if (!force)
265 | {
266 | SendCallback(id, 6, 0);
267 | pptView[id].state = PPT_CLOSED;
268 | }
269 | Unhook(id);
270 | if (force || pptView[id].hWnd == 0)
271 | {
272 | TerminateThread(pptView[id].hThread, 0);
273 | }
274 | else
275 | {
276 | PostMessage(pptView[id].hWnd, WM_CLOSE, 0, 0);
277 | }
278 |
279 | Sleep(100);
280 |
281 | TerminateThread(pptView[id].listenerThread, 0);
282 | CloseHandle(pptView[id].listenerThread);
283 | if (force && pptView[id].hProcess != NULL)
284 | {
285 | TerminateProcess(pptView[id].hProcess, 0);
286 | }
287 | CloseHandle(pptView[id].hThread);
288 | CloseHandle(pptView[id].hProcess);
289 | memset(&pptView[id], 0, sizeof(PPTVIEW));
290 | DEBUG("ClosePPT: exit ok\n");
291 | return;
292 | }
293 |
294 | // Close the PowerPoint viewer, release resources
295 | DllExport void ClosePPT(int id)
296 | {
297 | ClosePPT(id, false);
298 | }
299 |
300 | // Take a step forwards through the show
301 | void InternalNextStep(int id)
302 | {
303 | DEBUG("NextStep:%d (%d)\n", id, pptView[id].currentSlide);
304 | if (pptView[id].currentSlide > pptView[id].slideCount) return;
305 | PostMessage(pptView[id].hWnd2, WM_MOUSEWHEEL, MAKEWPARAM(0, -WHEEL_DELTA),
306 | 0);
307 | }
308 |
309 | DWORD WINAPI ProcessCallbackMessages( LPVOID lpParam )
310 | {
311 | int id = *((int*)lpParam);
312 |
313 | while (pptView[id].state != PPT_CLOSED)
314 | {
315 | if (pptView[id].locked)
316 | {
317 | DEBUG("waiting for lock\n");
318 | }
319 | else if(pptView[id].nextMsg > 0)
320 | {
321 | // TODO: some kind of locking
322 | pptView[id].locked = true;
323 | DEBUG("Sending callback %d\n", pptView[id].nextMsg);
324 | pptView[id].callbackFunc(pptView[id].nextMsg, pptView[id].nextMsgParam);
325 | DEBUG("Sent callback %d\n", pptView[id].nextMsg);
326 | pptView[id].nextMsg = 0;
327 | pptView[id].locked = false;
328 | }
329 | Sleep(10);
330 | }
331 |
332 | Sleep(50);
333 |
334 | if (pptView[id].locked)
335 | {
336 | DEBUG("waiting for lock\n");
337 | }
338 | else if(pptView[id].nextMsg > 0)
339 | {
340 | pptView[id].locked = true;
341 | DEBUG("Sending callback to %d (after) %d\n", id, pptView[id].nextMsg);
342 | pptView[id].callbackFunc(pptView[id].nextMsg, pptView[id].nextMsgParam);
343 | DEBUG("Sent callback to %d (after) %d\n", id, pptView[id].nextMsg);
344 | pptView[id].nextMsg = 0;
345 | pptView[id].locked = false;
346 | }
347 |
348 | return 0;
349 | }
350 |
351 | // This hook is started with the PPTVIEW.EXE process and waits for the
352 | // WM_CREATEWND message. At this point (and only this point) can the
353 | // window be resized to the correct size.
354 | // Release the hook as soon as we're complete to free up resources
355 | LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam)
356 | {
357 | HHOOK hook = globalHook;
358 | if (nCode == HCBT_CREATEWND)
359 | {
360 | char csClassName[16];
361 | HWND hCurrWnd = (HWND)wParam;
362 | DWORD retProcId = NULL;
363 | GetClassName(hCurrWnd, csClassName, sizeof(csClassName));
364 | if ((strcmp(csClassName, "paneClassDC") == 0)
365 | ||(strcmp(csClassName, "screenClass") == 0))
366 | {
367 | int id = -1;
368 | DWORD windowThread = GetWindowThreadProcessId(hCurrWnd, NULL);
369 | for (int i=0; i < MAX_PPTS; i++)
370 | {
371 | if (pptView[i].dwThreadId == windowThread)
372 | {
373 | id = i;
374 | break;
375 | }
376 | }
377 | if (id >= 0)
378 | {
379 | if (strcmp(csClassName, "paneClassDC") == 0)
380 | {
381 | pptView[id].hWnd2 = hCurrWnd;
382 | }
383 | else
384 | {
385 | pptView[id].hWnd = hCurrWnd;
386 |
387 | CBT_CREATEWND* cw = (CBT_CREATEWND*)lParam;
388 | if (pptView[id].hParentWnd != NULL)
389 | {
390 | cw->lpcs->hwndParent = pptView[id].hParentWnd;
391 | }
392 | cw->lpcs->cy = pptView[id].rect.bottom
393 | - pptView[id].rect.top;
394 | cw->lpcs->cx = pptView[id].rect.right
395 | - pptView[id].rect.left;
396 | cw->lpcs->y = -32000;
397 | cw->lpcs->x = -32000;
398 | }
399 | if ((pptView[id].hWnd != NULL) && (pptView[id].hWnd2 != NULL))
400 | {
401 | UnhookWindowsHookEx(globalHook);
402 | globalHook = NULL;
403 | pptView[id].hook = SetWindowsHookEx(WH_CALLWNDPROC,
404 | CwpProc, hInstance, pptView[id].dwThreadId);
405 | pptView[id].msgHook = SetWindowsHookEx(WH_GETMESSAGE,
406 | GetMsgProc, hInstance, pptView[id].dwThreadId);
407 | Sleep(10);
408 | pptView[id].state = PPT_OPENED;
409 | SendCallback(id, 1, (int)pptView[id].hWnd);
410 | SendCallback(id, 2, (int)pptView[id].hWnd2);
411 | }
412 | }
413 | }
414 | }
415 | return CallNextHookEx(hook, nCode, wParam, lParam);
416 | }
417 |
418 | // This hook exists whilst the slideshow is loading but only listens on the
419 | // slideshows thread. It listens out for mousewheel events
420 | LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
421 | {
422 | HHOOK hook = NULL;
423 | MSG *pMSG = (MSG *)lParam;
424 | DWORD windowThread = GetWindowThreadProcessId(pMSG->hwnd, NULL);
425 | int id = -1;
426 | for (int i = 0; i < MAX_PPTS; i++)
427 | {
428 | if (pptView[i].dwThreadId == windowThread)
429 | {
430 | id = i;
431 | hook = pptView[id].msgHook;
432 | break;
433 | }
434 | }
435 | if (id >= 0 && nCode == HC_ACTION && wParam == PM_REMOVE
436 | && pMSG->message == WM_MOUSEWHEEL)
437 | {
438 | SendCallback(id, 3, 0);
439 | if (pptView[id].state != PPT_LOADED)
440 | {
441 | pptView[id].steps++;
442 | }
443 | }
444 | return CallNextHookEx(hook, nCode, wParam, lParam);
445 | }
446 | // This hook exists whilst the slideshow is running but only listens on the
447 | // slideshows thread. It listens out for slide changes, message WM_USER+22.
448 | LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam){
449 | CWPSTRUCT *cwp;
450 | cwp = (CWPSTRUCT *)lParam;
451 | HHOOK hook = NULL;
452 |
453 | DWORD windowThread = GetWindowThreadProcessId(cwp->hwnd, NULL);
454 | int id = -1;
455 | for (int i = 0; i < MAX_PPTS; i++)
456 | {
457 | if (pptView[i].dwThreadId == windowThread)
458 | {
459 | id = i;
460 | hook = pptView[id].hook;
461 | break;
462 | }
463 | }
464 | if ((id >= 0) && (nCode == HC_ACTION))
465 | {
466 | if (cwp->message == WM_USER + 22)
467 | {
468 | SendCallback(id, 4, cwp->wParam);
469 |
470 | if (pptView[id].state != PPT_LOADED)
471 | {
472 | if (((cwp->wParam == 0)
473 | || (pptView[id].firstSlideNo == cwp->wParam))
474 | && (pptView[id].currentSlide > 0))
475 | {
476 | pptView[id].state = PPT_LOADED;
477 | pptView[id].currentSlide = pptView[id].slideCount + 1;
478 | }
479 | else
480 | {
481 | if (cwp->wParam > 0)
482 | {
483 | pptView[id].currentSlide = pptView[id].currentSlide + 1;
484 | if (pptView[id].currentSlide == 1)
485 | pptView[id].firstSlideNo = cwp->wParam;
486 | pptView[id].slideCount = pptView[id].currentSlide;
487 | }
488 | }
489 | }
490 | }
491 | if ((pptView[id].state != PPT_CLOSED)
492 | &&(cwp->message == WM_CLOSE || cwp->message == WM_QUIT))
493 | {
494 | pptView[id].state = PPT_CLOSING;
495 | SendCallback(id, 5, 0);
496 | }
497 | }
498 | return CallNextHookEx(hook, nCode, wParam, lParam);
499 | }
500 |
501 | VOID SendCallback(int id, int msg, int param)
502 | {
503 | while(pptView[id].locked || pptView[id].nextMsg != 0)
504 | {
505 | Sleep(15);
506 | }
507 |
508 | pptView[id].locked = true;
509 | pptView[id].nextMsg = msg;
510 | pptView[id].nextMsgParam = param;
511 | pptView[id].locked = false;
512 | }
513 |
--------------------------------------------------------------------------------
/pptviewlib/pptviewlib.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Boddlnagg/PowerpointViewerLib/53ac32b5a9a0d01105a9399d7faec5588028abe5/pptviewlib/pptviewlib.dll
--------------------------------------------------------------------------------
/pptviewlib/pptviewlib.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * PptViewLib - PowerPoint Viewer 2003/2007 Controller *
3 | * Originally part of OpenLP - Open Source Lyrics Projection *
4 | * --------------------------------------------------------------------------- *
5 | * Copyright (c) 2012-2014 Kai Patrick Reisert *
6 | * Original copyright (c) 2008-2011 Raoul Snyman *
7 | * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
8 | * Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
9 | * Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
10 | * Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
11 | * --------------------------------------------------------------------------- *
12 | * This program is free software; you can redistribute it and/or modify it *
13 | * under the terms of the GNU General Public License as published by the Free *
14 | * Software Foundation; version 2 of the License. *
15 | * *
16 | * This program is distributed in the hope that it will be useful, but WITHOUT *
17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
18 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
19 | * more details. *
20 | * *
21 | * You should have received a copy of the GNU General Public License along *
22 | * with this program; if not, write to the Free Software Foundation, Inc., 59 *
23 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA *
24 | ******************************************************************************/
25 |
26 | #define DllExport extern "C" __declspec( dllexport )
27 |
28 | #define DEBUG(...) if (debug) printf(__VA_ARGS__)
29 |
30 | typedef int (__cdecl *func_type)(int msg, int param);
31 |
32 | enum PPTVIEWSTATE {PPT_CLOSED, PPT_STARTED, PPT_OPENED, PPT_LOADED,
33 | PPT_CLOSING};
34 |
35 | DllExport int OpenPPT(char *command, func_type callbackFunc, HWND hParentWnd, int x, int y, int width, int height);
36 | DllExport void ClosePPT(int id);
37 | DllExport void SetDebug(BOOL onOff);
38 | DllExport void Shutdown();
39 |
40 | LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam);
41 | LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
42 | LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
43 | DWORD WINAPI ProcessCallbackMessages( LPVOID lpParam );
44 |
45 | void Unhook(int id);
46 | VOID SendCallback(int id, int msg, int param);
47 | void InternalNextStep(int id);
48 | void ClosePPT(int id, bool force);
49 |
50 | #define MAX_PPTS 16
51 | #define MAX_SLIDES 256
52 |
53 | struct PPTVIEW
54 | {
55 | HHOOK hook;
56 | HHOOK msgHook;
57 | HWND hWnd;
58 | HWND hWnd2;
59 | HWND hParentWnd;
60 | HANDLE hProcess;
61 | HANDLE hThread;
62 | DWORD dwProcessId;
63 | DWORD dwThreadId;
64 | RECT rect;
65 | int slideCount;
66 | int currentSlide;
67 | int steps;
68 | int firstSlideNo;
69 | func_type callbackFunc;
70 | bool locked;
71 | HANDLE listenerThread;
72 | int nextMsg;
73 | int nextMsgParam;
74 | PPTVIEWSTATE state;
75 | };
76 |
--------------------------------------------------------------------------------
/pptviewlib/pptviewlib.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {04CC20D1-DC5A-4189-8181-4011E3C21DCF}
15 | pptviewlib
16 | Win32Proj
17 |
18 |
19 |
20 | DynamicLibrary
21 | MultiByte
22 | true
23 | v110
24 |
25 |
26 | DynamicLibrary
27 | MultiByte
28 | v110
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | <_ProjectFileVersion>10.0.30319.1
42 | $(SolutionDir)bin\$(Configuration)\
43 | $(Configuration)\
44 | true
45 | $(SolutionDir)bin\$(Configuration)\
46 | $(Configuration)\
47 | false
48 |
49 |
50 |
51 | Disabled
52 | WIN32;_DEBUG;_WINDOWS;_USRDLL;PPTVIEWLIB_EXPORTS;%(PreprocessorDefinitions)
53 | true
54 | EnableFastChecks
55 | MultiThreadedDebugDLL
56 |
57 |
58 | Level3
59 | EditAndContinue
60 |
61 |
62 |
63 |
64 | true
65 | Windows
66 | MachineX86
67 |
68 |
69 |
70 |
71 | MaxSpeed
72 | true
73 | WIN32;NDEBUG;_WINDOWS;_USRDLL;PPTVIEWLIB_EXPORTS;%(PreprocessorDefinitions)
74 | MultiThreadedDLL
75 | true
76 |
77 |
78 | Level3
79 | ProgramDatabase
80 |
81 |
82 | true
83 | Windows
84 | true
85 | true
86 | MachineX86
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/pptviewlib/pptviewlib.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
20 | Header Files
21 |
22 |
23 |
--------------------------------------------------------------------------------