What's new

Windows beginner question

bcrew1375

New member
I'm a newb at Windows programming, so I need to ask a question. How can I make one of those FPS counters that show up in the title bar of the window?
 

zenogais

New member
Use the function SetWindowText, it has the format:

Code:
SetWindowText(HWND hWnd, LPCTSTR lpString)
 
Last edited:
OP
B

bcrew1375

New member
How would I go about using a number variable in that? Would I need to convert the number to a string?
 

zenogais

New member
Ah right, thats what you wanted to know. Well, since you're programming C you'd have to use sprintf in the form :

Code:
int fps;
...
char windowFpsString[_MAX_PATH];
sprintf(windowFpsString, "WindowName - FPS %d", fps);
SetWindowText(mainWindow, (LPCTSTR)windowFpsString);

As for the actual FPS calculations, I actually have a code snippet lying around here that you should be able to get the necessary data from. It uses SDL_GetTicks as a timer for the FPS count.
 
OP
B

bcrew1375

New member
Great, thanks. I don't have time to implement it right now, but I'll let you know how it works out.
 

secretemu

Future Emu Creator Hopefully
hi im not new to c++ but i am new to emu programming :ala:
can any1 help me with loading a rom.this is how you load text (you obviously know because your a genious) :blush:
hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, 0);
do i load it like this if so can you give me the commands for chip 8. :paperbag:
if not can you show me how its done :party:
ps is it possible to emulate in devc++ instead of c++.net :huh:
 

hap

New member
It's good that you're beginning with chip8, to understand the basics of emulator programming, instead of something a lot more complicated. Start by reading the *whole* Chip8 thread on top of this subforum (it's a Sticky topic). You'll find what you need there. If you're getting stuck later on, ask further questions in that thread. And don't ask too soon; try to find it out yourself first, it's more fun that way.

You can create an emulator in any programming language.
 

secretemu

Future Emu Creator Hopefully
the stuff on chip 8 is mostly only documentation.
what i wnt to know is how to use this documentation to create an emu
can you help please :party:
 

hap

New member
no offense, but no. i'd like you to do research yourself, or you'll never get the grip.
 
OP
B

bcrew1375

New member
You'll need to understand how a computer system runs in order to write an emulator. Understand how the hardware works, and make software that "emulates" these functions.
 

malcster

I wish I could code.
secretemu said:
the stuff on chip 8 is mostly only documentation.
what i wnt to know is how to use this documentation to create an emu
can you help please :party:

You are not ready to create an emulator if you ask this. Can you program simple data structures like a stack or queue? If you don't know what I'm referring to you are not even vaguely ready, you definitely need a stack for the chip8. Buy some C++ books or download some tutorials. You claim that you are not new to C++ but I don't get how you can be trying to load a file with the CreateFile() function.
 

smcd

Active member
CreateFile is used to both create and open files. Kind of silly, isn't it? When doing programming, even in Windows, I tend to use FILE *name; style access, it's easier for me and it works.
 

malcster

I wish I could code.
Fair enough, my apologies. But yeah, I'd recommend vanilla C or C++ file access rather than some windows specific thing.
 

Top