|
|
1 more question... For VS2005, whenever i'm working with a string say,
AfxMessageBox(_T("Something"));
I would have to put a '_T' before the string. Is there an easier way to work with strings without having to use '_T'?
|
|
|
|
|
_T is a macro that resolves to a unicode string on unicode builds (_UNICODE/UNICODE defined) and mbcs on mbcs builds. Eg. _T("Something") is L"Something" on unicode builds and "Something" on mbcs builds (You put L in front of a string to indicate a unicode string). It would be preferable to just get used to using the _T macro and all the TCHAR functions.
|
|
|
|
|
when I add a project to the current workspace, a warning message box pops up which showes "A project with the same name as the selected project already exists in the current workspace.". But actually my workspace doesn't have the project. somebody knows why? and how to figure out...
It is urgent! I am waiting online.
I will appreciate your answer.
kuoo
|
|
|
|
|
Oh,Maybe it is because the two project have the same name. but how to change the the project name in VC++ 6.0
kudoo
|
|
|
|
|
old_dustman wrote: how to change the the project name in VC++ 6.0
Two options:
1) Manually modify project files (.dsw, .dsp, .rc, etc)
2) Create a new project and copy over source files from the old project. Be sure to use the same project settings (easier to say than to do).
Best,
Jun
|
|
|
|
|
codes:
<br />
m_imagelist1.Create(16, 16, ILC_COLOR32, 1, 1);<br />
CBitmap *bmp=new CBitmap;<br />
CString str;<br />
for(int i=1; i<109; i++)<br />
{<br />
str.Format("qqface\\%d_m.bmp", i);<br />
bmp->m_hObject=(HBITMAP)LoadImage<br />
(NULL, str, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);<br />
<br />
m_imagelist1.Add(bmp, RGB(0, 0, 0));<br />
m_treeQunimage.Add(bmp, RGB(0, 0, 0));<br />
<br />
}<br />
delete bmp; <br />
m_List1.SetImageList(&m_imagelist2, LVSIL_SMALL);<br />
m_List1.DeleteAllItems();<br />
int nItem;<br />
m_List1.SetIconSpacing(50, 50);<br />
for(int i=1; i<109; i++)<br />
{<br />
nItem=m_List1.InsertItem(2*i,"hello", i);<br />
}<br />
now the list have a series of icons !
if I double click one icon, I want change this icon, what shall I do?will the following codes effective?
:
Wating for answers online, very urgent!
Just my interest for these common things
|
|
|
|
|
I think you need to check your code But see m_imagelist1.Replace(0,LoadIcon(AfxGetInstanceHandle(),(LPCTSTR)IDR_MAINFRAME)); maybe it is some helpful to you
whitesky
|
|
|
|
|
does it only change the imagelist
how to change the icon in CListCtrl?
or should insert into the item newly?
Just my interest for these common things
|
|
|
|
|
oh yes see SetItem and for other parameters for LVITEM see GetItem
whitesky
|
|
|
|
|
|
I insert the item this way , but how to get the item index?
or the other parameters for LVITEM, ex: item.iItem
:
for(int i=1; i<109; i++)<br />
{<br />
nItem=m_List1.InsertItem(2*i,"hello", i);<br />
}
it's double clicked !please tell me totallly!
thank you!
Just my interest for these common things
|
|
|
|
|
The parent window receives a NM_DBLCLK notification, and the message LPARAM points to an NMITEMACTIVATE that tells you which item was clicked, if any.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
VB > soccer
|
|
|
|
|
Thank you very much!
I have done it following:
Item=new LVITEM;<br />
oldImage=faceNO[m_nCurrentSel/2]-1;<br />
Item->mask=LVIF_IMAGE ;<br />
Item->iItem=m_nCurrentSel ;<br />
nHop=0;<br />
<br />
SetTimer(2, 400, NULL);<br />
SetTimer(3, 300, NULL);<br />
if(nIDEvent==2)<br />
{<br />
if(nHop++>4)<br />
{<br />
KillTimer(2);<br />
KillTimer(3);<br />
return;<br />
}<br />
Item->iImage=-1;<br />
m_List1.SetItem(Item);<br />
m_List1.RedrawItems(Item->iItem, Item->iItem);<br />
}<br />
else if(nIDEvent==3)<br />
{<br />
Item->iImage=oldImage;<br />
m_List1.SetItem(Item);<br />
m_List1.RedrawItems(Item->iItem, Item->iItem);<br />
}
,but feel the effect is not comfortable!
My old idea is to make an icon visible and hidden by turns
it's so uncomfortable, I can see the icon twinkling!
How to prevent this happen?
Hope for some helps !
Just my interest for these common things
|
|
|
|
|
Can anyone show me how to update, delete, and add a record in a MS access database using CRecordset class without inheriting it.
thanks...
---------------------------Life is simple, you just complicate things-----------------------
|
|
|
|
|
For UPDATE, DELETE, and INSERT statements you don't need even CRecordset.
Can directly call CDatabase::ExecuteSQL, like for example:
class CFoo
{
CDatabase m_db;
};
void CFoo::SomewhereInSpace()
{
TRY
{
m_db.ExecuteSQL(_T("UPDATE Cats SET Name='Kitty' ")
_T("WHERE OwnerName='James'"));
}
CATCH(CDBException, e)
{
e->ReportError();
}
END_CATCH
}
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
... and if you want to use CRecordset (for SELECT statements, no way, you must do it), instantiate a CRecordset object (no need to derive) the call CRecordset::Open, and so on.
See example below
TRY
{
CRecordset rs(&m_db);
rs.Open(CRecordset::forwardOnly,
_T("SELECT Name, OwnerName FROM Cats"));
while(!rs.IsEOF())
{
const int nFieldsCount = rs.GetODBCFieldCount();
for(int nFieldIndex = 0; nFieldIndex < nFieldsCount; nFieldIndex++)
{
CDBVariant dbvarValue;
rs.GetFieldValue(nFieldIndex, dbvarValue);
}
rs.MoveNext();
}
rs.Close();
}
CATCH(CDBException, e)
{
e->ReportError();
}
AND_CATCH(CMemoryException, e)
{
e->ReportError();
}
END_CATCH
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
I need to add combobox into a listctrl as a subitem . how to do it?
|
|
|
|
|
|
|
Hi, i just upgraded from visual studio 6 to visual studio 2005. The problem here is that i get this error message whenever i try to create a simple AfxMessageBox.
"error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types"
I realise that if i do it like this,
AfxMessageBox((CString)"Something");
it will work. In the previous version there is no need for the '(CString)' part. Is it really meant to be like this in this new version or am i missing something here?
|
|
|
|
|
Don't go around casting. Use this:
AfxMessageBox(_T("Something"));
The _T (from <tchar.h> ) is a macro which makes the string MBCS or UNICODE depending on what your build is targeting.
Steve
|
|
|
|
|
Thanks a bunch. May i also know why this happens for the new version(2005) and not the old one(v 6)?
|
|
|
|
|
If you make a project in MSVC6 and look at the compiler settings you'll see that it has the _MBCS defined. With Visual Studio 2005 instead of _MBCS UNICODE and _UNICODE are defined. The default for MSVC6 projects is to use multibyte strings but for 2005 it is Unicode.
Steve
|
|
|
|
|
Thanks again Steve. As you can see, i'm fairly new to programming with visual studio. I'm having another problem with writing to files. Like before, this code works perfectly well in MSVC6 but its giving me problems in VS2005. I'll only show half the code for simplicity.
CString tempbuf;
tempbuf = "Job number,";
file.Write((LPCTSTR)tempbuf,tempbuf.GetLength());
file.Close;
When i open the file, it has 'J o b n u' in it. Do you know how i can fix this problem?
Thanks for your time.
|
|
|
|