Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
716 | lvd | 1 | #include "std.h" |
2 | |||
3 | #include "emul.h" |
||
4 | #include "vars.h" |
||
5 | #include "draw.h" |
||
6 | |||
7 | #include "util.h" |
||
8 | |||
9 | HMODULE hMSHTML = 0, hURLMON = 0; |
||
10 | |||
11 | |||
12 | typedef HRESULT (WINAPI *tCreateURLMoniker)(IMoniker*,WCHAR*,IMoniker**); |
||
13 | typedef HRESULT (WINAPI *tShowHTMLDialog)(HWND,IMoniker*,VARIANT*,WCHAR*,VARIANT*); |
||
14 | |||
15 | void init_ie_help() { } |
||
16 | |||
17 | void done_ie_help() |
||
18 | { |
||
19 | if (hMSHTML) FreeLibrary(hMSHTML), hMSHTML = 0; |
||
20 | if (hURLMON) FreeLibrary(hURLMON), hURLMON = 0; |
||
21 | } |
||
22 | |||
23 | void showhelppp(const char *anchor = 0) //Alone Coder 0.36.6 |
||
24 | { |
||
25 | if (!hMSHTML) hMSHTML = LoadLibrary("MSHTML.DLL"); |
||
26 | if (!hURLMON) hURLMON = LoadLibrary("URLMON.DLL"); |
||
27 | |||
28 | tShowHTMLDialog Show = hMSHTML? (tShowHTMLDialog)GetProcAddress(hMSHTML, "ShowHTMLDialog") : 0; |
||
29 | tCreateURLMoniker CreateMoniker = hURLMON? (tCreateURLMoniker)GetProcAddress(hURLMON, "CreateURLMoniker") : 0; |
||
30 | |||
31 | HWND fgwin = GetForegroundWindow(); |
||
32 | if (!Show || !CreateMoniker) |
||
33 | { MessageBox(fgwin, "Install IE4.0 or higher to view help", 0, MB_ICONERROR); return; } |
||
34 | |||
35 | char dst[0x200]; |
||
36 | GetTempPath(sizeof dst, dst); strcat(dst, "us_help.htm"); |
||
37 | |||
38 | FILE *ff = fopen(helpname, "rb"), *gg = fopen(dst, "wb"); |
||
39 | if (!ff || !gg) return; |
||
40 | |||
41 | for (;;) |
||
42 | { |
||
43 | int x = getc(ff); |
||
44 | if (x == EOF) break; |
||
45 | if (x == '{') |
||
46 | { |
||
47 | char tag[0x100]; int r = 0; |
||
48 | while (r < sizeof(tag)-1 && !feof(ff) && (x = getc(ff)) != '}') |
||
49 | tag[r++] = x; |
||
50 | tag[r] = 0; |
||
51 | if (tag[0] == '?') |
||
52 | { |
||
53 | RECT rc; |
||
54 | GetWindowRect(fgwin, &rc); |
||
55 | if (tag[1] == 'x') |
||
56 | fprintf(gg, "%ld", rc.right-rc.left-20); |
||
57 | if (tag[1] == 'y') |
||
58 | fprintf(gg, "%ld", rc.bottom-rc.top-20); |
||
59 | } |
||
60 | else |
||
61 | { |
||
62 | char res[0x100]; GetPrivateProfileString("SYSTEM.KEYS", tag, "not defined", res, sizeof res, ininame); |
||
63 | char *comment = strchr(res, ';'); if (comment) *comment = 0; |
||
64 | int len; //Alone Coder 0.36.7 |
||
65 | for (/*int*/ len = strlen(res); len && res[len-1] == ' '; res[--len] = 0); |
||
66 | for (len = 0; res[len]; len++) if (res[len] == ' ') res[len] = '-'; |
||
67 | fprintf(gg, "%s", res); |
||
68 | } |
||
69 | } else putc(x, gg); |
||
70 | } |
||
71 | fclose(ff), fclose(gg); |
||
72 | |||
73 | char url[0x200]; |
||
74 | sprintf(url, "file://%s%s%s", dst, anchor?"#":nil, anchor?anchor:nil); |
||
75 | WCHAR urlw[0x200]; |
||
76 | MultiByteToWideChar(AreFileApisANSI()? CP_ACP : CP_OEMCP, MB_USEGLYPHCHARS, url, -1, urlw, _countof(urlw)); |
||
77 | IMoniker *pmk = 0; |
||
78 | CreateMoniker(0, urlw, &pmk); |
||
79 | |||
80 | if (pmk) |
||
81 | { |
||
82 | bool restore_video = false; |
||
83 | if(!(temp.rflags & (RF_GDI | RF_CLIP | RF_OVR | RF_16 | RF_32))) |
||
84 | { |
||
85 | temp.rflags = temp.rflags | RF_GDI; |
||
86 | set_video(); |
||
87 | restore_video = true; |
||
88 | } |
||
89 | Show(fgwin, pmk, 0,0,0); |
||
90 | pmk->Release(); |
||
91 | |||
92 | if(dbgbreak) |
||
93 | { |
||
94 | temp.rflags = RF_MONITOR; |
||
95 | set_video(); |
||
96 | } |
||
97 | else |
||
98 | { |
||
99 | if(restore_video) |
||
100 | apply_video(); |
||
101 | } |
||
102 | } |
||
103 | |||
104 | DeleteFile(dst); |
||
105 | } |
||
106 |