Void* to HWND__ *??

This is a discussion on Void* to HWND__ *?? within the C++ Programming forums, part of the General Programming Boards category; (WinXP, Borland C++ Free Command Line Compiler) Ok, something very strange is going on in my code. This should place ...

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    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!
    Last edited by Blackroot; 02-14-2006 at 04:56 AM.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    It looks like NULL is defined as
    Code:
    (void *)0
    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().
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Weird, I changed HANDLE Handler to HWND__* Handler and it worked... Isint an HWND__ a HANDLE? Maybe its a compiler bug?
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  3. My first "real" windows app
    By JoshR in forum Windows Programming
    Replies: 2
    Last Post: 07-28-2005, 07:40 AM
  4. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 06:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21