Thread: Just starting Windows Programming, School me!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Each window requires a WNDCLASS, but can share one already created. WNDCLASS is used to hold the settings/styles etc, so windows sharing common functionality and/or style can use the same WNDCLASS.

    You want a WIN32 main window with a child OpenGL frame (DC) inside.

    Your message pump should 'catch' WIN32 messages from the menu / buttons and pass them to your callback. If there are no messages your app will draw the next frame.

    I don't see why you would want to complicate BlackJack with OpenGL. BJ is not a game that requires serious graphic rendering. I see so many people fail because they over complicate thier first apps, get frustrated and quit. KEEP IT SIMPLE! Build up complexity as you gain in confidence.

    Simple GDI would do the job, if double buffered and you can use the WIN32 card class CARDS.DLL (ie the cards used in the windows games Hearts etc).

    I would create a main window with a menu built in the resource editor.
    I would also create a toolbar in the resource editor, though this is MUCH harder in WIN32 than MFC. (something for v2?)
    In the WM_CREATE handler I would work out the size of the screen and create my memory HDC.
    I would then create the controls (buttons) needed directly on the main screen (adding handlers into the callback).

    Respond to the buttons to determine the action required (new game, draw card etc)

    I would use cards.dll to draw the cards to the memory DC as required and then call for a paint (InvalidateRect and UpdateWindow).

    In the paint I would BitBlt the memory DC to the HDC (using the rect) in the PAINTSTRUCT.



    Quote Originally Posted by Elysia View Post
    Well, as I said, I'm an MFC dev so I know little about window classes. But there's nothing wrong in using MFC either, if you have Visual Studio Pro edition.
    I thought you knew everything? ("I am not young enough to know everything." Oscar Wilde)

    MFC's message pump is incompatible with the game style message pump.

    MFC's use of two PeekMessages and GetMessage is too much overhead for fast rendering And you do not have the ability to 'hack' this message pump (as you do in WIN32).

    You can process using the MFC OnIdle() handler but will not be as responsive as the message pump you are currently using.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by novacain View Post
    I thought you knew everything? ("I am not young enough to know everything." Oscar Wilde)
    No, no, no... That's what others have said, not I. I've never claimed to know everything. I've been corrected countless times and others have filled the void where my knowledge was lacking also countless times. No one knows everything...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    I already have cards and a deck and a working engine, all I need is an input/output interface that isn't poopy like the console.

    Code:
    class Card_Game
    {
    public:
    	Card_Game(){}
    	~Card_Game(){}
    	virtual void init(){}
    	virtual void cleanup(){}
    	virtual void turn_logic(std::string player_id);
    	std::vector<std::string> m_vPlayer_List;
    	int get_setting(std::string name);
    protected:
    	int calculate_winnings();
    	void new_setting(std::string name, Setting * new_setting);
    	void initialize_players();
    	// Give player id a new hand
    	void give_player_hand(std::string player_id);
    	void shuffle_deck(int deck_id);
    	// Draw how_many cards to player id's hand_id from deck_idntyd
    	void draw_card(std::string player_id, int hand_id, int deck_id, int how_many);
    	void place_bet(std::string player_id, int bet);
    	// Split player's active hand
    	void split_hand(std::string player_id, int hand_id);
    	// check if hand value > check_value
    	bool check_hand_value(std::string player_id, int hand_id, int check_value);	
    
    	Resource_Manager< Player > m_rPlayers;
    	Resource_Manager< std::vector<Hand*> > m_rHands;
    	Resource_Manager< int* > m_rBets;
    	Resource_Manager< Deck* > m_rDecks;
    	Resource_Manager< Setting > m_rSettings;
    	std::vector< Deck* > m_vDeck;	
    
    };
    The idea I'm trying to grasp right now is how to work windows into my state manager. This is how I update my game logic:
    Code:
    				srand ( unsigned(time(NULL)) );
    				Blackjack_Game * game = new Blackjack_Game();
    				game->init();
    
    				State_Manager * state_manager = new State_Manager;
    				state_manager->change_state(new Play_State(state_manager, game) );
    				*/
    
    				/*
    				while ( state_manager->running() )
    				{
    					state_manager->update();
    					state_manager->print();
    					state_manager->handle_events();
    				}
    
    				game->cleanup();
    I want to integrate the windows messaging system into my state manager.
    They will be responsible for the creation of certain windows and buttons and such, and also accept messages from Win32 and handle them, like a WM_COMMAND I suppose.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 01-01-2007, 07:36 AM
  2. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  4. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM