|
I am going to guess that is because when when you reach 2 charcters in length you then call SetWindowText on the edit control, which causes OnEditDateDay to be called again.
|
|
|
|
|
so why doesn't it do this under visual C++ 6 ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Blind luck! You are just ASKING for recursion to occur using SetWindowText on an EN_CHANGE message. A different user recently had a post here with a similar problem, and he DID suffer the recursion.
|
|
|
|
|
i'm not sure i understand you.
you mean SetWindowPos() "re-raises" the EN_CHANGE event ?
I thought to something like that already, but as it didn't do it under VC++6...
is it a new feature of MFC 7 ?
is there a way to work around this ?
thanks,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I said the SetWindowText() causes a regeneration of the EN_CHANGE message.
After all, you did CHANGE the text when you made the call to the SetWindowText(), which results in EN_CHANGE, which within you call SetWindowText() which results in EN_CHANGE, within which you call SetWindowText()... and so on and so on and so on....
It was not written to detect if it is the SAME text or not.
|
|
|
|
|
... BUT it worked great on VC++ 6 !!!!!! did you notice that point ???????
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Yes, I did. I am just implying that INHERENTLY your deisng is flawed. You could put in a blocker variable so you don't reenter your own function and that might help. Then you won't be dependent upon the whims of the development platform
|
|
|
|
|
ok blake,
here is the new code :
void CFactEditorDlg::OnEditDateDay() {
static bAlreadyIn = false;
if (!bAlreadyIn) {
bAlreadyIn = true;
m_peDateDay->GetWindowText(m_strDateDay);
if ((m_strDateDay.GetLength() >= 2) && (m_peDateDay == GetFocus())) {
m_strDateDay = m_strDateDay.Left(2);
m_peDateDay->SetWindowText(m_strDateDay);
m_peDateMonth->SetSel(0, -1);
m_peDateMonth->SetFocus();
}
m_strDateText.Format("%s/%s/%s", m_strDateDay, m_strDateMonth, m_strDateYear);
m_ptDate->SetWindowText(m_strDateText);
bAlreadyIn = false;
}
}
it seems to work quite fine now...
but it still don't understand why it behaves like this only under VC++7...
thanks anyway
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi, does anyone know how to use RLC? Can xplain how it is use? Can it be use to compress a DICOM image into a smaller file size? The purpose of reducing the size is to save space. Can it be done? Please help. Thank you.
|
|
|
|
|
|
In VC++ 6.0 in "ResourceView tab->Version" we find four places where version number has to be changed.
1. FILEVERSION
2. PRODUCTVERSION
and
3. FileVersion
4. ProductVersion
Initially the version number in all these four places will be
1,0,0,1. Now our client requirement is to add intermediate version number i.e. fifth digit (e.g. 1,0,0,1, I2).
I am able to add at "FileVersion" and "ProductVersion" but "FILEVERSON" and "PRODUCTVERSION" are not accepting the fifth digit.
Any solution in this regards will be highly appreciated.
Thanks & Regards,
Neeraj
|
|
|
|
|
There are only four defined places for digits.
The one place you can add stuff all day is to the version information that is stored as a string (FileVersion and ProductVersion).
The one that is a number is only treated as the two WORDS of two DWORDS. So you only get four numbers possible for each of FILEVERSION and PRODUCTVERSION.
What you might consider doing, assuming you don't have 'hundreds' of patches and more than 9 service packs, is to use the lower number as a build identifier and then for the third number use the 10's digits as a patch number and the hundreds or thousands place as a service pack indicator.
For example, 7.11.1.3452
would mean product version 7.11, patch 1, build 3452
7.11.201.35
would mean product version 7.11 service pack 2 patch 1 build 35
7.5.434.99
would mean product version 7.5 service pack 4 patch 34 build 99
This works well with version checking tools as well, because all numebrs are constantly increasing.
Some scheme similar to this might help you out.
|
|
|
|
|
Thanks miller.
I would try with the solution you have provided.
thanx again.
Thanks & Regards,
Neeraj
|
|
|
|
|
I am trying to make an array of function pointers in C++. I have done it sucessfully in C, but I am having a problem with the arrays not giving defined correctly. Syntactically they are correct (or at least according to the compiler they are), but when it comes time to call the function, the arrays show that they are not defined with the functions that i am putting in the arrays.
Here is the declaration for both of my function pointer arrays that are public members of my "CDialog" class in my dialog.h file:
void (*functionarray1[48])();
void (*functionarray2[160])();
That file also houses the declarations for all of the functions I will use with the arrays.
Next I define the 2 arrays in my dialog.cpp file:
void (CDialog::*functionarray1[48])() = {CDialog::function1,CDialog::function2};
void (CDialog::*functionarray2[160])() = {CDialog::function3,CDialog::function4};
So according to this function1 should be in functionarray1[0]. function2 in functionarray1[1], etc... but at runtime when i run a debug the array never gets filled and I get an assertion error
Here is the code to call the function pointer based on an unknown offset value between 00h and 9Fh in "insptr":
CDialog FuncPtr;
UINT insptr = (INSNum / 2);
(FuncPtr.functionarray1[insptr])(); <-----------------
The assertion error happens when the line pointed to executes.
I took this syntax from a paper on C++ array of function pointers
if anyone can help, I'd really appreciate it.
|
|
|
|
|
you should call the functions like
assign the address of the function like:
void (CDlg::*functionarray1[48])() = { &CDlg::function1, &CDlg::function2 };<br />
and call them like:
(FuncPtr.*(functionarray1[insptr]))();<br />
I think that should do it...
Offcourse you should be mindfull to call functions on a CDialog object which has not yet been created (does not have a valid HWND member).
Greetings,
Davy
|
|
|
|
|
it is not as GDavy suggested (the & operator is not necessary when assigneing function addresses, as the name of a function is already its address).
i'd suggest you better assign an instance of the function instead of its name...
i doubt you have a CDialog::function1 in your code...
but if you have a CDialog object instanced (let's say dlg ), then you could pass dlg.Function1 .
better like this ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
it is not as GDavy suggested (the & operator is not necessary when assigneing function addresses, as the name of a function is already its address).
According to ANSI C++[^]it is! VS 2005 even requires it..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
CNewbie wrote:
...at runtime when i run a debug the array never gets filled and I get an assertion error
What is the file/line of the assertion?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Ok FWIW the function that calls the function pointer array is not in the same source file as the function pointer array definition.
The definition:
void (CflowlogDlg::*call_ins_function[48])() = {CflowlogDlg::doins00,CflowlogDlg::doins02,CflowlogDlg::doins04,CflowlogDlg::doins06,CflowlogDlg::doins08,CflowlogDlg::doins0A,CflowlogDlg::doins0C,CflowlogDlg::doins0E};
Is in my dialog1.cpp file and the call:
CflowlogDlg INSFunction;
UINT insptr = (INSNum / 2);
(INSFunction.call_ins_function[insptr])();
is in the dialog2.cpp file
the assertion happens on this line:
(INSFunction.call_ins_function[insptr])();
It should be *call_ins_function, but the compiler wont allow it. Keeps giving me an error C2109: subscript requires array or pointer type
and
error C2597: illegal reference to non-static member 'CflowlogDlg::call_ins_function'
but that is because I am calling from a static member function to a non static member function.
|
|
|
|
|
CNewbie wrote:
the assertion happens on this line:
(INSFunction.call_ins_function[insptr])();
Ok, what assertion is being fired?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Unhandled exception at 0xcccccccc in flowlog.exe: 0xC0000005: Access violation reading location 0xcccccccc.
And as you might have guessed, in the debug at that spot, when I look at what is in the array there is nothing but 0xcccccccc where the function addresses should be.
When I run the program without debug I get the assertion error on line 1002 of wincore.cpp which is:
ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
|
|
|
|
|
CNewbie wrote:
Unhandled exception at 0xcccccccc...
This is the standard value for uninitialized local variables in debug mode. One thing to try is the Debug -> Exceptions options to select breaking (rather than stopping) on the raising of an exception. Then you can catch them directly when they happen.
See here for more.
CNewbie wrote:
When I run the program without debug I get the assertion error on line 1002 of wincore.cpp which is:
This indicates that you are using something other than VC++ v6. Correct?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
yes, I am using VS.NET 2003 or VC++ 7.1 whichever way you want to look at it.
My problem would seem to come down to the fact that I am not defining the array correctly, but I dont see why. Maybe you could see what I am doing wrong.
|
|
|
|
|
CNewbie wrote:
Maybe you could see what I am doing wrong.
Try these articles:
http://www.everything2.com/index.pl?node_id=1509071
http://oopweb.com/CPP/Documents/FunctionPointers/Volume/CCPP/FPT/em_fpt.html
http://mail.nl.linux.org/kernelnewbies/2003-05/msg00447.html
http://www.newty.de/fpt/fpt.html
http://lists.trolltech.com/qt-interest/2004-07/thread00496-0.html
http://publications.gbdirect.co.uk/c_book/chapter5/function_pointers.html
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hey David. i just wanted to update you on my Function Pointer array problem.
I have solved the problem of the arrays not being initialized by filling them within a member thread using an instance of my class as such:
CDialog Function;
Function.call_function[0] = &CDialog::dFunction1;
Function.call_function[1] = &CDialog::dFunction2;
However, these are only Local definitions and would need to be redefined whenver this function is called. So what I would rather do is define them globally, but I have not been able to figure out how to do it without error.
According to books I read. To declare instances (objects) of a class, you do so by including them at the end of the class declaration outside of the ending curly bracket. I did this using the "extern" keyword so the object could be used throughout all of my source files as such:
<br />
class CDialog<br />
{<br />
public:<br />
CDialog(CWnd* pParent = NULL);
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
protected:<br />
virtual BOOL OnInitDialog();<br />
DECLARE_MESSAGE_MAP()<br />
public:<br />
CEdit m_sigstrEdit;<br />
}extern Function;<br />
I then defined the instance globally in one of my source files as such:
CDialog Function;
and it compiled without syntax error, but as soon as the program starts I get an assertion error in Line 26 of afxwin1.inl. If I do not use the "extern" keyword i get linker errors about the object already being defined. So I am at a loss about how to implement this globally.
I really appreciate your help thus far.
|
|
|
|