invalid conversion from 'void*' to 'HFONT_*' - Programmers Heaven

Howdy, Stranger!

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

Categories

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:)
  • AsmGuru62AsmGuru62 Posts: 6,519Member
  • 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.