Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

LPCTSTR to int and other silly errors

RbickRbick Member Posts: 17
Hello Gentlemen,

I'm currently developing a program for IP based intercom systems. I am using MFC to make an activeX wrapper for the .dll which has already been made. I keep getting these errors, and they have been my only problem thus far. The following code produces error C2664 cannot convert parameter 1 from "LPCTSTR" to "int". However, if I remove LPCTSTR, it gives me the same error, just in reverse.

[code]m_listIcoms.InsertColumn((LPCTSTR)COL_ICON,"",LVCFMT_LEFT,20,-1);
m_listIcoms.InsertColumn((LPCTSTR)COL_LOCATION,"Location",LVCFMT_LEFT,165,-1);
m_listIcoms.InsertColumn((LPCTSTR)COL_STATUS, "Status",LVCFMT_LEFT,101,-1);
m_listIcoms.InsertColumn((LPCTSTR)COL_DOOR, "Door/Gate",LVCFMT_LEFT,62,-1);
m_listIcoms.InsertColumn((LPCTSTR)COL_ADDRESS, "IPAddress",LVCFMT_LEFT,107,-1);[/code]

This is code to add columns to the ActiveX control.

My other error states that everything left of "->m_pMainWnd;" needs class/struct/union or that it hasn't been defined. My problem is that it is defined using extern (theApp is what is left of m_pMainWnd) and I have included the proper .h files in my source files.

My definitions are shown here:
[code]#pragma once

#if !defined( __AFXCTL_H__ )
#error "include 'afxctl.h' before including this file"
#endif

#include "resource.h"
class CActiveXApp : public COleControlModule
{
public:
BOOL InitInstance();
int ExitInstance();
CActiveXApp();

protected:
HMODULE m_hButtonControl;
};

extern const GUID CDECL _tlid;
extern const WORD _wVerMajor;
extern const WORD _wVerMinor;

[b]extern CActiveXApp *theApp;[/b][/code]

This is in my main activex.h file. Any help would be greatly appreciated. Thanks guys.

Comments

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : Hello Gentlemen,
    :
    : I'm currently developing a program for IP based intercom systems. I
    : am using MFC to make an activeX wrapper for the .dll which has
    : already been made. I keep getting these errors, and they have been
    : my only problem thus far. The following code produces error C2664
    : cannot convert parameter 1 from "LPCTSTR" to "int". However, if I
    : remove LPCTSTR, it gives me the same error, just in reverse.
    :

    Not so very familair with MFC, so could you post the definition of COL_ICON, and of InsertColumn?


    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • RbickRbick Member Posts: 17
    : Not so very familair with MFC, so could you post the definition of
    : COL_ICON, and of InsertColumn?
    :
    :
    : Best Regards,
    : Richard


    No Problem. definition of COL_ICON is located in my PropPage.h and is:
    [code]
    struct _listData
    {
    void **data;
    int dataSize;
    };

    [b]#define COL_ICON 0[/b]
    #define COL_LOCATION 1
    #define COL_STATUS 2
    #define COL_DOOR 3
    #define COL_ADDRESS 4[/code]

    and InsertColumn is located in afxcmn.h which is already pre-programmed in windows. It is:

    [code]// Inserts a column into a report-mode control.
    int InsertColumn(int nCol, const LVCOLUMN* pColumn);
    int InsertColumn(int nCol, LPCTSTR lpszColumnHeading,
    int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1);[/code]

    Thanks again =)
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    In that case, this should work:

    : [code]: m_listIcoms.InsertColumn(COL_ICON,_T(""),LVCFMT_LEFT,20,-1);
    : m_listIcoms.InsertColumn(COL_LOCATION, _T("Location"),LVCFMT_LEFT,165,-1);
    : m_listIcoms.InsertColumn(COL_STATUS, _T("Status"),LVCFMT_LEFT,101,-1);
    : m_listIcoms.InsertColumn(COL_DOOR, _T("Door/Gate"),LVCFMT_LEFT,62,-1);
    : m_listIcoms.InsertColumn(COL_ADDRESS, _T("IPAddress"),LVCFMT_LEFT,107,-1);[/code]:

    The _T() macro insures the string literal is of type TCHAR. Furtherly, I've removed the casting from integer value to LPCTSTR (why did you do that in the first place?), because the code wants an int and not a string.
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • RbickRbick Member Posts: 17
    I'm not sure why I put that there. I think I got frustrated and started putting code in randomly in an attempt to fix it. I've been working on this damn thing for months. Thanks for the help though, the errors in that section are solved =)
Sign In or Register to comment.