|
I did a test for size change of MFC exe.
When a line of code or a small resource bitmap is deleted or added in the exe program, exe size keeps unchanged.
So I guess exe is aligned in size - similar to class aligned in size by its members.
Do you think it is correct or have more info about this?
|
|
|
|
|
Yes. By default applications are aligned on 512 byte boundaries. (Due to a quirk in the Windows 98 paging mechanism, before Visual Studio 2008, Win32 applications were aligned on 4096 byte boundaries unless you added the /OPT:NOWIN98 switch to the linker. The linker for VS 2008 and later now uses 512 alignment by default.)
|
|
|
|
|
Hi Joe,
The /OPT:NOWIN98 should be sdded at which place of project settings? How?
|
|
|
|
|
In Visual Studio 2003/2005 it's in Properties|Linker|Optimization. Select "No (/OPT:NOWIN98) Only set this for Release mode.
In Visual Studio 2008, this will generate a warning, so it should be set to Default.
In Visual C++ 6.0, go to Settings|Link. In the Project Options Edit control, go to end and manually add "/OPT:NOWIN98"
|
|
|
|
|
Joe, thanks,
The min change is from 4096 to 512 bytes now.
cheers.
|
|
|
|
|
How are you looking at the size? If you're looking at the Windows Explorer, it only shows size in "cluster" increments.
Open a command window and use the "dir" command to see the actual files size at the byte level.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
krmed wrote: Open a command window and use the "dir" command to see the actual files size at the byte level.
Better still, right click in Explorer and select Properties .
|
|
|
|
|
krmed wrote: If you're looking at the Windows Explorer, it only shows size in "cluster" increments.
It also shows the file's actual size, not just its size on disk.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Unless you have a different Windows Explorer than I do, it only shows one size - and it's not the actual size.
But perhaps you were responding to the idea of looking at the properties?
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
krmed wrote: But perhaps you were responding to the idea of looking at the properties?
Correct.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I've recently started using the XP styles look by using a manifest on an MFC application, and overall it looks fine.
The problem is a specific screen I have, which uses quite a few Comboboxes and Edit boxes. Everything works basically as before, only much much slower than it used to. When I change back and remove the manifest, everything changes back to regular speed.
Can anyone help me solve this speed issue? The hope is to be able to retain the XP-style look while not slowing down so significantly. Any help would be appreciated, thank you.
|
|
|
|
|
Using VC6 & MFC
I have dialog with an edit box for the user to enter an integer number. I have set the number property in the resource sheet (ES_NUMBER) to handle entering numbers. Now everything is fine in that I can enter numbers and catch the new member value in my OnChangeEdit......() function.
However !
If you have say "3" in the edit box and you want to change it to say "4", a legitimate way for the user to do this is to press backspace to delete the "3" character and type "4" to set the new value.
But if you do this I get a message box saying "Please enter a positive integer." on using the backspace key switfly followed by an exception and program crash. Not very elegant !!
I have tried to intercept this with break points in OnChangeEdit or DoDataExchange of the dialog but it never gets there before the message box pops up.
Appart from priseing out the backspace key from the keyboard is there way to get around this ? It looks to my like a glaring whole in the default way MFC works. Other more learned people than me must have hit this plenty of times ?
Neil
|
|
|
|
|
Have you added any filters or made any unusual changes? I have number edit-controls as well but I don't get message boxes nor exceptions.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I have a spin control associated with it via the AUTO_BUDDY mechanisam. I have used SetRange in OnInitDialog() for the spin control.
|
|
|
|
|
Neil Urquhart wrote: I have used SetRange...
With what values?
I tried to reproduce this behavior but it works fine for me. I added one edit control and one spin control. I added the ES_NUMBER style to the edit control. I added the UDS_SETBUDDYINT and UDS_AUTOBUDDY styles to the spin control. I used 1,5 as the range. You must have something else in place that is interfering.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
 Having produced a reduced version of my dialog I have tracked to source of the exception.
