-
Void* to HWND__ *??
(WinXP, Borland C++ Free Command Line Compiler)
Ok, something very strange is going on in my code. This should place a .mid, and return a handle:
Code:
#include <windows>
#include <string>
#include <iostream>
using namespace std;
HANDLE Order(SHORT order, string PATH) {
string Muz;
HANDLE Handler;
if(order == 0)
Muz+="play ";
else
Muz+="stop ";
Muz+=PATH;
cout << Muz << endl;
mciSendString(Muz.c_str(), NULL, 0, Handler);
return Handler;
}
int main() {
Order(0, "C:\\TW.mid");
Sleep(4500);
Order(1, "C:\\TW.mid");
}
But I get something about casting from a void pointer to an HWND__ pointer...
Code:
C:\Borland\BCC55\Bin>BCC32 C:\SoundTest.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\SoundTest.cpp:
Error E2034 C:\SoundTest.cpp 18: Cannot convert 'void *' to 'HWND__ *' in function Order(short,string)
Error E2342 C:\SoundTest.cpp 18: Type mismatch in parameter 'hwndCallback' (wanted 'HWND__ *', got 'void *') in function Order(short,string)
*** 2 errors in Compile ***
Why is it even bringing this up? It does want a HANDLE doesnt it? I've never had this problem before... :/. Whats it want me to do >.>. Oh, and what is that handle for anyways? I know I could specify a NULL, but is it used for something?
Thanks!
-
It looks like NULL is defined as
on your compiler (even though it shouldn't be). Try casting the NULL to whatever the function's excepting (HANDLE ** or whatever).
Or maybe the error is referring to the last parameter.
You might need WinMain().
-
Weird, I changed HANDLE Handler to HWND__* Handler and it worked... Isint an HWND__ a HANDLE? Maybe its a compiler bug?
-
The function actually expects a HWND. The documentation is incorrect. However, there's more to calling a function than just getting the types to match. You also need an appropriate value. This last value can take a window handle, to which notifications will be sent. In your case, since you don't wish to receive notification messages, you can use the value NULL.