• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1275
  • Last Modified:

c++ errors ( cannot convert parameter 2 from 'char [32]' to 'int')

I am getting the following errors in my code (from an override):

.\TotalControl.cpp(36) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to 'LPWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
.\TotalControl.cpp(37) : error C2664: 'HRESULT (char *,int)' : cannot convert parameter 2 from 'char [32]' to 'int'
        There is no context in which this conversion is possible

Code:

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <stdio.h>
#include "stdafx.h"
#include "KC0Mapper.h"
#include "VdjPlugin.h"
#include "vdjDevice.h"

// Mapper class
class KC0DefaultMapper : public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};

// Set device type
HRESULT KC0DefaultMapper::GetDeviceType(int *type)
{
      *type = PLUGINDEVICE_TOTALCONTROL;
      return(PLUGINDEVICE_TOTALCONTROL);
}

HRESULT KC0DefaultMapper::OnSlider(int chan,int slider,int absvalue,int relvalue)
{
      char cmd[32];

      switch(slider)
      {
            case KC0_SLID_CROSSFADER:
            wsprintf(cmd,"video_crossfade %d",absvalue);
            SendCommand(chan,cmd);
            break;
      }
}

// Return information about plugin
HRESULT KC0DefaultMapper::OnGetPluginInfo(TVdjPluginInfo *infos)
{
      static char st[128];

      infos->PluginName = ".";
      infos->Author = ".";
      infos->Description = ".";
      infos->Flag = 0;

      infos->Bitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(100));

      return S_OK;
}
0
makman111
Asked:
makman111
  • 2
  • 2
3 Solutions
 
jimstarCommented:
From just looking at this code, there are two separate issues I think.

For the first error:
Try changing from wsprintf to sprintf.

For the second error:
HRESULT (char *,int) seems to be the prototype for the function SendCommand, however you are providing (int, char*). Switch your params around and that should work. SendCommand(cmd,chan). I'm making guesses since I don't have the function prototype to reference.
0
 
jkrCommented:
>>error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to >>'LPWSTR'

To me that looks like the project is set to use UNICODE, yet the code doesn't - try to turn off UNICODE in your project settings or make that the ANSI version explicitly:

wsprintfA(cmd,"video_crossfade %d",absvalue);

Yet changing the settings will save you a lot of changes like the above.
0
 
makman111Author Commented:
Use Multi-Byte Character Set?
0
 
jkrCommented:
Yes, that would be the setting ;o)
0
 
makman111Author Commented:
Can you look at (below) as well?  I think you are correct, but the errors below are preventing me from seeing to total solution.

http://www.experts-exchange.com/Programming/Languages/CPP/Q_22880391.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now