Thread: Redefinition of variables.

  1. #1
    Registered User
    Join Date
    May 2006

    Redefinition of variables.


    This might be simple to answer, but please bear with me. My image processing program needs to use various types ie short, long, float. I get a pointer (*pMod) to a pixel which is used to modify the pixel values.

    hr = SafeArrayPtrOfIndex(pData, ij, (void **)&pMod);
    if (FAILED(hr)) AfxMessageBox("nope");
    (*pMod) = dVal;
    However the pointer clearly needs to be of the same type as the Safearray, therefore I want to CHANGE THE VARIABLE TYPE, KEEPING THE POINTER NAME CONSTANT for use with different image types. I've tried using unions, but unless mistaken I cannot change the type without using a switch. IS there any other way?

    Thanks for your attention.


  2. #2
    Registered User
    Join Date
    Aug 2005
    you need the switch statement to find out what data type is contained in the VARIANT object, assuming the SAFEARRAY is an array of type VT_VARIANT. If it can contain a variety of data types, the the switch is necessary -- if you know it will always be one data type then the switch is probably not necessary

    If all you want to do is get an element out of the array, you can use other functions, such as SafeArrayGetElenment()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM