MFC vc++ and MySQL database
-
I'm new to MFC VC++ and trying to create a dialog base simple MFC application that display the data contains in MySQL database. Please guide me through this. Thank you.
-
I'm new to MFC VC++ and trying to create a dialog base simple MFC application that display the data contains in MySQL database. Please guide me through this. Thank you.
-
Thank you. Could you please suggest me a good book for MFC vc++.
-
Thank you. Could you please suggest me a good book for MFC vc++.
If you want some books on paper, you can find it on amazon: Windows programming with MFC (or something similar) by Jeff Prosise[^] or MFC Internals: Inside the Microsoft(c) Foundation Class Architecture 1st Edition[^] Also, you cand find a lot of sites that teach you MFC: Programming Windows with MFC, Second Edition[^] formerly, I learned MFC from here: Teach Yourself Visual C++ 6 in 21 Days[^]. If you want a html version of this book, just write me an email. Hope help these docs. And not the last, you can learn MFC from MFC forums :) (This one is one of the best).
-
If you want some books on paper, you can find it on amazon: Windows programming with MFC (or something similar) by Jeff Prosise[^] or MFC Internals: Inside the Microsoft(c) Foundation Class Architecture 1st Edition[^] Also, you cand find a lot of sites that teach you MFC: Programming Windows with MFC, Second Edition[^] formerly, I learned MFC from here: Teach Yourself Visual C++ 6 in 21 Days[^]. If you want a html version of this book, just write me an email. Hope help these docs. And not the last, you can learn MFC from MFC forums :) (This one is one of the best).
Thanks for the help! I'am having trouble understanding why it does this
BOOL CMyApp::InitInstance(){
..........
..........
CWinApp::InitInsatnce();
..........
..........
}Could you please explain why do we need to call two InitInstance() and what is the main reason?
-
Thanks for the help! I'am having trouble understanding why it does this
BOOL CMyApp::InitInstance(){
..........
..........
CWinApp::InitInsatnce();
..........
..........
}Could you please explain why do we need to call two InitInstance() and what is the main reason?
When you derive from a class and override one of its methods, it's common, and sometimes required, to call the base class implementation.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
When you derive from a class and override one of its methods, it's common, and sometimes required, to call the base class implementation.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
Thanks for the reply. :) If you don't mind, could you please elaborate the "sometime required, to call the base class implementation" part with some example.
-
Thanks for the help! I'am having trouble understanding why it does this
BOOL CMyApp::InitInstance(){
..........
..........
CWinApp::InitInsatnce();
..........
..........
}Could you please explain why do we need to call two InitInstance() and what is the main reason?
CMyApp
is derived fromCWinApp
, so the lineCWinApp::InitInsatnce();
simply call the
InitInstance
method from parentCWinApp
, which is the base implementation ofCMyApp::InitInstance()
. "sometime required" sometime is necesarry to call this base implementation, sometime not :) -
CMyApp
is derived fromCWinApp
, so the lineCWinApp::InitInsatnce();
simply call the
InitInstance
method from parentCWinApp
, which is the base implementation ofCMyApp::InitInstance()
. "sometime required" sometime is necesarry to call this base implementation, sometime not :)Thanks :) I am creating a simple MFC application. That has a search box which accept both string and integers to retrieve data from the Mysql database and display in the list box. Please guide me how to create a search box that accepts when entered string and when entered integers.
-
Thanks :) I am creating a simple MFC application. That has a search box which accept both string and integers to retrieve data from the Mysql database and display in the list box. Please guide me how to create a search box that accepts when entered string and when entered integers.
Anything you type into a text box is a string, whether letters, numbers or special characters. If you want to use numeric text as integer values then you need to convert them with one of the conversion methods. See Data Conversion | Microsoft Docs[^].
-
Anything you type into a text box is a string, whether letters, numbers or special characters. If you want to use numeric text as integer values then you need to convert them with one of the conversion methods. See Data Conversion | Microsoft Docs[^].
Thank you for the information :) .
-
Hello, I created an MFC dialog application which is connected to MySql database. I wanted to create a search button/Search query for database. Could you give me some pointers for creating functions for the same which accept string as well as Integers. Thanks. I've read about atoi(), but still having problem. And for displaying the search result, which one is better to use listbox or listcontrol.
-
Hello, I created an MFC dialog application which is connected to MySql database. I wanted to create a search button/Search query for database. Could you give me some pointers for creating functions for the same which accept string as well as Integers. Thanks. I've read about atoi(), but still having problem. And for displaying the search result, which one is better to use listbox or listcontrol.
-
If you have more than one column data to display, I would use CListCtrl[^] or CMFCListCtrl[^] If you want to use an edit to use it for SQL statement, then give more details about what you intend to do there (e.g. sold > 1000 ?)
SQl is not greater than 1000. I wanted to create a simple application first. Like for example.. I have a table with ID(primary Key), Name, DOB...etc columns. What I wanted to create is a search box in the dialog application. when I type the Name in the search box it will display the result in the listbox/list control box. Similarly when I enter the ID in the search box it will return the same.
-
SQl is not greater than 1000. I wanted to create a simple application first. Like for example.. I have a table with ID(primary Key), Name, DOB...etc columns. What I wanted to create is a search box in the dialog application. when I type the Name in the search box it will display the result in the listbox/list control box. Similarly when I enter the ID in the search box it will return the same.
-
Thank you for always helping. I really appreciate the help :) I have created a search function and now it's displaying in the CListCtrl and working the way I wanted. :) I'll try to extend the functionality like if I select the result in the CListCtrl it will take me to another dialog that contains the details of the selected. :) If I have any doubt i'll post it here. Thanks again :)
-
Thank you for always helping. I really appreciate the help :) I have created a search function and now it's displaying in the CListCtrl and working the way I wanted. :) I'll try to extend the functionality like if I select the result in the CListCtrl it will take me to another dialog that contains the details of the selected. :) If I have any doubt i'll post it here. Thanks again :)
-
Hello I'm back again :-D How to get all the data present in a row displayed in the ListCtrl from the database and display those data in the next dialog? For example:- There are name, age,dob..etc in a row.. when I select this row and press the select button.. It will take me to another where all this details will be display. If you don't mind could you please give example. Thanks.
-
Hello I'm back again :-D How to get all the data present in a row displayed in the ListCtrl from the database and display those data in the next dialog? For example:- There are name, age,dob..etc in a row.. when I select this row and press the select button.. It will take me to another where all this details will be display. If you don't mind could you please give example. Thanks.
Then you take all your list control data with CListCtrl::GetItemText[^] and you simply put them into next dialog, just like that:
CNextDlg dlg;
dlg.m_sName = m_ListCtrl.GetItemText(...);
dlg.m_sAge = m_ListCtrl.GetItemText(...);
dlg.m_sDOB = m_ListCtrl.GetItemText(...);
dlg.DoModal(); -
Then you take all your list control data with CListCtrl::GetItemText[^] and you simply put them into next dialog, just like that:
CNextDlg dlg;
dlg.m_sName = m_ListCtrl.GetItemText(...);
dlg.m_sAge = m_ListCtrl.GetItemText(...);
dlg.m_sDOB = m_ListCtrl.GetItemText(...);
dlg.DoModal();Thank you.
void CMyDlg::ResetListControl() {
m_ListControl.DeleteAllItems();
int iNbrOfColumns;
CHeaderCtrl* pHeader = (CHeaderCtrl*)m_ListControl.GetDlgItem(0);
if (pHeader) {
iNbrOfColumns = pHeader->GetItemCount();
}
for (int i = iNbrOfColumns; i >= 0; i--) {
m_ListControl.DeleteColumn(i);
}
}I particularly don't understand this line :
CHeaderCtrl* pHeader = (CHeaderCtrl*)m_ListControl.GetDlgItem(0);
Could you please explain this line of code. Thanks :)