Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

invalid conversion from 'void*' to 'HFONT_*'

Aberran7Aberran7 Posts: 5Member
I am working on the Forger Tut and have run across this error. I have looked through google and can't find the answer. So I thought I would see if any one here could help. I am using DEV C++ and the file is App 1.

CODE:

hfDefault = GetStockObject (DEFAULT_GUI_FONT);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
}
break;


invalid conversion from 'void*' to 'HFONT_*'


I apreciate any help any one can give me.

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [blue]See RED...
    Also, MAKELPARAM(FALSE,0) is just zero.
    [/blue]

    : [code]
    : hfDefault = [red](HFONT)[/red] GetStockObject (DEFAULT_GUI_FONT);
    : SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    : break;
    : [/code]

  • Aberran7Aberran7 Posts: 5Member
    : [blue]See RED...
    : Also, MAKELPARAM(FALSE,0) is just zero.
    : [/blue]
    :
    : : [code]
    : : hfDefault = [red](HFONT)[/red] GetStockObject (DEFAULT_GUI_FONT);
    : : SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    : : break;
    : : [/code]
    :
    :

    Thanks ASM, the (HFONT) worked for the problem. Dev didn't like when I took out the false though so I kept it and it worked fine. Now I am running into another error on the next lesson.

    [code]
    DWORD dwFileSize;

    dwFileSize = GetFileSize(hFile, NULL);
    if(dwFileSize != 0xFFFFFFFF)
    {
    LPSTR pszFileText;

    pszFileText = [red]GlobalAlloc(GPTR, dwFileSize + 1);[/red]
    if (pszFileText != NULL);
    [/code]

    with an error of: invalid conversion from 'void*' to 'CHAR*'

    Eventualy I will figure out all of these damn errors:)
  • Aberran7Aberran7 Posts: 5Member
    :
    ummmm don't think anything came through that time.
  • LundinLundin Posts: 3,711Member
    : : [blue]See RED...
    : : Also, MAKELPARAM(FALSE,0) is just zero.
    : : [/blue]
    : :
    : : : [code]
    : : : hfDefault = [red](HFONT)[/red] GetStockObject (DEFAULT_GUI_FONT);
    : : : SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    : : : break;
    : : : [/code]
    : :
    : :
    :
    : Thanks ASM, the (HFONT) worked for the problem. Dev didn't like when I took out the false though so I kept it and it worked fine. Now I am running into another error on the next lesson.
    :
    : [code]
    : DWORD dwFileSize;
    :
    : dwFileSize = GetFileSize(hFile, NULL);
    : if(dwFileSize != 0xFFFFFFFF)
    : {
    : LPSTR pszFileText;
    :
    : pszFileText = [red]GlobalAlloc(GPTR, dwFileSize + 1);[/red]
    : if (pszFileText != NULL);
    : [/code]
    :
    : with an error of: invalid conversion from 'void*' to 'CHAR*'
    :
    : Eventualy I will figure out all of these damn errors:)
    :


    If you compile as C++, you need to make an explicit typecast.
    You won't get that error if you compile as C.
  • Aberran7Aberran7 Posts: 5Member
    [b][red]This message was edited by Aberran7 at 2006-9-4 15:47:23[/red][/b][hr]
    : : [code]
    : : DWORD dwFileSize;
    : :
    : : dwFileSize = GetFileSize(hFile, NULL);
    : : if(dwFileSize != 0xFFFFFFFF)
    : : {
    : : LPSTR pszFileText;
    : :
    : : pszFileText = [red]GlobalAlloc(GPTR, dwFileSize + 1);[/red]
    : : if (pszFileText != NULL);
    : : [/code]
    : :
    : : with an error of: invalid conversion from 'void*' to 'CHAR*'
    : :
    : : Eventualy I will figure out all of these damn errors:)
    : :
    :
    :
    : If you compile as C++, you need to make an explicit typecast.
    : You won't get that error if you compile as C.
    :
    ok looked up explicit typecast on the net and I think I understand. Should be something like this:

    [code]

    pszFileText = [RED] (LPSTR)[/RED] GlobalAlloc(GPTR, dwFileSize + 1);

    [/code]

    Right?
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : [b][red]This message was edited by Aberran7 at 2006-9-4 15:47:23[/red][/b][hr]
    : : : [code]
    : : : DWORD dwFileSize;
    : : :
    : : : dwFileSize = GetFileSize(hFile, NULL);
    : : : if(dwFileSize != 0xFFFFFFFF)
    : : : {
    : : : LPSTR pszFileText;
    : : :
    : : : pszFileText = [red]GlobalAlloc(GPTR, dwFileSize + 1);[/red]
    : : : if (pszFileText != NULL);
    : : : [/code]
    : : :
    : : : with an error of: invalid conversion from 'void*' to 'CHAR*'
    : : :
    : : : Eventualy I will figure out all of these damn errors:)
    : : :
    : :
    : :
    : : If you compile as C++, you need to make an explicit typecast.
    : : You won't get that error if you compile as C.
    : :
    : ok looked up explicit typecast on the net and I think I understand. Should be something like this:
    :
    : [code]
    :
    : pszFileText = [RED] (LPSTR)[/RED] GlobalAlloc(GPTR, dwFileSize + 1);
    :
    : [/code]
    :
    : Right?
    :
    [blue]Correct.[/blue]
Sign In or Register to comment.