Standard tabing
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2675 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
a4723522cf
commit
973a61fbcf
4 changed files with 1026 additions and 1026 deletions
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2002 Amir Szekely <kichik@netvision.net.il>
|
Copyright (C) 2002 Amir Szekely <kichik@netvision.net.il>
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
appreciated but is not required.
|
appreciated but is not required.
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DialogTemplate.h"
|
#include "DialogTemplate.h"
|
||||||
|
@ -30,49 +30,49 @@
|
||||||
|
|
||||||
// returns the number of WCHARs in str including null charcter
|
// returns the number of WCHARs in str including null charcter
|
||||||
inline DWORD WCStrLen(WCHAR* szwStr) {
|
inline DWORD WCStrLen(WCHAR* szwStr) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; szwStr[i]; i++);
|
for (i = 0; szwStr[i]; i++);
|
||||||
return i+1;
|
return i+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads a variany length array from seeker into readInto and advances seeker
|
// Reads a variany length array from seeker into readInto and advances seeker
|
||||||
void ReadVarLenArr(BYTE* &seeker, char* &readInto, unsigned int uCodePage) {
|
void ReadVarLenArr(BYTE* &seeker, char* &readInto, unsigned int uCodePage) {
|
||||||
WORD* arr = (WORD*)seeker;
|
WORD* arr = (WORD*)seeker;
|
||||||
switch (arr[0]) {
|
switch (arr[0]) {
|
||||||
case 0x0000:
|
case 0x0000:
|
||||||
readInto = 0;
|
readInto = 0;
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
break;
|
break;
|
||||||
case 0xFFFF:
|
case 0xFFFF:
|
||||||
readInto = MAKEINTRESOURCE(arr[1]);
|
readInto = MAKEINTRESOURCE(arr[1]);
|
||||||
seeker += 2*sizeof(WORD);
|
seeker += 2*sizeof(WORD);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
int iStrLen = WideCharToMultiByte(uCodePage, 0, (WCHAR*)arr, -1, 0, 0, 0, 0);
|
int iStrLen = WideCharToMultiByte(uCodePage, 0, (WCHAR*)arr, -1, 0, 0, 0, 0);
|
||||||
readInto = new char[iStrLen];
|
readInto = new char[iStrLen];
|
||||||
WideCharToMultiByte(uCodePage, 0, (WCHAR*)arr, -1, readInto, iStrLen, 0, 0);
|
WideCharToMultiByte(uCodePage, 0, (WCHAR*)arr, -1, readInto, iStrLen, 0, 0);
|
||||||
seeker += WCStrLen((WCHAR*)arr)*sizeof(WCHAR);
|
seeker += WCStrLen((WCHAR*)arr)*sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A macro that writes a given string (that can be a number too) into the buffer
|
// A macro that writes a given string (that can be a number too) into the buffer
|
||||||
#define WriteStringOrId(x) \
|
#define WriteStringOrId(x) \
|
||||||
if (x) \
|
if (x) \
|
||||||
if (IS_INTRESOURCE(x)) { \
|
if (IS_INTRESOURCE(x)) { \
|
||||||
*(WORD*)seeker = 0xFFFF; \
|
*(WORD*)seeker = 0xFFFF; \
|
||||||
seeker += sizeof(WORD); \
|
seeker += sizeof(WORD); \
|
||||||
*(WORD*)seeker = WORD(x); \
|
*(WORD*)seeker = WORD(x); \
|
||||||
seeker += sizeof(WORD); \
|
seeker += sizeof(WORD); \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
int us = MultiByteToWideChar(m_uCodePage, 0, x, -1, (WCHAR*)seeker, dwSize); \
|
int us = MultiByteToWideChar(m_uCodePage, 0, x, -1, (WCHAR*)seeker, dwSize); \
|
||||||
seeker += us*sizeof(WCHAR); \
|
seeker += us*sizeof(WCHAR); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
|
|
||||||
// A macro that adds the size of x (which can be a string a number, or nothing) to dwSize
|
// A macro that adds the size of x (which can be a string a number, or nothing) to dwSize
|
||||||
#define AddStringOrIdSize(x) dwSize += x ? (IS_INTRESOURCE(x) ? sizeof(DWORD) : (lstrlen(x)+1)*sizeof(WCHAR)) : sizeof(WORD)
|
#define AddStringOrIdSize(x) dwSize += x ? (IS_INTRESOURCE(x) ? sizeof(DWORD) : (lstrlen(x)+1)*sizeof(WCHAR)) : sizeof(WORD)
|
||||||
|
@ -84,142 +84,142 @@ void ReadVarLenArr(BYTE* &seeker, char* &readInto, unsigned int uCodePage) {
|
||||||
CDialogTemplate::CDialogTemplate(BYTE* pbData, unsigned int uCodePage) {
|
CDialogTemplate::CDialogTemplate(BYTE* pbData, unsigned int uCodePage) {
|
||||||
m_uCodePage = uCodePage;
|
m_uCodePage = uCodePage;
|
||||||
|
|
||||||
m_szClass = 0;
|
m_szClass = 0;
|
||||||
m_szFont = 0;
|
m_szFont = 0;
|
||||||
m_szMenu = 0;
|
m_szMenu = 0;
|
||||||
m_szTitle = 0;
|
m_szTitle = 0;
|
||||||
|
|
||||||
WORD wItems = 0;
|
WORD wItems = 0;
|
||||||
|
|
||||||
if (*(DWORD*)pbData == 0xFFFF0001) { // Extended dialog template signature
|
if (*(DWORD*)pbData == 0xFFFF0001) { // Extended dialog template signature
|
||||||
m_bExtended = true;
|
m_bExtended = true;
|
||||||
|
|
||||||
DLGTEMPLATEEX* dTemplateEx = (DLGTEMPLATEEX*)pbData;
|
DLGTEMPLATEEX* dTemplateEx = (DLGTEMPLATEEX*)pbData;
|
||||||
|
|
||||||
m_dwHelpId = dTemplateEx->helpID;
|
m_dwHelpId = dTemplateEx->helpID;
|
||||||
m_dwStyle = dTemplateEx->style;
|
m_dwStyle = dTemplateEx->style;
|
||||||
m_dwExtStyle = dTemplateEx->exStyle;
|
m_dwExtStyle = dTemplateEx->exStyle;
|
||||||
m_sX = dTemplateEx->x;
|
m_sX = dTemplateEx->x;
|
||||||
m_sY = dTemplateEx->y;
|
m_sY = dTemplateEx->y;
|
||||||
m_sWidth = dTemplateEx->cx;
|
m_sWidth = dTemplateEx->cx;
|
||||||
m_sHeight = dTemplateEx->cy;
|
m_sHeight = dTemplateEx->cy;
|
||||||
|
|
||||||
wItems = dTemplateEx->cDlgItems;
|
wItems = dTemplateEx->cDlgItems;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_bExtended = false;
|
m_bExtended = false;
|
||||||
DLGTEMPLATE* dTemplate = (DLGTEMPLATE*)pbData;
|
DLGTEMPLATE* dTemplate = (DLGTEMPLATE*)pbData;
|
||||||
|
|
||||||
m_dwStyle = dTemplate->style;
|
m_dwStyle = dTemplate->style;
|
||||||
m_dwExtStyle = dTemplate->dwExtendedStyle;
|
m_dwExtStyle = dTemplate->dwExtendedStyle;
|
||||||
m_sX = dTemplate->x;
|
m_sX = dTemplate->x;
|
||||||
m_sY = dTemplate->y;
|
m_sY = dTemplate->y;
|
||||||
m_sWidth = dTemplate->cx;
|
m_sWidth = dTemplate->cx;
|
||||||
m_sHeight = dTemplate->cy;
|
m_sHeight = dTemplate->cy;
|
||||||
|
|
||||||
wItems = dTemplate->cdit;
|
wItems = dTemplate->cdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* seeker = pbData + (m_bExtended ? sizeof(DLGTEMPLATEEX) : sizeof(DLGTEMPLATE));
|
BYTE* seeker = pbData + (m_bExtended ? sizeof(DLGTEMPLATEEX) : sizeof(DLGTEMPLATE));
|
||||||
|
|
||||||
// Read menu variant length array
|
// Read menu variant length array
|
||||||
ReadVarLenArr(seeker, m_szMenu, m_uCodePage);
|
ReadVarLenArr(seeker, m_szMenu, m_uCodePage);
|
||||||
// Read class variant length array
|
// Read class variant length array
|
||||||
ReadVarLenArr(seeker, m_szClass, m_uCodePage);
|
ReadVarLenArr(seeker, m_szClass, m_uCodePage);
|
||||||
// Read title variant length array
|
// Read title variant length array
|
||||||
ReadVarLenArr(seeker, m_szTitle, m_uCodePage);
|
ReadVarLenArr(seeker, m_szTitle, m_uCodePage);
|
||||||
// Read font size and variant length array (only if style DS_SETFONT is used!)
|
// Read font size and variant length array (only if style DS_SETFONT is used!)
|
||||||
if (m_dwStyle & DS_SETFONT) {
|
if (m_dwStyle & DS_SETFONT) {
|
||||||
m_sFontSize = *(short*)seeker;
|
m_sFontSize = *(short*)seeker;
|
||||||
seeker += sizeof(short);
|
seeker += sizeof(short);
|
||||||
if (m_bExtended) {
|
if (m_bExtended) {
|
||||||
m_sFontWeight = *(short*)seeker;
|
m_sFontWeight = *(short*)seeker;
|
||||||
seeker += sizeof(short);
|
seeker += sizeof(short);
|
||||||
m_bItalic = *(BYTE*)seeker;
|
m_bItalic = *(BYTE*)seeker;
|
||||||
seeker += sizeof(BYTE);
|
seeker += sizeof(BYTE);
|
||||||
m_bCharset = *(BYTE*)seeker;
|
m_bCharset = *(BYTE*)seeker;
|
||||||
seeker += sizeof(BYTE);
|
seeker += sizeof(BYTE);
|
||||||
}
|
}
|
||||||
ReadVarLenArr(seeker, m_szFont, m_uCodePage);
|
ReadVarLenArr(seeker, m_szFont, m_uCodePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read items
|
// Read items
|
||||||
for (int i = 0; i < wItems; i++) {
|
for (int i = 0; i < wItems; i++) {
|
||||||
// DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry
|
// DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry
|
||||||
if (DWORD(seeker - pbData) % sizeof(DWORD))
|
if (DWORD(seeker - pbData) % sizeof(DWORD))
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
|
|
||||||
DialogItemTemplate* item = new DialogItemTemplate;
|
DialogItemTemplate* item = new DialogItemTemplate;
|
||||||
ZeroMemory(item, sizeof(DialogItemTemplate));
|
ZeroMemory(item, sizeof(DialogItemTemplate));
|
||||||
|
|
||||||
if (m_bExtended) {
|
if (m_bExtended) {
|
||||||
DLGITEMTEMPLATEEX* rawItem = (DLGITEMTEMPLATEEX*)seeker;
|
DLGITEMTEMPLATEEX* rawItem = (DLGITEMTEMPLATEEX*)seeker;
|
||||||
|
|
||||||
item->dwHelpId = rawItem->helpID;
|
item->dwHelpId = rawItem->helpID;
|
||||||
item->dwStyle = rawItem->style;
|
item->dwStyle = rawItem->style;
|
||||||
item->dwExtStyle = rawItem->exStyle;
|
item->dwExtStyle = rawItem->exStyle;
|
||||||
item->sX = rawItem->x;
|
item->sX = rawItem->x;
|
||||||
item->sY = rawItem->y;
|
item->sY = rawItem->y;
|
||||||
item->sWidth = rawItem->cx;
|
item->sWidth = rawItem->cx;
|
||||||
item->sHeight = rawItem->cy;
|
item->sHeight = rawItem->cy;
|
||||||
item->wId = rawItem->id;
|
item->wId = rawItem->id;
|
||||||
|
|
||||||
seeker += sizeof(DLGITEMTEMPLATEEX);
|
seeker += sizeof(DLGITEMTEMPLATEEX);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DLGITEMTEMPLATE* rawItem = (DLGITEMTEMPLATE*)seeker;
|
DLGITEMTEMPLATE* rawItem = (DLGITEMTEMPLATE*)seeker;
|
||||||
|
|
||||||
item->dwStyle = rawItem->style;
|
item->dwStyle = rawItem->style;
|
||||||
item->dwExtStyle = rawItem->dwExtendedStyle;
|
item->dwExtStyle = rawItem->dwExtendedStyle;
|
||||||
item->sX = rawItem->x;
|
item->sX = rawItem->x;
|
||||||
item->sY = rawItem->y;
|
item->sY = rawItem->y;
|
||||||
item->sWidth = rawItem->cx;
|
item->sWidth = rawItem->cx;
|
||||||
item->sHeight = rawItem->cy;
|
item->sHeight = rawItem->cy;
|
||||||
item->wId = rawItem->id;
|
item->wId = rawItem->id;
|
||||||
|
|
||||||
seeker += sizeof(DLGITEMTEMPLATE);
|
seeker += sizeof(DLGITEMTEMPLATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read class variant length array
|
// Read class variant length array
|
||||||
ReadVarLenArr(seeker, item->szClass, m_uCodePage);
|
ReadVarLenArr(seeker, item->szClass, m_uCodePage);
|
||||||
// Read title variant length array
|
// Read title variant length array
|
||||||
ReadVarLenArr(seeker, item->szTitle, m_uCodePage);
|
ReadVarLenArr(seeker, item->szTitle, m_uCodePage);
|
||||||
|
|
||||||
// Read creation data variant length array
|
// Read creation data variant length array
|
||||||
// First read the size of the array (no null termination)
|
// First read the size of the array (no null termination)
|
||||||
item->wCreateDataSize = *(WORD*)seeker;
|
item->wCreateDataSize = *(WORD*)seeker;
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
// Then read the array it self (if size is not 0)
|
// Then read the array it self (if size is not 0)
|
||||||
if (item->wCreateDataSize) {
|
if (item->wCreateDataSize) {
|
||||||
item->wCreateDataSize -= sizeof(WORD); // Size includes size field itself...
|
item->wCreateDataSize -= sizeof(WORD); // Size includes size field itself...
|
||||||
item->szCreationData = new char[item->wCreateDataSize];
|
item->szCreationData = new char[item->wCreateDataSize];
|
||||||
CopyMemory(item->szCreationData, seeker, item->wCreateDataSize);
|
CopyMemory(item->szCreationData, seeker, item->wCreateDataSize);
|
||||||
seeker += item->wCreateDataSize;
|
seeker += item->wCreateDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the item to the vector
|
// Add the item to the vector
|
||||||
m_vItems.push_back(item);
|
m_vItems.push_back(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CDialogTemplate::~CDialogTemplate() {
|
CDialogTemplate::~CDialogTemplate() {
|
||||||
if (m_szMenu && !IS_INTRESOURCE(m_szMenu))
|
if (m_szMenu && !IS_INTRESOURCE(m_szMenu))
|
||||||
delete [] m_szMenu;
|
delete [] m_szMenu;
|
||||||
if (m_szClass && !IS_INTRESOURCE(m_szClass))
|
if (m_szClass && !IS_INTRESOURCE(m_szClass))
|
||||||
delete [] m_szClass;
|
delete [] m_szClass;
|
||||||
if (m_szTitle)
|
if (m_szTitle)
|
||||||
delete [] m_szTitle;
|
delete [] m_szTitle;
|
||||||
if (m_szFont)
|
if (m_szFont)
|
||||||
delete [] m_szTitle;
|
delete [] m_szTitle;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
||||||
if (m_vItems[i]->szClass && !IS_INTRESOURCE(m_vItems[i]->szClass))
|
if (m_vItems[i]->szClass && !IS_INTRESOURCE(m_vItems[i]->szClass))
|
||||||
delete [] m_vItems[i]->szClass;
|
delete [] m_vItems[i]->szClass;
|
||||||
if (m_vItems[i]->szTitle && !IS_INTRESOURCE(m_vItems[i]->szTitle))
|
if (m_vItems[i]->szTitle && !IS_INTRESOURCE(m_vItems[i]->szTitle))
|
||||||
delete [] m_vItems[i]->szTitle;
|
delete [] m_vItems[i]->szTitle;
|
||||||
if (m_vItems[i]->szCreationData)
|
if (m_vItems[i]->szCreationData)
|
||||||
delete [] m_vItems[i]->szCreationData;
|
delete [] m_vItems[i]->szCreationData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -228,32 +228,32 @@ CDialogTemplate::~CDialogTemplate() {
|
||||||
|
|
||||||
// Returns the width of the dialog
|
// Returns the width of the dialog
|
||||||
short CDialogTemplate::GetWidth() {
|
short CDialogTemplate::GetWidth() {
|
||||||
return m_sWidth;
|
return m_sWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the height of the dialog
|
// Returns the height of the dialog
|
||||||
short CDialogTemplate::GetHeight() {
|
short CDialogTemplate::GetHeight() {
|
||||||
return m_sHeight;
|
return m_sHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns info about the item with the id wId
|
// Returns info about the item with the id wId
|
||||||
DialogItemTemplate* CDialogTemplate::GetItem(WORD wId) {
|
DialogItemTemplate* CDialogTemplate::GetItem(WORD wId) {
|
||||||
for (unsigned int i = 0; i < m_vItems.size(); i++)
|
for (unsigned int i = 0; i < m_vItems.size(); i++)
|
||||||
if (m_vItems[i]->wId == wId)
|
if (m_vItems[i]->wId == wId)
|
||||||
return m_vItems[i];
|
return m_vItems[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns info about the item with the indexed i
|
// Returns info about the item with the indexed i
|
||||||
DialogItemTemplate* CDialogTemplate::GetItemByIdx(DWORD i) {
|
DialogItemTemplate* CDialogTemplate::GetItemByIdx(DWORD i) {
|
||||||
if (i >= m_vItems.size()) return 0;
|
if (i >= m_vItems.size()) return 0;
|
||||||
return m_vItems[i];
|
return m_vItems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes an item
|
// Removes an item
|
||||||
void CDialogTemplate::RemoveItem(WORD wId) {
|
void CDialogTemplate::RemoveItem(WORD wId) {
|
||||||
for (unsigned int i = 0; i < m_vItems.size(); i++)
|
for (unsigned int i = 0; i < m_vItems.size(); i++)
|
||||||
if (m_vItems[i]->wId == wId)
|
if (m_vItems[i]->wId == wId)
|
||||||
m_vItems.erase(m_vItems.begin() + i);
|
m_vItems.erase(m_vItems.begin() + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,145 +274,145 @@ void CDialogTemplate::SetFont(char* szFaceName, WORD wFontSize) {
|
||||||
m_bExtended = true;
|
m_bExtended = true;
|
||||||
}
|
}
|
||||||
m_dwStyle |= DS_SETFONT;
|
m_dwStyle |= DS_SETFONT;
|
||||||
if (m_szFont) delete [] m_szFont;
|
if (m_szFont) delete [] m_szFont;
|
||||||
m_szFont = new char[lstrlen(szFaceName)];
|
m_szFont = new char[lstrlen(szFaceName)];
|
||||||
lstrcpy(m_szFont, szFaceName);
|
lstrcpy(m_szFont, szFaceName);
|
||||||
m_sFontSize = wFontSize;
|
m_sFontSize = wFontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds an item to the dialog
|
// Adds an item to the dialog
|
||||||
void CDialogTemplate::AddItem(DialogItemTemplate item) {
|
void CDialogTemplate::AddItem(DialogItemTemplate item) {
|
||||||
DialogItemTemplate* newItem = new DialogItemTemplate;
|
DialogItemTemplate* newItem = new DialogItemTemplate;
|
||||||
CopyMemory(newItem, &item, sizeof(DialogItemTemplate));
|
CopyMemory(newItem, &item, sizeof(DialogItemTemplate));
|
||||||
|
|
||||||
if (item.szClass && !IS_INTRESOURCE(item.szClass)) {
|
if (item.szClass && !IS_INTRESOURCE(item.szClass)) {
|
||||||
newItem->szClass = new char[lstrlen(item.szClass)+1];
|
newItem->szClass = new char[lstrlen(item.szClass)+1];
|
||||||
lstrcpy(newItem->szClass, item.szClass);
|
lstrcpy(newItem->szClass, item.szClass);
|
||||||
}
|
}
|
||||||
if (item.szTitle && !IS_INTRESOURCE(item.szTitle)) {
|
if (item.szTitle && !IS_INTRESOURCE(item.szTitle)) {
|
||||||
newItem->szTitle = new char[lstrlen(item.szTitle)+1];
|
newItem->szTitle = new char[lstrlen(item.szTitle)+1];
|
||||||
lstrcpy(newItem->szTitle, item.szTitle);
|
lstrcpy(newItem->szTitle, item.szTitle);
|
||||||
}
|
}
|
||||||
if (item.wCreateDataSize) {
|
if (item.wCreateDataSize) {
|
||||||
newItem->szCreationData = new char[item.wCreateDataSize];
|
newItem->szCreationData = new char[item.wCreateDataSize];
|
||||||
memcpy(newItem->szCreationData, item.szCreationData, item.wCreateDataSize);
|
memcpy(newItem->szCreationData, item.szCreationData, item.wCreateDataSize);
|
||||||
}
|
}
|
||||||
m_vItems.push_back(newItem);
|
m_vItems.push_back(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moves all of the items in the dialog by (x,y)
|
// Moves all of the items in the dialog by (x,y)
|
||||||
void CDialogTemplate::MoveAll(short x, short y) {
|
void CDialogTemplate::MoveAll(short x, short y) {
|
||||||
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
||||||
m_vItems[i]->sX += x;
|
m_vItems[i]->sX += x;
|
||||||
m_vItems[i]->sY += y;
|
m_vItems[i]->sY += y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resizes the dialog by (x,y)
|
// Resizes the dialog by (x,y)
|
||||||
void CDialogTemplate::Resize(short x, short y) {
|
void CDialogTemplate::Resize(short x, short y) {
|
||||||
m_sWidth += x;
|
m_sWidth += x;
|
||||||
m_sHeight += y;
|
m_sHeight += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a dummy dialog that is used for converting units
|
// Creates a dummy dialog that is used for converting units
|
||||||
HWND CDialogTemplate::CreateDummyDialog() {
|
HWND CDialogTemplate::CreateDummyDialog() {
|
||||||
DWORD dwTemp;
|
DWORD dwTemp;
|
||||||
BYTE* pbDlg = Save(dwTemp);
|
BYTE* pbDlg = Save(dwTemp);
|
||||||
HWND hDlg = CreateDialogIndirect(GetModuleHandle(0), (DLGTEMPLATE*)pbDlg, 0, 0);
|
HWND hDlg = CreateDialogIndirect(GetModuleHandle(0), (DLGTEMPLATE*)pbDlg, 0, 0);
|
||||||
delete [] pbDlg;
|
delete [] pbDlg;
|
||||||
if (!hDlg)
|
if (!hDlg)
|
||||||
throw runtime_error("Can't create dialog from template!");
|
throw runtime_error("Can't create dialog from template!");
|
||||||
|
|
||||||
return hDlg;
|
return hDlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts pixels to this dialog's units
|
// Converts pixels to this dialog's units
|
||||||
void CDialogTemplate::PixelsToDlgUnits(short& x, short& y) {
|
void CDialogTemplate::PixelsToDlgUnits(short& x, short& y) {
|
||||||
HWND hDlg = CreateDummyDialog();
|
HWND hDlg = CreateDummyDialog();
|
||||||
RECT r = {0, 0, 10000, 10000};
|
RECT r = {0, 0, 10000, 10000};
|
||||||
MapDialogRect(hDlg, &r);
|
MapDialogRect(hDlg, &r);
|
||||||
DestroyWindow(hDlg);
|
DestroyWindow(hDlg);
|
||||||
|
|
||||||
x = short(float(x) / (float(r.right)/10000));
|
x = short(float(x) / (float(r.right)/10000));
|
||||||
y = short(float(y) / (float(r.bottom)/10000));
|
y = short(float(y) / (float(r.bottom)/10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts pixels to this dialog's units
|
// Converts pixels to this dialog's units
|
||||||
void CDialogTemplate::DlgUnitsToPixels(short& x, short& y) {
|
void CDialogTemplate::DlgUnitsToPixels(short& x, short& y) {
|
||||||
HWND hDlg = CreateDummyDialog();
|
HWND hDlg = CreateDummyDialog();
|
||||||
RECT r = {0, 0, 10000, 10000};
|
RECT r = {0, 0, 10000, 10000};
|
||||||
MapDialogRect(hDlg, &r);
|
MapDialogRect(hDlg, &r);
|
||||||
DestroyWindow(hDlg);
|
DestroyWindow(hDlg);
|
||||||
|
|
||||||
x = short(float(x) * (float(r.right)/10000));
|
x = short(float(x) * (float(r.right)/10000));
|
||||||
y = short(float(y) * (float(r.bottom)/10000));
|
y = short(float(y) * (float(r.bottom)/10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the size of a string in the dialog (in dialog units)
|
// Returns the size of a string in the dialog (in dialog units)
|
||||||
SIZE CDialogTemplate::GetStringSize(WORD id, char *str) {
|
SIZE CDialogTemplate::GetStringSize(WORD id, char *str) {
|
||||||
HWND hDlg = CreateDummyDialog();
|
HWND hDlg = CreateDummyDialog();
|
||||||
|
|
||||||
LOGFONT f;
|
LOGFONT f;
|
||||||
GetObject((HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0), sizeof(LOGFONT), &f);
|
GetObject((HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0), sizeof(LOGFONT), &f);
|
||||||
|
|
||||||
HDC memDC = CreateCompatibleDC(GetDC(hDlg));
|
HDC memDC = CreateCompatibleDC(GetDC(hDlg));
|
||||||
HFONT font = CreateFontIndirect(&f);
|
HFONT font = CreateFontIndirect(&f);
|
||||||
SelectObject(memDC, font);
|
SelectObject(memDC, font);
|
||||||
|
|
||||||
SIZE size;
|
SIZE size;
|
||||||
GetTextExtentPoint32(memDC, str, lstrlen(str), &size);
|
GetTextExtentPoint32(memDC, str, lstrlen(str), &size);
|
||||||
|
|
||||||
DestroyWindow(hDlg);
|
DestroyWindow(hDlg);
|
||||||
DeleteObject(font);
|
DeleteObject(font);
|
||||||
DeleteDC(memDC);
|
DeleteDC(memDC);
|
||||||
|
|
||||||
PixelsToDlgUnits((short&)size.cx, (short&)size.cy);
|
PixelsToDlgUnits((short&)size.cx, (short&)size.cy);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trims the right margins of a control to fit a given text string size.
|
// Trims the right margins of a control to fit a given text string size.
|
||||||
void CDialogTemplate::RTrimToString(WORD id, char *str, int margins) {
|
void CDialogTemplate::RTrimToString(WORD id, char *str, int margins) {
|
||||||
DialogItemTemplate* item = GetItem(id);
|
DialogItemTemplate* item = GetItem(id);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
SIZE size = GetStringSize(id, str);
|
SIZE size = GetStringSize(id, str);
|
||||||
|
|
||||||
size.cx += margins;
|
size.cx += margins;
|
||||||
size.cy += 2;
|
size.cy += 2;
|
||||||
|
|
||||||
item->sWidth = short(size.cx);
|
item->sWidth = short(size.cx);
|
||||||
item->sHeight = short(size.cy);
|
item->sHeight = short(size.cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trims the left margins of a control to fit a given text string size.
|
// Trims the left margins of a control to fit a given text string size.
|
||||||
void CDialogTemplate::LTrimToString(WORD id, char *str, int margins) {
|
void CDialogTemplate::LTrimToString(WORD id, char *str, int margins) {
|
||||||
DialogItemTemplate* item = GetItem(id);
|
DialogItemTemplate* item = GetItem(id);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
SIZE size = GetStringSize(id, str);
|
SIZE size = GetStringSize(id, str);
|
||||||
|
|
||||||
size.cx += margins;
|
size.cx += margins;
|
||||||
size.cy += 2;
|
size.cy += 2;
|
||||||
|
|
||||||
item->sX += item->sWidth - short(size.cx);
|
item->sX += item->sWidth - short(size.cx);
|
||||||
item->sWidth = short(size.cx);
|
item->sWidth = short(size.cx);
|
||||||
item->sHeight = short(size.cy);
|
item->sHeight = short(size.cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trims the left and right margins of a control to fit a given text string size.
|
// Trims the left and right margins of a control to fit a given text string size.
|
||||||
void CDialogTemplate::CTrimToString(WORD id, char *str, int margins) {
|
void CDialogTemplate::CTrimToString(WORD id, char *str, int margins) {
|
||||||
DialogItemTemplate* item = GetItem(id);
|
DialogItemTemplate* item = GetItem(id);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
SIZE size = GetStringSize(id, str);
|
SIZE size = GetStringSize(id, str);
|
||||||
|
|
||||||
size.cx += margins;
|
size.cx += margins;
|
||||||
size.cy += 2;
|
size.cy += 2;
|
||||||
|
|
||||||
item->sX += item->sWidth/2 - short(size.cx/2);
|
item->sX += item->sWidth/2 - short(size.cx/2);
|
||||||
item->sWidth = short(size.cx);
|
item->sWidth = short(size.cx);
|
||||||
item->sHeight = short(size.cy);
|
item->sHeight = short(size.cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moves every item right and gives it the WS_EX_RIGHT extended style
|
// Moves every item right and gives it the WS_EX_RIGHT extended style
|
||||||
|
@ -439,161 +439,161 @@ void CDialogTemplate::ConvertToRTL() {
|
||||||
}
|
}
|
||||||
else addExStyle = true;
|
else addExStyle = true;
|
||||||
if (addExStyle)
|
if (addExStyle)
|
||||||
m_vItems[i]->dwExtStyle |= WS_EX_RIGHT;
|
m_vItems[i]->dwExtStyle |= WS_EX_RIGHT;
|
||||||
m_vItems[i]->sX = m_sWidth - m_vItems[i]->sWidth - m_vItems[i]->sX;
|
m_vItems[i]->sX = m_sWidth - m_vItems[i]->sWidth - m_vItems[i]->sX;
|
||||||
}
|
}
|
||||||
m_dwExtStyle |= WS_EX_RIGHT;
|
m_dwExtStyle |= WS_EX_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saves the dialog in the form of DLGTEMPLATE[EX]
|
// Saves the dialog in the form of DLGTEMPLATE[EX]
|
||||||
BYTE* CDialogTemplate::Save(DWORD& dwSize) {
|
BYTE* CDialogTemplate::Save(DWORD& dwSize) {
|
||||||
// We need the size first to know how much memory to allocate
|
// We need the size first to know how much memory to allocate
|
||||||
dwSize = GetSize();
|
dwSize = GetSize();
|
||||||
BYTE* pbDlg = new BYTE[dwSize];
|
BYTE* pbDlg = new BYTE[dwSize];
|
||||||
ZeroMemory(pbDlg, dwSize);
|
ZeroMemory(pbDlg, dwSize);
|
||||||
BYTE* seeker = pbDlg;
|
BYTE* seeker = pbDlg;
|
||||||
|
|
||||||
if (m_bExtended) {
|
if (m_bExtended) {
|
||||||
DLGTEMPLATEEX dh = {
|
DLGTEMPLATEEX dh = {
|
||||||
0x0001,
|
0x0001,
|
||||||
0xFFFF,
|
0xFFFF,
|
||||||
m_dwHelpId,
|
m_dwHelpId,
|
||||||
m_dwExtStyle,
|
m_dwExtStyle,
|
||||||
m_dwStyle,
|
m_dwStyle,
|
||||||
m_vItems.size(),
|
m_vItems.size(),
|
||||||
m_sX,
|
m_sX,
|
||||||
m_sY,
|
m_sY,
|
||||||
m_sWidth,
|
m_sWidth,
|
||||||
m_sHeight
|
m_sHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
CopyMemory(seeker, &dh, sizeof(DLGTEMPLATEEX));
|
CopyMemory(seeker, &dh, sizeof(DLGTEMPLATEEX));
|
||||||
seeker += sizeof(DLGTEMPLATEEX);
|
seeker += sizeof(DLGTEMPLATEEX);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DLGTEMPLATE dh = {
|
DLGTEMPLATE dh = {
|
||||||
m_dwStyle,
|
m_dwStyle,
|
||||||
m_dwExtStyle,
|
m_dwExtStyle,
|
||||||
m_vItems.size(),
|
m_vItems.size(),
|
||||||
m_sX,
|
m_sX,
|
||||||
m_sY,
|
m_sY,
|
||||||
m_sWidth,
|
m_sWidth,
|
||||||
m_sHeight
|
m_sHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
CopyMemory(seeker, &dh, sizeof(DLGTEMPLATE));
|
CopyMemory(seeker, &dh, sizeof(DLGTEMPLATE));
|
||||||
seeker += sizeof(DLGTEMPLATE);
|
seeker += sizeof(DLGTEMPLATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write menu variant length array
|
// Write menu variant length array
|
||||||
WriteStringOrId(m_szMenu);
|
WriteStringOrId(m_szMenu);
|
||||||
// Write class variant length array
|
// Write class variant length array
|
||||||
WriteStringOrId(m_szClass);
|
WriteStringOrId(m_szClass);
|
||||||
// Write title variant length array
|
// Write title variant length array
|
||||||
WriteStringOrId(m_szTitle);
|
WriteStringOrId(m_szTitle);
|
||||||
|
|
||||||
// Write font variant length array, size, and extended info (if needed)
|
// Write font variant length array, size, and extended info (if needed)
|
||||||
if (m_dwStyle & DS_SETFONT) {
|
if (m_dwStyle & DS_SETFONT) {
|
||||||
*(short*)seeker = m_sFontSize;
|
*(short*)seeker = m_sFontSize;
|
||||||
seeker += sizeof(short);
|
seeker += sizeof(short);
|
||||||
if (m_bExtended) {
|
if (m_bExtended) {
|
||||||
*(short*)seeker = m_sFontWeight;
|
*(short*)seeker = m_sFontWeight;
|
||||||
seeker += sizeof(short);
|
seeker += sizeof(short);
|
||||||
*(BYTE*)seeker = m_bItalic;
|
*(BYTE*)seeker = m_bItalic;
|
||||||
seeker += sizeof(BYTE);
|
seeker += sizeof(BYTE);
|
||||||
*(BYTE*)seeker = m_bCharset;
|
*(BYTE*)seeker = m_bCharset;
|
||||||
seeker += sizeof(BYTE);
|
seeker += sizeof(BYTE);
|
||||||
}
|
}
|
||||||
WriteStringOrId(m_szFont);
|
WriteStringOrId(m_szFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write all of the items
|
// Write all of the items
|
||||||
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
||||||
// DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry
|
// DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry
|
||||||
if (DWORD(seeker - pbDlg) % sizeof(DWORD))
|
if (DWORD(seeker - pbDlg) % sizeof(DWORD))
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
|
|
||||||
if (m_bExtended) {
|
if (m_bExtended) {
|
||||||
DLGITEMTEMPLATEEX dih = {
|
DLGITEMTEMPLATEEX dih = {
|
||||||
m_vItems[i]->dwHelpId,
|
m_vItems[i]->dwHelpId,
|
||||||
m_vItems[i]->dwExtStyle,
|
m_vItems[i]->dwExtStyle,
|
||||||
m_vItems[i]->dwStyle,
|
m_vItems[i]->dwStyle,
|
||||||
m_vItems[i]->sX,
|
m_vItems[i]->sX,
|
||||||
m_vItems[i]->sY,
|
m_vItems[i]->sY,
|
||||||
m_vItems[i]->sWidth,
|
m_vItems[i]->sWidth,
|
||||||
m_vItems[i]->sHeight,
|
m_vItems[i]->sHeight,
|
||||||
m_vItems[i]->wId
|
m_vItems[i]->wId
|
||||||
};
|
};
|
||||||
|
|
||||||
CopyMemory(seeker, &dih, sizeof(DLGITEMTEMPLATEEX));
|
CopyMemory(seeker, &dih, sizeof(DLGITEMTEMPLATEEX));
|
||||||
seeker += sizeof(DLGITEMTEMPLATEEX);
|
seeker += sizeof(DLGITEMTEMPLATEEX);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DLGITEMTEMPLATE dih = {
|
DLGITEMTEMPLATE dih = {
|
||||||
m_vItems[i]->dwStyle,
|
m_vItems[i]->dwStyle,
|
||||||
m_vItems[i]->dwExtStyle,
|
m_vItems[i]->dwExtStyle,
|
||||||
m_vItems[i]->sX,
|
m_vItems[i]->sX,
|
||||||
m_vItems[i]->sY,
|
m_vItems[i]->sY,
|
||||||
m_vItems[i]->sWidth,
|
m_vItems[i]->sWidth,
|
||||||
m_vItems[i]->sHeight,
|
m_vItems[i]->sHeight,
|
||||||
m_vItems[i]->wId
|
m_vItems[i]->wId
|
||||||
};
|
};
|
||||||
|
|
||||||
CopyMemory(seeker, &dih, sizeof(DLGITEMTEMPLATE));
|
CopyMemory(seeker, &dih, sizeof(DLGITEMTEMPLATE));
|
||||||
seeker += sizeof(DLGITEMTEMPLATE);
|
seeker += sizeof(DLGITEMTEMPLATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write class variant length array
|
// Write class variant length array
|
||||||
WriteStringOrId(m_vItems[i]->szClass);
|
WriteStringOrId(m_vItems[i]->szClass);
|
||||||
// Write title variant length array
|
// Write title variant length array
|
||||||
WriteStringOrId(m_vItems[i]->szTitle);
|
WriteStringOrId(m_vItems[i]->szTitle);
|
||||||
|
|
||||||
// Write creation data variant length array
|
// Write creation data variant length array
|
||||||
// First write its size
|
// First write its size
|
||||||
if (m_vItems[i]->wCreateDataSize) m_vItems[i]->wCreateDataSize += sizeof(WORD);
|
if (m_vItems[i]->wCreateDataSize) m_vItems[i]->wCreateDataSize += sizeof(WORD);
|
||||||
*(WORD*)seeker = m_vItems[i]->wCreateDataSize;
|
*(WORD*)seeker = m_vItems[i]->wCreateDataSize;
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
// If size is nonzero write the data too
|
// If size is nonzero write the data too
|
||||||
if (m_vItems[i]->wCreateDataSize) {
|
if (m_vItems[i]->wCreateDataSize) {
|
||||||
CopyMemory(seeker, m_vItems[i]->szCreationData, m_vItems[i]->wCreateDataSize);
|
CopyMemory(seeker, m_vItems[i]->szCreationData, m_vItems[i]->wCreateDataSize);
|
||||||
seeker += m_vItems[i]->wCreateDataSize;
|
seeker += m_vItems[i]->wCreateDataSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DONE!
|
// DONE!
|
||||||
return pbDlg;
|
return pbDlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the size that the DLGTEMPLATE[EX] will take when saved
|
// Returns the size that the DLGTEMPLATE[EX] will take when saved
|
||||||
DWORD CDialogTemplate::GetSize() {
|
DWORD CDialogTemplate::GetSize() {
|
||||||
DWORD dwSize = m_bExtended ? sizeof(DLGTEMPLATEEX) : sizeof(DLGTEMPLATE);
|
DWORD dwSize = m_bExtended ? sizeof(DLGTEMPLATEEX) : sizeof(DLGTEMPLATE);
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
AddStringOrIdSize(m_szMenu);
|
AddStringOrIdSize(m_szMenu);
|
||||||
// Class
|
// Class
|
||||||
AddStringOrIdSize(m_szClass);
|
AddStringOrIdSize(m_szClass);
|
||||||
// Title
|
// Title
|
||||||
AddStringOrIdSize(m_szTitle);
|
AddStringOrIdSize(m_szTitle);
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
if (m_dwStyle & DS_SETFONT) {
|
if (m_dwStyle & DS_SETFONT) {
|
||||||
dwSize += sizeof(WORD) + (m_bExtended ? sizeof(short) + 2*sizeof(BYTE) : 0);
|
dwSize += sizeof(WORD) + (m_bExtended ? sizeof(short) + 2*sizeof(BYTE) : 0);
|
||||||
AddStringOrIdSize(m_szFont);
|
AddStringOrIdSize(m_szFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
||||||
// DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry
|
// DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry
|
||||||
ALIGN(dwSize, sizeof(DWORD));
|
ALIGN(dwSize, sizeof(DWORD));
|
||||||
|
|
||||||
dwSize += m_bExtended ? sizeof(DLGITEMTEMPLATEEX) : sizeof(DLGITEMTEMPLATE);
|
dwSize += m_bExtended ? sizeof(DLGITEMTEMPLATEEX) : sizeof(DLGITEMTEMPLATE);
|
||||||
|
|
||||||
// Class
|
// Class
|
||||||
AddStringOrIdSize(m_vItems[i]->szClass);
|
AddStringOrIdSize(m_vItems[i]->szClass);
|
||||||
// Title
|
// Title
|
||||||
AddStringOrIdSize(m_vItems[i]->szTitle);
|
AddStringOrIdSize(m_vItems[i]->szTitle);
|
||||||
|
|
||||||
dwSize += sizeof(WORD) + m_vItems[i]->wCreateDataSize;
|
dwSize += sizeof(WORD) + m_vItems[i]->wCreateDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dwSize;
|
return dwSize;
|
||||||
}
|
}
|
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2002 Amir Szekely <kichik@netvision.net.il>
|
Copyright (C) 2002 Amir Szekely <kichik@netvision.net.il>
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
appreciated but is not required.
|
appreciated but is not required.
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)
|
#if !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)
|
||||||
|
@ -41,105 +41,105 @@ using namespace std;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct DialogItemTemplate {
|
struct DialogItemTemplate {
|
||||||
DWORD dwHelpId; // Extended only
|
DWORD dwHelpId; // Extended only
|
||||||
|
|
||||||
short sX;
|
short sX;
|
||||||
short sY;
|
short sY;
|
||||||
short sWidth;
|
short sWidth;
|
||||||
short sHeight;
|
short sHeight;
|
||||||
DWORD dwExtStyle;
|
DWORD dwExtStyle;
|
||||||
DWORD dwStyle;
|
DWORD dwStyle;
|
||||||
WORD wId;
|
WORD wId;
|
||||||
|
|
||||||
char *szClass;
|
char *szClass;
|
||||||
char *szTitle;
|
char *szTitle;
|
||||||
char *szCreationData;
|
char *szCreationData;
|
||||||
|
|
||||||
WORD wCreateDataSize;
|
WORD wCreateDataSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WORD dlgVer;
|
WORD dlgVer;
|
||||||
WORD signature;
|
WORD signature;
|
||||||
DWORD helpID;
|
DWORD helpID;
|
||||||
DWORD exStyle;
|
DWORD exStyle;
|
||||||
DWORD style;
|
DWORD style;
|
||||||
WORD cDlgItems;
|
WORD cDlgItems;
|
||||||
short x;
|
short x;
|
||||||
short y;
|
short y;
|
||||||
short cx;
|
short cx;
|
||||||
short cy;
|
short cy;
|
||||||
} DLGTEMPLATEEX;
|
} DLGTEMPLATEEX;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DWORD helpID;
|
DWORD helpID;
|
||||||
DWORD exStyle;
|
DWORD exStyle;
|
||||||
DWORD style;
|
DWORD style;
|
||||||
short x;
|
short x;
|
||||||
short y;
|
short y;
|
||||||
short cx;
|
short cx;
|
||||||
short cy;
|
short cy;
|
||||||
WORD id;
|
WORD id;
|
||||||
WORD _miscrosoft_docs_are_wrong;
|
WORD _miscrosoft_docs_are_wrong;
|
||||||
} DLGITEMTEMPLATEEX;
|
} DLGITEMTEMPLATEEX;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
class CDialogTemplate {
|
class CDialogTemplate {
|
||||||
public:
|
public:
|
||||||
CDialogTemplate(BYTE* pbData, unsigned int uCodePage=CP_ACP);
|
CDialogTemplate(BYTE* pbData, unsigned int uCodePage=CP_ACP);
|
||||||
virtual ~CDialogTemplate();
|
virtual ~CDialogTemplate();
|
||||||
|
|
||||||
short GetWidth();
|
short GetWidth();
|
||||||
short GetHeight();
|
short GetHeight();
|
||||||
DialogItemTemplate* GetItem(WORD wId);
|
DialogItemTemplate* GetItem(WORD wId);
|
||||||
DialogItemTemplate* GetItemByIdx(DWORD i);
|
DialogItemTemplate* GetItemByIdx(DWORD i);
|
||||||
void RemoveItem(WORD wId);
|
void RemoveItem(WORD wId);
|
||||||
void SetFont(char* szFaceName, WORD wFontSize);
|
void SetFont(char* szFaceName, WORD wFontSize);
|
||||||
void AddItem(DialogItemTemplate item);
|
void AddItem(DialogItemTemplate item);
|
||||||
HWND CreateDummyDialog();
|
HWND CreateDummyDialog();
|
||||||
void MoveAll(short x, short y);
|
void MoveAll(short x, short y);
|
||||||
void Resize(short x, short y);
|
void Resize(short x, short y);
|
||||||
void PixelsToDlgUnits(short& x, short& y);
|
void PixelsToDlgUnits(short& x, short& y);
|
||||||
void DlgUnitsToPixels(short& x, short& y);
|
void DlgUnitsToPixels(short& x, short& y);
|
||||||
SIZE GetStringSize(WORD id, char *str);
|
SIZE GetStringSize(WORD id, char *str);
|
||||||
void RTrimToString(WORD id, char *str, int margins);
|
void RTrimToString(WORD id, char *str, int margins);
|
||||||
void LTrimToString(WORD id, char *str, int margins);
|
void LTrimToString(WORD id, char *str, int margins);
|
||||||
void CTrimToString(WORD id, char *str, int margins);
|
void CTrimToString(WORD id, char *str, int margins);
|
||||||
void ConvertToRTL();
|
void ConvertToRTL();
|
||||||
BYTE* Save(DWORD& dwSize);
|
BYTE* Save(DWORD& dwSize);
|
||||||
DWORD GetSize();
|
DWORD GetSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bExtended;
|
bool m_bExtended;
|
||||||
|
|
||||||
DWORD m_dwHelpId; // Extended only
|
DWORD m_dwHelpId; // Extended only
|
||||||
|
|
||||||
short m_sX;
|
short m_sX;
|
||||||
short m_sY;
|
short m_sY;
|
||||||
short m_sWidth;
|
short m_sWidth;
|
||||||
short m_sHeight;
|
short m_sHeight;
|
||||||
DWORD m_dwExtStyle;
|
DWORD m_dwExtStyle;
|
||||||
DWORD m_dwStyle;
|
DWORD m_dwStyle;
|
||||||
|
|
||||||
char* m_szMenu;
|
char* m_szMenu;
|
||||||
char* m_szClass;
|
char* m_szClass;
|
||||||
char* m_szTitle;
|
char* m_szTitle;
|
||||||
|
|
||||||
// Only if DS_FONT style is set
|
// Only if DS_FONT style is set
|
||||||
short m_sFontSize;
|
short m_sFontSize;
|
||||||
short m_sFontWeight; // Extended only
|
short m_sFontWeight; // Extended only
|
||||||
BYTE m_bItalic; // Extended only
|
BYTE m_bItalic; // Extended only
|
||||||
BYTE m_bCharset; // Extended only
|
BYTE m_bCharset; // Extended only
|
||||||
char* m_szFont;
|
char* m_szFont;
|
||||||
|
|
||||||
// For (en/de)coding Unicode
|
// For (en/de)coding Unicode
|
||||||
unsigned int m_uCodePage;
|
unsigned int m_uCodePage;
|
||||||
|
|
||||||
// Items vector
|
// Items vector
|
||||||
vector<DialogItemTemplate*> m_vItems;
|
vector<DialogItemTemplate*> m_vItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)
|
#endif // !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2002 Amir Szekely <kichik@netvision.net.il>
|
Copyright (C) 2002 Amir Szekely <kichik@netvision.net.il>
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
appreciated but is not required.
|
appreciated but is not required.
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(AFX_RESOURCEEDITOR_H__683BF710_E805_4093_975B_D5729186A89A__INCLUDED_)
|
#if !defined(AFX_RESOURCEEDITOR_H__683BF710_E805_4093_975B_D5729186A89A__INCLUDED_)
|
||||||
|
@ -53,121 +53,121 @@ class CResourceDataEntry;
|
||||||
|
|
||||||
// Resource directory with entries
|
// Resource directory with entries
|
||||||
typedef struct RESOURCE_DIRECTORY {
|
typedef struct RESOURCE_DIRECTORY {
|
||||||
IMAGE_RESOURCE_DIRECTORY Header;
|
IMAGE_RESOURCE_DIRECTORY Header;
|
||||||
IMAGE_RESOURCE_DIRECTORY_ENTRY Entries[1];
|
IMAGE_RESOURCE_DIRECTORY_ENTRY Entries[1];
|
||||||
} *PRESOURCE_DIRECTORY;
|
} *PRESOURCE_DIRECTORY;
|
||||||
|
|
||||||
class CResourceEditor {
|
class CResourceEditor {
|
||||||
public:
|
public:
|
||||||
CResourceEditor(BYTE* pbPE, int iSize);
|
CResourceEditor(BYTE* pbPE, int iSize);
|
||||||
virtual ~CResourceEditor();
|
virtual ~CResourceEditor();
|
||||||
|
|
||||||
bool UpdateResource(char* szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResource(char* szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
bool UpdateResource(WORD szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResource(WORD szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
bool UpdateResource(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResource(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
bool UpdateResource(WORD szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResource(WORD szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
BYTE* GetResource(char* szType, char* szName, LANGID wLanguage);
|
BYTE* GetResource(char* szType, char* szName, LANGID wLanguage);
|
||||||
|
|
||||||
bool AddExtraVirtualSize2PESection(const char* pszSectionName, int addsize);
|
bool AddExtraVirtualSize2PESection(const char* pszSectionName, int addsize);
|
||||||
BYTE* Save(DWORD &dwSize);
|
BYTE* Save(DWORD &dwSize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BYTE* m_pbPE;
|
BYTE* m_pbPE;
|
||||||
int m_iSize;
|
int m_iSize;
|
||||||
|
|
||||||
PIMAGE_DOS_HEADER m_dosHeader;
|
PIMAGE_DOS_HEADER m_dosHeader;
|
||||||
PIMAGE_NT_HEADERS m_ntHeaders;
|
PIMAGE_NT_HEADERS m_ntHeaders;
|
||||||
|
|
||||||
DWORD m_dwResourceSectionIndex;
|
DWORD m_dwResourceSectionIndex;
|
||||||
DWORD m_dwResourceSectionVA;
|
DWORD m_dwResourceSectionVA;
|
||||||
|
|
||||||
CResourceDirectory* m_cResDir;
|
CResourceDirectory* m_cResDir;
|
||||||
|
|
||||||
CResourceDirectory* ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan);
|
CResourceDirectory* ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan);
|
||||||
|
|
||||||
void WriteRsrcSec(BYTE* pbRsrcSec);
|
void WriteRsrcSec(BYTE* pbRsrcSec);
|
||||||
void SetOffsets(CResourceDirectory* resDir, DWORD newResDirAt);
|
void SetOffsets(CResourceDirectory* resDir, DWORD newResDirAt);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef RESOURCE_EDITOR_NO_API
|
#ifdef RESOURCE_EDITOR_NO_API
|
||||||
|
|
||||||
class CResourceDirectory {
|
class CResourceDirectory {
|
||||||
public:
|
public:
|
||||||
CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY prd);
|
CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY prd);
|
||||||
virtual ~CResourceDirectory();
|
virtual ~CResourceDirectory();
|
||||||
|
|
||||||
IMAGE_RESOURCE_DIRECTORY GetInfo();
|
IMAGE_RESOURCE_DIRECTORY GetInfo();
|
||||||
|
|
||||||
CResourceDirectoryEntry* GetEntry(unsigned int i);
|
CResourceDirectoryEntry* GetEntry(unsigned int i);
|
||||||
void AddEntry(CResourceDirectoryEntry* entry);
|
void AddEntry(CResourceDirectoryEntry* entry);
|
||||||
void RemoveEntry(int i);
|
void RemoveEntry(int i);
|
||||||
int CountEntries();
|
int CountEntries();
|
||||||
int Find(char* szName);
|
int Find(char* szName);
|
||||||
int Find(WORD wId);
|
int Find(WORD wId);
|
||||||
|
|
||||||
DWORD GetSize();
|
DWORD GetSize();
|
||||||
|
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
DWORD m_dwWrittenAt;
|
DWORD m_dwWrittenAt;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IMAGE_RESOURCE_DIRECTORY m_rdDir;
|
IMAGE_RESOURCE_DIRECTORY m_rdDir;
|
||||||
vector<CResourceDirectoryEntry*> m_vEntries;
|
vector<CResourceDirectoryEntry*> m_vEntries;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CResourceDirectoryEntry {
|
class CResourceDirectoryEntry {
|
||||||
public:
|
public:
|
||||||
CResourceDirectoryEntry(char* szName, CResourceDirectory* rdSubDir);
|
CResourceDirectoryEntry(char* szName, CResourceDirectory* rdSubDir);
|
||||||
CResourceDirectoryEntry(char* szName, CResourceDataEntry* rdeData);
|
CResourceDirectoryEntry(char* szName, CResourceDataEntry* rdeData);
|
||||||
virtual ~CResourceDirectoryEntry();
|
virtual ~CResourceDirectoryEntry();
|
||||||
|
|
||||||
bool HasName();
|
bool HasName();
|
||||||
char* GetName();
|
char* GetName();
|
||||||
int GetNameLength();
|
int GetNameLength();
|
||||||
|
|
||||||
WORD GetId();
|
WORD GetId();
|
||||||
|
|
||||||
bool IsDataDirectory();
|
bool IsDataDirectory();
|
||||||
CResourceDirectory* GetSubDirectory();
|
CResourceDirectory* GetSubDirectory();
|
||||||
|
|
||||||
CResourceDataEntry* GetDataEntry();
|
CResourceDataEntry* GetDataEntry();
|
||||||
|
|
||||||
DWORD m_dwWrittenAt;
|
DWORD m_dwWrittenAt;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bHasName;
|
bool m_bHasName;
|
||||||
union {
|
union {
|
||||||
char* m_szName;
|
char* m_szName;
|
||||||
WORD m_wId;
|
WORD m_wId;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool m_bIsDataDirectory;
|
bool m_bIsDataDirectory;
|
||||||
union {
|
union {
|
||||||
CResourceDirectory* m_rdSubDir;
|
CResourceDirectory* m_rdSubDir;
|
||||||
CResourceDataEntry* m_rdeData;
|
CResourceDataEntry* m_rdeData;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class CResourceDataEntry {
|
class CResourceDataEntry {
|
||||||
public:
|
public:
|
||||||
CResourceDataEntry(BYTE* pbData, DWORD dwSize, DWORD dwCodePage = 0);
|
CResourceDataEntry(BYTE* pbData, DWORD dwSize, DWORD dwCodePage = 0);
|
||||||
~CResourceDataEntry();
|
~CResourceDataEntry();
|
||||||
|
|
||||||
BYTE* GetData();
|
BYTE* GetData();
|
||||||
|
|
||||||
void SetData(BYTE* pbData, DWORD dwSize);
|
void SetData(BYTE* pbData, DWORD dwSize);
|
||||||
void SetData(BYTE* pbData, DWORD dwSize, DWORD dwCodePage);
|
void SetData(BYTE* pbData, DWORD dwSize, DWORD dwCodePage);
|
||||||
|
|
||||||
DWORD GetSize();
|
DWORD GetSize();
|
||||||
DWORD GetCodePage();
|
DWORD GetCodePage();
|
||||||
|
|
||||||
DWORD m_dwWrittenAt;
|
DWORD m_dwWrittenAt;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BYTE* m_pbData;
|
BYTE* m_pbData;
|
||||||
DWORD m_dwSize;
|
DWORD m_dwSize;
|
||||||
DWORD m_dwCodePage;
|
DWORD m_dwCodePage;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifdef RESOURCE_EDITOR_NO_API
|
#endif // #ifdef RESOURCE_EDITOR_NO_API
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue