Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,444 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,274 people online right now. Registration is fast and FREE... Join Now!




Can any one tell me whats wrong with this code?

 
Reply to this topicStart new topic

Can any one tell me whats wrong with this code?

AntiBNI
6 Jan, 2008 - 07:20 PM
Post #1

D.I.C Head
**

Joined: 21 Jul, 2006
Posts: 59


My Contributions
This is the Source:

CODE
// BitDefender Update DownloaderDlg.cpp : implementation file
//

#include "stdafx.h"
#include "BitDefender Update Downloader.h"
#include "BitDefender Update DownloaderDlg.h"
#include "Urlmon.h"
#include "windows.h"
#include "afxwin.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
    CAboutDlg();

// Dialog Data
    //{{AFX_DATA(CAboutDlg)
    enum { IDD = IDD_ABOUTBOX };
    //}}AFX_DATA

    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAboutDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL

// Implementation
protected:
    //{{AFX_MSG(CAboutDlg)
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
    //{{AFX_DATA_INIT(CAboutDlg)
    //}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAboutDlg)
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    //{{AFX_MSG_MAP(CAboutDlg)
        // No message handlers
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBitDefenderUpdateDownloaderDlg dialog

CBitDefenderUpdateDownloaderDlg::CBitDefenderUpdateDownloaderDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CBitDefenderUpdateDownloaderDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CBitDefenderUpdateDownloaderDlg)
    m_text = _T("");
    m_version = _T("");
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CBitDefenderUpdateDownloaderDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CBitDefenderUpdateDownloaderDlg)
    DDX_Control(pDX, IDC_BUTTON2, m_download);
    DDX_Text(pDX, IDC_EDIT1, m_text);
    DDX_CBString(pDX, IDC_COMBO1, m_version);
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CBitDefenderUpdateDownloaderDlg, CDialog)
    //{{AFX_MSG_MAP(CBitDefenderUpdateDownloaderDlg)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
    ON_CBN_SETFOCUS(IDC_COMBO1, OnSetfocus)
    ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchange)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBitDefenderUpdateDownloaderDlg message handlers

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

    // Add "About..." menu item to system menu.

    // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
        CString strAboutMenu;
        strAboutMenu.LoadString(IDS_ABOUTBOX);
        if (!strAboutMenu.IsEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }

    // 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
    
    // TODO: Add extra initialization here
    m_download.LoadBitmaps(IDB_Download);
    m_download.SizeToContent();
    return TRUE;  // return TRUE  unless you set the focus to a control
}

void CBitDefenderUpdateDownloaderDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CBitDefenderUpdateDownloaderDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // device context for painting

        SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

        // Center icon in client rectangle
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // Draw the icon
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CBitDefenderUpdateDownloaderDlg::OnQueryDragIcon()
{
    return (HCURSOR) m_hIcon;
}

void CBitDefenderUpdateDownloaderDlg::OnButton2()
{
    m_text = "Downloading Update...";
  UpdateData(FALSE);
    HRESULT hr;
  hr = URLDownloadToFile(NULL,"http://download.bitdefender.com/updates/bitdefender_2008/x86/weekly.exe","BitDefender Total Security 2008 Update.exe",0,NULL);

  if ( hr == S_OK)
      m_text = "Download Completed";
  UpdateData(FALSE);

  if (hr == E_OUTOFMEMORY)
      m_text = "Download Failed";
  UpdateData(FALSE);

  if (hr == INET_E_DOWNLOAD_FAILURE)
      m_text = "Download Failed";
  UpdateData(FALSE);
}


void CBitDefenderUpdateDownloaderDlg::OnSelchange()
{
int CurSel = m_version.GetCurSel();    

switch( CurSel )
    {

case 0: m_text = "BTDENDR1";
             UpdateData(FALSE);
case 1: m_text = "BTDENDR2";
             UpdateData(FALSE);
case 2: m_text = "BTDENDR4";
             UpdateData(FALSE);
}
}


and this is the error:

CODE
DownloaderDlg.cpp(205) : error C2039: 'GetCurSel' : is not a member of 'CString'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
Error executing cl.exe.

BitDefender Update Downloader.exe - 1 error(s), 0 warning(s)


Help will be appreciated biggrin.gif icon_up.gif

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Can Any One Tell Me Whats Wrong With This Code?
6 Jan, 2008 - 08:08 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,209



Thanked: 214 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well it means that you have defined the variable "m_version" to be of type CString and that class doesn't have a method called "GetCurSel()". So you might have either defined your variable as the wrong type or you are trying to reference something that is not there. Could you have meant some kind of control instead of defining this as a CString? For instance, could it have been a listbox or something where it defines a GetCurSel() method?

So take a look at m_version and how you have defined it. smile.gif
User is online!Profile CardPM
+Quote Post

AntiBNI
RE: Can Any One Tell Me Whats Wrong With This Code?
7 Jan, 2008 - 07:26 AM
Post #3

D.I.C Head
**

Joined: 21 Jul, 2006
Posts: 59


My Contributions
Fixed it and works like a charm happy.gif.

Thanks Bro biggrin.gif

I appreciate your help icon_up.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 02:20PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month