|
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#
|
|
|
|
|
plz give me solution to solve this problem
#sankar#
-- modified at 4:23 Thursday 22nd June, 2006
|
|
|
|
|
Hello everyone...
Below is a complete sample application.
How can i get the same output but the shape must be circle??
which line of coding do i need to change?
Please help me here.
It is urgent.
Thanks alot
Tillandran
-----------------------------------------------------------------------------
#include <windows.h>
#include <gl\gl.h>
#include <gl\glaux.h>
#include<math.h>
//initial square position and its size
GLfloat x=250.0f;
GLfloat y=0.0f;
GLsizei rsize=50;
GLfloat x2=0.0f;
GLfloat y2=0.0f;
GLfloat x3=250.0f;
GLfloat y3=250.0f;
GLfloat x4=0.0f;
GLfloat y4=250.0f;
//step size in x and y directions
//number of pixels to move each time
GLfloat xstep=0.10f;
GLfloat ystep=0.10f;
GLfloat x2step=0.10f;
GLfloat y2step=0.10f;
GLfloat x3step=0.10f;
GLfloat y3step=0.10f;
GLfloat x4step=0.10f;
GLfloat y4step=0.10f;
//keep track of window's changing width and height
GLfloat windowWidth;
GLfloat windowHeight;
//called by AUX library when the windows has changed size
void CALLBACK ChangeSize(GLsizei w, GLsizei h)
{
//prevent a divide by zero. when window is too short
// you cannot make a window zero width
if(h==0)
h=1;
//set the viewport to be the entire window
glViewport(0,0,w,h);
//Reset the coordinate system before modifying
glLoadIdentity();
//keep the square square, this time, save calculated width and height for later use
if(w<=h)
{
windowHeight=250.0f*h/w;
windowWidth=250.0f;
}
else
{
windowWidth=250.0f * w/h;
windowHeight=250.0f;
}
//set the clipping volume
glOrtho(1.0f, windowWidth, 0.01, windowHeight, 1.0f, -1.0f);
}
//called by AUX library to update window
void CALLBACK RenderScene(void)
{
glClearColor(0.0f,0.0f,1.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT);
//set drawing color to red and draw rectangle at current position
glColor3f(0.0f,1.0f,0.0f);
glRectf(x2,y2,x2+rsize,y2+rsize);
glColor3f(1.0f,0.0f,0.0f);
glRectf(x3,y3,x3+rsize,y3+rsize);
glColor3f(1.0f,0.0f,0.0f);
glRectf(x4,y4,x4+rsize,y4+rsize);
glColor3f(1.0f, 1.0f, 0.0f);
glRectf(x,y,x+rsize,y+rsize);
glFlush();
}
//called by AUX library when idle(window not being resized or moved)
void CALLBACK IdleFunction(void)
{
//reverse direction when you reach let or right edge
if(x>windowWidth-rsize || x<0)
xstep=-xstep;
//reverse direction when you reach top or bottom edge
if(y>windowHeight-rsize || y<0)
ystep=-ystep;
//check bounds. This is in case the window is made smaller and the retangle is outside the new clipping volume
if(x>windowWidth-rsize)
x=windowWidth-rsize-1;
if(y>windowHeight-rsize)
y=windowHeight-rsize-1;
//Actually move the square
x+=xstep;
y+=ystep;
//reverse direction when you reach left or right edge
if(x2>windowWidth-rsize || x2<0)
x2step=-x2step;
//reverse direction when you reach top or bottom edge
if(y2>windowHeight-rsize || y2<0)
y2step=-y2step;
//check bounds. This is in case the window is made smaller and the rectangle is outside the new clipping volume
if(x2>windowWidth-rsize)
x2=windowWidth-rsize-1;
if(y2>windowHeight-rsize)
y2=windowHeight-rsize-1;
if(x3>windowWidth-rsize || x3<0)
x3step=-x3step;
//reverse direction when you reach top or bottom edge
if(y3>windowHeight-rsize || y3<0)
y3step=-y3step;
//check bounds. This is in case the window is made smaller and the rectangle is outside the new clipping volume
if(x3>windowWidth-rsize)
x3=windowWidth-rsize-1;
if(y3>windowHeight-rsize)
y3=windowHeight-rsize-1;
if(x4>windowWidth-rsize || x4<0)
x4step=-x4step;
//reverse direction when you reach top or bottom edge
if(y4>windowHeight-rsize || y4<0)
y4step=-y4step;
//check bounds. This is in case the window is made smaller and the rectangle is outside the new clipping volume
if(x4>windowWidth-rsize)
x4=windowWidth-rsize-1;
if(y4>windowHeight-rsize)
y4=windowHeight-rsize-1;
//Actually move the square
x2+=x2step;
y2+=y2step;
x3+=x3step;
y3+=y3step;
x4+=x4step;
y4+=y4step;
//redraw the scene with new coordinates
RenderScene();
}
//main body of the program
void main(void)
{
//aux window setup and initialization
auxInitDisplayMode(AUX_DOUBLE || AUX_RGBA);
auxInitPosition(100,100,250,250);
auxInitWindow("Assignment 1");
//set function to call when window is resized
auxReshapeFunc(ChangeSize);
auxIdleFunc(IdleFunction);
//start main loop
auxMainLoop(RenderScene);
}
//GLAUX.LIB GLU32.LIB glut32.lib glut.lib OPENGL32.LIB
-- modified at 3:43 Thursday 22nd June, 2006
|
|
|
|
|
|