You could get the inheritance to work by making the interface a template, i.e.
virtual BOOL AddNew(T&)=0;
virtual BOOL Edit(T)=0;
virtual BOOL Delete(T)=0;
virtual BOOL GetList(CArray<T,T>&)=0;
class CPartsTable : public CRecordSet, ICommonTable<part>
class CBoardTable : public CRecordSet, ICommonTable<board>
This would help if you were writing a lot of generic functions that operated on the tables without needing to know the details (for instance an algorithm that deleted every second entry could be written as a template function and would work on both part and board tables). However without knowing why you think the common interface would make your life easier then it is hard to know whether this would help or not.
I have been developing C++ code for many years now, but I am relatively new to MFC. I am going through the book "Programming Windows 95 with MFC" (First Edition) by Jeff Prosise. I have carefully gone through the first seven characters of the book. I also went through all the examples and ran them on my computer with no problems. I have also written three toy MFC applications.
When I get to chapter 8 (which deals with SDI), I cannot get the example to work. I feel that MFC programs written using the SDI model are hard to understand and hard to debug. I do not see the SDI model as a big time saver for the developer. Is it really that good? By the way, if somebody has a small (say under 100 lines) MFC SDI program that they could send me, I would really appreciate it.
The reason I am learning MFC is that I want to write a 1st class Retirement Calculator. Should such a program be written as a SDI application? I am thinking that it should not.
The book you've got is really good for learning MFC.
The question I have is: what version of visual studio are you using to run the examples? I found it easy to compile the examples with VC++ 6.0. I think that the newer versions of VC++ will work but you might get some problems.
As far as the need for SDI and MDI applications: you can usually get by just using dialog based apps. However, the SDI apps provide a better design framework. This is especially true if you want to distribute your presentation code from you data handling code. The SDI framework also makes it easy to save your application's data.
One thing that might help you is to try deriving the View class from CFormView. This has the effect of combining the SDI Document/View framework with the ease of Dialog programming. (The App wizard allows you to change the View base class in the last step.)
You added an extra semicolon, but the statement does make sense. It should be:
weekly wages = 12.75*40 + ( (40>40) ? (12.75*40/2) : 0 );
Now, 12.75*40 = 510 and 40 > 40 is false so we have
weekly wages = 510 + 0
weekly wages = 510
I am using API RegEnumValue() to retrieve the regkey's values. However, for DWORD and BINARY datatype it returns some garbage or junk characters in buffer(for the values which has above datatypes).. do I need to typecast this returned data to make it readable in eng ??? if yes how shud I do that, any pointers ?
Thanks in advance.
The Registry Key Value Type is 'REG_DWORD' and 'REG_BINARY'.
You can create any new key in registry and then create new key values for it which has datatype as above(Selecting 'DWORD Value' and 'BINARY Value') and plz have a look at datavalue to see how data looks like.. For 'REG_SZ' values I am getting data in buffer properly.
Sample Code : (Assume regkey handle and open proc is passing and I am able to access it thru another APIs)
// Enumerate the key values.
for (i=0, retCode=ERROR_SUCCESS; i<dwvalues;>
retCode = RegEnumValue(
hkScanKey, // Handle to an open registry key
i, // The index of the value to be retrieved
pszRegValueName, // Pointer to a buffer that receives the name of the value
&dwRegValNameLen, // Size of the buffer pointed to by the 'pszRegValueName'
NULL, // Reserved
&dwRegValType, // Type of data
(LPBYTE)pszRegValData, // Data for the value
&dwRegValLen); // Size of Data
so whenever it finds any value with datatype 'REG_DWORD' or 'REG_BINARY' , the buffer 'pszRegValData' has some garbage value or unreadble val...
Are you aware that RegEnumValue returns a 32 bit integer whenever it finds a REG_DWORD? It doesn't return the string representation of the number. The same applies to REG_BINARY. Of course I'm only guessing, since you missed posting input & output value samples.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
I am new to this. I have made an activex edit control that deals only with floating point numbers. It works perfect in the test container, but I cannot get it to work at all in my application. After inserting it the software added the class to my project. It compiles without error or warning, but I cannot update data to the control or read anything frrom it into my application. Any advice would be appreciated.
Hello Bob, when you are experiencing errors saying things like "it doesn't work","it breaks","it dies" is not appropriate. You need to post actual error information. GetLastError() numbers, Exception text, assert information like the line of code containing the assert, etc. Hopefully you get the idea.
or the best way to debug this program.
I don't know what that means. Debugging is somewhat universal, you break into the execution at a line of code and analyze the state of the process using debugger tools (call stack, memory values).