|
I am trying to make the text bold in a CStatic. I wrote the following code, Can anyone see where i am going wrong.
CFont *M_titleFont is a member varible.
Code Snippet, from oninitdialog:
LOGFONT lf;
m_titleFont= GetDlgItem(IDC_TITLE)->GetFont();
m_titleFont->GetLogFont(&lf);
lf.lfWeight = 700; //Set Bold
m_titleFont->CreateFontIndirect(&lf);
Cheers
Rich
|
|
|
|
|
The problem is in the GetFont() call. MFC wrapps the HFONT in a temporary CFont object and when you call the CreateFontIndirect() a new HFONT is created in the temporary object and never gets back to the control. All you have to do is tell the control to use the new font, GetDlgItem( IDC_TITLE )->SetFont( m_titleFont );
|
|
|
|
|
Cheers! That was driving me up the wall!
|
|
|
|
|
How can I obtain the ip address of the machine using c++.
Currently I've been using gethostbyname & getcomputername but this returns the DNS, I want the IP.
Cheers
Gerry.
|
|
|
|
|
You've got the answer on the excellent Warren Young's Winsock Programmer's FAQ, section 6.5
Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you, this did the job.
Gerry.
|
|
|
|
|
I want a wrap class for parse regular expression ,can u help me?
Thank in advance!
Please pardon my weak English!
|
|
|
|
|
You might want to take a look at the very C++-oriented John Maddock's Regex++ library
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Depends on the compiler you're using.
If it's a 32-bit compiler (MSVC++ 2 or up for instance),
it would probably be 4.
It if were a 16-bit compiler, it would be 2.
Check it yourself:
printf("Size of UINT is %d BYTES\n", sizeof (UINT));
|
|
|
|
|
|
If I use Microsoft Agent 2.0 ActiveX or com Interface for programming,
(Microsoft Visual C++6.0)
how can I add a button or CheckList on WordBalloon like Microsoft Office Assistants?
if you know,please mail to:liuchuan2901@sina.com.
Thank you !
|
|
|
|
|
I’m writing an MFC Doc/View (SDI) application with database support (DAO).
In CMyDoc class I put a member variable CmyDaoDB* m_MyDaoDB and some function to add/delete data to/from Database.
On the view I build a listbox control in wich I need to put the entire recordset (say Customers).
I’d like to buil a member function in the CmyDoc class that return the list of Customer to view. But how?
I think that the only solution is to access directly to CmyDaoDB from the view to get the customers:
while (!m_MyDaoDb->IsEOF())
{
/* Put the record in the list control */
m_MyDaoDb->MoveNext()
}
Is there a better way to get that list? (I mean more OO)
|
|
|
|
|
You have the basic idea. The way that I do it is to pass the list control to the Doc and have the doc populate the list, that way the View doesn't need to know anything about the database. Something like this:
CDoc::AddCustomers( CListCtrl* pList )
{
// Reset the list control content
pList->DeleteAllItems();
// I'm assuming that you somehow get a CDaoRecordset for the Customer table
// and not accessing the database object directly.
m_MyDaoDB->MoveFirst();
while( m_MyDaoDB->IsEOF() != 0 )
{
// Add the record to the list
m_MyDaoDB->MoveNext();
}
}
Don't know if this is a better OO way, but the Doc should know about the data, and the view handles the UI. I like to keep access to the data in the Doc and the View handles the display and user interaction.
|
|
|
|
|
Is there a better way to get that list? (I mean more OO)
"More OO" solution is to create a public member in your doc class which takes CListBox reference as an argument and fills the window with database contents:
void CYourDoc::FillListBox(CListBox &lbx)
{
while (!m_MyDaoDb->IsEOF())
{
int idx = lbx.AddString(...);
lbx.SetItemData(idx, ...);
m_MyDaoDb->MoveNext();
}
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How can I set CRichEditCtrl not to make automatic wrap (word break)?
|
|
|
|
|
Enable Auto HScroll.
/Per
|
|
|
|
|
Enable Auto HScroll.
/Per
|
|
|
|
|
I want to save in file the system time in format of:
____________
DWORD year
DWORD month
DWORD day
DWORD hour
DWORD minute
DWORD second
______________
Which func would give me this or how can I to extract only this data from the func: GetSystemTime() ??????????
|
|
|
|
|
Have you tried it yourself yet? GetSystemTime() will give you WORDs. If you're stuck, post your code so we can see what you've tried.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
|
What is the difficulty?
Just copy the values you need and convert them to DWORDs.
I would have understand it if GetSystemTime gave you 6 WORDs and you wanted 8.
|
|
|
|
|
OK, I have made an app that parses a bunch of files and I have all the data
stored into various arrays.
I would like to be able to store this information into an Access database.
I have no clue where to start on accessing Access and writing information to
a database though. If anyone could help me out and point me in the right
direction I'd be greatful!
Adam
cabadam@houston.rr.com
|
|
|
|
|
If you use MFC, CDaoDatabase and CDaoRecordset may help you. With the class wizard add a new CMyDaoRecordset and map the database fields into class members. You find examples on MSDN.
|
|
|
|
|
OK, but it gives me 'unrecognized database format' when creating the class and selecting which database I want to use... I am using Access 2000. Will that not work?
Adam
cabadam@houston.rr.com
|
|
|
|