RECHERCHER :
COMMUNAUTE MP
Identifiez vous ...
Devenir Membre
J'ai oublié mon MDP
DOMAINE MP
Bavardages
Langages Généraux
Langages Web
Langages DotNet
Autres langages
Dev. Jeux Video
Sécurité
Sys. Exploitation
Graphismes
Logiciels
Réseaux
Bases de données
Méthodologies
Emplois High-tech
Aide juridique
Articles juridiques
FORUM
Index des forums
Ajouter un sujet
Rechercher sujet
Contact Responsable
Devenir modérateur
CHAT MP IRC
Votre pseudo ...
Serv: irc.irc-land.org
Chan: #MoteurProg
PARTICIPER
Plus de 3500 emplois.
Rechercher un job
Déposez votre CV
Emplois High-tech

Visiteur MP

 Win32 C : Problème de scrolling.

Forum : C & C++ - CONSOLE
Sous Catégorie : Console
Type du sujet : Sujet Normale
FAQ : FAQ C & C++ - CONSOLE

SUIVI DES SUJETS PAR MAIL

SUIVI PAR MAIL INACTIF

RESOLUTION DU SUJET SUJET NON RESOLU
BLOQUAGE DU SUJET SUJET ACTIF
APPARTENANCE A LA FAQ N'APPARTIENT PAS A LA FAQ


POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

FORUM C & C++ - CONSOLE

PREMIERE PAGE

PAGE PRECEDENTE

Page précedente

Page suivante

PAGE SUIVANTE

DERNIERE PAGE
AZERTY2410
Nouveau membre
Avatar de AZERTY2410
Inscrit : 23/02/2008
Messages : 2
Message
#149526
Posté le 23/02/08 à 19:28
Bonjour à tous,

J'essaye d'adapter un code MFC en C et j'ai un souci avec le scrolling.
Le programme affiche sur une page 10 rangées de 10 rectangles de différentes couleurs.
Le problème est le suivant : Aprés avoir paginé de haut en bas 6 ou 7 fois, les rectangles perdent leurs couleurs et dés ce moment là, c'est la foire : une barre verticale incomplète apparaît sur la gauche, à cheval sur la barre de menus ; toute action par la suite ne permet pas de de récupérer les couleurs ; la réduction puis l'agrandissement de la fenêtre font que la zone client
occupe la totalité de l'écran.
Je pense que ce doit être lié au mapping mode mais après avoir sorti quelques variables dans un fichier
pendant l'exécution de WM_PAINT, joué sur InvalidateRect, essayé ScrollWindow, je séche.

Votre aide est la bienvenue.

Je joins ci-dessous le code des 5 procédures concernées :


#define CST_MAPMODE MM_ANISOTROPIC

