|
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.
|
|
|
|
|
The problem here is that you want to write the file in ANSI but you're compiling for Unicode. There are two ways you can go:
- Convert the Unicode string before writing.
- Change the project from Unicode to MBCS.
To make the second select "Project->Settings" and select the "C/C++" tab. Now erase the "_MSBS" "_MBCS" from the "Preprocessor definitions" edit box and add "UNICODE, _UNICODE" in its place. These steps are for MSVC6 but you should be able to adapt them.
Steve
-- modified at 4:14 Sunday 25th June, 2006
|
|
|
|
|
I couldn't find 'settings' in 'Project'. So the way i did it was i right-clicked the project node in Solution Explorer and clicked Properties.
There, i went to "Configuration Properties->C/C++->Preprocessor". I think it should be the same but they only had "WIN32;_WINDOWS;_DEBUG"
in the "Preprocessor definitions" edit box. I tried to add "UNICODE,_UNICODE" but it still didn't solve the problem.
|
|
|
|
|
Sorry, I got that the wrong way:
Remove "UNICODE,_UNICODE" and add "_MBCS".
Steve
|
|
|
|
|
I believe that my interface is slightly different from yours. First of all, in the preprocessor definitions box, there isn't any "UNICODE,_UNICODE". Whats there is: "WIN32;_WINDOWS;_DEBUG".
BUT, when i clicked on the "..." button at the right hand side of the box, there is a checkbox saying "Inherit from parent or project defaults" and a box that lists the inherited values: "_AFXDLL,UNICODE,_UNICODE".
I unchecked this box and added "_AFXDLL" and "_MBCS" to the original list of preprocessor definitions.
The list now looks like this: "WIN32;WINDOWS;_DEBUG;_AFXDLL;_MBCS;$(NOINHERIT)"
Now when i compile, this error comes up:
msvcrtd.lib(wcrtexew.obj) : error LNK2019: unresolved external symbol _wWinMain@16 referenced in function ___tmainCRTStartup
|
|
|
|
|
I haven't got VS2005 so I can't help you any further, sorry. Someone as CP must know how to change a Unicode project to MBCS using VS2005. Good luck.
Steve
|
|
|
|
|
Its ok.. What about your 1st solution: convert the unicode string before writing?
How can i do that?
|
|
|
|
|
Try this:
CT2CA(static_cast<LPCTSTR>(str))
See here[^] for details.
Steve
|
|
|
|
|
|
hello!
i change header of a pe file and i add a new section for this file. this file execute correct and no problem. but kaspersky (anti virus) detect this file as a type_win32 virus!!!
why???
Zo.Naderi-Iran
|
|
|
|
|
I would guess it interprets the file beging edited as an attack. This in understandable as this is the kind of trick a virus would use.
Steve
|
|
|
|
|
Virus checkers can give false positives, they are not 100% correct
I had one that claimed an empty directory was a virus, it was Microsoft's latest, once the 'fault' was reported they fixed their virus checker!
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for - in order to get to the job you need to pay for the clothes and the car, and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
|
|
|
|
|
What's the function that return the caption of the windows that is focusing in the system.
|
|
|
|