|
How do i show a balloon window with my trayicon to show some events accoring.
The balloon window similar to what you get when a new hardware is detected by windows.
Regards.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
hi, guys
i need to use a CTypedPtrList templet structure in my program.
here is my code: (CFreqStandard is a class which i derived from CObject and it's basically used to store some data)
class CSDIgDoc : public CDocument
{
protected: // create from serialization only
CSDIgDoc();
DECLARE_DYNCREATE(CSDIgDoc)
protected:
//CTypedPtrList<coblist,cfreqstandard*> FreqList;
//CString StandardName;
CString StandardName;
CTypedPtrList<coblist,cfreqstandard> m_FreqList;/////////////////////
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSDIgDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSDIgDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CSDIgDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
but when i compile i always get an error in the line
CTypedPtrList<coblist,cfreqstandard> m_FreqList;
it shows that "'CTypedPtrList' : missing storage-class or type specifiers"
what is the problem in this case?
Thank you very much in advance
|
|
|
|
|
You never defined the types to use for the template, like this for example:
typedef CTypedPtrList<CObList, CMyObject*> m_FreqList;
Have a look to this article[^] of MSDN for a sample.
HTH,
K.
Mais donnez-moi aussi
Le courage et la force et la foi
Car vous êtes le seul à donner
Ce que l'on ne peut obtenir que de soi.
|
|
|
|
|
Hi Friends,
How can i programmatically cancel a message box that popped during a startup of a application
thanx,
John
|
|
|
|
|
Seems like writing a loader, or removing a nag screen
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I declear a CTime valiable and set it's value before 1970-1-1, it will cause a assertion failed error(timecore.cpp), I realized that 1970-1-1 is the defaule value for CTime, anybody encounter this problem before? please help me out, thanks a lot.
|
|
|
|
|
CTime objects can contain times from 1970-1-1 to somewhere in 2038. (you should check the validity of the input yourself)
if you want to have dates outside that period you can use the COleDateTime class.
Regards,
Davy
|
|
|
|
|
I have been using FindFirstUrlCacheEntry/FindNextUrlCacheEntryA/DeleteUrlCacheEntry without specifying wininet.lib in the object/library modules in my project options.
But when I added the cache group functions (FindFirstUrlCacheGroup, etc), I could not build my project without adding wininet.lib to the object/library modules.
any ideas why this is so?
|
|
|
|
|
just add it and please don't waste our time.
Don't try it, just do it!
|
|
|
|
|
I want to statically link the DLL MSVCP60.DLL to my EXE. How do I specify this in my project options? I am using visual studio 6.
1. Is it by specifying 'Use MFC in static library'? I dont use MFC. Even after specifying this option my exe size is same.
2. Under link, Input category, specify the lib under Object/library modules. What is the lib for MSVCp60.DLL? If I say, msvcp60.lib, it is not found.
I am using dependancy walker to see the DLLs my EXE is dependant on. If I link a DLL statically, I assume it wont show in the dependancy walker any more, right?
Thanks
Fl.
|
|
|
|
|
Flace wrote:
statically link the DLL
I think you've missed the point a little. DLL's are Dynamically Linked Libraries, they require dynamic linking. The .lib (static libraries) that you link to for implicit linking (at compile time) only forward responsibility to the DLL. Even if it is possible to statically link to a DLL (I personally don't know how too, but I'm sure there are hacks to do it) why would you bother??? Just distribute the DLL with your executable if you aren't sure whether the client has it.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Ok, got it. Thanks.
but just curious as to how to statically link a library. for ex, wininet.lib. What should I do to statically link this?
Thanks,
Fl.
|
|
|
|
|
It depends a on which compiler and IDE you are using. One of the easiest ways in VC.NET is to add wininet.lib to the edit box:
Project Properties -> Linker -> Input -> Additional Dependencies.
Most IDE's should have something similar.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
How do I take an input(integer value) from a textbox than assign that input into an array. The array is a 50 element array.
int sum,val;
//int* average = new int[50];
//int average[50];// Create an array dynamically pg.234
String* i = VoltsTextBox->Text;
int averagr[val] = Int32::Parse(i);
|
|
|
|
|
What type of application are you working on? SDK or MFC?
Maxwell Chen
|
|
|
|
|
windows forms micosoft visual studio.net.
|
|
|
|
|
Right-click at the edit box control to add a data member of type int (for example, m_iMyVal). Then have a look at the function UpdateData(FALSE) to sync the value of m_iMyVal with the value (text) seen in that edit box. Finally you add the value into your array, and loop the step to complete the array.
Maxwell Chen
|
|
|
|
|
Hi
I have a problem with the thread and class.
I created a thread from a function and in the thread function, i called and init a class but not using the new and delete method. There is a problem when the thread ended as the class destructor was not activated when i called ExitThread...an example below
main function()
{
CreateThread(.....,ThreadProc,...);
}
ThreadProc()
{
CDB_Database Data(); //Class Init
DWORD dwRecords;
HANDLE hFile; etc
OpenFile();
...
....
...
ExitThread(0);
}
my problem is everytime i called creatThread, the class constructor will be activated but when i called ExitThread, the class destructor was not activated.
So is the resources used by the thread free when i called exitThread as i seems to have sharing violation inside the function
Thank you for ur advise
|
|
|
|
|
The ExitThread() function never returns, so the ThreadProc() doesn't reach its end and destructors don't get called. One way to solve this is to add another pair of braces:
ThreadProc()
{
{
CDB_Database Data();
DWORD dwRecords;
HANDLE hFile; etc
OpenFile();
}
ExitThread(0);
}
Now Data is destroyed when code exits the inner braces, just before ExitThread()
|
|
|
|
|
If the ThreadProc is declared as follows:
DWORD WINAPI ThreadProc(
LPVOID lpParameter // thread data
);
Why don't you just
return 0;
from your thread function instead of calling ExitThread at the every end of it anyway? Then your variables can go out of scope and destroy themselves automatically. Anything monitoring the 'exit code' of the thread will still see the 0.
FYI (From MSDN):
A thread that uses functions from the C run-time libraries should use the _beginthread and _endthread C run-time functions for thread management rather than CreateThread and ExitThread. Failure to do so results in small memory leaks when ExitThread is called.
|
|
|
|
|
fstream file;
char buffer[MAXBUFSIZE];
string line;
file.open(..., ios_base::in);
file.getline(buffer, MAXBUFSIZE-1);
//getline(file, line);
//both of the above fail to work
//and the vc.net2003 print such error info:
//error C2663: “std::basic_istream<_Elem,_Traits>::getline” : //2 //overloaded functions lack a legal conversion of pointer "this".
|
|
|
|
|
This works fine:
--------------------------------------
#include <iostream>
#include <fstream>
using namespace std;
void main()
{
fstream file;
const int MAXBUFSIZE = 256;
char buffer[MAXBUFSIZE];
file.open("a.txt", ios_base::in);
do
{
file.getline(buffer, MAXBUFSIZE-1);
//getline(file, line);
string s = buffer;
cout << s.c_str() << endl;
} while (! file.eof() );
}
<b>Maxwell Chen</b>
|
|
|
|
|
Might I suggest something more like this:
#include <iostream>
#include <fstream>
#include <string>
int main() {
std::ifstream file("filename");
std::string line;
while (std::getline(file, line)) {
std::cout << line << '\n';
}
return 0;
}
Just a couple of points:
- C++ defines main as: "int main()" or "int main(int argc, char* argv[])". There's nothing in the code that limits us to Visual C++ and its non-standard "void main()" extension.
- Using std::getline (defined in "string") we avoid using a char* buffer as we have to with std::basic_istream<...>::getline.
- Invoking s.c_str() on something we write out using iostreams anyway might incur the following overhead: a char* buffer that can contain the contents is allocated, the contents of s is copied over into it, a terminating null character is added and this buffer is returned. This is because the contents of std::string isn't guaranteed to be null terminated.
Hope this helps.
--
Henrik Stuart (http://www.unprompted.com/hstuart/[^])
|
|
|
|
|
thank you for the response.
Finnally, I figured out the key problem.
the fstream object is the data member of my
class not declared mutable, but in the member
function declared const, the fstream.getline()
failed.
//ps: the error information vc.net2003 offers me
//just confuses me
|
|
|
|
|
Henrik, you got my 5!
Basically I agree with all of your view points, and they are quite true. It reminds me to pay efforts in studying the Standard Library.
Regarding to the prototype of main, you are right too, as we don't find any 'void main()' in Stroustrup's book. It's just my bad custom for simplicity, since in the MSDN Library it is stated:
Alternatively, the main and wmain functions can be declared as returning void (no return value). If you declare main or wmain as returning void, you cannot return an exit code to the parent process or operating system using a return statement; to return an exit code when main or wmain is declared as void, you must use the exit function.
Anyway, I like your attitude!
Maxwell Chen
|
|
|
|