Thread: Help~

  1. #1
    Registered User
    Join Date
    Jul 2002


    GetDlgItemText(hWnd, IDC_FILENAME, szBitmapFilename, sizeof(szBitmapFilename)/sizeof(TCHAR));

    I don't know what the last parameters means. (sizeof(szBitmapFilename)/sizeof(TCHAR))
    what will be return after that operation ? (sizeof(szBitmapFilename)/sizeof(TCHAR))
    I always meet this but I dont know understand.

  2. #2
    Registered User
    Join Date
    May 2002
    All it is is the size fo the filename,

    sizeof(szBitmapFilename) //length of filename in bytes
    sizeof(TCHAR) //length of individual Letter

    therefore when you divide the two you get the size of the filename in letters (TCHARs)
    Last edited by Traveller; 07-11-2002 at 03:49 AM.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    TCHAR is a typedef for "char" that is a standard under normal conditions, but if you compile for a Unicode platform it changes to WCHAR - wide char

    A char is a single byte, but a WCHAR is 2 bytes......

    Therefore.....a 10 charactor array for ASCII (ignoring the terminating NULL) is 10 bytes....but under unicode it will be 20 bytes...

    Its just a safe way to write code so it can be compiled easily for different platforms.......

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    Actually dividing an array by the size of a single element is a very unsafe way of finding the text length. It works only for texts that were entered at compile time into an array that has the same size as the text. It seems to be used frequently, but you should use strlen, or for the T-type datatypes _tstrlen.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Jul 2002
    Thanks all!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ~ User Input script help~
    By indy in forum C Programming
    Replies: 4
    Last Post: 12-02-2003, 06:01 AM
  2. Help~
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 04-12-2002, 12:21 PM