LPSTR error...

This is a discussion on LPSTR error... within the Windows Programming forums, part of the Platform Specific Boards category; As many of you may or probably may not know, I am working on a text editor. I was looking ...

  1. #1
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942

    LPSTR error...

    As many of you may or probably may not know, I am working on a text editor. I was looking at how to save at WinProg.org. The file handling stuff the creator of the site used, however, doesn't work.

    This is the portion with the error

    Code:
    LPSTR pszFileText;
    
                pszFileText = GlobalAlloc(GPTR, dwFileSize + 1); // error
    How do I fix this?

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219

    Exclamation What is the error?

    What is the error your having? GlobalAlloc() returns an HGLOBAL which is a handle to a global memory block. It is not a pointer to an array of 8-bit chars (LPSTR). Please provide more information.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #3
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    It says "invalid conversion void* to CHAR*"

    I'm new at WinAPI,

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Try this:

    Code:
    GLOBALHANDLE hGlobal;
    LPSTR pszFileText;
    
    hGlobal = GlobalAlloc ( GHND, dwFileSize + 1);
    pszFileText = (char *) GlobalLock (hGlobal);
    Then be on your way to do whatever

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    pszFileText = (LPSTR) GlobalAlloc(GPTR, dwFileSize + 1);

  6. #6
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    thanks guys!

  7. #7
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    K. Now it doesn't work because I can't get it to work in hEdit

    Code:
                                {
                                          LoadTextFileToEdit(hEdit, szFileName);
                                }     
                   }
            }
        }
        break;
        case WM_CREATE:
        {
            HFONT hfDefault;
            HWND hEdit;
    
            hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
                WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 
                0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
    I can't get it to recognize hEdit

  8. #8
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Post the code for LoadTextFileToEdit()

  9. #9
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219

    RE hEdit

    You need to declare hEdit at the beginning of the window procedure and make it static. That way it is always valid.
    Code:
    static HWND hEdit;
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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