It seems using UpdateData(FALSE) in the OnChangeEdit1() is the source of the problem. Without it I don't get the exception. Its probably not required anyhow. I don't understand why it only causes the problem when the string in the edit control is empty.
This is the code which causes the exception :
#include "stdafx.h"
#include "CEditTest.h"
#include "CEditTestDlg.h"
#define IDT_UPDATE 1000
#define UPDATE_INTERVAL 1000
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CCEditTestDlg::CCEditTestDlg(CWnd* pParent )
: CDialog(CCEditTestDlg::IDD, pParent)
{
m_edit1 = 0;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
bDlgInitDone = FALSE ;
}
void CCEditTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SPIN1, m_spin1);
DDX_Text(pDX, IDC_EDIT1, m_edit1);
}
BEGIN_MESSAGE_MAP(CCEditTestDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
END_MESSAGE_MAP()
BOOL CCEditTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
m_spin1.SetRange(1,99) ;
SetTimer(IDT_UPDATE, UPDATE_INTERVAL, NULL) ;
bDlgInitDone = TRUE ;
return TRUE;
}
void CCEditTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CCEditTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CCEditTestDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCEditTestDlg::OnTimer(UINT nIDEvent)
{
switch (nIDEvent) {
case IDT_UPDATE :
KillTimer(nIDEvent) ;
UpdateData(TRUE) ;
UpdateData(FALSE) ;
SetTimer(IDT_UPDATE, UPDATE_INTERVAL, NULL) ;
break ;
default :
CDialog::OnTimer(nIDEvent);
}
}
void CCEditTestDlg::OnChangeEdit1()
{
if(bDlgInitDone) UpdateData(TRUE) ;
TRACE("value is %d\n", m_edit1) ;
}
|
|
|
|
|
Neil Urquhart wrote: It seems using UpdateData(FALSE) in the OnChangeEdit1() is the source of the problem.
UpdateData() is rarely, if ever, necessary. Remove it, use a CEdit control variable, and your troubles will cease.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
It seems if you don't use UpdateData(TRUE) in your OnChangeEdit.....() function then the member variable added to the control is not updated.
Ie the user will perhaps change a value from 1 to 12 in the integer CEdit box and without UpdateData(TRUE) the m_edit1 caught in the OnChangeEdit...() function will be 1 and not 12.
Also it seems the OnChangeEdit...() function can be called prior to OnInitDialog() and if UpdateData() is called at this time then problems will result. I protect my code against this by using a flag to indicate that the OnInitDialog() function had finished.
BOOL CCEditTestDlg::OnInitDialog()<br />
{<br />
CDialog::OnInitDialog();<br />
<br />
<br />
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);<br />
ASSERT(IDM_ABOUTBOX < 0xF000);<br />
<br />
CMenu* pSysMenu = GetSystemMenu(FALSE);<br />
if (pSysMenu != NULL)<br />
{<br />
CString strAboutMenu;<br />
strAboutMenu.LoadString(IDS_ABOUTBOX);<br />
if (!strAboutMenu.IsEmpty())<br />
{<br />
pSysMenu->AppendMenu(MF_SEPARATOR);<br />
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);<br />
}<br />
}<br />
<br />
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
<br />
<br />
...<br />
...<br />
...<br />
<br />
bDlgInitDone = TRUE ;<br />
<br />
<br />
return TRUE;
}<br />
void CCEditTestDlg::OnChangeEdit1() <br />
{<br />
<br />
<br />
if(bDlgInitDone) UpdateData(TRUE) ;<br />
<br />
TRACE("value is %d\n", m_edit1) ;<br />
<br />
<br />
}
|
|
|
|
|
Neil Urquhart wrote: It seems if you don't use UpdateData(TRUE) in your OnChangeEdit.....() function then the member variable added to the control is not updated.
That's what GetWindowText() is for.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
 I have found a fix !
