|
Cedric Moonen wrote: Yes, but... Why use a class then ?
Just to gather things that deal with the same subject...
|
|
|
|
|
If your ConfigFile value isn't ever going to be changed, then you can do this
class ConfigManager
{
.
.
.
private:
static const CString ConfigFile = DEFAULT_PROFILE;
};
|
|
|
|
|
Weiye Chen wrote: private: static const CString ConfigFile = DEFAULT_PROFILE;
this is not allowed in C++ (you are showing a C# solution)
he must initialize its static member outise of the class
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
toxcct wrote: this is not allowed in C++ (you are showing a C# solution)
he must initialize its static member outise of the class
Right,
Moreover I'd like to be able to change the ConfigFile.
|
|
|
|
|
You could put the constant in an anonymous namespace at the top of your implementation file, rather than in the class. You could also have GetConfigFile() set the file name if it hasn't been set, and always call it, rather than use the filename directly - that way it would always be initialised before it was used
Cedric is right though. Since your class contains state, it is better implemented as a singleton, rather than a bunch of static methods and a static data member.
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"
|
|
|
|
|
Ryan Binns wrote: You could also have GetConfigFile() set the file name if it hasn't been set
Yes I had this idea already... but did not succeed at first... I had a look again after seeing your message and it seems the following code works :
<br />
CString ConfigManager::GetConfigFile()<br />
{<br />
static bool bInit = false;<br />
if (!bInit)<br />
{<br />
ConfigManager::ConfigFile = DEFAULT_FILE;<br />
bInit = true;<br />
}<br />
return ConfigManager::ConfigFile; <br />
}<br />
Thanks
|
|
|
|
|
Yep, that will do it. I would recommend either putting the variable in an anonymous namespace or making your class a singleton though. It's not much of a hack.
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"
|
|
|
|
|
I do a project with Directshow. I want preview from a carema in two windows and play a flie in two windows . But directshow can only set one window with a function named put_owner().How can I do?
|
|
|
|
|
Directshow (the framework) has no such limitation. You would however have to build the filter graph manually or semi-manually (use ICaptureGraphBuilder2). The easier way would probably be to use an Infinite Pin Tee Filter and have a few video renderers to render the video. The harder way would be to write your own video renderer. Why do you need to preview in 2 windows and play in 2 windows. So that means you have 4 video renderers? And what is the difference between your preview and your playback windows? Modification: Just saw that your playback windows are playing back files. In which case you need more than one filter graph.
-- modified at 7:23 Thursday 22nd June, 2006
|
|
|
|
|
For a Dialog initialization, there's OnInitDialog function provided by CDialog! For the same same functionality in a Frame window, which Initialization function is Most suitable?
SaRath.
"Do Next Thing..."
Understanding State Pattern in C++
|
|
|
|
|
Try:-
void InitialUpdateFrame( CDocument* pDoc, BOOL bMakeVisible );
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
|
You can try OnCreate(...) of your CMainFrame.
|
|
|
|
|
Hi,
I need my dialog to be active in the background so it works when other applications are running in the foreground. Is there a way to do this?
Thanks for your help
|
|
|
|
|
What do you mean by ACTIVE?(Plz Clarify)
The application created keeps on working even when other application is running. It's just the fact that it looses focus.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Well, I currently have an dialog application which polls a joystick and uses these values to perform an operation on external equipment. However, I will be using video which must be full-screen so the dialog will lose focus. The dialog only reads the joystick values when it has focus. So i need the dialog to read the data when it loses focus.
Maybe, a dialog application is not the best method
|
|
|
|
|
|
You can put a timer in your dialog and do your polling there.
|
|
|
|
|
If you want to minimize,
then WM_SETFOCUS message handler or OnActivateApp,
Call
ShowWindow(SW_MINIMIZE) for minimizing
ShowWindow(SW_HIDE) for hiding the window. Hope I answered you
SaRath.
"Do Next Thing..."
Understanding State Pattern in C++
|
|
|
|
|
Thanks for the advice and time.
The problem was to do with the joystick cooperative levels in the DirectInputDevice. Changing the cooperative level allowed the application to have access to the device when running in the background.
|
|
|
|
|
Hi,
Ive done some searching with no luck to get the ip of client connected to a socked using winsock.
heres what ive got which may be totally off...
accept( ListenSocket, (SOCKADDR*) &clientip, NULL);
int strangeip=clientip.sin_addr.s_addr;
strange ip reports some strange int... cant figure out how to get the actual ip there.. or convert the u_long to hostent.. i think i can get hostent converted to ip however cant get that far...
any help would be appreciated...
|
|
|
|
|
See if this helps
inet_ntoa(client.sin_addr)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
hmm.. getting 204.204.204.204 from the inet_ntoa.. which probably means.. that part of the accept is not going to help me get the ip... i assume..
ive seen this before....
char hostname[256]; struct hostent *host; in_addr ip; gethostname(hostname, 256); host = gethostbyname(hostname); memcpy(&ip, host->h_addr, sizeof(ip)); printf("First host IP is: %s\n", inet_ntoa(ip));
which seems to get the local ip.. which is not what im trying to do...
|
|
|
|
|
I think you can get the IP in this manner:
sockaddr_in clientAddress;
accept( ..., (SOCKADDR*)&clientAddress, ...);
in_addr inAddr = clientAddress.sin_addr;
Now the four components of IP, from left to right, are in inAddr.S_un.S_un_b.s_b# members:
printf("The IP is: %i.%i.%i.%i",
inAddr.S_un.S_un_b.s_b1,
inAddr.S_un.S_un_b.s_b2,
inAddr.S_un.S_un_b.s_b3,
inAddr.S_un.S_un_b.s_b4);
Hope it helps.
|
|
|
|
|
here i had aproblem in usage of smpp ie the parameters are not matching with the code in SMPPlibTest.so plz kindely help me howto use SMPP in my project to send SMS
#sankar#
|
|
|
|