• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

problem with BoolToStr transtyping method

Started by lafayetto, April 27, 2009, 09:31:50 am

Previous topic - Next topic

lafayetto


//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <comctrls.hpp>
#include "usb_projet.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "nrclasses"
#pragma link "nrcommbox"
#pragma link "nrusb"
#pragma link "nrusbdriver"
#pragma link "nrcommbox"
#pragma link "nrclasses"
#pragma link "nrusb"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}

void __fastcall TForm1::AddInfo(AnsiString sCapt, AnsiString sVal)
{
        TListItem *Itm;
        if(sVal.Trim() == "") return;
        Itm = lvProperties->Items->Add();
        Itm->Caption = sCapt;
        Itm->SubItems->Add(sVal);
}

//---------------------------------------------------------------------------
void __fastcall TForm1::nrDeviceBox1OnChange(TObject *Sender)
{
        int i;
        TnrUsbDevice *Dev;
        Dev = nrUSB1->UsbDevice;

        lvProperties->Items->BeginUpdate();
//        lvProperties->Clear();

        if(Dev != NULL)
        {
                AddInfo("Description",Dev->Description);
                AddInfo("Max Power",IntToStr(Dev->MaxPower)+" mA");
                AddInfo("Max Packet Size",IntToStr(Dev->MaxPacketSize));
                AddInfo("Vendor ID",IntToHex(Dev->VendorID,4)+"h");
                AddInfo("Product I",IntToHex(Dev->ProductID,4)+"h");
//AddInfo("Is Wake Up",BoolToStr(Dev->IsWakeUp,True));
//                AddInfo("Is Self Power",BoolToStr(Dev->IsSelfPower,True));
//                AddInfo("Is Bus Power",BoolToStr(Dev->IsBusPower,True));
                AddInfo("USB Version",IntToStr(Dev->VerHi) + "." + IntToStr(Dev->VerLo));
                AddInfo("Speed (Low,Full,High)",strUSBSpeeds[Dev->Speed]+" ");
                AddInfo("Pipe Count",IntToStr(Dev->PipeCount));
                AddInfo("Service",Dev->Service);
                AddInfo("Disk's",Dev->DriverLetters);
                for(int i = 0; i < Dev->Descriptors->Count; i++)
                        AddInfo("String Descriptor ["+IntToStr(i+1) + "]", Dev->Descriptors->Strings);
        }

        lvProperties->Items->EndUpdate();
}
//---------------------------------------------------------------------------
int __fastcall TForm1::WMDeviceChange(TMessage &Msg)
{
  int i = nrUSB1->DeviceIndex;
  nrUSB1->WMDeviceChange(Msg);
  nrUSB1->DeviceIndex = i;
  nrDeviceBox1OnChange(this);
  return 0;
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button1OnClick(TObject *Sender)
{
  if(nrUSB1->UsbDevice == NULL)
  {
    ShowMessage("Please select device.");
    return;
  }

  if(AnsiCompareText(nrUSB1->UsbDevice->Service,"WinUSB") == 0)
  {
    ShowMessage("WinUSB driver is already installed.");
    return;
  }

  if(Application->MessageBox("Do you want continue?","Warning",MB_YESNO) != IDYES)
    return;

  Screen->Cursor = crHourGlass;
  try
  {
//  nrUsbDriver1->Install();
  }
  __finally
  {
    Screen->Cursor = crDefault;
  }

}

nrusbdriver.hpp isn't part of nrcomm lib demo, so no problem for debugging.
For all the remaining code, void__fastcal Tform1::nrdevicebox1onchange(...),int__
fascall Tform1:: WMdevicechange(), and void__fastcall Tform1::Addinfo()
weren't part of project_usb.h... and are not declared within the form1 class.Therefore errors were justified.

Just one question: why does the BooToStr method which is transtyping method
is not recognized by builder C++ 5.0 compiler. Is it inherit to the fact that
kind of methods are not defined in Borland Builder 5.0 and require nrcomm lib
to work? is that for another reason?

Thank you very much for your answer,

All my regards.

Roman Novgorodov

Hello

Please try replace BoolToStr function by somehting like this:

AddInfo("Is Wake Up",  Dev->IsWakeUp ? "True" : "False");

Also you can read something like this:
http://www.dummies.com/store/product/C-For-Dummies-5th-Edition.productCd-0764568523,navId-322467.html

:-)

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.