It seems in my break point testing in DoDataExchange I had put it after the DDX_Text function. It seems that the "Please enter a positive integer." message come from inside the relvant DDX_Text function somewhere.
I was therefore able to fix the problem by intercepting the value coming from CEdit at the top of DoDataExchange with a bit of validation code. The curcial test you need is to check the text in CEdit to see if the user deleted it all, even though it uses numbers. If he did delete it all I set the text and memver variable to a default value.
I also add validation code for my values range.
void CArtConDlg::DoDataExchange(CDataExchange* pDX)
{
CEdit *cEd ;
CString csTxt ;
cEd = (CEdit*)GetDlgItem(IDC_EDIT_DMINTERVAL) ;
cEd->GetWindowText(csTxt) ;
if(csTxt.IsEmpty()) {
m_iDmInterval = MIN_DMINTERVAL ;
csTxt.Format("%d", m_iDmInterval) ;
cEd->SetWindowText((LPCSTR)csTxt) ;
} else if(m_iDmInterval < MIN_DMINTERVAL) {
m_iDmInterval = MIN_DMINTERVAL ;
} else if(m_iDmInterval > MAX_DMINTERVAL) {
m_iDmInterval = MAX_DMINTERVAL ;
}
cEd = (CEdit*)GetDlgItem(IDC_EDIT_ONESHOTHOURS) ;
cEd->GetWindowText(csTxt) ;
if(csTxt.IsEmpty()) {
m_iTmrOneShotHours = MIN_TMRONESHOTHOURS ;
csTxt.Format("%d", m_iTmrOneShotHours) ;
cEd->SetWindowText((LPCSTR)csTxt) ;
} else if(m_iTmrOneShotHours < MIN_TMRONESHOTHOURS) {
m_iTmrOneShotHours = MIN_TMRONESHOTHOURS ;
} else if(m_iTmrOneShotHours > MAX_TMRONESHOTHOURS) {
m_iTmrOneShotHours = MAX_TMRONESHOTHOURS ;
}
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SPIN_ONESHOTHOURS, m_ctrlSpinOneShotHours);
DDX_Control(pDX, IDC_SPIN_DMINTERVAL, m_ctrlSpinDmInterval);
DDX_Control(pDX, IDC_TIMERONOFF, m_ctrlTimerOn);
DDX_Control(pDX, IDC_LIGHTSENSORDAYNIGHT, m_ctrlLightSensor);
DDX_Control(pDX, IDC_ARTWORK, m_ctrlArtworkOn);
DDX_Control(pDX, IDC_EDITMODELAP, m_ctrlEditModeLap);
DDX_Control(pDX, IDC_COMMSALIVE, m_ctrlCommsAlive);
DDX_Control(pDX, IDC_EDIT_LUMIN, m_ctrlEditLumin);
DDX_Control(pDX, IDC_SLIDER_LUMIN, m_ctrlSliderLumin);
DDX_Control(pDX, IDC_LIST_FADERS, m_ctrlListFaders);
DDX_Text(pDX, IDC_EDIT_FADERUPDATETIME, m_csFaderUpdateTime);
DDX_Text(pDX, IDC_EDIT_TOTAL_AMPS, m_csTotalAmps);
DDX_Text(pDX, IDC_EDIT_TOTAL_AMPSPCT, m_csTotalAmpsPct);
DDX_Radio(pDX, IDC_RADIO_MODEON, m_iTimerMode);
DDX_Check(pDX, IDC_CHECK_TMRONESHOTONEN, m_bTmrOneShotEn);
DDX_Check(pDX, IDC_CHECK_TMRFRI, m_bTmrFri);
DDX_Check(pDX, IDC_CHECK_TMRMON, m_bTmrMon);
DDX_Check(pDX, IDC_CHECK_TMRSAT, m_bTmrSat);
DDX_Check(pDX, IDC_CHECK_TMRSUN, m_bTmrSun);
DDX_Check(pDX, IDC_CHECK_TMRTHU, m_bTmrThu);
DDX_Check(pDX, IDC_CHECK_TMRTUE, m_bTmrTue);
DDX_Check(pDX, IDC_CHECK_TMRWED, m_bTmrWed);
DDX_Text(pDX, IDC_EDIT_ONESHOTENDENDDATETIME, m_csOneShotEndDateTime);
DDX_Radio(pDX, IDC_RADIO_DMCYCLE, m_iDisplayMode);
DDX_Text(pDX, IDC_EDIT_DMINTERVAL, m_iDmInterval);
DDX_Text(pDX, IDC_EDIT_DMFILE, m_csDmFile);
DDV_MaxChars(pDX, m_csDmFile, 32);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_START, m_ctTmrStart);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_FINISH, m_ctTmrFinish);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_ONESHOTSTART, m_ctTmrOneShotStart);
DDX_Text(pDX, IDC_EDIT_ONESHOTHOURS, m_iTmrOneShotHours);
DDX_Radio(pDX, IDC_RADIO_DMPERIODMIN, m_iDmIntervalUnits);
DDX_Text(pDX, IDC_EDIT_DMLASTFILE, m_csDmLastFile);
DDX_Text(pDX, IDC_EDIT_DMLASTUPDATE, m_csDmLastFileUpdated);
DDX_Radio(pDX, IDC_RADIO_LSORAUTO, m_iLightSensorOverRide);
DDX_Slider(pDX, IDC_SLIDER_LUMIN, m_iSliderLumin);
DDX_Text(pDX, IDC_EDIT_LUMIN, m_iEditLumin);
DDX_Text(pDX, IDC_EDIT_FILE, m_csEditFile);
}
|
|
|
|
|
Hi all,
do you know any good barcode generator lib? I've found some, including some good CP articles, but they are not enough as I need the maximum number of type of barcodes to cover: 1D and 2D.
Any option is welcome: paid or free&opensource.
thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
If you prepare to print barcode, you have to buy barcode fonts - only fonts can be printed clearly enough for scanner.
barcode fonts are code generators.
|
|
|
|
|
I'm using DLSoft's barcodes for .NET ([^]) which is adequate.
They cover a wide range of 1D and 2D barcodes, and the technical support is adequate.
|
|
|
|
|
Hi
Why we are using Pure virtual function and Which situation we used Pure virtual function ??
Thanks
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|