|
Anybody know how to write modules to Flight Simulator 2000????
If you know please contact with me on this email:
piopawlu@interia.pl
|
|
|
|
|
|
Is it possible to have a timer in the background of a console-based program? Maybe an API function that takes a pointer to a function in my program?
I would be very happy if it could even operate in the background of a prompt for text input.
The reason for this question, is that I am developing a text-based adventure game (Yes, it IS true), and I want it to be real-time.
Thanks in Advance.
Ulf
|
|
|
|
|
You can't use the Windows WM_TIMER message without a window. (this includes the callback function variation, which simply translates the window message to a callback).
There are several solutions to this.
1) Create a hidden window to recieve the messages
2) Use the Sleep() function to sleep for the amount of time that you would want to use a timer for. This has the drawback of blocking until the time is up.
3) Use a multimedia timer.
|
|
|
|
|
What I have to do to retrieve the text of a DOS program while it runs and show the text in a TextBox Control for example? In other words, how I can monitor the output of a DOS program? Thanx.
|
|
|
|
|
when I include the afxpriv.h file (doesn't matter which file its included in)
I get the following messages after compiling:
..\include\afxpriv.h(640) : error C2259: 'CDockBar' : cannot instantiate abstract class due to following members:
..\include\afxpriv.h(565) : see declaration of 'CDockBar'
..\include\afxpriv.h(640) : warning C4259: 'void __thiscall CControlBar::OnUpdateCmdUI(class CFrameWnd *,int)' : pure virtual function was not defined
..\include\afxext.h(165) : see declaration of 'OnUpdateCmdUI'
The reason I want to include this file is to use the CControlBar.
How do i include this file without getting these error ??
Thanks
|
|
|
|
|
Why do you think you need to include that file to use CControlBars? I have never needed to included it.
What exactly are you up to?
Roger C.
|
|
|
|
|
Oh... I see, it's used in the CtrlBars sample. I'm not clear as to the error messages... I'll take another look.
|
|
|
|
|
afxpriv.h is not intended to be used by user programs, but it's there as an "If you insist, but we don't support this" kind of thing.
Generally this code means that OnUpdateCmdUI is a pure virtual function which cannot be sued by itself, you must inherit from it and specify your own OnUpdateCmdUI function.
|
|
|
|
|
CControlBar is an abstract class. I am trying to understand what you are doing and I get the feeling you are tying to create a CControlBar object.
|
|
|
|
|
Roger and Erik above are right. CControlBar is an abstract class (has abstract member functions) and you can't instantiate an object from it. You should derive your own class from CControlBar (say CMyBar) and provide your implementation of the virtual function.
You can define OnUpdateCmdUI() as a do-nothing function in your class.
Take a look at my code here: http://www.codeproject.com/docking/sizecbar.asp
If you are patient, you will see that CSizingControlBar is derived directly from CControlBar, and it provides its own OnUpdateCmdUI().
|
|
|
|
|
Is it possible to pass a parameter of type void * in a DCOM interface? If not, is there a way around passing data structures via address where the type is not specified?
|
|
|
|
|
Hi Gurus,
How to get control panel object? Actually i want to add a atb control
to control panel / display properties, Can any body tell me how to proceed?
I think it is possible by getting control pnel object from that by getting
Display properties object, then only there is a chance of adding a tab control
to diaplay properties.
Is there any possibility to get control panel's object through Ishellbrowse,
IShellview etc.
If anybody have an idea, send me links or articles.
Thanks in advance,
Koteswara
|
|
|
|
|
I've tried to store the windows location/size in the registry, and it appears to save the right numbers, but when I read them back in and call MoveWindow it seems to change the numbers. Is move window the right function to call for this, or am I saving the wrong postion using by calling GetWindowRect? I'm pretty sure that its not any of the code that is wrong, but rather that I'm not saving the right numbers.
thanks tyler.
|
|
|
|
|
There are a few possible issues.
1/ Where are you setting the position
2/ what sort of co-ordinates are you saving ( relative to window or relative to dialog ) ? ClientToScreen will convert your co-ordinates to ones relative to the whole window
3/ Have you checked the values going in and coming out to make sure you're reading them correctly ?
4/ Are you passing them in correctly ( MoveWindow takes a width and height, rather than x2, y2. )
|
|
|
|
|
ah yeah, MoveWindow takes width and height and not x2, y2.
I wish I remembered that.
I did this once in MFC though the same way with MoveWindow using GetWindowRect but when looking back through the code I missed the rect.Width(), and rect.Height() instead of just a RECT structure passing the bottom and right.
thanks for the help.
|
|
|
|
|
You may also try with Get/SetWindowPlacement() .
If you save and restore all its fields you can also restore minimized/maximized state.
Cheers
Paolo.
|
|
|
|
|
I suggest that you should read the topic about Persistent Frames in the book Inside Visual C++ from Kruglinsky from Microsoft Press.
|
|
|
|
|
to save the Window position :
WINDOWPLACEMENT pwp;
BOOL ret;
ret = GetWindowPlacement(&pwp);
CString strBuffer;
strBuffer.Format("%i %i %i %i %i %i %i %i %i %i",
pwp.flags, pwp.showCmd,
pwp.ptMinPosition.x , pwp.ptMinPosition.y ,
pwp.ptMaxPosition.x , pwp.ptMaxPosition.y ,
pwp.rcNormalPosition.left , pwp.rcNormalPosition.top ,
pwp.rcNormalPosition.right , pwp.rcNormalPosition.bottom);
AfxGetApp()->WriteProfileString("Settings","windowPos",strBuffer);
to restore the window position :
WINDOWPLACEMENT pwp;
CString strBuffer = AfxGetApp ()->GetProfileString("Settings","windowPos");
int cRead = _stscanf(strBuffer,"%i %i %i %i %i %i %i %i %i %i",
&pwp.flags,&pwp.showCmd,
&pwp.ptMinPosition.x , &pwp.ptMinPosition.y ,
&pwp.ptMaxPosition.x , &pwp.ptMaxPosition.y ,
&pwp.rcNormalPosition.left , &pwp.rcNormalPosition.top ,
&pwp.rcNormalPosition.right , &pwp.rcNormalPosition.bottom);
if (cRead == 10) SetWindowPlacement(&pwp);
|
|
|
|
|
thanks a lot, this is much better than what I was doing previously.
|
|
|
|
|
Just one thing that you forgot, when you restore the window's position you need to set pwp.length = sizeof(pwp) for anybody else that sees this.
Tyler.
|
|
|
|
|
As you probably noticed from this post I am a very new newbie to VC++. Here is my problem. I need to read in a test file that might have a format like this... string, int, int. I know in java you can use a string tokenizer to read in each value separatly and by line. I can't seem to figure this out in C++. This is what I have been doing.
CFile myFile("test.txt", CFile::modeWrite);
BYTE buffer[4096];
CString input;
input = myFile.Read(buffer, 4096);
Once I get it into a string object I can use the method SpanExcluding to get a string from the beginning to the first character I specify not to read. I can't seem to get past it thought. I know my approach is probably all wrong so I don't care if you tear it to shreads. I frequently visit this site and know you guys know what you;re doing so thanks for any advice in advance.
Joshua
|
|
|
|
|
Joshua, use CStdioFile instead of CFile; it lets you read in a line at a time.
For grabbing the tokens, you can use the CRT function strtok(), or the undocumented MFC function AfxExtractSubString(). You use the function thus:
// assuming you have a CString sLine that holds the next line...
CString sStringToken, sIntToken1, sIntToken2;
AfxExtractSubString ( sStringToken, sLine, 0, ',' );
AfxExtractSubString ( sIntToken1, sLine, 1, ',' );
AfxExtractSubString ( sIntToken2, sLine, 2, ',' );
The prototype for AfxExtractSubString() is:
BOOL AfxExtractSubString(CString& rString, LPCTSTR lpszFullString, int iSubString, TCHAR chSep = '\n');
where rString is where the token is placed, lpszFullString is the string to search, iSubString is the token to pull out (a 0-based count), and chSep is the delimiter character.
|
|
|
|
|
Thanks for the insight. This is exactly what I was looking for, I just didn't know where to go. Thanks again for your time.
Joshua
|
|
|
|
|
To add to what Michael has given you...
Text file are usually much easier to handle if you use CStdioFile instead of CFile. CStdioFile allows you to easly read each line in a loop. For example...
CStdioFile f; // construct a CStdioFile object
char buffer[256]; // define a temp buffer
while (f.ReadString(szBuffer, 255))
// tokenize string and process
Roger C.
|
|
|
|