Thread: Win32 with C++

  1. #1
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256

    Win32 with C++

    I know that there it is possible to program Win32 applications using C++, but half the time, I get all kinds of errors, based off of things that were fine in C, but a no-no in C++. For example...

    Code:
    HBITMAP CreateBitmap(int nWidth, int nHeight,
                         UINT cPlanes, UINT cBitsPerPixel,
                         CONST VOID* lpvBits);
    I'm refering to the last perameter specifically. In C, using a void* is fine, but when I try to use this function in C++, I get an error for casting an int* as a void*. How would I work around things like this?
    Code:
    void function(void)
     {
      function();
     }

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Make sure you take into consideration const.

    Kuphryn

  3. #3
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    What do you mean? Would I need to remove that for C++.
    Code:
    void function(void)
     {
      function();
     }

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    No, I was thinking of casting from within CreateBitmap().

    static_cast() should be fine.

    Kuphryn

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    I believe reinterpret_cast would be more appropriate since it's a pointer-to-pointer conversion.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Ahh. I still have much to learn of C++. Heh.
    Code:
    void function(void)
     {
      function();
     }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Console program to Win32
    By Ducky in forum Windows Programming
    Replies: 3
    Last Post: 02-25-2008, 12:46 PM
  2. Win32 API or Win32 SDK?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-20-2005, 03:26 PM
  3. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 05:57 PM
  4. Thread Synchronization :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 08-09-2002, 09:09 AM
  5. Win32 API Tutorials?
    By c++_n00b in forum C++ Programming
    Replies: 9
    Last Post: 05-09-2002, 03:51 PM