screen difference according to windows XP
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: screen difference according to windows XP

  1. #1
    Join Date
    Jan 2006
    Location
    Marseille, France
    Posts
    94

    screen difference according to windows XP

    Hi,

    I have a real problem to understand why my MFC DialogBox application doesn't work at the same way according to pc (under XP) where it run.

    look a screen, on the left a screenshot on my boss's pc where it doesn't work correctly

    on the right, my pc, it run correctly

    you can see that button position and size are different : why ?
    Attached Images Attached Images  

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: screen difference according to windows XP

    Isn't it funny that it should happen on your boss' system ?? And scary too..
    From the look of it, it appears you are showing a bitmap background and the proiblem seems to be with that not being stretched all the way. Are you doing some sort of background painting for the dialog ?

  3. #3
    Join Date
    Jan 2006
    Location
    Marseille, France
    Posts
    94

    Re: screen difference according to windows XP

    On other forum,

    one say me that this problem come from font size, font is bigger on my boss'pc than on mine, he say that elements's position are base d on font size

    he advices me to resize and move each element manually,
    but I don't see how I can do to correct it and to get the same screen with differents font size

    an idea / advice ?

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: screen difference according to windows XP

    That is true. The controls are ok, IMO. You haven't answered my question, though..

  5. #5
    Join Date
    Jan 2006
    Location
    Marseille, France
    Posts
    94

    Re: screen difference according to windows XP

    Sorry,

    Yes, I use this code to show my background :


    Code:
    class CMyDialog:
    	public CDialog
    {
    private:
    	CBitmap m_Background;	
    	int m_iWidth, m_iHeight;
    
    .........
    }
    
    
    
    CMyDialog::CMyDialog(UINT nIDTemplate, CWnd* pParentWnd, UINT iIDD_Background)
    {
    	m_Background.LoadBitmap(iIDD_Background);	// lecture bitmap dans les ressources
    	BITMAP InfosBackground;
    	m_Background.GetBitmap(&InfosBackground);	// structure d'informations.
    	m_iWidth  = InfosBackground.bmWidth;
    	m_iHeight = InfosBackground.bmHeight;
    
    	CDialog::CDialog(nIDTemplate, pParentWnd);
    }
    
    
    
    BOOL CMyDialog::OnEraseBkgnd(CDC* pDC)
    {	
        CDC MemDC;
    	
    	// creation d'un DC en memoire
        MemDC.CreateCompatibleDC(pDC);	
    
    	// selection du bitmap dans le DC en memoire
        MemDC.SelectObject(&m_Background);	
        
    	// transfert final du bitmap dans le dc de la view.
    	pDC->BitBlt( 0,0,m_iWidth, m_iHeight, &MemDC, 0, 0, SRCCOPY); 
    
    	return TRUE;
    }

  6. #6
    Join Date
    Jan 2006
    Posts
    35

    Re: screen difference according to windows XP

    to paint the bmp you use

    pDC->BitBlt( 0,0,m_iWidth, m_iHeight, &MemDC, 0, 0, SRCCOPY);

    insted if you use strectchblt() API that will solve your problem

  7. #7
    Join Date
    Jan 2006
    Location
    Marseille, France
    Posts
    94

    Re: screen difference according to windows XP

    No, I need keeping the width & height I gave while development

  8. #8
    Join Date
    Jan 2006
    Posts
    35

    Re: screen difference according to windows XP

    then before painting take the height and width with GetClientRect then pase this rectangle to the painting routine; means use the height and width of this rect in painting

  9. #9
    Join Date
    Jan 2006
    Location
    Marseille, France
    Posts
    94

    Re: screen difference according to windows XP

    You don't understand what I want to mean,
    Sorry for bad explaining me....

    In fact, I want all my CDialog to keep exactly size I gave when I developped it and this, whatever is it's configuration (little or big font ....)

    On other forum, developper gave me this code witch seems working when I change font size on my pc but not on these of my boss

    Code:
    int CMyDialog::DoModal()
    {
       CDialogTemplate dlgTemp;
       int			 nResult;
    
       // lecture du template d'origine
       if (!dlgTemp.Load(MAKEINTRESOURCE(IDD))) return -1;
    
       // fonte par defaut
       dlgTemp.SetFont("MS Sans Serif", 8);
    
       // pointeur sur le dialogue template modifié
       LPSTR pdata = reinterpret_cast<LPSTR>(GlobalLock(dlgTemp.m_hTemplate));
    
       m_lpszTemplateName = NULL;
       InitModalIndirect(pdata);
    
       // appel DoModal
       nResult = (int) CDialog::DoModal();
    
       // liberation du template modifié
       GlobalUnlock(dlgTemp.m_hTemplate);
    
       return nResult;
    }
    Writting dlgTemp.SetFont("MS Sans Serif", 12); show me the same problem he has
    Last edited by FireJocker; February 8th, 2006 at 05:34 AM.

  10. #10
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: screen difference according to windows XP

    Quote Originally Posted by FireJocker
    In fact, I want all my CDialog to keep exactly size I gave when I developped it and this, whatever is it's configuration (little or big font ....)
    Dialog resource templates are an automatism meant to create standard dialogs which adapt in a flexible way to the user's preferences. That's why you design them using dialog units, not pixels. At run-time, the system will convert the dialog size and control positions to pixels, depending on the system font base size the user has chosen in the 'Display' control panel.

    If you want to circumvent that automatism, then you can't use dialog resource templates, but need to create and position your controls programmatically to hard-coded pixel positions.

    However, keep in mind that users (like your boss, in your example) usually have a good reason for changing the base font size on their system - most likely, they have a very high resolution display, or simply a weaker eyesight. As a result, every normal dialog will be resized accordingly, and all controls are moved and resized for a larger display. It is obvious that if you hard-code your dialog to fixed pixel values and font sizes, your dialog will appear smaller than other dialogs on the system, and possibly be hard to read for the user.

    The cheap way out would be to resize your bitmap accordingly (as already suggested by bantisk above). You can avoid most of the loss of image quality if you provide a rather large bitmap and scale it down via StretchBlt(), using HALFTONE as the StretchBlt mode. If you absolutely need to avoid bitmap resizing, you could provide different bitmaps for different font sizes / resolutions, and choose the correct bitmap at run-time.

  11. #11
    Join Date
    Jan 2006
    Location
    Marseille, France
    Posts
    94

    Resolved Re: screen difference according to windows XP

    Ok, I followed your advice, and strech the picture as you told me.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center