C++ Calling Out Arguments inside the Functions and its funcion it'self

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KYAW KYAW OO
    New Member
    • Jan 2007
    • 30

    C++ Calling Out Arguments inside the Functions and its funcion it'self

    I would like to get the value of argument and its output from function as per below.

    Code:
    LPCWSTR fileName = _T("C\\Test.bmp"); 
    unsigned char *Content, Mem;
    HBITMAP bitmap;
    
    bitmap = LoadBMPFromFile(fileName, Content);
    Mem = Content;
    
    HBITMAP Dlg::LoadBMPFromFile(LPCWSTR fileName, unsigned char *Content)
    {
          HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, fileName,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
    
       BITMAP m_sbmpBitmap;
       CBitmap m_bmpBitmap;
    
        datasize = m_bmpBitmap.GetBitmapBits(datasize * sizeof(COLORREF), lpClrData);
    
        for(int i = 0;i<m_sbmpBitmap.bmHeight;i++)
        {
              for(int k = 0;k<m_sbmpBitmap.bmWidth;k++)
              {
                      char *Mem = temp.put(k,i, 3);
                }
       }
    
        Content = (unsigned char*)Mem;
        return hBitmap;
    }
    Please advise me to get it done since I left this function only for my development and looking forward to hearing from good news from someone.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    can you post the code in code format

    at the top of the code
    LPCWSTR fileName = _T("C\\Test.bmp ");
    the given path is wrong in that case your program will try to find the file
    "dir_of_the_exec utable\c\Test.b mp"

    but I guess you are trying to pu
    C:\Test.bmp

    Comment

    • KYAW KYAW OO
      New Member
      • Jan 2007
      • 30

      #3
      Hi,

      Here is my draft code and I think one input argument and mulitple output arguments couldn't be possible using C++ funcitons.

      Code:
      // main.cpp 
      BOOL Dlg::Start()
      { 
           LPCWSTR fileName = _T("C\\Test.bmp");      // same as C:\Test.bmp 
           unsigned char *Content, Mem; 
           HBITMAP bitmap; 
        
           bitmap = LoadBMPFromFile(fileName, Content); 
           Mem = Content; 
      
           // display image from Mem
          
      }
        
      HBITMAP Dlg::LoadBMPFromFile(LPCWSTR fileName) 
      { 
            HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, fileName,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE); 
        
         BITMAP m_sbmpBitmap; 
         CBitmap m_bmpBitmap; 
        
          datasize = m_bmpBitmap.GetBitmapBits(datasize * sizeof(COLORREF), lpClrData); 
        
          for(int i = 0;i<m_sbmpBitmap.bmHeight;i++) 
          { 
                for(int k = 0;k<m_sbmpBitmap.bmWidth;k++) 
                { 
                        char *Mem = temp.put(k,i, 3); 
                  } 
         } 
        
          Content = (unsigned char*)Mem; 
          return hBitmap; 
      }

      Code:
      // main.h
      // Image Display and BufferMemory
      typedef struct Image
      {
      	 HBITMAP hBitmap;
      	 unsigned char *bufMem;
      }Image;
      I would like to return HBITMAP and unsigned char* from the function LoadBMPFromFile to main.cpp. I am trying with structure to settle this issue and hoping from someone's advice soon.

      Best regards
      Last edited by Banfa; Mar 9 '10, 09:26 AM. Reason: Added [code]...[/code] tags

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        KYAW KYAW OO,

        please start posting your code inside [code]...[/code] tags. It makes it easier to read. This is the second time I have asked you to do this if you continue breaking forum posting guidelines you will begin getting infractions, if you get enough infractions you will get an initially temporary ban from the forum.

        Banfa
        Administrator

        Comment

        Working...