|
Hi,
I'm a bit new to this TCHAR stuff, so I'm confused as to how to do what I need to do.
I created a struct
struct gaugeSound
{
int buffer;
TCHAR* filename;
// char* filename;
bool loop;
bool isLoaded;
};
That I originally stored a filename in as a char*, but later changed to TCHAR* to try to deal with this issue. This has not worked.
With the above struct, I do this:
gaugeSound sound_EngOut = { 0, L"sound\\B206B-III\\Loop_EngOut.wav", true, false };
(here I added the 'L', but originally I just used a char*)
Then I try to do this:
LoadWaveFile(sound_EngOut.buffer, sound_EngOut.filename);
sound_EngOut.isLoaded = true;
however the LoadWaveFile() function was defined like this:
extern "C" VOID LoadWaveFile( WORD BufferN, TCHAR* strFileName )
{
// Create the sound buffer object from the wave file data
if( FAILED( CreateStaticBuffer( BufferN, strFileName ) ) )
{
return;
}
else // The sound buffer was successfully created
{
// Fill the buffer with wav data
FillBuffer(BufferN);
}
}
so originally I changed it to this:
//extern "C" VOID LoadWaveFile( WORD , const char* );
but since that didn't work I am trying to go with the original again.
Yet... there is a problem.... as in this function...
HRESULT CreateStaticBuffer( WORD BufferN, TCHAR* strFileName )
{
HRESULT hr;
// Free any previous globals
SAFE_DELETE( g_pWaveSoundRead [BufferN]);
SAFE_RELEASE( g_pDSBuffer [BufferN]);
// Create a new wave file class
g_pWaveSoundRead[BufferN]= new CWaveSoundRead();
// Load the wave file
if( FAILED( g_pWaveSoundRead[BufferN]->Open( strFileName ) ) )
<snip...>
the Open() call above requires (in WaveRead.cpp) a CHAR* !!!!!!
So, it seems that I have no clue how to use this DirectSound code that has been programmed with TCHAR*, especially since when I use the 'L', the above function can then not be called.
Help! What the heck am I supposed to begin doing?
|
|
|
|
|
It's up to you, as always to use the proper data types in C++.
The type TCHAR's actual type will vary depending on if you've defined _UNICODE, _MBCS, or neither.
If you choose to use the generic text mappings, and you use an API that requires a different type
char, then you'll need to convert strings to the appropriate type before passing them, or use
the appropriate type string literals.
Here's a link to the docs: Using Generic-Text Mappings[^]
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Thanks for the links.
Turns out the problem was that I had UNICODE defined and didnt' know it.
|
|
|
|
|
This is more on the mathematical side but I'm trying to convert metrics to english and vice versa.
I've got the main coding done but my equations are off. Maybe it's because I've been working on this for about 3 days straight and just cannot see what I'm doing wrong, OR I'm just have no clue as to what I am doing in the first place. LOL
here is the code I have for converting metric to english (grams and kilograms to pounds and ounces):
const double KILOGRAMS_PER_POUND = .454;
const double POUNDS_PER_KILOGRAM = 2.2046;
const double GRAMS_PER_KILOGRAM = 1000;
const double OUNCES_PER_POUND = 16;
const double GRAMS_PER_POUND = 453.59;
void convert_M_to_E( double £s, double& ounces, double grams, double kilograms)
// Parameters: Grams and kilograms values to be converted to pounds and ounces
// and references to variables that hold pounds and ounces
// Returns: None
// Calls: None
{ double total_pounds; // Grams and kilograms converted to pounds
double total_grams; // Pounds and ounces converted to grams
total_grams = grams + kilograms / GRAMS_PER_KILOGRAM;
total_pounds = total_grams / GRAMS_PER_POUND;
pounds = int( total_pounds );
ounces = pounds/OUNCES_PER_POUND;
} // End of convert_M_to_E()
And here is the code I have to convert English to Metric:
void convert_E_to_M( double pounds, double ounces, double& grams, double& kilograms)
// Parameters: pounds and ounces values to be converted to grams and kilograms
// and references to variables that hold grams and kilograms
// Returns: None
// Calls: None
{ double total_pounds; // pounds and ounces converted to pounds
double total_grams; // pounds and ounces converted to grams
total_pounds = (pounds + ounces)/OUNCES_PER_POUND;
total_grams = GRAMS_PER_POUND * total_pounds;
grams = double (total_grams);
kilograms = grams/GRAMS_PER_KILOGRAM;
} // End of convert_E_to_M()
I know I've got it completely wrong... can anyone help??
Thanks,
Ruby
|
|
|
|
|
You've done a good job of asking a detailed question, and showing hte code you've written to try and solve the problem. However, it looks to me like C++ code, and not C++/CLI. Please ask in the right forum.
RubyM wrote: double total_pounds; // Grams and kilograms converted to pounds
double total_grams; // Pounds and ounces converted to grams
total_grams = grams + kilograms / GRAMS_PER_KILOGRAM;
total_pounds = total_grams / GRAMS_PER_POUND;
pounds = int( total_pounds );
ounces = pounds/OUNCES_PER_POUND;
1 - NEVER declare your variables at the top, unless you use them right away. If this is actually C code, then you must do that, and you really are in the completely wrong forum.
2 - NEVER declare a variable without giving it a default value
3 - I do think you're doing the conversion wrong, but if your answer is only a little bit wrong, even double does not give exact answers.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
sorry about posting in the wrong forum... I'm a student, and to be honest, I don't know what the difference is between C++/CLI or any other C++ programing. All I know is that it's C++ and this forum has "C++" in the title.
Sorry again.
Ruby
|
|
|
|
|
Hello,
Jus try:
1. total_grams = grams + kilograms * GRAMS_PER_KILOGRAM;
2. ounces = pounds*OUNCES_PER_POUND;
3. total_pounds = pounds + ounces/OUNCES_PER_POUND;
Regards,
|
|
|
|
|
For many years, I have been "naughty" in reusing my classes by copying the relevent files in to my current project in MSVC - I knew that I should be generating a library, but I was lazy !!! I have now generated a library and tried to alter my project settings to use MyLibrary. (I have experimented with a known working project) I have referenced the library by stating the path in MSVC/Project/Settings/Link and adding it to "Object/Library modules".
When I compile/link the project without making any source code changes (apart from adding a constructor for a class contained in MyLibrary), I get loads of errors (just under 200 !!), one of which I quote below:-
nafxcwd.lib(wincore.obj) : error LNK2005: "public: virtual void __thiscall CWnd::OnFinalRelease(void)" (?OnFinalRelease@CWnd@@UAEXXZ) already defined in mfc42d.lib(MFC42D.DLL)
If I remove the constructor for the class contained in MyLibrary, it links without error.
Can someone pin-point what I am doing wrong in the setup of my project within the MSVC (vers 6.0) build and usage of MyLibrary ?
Doug
|
|
|
|
|
DougButtimer wrote: 6.0
VC6.0 does not support C++/CLI, therefore this is the wrong forum, try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
My apologies !! I realised that I had the wrong forum JUST after I posted it, but decided to let it go in case someone on this side knew the answer !!
Doug
|
|
|
|
|
Hello,
I am developing a dozen or so C++/CLI assemblies in my solution. When I apply even a smallest change to one of them (so the binary is updated on build), all other assemblies that refer to this modified assembly are getting fully rebuilt (along with their precompiled headers). It takes quite a lot of time, and seem completely unnecessary to me, as I am not modifying any interfaces, only implementations.
Is there a reasonable way to prevent the dependent assemblies from being rebuilt?
|
|
|
|
|
I need to create an 2 dimension array, wich type is picture box, so I have write such code:
<br />
private: static unsigned short int n = 100;<br />
private: static array < System::Windows::Forms::PictureBox^ >^ m; <br />
m = gcnew array < System::Windows::Forms::PictureBox^ > (n);<br />
for(int i=0; i < n; i++){<br />
m[i] = gcnew array < System::Windows::Forms::PictureBox^ >(n);<br />
for( int j = 0; j < n; j++){<br />
m[i, j] = gcnew System::Windows::Forms::PictureBox();<br />
m[i, j]->Location = System::Drawing::Point(200 + i, 250);<br />
m[i, j]->Visible = true;<br />
m[i, j]->Size = System::Drawing::Size(1, 1);<br />
m[i, j]->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;<br />
m[i, j]->Load("a.gif");<br />
Controls->Add(m[i, j]);<br />
}<br />
}
but i get an error, that this array is not 2 dimension
what can be wrong?
|
|
|
|
|
To create it in two dimensions, you need to create an array of arrays.
private: static array < array < System::Windows::Forms::PictureBox^> >^ m;
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thank you for your help
|
|
|
|
|
array<System::Windows::Forms::PictureBox^,2>^ m;
m = gcnew array<System::Windows::Forms::PictureBox^,2>(n,n);
|
|
|
|
|
i would adding a menu on treeView,i try
TreeNode^ eventLogsNode = gcnew TreeNode("Event Logs");<br />
eventLogsNode->ImageIndex=2;<br />
eventLogsNode->SelectedImageIndex=2;<br />
eventLogsNode->ContextMenuStrip=computerContextMenuStrip;<br />
treeView1->Nodes->Add(eventLogsNode);
But they are error:
error C2065: 'computerContextMenuStrip' : undeclared identifier
|
|
|
|
|
i would set the shortcut menu associated with this tree node
-- modified at 15:40 Saturday 10th March, 2007
|
|
|
|
|
I want to add a menu; treeView, there has for example root, and that we click on + who is situated near root a submenu which opens, Thank you
|
|
|
|
|
Hi,
It's about 5 day that I'm traying to create a MixedMode DLL with MFC and Managed C++. At this time I'm freak I don't really know what I'm doing. I have read a lot of documentation and I still confuse.
With more detail, I want to create an MFC Regular DLL that can be accessible in C# and from an other MFC application.
If any body have a good tutorial or a small project that implement the DLL, an application in MFC and an other application in C#.
Thank for your help.
|
|
|
|
|
When i declare :
EventLog* log2 = new EventLog();
it's write error about (*)??
Thank you
|
|
|
|
|
Perhaps if you told us what the error is ?
If EventLog is a managed object, I thought you needed to use gcnew ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How to create a new instance of treenode in winforms? in C# :
TreeNode eventLogsNode = new TreeNode("Event Logs");
and it work,
thank you
|
|
|
|
|
|
I would GetHostName and show him in treeView, i work with winforms, i try for
System::Net::Dns::GetHostName^ er;
treeView1->Nodes->Add(er);
and there are errors:
error C2065: 'er' : undeclared identifier
error C3867: 'System::Net::Dns::GetHostName': function call missing argument list; use '&System::Net::Dns::GetHostName' to create a pointer to member
Thank you
|
|
|
|
|
GetHostName is a static method:
String^ hostName = System::Net::Dns::GetHostName();
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|