CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old May 9th, 2001, 09:42 AM
    WXP WXP is offline
    Member
     
    Join Date: May 2001
    Location: Switzerland
    Posts: 175
    WXP is an unknown quantity at this point (<10)
    Background Picture on Dialog

    Hey !

    I Created a Dialog Based App.
    And i put a picture box on the background and other controls on it. The trouble is they disappear under the picture.
    So i changed the TAB Order but when a window comes over my app the button disappear again !!

    How is it possible to put a picture on the background without a picture box ?

    OR how it is possible to have my controls over eveything ?

    Thanx

    Reply With Quote
      #2    
    Old May 9th, 2001, 10:00 AM
    Xeon's Avatar
    Xeon Xeon is offline
    Want me to ban you?!
    Power Poster
     
    Join Date: Jul 2000
    Location: Singapore
    Posts: 4,195
    Xeon will become famous soon enough (50+)
    Re: Background Picture on Dialog


    That's no way to do things, pal! A picture box is both inefficient and darn, pal. :-D

    Now, Uncle Xeon to the fire scene rescue!

    First, in your OnInitDialog(), code the following and paste everything just above the 'return TRUE;' statement, but below everything else:

    CBitmap bitmap;
    bitmap.LoadBitmap(IDB_YOURBITMAP);

    CClientDC dc(this);
    CRect rcRect;
    GetClientRect(rcRect);
    CDC memDC;
    memDC.CreateCompatibleDC(&dc);
    memDC.SelectObject(&bitmap);

    dc.BitBlt(0,0,rcRect.Width(), rcRect.Height(),&memDC,0,0,SRCCOPY);




    Now, that's all to it! But preferably, u should add a windows message handler call WM_ERASEBKGND and add the code above to it. Now, don't treat me to a buffet though. :-D That's too grand! :-D


    __________________
    "Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria

    "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria
    Reply With Quote
      #3    
    Old May 9th, 2001, 10:09 AM
    WXP WXP is offline
    Member
     
    Join Date: May 2001
    Location: Switzerland
    Posts: 175
    WXP is an unknown quantity at this point (<10)
    Re: Background Picture on Dialog

    It's not working Xeon.. sorry..

    My Dialog do not have my pic on the background.. not even a pixel !

    anyother idea ?


    BOOL CGPIBMultimeterDlg::OnInitDialog()
    {
    CDialog::OnInitDialog();

    // Set the icon for this dialog. The framework does this automatically
    // when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE); // Set big icon
    SetIcon(m_hIcon, FALSE); // Set small icon

    // Some of my code...

    CBitmap bitmap;
    bitmap.LoadBitmap(IDB_INTERFACE_BITMAP);
    CClientDC dc(this);
    CRect rcRect;
    GetClientRect(rcRect);
    CDC memDC;
    memDC.CreateCompatibleDC(&dc);
    memDC.SelectObject(&bitmap);
    dc.BitBlt(0,0,rcRect.Width(), rcRect.Height(),&memDC,0,0,SRCCOPY);

    return TRUE; // return TRUE unless you set the focus to a control
    }




    Reply With Quote
      #4    
    Old May 9th, 2001, 10:15 AM
    Weiye Weiye is offline
    Senior Member
     
    Join Date: Jun 1999
    Location: Singapore
    Posts: 1,304
    Weiye is an unknown quantity at this point (<10)
    Re: Background Picture on Dialog

    You can do your displaying of bitmap inside you dialog's OnDraw(...) function.

    Chen Weiye
    ------------------------------------------------------------------------------
    When pursuing your dream, don't forget to enjoy your life...
    ------------------------------------------------------------------------------
    __________________
    Chen Weiye
    -----------------------------------------------------------------------------
    When pursuing your dream, don't forget to enjoy your life
    -----------------------------------------------------------------------------
    Reply With Quote
      #5    
    Old May 9th, 2001, 10:19 AM
    Gerd Mayer Gerd Mayer is offline
    Member
     
    Join Date: Jun 1999
    Location: Germany
    Posts: 343
    Gerd Mayer is an unknown quantity at this point (<10)
    Re: Background Picture on Dialog


    class CGPIBMultimeterDlg : public CDialog
    //....
    //{{AFX_MSG(CGPIBMultimeterDlg )
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    //}}AFX_MSG
    //....

    BEGIN_MESSAGE_MAP(CGPIBMultimeterDlg, CDialog)
    //{{AFX_MSG_MAP(CMedStatix)
    ON_WM_ERASEBKGND()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()

    BOOL CGPIBMultimeterDlg::OnEraseBkGnd(CDC* pDC)
    {
    CBitmap bitmap;
    bitmap.LoadBitmap(IDB_INTERFACE_BITMAP);
    CRect rcRect;
    GetClientRect(rcRect);
    CDC memDC;
    memDC.CreateCompatibleDC(pDC);
    memDC.SelectObject(&bitmap);
    dc.BitBlt(0,0,rcRect.Width(),
    rcRect.Height(),&memDC,0,0,SRCCOPY);
    return TRUE; // Don't call base class
    }




    That's the way

    But another hint;-)
    You should make
    the CBitmap bitmap;
    as a member of your dialog and load the bitmap only one time in the OnInitDialog

    Regards,
    Gerd

    Gerd
    Reply With Quote
      #6    
    Old May 9th, 2001, 10:20 AM
    WXP WXP is offline
    Member
     
    Join Date: May 2001
    Location: Switzerland
    Posts: 175
    WXP is an unknown quantity at this point (<10)
    Re: Background Picture on Dialog

    thanx it worked

    Reply With Quote
      #7    
    Old May 9th, 2001, 10:26 AM
    Xeon's Avatar
    Xeon Xeon is offline
    Want me to ban you?!
    Power Poster
     
    Join Date: Jul 2000
    Location: Singapore
    Posts: 4,195
    Xeon will become famous soon enough (50+)
    Re: Background Picture on Dialog


    Do u have the bitmap imported into your resources?

    __________________
    "Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria

    "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:37 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009