|
You should ensure that the algorithms and implementation are as efficient as possible. Also look at profiling the code. I happilly use Glowcode for this www.glowcode.com[^]
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
You need to use the keyword extern in front of your variable declarations in the header
file. Then declare them without the extern in one of your implementation files.
e.g.
extern HANDLE g_hAbortThreadEvent;
#include "Header.h"
...
HANDLE g_hAbortThreadEvent = NULL;
main ()
{
g_hAbortThreadEvent = CreateEvent (....);
....
DeleteObject (g_hAbortThreadEvent);
}
#include "Header.h"
...
dwWait = WaitForSingleEvent (g_hAbortThreadEvent, ...);
Make sense now? By "implementing" the variable in the header file, you were actually implementing
it in each .c file, hence the linker confusion.
Iain.
|
|
|
|
|
I've had problems mixing .C and .CPP functions in the past. Is there a good reason you can't just
rename rs232.c to rs232.cpp and compile it as a c++ file? That should hopefully get rid of your
problems. You could probably lose the "C" part of the extern, making it much simpler to keep
track of things.
Someone else may have inspiration better than mine thought.
Iain.
|
|
|
|
|
hi there
thanks for the time!
the problem i am facing is that i wanted to create a Dispatch parameter array..Once i have created a var of the type using "new", how can i create an array of a given size and be able to assign variables and vts???
here is the code:
This code throws bad memory exception after the method is invoked a couple of times )
void Spread::AddSelection(long nRow1, long nCol1, long nRow2, long nCol2)
{
DISPPARAMS DispParam;
EXCEPINFO excep;
UINT nArgErr;
DispParam1.cArgs = 4; //number of arguments
DispParam1.cNamedArgs = 0;// Number of named arguments.
DispParam1.rgdispidNamedArgs = NULL ; // Dispatch IDs of named arguments.
DispParam1.rgvarg = new VARIANTARG();
//here i create a new ptr, but how do i create an array which may have variables of different vts and make this pointer point to it?
DispParam1.rgvarg->vt = VT_ARRAY;
DispParam1.rgvarg[3].vt = VT_I4;
DispParam1.rgvarg[3].lVal = nRow1;
DispParam1.rgvarg[2].vt = VT_I4;
DispParam1.rgvarg[2].lVal = nCol1;
DispParam1.rgvarg[1].vt = VT_I4;
DispParam1.rgvarg[1].lVal = nRow2;
DispParam1.rgvarg[0].vt = VT_I4;
DispParam1.rgvarg[0].lVal = nCol2;
ISpread::Invoke(ID_AddSelection , IID_NULL , 0 , 1, &DispParam1, NULL , &excep, &nArgErr);
}
please help
thanks
regards
|
|
|
|
|
You're trying to set 4 parameters, but only allocating memory for 1. You need to allocation 4 structures, not 1:
DispParam1.rgvarg = new VARIANTARG[4]; Remember to call
delete [] DispParm1.rgvarg; after the Invoke() method call.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
thanks a lot for this timely help!
kindest regards
safee
|
|
|
|
|
You're welcome
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
How can I programmatically know when any machine on my network accesses my machine through a share or through C$, D$ using admin priviledges?
Is it possible to know the logged in username also?
Thanks in advance.
With best regards,
Sayan
With best regards,
Sayan
Email:sayanmukherjee@indiatimes.com
|
|
|
|
|
Sayan Mukherjee wrote:
Is it possible to know the logged in username also?
GetUserName() will return the currently logged in user on the local machine.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi
What about c:\>NET Session at the command prompt.
best wishes ...mil10
|
|
|
|
|
Hello,
I'm using VC++ 6.0 and I want to change the background color of my CTreeCtrl object. I don't know how . Can anybody help me?
thanks in advance.
|
|
|
|
|
CTreeCtrl::SetBkColor()
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
thanks
|
|
|
|
|
You're welcome
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I've just started programming in VC++ and I've encountered some problems.
I'm accessing an Access database using DAO. This database contains two fields; a hyperlink (Addr) and a description of this hyperlink (Desc).
I've done that like this:
[code]
void CClientListDlg::RefreshList()
{
COleVariant var;
var.ChangeType(VT_BSTR, NULL);
CString Desc,Addr;
m_Desc.DeleteAllItems();
db.Open("List.mdb");
recset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM Clients",NULL);
while(!recset.IsEOF())
{
int i = 0;
recset.GetFieldValue("Desc",var);
Desc = (LPCSTR)var.pbstrVal;
m_Desc.InsertItem(i,Desc,0);
recset.GetFieldValue("Addr",var);
Addr = (LPCSTR)var.pbstrVal;
m_Desc.SetItemText(0,1,Addr);
i = i++;
recset.MoveNext();
}
recset.Close();
db.Close();
}
[/code]
Is it possible to let VC++ show this hyperlink (Addr) clickable?
Also, is there a routine to make my prog search through the database, preferably in both fields?
Sorry about the newbie questions, but as I said, I'm new at this.
Thanks in advance for all your help!
Greetz,
[NL]G}{0$T
..: [ Once Busted - Twice As Shy ] :..
|
|
|
|
|
1. Yes; by adding a click handler (or possibly a double-click handler) to the listview, you could then launch IE from there (by ShellExecute or some such).
2. If you want to search, you'd modify the SQL used to open the recordset.
You can do this modifying one of the member variables of the CDaoRecordset, setting it to something like
Addr LIKE '%codeproject%'
which would return all the hlinks containing codeproject.
(% might need to be a * depending on your version of Access).
Steve S
[This signature space available for rent]
|
|
|
|
|
Thank you for your quick reply..
You're right, I should ShellExecute IE, but how can I use a variable link in the command?
I've tried:
[code]
void CClientListDlg::OnDblclkClients(NMHDR* pNMHDR, LRESULT* pResult)
{
(32 >= (int)ShellExecute(NULL, "open", ADDRE, NULL, NULL, SW_SHOWNORMAL));
*pResult = 0;
}
[/code]
But this does't seem to work. It VC tells me that ADDRE is not defined..
Any suggestions?
Greetz,
[NL]G}{0$T
..: [ Once Busted - Twice As Shy ] :..
|
|
|
|
|
Steve S wrote:
[This signature space available for rent]
How much?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hiya I am using remove function to remove a file i.e
remove( "\\myfile.pmx" );
which works fine but when the file is in a directory i.e
remove( "dir\\myfile.pmx" );
It doesn't remove it. Any ideas??
thanks
|
|
|
|
|
Did you try with the complete file path?
|
|
|
|
|
Hi all,
how to use extended MAPI as redemption.dll is used..please check http://www.dimastr.com/redemption/security.htm for more details..I want to make something like that..so that when I access any object of outlook to post some data it doesnt show me any error..anyone has any clue about it..any ideas or tutorials or pointers are highly appreciated..
Thanks a lot in advance..
Himanshu
|
|
|
|
|
Hi all,
how to use extended MAPI as redemption.dll is used..please check http://www.dimastr.com/redemption/security.htm for more details..I want to make something like that..so that when I access any object of outlook to post some data it doesnt show me any error..anyone has any clue about it..any ideas or tutorials or pointers are highly appreciated..
Thanks a lot in advance..
Himanshu
|
|
|
|
|
Hi,
Is the following possible with Visual C++ .Net:
class.h:
template<class t="">
class A
{
public:
T* GetT();
private:
T* m_T;
}
class.cpp:
template<class t="">
T* A<t>::GetT()
{
return m_T;
}
If so, what is the correct syntax? The above gives me a linker error saying 'undefined reference to A<t>::GetT()', which basically means to me that class.cpp is not included in the compilation somehow, or at least that the contents of class.cpp are not associated with the declaration in class.h (correct me if I'm wrong on this).
I hope my question is clear enough, thanks for all insights!
cheers,
roel
|
|
|
|
|
You can't do this at the moment with Visual C++. The definition of the template must be available to the compiler at the point of instantation, including the definitions of all methods.
In practical terms, this means you must define the function in the class.h header file.
At a rough guess, it should look something like:
template <typename T>
class A
{
public:
T* GetT();
private:
T* m_T;
};
template <typename T>
T* A<T>::GetT()
{
return m_T;
} Hope this helps.
By the way, to format your code on CodeProject, for small snippets, use the <code> attribute; for larger ones, use <pre>. To get angle brackets to render, you must use the < and >, or use the 'no HTML' check-box.
|
|
|
|
|
You can't do this at the moment with Visual C++.
Bummer I hope they'll add support for that soon...
By the way, to format your code on CodeProject, for small snippets, use the attribute; for larger ones, use
.
Yeah I should have done that, I'll remember it next time, thanks.
|
|
|
|