C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
invalid conversion from 'void*' to 'HFONT_*' Posted by Aberran7 on 31 Aug 2006 at 3:49 PM
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.
Report
Re: invalid conversion from 'void*' to 'HFONT_*' Posted by AsmGuru62 on 31 Aug 2006 at 10:47 PM
See RED...
Also, MAKELPARAM(FALSE,0) is just zero.


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


Report
Re: invalid conversion from 'void*' to 'HFONT_*' Posted by Aberran7 on 2 Sept 2006 at 4:49 PM
: See RED...
: Also, MAKELPARAM(FALSE,0) is just zero.
:

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

:
:

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.

DWORD dwFileSize;
          
          dwFileSize = GetFileSize(hFile, NULL);
          if(dwFileSize != 0xFFFFFFFF)
          {
               LPSTR pszFileText;
               
               pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
               if (pszFileText != NULL);


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

Eventualy I will figure out all of these damn errors:)
Report
Re: invalid conversion from 'void*' to 'HFONT_*' Posted by AsmGuru62 on 3 Sept 2006 at 4:55 AM
Report
Re: invalid conversion from 'void*' to 'HFONT_*' Posted by Aberran7 on 3 Sept 2006 at 3:14 PM
:
ummmm don't think anything came through that time.
Report
Re: invalid conversion from 'void*' to 'HFONT_*' Posted by Lundin on 4 Sept 2006 at 1:35 AM
: : See RED...
: : Also, MAKELPARAM(FALSE,0) is just zero.
: :

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

: :
: :
:
: 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.
:
:
: DWORD dwFileSize;
:           
:           dwFileSize = GetFileSize(hFile, NULL);
:           if(dwFileSize != 0xFFFFFFFF)
:           {
:                LPSTR pszFileText;
:                
:                pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
:                if (pszFileText != NULL);
: 

:
: 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.
Report
Re: invalid conversion from 'void*' to 'HFONT_*' Posted by Aberran7 on 4 Sept 2006 at 3:45 PM
This message was edited by Aberran7 at 2006-9-4 15:47:23

: :
: : DWORD dwFileSize;
: :           
: :           dwFileSize = GetFileSize(hFile, NULL);
: :           if(dwFileSize != 0xFFFFFFFF)
: :           {
: :                LPSTR pszFileText;
: :                
: :                pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
: :                if (pszFileText != NULL);
: : 

: :
: : 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:


 pszFileText =  (LPSTR) GlobalAlloc(GPTR, dwFileSize + 1);



Right?
Report
Re: invalid conversion from 'void*' to 'HFONT_*' Posted by AsmGuru62 on 4 Sept 2006 at 8:17 PM
: This message was edited by Aberran7 at 2006-9-4 15:47:23

: : :
: : : DWORD dwFileSize;
: : :           
: : :           dwFileSize = GetFileSize(hFile, NULL);
: : :           if(dwFileSize != 0xFFFFFFFF)
: : :           {
: : :                LPSTR pszFileText;
: : :                
: : :                pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
: : :                if (pszFileText != NULL);
: : : 

: : :
: : : 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:
:
:
: 
:  pszFileText =  (LPSTR) GlobalAlloc(GPTR, dwFileSize + 1);
: 
: 

:
: Right?
:
Correct.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.