Click here to Skip to main content
15,909,645 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Help to modify dialog style using ModifyStyleEx() Pin
David Crow20-Feb-07 2:33
David Crow20-Feb-07 2:33 
AnswerRe: Help to modify dialog style using ModifyStyleEx() Pin
bosfan20-Feb-07 2:37
bosfan20-Feb-07 2:37 
GeneralRe: Help to modify dialog style using ModifyStyleEx() Pin
David Crow20-Feb-07 2:52
David Crow20-Feb-07 2:52 
GeneralRe: Help to modify dialog style using ModifyStyleEx() Pin
bosfan20-Feb-07 4:46
bosfan20-Feb-07 4:46 
QuestionWindows SDK Communication Question Pin
Jethro6319-Feb-07 4:53
Jethro6319-Feb-07 4:53 
AnswerRe: Windows SDK Communication Question Pin
Roger Stoltz19-Feb-07 5:13
Roger Stoltz19-Feb-07 5:13 
GeneralRe: Windows SDK Communication Question Pin
Jethro6319-Feb-07 7:53
Jethro6319-Feb-07 7:53 
QuestionComBSTR Question Pin
Like2Byte19-Feb-07 3:41
Like2Byte19-Feb-07 3:41 
Hello everyone,

I'm migrating an MFC application to use a new interface (Old DLL to new OCX). the old interface used _TCHAR, bool, etc..., types. The new interface (OCX) uses VARIANTs - *everywhere*.

here's the problem: We're using a structure to maintain a list of active connections (MAX 10).

/*header file - SANDBOX.H*/
typedef struct SModuleInfo
{
#if 1
/*new*/
  CComBSTR bstrModName[256];
  CComBSTR bstrBinFileName[256];
  VARIANT  vbSelected;  /*T/F - if item was selected
  VARIANT  vModHandle;  /*Module Handle*/
  VARIANT  vModID;  /*Module ID*/
  VARIANT  *m_cpzModName;
  VARIANT  *m_pzBinFileName;
#else
/*old*/
  BOOL  bSelected;  /*T/F - if item was selected
  long  lModHandle;  /*Module Handle*/
  long  lModID;  /*Module ID*/
  _TCHAR  m_cpzModName[256];
  _TCHAR  m_pzBinFileName[256];
#endif
} SModuleInfo_t;


class CSandboxApp : public CWinApp
{
public:
  void ModInfoDestroy();
  bool InitModInfo();
  SModuleInfo_t mods[10];
  CSandboxApp();

// Overrides
   ...

// Implementation
   ...
};


Would the following code be the best way to initialize my structure?

/*SOURCE CODE - SANDBOX.CPP*/

bool CSandboxApp::InitModInfo()
{
  for( short i = 0 ; i < 10 ; i++ )
  {
     mods[i].bSelected.vt = VT_BOOL;
     mods[i].lModHandle.vt = VT_I4;
     mods[i].lModID.vt = VT_I4;
     mods[i].lVdsID.vt = VT_I4;
	
     mods[i].m_cpzModName->vt = VT_BSTR;
     mods[i].m_pzBinFileName->vt = VT_BSTR;
     mods[i].m_cpzModName->bstrVal = mods[i].bstrModName->Copy();
     mods[i].m_pzBinFileName->bstrVal = mods[i].bstrBinFileName->Copy();
   }
   return 1;
}

void CSandboxApp::ModInfoDestroy()
{
   int i = 0;
      for( i = 0 ; i < 10 ; i++ )
      {
         mods[i].bSelected.bVal = FALSE;
         mods[i].lModHandle.lVal = 0;
         mods[i].lModID.lVal = 0;
         mods[i].lVdsID.lVal = 0;
         mods[i].m_cpzModName->bstrVal = NULL;
         mods[i].m_pzBinFileName->bstrVal = NULL;
         mods[i].bstrModName->Empty();
         mods[i].bstrBinFileName->Empty();	
      }
}


Between InitModInfo() and DestroyModInfo() I will be populating mods[i].m_pzBinFileName and mods[i].m_cpzModName with textual data the user will be selecting from a listbox. The other values (longs, bools, etc.) will be filled as appropriate later.

My chief concern is properly maintaining the two BSTR arrays. Can I expect this code to align the data correctly so I can pass the variant String data to a function that takes VARIANTs? I think it is ATL and I've not used it before.

Thanks. Unsure | :~
AnswerRe: ComBSTR Question Pin
prasad_som19-Feb-07 6:00
prasad_som19-Feb-07 6:00 
GeneralRe: ComBSTR Question Pin
Like2Byte19-Feb-07 7:21
Like2Byte19-Feb-07 7:21 
AnswerRe: ComBSTR Question Pin
Stephen Hewitt19-Feb-07 17:40
Stephen Hewitt19-Feb-07 17:40 
GeneralRe: ComBSTR Question Pin
Like2Byte20-Feb-07 3:51
Like2Byte20-Feb-07 3:51 
QuestionCLISTBOX Owner Drawn ListBox , DrawText does not return correct height. Pin
Killer319-Feb-07 3:35
Killer319-Feb-07 3:35 
Questionfile input program Pin
klutez12319-Feb-07 3:19
klutez12319-Feb-07 3:19 
AnswerRe: file input program Pin
David Crow19-Feb-07 3:22
David Crow19-Feb-07 3:22 
AnswerRe: file input program Pin
toxcct19-Feb-07 3:23
toxcct19-Feb-07 3:23 
GeneralRe: file input program Pin
jhwurmbach19-Feb-07 3:32
jhwurmbach19-Feb-07 3:32 
GeneralRe: file input program Pin
Sebastian Schneider19-Feb-07 3:59
Sebastian Schneider19-Feb-07 3:59 
Questiondrawing pixels in a different game Pin
Parallan19-Feb-07 2:34
Parallan19-Feb-07 2:34 
AnswerRe: drawing pixels in a different game [modified] Pin
Newbie0019-Feb-07 4:11
Newbie0019-Feb-07 4:11 
GeneralRe: drawing pixels in a different game Pin
Parallan19-Feb-07 4:33
Parallan19-Feb-07 4:33 
GeneralRe: drawing pixels in a different game [modified] Pin
Parallan19-Feb-07 4:52
Parallan19-Feb-07 4:52 
QuestionRe: drawing pixels in a different game Pin
Mark Salsbery19-Feb-07 8:07
Mark Salsbery19-Feb-07 8:07 
QuestionRe: drawing pixels in a different game [modified] Pin
Parallan19-Feb-07 8:25
Parallan19-Feb-07 8:25 
QuestionSystem Menu Pin
urid19-Feb-07 2:02
urid19-Feb-07 2:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.