|
my problem isnt how to use msdn, as i have been programming for 6+ years.. and have used it a fair amount in that time... i have downloaded some sameple programs from this site and they all have the same problem....
|
|
|
|
|
are you forwarding your data port as well?
|
|
|
|
|
i dont know what port the data port is... can i set this up ?? if i use port 21 it works ok...
|
|
|
|
|
Here[^] is a decent explanation.
|
|
|
|
|
Hi,
In a current project I need a class that monitors some maintenance data and regularly writes them to a log file. As this class is used in different modules in different ways, the functions should be encapsulated as best as possible and the usual way of using this class should be by giving a filename to the constructor to configure the instance and then calling Collect() to immediately collect and log the data or calling EnableTimer(time_span) to regularly log the data to the log file every time_span milliseconds.
The problem I can't solve is the timer. My first approach was
<br />
<br />
BOOL CMaintMonitor::EnableTimer(UINT interval)<br />
{<br />
if(bl_TimerEnabled) StopTimer();<br />
bl_TimerEnabled = TRUE;<br />
ui_TimerInterval = interval;<br />
TimerID = SetTimer(NULL, 0, interval, TimerFunction);<br />
if(!TimerID)<br />
{<br />
bl_TimerEnabled = FALSE;<br />
ui_TimerInterval = 0;<br />
return FALSE;<br />
}<br />
return TRUE;<br />
}<br />
<br />
...<br />
<br />
BOOL CMaintMonitor::StopTimer()<br />
{<br />
if(bl_TimerEnabled)<br />
{<br />
bl_TimerEnabled = FALSE;<br />
ui_TimerInterval = 0;<br />
KillTimer(TimerID);<br />
}<br />
return TRUE;<br />
}<br />
TimerFunction was thought as a private method of CMaintMonitor that calls Collect(). Visual C++ didn't like this approach, telling me that it couldn't convert parameter 4 of SetTimer from void(...) to void(__stdcall *)(...). Reading the help pages again I saw that this function is meant to send a WM_TIMER message to a window whose message processing function should call the provided function instead of standard functions, so it still needs a WM_TIMER message processing even if the window handle provided is NULL .
The problem now is that I can't call a global function (I think this is what the compiler wants to say with the (__stdcall *) part of the error message) as Collect is a member function of an instance of CMaintMonitor using instance member data to do its work. So even if I found a way to use a global function for that timer event, I still need a way to give a pointer to my CMaintMonitor instance to that function for the call to Collect(), but I don't see a way to do so.
Can anyone help me solving the problem with that timer? This class should come without a user-Interface, so there is no window I can abuse to handle the timer event, and I can't even use the window of a caller as there are a lot of modules which come without UI either but still need to to use my monitor class. I'm new to programming under Windows, so I don't know if there might be an easy workaround for this problem I just don't know.
Thanks in advance
Martin Dietz
|
|
|
|
|
|
This looks interesting, but I can't find it in my helppages and my compiler doesn't find it neither although I included windows.h (as said in the MSDN article), is it available in Visual C++ 6.0 (sorry I forgot to mention that I'm pinned to that compiler)?
Greetings
Martin
|
|
|
|
|
I was using it with VC6 a few years ago. You need to download the latest SDK from MSDN and make sure to include the header and library file paths in the IDE setup.
[modified] That is "Platform SDK" sorry
led mikeLast modified: Tuesday, August 15, 2006 10:50:44 AM -- Platform SDK
|
|
|
|
|
Sorry, but if I have to download something I'm not sure other developers in my company have installed, it's useless. I can't bring up a solution that can only be compiled on my computer.
Thanks anyway, I'll try if I can make sense of the Multimedia Timers cje mentioned
Martin
|
|
|
|
|
m.dietz wrote: I'm new to programming under Windows
The Windows Platform SDK is a standard part of the operating system and any development environment. You should not be developing without it. You might want to do some reading about things life safe strings etc.
led mike
|
|
|
|
|
could you use using multi-media timers? There are articles here on code project that talk about them. I use a class that wraps the multimedia timer that I inherit from (MMTimer) that allows me to get an Update callback when the timer fires.
cje
|
|
|
|
|
Hello!
I've implemented a singleton class and i discovered that in every .dll that i accessed a instance of the singleton a new instance is created. So, in every dll i have a different instance. My question is :How can I have a single instance of the singleton between multiple dll ?
This is my implementation:
class cSingleton
{
private:
static cSingleton* m_instance;
cSingleton(){};
~cSingleton(){};
public:
static cSingleton& Instance();
};
cSingleton& cSingleton::Instance()
{
if(m_instance == NULL)
{
m_instance = new cSingleton;
}
return *m_instance;
};
Thanks!
-- modified at 3:33 Thursday 17th August, 2006
|
|
|
|
|
Hi people
How can I get the IP of a machine in my workgroup?
I get a list of connected PCs in the workgroup using NetServerEnum, so I have the computer Name
Thanks in advance
|
|
|
|
|
Kharfax wrote: How can I get the IP of a machine in my workgroup?
Use gethostbyname() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Fantastic, thanks a lot David, that was a quick answer
|
|
|
|
|
void GetLocalIPAddress(char *ipAddress)
{
#define MAX_NAME_LEN 65
WSADATA wsaData;
if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) == 0 )
{
char HostName[MAX_NAME_LEN];
struct in_addr *ptr;
gethostname (HostName,MAX_NAME_LEN);
hostent *host = gethostbyname(HostName);
if(host == NULL)
{
ipAddress = NULL ;
WSACleanup( );
return ;
}
ptr = (struct in_addr *)host->h_addr_list[0];
CString str;
str.Format("%d.%d.%d.%d",
ptr->S_un.S_un_b.s_b1,
ptr->S_un.S_un_b.s_b2,
ptr->S_un.S_un_b.s_b3,
ptr->S_un.S_un_b.s_b4);
strcpy(ipAddress,(char*)str.GetString());
}
WSACleanup( );
}
|
|
|
|
|
Hey thanks a lot for the code
Anyway once David told me about gethostbyname the rest was easy.
But what I noticed is that I forgot to call WSACleanup(), now thanks to you I know I should call it
|
|
|
|
|
I have a CListCtrl embedded in a CView object which covers
the client area completely.
I am running the list control in report mode with several columns.
I want one column to follow the size of the listcontrol (view),
but I am running into some problems.
I cannot ask the list view for its client rect in the
OnInitialUpdate function because that always returns an
rectangle that is not correct yet. I don't know at what stage the client rect
will become valid so it is difficult to determine where
to put my column sizing code.
Any tips on how/when I can get the width of the window to
size my column?
Thanks
|
|
|
|
|
You can use the SetColumnWidth() member function, in addition to the LVSCW_AUTOSIZE / LVSCW_AUTOSIZE_USEHEADER parameter to resize your columns.
I tend to override the WM_SIZE message (OnSize() handler function), then call this function.
Now if you want to over the entire client area, you are on the right track when you said that you obtained the client rect. But not in the OnInitialUpdate() function, do this either after populating your control, or in the size handler.
I Dream of Absolute Zero
|
|
|
|
|
You could derive a class from CListCtrl and then you could add some code in OnSize() that adjusts the column width. This seems the best way to me - plus it is very reusable.
A cynic is a man who, when he smells flowers, looks around for a coffin. -H.L. Mencken
|
|
|
|
|
Do you use SetColumnWidth or Do you have a derived class from ListCtrl
|
|
|
|
|
Hi all,
As long as the OnSize handler gets called, the sizing works fine.
But when I reopen a new document in a SDI application, the OnSize
handler seems not to get called. Where do I have to place my sizing
routine which calls SetColumnWidth(...) ??
tia
|
|
|
|
|
Hi all,
Please help me out of this problem.
I have 3 classes which all require each other.
The problem is that they fail to recognize each other on compilation and give errors as: Undefined class Two, Undefined class Three and Undefined class One
Someone suggested me forward declaration. But that too did not help.
Where am i going wrong ? Please help me.
Here is my code.. (Actually i am having the same problem with an VC++ program. This is just to simulate the same problem)
File1.h
class One
{
private:
int one;
public:
int GetOne();
Two tw;
Three th;
};
File2.h
class Two
{
private:
int two;
public:
int GetTheTwo();
One on;
Three th;
};
File3.h
class Three
{
private:
int three;
public:
int GetAslThree();
One on;
Two tw;
};
File1.cpp
#ifndef _FILE1_H
#define _FILE1_H
#include "File1.h"
#endif
int One::GetOne()
{
return one;
}
File2.cpp
#ifndef _FILE2_H
#define _FILE2_H
#include "File2.h"
#endif
int Two::GetTheTwo()
{
return this->two;
}
File3.cpp
#ifndef _FILE3_H
#define _FILE3_H
#include "File3.h"
#endif
int Three::GetAslThree()
{
return this->three;
}
Thanks in advance.
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
Forward declaration can only be used for pointer types because the concrete definitions of the types have not been known yet in the compilation scope.
class One;
class Two;
class Three{
private:
int three;
public:
int GetAslThree();
One* pon;
Two* ptw;
};
Maxwell Chen
|
|
|
|
|
Hi Maxwell,
Thanks a lot for the quick reply.
That really helped me.
But i have a situation where i do need to declare an object rather than a pointer, is there any possible way for it?
Is it possible that i declare the pointer inside the class, and in the constructor of the class, i allocate memory for it. I am not able to make that work. Is there any other way for it.
Thanks in advance !!
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|