|
I'm reading a text-file. Looks like this:
name= "Test";<br />
mass= 5000;<br />
MountPoints= 3;
In the code I've got this:
label = group + '/';
These variables are of type std::string.
At this point group contains "Vehicle". When label contains "name" or "mass" the label is correctly reseted to "Vehicle/". But when it comes to "MountPoints" it just sets it to ??? (According to the watch in VS). If I in the text-file cut down that row to just "MountPo", it works. Why??? Anyone knows?
|
|
|
|
|
How big is the variable that you are using to read the file? Seem highly significant to me that Vehicle and MousePo are the same size.
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
Hm, I didn't notice that they were of the same length...
I use this to open the file:
ifstream theFile;<br />
theFile.open(fileName);
And this to read:
while (tempChar = theFile.get())<br />
{<br />
...<br />
label += tempChar;<br />
...<br />
}
Both label and group are of type std::string. I thought that these strings adjusted their size as needed.
|
|
|
|
|
Anyone else got any idéas? I really can't figure this out, doesn't use the string-class so often.
If the read label is more than seven characters long, the row
label += group + '/'
makes "label" get the value '???'
"group" contains 'vehicle' at the given moment...
|
|
|
|
|
I wrote a screensaver that mutes the volume using a call to mixerOpen followed by all the other relevant calls to get the ID of the MIXERCONTROL_CONTROLTYPE_MUTE. It works fine on my Windows98 machine, muting the sound perfectly. However it never works on WindowsXP, I believe that the mixerOpen function keeps failing. Does anyone have any ideas of how to mute the sound on XP. Unfortunately I don't have an XP machine that I can develop on.
|
|
|
|
|
If mixerOpen() fails, it will return a specific error code. What is that error code?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
mixerOpen() returns 2. I can't look up what MMSYSERR that is right now, as I don't have VC++ on the XP machine. As I said though, it works fine on 98.
|
|
|
|
|
It appears to be MMSYSERR_BADDEVICEID . What does the call to mixerOpen() look like?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks for the help DavidCrow, but I got it fixed now. I was calling mixerOpen like this
if (mixerOpen(&hMixer, MIXER_OBJECTF_HMIXER, 0, 0, 0) != MMSYSERR_NOERROR)
return FALSE;
It worked on Windows98, but not on XP, only when I re-read the documentation did I change the second parameter to 0.
|
|
|
|
|
I am a beginner at Visual C++. I created an editbox with an dword variable. I would like to enter hexadecimal values in the format for example 004FD210 and i want the corresponding variable for the editbox or (maybe with a small code others) to have corresponding decimal value. I thought to read into a string andthen to convert it to integer value. But is there a shorter way. Pls.
|
|
|
|
|
converting string to interger: value strtol(), strtoul().
converting interger value to hex string: sprintf(pStr,"%X",nValue).
If you want to convert to hex string with leading 0's:
sprintf(pStr,"%8.8,X",nValue); // 00000000
Or
sprintf(pStr,"%*.*,X",8,8,nValue); // 00000000
I believe those should work for ASCII formated string.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi all,
I am writing a program that continuously stores data from an external memory.
while(isConnected)
{
// Do stuff over here
}// end while
However, when it runs, it takes all the memory (program is not responded).
I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed.
Any suggestions? Thanks.
|
|
|
|
|
|
Use a worker thread. If you don;t thread the application, then the reason you're locking the program up is because the Message Loop never has the chance to run, and therefore the button press is never noticed. Use a thread for the user interface, and one to do the loop.
|
|
|
|
|
An alternative is to pump the message queue every n iterations of the loop. There is no need to create a worker thread.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hello,
I'm writing to ask some explanations on the excellent article "Using Custom Controls in a Dialog Bar" by Douglas R. Keesler, see http://www.codeproject.com/useritems/DerivedDlgBar.asp. Maybe that I did not understand everything, I'm french and my english is not so good.
So my matter is about how to create a menu in a CDialogBar :
I have made a little MDI which has got a CDialogBar with VC++6.0 .
In this class, I want to put a Menu.
So I made that you said :
- create a CDialogBar : IDD_DLGBAR_TEST ,
- create a Menu in my ressource : IDD_DLGBAR_TEST ,
- create the class MyDlgBar (import files MyDlgBar, remove file.clw and clic on ctrl+w to wizard VC6.0 as he said)
- select to this ressource the classe MyDlgBar
- put in the class CMainFrame the instance : CMyDlgBar m_dlgBarTest
- put the creation of this box in the create function of the CMainFrame with :
m_dlgBarTest.Create(this, IDD_DLGBAR_TEST, <br />
CBRS_RIGHT | CBRS_GRIPPER |CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,<br />
IDD_VIEW_MENU_DLGBAR)
- I put, in the message map of my CMainFrame, the 2 lines :
ON_COMMAND_EX(IDD_VIEW_MENU_DLGBAR, OnBarCheck)<br />
ON_UPDATE_COMMAND_UI(IDD_VIEW_MENU_DLGBAR, OnUpdateControlBarMenu)
- then I compile and I built my application.
When I execute this application, I have got :
- the main frame
- the floating dialog box (CDialogBar)
But I haven't got the menu of this floating box !
I search in the source of the demo project but I don't see the menu that we could see in the article.
Perhaps the autor forgot to write something to realize a menu in a CDialogBar?
Or perhaps I don't understand all ...
Could you explain to me how to realize it ?
Thanks very much to help me !
Alice
|
|
|
|
|
Maybe this will be disappointment for you but child window cannot have menu. Since dialog bar is a child window (either main frame or floating frame) it will not show menu.
JohnCz
|
|
|
|
|
How does one implement undo functionality in a Vc++ environment . Always is a definete wish list thing but dont have a clue as to how to implement it .
Engineering is the effort !
|
|
|
|
|
I would start by typing "Undo" (sans quotes) in the search bar on the top of this page (directly under Bob) and read the articles that are listed.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
since "undo" is a vast and sometimes complex domain, I suggest that you examine the following :
Undoing an operatation depends on the way the operation was done initially.
for example, you do a "create something" operation/command, the undo operation/command might simply be a cut or a remove, or worse, an "uncreate something"; do after that, if you go furher, what is the undo of the undo ( redo ); is it do a "create something" again ? or a paste or something ?
in my opinion, a good undo/redo system depends on the way you handle the different commands ( or actions) in your application.
for example, in a DB, you create a new record, the command that creates the record should contain as much context as possible so that you can recreate the record without any user action.
if you look from the other side.
you remove a record and do an undo, what is the result command ? is it a "create record" or something like a "paste" ?
...
so there are a lot going on here...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Im having this wierd problem regarding outputing a file in the same path as the .exe, whenever i save the settings for my app it always save it to the desktop i have no idea why...its suppose to save it in the same path as the exe.. this is the first time ive had this kind of problem, this is almost the same code i always use and yet its not working the way it should be i dont know why..
heres the code
heres the defined values:
#define FILENAME_S "settings.ini"
#define STRINGi "Font=%s\nFont_Size=%d\nShow_Margin=%d\nShow_Toolbar=%d\nShow_Workspace=%d\nShow_Status=%d\nFile1=%s\nFile2=%s\nFile3=%s\nFile4=%s"
This is part of this FILESTUFF CLass
int FILESTUFF::saveIni( SETTINGS *st )
{
FILE *file;
if( ( file = fopen( FILENAME_S, "w+" ) ) == NULL )
return 0;
stripSpace( st->font, 1 );
stripSpace( st->file1, 1 );
stripSpace( st->file2, 1 );
stripSpace( st->file3, 1 );
stripSpace( st->file4, 1 );
fprintf( file, STRINGi , st->font, st->fontSize, st->showMargin, st->showToolbar, st->showWorkspace, st->showStatusBar, st->file1, st->file2, st->file3, st->file4 );
loadIni( &*st );
fclose( file );
return 1;
}
int FILESTUFF::loadIni( SETTINGS *st )
{
FILE *file;
if( ( file = fopen( FILENAME_S, "r+" ) ) == NULL )
return 0;
fscanf( file, STRINGi , st->font, &st->fontSize, &st->showMargin, &st->showToolbar, &st->showWorkspace, &st->showStatusBar, st->file1, st->file2, st->file3, st->file4 );
stripSpace( st->file1, 0 );
stripSpace( st->file2, 0 );
stripSpace( st->file3, 0 );
stripSpace( st->file4, 0 );
return 1;
fclose( file );
}
I have no idea
|
|
|
|
|
If you only specify the file name, not the entire path as you are doing, then the file will be opened in the current working directory which is not necessarily the same as app's installed directory. To ensure the file is saved in the directory you want it in always specify the full path.
You can use GetModuleFileName() to get the path to the exe.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Yeah i can use that function, but there must be an explanation why this is happening, and my current working directory isnt my desktop so it wont be that.. there must be some thing else i did wrong just dont know wht it is...
I have no idea
|
|
|
|
|
RealityGamma wrote:
...and my current working directory isnt my desktop...
How are you verifying this?
As has already been mentioned, if you do not specify an absolute path, a relative path is assumed.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am trying to change an ISAPI Extension so it uses Thread Pooling.
I've downloaded the sample from Microsoft and able to get it running.
The problem I am encountering has to do with the AfxBeginThread
function and a Runtime Class. I don't know how to let the class know
how to pass any parameters through the UI thread.
The unconverted ISAPI Extension uses this call:
CClientSession* pWinThread =
(CClientSession*)AfxBeginThread(RUNTIME_CLASS(CClientSession));
Whereas the sample uses:
CWinThread* pWinThread =
AfxBeginThread((AFX_THREADPROC)ThreadProc, m_hIoPort);
Note the MS Example AfxBeginThread uses the ThreadProc overload, the
existing project however uses CClientSession, which inherits from
CWinThread.
How can I let the CClientSession thread know about m_hIoPort the I/O
Completion Port?
<signature>
It's good to live,
Josef Wainz
Software Developer
|
|
|
|
|