CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2002
    Posts
    28

    Why don't it work in OnInitialUpdate or other

    I have the following Code to see some fields in a Combo box it works right but how can I do it in a FormView to see the combo with the items on start up so that I dont have to click any other button?

    void CSetTagsForm::OnBnClickedWrite()
    {
    for(int x = 0; x < (sizeof(genres) / sizeof(char*)); ++x)
    m_Combo.AddString(genres[x]);
    }

    thats the rest of the code:

    // SetTagsForm.cpp : implementation file
    //

    #include "stdafx.h"
    #include "MP3Locater.h"
    #include "SetTagsForm.h"
    #include "DirDialog.h"
    #include "..\id3lib-3.8.0\include\id3\tag.h"

    //Genresarten
    static const char *genres[] = {
    "Blues ", "Classic Rock ", "Country ", "Dance ",
    "Disco ", "Funk ", "Grunge ", "Hip-Hop ",
    "Jazz ", "Metal ", "New Age ", "Oldies ",
    "Other ", "Pop ", "R&B ", "Rap ",
    "Reggae ", "Rock ", "Techno ", "Industrial ",
    "Alternative ", "Ska ", "Death Metal ", "Pranks ",
    "Soundtrack ", "Euro-Techno ", "Ambient ", "Trip-Hop ",
    "Vocal ", "Jazz+Funk ", "Fusion ", "Trance ",
    "Classical ", "Instrumental ", "Acid ", "House ",
    "Game ", "Sound Clip ", "Gospel ", "Noise ",
    "Altern Rock ", "Bass ", "Soul ", "Punk ",
    "Space ", "Meditative ", "Inst. Pop ", "Instrum. Rock ",
    "Ethnic ", "Gothic ", "Darkwave ", "Techno-Indus ",
    "Electronic ", "Pop-Folk ", "Eurodance ", "Dream ",
    "Southern Rock ", "Comedy ", "Cult ", "Gangsta ",
    "Top 40 ", "Christian Rap ", "Pop/Funk ", "Jungle ",
    "Native American", "Cabaret ", "New Wave ", "Psychadelic ",
    "Rave ", "Showtunes ", "Trailer ", "Lo-Fi ",
    "Tribal ", "Acid Punk ", "Acid Jazz ", "Polka ",
    "Retro ", "Musical ", "Rock & Roll ", "Hard Rock "
    };

    /////////////////////////////////////////////////////////////////////////////////

    // CSetTagsForm

    IMPLEMENT_DYNCREATE(CSetTagsForm, CFormView)

    CSetTagsForm::CSetTagsForm()
    : CFormView(CSetTagsForm::IDD)
    , m_Directory(_T(""))
    , m_Edit_Title(_T(""))
    , m_Edit_Artist(_T(""))
    {
    }




    CSetTagsForm::~CSetTagsForm()
    {
    }

    void CSetTagsForm:oDataExchange(CDataExchange* pDX)
    {
    CFormView:oDataExchange(pDX);
    DDX_Text(pDX, IDC_DIRECTORY, m_Directory);
    DDX_Text(pDX, IDC_EDIT_TITLE, m_Edit_Title);
    DDX_Text(pDX, IDC_EDIT_ARTIST, m_Edit_Artist);
    DDX_Control(pDX, IDC_COMBO1, m_Combo);
    }

    BEGIN_MESSAGE_MAP(CSetTagsForm, CFormView)
    ON_BN_CLICKED(IDC_OPEN, OnBnClickedOpen)
    ON_BN_CLICKED(IDC_WRITE, OnBnClickedWrite)
    END_MESSAGE_MAP()


    // CSetTagsForm diagnostics

    #ifdef _DEBUG
    void CSetTagsForm::AssertValid() const
    {
    CFormView::AssertValid();
    }

    void CSetTagsForm:ump(CDumpContext& dc) const
    {
    CFormView:ump(dc);
    }
    #endif //_DEBUG


    // CSetTagsForm message handlers

    hope anyone will help me its very important

  2. #2
    Join Date
    Dec 2002
    Posts
    1,050
    Hi guy,

    You mentioned OnInitialUpdate and thats where it can be done
    void CInitialupdateView::OnInitialUpdate()
    {
    CFormView::OnInitialUpdate();
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();
    m_combo.AddString( "Hello" );
    m_combo.AddString( "Bood Bye" );
    m_combo.SetCurSel( 0 );
    }

    Are you saying this does not work the first time the form is loaded ?

  3. #3
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    Visual Studio.Net is ****ed. It does this to me too. Why?

  4. #4
    Join Date
    Dec 2002
    Posts
    1,050
    Sorry ! If this is VS.Net problem then I'm out. I uninstalled mine and left myself with VS6

    Best things to do ?
    -Set a breakpoint in OnInitialUpdate and make sure it is called.
    -Post yourself a message after creating the window and update the text there.
    -Check MS website for workaround
    -Update .netRuntime

    Good luck !

  5. #5
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    the combo box is NULL in OnInitUpdate / OnInitDialog. For some reason, it no longer gets a value until after the function have exited. You can set a timer of 1ms at the end of OnInitDialog, but that is still stupid. Why does microsoft do this to us?

  6. #6
    Join Date
    Dec 2002
    Posts
    1,050
    Well I might just reinstall to see this happening. There seems to be a lot of vc7 specific bugs here. Anyway, try putting a breakpoint where your ddx_control is for the combobox and see if that is not hit untill after.

    Otherwise try GetDlgItem(), is that null ?
    Try it after the base class call to OnCreate(), hope it works there !

    If you still have a problem I'll reinstall and try to find a good work around if you need.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured