|
In the LVN_DELETEITEM handler you don't use GetItemData because the LPARAM is already passed in through the NMHDR pointer. You need to cast it to a NMLISTVIEW pointer. Here is an example:
void CMyDlg::OnLvnDeleteitem(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
*pResult = 0;
MY_DATA_TYPE pData = reinterpret_cast<MY_DATA_TYPE>(pNMLV->lParam);
if (pData != NULL)
delete pData;
}
This gets called for each item in the list control whether you are just removing a single item from the list control or if the window is being destroyed. Be sure to read the MSDN for more information on this notification message.
Kelly Herald
Software Developer
MPC
|
|
|
|
|
Hello all,
I have a function - UpdateTimes() - that connected to SQL server. It will increases the Times value in my database if this value less than 5.
The code like this:
void UpdateTimes()
{
CDatabase m_Db;
CRecordset m_Rs(&m_Db);
m_Db.OpenEx(_T("DSN=MyData;UID=sa;PWD=sa"),0);
CString sSQL_Sel = "SELECT ConID,ChkTimes FROM tblList";
m_Rs.Open(CRecordset::forwardOnly, _T(sSQL_Sel));
while (!m_Rs.IsEOF())
{
short ind = 0;
CString sID;
m_Rs.GetFieldValue(ind, sID);
ind = 1;
CDBVariant varTimes;
m_Rs.GetFieldValue(ind, varTimes);
if (varID.m_iVal <= 5)
{
varID.m_iVal ++;
CString sTemp;
sTemp.Format("%d", varTimes.m_iVal);
CString sSQL_Upd = "UPDATE tblList SET [ChkTimes] = " + sTemp + " WHERE ConID like '" + sID + "'";
m_Db.ExecuteSQL(sSQL_Upd);
}
m_Rs.MoveNext();
}
m_Rs.Close();
m_Db.Close();
}
If my database has only 1 record, this code is OK. But if I have more than 2 records, it has an error message, say "Connection is busy ...".
So do you have another way to do it? Pls help me ...
Thank you very much.
|
|
|
|
|
Using ODBC with SQL Server means you need to be aware that only one record set can be used per connection. If there's one record, when you've read it, there are no more records and the connection can be reused, whereas if there are two or more, it's still busy, and you can't reuse it, but you can use a second (hint).
Alternatively, for what you're doing
"UPDATE tblList Set [ChkTimes] = [ChkTimes] + 1 WHERE [ChkTimes] <= 5"
which is much more efficient, as almost all the work is done by the server, eliminating the need to transfer data backwards and forwards.
Steve S
Developer for hire!
|
|
|
|
|
|
|
For a CWnd you could use (GetScrollBarCtrl() != NULL)
Update: it should be GetScrollBarCtrl(SB_HORZ) or GetScrollBarCtrl(SB_VERT) and it only works for CView and derived classes.
For what kind of window do you need it?
--
jlr
http://jlamas.blogspot.com/[^]
-- modified at 1:23 Monday 5th September, 2005
|
|
|
|
|
|
If you mean how to know if the number of items exceeds the amount of visible items you could use:
(GetItemCount() > GetCountPerPage())
You may also try ApproximateViewRect and compare it to the control dimensions
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I used the first method,(GetItemCount() > GetCountPerPage()),it works perfectly.
|
|
|
|
|
Hi all,
I wanna play *.rm file use MCI!! Can I do it?
If can't ,What should I use ?
Thank you so much.
do it.
|
|
|
|
|
You need realplayer to play .rm files. WMP can't do it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm supposed to make a program that does infix to postfix and prints each, as well as the value of the expression.
Here's my code: http://www.straightlyrics.com/postfix.cpp
Here's a sample data set: http://www.straightlyrics.com/data
The problem lies in where it does the 2 * 6 / 2 + 5 expression.
It outputs the postfix as 2 6 2 / 5 + *
I think it is supposed to be 2 6 2 / * 5 + but I don't know what is causing it to mess up.
By the way, for this program, order of operations are different. / has highest priority, followed by * and + which are equial, then - is last. all operations are supposed to work left to right, except -, which goes right to left.
|
|
|
|
|
Check the order of priority for the operators in your code. Based on that priority The Code is giving the result.
Nice talking to you.
|
|
|
|
|
Hello,
I am having a weird problem with a list view control (CListCtrl) in MFC. I can create it but for some reason I can't add an item to it. When I call the controls InsertItem function, it returns -1, which according to the MFC documentation means that adding the item to the list view was unsuccessful. I know this from running this code:
folderContents.Create(WS_VISIBLE|WS_CHILD|WS_BORDER|<br />
LVS_LIST|LVS_SINGLESEL,<br />
CRect(10,10,300,180), this, <br />
IDC_FOLDERCONTENTS);<br />
<br />
LV_ITEM lvItem;<br />
lvItem.mask = LVIF_TEXT|LVIF_STATE;<br />
lvItem.state = 0;<br />
lvItem.stateMask = 0;<br />
lvItem.pszText = "an item";<br />
lvItem.iItem = 0;<br />
<br />
if(folderContents.InsertItem(&lvItem) == -1)<br />
{<br />
COLORREF c = PALETTERGB(150, 90, 130);<br />
folderContents.SetBkColor(c);<br />
}
When I run the application, backgound color of the list view (named folderContents in above code) is changed. So why cant InsertItem add an item to the list view? There is no explanation in the documentation. Anybody know?
TraileR ParK LifE 4Ever
|
|
|
|
|
The LV_ITEM structure contains a lot of info apart from what you're specifying, and it's all full of random data when you create one. If you add this line:
::memset(&lvItem, 0, sizeof(LV_ITEM));
before setting any values, it works ( I just tried it )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Wow! Thanks a lot! I did not know about this function.
TraileR ParK LifE 4Ever
|
|
|
|
|
I need an advice. For the last weeks I do a lot of Java with the NETBeans IDE. It has some neat features,
like creating the get and set methods automaticaly. Does anyone know about a extention for the VC7 IDE , that can do the
same? (auto generate GET and SET handlers, create overrides for pure virtual methods and so on)
It should be for C++ (thats why I used this forum)
thank you.
|
|
|
|
|
VS2005 has all of this built in for C# and VB.NET, but sadly, not for C++. I reckon once it hits the market, there will be a real call for this stuff in the C++ IDE, and some products will come out to support it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Quote from Microsoft:
"You receive a "This application has requested the Runtime to terminate it in an unusual way" error message when you run a custom Microsoft Visual C++ 6.0 program in Windows XP
View products that this article applies to.
Article ID : 884538
Last Review : May 3, 2005
Revision : 2.1
SYMPTOMS
When you run your custom Microsoft Visual C++ 6.0 program in Microsoft Windows XP, you may receive the following error message:
This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
CAUSE
This problem may occur when you use the /GR and the /MD compiler switches, and the version of the Msvcrt.dll file and of the Msvcirt.dll file is 7.0.x.
Note This problem does not occur when you use a version of the Msvcrt.dll file and of the Msvcirt.dll file that is earlier than 7.0.
RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Windows XP service pack that contains this hotfix.
To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support (http://support.microsoft.com/contactus/?ws=support)
Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
Prerequisites
There are no prerequisites for installing this hotfix package.
Restart information
You must restart your computer after you apply this hotfix.
Hotfix replacement information
This hotfix does not replace any earlier hotfix.
Hotfix file information
The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel. Date Time Version Size File name
------------------------------------------------------
20-Oct-2004 22:59 7.0.2600.2534 57,344 Msvcirt.dll
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section " quote ends.
Found at:
http://support.microsoft.com/default.aspx?scid=kb;en-us;884538#appliesto
Anyone who knows what this means? I'm trying to launch IExplorer.exe in Program Files section
I have Windows Pro SP2 installed and everything else is working! Also Visual studio 6.0 installed,
I will be most grateful of any answers on this matter
|
|
|
|
|
EA6_Panther wrote:
Found at:
http://support.microsoft.com/default.aspx?scid=kb;en-us;884538#appliesto
Anyone who knows what this means? I'm trying to launch IExplorer.exe in Program Files section
What's exactly your problem? The MS document you quoted has nothing to do with launching Internet Explorer.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Eg when I try to run Internet Explorer then Visual C++ 6.0 causes a runtime error
due to the visual c++ runtime libraries .The explanation that is given in this article
is that when msvcirt.dll (or msvcrt.dll ) is used with /MD compiler directives a runtime error
occurs in Windows XP SP2 when Visual Studio 6.0 is installed, which I am positive about is the root of this problem .Also I am referring to this article because I am convinced in doing so .
I quote:
C Run-Time Library (without iostream) Characteristics Option Defined
LIBC.LIB Single threaded, static link /ML
LIBCMT.LIB Multithreaded, static link /MT _MT
MSVCRT.LIB Multithreaded, dynamic link (import library for MSVCRT.DLL) /MD _MT, _DLL
Standard C++ Library Characteristics Option Defined
LIBCP.LIB Single threaded, static link /ML
LIBCPMT.LIB Multithreaded, static link /MT _MT
MSVCPRT.LIB Multithreaded, dynamic link (import library for MSVCRT.DLL) /MD _MT, _DLL
Old Iostream Library Characteristics Option Defined
LIBCI.LIB Single threaded, static link /ML
LIBCIMT.LIB Multithreaded, static link /MT _MT
MSVCIRT.LIB Multithreaded, dynamic link (import library for MSVCIRT.DLL) /MD _MT, _DLL
Now check this!This problem may occur when you use the /GR and the /MD compiler switches, and the version of the Msvcrt.dll file and of the Msvcirt.dll file is 7.0.x.
Thus When I run my custom Microsoft Visual C++ 6.0 program in Microsoft Windows XP, I receive the following error message:
This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
I perform a search on MyComputer after "msvcirt.dll" and found several versions installed.
However in windows\system32 there is version 7 (cf article that I quote ) which is the same
latest version of a visual c++ runtime library.A Hotfix resolve this problem but i cannot obtain this via internet.I hope I have stated my problem clear .
I will be grateful of help or information on this matter.
|
|
|
|
|
in visual c++ 2002 i created a win32 application... (unmanaged).. how do i make a button, dialog, textbox, etc? i've programmed in c# before but i know that is nothing like unmanaged c++. i have "c++ for dummies" and i hope that will help me but i dont want to make console applications, i want to make windows applications. i need to know where to start. thanks in advance.
|
|
|
|
|
What about MFC? Just create a MFC application and you can create your forms similiar to the way you do it in C#.
If you want it the hard way, do all your API calls like "CreateWindow" by yourself.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi - a Win32 project is perhaps the most difficult type of project to get together. Basically, you want to create an MFC project, MFC is a library that sits on top of Win32 and makes things a lot easier.
However, C++ is more complex ( and also more powerful ) than C#. I'd recommend you first do some console programming to learn the language, then buy a good MFC book before continuing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Im relatively new to programming and have never come across a memory leak problem before and cant seem to figure out how to fix the problem. For some reason I have this memory leak
memory check error at 0x000349C0 = 0xFF, should be 0xFD.
memory check error at 0x000349C1 = 0x00, should be 0xFD.
memory check error at 0x000349C2 = 0x03, should be 0xFD.
memory check error at 0x000349C3 = 0x00, should be 0xFD.
Detected memory leaks!
Dumping objects ->
C:\Program Files\Microsoft Visual Studio\MyProjects\Mandelbrot\MandelbrotDoc.cpp(20) : {61} client block at 0x00034550, subtype 0, 1136 bytes long.
a CObject object at $00034550, 1136 bytes long
plex.cpp(31) : {60} normal block at 0x00034498, 124 bytes long.
Data: < C > 00 00 00 00 00 00 00 00 00 00 00 00 F0 43 03 00
{59} client block at 0x00032A58, subtype 0, 32 bytes long.
a CDocManager object at $00032A58, 32 bytes long
c:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\MYPROJECTS\Mandelbrot\Mandelbrot.cpp(78) : {58} client block at 0x000343F0, subtype 0, 108 bytes long.
a CSingleDocTemplate object at $000343F0, 108 bytes long
strcore.cpp(118) : {56} normal block at 0x00032A00, 19 bytes long.
Data: < File> 01 00 00 00 06 00 00 00 06 00 00 00 46 69 6C 65
strcore.cpp(118) : {55} normal block at 0x00032998, 29 bytes long.
Data: < Rece> 01 00 00 00 10 00 00 00 10 00 00 00 52 65 63 65
{54} normal block at 0x00032940, 20 bytes long.
Data: < M_ M_ M_> 04 00 00 00 14 0B 4D 5F 14 0B 4D 5F 14 0B 4D 5F
{53} normal block at 0x000328D8, 32 bytes long.
Data: < K_ D) ) > CC AD 4B 5F 04 00 00 00 44 29 03 00 A4 29 03 00
Object dump complete.
The thread 0xFC6C has exited with code 3 (0x3).
The program 'C:\Program Files\Microsoft Visual Studio\MyProjects\Mandelbrot\Debug\Mandelbrot.exe' has exited with code 3 (0x3).
It says my leak lies here
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMandelbrotDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMandelbrotView));
AddDocTemplate(pDocTemplate);
and here
IMPLEMENT_DYNCREATE(CMandelbrotDoc, CDocument)
BEGIN_MESSAGE_MAP(CMandelbrotDoc, CDocument)
//{{AFX_MSG_MAP(CMandelbrotDoc)
ON_COMMAND(ID_APPIDLE, OnAppIdle)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
If you need more info to help me out just let me know. Thanks.
|
|
|
|
|