|
Thanks so much for your reply!
I unfortunately can't say that my DLL is working, but the problem I have now is one in relation to the SDK, not with C++ or the help you offered. The 'extern "C" __declspec..." line did the trick fine, and I'm starting to get the hang of this!
Thanks again.
|
|
|
|
|
Hi
Need help. How do i get all Files and Directories in a specified Directory
MFG
RedDragon2k
Unix and C are the ultimate computer viruses.
|
|
|
|
|
|
Save yourself some trouble and look here[^] under the General section and file globbing.
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
The default of an SDI application is SW_SHOWDEFAULT = SW_NORMAL.
How and where can this be changed to SW_MAXIMIZE?
thanks
|
|
|
|
|
Are you wanting to make the frame initially maximized? If so, just change SW_SHOW to SW_MAXIMIZE in the app's InitInstance() method.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have a class called 'CWatchedWindow', and a vector container in my dialog class to hold pointers to CWatchedWindow objects.
I'm trying to use the find algorithm on the vector for a new object. The determining factor for one CWatchedWindow object to be equal to another is the string it holds, (m_strName). The operator== works in a simple if() statement, but it won't call any of the overloaded functions for operator== when I use the find algorithm using a pointer to an object of type CWatchedWindow. And I can't use it by de-referencing the pointer, because the template won't recognize it. Here's my class definition:
class CWatchedWindow
{
public:
unsigned long m_nSeconds;
CString m_strName;
COleDateTime m_lastTime;
CWatchedWindow()
{
m_lastTime = COleDateTime::GetCurrentTime();
m_nSeconds = 0;
}
bool operator== (const CWatchedWindow& sWord )
{
return m_strName.CompareNoCase(sWord.m_strName) == 0;
}
bool operator== (const CWatchedWindow sWord )
{
return m_strName.CompareNoCase(sWord.m_strName) == 0;
}
bool operator== (CWatchedWindow* pWord )
{
return m_strName.CompareNoCase(pWord->m_strName) == 0;
}
bool operator== (const CString& sWord )
{
return m_strName.CompareNoCase(sWord) == 0;
}
};
and here's the call to find:
CWatchedWindow win;
win.m_strName = m_strLastWindowCaption;
CWatchedWindow* pWin = &win;
vector<CWatchedWindow*>::iterator findIter;
findIter = find(vecWindows.begin(),vecWindows.end(),pWin);
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
The problem here is you're comparing pointers, and not the objects they point to.
Here's the code for find algorithm:
<br />
{
for (; _First != _Last; ++_First)<br />
if (*_First == _Val)<br />
break;<br />
return (_First);<br />
}<br />
*_First dereferences the iterator, which gives you a pointer to a CWatchedWindow. So basically, you're doing this:
<br />
int * x = 0;<br />
<br />
if (x == 10)<br />
<br />
whereas you want this:
<br />
int * x = 0;<br />
<br />
if (*x == 0)<br />
<br />
The way that I know to get around this problem is by using find_if() with a predicate.
<br />
<br />
class MatchName<br />
{<br />
MatchName(LPCTSTR lpszName) : m_strName(lpszName)<br />
{<br />
}<br />
bool operator()(CWatchedWindow* window)<br />
{<br />
return (window->m_strName.CompareNoCase(m_strName) == 0);<br />
}<br />
}<br />
<br />
<br />
iFind = find_if(blah.begin(), blah.end(), MatchName("Window Name"));<br />
<br />
if (iFind != blah.end())<br />
AfxMessageBox("Found it");<br />
<br />
The code for find_if is as follows:
<br />
<br />
for (; _First != _Last; ++_First)<br />
if (_Pred(*_First))<br />
break;<br />
return (_First);<br />
The _Pred(*_First) line triggers the function call operator defined in MatchName for each of the objects in the vector.
I think there is a way to avoid creating a class (ptr_fun? or something bizarre like that), but I'm only familar with the above method.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Cool! I thought about the find_if(), but I thought I was doing something wrong, that I should've been able to do it with find(). I stopped using pointers yesterday when I got frustrated, and just used the objects themselves. Either way, the same amount of CWatchedWindow objects will be hanging around for the duration of the program, and I don't have to worry about memory leaks this way. Is there any reason you can see why I shouldn't use the objects themselves instead of pointers? This seems to be a cleaner solution, but I'm not sure. Your solution is great, but I'm thinking it's better not to use workarounds if I don't have to?
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Is there any reason you can see why I shouldn't use the objects themselves instead of pointers? This seems to be a cleaner solution, but I'm not sure. Your solution is great, but I'm thinking it's better not to use workarounds if I don't have to?
It's perfectly fine to use the objects, I don't see it being a problem at all.
The rule of thumb I used to use, was to use pointers if the class was large/complex, that way algorithms/functions could access the object using a simple pointer address (32 bit variable) instead of creating a new copy of the object each time. The only reason for this (that I was told) was the speed gain, and given how fast today's computers are, there may not be much of a speed difference anymore.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Hi
Is there any way to create a recordset from the CListCtrl object ?
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Your question is a bit ambiguous. Are you wanting to create a CRecordset object from within a CListCtrl object, or are you wanting to add records to a CRecordset object based on the items in a list control?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
Am sorry, I shall put it right.
I want to export the CListCtrl data to excel File.
For this I want to get the recordset of CListCtrl object. This should be ado recordset. Then I can export to excel file using
Range.CopyFromRecordset(AdoRecordSet,...,...); function.
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
zainu wrote:
For this I want to get the recordset of CListCtrl object.
A CListCtrl object does not contain a record set, ADO or otherwise.
I've not ever used ADO so I may be off, but I think you'll need something like:
#import "c:\program files\Common Files\System\ado\msado15.dll"
_ConnectionPtr pCn;
_RecordsetPtr pRs;
CoInitialize(NULL);
pCn.CreateInstance(__uuidof(Connection));
pRs.CreateInstance(__uuidof(Recordset));
pCn.Open(...);
pRs.Open(..., pCn, ...);
for (int x = 0; x < m_listctrl.GetItemCount(); x++)
{
CString strText = m_listctrl.GetItemText(x, 0);
pRs->AddNew(...);
}
pRs.Close();
pCn.Close();
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
I want to integrate an activeX control (NTGraph2D) in my Visual C++ .Net 2003 application for displaying graphs, but I´m not sure how to do it.
Could somebody give me a clue, as I am quite new to both VC++ .net and activeX controls?
(I have tried to search these pages also, but I didn´t find any articles that mached my needs)
best regards,
eirik
|
|
|
|
|
I was looking at the Automation Object Model chart and saw the VCProject object. In the help files I see an example where the VBProject is retrieved using DTE::GetObject("VBProjects"). I was wondering does anybody know how to do it for the VCProject and what IDispath derived object I need?
I am the handsome one in the crowd.
|
|
|
|
|
Hi,
In order to create a virtual COM port(for BlueTooth Comunication),
I need the address of the BlueTooth device.
I know the BD_ADDR,but i must convert it to BT_ADDR if i want to use
the RegisterDevice() function.
anyone?
Regards,
Eli
|
|
|
|
|
hi every one,
i am connecting two computers using dial-up connection (modem to modem on phone line)...very after the connection is established btw two computers you can see the client and server ip addresses by double clicking the connection status window in system tray.
all i need to access the both ip addresses programatically in vc++ 6 or 7 or c#...
plz let me know if someone could help me on this email address
msherazkhan@hotmail.com
i 'll be thankful
|
|
|
|
|
Hi all,
I've a problem: copy files to remote computer using Window XP by programming.
I have found WNetAddConnection2 function, but when I try to use this function connect to remote computer use WinXP with user has administrator right, it alway return "5" (Access Denied).
Here is my code
==================RemoteConnect.cpp=======================
#include <windows.h>
#include <stdio.h>
#include <winnetwk.h>
void main(){
NETRESOURCE nr;
DWORD res;
TCHAR szUserName[32] = "administrator",
szPassword[32] = "",
szLocalName[32] = "Q",
szRemoteName[MAX_PATH] = "\\\\sas\\C$";
//
// Assign values to the NETRESOURCE structure.
//
nr.dwType = RESOURCETYPE_DISK;
nr.lpLocalName = szLocalName;
nr.lpRemoteName = szRemoteName;
nr.lpProvider = NULL;
printf("%s\n", nr.lpRemoteName);
//
// Call the WNetAddConnection2 function to assign
// a drive letter to the share.
//
res = WNetAddConnection2(&nr, szPassword, szUserName, FALSE);
//
// If the call succeeds, inform the user; otherwise,
// print the error.
//
if (res == NO_ERROR)
printf("Connection added %s\n", szRemoteName);
else
printf("Error: %ld\n", res);
return;
}
==========================================================
Anyone know why this function failed?
If possible, please show me the solution to connect to remote computer using Win XP by programming (using WNetAddConnection or the other solutions).
I've hear about tftp, but i wonder that, if the remote computer don't have tftp listening, how can i use tftp to copy the files to it?
Please, help me find the right solution to do that.
Many thanks.
.::LDLP::.
|
|
|
|
|
L D L P wrote:
I've a problem: copy files to remote computer...
please show me the solution to connect to remote computer using...
So what are you wanting help with, copying a file, or connecting to a remote computer? There is no need to connect to the remote computer (via WNetAddConnection2() ) just to copy a file to it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I just want to copy mutilple files to it, into many folders of it.
How can i do that? Note that I want to copy to Win XP computer
.::LDLP::.
|
|
|
|
|
L D L P wrote:
I just want to copy mutilple files to it, into many folders of it.
You can use CopyFile() , CopyFileEx() , or SHFileOperation() for this. The first two operate on one file at a time, while the last one supports wildcards.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
Bring window on the top use the function "SetForegroundWindow".
Is there any function to minimize the window?
|
|
|
|
|
If you are Using MFC
this->ShowWindow(SW_MINIMIZE);
if you are Using Win32 api based Application
ShowWindow(hWnd,SW_MINIMIZE);
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
ting668 wrote:
Bring window on the top use the function "SetForegroundWindow".
Are you wanting to know the syntax of this function, or are you already using it but it is not producing the desired results?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|