void OnVScroll( HWND hWnd, HWND hWndCtl, UINT nScrollCode, int nPos )
{

RECT rc;

switch( nScrollCode ) {
case SB_BOTTOM:
break;
case SB_ENDSCROLL:
return;
case SB_LINEDOWN:
Page.nVIncr = 1;
break;
case SB_LINEUP:
Page.nVIncr = -1;
break;
case SB_PAGEDOWN:
break;
case SB_PAGEUP:
break;
case SB_THUMBPOSITION:
break;
case SB_THUMBTRACK:
break;
case SB_TOP:
break;
default:
return;
}

// InvalidateRect( hWnd, NULL, TRUE );
// int nPos = GetScrollPos( g_hWndScrollVert, SB_CTL );
GetClientRect( hWnd, &rc );
rc.right -= nSbVertcx;
ScrollWindow( hWnd, 0, -UpdScrollBars( hWnd ), &rc, NULL );
InvalidateRect( hWnd, NULL, TRUE );
}
/*----------------------------------------------------------------------------------------------*/
int UpdScrollBars( HWND hWnd )
{
RECT rc;
SCROLLINFO si;
int nPos;

GetClientRect( hWnd, &rc );
nPos = GetScrollPos( g_hWndScrollVert, SB_CTL );
si.cbSize = sizeof( SCROLLINFO );
si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
si.nPage = rc.bottom; // Page.sizeWindow.cy;
si.nMin = 0;
si.nMax = Page.Extent.cy -1;
si.nPos = Page.nVIncr *10; //(int) ( Page.nVIncr * Page.fZmFacteur );
si.nPos += nPos;
si.nPos = max( 0, si.nPos );
si.nPos = min( si.nPos, si.nMax - ( si.nPage -1 ) );

if( g_boSBVertVisible == FALSE ) ShowWindow( g_hWndScrollVert, SW_SHOW );
SetScrollInfo( g_hWndScrollVert, SB_CTL, &si, TRUE );

if( si.nPos == nPos ) return 0;
return si.nPos - nPos;
}
/*----------------------------------------------------------------------------------------------*/
int OnPaint( HWND hWnd )
{
PAINTSTRUCT ps;
HDC hDC;
int nOldMapMode;


hDC = BeginPaint( hWnd, &ps );
if( hDC ) {
nOldMapMode = SetMapMode( hDC, CST_MAPMODE );
Zoom( hWnd, hDC );
#ifdef DEBUG
Page.ps.hdc = ps.hdc;
Page.ps.rcPaint.top = ps.rcPaint.top;
Page.ps.rcPaint.left = ps.rcPaint.left;
Page.ps.rcPaint.right = ps.rcPaint.right;
Page.ps.rcPaint.bottom = ps.rcPaint.bottom;
debug( 0 );
#endif

Dessiner( hWnd, hDC );
SetMapMode( hDC, nOldMapMode );
}
EndPaint( hWnd, &ps );
return 0;
}
/*----------------------------------------------------------------------------------------------*/
void Zoom( HWND hWnd, HDC hDC )
{
RECT rc;

if( !hDC ) return;

GetClientRect( hWnd, &rc );

Page.Extent.cx = Page.ExtentOrig.cx * Page.fZmFacteur;
Page.Extent.cy = Page.ExtentOrig.cy * Page.fZmFacteur;

if( Page.Extent.cy > rc.bottom )
UpdScrollBars( hWnd );
else
HideScrollBars();

Page.ptVpOrg.x = -GetScrollPos( g_hWndScrollHorz, SB_CTL );
Page.ptVpOrg.y = -GetScrollPos( g_hWndScrollVert, SB_CTL );

if( Page.boCentre ) {
/* Si la zone client est plus large que le document, l'origine du document est
* recalculée de façon à ce que le document soit centré.
*/
if( Page.Extent.cx < Page.sizeWindow.cx )
Page.ptVpOrg.x = ( Page.sizeWindow.cx - Page.Extent.cx ) / 2;
if( Page.Extent.cy < rc.bottom )
Page.ptVpOrg.y = ( rc.bottom - Page.Extent.cy ) / 2;
}
SetWindowOrgEx( hDC, 0, 0, NULL );
SetWindowExtEx( hDC, Page.sizeLog.cx, Page.sizeLog.cy, NULL );
SetViewportOrgEx( hDC, Page.ptVpOrg.x, Page.ptVpOrg.y, NULL );
SetViewportExtEx( hDC, Page.Extent.cx, Page.Extent.cy, NULL );
}
/*----------------------------------------------------------------------------------------------*/
void Dessiner( HWND hWnd, HDC hDC )
{
RECT rc;
int nWidth,
nHeight,
nWidthPad,
nHeightPad,
nTextX,
nTextY,
nRow,
nCol,
nCouleur;
SIZE size;
HPEN hNewPen,
hOldPen;
HFONT hOldFont;
char szBuffer[ 12 ];

if( GetMapMode( hDC ) != CST_MAPMODE ) return;
GetClientRect( hWnd, &rc );
Rectangle( hDC, 1, 1, Page.sizeLog.cx -1, Page.sizeLog.cy -1 );
hOldFont = SelectObject( hDC, hFont );
nCouleur = 0;
nWidth = Page.sizeLog.cx / 10;
nHeight = Page.sizeLog.cy / 10;
nWidthPad = nWidth / 10;
nHeightPad = nHeight / 10;
for( nRow = 0; nRow < 10; nRow++ ) {
for( nCol = 0; nCol < 10; nCol++ ) {
SetRect( &rc, ( nCol * nWidth + nWidthPad ),
( nRow * nHeight + nHeightPad ),
( nCol * nWidth + nWidth - nWidthPad ),
( nRow * nHeight + nHeight - nHeightPad )
);
hNewPen = CreatePen( PS_SOLID, 0, couleurs[ nCouleur ] );
hOldPen = SelectObject( hDC, hNewPen );
Rectangle( hDC, rc.left, rc.top, rc.right, rc.bottom );
SelectObject( hDC, hOldPen );
if( ++nCouleur > NUM_COLORS -1 )
nCouleur = 0;
wsprintf( szBuffer, "row %d", nRow );
GetTextExtentPoint32( hDC, szBuffer, strlen( szBuffer ), &size );
nTextX = rc.left + ( ( (rc.right - rc.left) /2 ) - ( size.cx /2 ) );
nTextY = rc.top + ( ( (rc.bottom - rc.top) /2 ) - size.cy );
TextOut( hDC, nTextX, nTextY, szBuffer, strlen( szBuffer ) );
wsprintf( szBuffer, "col %d", nCol );
nTextY += size.cy;
TextOut( hDC, nTextX, nTextY, szBuffer, strlen( szBuffer ) );
}
}
SelectObject( hDC, hOldFont );
}
/*----------------------------------------------------------------------------------------------*/

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

Publicité
Inscrit : X
Messages : X
Message
#Aucun

HAUT DE PAGE

  

AZERTY2410
Nouveau membre
Avatar de AZERTY2410
Inscrit : 23/02/2008
Messages : 2
Message
#150144
Posté le 09/03/08 à 15:51
Smiley Ca y est, j'ai trouvé. Manquait un DeleteObject(hNewPen) dans Dessiner.

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 


    PAGE : [1]



.: Site Web développé par Julien Pichot et l'équipe MPWG avec www.evolvia-web.com :.