I was wondering how I would go about reading a .nfo file (not the system spec kind but the .nfo files that are like readmes) into my program. Would it be like reading a regular text file?
Posted on 2005-07-01 01:43:49 by resistance_is_futile
Most .nfo file I have came across are txt file (I opened them with notepad)  ;)
Posted on 2005-07-01 01:45:28 by roticv
NFO extension is used to denote an 'information' file for a regular text file.
Usually those files come with a lot of ascii characters that are not supported by standard windows fonts, so make sure you handle them correctly.
Posted on 2005-07-01 06:50:20 by arafel
If you open the .nfo files with notepad and change the font to "Terminal" you should see some nice ascii graphics.
Posted on 2005-07-01 09:13:10 by dev_zero
yeah I just figured that out. What I was thinking was just setup a richedit and read it with the terminal font. However, I am having quite a hard time. I want the file to open as soon as the program opens and display in the terminal font. Im using the richedit dll and from there try to set everything up. Things aren't really going my way with this. It seems that there is something wrong with both opening the file and changing the font automatically. The font does not change and only part of the file is opened. Any help is appreciated guys. Heres my code:


.data
buffer db 'file.nfo',0




.if eax==WM_INITDIALOG
push hWin
pop hWnd
;Get handle of RichEdit window and give it focus
invoke GetDlgItem,hWin,IDC_RED
mov hREd,eax
invoke SendMessage,hREd,EM_SETTEXTMODE,0,TM_PLAINTEXT
;Set event mask
invoke SendMessage,hREd,EM_SETEVENTMASK,0,ENM_SELCHANGE
;Set the text limit.
invoke SendMessage,hREd,EM_LIMITTEXT,-1,0
;Create font
invoke lstrcpy,offset lfnt.lfFaceName,offset szFont
mov lfnt.lfHeight,-12
mov lfnt.lfWeight,400
invoke CreateFontIndirect,offset lfnt
mov    hFont,eax
;Set font & format
invoke SetFormat,hREd
                ;Load File
                invoke LoadFile,addr buffer
;Init RichEdit
invoke SendMessage,hREd,EM_SETMODIFY,FALSE,0
invoke SendMessage,hREd,EM_EMPTYUNDOBUFFER,0,0
invoke SetFocus,hREd
.endif


Heres the Proc's


LoadFile proc lpFileName:DWORD
    LOCAL  hFile:DWORD
LOCAL editstream:EDITSTREAM
LOCAL chrg:CHARRANGE

;Open the file
invoke CreateFile,lpFileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
.if eax!=INVALID_HANDLE_VALUE
mov hFile,eax
;Copy buffer to FileName
invoke lstrcpy,offset FileName,lpFileName
;stream the text into the richedit control
push hFile
pop editstream.dwCookie
mov editstream.pfnCallback,offset StreamInProc
invoke SendMessage,hREd,EM_STREAMIN,SF_TEXT,addr editstream
invoke CloseHandle,hFile
invoke SendMessage,hREd,EM_SETMODIFY,FALSE,0
mov chrg.cpMin,0
mov chrg.cpMax,0
invoke SendMessage,hREd,EM_EXSETSEL,0,addr chrg
mov eax,FALSE
.else
invoke MessageBox,hWnd,offset OpenFileFail,offset AppName,MB_OK or MB_ICONERROR
mov eax,TRUE
.endif
ret

LoadFile endp



StreamInProc proc hFile:DWORD,pBuffer:DWORD,NumBytes:DWORD,pBytesRead:DWORD

invoke ReadFile,hFile,pBuffer,NumBytes,pBytesRead,0
xor eax,1
ret

StreamInProc endp



SetFormat proc hWin:DWORD
    LOCAL chrg1:CHARRANGE
    LOCAL chrg2:CHARRANGE
LOCAL pf:PARAFORMAT2
LOCAL cf:CHARFORMAT
LOCAL tp:DWORD
LOCAL buffer[16]:BYTE
LOCAL pt:POINT
LOCAL hDC:HDC

;Save modify state
invoke SendMessage,hWin,EM_GETMODIFY,0,0
push eax
;Save selection
invoke SendMessage,hWin,EM_EXGETSEL,0,addr chrg1
invoke SendMessage,hWin,EM_HIDESELECTION,TRUE,0
;Select all text
mov chrg2.cpMin,0
mov chrg2.cpMax,-1
invoke SendMessage,hWin,EM_EXSETSEL,0,addr chrg2
;Set font charset
mov cf.cbSize,sizeof cf
mov cf.dwMask,CFM_CHARSET or CFM_FACE or CFM_SIZE or CFM_COLOR
mov al,lfnt.lfCharSet
mov cf.bCharSet,al
mov al,lfnt.lfPitchAndFamily
mov cf.bPitchAndFamily,al
invoke lstrcpyn,addr cf.szFaceName,offset lfnt.lfFaceName,LF_FACESIZE
mov eax,lfnt.lfHeight
neg eax
mov ecx,15
mul ecx
mov cf.yHeight,eax
mov eax,rgb
mov cf.crTextColor,eax
invoke SendMessage,hWin,EM_SETCHARFORMAT,SCF_SELECTION,addr cf
;Get tab width
invoke GetDC,hWin
mov hDC,eax
invoke SelectObject,hDC,hFont
push eax
mov eax,'WWWW'
mov dword ptr buffer,eax
invoke GetTextExtentPoint32,hDC,addr buffer,4,addr pt
pop eax
invoke SelectObject,hDC,eax
invoke ReleaseDC,hWin,hDC
mov eax,pt.x
mov ecx,TabSize
mul ecx
mov ecx,15
mul ecx
shr eax,2
mov tp,eax
;Set tab stops
mov pf.cbSize,sizeof pf
mov pf.dwMask,PFM_TABSTOPS
mov pf.cTabCount,MAX_TAB_STOPS
xor eax,eax
xor edx,edx
mov ecx,MAX_TAB_STOPS
  @@:
