📄 prreadgpldialog.cpp
字号:
/* * * prreadgpldialog.cpp * Copyright (C) 2006 Michael H. Overlin This program 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. This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact at poster_printer@yahoo.com * */#include "prreadgpldialog.h"#include "mathutils.h"#include "prreadgpldialog_rc.h"#include "prutils.h"#include "types.h"//#include "C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\richedit.h"#define EM_SETTEXTEX (WM_USER + 97)typedef struct _settextex{ DWORD flags; UINT codepage; } SETTEXTEX;#define ST_DEFAULT 0#define LICENCE_SIDEMARGINS_PIXELS 12ReadGPLDialog::ReadGPLDialog(HINSTANCE hinst, LPTSTR lptstrGPL_RTF, BOOL bRequireReadToEnd) : DialogWindow(hinst, IDD_DIALOG_LICENSE) { m_lptstrGPL_RTF = lptstrGPL_RTF; m_bRequireReadToEnd = bRequireReadToEnd;}ReadGPLDialog::~ReadGPLDialog() { // NOTHING TO DELETE}BOOL ReadGPLDialog::InitMsg(WPARAM wParam, LPARAM lParam) { DialogWindow::InitMsg(wParam, lParam); BOOL bRetValue = FALSE; this->CenterWindowAboveParent(); if (!m_bRequireReadToEnd) { HWND hwndCancel = this->GetDlgItem(IDC_BUTTON_CANCEL_GPL); ::ShowWindow(hwndCancel, SW_HIDE); HWND hwndOK = this->GetDlgItem(IDC_BUTTON_OK_GPL); ::CenterWindowHorizontallyInDialog(hwndOK, this->hdlg()); } { tstring tstrTitle; ::ComposeDialogTitle(PrintResizerComponents::eInstaller, tstrTitle, TEXT("License Agreement")); this->SetWindowText(tstrTitle.c_str()); } // 7/12 //HINSTANCE hInst = this->hinst(); //HRSRC hResInfo = ::FindResource(hInst, MAKEINTRESOURCE(IDF_PRINTRESIZER_DATAFILE), MAKEINTRESOURCE(RC_BINARYTYPE)); //if (hResInfo != NULL) { // HGLOBAL hgRes = ::LoadResource(hInst, hResInfo); // if (hgRes != NULL) { // void *pvRes = ::LockResource(hgRes); // if (pvRes != NULL) { // //DWORD dwcRes = ::SizeofResource(hInst, hResInfo); void *pvRes = (void *) m_lptstrGPL_RTF; ::SETTEXTEX settext; settext.flags = ST_DEFAULT; settext.codepage = 1200; // UNICODE, NO TRANSLATION TO UNICODE IS PERFORMED this->SendDlgItemMessage(IDC_RICHEDIT_GPL, EM_SETTEXTEX, (WPARAM) &settext, (LPARAM) pvRes); //this->SendDlgItemMessage(IDC_RICHEDIT_GPL, EM_SETMARGINS, (WPARAM) EC_USEFONTINFO, 0); this->SendDlgItemMessage(IDC_RICHEDIT_GPL, EM_SETMARGINS, (WPARAM) ( EC_LEFTMARGIN | EC_RIGHTMARGIN ), (LPARAM) MAKELPARAM(LICENCE_SIDEMARGINS_PIXELS,LICENCE_SIDEMARGINS_PIXELS) ); bRetValue = TRUE; // UnlockResource(hgRes); // } // ::FreeResource(hgRes); // } //} return TRUE;}BOOL ReadGPLDialog::CommandMsg(WPARAM wParam, LPARAM lParam) { WORD wID = LOWORD(wParam); switch(wID) { case IDC_BUTTON_OK_GPL: if (this->m_bRequireReadToEnd) { HWND hwndRE = this->GetDlgItem(IDC_RICHEDIT_GPL); RECT r; ::GetClientRect(hwndRE, &r); POINTL pt = { RW(r), RH(r) }; LRESULT lresChar = ::SendMessage(hwndRE, EM_CHARFROMPOS, 0, (LPARAM) &pt); LRESULT lresLength = ::SendMessage(hwndRE, WM_GETTEXTLENGTH, 0, 0); if (lresChar >= lresLength) { this->EndDialog(ReadGPLDialog::eUserOK); } else { ::ErrorMessage(::PrintResizerComponents::eInstaller, this->hdlg(), TEXT("Please scroll the license text all the way to the bottom to read it, and then press OK.")); } } else { this->EndDialog(ReadGPLDialog::eUserOK); } break; case IDC_BUTTON_CANCEL_GPL: this->EndDialog(ReadGPLDialog::eUserCancelInstallation); break; default: break; } return TRUE;}BOOL ReadGPLDialog::NotificationMsg(UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: this->PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_OK_GPL, 0), 0); break; default: break; } return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -