|
The best way is to replace QandA structure with QandA class. After that, you should write serialization method for your class.
The another way (which I prefer) is using XML file for storing structured data. It is more complex but it is very powerful.
Sincerely Yours,
RadioShark
|
|
|
|
|
RadioShark wrote:
The best way is to replace QandA structure with QandA class
You can write functions for a struct just as well: A class differs from a struct only in the fact that all class members are private by default whereas all struct members are publich by default (but private: and public: work in both!).
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
I would urge you to write your own class serialisation, preferably into XML. In anything not entirly trivial, you need some way of versioning, and XML makes this easier.
You can override the MFC-calls if you like, but you will most probably need to write anything beneath it from scratch. You can use quite a lot of articles on CP about XML and serialisation
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
I have a dialog based application that has a tree control on it and when clicked on any item in the tree another dialog is opened that has two tab pages. I wanted to change the behavious of the application so that is any argument is passed to the application, instead of the dialog with tree opens, the second dialog with tap pages should open. But when i try to call the CTabbedDialog.DoModal() and exception occurs.
Any thoughts why this exception is occuring?
Tariq
|
|
|
|
|
Tariq878 wrote:
But when i try to call the CTabbedDialog.DoModal() and exception occurs
What is the exception? If you are running debug, then the debugger is more than likely going to take you to the code which is throwing the exception.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
hi..
ia m building an application to pass data retrived from DB using MS SQL v.7 and VC++....
No error in the compilation...
but it still not working ..it sould return as response from the target page an error code that detrmine the status of my message (0 mean Message Accepted,otherwise error)...
i have to send it in the following format
http://111.111.111.111:2222/ABC.aspx?user=xxx&pass=ccc
this the code......
--------------------------------------------------------
{
UpdateData(true);
DWORD dwRet = 0;
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
CString strFormData ;
CString error_no;
//CString strHeaders = _T("Accept: text/plain, text/html, text/*\r\n");
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded\r\n");
CDatabase db_mssql;
CString sqlS,sqlU,sqlI,m_txt;
CRecordset *m_rec = new CRecordset ( &db_mssql ) ;
CHttpConnection* pConnection;
BOOL F2=false;
CString infostr ;
SYSTEMTIME *ptime = new SYSTEMTIME ;
CInternetSession session("MyConn");
int nport=1427;
try
{
pConnection =session.GetHttpConnection(m_EIP+":2222");
//pConnection =session.GetHttpConnection(m_EIP,(INTERNET_PORT) nport);
}
catch(CInternetException* pEx)
{
MessageBox("Error in Connection");
pEx->ReportError();
pEx->Delete();
OnOK();
}
pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET,"/ABC.aspx");
MessageBox(pFile->GetFileURL());
pFile->AddRequestHeaders(strHeaders);
//........statemets to retrive the data from DB
m_txt.Format("%s %s",m_EUN,m_EUN);
strFormData = _T("user="+m_EUN+"&pass="+m_EPW");
F2=pFile->SendRequest(NULL,0,(LPVOID)(LPCTSTR)strFormData,strFormData.GetLength());
if (pFile->QueryInfo(HTTP_QUERY_FLAG_NUMBER, ptime) ==0 )
{
m_DATA.AddString(_T(pFile->GetFileURL())+"?"+strFormData);
m_DUN=_T(pFile->GetFileURL())+strFormData;
m_rec -> MoveNext( ) ;
}
else
{
m_DATA.AddString("!!!!!!!! ERORR !!!!!!!!!!!");
}
************************
Please any piece of information to help me I need it argent.....
|
|
|
|
|
Hello,
First off, let me say that I'm fairly new to ActiveX controls, so I'm probably missing something obvious, but here's the situation.
I'm trying to use the Microsoft Office Spreadsheet 11.0 control in a dialog application. I've gone through all of the steps to get the class added to my project. I found the control in the Registered ActiveX Controls folder and selected it, I left the default classes selected and it appeared to create all of the wrapper classes without any major hiccups.
The problem comes when I try to compile the program. I get many errors (around 35) which read:
error C2440: 'type cast' : cannot convert from 'struct IDispatch *' to 'class CSpreadsheet'
No constructor could take the source type, or constructor overload resolution was ambiguous
The errors occur in various classes, but invariably the function causing the error has this structure:
CSpreadsheet CXmlMaps::GetApplication()<br />
{<br />
LPDISPATCH pDispatch;<br />
InvokeHelper(0x60020004, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);<br />
return CSpreadsheet(pDispatch);<br />
}
The problem seems to be calling the CSpreadsheet (one of the wrapper classes created by the ActiveX wizard) constructor, but CSpreadsheet doesn't appear to have any constructors defined. It's derived from CWnd, so I don't think there are any suitable constructors there either. I've been able to successfully use some of the simpler ActiveX controls (such as the Calendar control), but it seems to hang up on this one for some reason. Any insight would be helpful. I hope I've explained it well enough.
Thanks!
JD
|
|
|
|
|
I'm using this code to draw on a dialog box and had a quick question.
CClientDC dc (this);
CRect rect;
GetClientRect (&rect);
dc.SetBkMode (TRANSPARENT);
CFont font;
font.CreatePointFont (100, _T ("Arial"));
CFont* pOldFont = dc.SelectObject (&font);
CString str (_T ("Hello World"));
dc.TextOut (rect.Width () - 100, rect.Height () - 200, str);
dc.SelectObject (pOldFont); I just want to know if this is the best way to write on a dialog without using a control of any type? I thought of another question that'd I'd like to ask. If I wanted to print text next to a control on the dialog (say an Edit control) how would I get it's coordinates? I've tried using GetClientRect and GetWindowRect (both with and without using ScreenToClient), but neither of them gets the right position of the window. Any help is appreciated. Thanks.
- Aaron
|
|
|
|
|
I am developing a dialog app in Vc++ that uses a Property sheet and adds 1 page to it . the page has 2 grid controls(specifically #grid) as its main item and also a Child Dialog that it creates .
Here is the heirarchy
MainDialog (Memory allocation and deallocation, calls to the COM server)
PropertySheet , ComServer
PropertyPage (grid controls , XML parsing using MSXML & memory allocation and deallocation)
ChildDialog (painting the window)
Also there is 500 bytes of memory allocation and the same is being deallocated . I need to do this 2 times .
I do this using calls to "new " and make sure that i delete the array when not needed .
Plus i have some interaction with a COM server in my code .
Finally in one of the child windows created by the page , i do some custom drawing by implenting code in the OnPaint method of that Dialog class .
out of curiosity i was monitoring my app's memory usage in the Windows task manager and found that
During startup the mem size was around
2500 k
After i invoke a CFileDialog in the code and open a file , (perform some XML parsing using MSXML) the mem usage was
8000 k
and then it keeps on increasing . till it gets stable around 12000 k .
I am wondering why my app's mem usage is so high and shouldnt it change when i delallocate memory ?
Is this a true measure of my apps performance ?
I need to have some pointers(no pun intended) whether there is some critical performance issue here !
|
|
|
|
|
i have 2 dialogs(2 classes) set up as 2 tabs on another dialog in an SDI application, each tab has edit box controls and such... how can i share data between these 2 tabs or share members data between these 2 classes?
what i am trying to do is get the filename from the first class (in a cedit control or a member variable) when i am on the second tab
thanks for helping this newbie
|
|
|
|
|
Cant u have this data as part of(member variable) the other dialog that holds these 2 dialogs ?
or declare it in CMainFrame and then declare it as extern , wherever u need to use it !
|
|
|
|
|
well, i can set a global var and solve my problem, but im wondering how to share data between 2 dialog classes or perhaps between a view and a dialog
thanks
|
|
|
|
|
Can't you make the datas members of your CDoc-derived class? Or, if that violates your application logic, have a data variable in the common parent of the two dialogs. Dialogs should IMHO never hold any data, just display and validate it. The data is to be stored in the document.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
In this line of code :" WSAStartup(0x0101,&wsd) " can somebody tell me what the " 0x0101 " stands for ??
Regards,
Kapil
|
|
|
|
|
|
kpatry wrote:
...can somebody tell me what the " 0x0101 " stands for ??
In general, or in the context of the WSAStartup() function?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Give me both.. in general and in the context of WSAStartup()
cheers,
Kapil
|
|
|
|
|
In general, it is the base-16 representation of 257. In the context of WSAStartup() , it is highest version of Windows Sockets support that the caller can use, with the high-order byte specifying the minor version (revision) number, and the low-order byte specifying the major version number.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
LRESULT CT71View::OnGoodbye(WPARAM wParam, LPARAM lParam)
{
// message received in response to modeless dialog OK
// and Cancel buttons
TRACE("CT71View::OnGoodbye %x, %lx\n", wParam, lParam);
TRACE("Dialog edit1 contents = %s\n",
(const char*) m_pDlg->m_strEdit1);
//m_strEdit1 ismembervariable of the edit control in dialog control
m_pDlg->DestroyWindow();
return 0L;
}
onGoodbye the message function is written by the user herself.
i want to know :first,What is the meanin of "LRESULT",why to add it?when to use it?
second,why "return 0L",Why not "return 0" only?
thank you!
|
|
|
|
|
Microsoft code is lousy with terrible macros and typedefs. LRESULT is a return code, and obviously the L stands for long, hence the return value also being explicitly made a long. Google gave me this:
http://root.cern.ch/lxr/ident?i=LRESULT[^]
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Just curious all the tutorials i have came upon doesn't address this issue. How do you append to a file using serialization? I have a database (text file) dialog program i made that will write to a file and read from the file. However it overwrites preexisting data. Help on this would be great. I know fsopen has +a is there anything like that in serialization?
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
Appending with serialisation makes no sense. The point of serialisation is that you have a data structure somewhere in memory that you want to save to disk and read back sometime later. The serialisation process doesn't just save the data, it saves metadata to make it possible to read both the data and the data structure back later. Deserialisation recreates your datastructure (with all the pointers from high level objects to lower level objects intact). Thus, the only way that appending makes sense is to 'append' an object of some kind to the original structure in memory. Appending data to a 'file' that contains serialisation data without reference to the original data will result in 'orphaned' objects existing in your memory - objects you can't reference because your original data structure has no idea they exist.
Rob Manderson
Colin Davies wrote: I'm sure Americans could use more of it, and thus reduce the world supply faster. This of course would be good, because the faster we run out globally, the less chance of pollution there will be. (Talking about the price of petrol) The Soapbox, March 5 2004
|
|
|
|
|
HI all;
I am building an application which should have a tab control on a CDialogBar. Visual C++ gladly added the dockable dialog bar for me but i could not figure out where to put the code to create the tab control since the OnInitDialog() function is simply ineffective. Can anybody please help out. I need to know where i should place my code to create the TAb control on the dialogbar.
I badly need this guys;
THanks
Krugger
|
|
|
|
|
Let's assume you're trying to create the object using DDX. In other words, you've embedded an object of the correct type in your class definition and written a DoDataExchange function with the appropriate DDX_Control() call.
It might look like this (simplified).
Header file.
class CMyDialogBar : public CDialogBar
{
public:
CMyTabbedControl m_tabControl;
virtual void DoDataExchange(CDataExchange* pDX);
virtual void OnInitDialog();
};
and your implementation file looks like this.
void CMyDialogBar::DoDataExchange(CDataExchange* pDX)
{
CDialogBar::DoDataExchange(pDX);
DDX_Control(pDX, IDC_MYTABCONTROL, m_tabControl);
}
void CMyDialogBar::OnInitDialog()
{
CDialogBar::OnInitDialog();
return TRUE;
}
And yet it doesn't work. As you've noticed, OnInitDialog() isn't called for a DialogBar. The solution I found was to add a function Initialise() to the DialogBar derived class and call it once I knew the dialog bar had been created.
void CMyDialogBar::Initialise()
{
UpdateData(FALSE);
}
Yes, it's that simple. Just call UpdateData() (make sure the call occurs before any code that tries to use the TabControl) and the control will be created.
Rob Manderson
Colin Davies wrote: I'm sure Americans could use more of it, and thus reduce the world supply faster. This of course would be good, because the faster we run out globally, the less chance of pollution there will be. (Talking about the price of petrol) The Soapbox, March 5 2004
|
|
|
|
|