add eax,tp
mov dword ptr pf.rgxTabs,eax
add edx,4
loop @b
invoke SendMessage,hWin,EM_SETPARAFORMAT,0,addr pf
;Restore modify state
pop eax
invoke SendMessage,hWin,EM_SETMODIFY,eax,0
;Restore selection
invoke SendMessage,hWin,EM_EXSETSEL,0,addr chrg1
invoke SendMessage,hWin,EM_HIDESELECTION,FALSE,0
ret

SetFormat endp

Posted on 2005-07-01 13:17:28 by resistance_is_futile
lol nevermind. Had my richedit control set to single line.. Just need help setting the text as soon as the program starts. I want it to be terminal before it even loads the text so it shows as terminal.. any ideas?
Posted on 2005-07-01 20:30:33 by resistance_is_futile
Don't use richedit, code your own control... and use the codepage 865 dos font for displaying. That way, you will get correct results.

I've attached the binary font. 256 chars of 8x16 size, monochrome bitmap.
Attachments:
Posted on 2005-07-02 10:24:39 by f0dder
Do you mind me asking why you suggested to code my own control? I would really prefer not to because its just extra work. I know it probably would turn out nicer but I dont think I have the energy to do that lol
Posted on 2005-07-02 15:22:55 by resistance_is_futile
Okay well here is an update. I smoothed out the code a bit but it still doesnt seem to change the font at runtime. I want it changed before the .nfo file is loaded. This would seem like the most logical way. But im still stuck with the system font in the richedit control. Any ideas?


.if eax==WM_INITDIALOG
push hWin
pop hWnd

invoke GetDlgItem,hWin,IDC_RED
mov hREd,eax
invoke SendMessage,hREd,EM_SETTEXTMODE,0,TM_PLAINTEXT
invoke SendMessage,hREd,EM_SETEVENTMASK,0,ENM_SELCHANGE
invoke SendMessage,hREd,EM_LIMITTEXT,-1,0
                        invoke Format <--- Controls Font Face
invoke LoadFile,addr devious
invoke SendMessage,hREd,EM_SETMODIFY,FALSE,0
invoke SendMessage,hREd,EM_EMPTYUNDOBUFFER,0,0
invoke SetFocus,hREd
.endif


Here is the Format Proc


Format PROC
local  cf:CHARFORMAT2

invoke RtlZeroMemory,addr lfnt,sizeof lfnt
mov lfnt.lfHeight,-12
mov lfnt.lfWeight,400
invoke lstrcat,addr lfnt.lfFaceName,offset szFont
invoke CreateFontIndirect,addr lfnt
mov hFont,eax
;Set font
invoke SendMessage,hREd,WM_SETFONT,hFont,0

ret

Format endp


Any help is appreciated.
Posted on 2005-07-02 16:09:23 by resistance_is_futile
I suggest coding your own control because it's the only way you'll get accurate rendering of the files, because it's really not that much work to do, and because it's fun :)
Posted on 2005-07-03 09:00:56 by f0dder
Okay well if I can I would rather not. But if need be I suppose I can read up on it. I have already just doesn't seem to be my particular brand of vodka. Anyway, I have this so far but as I said before, its not working correctly. It works if I use the ChooseFont dialog box and all but when I try to set the font on startup, all goes to hell. I'd like to get it to work this way if its possible.


Format PROC
invoke GetDlgItem,hWnd,1001
mov hREd,eax
mov cf1.cbSize,sizeof cf1
mov cf1.dwMask,CFM_COLOR + CFM_FACE
mov cf1.crTextColor,0000000h
invoke lstrcpy,offset cf1.szFaceName,addr szFont
;mov cf1.szFaceName,szFont
invoke SendMessage,hREd,EM_SETCHARFORMAT,SCF_ALL,addr cf1

ret

Format endp


Posted on 2005-07-04 02:31:37 by resistance_is_futile
nfo files are illegal
Posted on 2005-07-05 00:07:18 by comrade

nfo files are illegal


why?
Posted on 2005-07-05 00:09:47 by arafel
Yes I would like to know why as well...

Would also like to know why no one can answer my question??
Posted on 2005-07-05 01:55:40 by resistance_is_futile

nfo files are illegal


proof?

Posted on 2005-07-05 06:06:47 by JimmyClif

nfo files are illegal

ROFLOL! :lol: this one made my day
Posted on 2005-07-05 18:27:44 by QvasiModo
Okay well I got the problem fixed elsewhere.. Thanks for tryin
Posted on 2005-07-06 10:42:14 by resistance_is_futile