LordHarryPotter | Reprise du message précédent :
SquiZZ a écrit :
tu peux poster un peu le code de ta classe dérivée de CFrameWnd ?
tu peux virer les méthodes Plot*() pour alléger, le problème ne doit pas venir de ces méthodes.
|
oki si tu veux, voilà le .h
Code :
- #ifndef _MYMAINWINDOW_OTHELLO_H_DS_
- #define _MYMAINWINDOW_OTHELLO_H_DS_
- #include <afxwin.h>
- #include <afxext.h>
- #include "dessin.h"
- #include "../othello.h"
- const unsigned short int status_length = 3 ;
- class GraphiqueMainWin : public CFrameWnd
- {
- CMenu menu_principal ;
- CString filesave;
- CString fileopen;
- CStatusBar status_principal ;
- CToolBar tool_principal ;
- UINT status_text[status_length] ;
- UINT status_width ;
- UINT status_height ;
- UINT width ;
- UINT height ;
- Echiquier le_jeu ;
- Dessin* le_visuel ;
- void SetStatusTextPoisition(UINT ,UINT ) ;
- void DrawChess(void) ;
- bool OuvrirFichier(void) ;
- bool EnregistrerFichier(void) ;
- public:
- GraphiqueMainWin();
- ~GraphiqueMainWin();
- DECLARE_MESSAGE_MAP()
- afx_msg void OnQuicommenceNoir();
- afx_msg void OnQuicommenceBlanc();
- afx_msg void OnQuicommenceAltern40013();
- afx_msg void OnAideApropos();
- afx_msg void OnAideManuel();
- afx_msg void OnOptionAffichage();
- afx_msg void OnPartieNouvelle();
- afx_msg void OnPartieEnregistrer();
- afx_msg void OnPartieOuvrir();
- afx_msg void OnPartieEnregistrerSous();
- afx_msg BOOL OnEraseBkgnd(CDC* ) ;
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point) ;
- friend class Dessin;
- afx_msg void OnAideRules();
- };
- #endif /* _MYMAINWINDOW_OTHELLO_H_DS_ */
|
et le .cpp (juste les 2 fonctions qui actualisent l'écran) :
Code :
- // quand le bouton de la souris est relaché
- void GraphiqueMainWin::OnLButtonUp(UINT nFlags, CPoint point)
- {
- CMemDC pDC(GetDC()) ;
- // test si la partie courante est terminée
- if (le_visuel->UpdatePions(point))
- {
- unsigned int joueur_commence ;
- if (GetMenuState(menu_principal,ID_QUICOMMENCE_JOUEUR1,MF_BYCOMMAND)==MF_CHECKED)
- {
- joueur_commence = 1 ;
- }
- else
- {
- if (GetMenuState(menu_principal,ID_QUICOMMENCE_JOUEUR2,MF_BYCOMMAND)==MF_CHECKED)
- {
- joueur_commence = 2 ;
- }
- else
- if (GetMenuState(menu_principal,ID_QUICOMMENCE_ALTERN40013,MF_BYCOMMAND)==MF_CHECKED)
- {
- joueur_commence = 0 ;
- }
- }
- // On réinitialise le jeu
- le_jeu.PlayAnOtherOne(joueur_commence) ;
- }
- le_visuel->PlotAll(pDC) ;
- }
- BOOL GraphiqueMainWin::OnEraseBkgnd(CDC* ppDC)
- {
- CMemDC pDC(ppDC) ;
- CRect rect;
- GetClientRect(&rect) ;
- status_width = rect.Width() ;
- width = status_width ;
- height = rect.Height() ;
- for(int i=0 ; i< status_length ; ++i )
- status_principal.SetPaneInfo(i,status_text[i],SBPS_NORMAL,status_width/3);
- // si le visuel n'a pas été crée alors on l'initialise
- // sinon on rafraichit
- if (le_visuel)
- le_visuel->Refresh(pDC) ;
- else
- {
- le_visuel = new Dessin(this,pDC) ;
- }
- return FALSE;
- }
|
Message édité par LordHarryPotter le 16-04-2005 à 12:04:49
|