|
Hi,
This is the code i am using.. but now its giving me
Thread exit with error 0x2
NOTIFYICONDATA tnid;
// Remove the Icon from the TaskBar
tnid.cbSize = sizeof(NOTIFYICONDATA);
tnid.hWnd = GetSafeHwnd();
tnid.uID = 14;
Shell_NotifyIcon(NIM_DELETE, &tnid);
PostMessage(WM_CLOSE,0,0);
return;
The Error is
he thread 0xFFFA9B37 has exited with code 2 (0x2).
The program 'D:\RCMMS\Code\shnotify\Debug\shnotify.exe' has exited with code 2 (0x2).
Please help
|
|
|
|
|
Hi,
How can i Modify the "common" List Box text font size to a custom size ?
Thank's.
|
|
|
|
|
You just need to create a new font for the control. For example:
LOGFONT lf ;
CFont *pFont = GetDlgItem(IDC_LISTCONTROL)->GetFont() ;
if (pFont != NULL)
{
pFont->GetLogFont(&lf) ;
lf.lfHeight += 2 ;
}
else
{
}
m_Font.CreateFontIndirect(&lf) ;
GetDlgItem(IDC_LISTCONTROL)->SetFont(&m_Font) ;
Roger Allen
Sonork 100.10016
yet to be identified being from the planet Paltinmoriumbanfrettybooter
|
|
|
|
|
My work often involves writing multi-threaded turnkey systems - ie. programs which are designed to run "for ever". As such the kind of memory leaks that are found by BoundsChecker - memory that is allocated but not released when the program terminates - are relatively unimportant. What does cause problems is when a thread, running as a continuous loop, allocates memory each time round the loop that it doesn't free. Over time the system floods until eventually a catastrophic failure occurs.
I need a way to monitor the heap usage of each individual thread, and detect whether it is leaking each time it executes its loop. (I know there is something called "thread-local storage" but I haven't been able to find much detail on it). If anyone knows any techniques for this, or can point me at some good articles or books, I'd be most grateful.
Dave
|
|
|
|
|
I had the same problems a year back and ended up writing a sort of collector where I registered all dynamically allocated objects (and general storage) an unregistered them on deletion. The collector was instanciated on the stack for each thread. When the thread exited, the collector printed information about all objects still not unregistered.
If there is a better way to do this, I also would like to know.
|
|
|
|
|
As the name implies TLS is synonym of thread specific data.
Use TlsAlloc on process/dll initialization, this will allocate a TLS index, then for each thread that needs specific instance data allocate some storage and pass the pointer to TlsSetValue, associating the TLS index with it.
When a thread needs to get the instance value use TlsGetValue.
Finally when all your threads are over, use TlsFree to release the Tls Index.
The nº of TLS index is limited by process to 64 on 95 ??? , 64 or 80 in 98/me and 10?? in XP, please check msdn for the correct value, I don't remember clearly
You could circumvent this if you wish by providing a pointer to a list/map of pseudo TLS indexes.
Joao Vaz
Unhappy TCL programmer
|
|
|
|
|
Hi
I'm having a problem with a list control. I am try to sort it numberically
and the use InsertItem but I can't seem to control where the item is inserted.
In the code:
m_lstCellDetails.InsertItem(nIndex, myStr);
is the parameter nIndex not the row number?
|
|
|
|
|
Catherine wrote:
is the parameter nIndex not the row number?
Well, yes and no. It's where the list will try to put the item, but if you have any sorting turned on, the value specified will be ignored and you will get the actual row index returned from the function. int CListCtrl::InsertItem(...)
|
|
|
|
|
Since sorting is a big issue, this is how I do it:
struct MyData { int nVal, CString str };
for (int i = 0; i < nItems; i++) {
MyData *pData = new MyData;
pData->nVal = nIntVal;
pData->str = "Hello";
int nRow = list.InsertItem(i, pData->str);
list.SetItemData((DWORD) pData);
} now sorting on integer value would be
#define SORT_INT_ASC 1
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
MyData *pData1 = (MyData*) lParam1;
MyData *pData2 = (MyData*) lParam2;
if (lParamSort == SORT_INT_ASC)
{
if (pData1->nVal < pData2->nVal) return -1;
if (pData1->nVal > pData2->nVal) return 1;
return 0;
}
}
list.SortItems(CompareFunc, SORT_INT_ASC);
The whole idea is to place useful 'user data' in every list item. Cause these are what you can sort on.
This is from heart, I bet the compiler has a few things to say about it
|
|
|
|
|
Thankyou ..I think that was my problem I had sort Ascending selected in the styles property
|
|
|
|
|
what are good books for learning atl ?
i've got "beginning atl com programming" by Gimes Stockton Reily and Templeton
but its pretty much unreadble
any suggestions?
bryce
|
|
|
|
|
I found the same thing and bought Jonothan Bates 'Creating Lightweight Components with ATL'. I never looked back.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
I've been using Developer's Workshop to COM and ATL 3.0 by Andrew w. Troelsen. The first few chapters cover the basics of COM, and then he dives into how ATL works. Troelsen covers important features such as ATL's smart pointer template class, how the "BSTR" type is wrapped by ATL, and then finishes up with the basic windowing functionality in the ATL.
--
Paul
"I drank... WHAT?"
|
|
|
|
|
I've just bought 'COM+ Programming, A Practical Guide using Visual C++ and ATL'; I'm only a couple of chapters in but I'd recommened it.
It's on Hewlett-Packard Professional Books if you want to check it out
Dylan Kenneally
London,UK
|
|
|
|
|
|
Hi all. I'd like to know how to get CPU and memory information by C++. Is it neccessary to use MFC? How can I do it without MFC?
Thanks!
|
|
|
|
|
I created a VC++ application under Win'98. I try to run under Win'2000 , i cannot...Why?
Also from the workspace i cannot execute the application.
|
|
|
|
|
Manikandan wrote:
I created a VC++ application under Win'98. I try to run under Win'2000 , i cannot...Why?
It's because there is something wrong with your code.
Manikandan wrote:
Also from the workspace i cannot execute the application
Probably the same cause.
(HINT: Try to be a bit more specific)
|
|
|
|
|
...if the code is wrong it should not run under win'98, right?
|
|
|
|
|
It just might. I used a ON_NOTIFY_EX macro where I should have used a ON_NOTIFY the other day. Worked like a charm on ME in both Debug and Release build. It also worked fine on w2k in Debug build, but created access violations in Release. So, there is one example. There are probably thousends of others.
|
|
|
|
|
Yes, you are right. But this one look strange to me. I don't know what to do.
Just now i tried to implement something from,
http://www.codeproject.com/w2k/access_api.asp
//////////////////////////
#define _WIN32_WINNT 0x0500 // allow Win2000 specific calls
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#undef _WIN32_WINNT // allow CFileDialog to build with
///////////////////////////
this stuff too not working...
anyway i try to fix the problem. thank you very much for responding.
|
|
|
|
|
For my opinion it's compiled wrong ... you try compile for 32platform and unicode format; because i guess that your pc(with win2000) ... it's disabled a option for loading your bilt format(for win98).
|
|
|
|
|
Hi,
I would like to make an Active Document Server with Active Document Container capebilities.
In short I have tried to modifiy the Microsoft MFCBIND (http://msdn.microsoft.com/code/default.asp?URL=/code/sample.asp?url=/MSDN-FILES/026/001/803/msdncompositedoc.xml) sample to be a Server also. I want the MFCBIND to be running in a container (Word, Excel or myown) and still be able to use MFCBIND as a container for other Active Document Servers.
Have you tried something like that - nested Active Documents? I am really lost and I am about to think it is not possible..... but even the Visual Studio Wizard lets you define such projects but they dosen't seem to work correct....
Any help will be highly appreciated...
Best regards
Nyrup
|
|
|
|
|
i abstract data from database ,but this could create a temp file .i want real-time abstract the data,it will chock up my C tray .i want know how to delet the temp file in vc?
if (pb.Open("mymib"))
{
CBisheSet*PB=new CBisheSet();
PB->Open(CRecordset::snapshot,NULL);
PB->MoveLast();
m_interfacename=PB->m_Name;
UpdateData(false);
ac="data total:";
dbltotal=PB->m_Total;
ab.Format("%-10.2f",dbltotal);
ac.Insert(18,ab);
m_listdata.AddString(ac);
ac="";
|
|
|
|
|
A lot depends on how you are creating the temp file.
Have a look at DeleteFile on MSDN.
Michael
|
|
|
|