/* * $Id$ * Copyright © 2007-2020 gingko - https://www.gingko.ovh/ * * This file is part of Pouchin TV Mod, a free DVB-T viewer. * See https://www.pouchintv.fr/ for updates. * * Pouchin TV Mod is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Pouchin TV Mod is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * * Most files of this project have been changed from the Pouchin TV * project (Copyright © 2006 Pouchin ), * to use with a modified version of this software. * See http://pouchinteve.free.fr/ for the original project. */ #include "stdafx.h" #include "helpdlg.h" #include #if LZMA_HELP #include "lzma.h" #endif // ==================================================================================== /// Extraction et décompression de la ressource d'aide bool CHelpDialogBase::ResReader::Extraction(UINT idRessource) { #if LZMA_HELP RawResource vCompressed; if (!vCompressed.Extraction(NULL, idRessource)) return false; if (!DecompressLzma(*this, vCompressed)) return false; // -> Décompression impossible #else if (!__super::Extraction(NULL, idRessource)) return false; #endif sMm = MemRng(&*begin(), (UINT)size()); return true; }; // ==================================================================================== CHelpDialogBase::HelpTEMPLATE CHelpDialogBase::sDlgTmpl = { { 1, // dlgVer 0xffff, // signature 0, // helpID 0, // exStyle DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, // style 2, // cDlgItems 0, 0, // x, y 500,300, // cx, cy 0, // menu 0, // windowClass #if defined(LANG) && LANG==LANG_FR L"Aide", // title #else L"Help", // title #endif 8, 400, // pointsize, weight 0, 0x1, // italic, charset L"MS Shell Dlg" // typeface }, { 0, // helpID 0, // exStyle ES_MULTILINE | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_TABSTOP | WS_CHILD | WS_VISIBLE, // style 4,4, // x, y 492,274, // cx, cy eIDC_HELPTEXT, // id L"RichEdit20A", // windowClass 0, // title 0 // extraCount }, { 0, // helpID 0, // exStyle BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD | WS_VISIBLE, // style 224,282, // x, y 50,14, // cx, cy IDOK, // id {0xffff,swc_Button}, // windowClass L"OK", // title 0 // extraCount } }; DWORD CHelpDialogBase::ResReader::ESCallback(LPBYTE pbBuff, LONG cb, LONG *pcb) { LONG nLen = min(cb, sMm.siz); if (nLen > 0) { memcpy(pbBuff, sMm.ptr, nLen); *pcb = nLen; sMm += nLen; } return 0; } /// Traitement des messages de la boîte de dialogue INT_PTR CHelpDialogBase::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { static ResizingItemTpl asResizingTemplate[] = { {eIDC_HELPTEXT, ANCHOR_FULL_FULL}, {IDOK, ANCHOR_BOTTOM_CENTER} }; // Initialisation de la fenêtre SetWindowText(hDlg, strDlgTitle.c_str()); hRtfCtl = GetItem(eIDC_HELPTEXT); WinSubClass::SubClass(hRtfCtl); ResReader sResRdr; if (sResRdr.Extraction(idRtfResource)) { EDITSTREAM sEs = {(DWORD_PTR)&sResRdr, 0, sResRdr.ESCallback}; SendMessage(hRtfCtl, EM_STREAMIN, SF_RTF, (LPARAM)&sEs); } cResizingHelper.Init(hDlg, asResizingTemplate, MkSIZE(400, 180)); return TRUE; } case WM_GETMINMAXINFO: return cResizingHelper.Process_WM_GETMINMAXINFO(lParam); case WM_SIZE: cResizingHelper.Process_WM_SIZE(lParam); return TRUE; case WM_CLOSE: DestroyWindow(hDlg); return TRUE; case WM_COMMAND: // Commande reçue (clic, etc...) switch(wParam) { case eIDC_HELPTEXT: wParam = wParam; EN_CHANGE; break; case _cmd_(IDOK, BN_CLICKED): // Clic sur le bouton OK DestroyWindow(hDlg); return TRUE; } } // Autre message, traité par Windows return FALSE; } // ====================================================================================