|
Thank You
|
|
|
|
|
Hi,
I have the following prototype in ActiveX to send the Array from my client program. The variable VarArray contains array of values, Can you please provide me an example to get the values of each index by using SafeArray.
void CSimpleAdditionAtxCtrl::Final(VARIANT* VarArray)
{
}
|
|
|
|
|
VARIANT varBuffer;
------------------
if(varBuffer.vt==(VT_ARRAY|VT_UI1))
{
DWORD dwSize=varBuffer.parray->rgsabound[0].cElements;
BYTE lpBuffer=new BYTE[dwSize];
memcpy( lpBuffer , varBuffer.parray->pvData,dwSize);
delete []lpBuffer;
}
alantop
|
|
|
|
|
sivaprakashshanmugam wrote: I have the following prototype in ActiveX to send the Array from my client program. The variable VarArray contains array of values, Can you please provide me an example to get the values of each index by using SafeArray.
Here m_vecIcecreamFlavors and m_vecIcecreamPrices are vecters of BSTR and float resp.
SAFEARRAYBOUND safeBound[2]; <br />
<br />
safeBound[0].cElements = m_vecIcecreamFlavors.size(); <br />
safeBound[0].lLbound = 0;<br />
<br />
safeBound[1].cElements = m_vecIcecreamPrices.size();<br />
safeBound[1].lLbound = 0 ;<br />
<br />
<br />
VariantInit(VarArray);<br />
pVariant->vt = VT_VARIANT | VT_ARRAY; <br />
pVariant->parray = SafeArrayCreate(VT_VARIANT,2,safeBound);<br />
<br />
<br />
std::vector<CComBSTR>::iterator iterFlavor;<br />
std::vector<float>::iterator iterPrices;<br />
<br />
<br />
<br />
long lDimension[2];<br />
int iFlavorIndex = 0;<br />
<br />
<br />
iterPrices = m_vecIcecreamPrices.begin();<br />
iterFlavor = m_vecIcecreamFlavors.begin(); <br />
<br />
<br />
while(iterFlavor != m_vecIcecreamFlavors.end()) <br />
{<br />
<br />
<br />
lDimension[1] = iFlavorIndex;<br />
lDimension[0] = 0;<br />
CComVariant variantFlavor(SysAllocString((*iterFlavor).m_str));<br />
SafeArrayPutElement(pVariant->parray,lDimension,&variantFlavor);<br />
<br />
<br />
<br />
lDimension[1] = iFlavorIndex;<br />
lDimension[0] = 1;<br />
CComVariant variantPrices(*iterPrices);<br />
SafeArrayPutElement(pVariant->parray,lDimension,&variantPrices);<br />
<br />
<br />
iFlavorIndex++;<br />
iterPrices++;<br />
iterFlavor++;<br />
<br />
<br />
}
Suppose Variant result is parameter passed for fillup then we can retrive the elements from the array as follows.
long lUDimension,lLDimension;<br />
<br />
SafeArrayGetUBound(result->parray,2,&lUDimension);<br />
SafeArrayGetLBound(result->parray,2,&lLDimension);<br />
VARIANT val[2];<br />
long Dimension[2];<br />
<br />
for(LONG i=lLDimension;i<=lUDimension;i++)<br />
{<br />
m_Data.InsertItem(i," ");<br />
Dimension[0]=0;<br />
Dimension[1]=i; <br />
HRESULT hr=SafeArrayGetElement(result->parray,Dimension,(void*)&val[0]);<br />
if(FAILED(hr))<br />
AfxMessageBox("Unable to read 1 element");<br />
m_Data.SetItemText(i,0,_com_util::ConvertBSTRToString(val[0].bstrVal));<br />
Dimension[0]=1;<br />
Dimension[1]=i; <br />
hr=SafeArrayGetElement(result->parray,Dimension,(void*)&val[1]);<br />
if(FAILED(hr))<br />
AfxMessageBox("Unable to read 2 element");<br />
m_Data.SetItemText(i,1,_com_util::ConvertBSTRToString(val[1].bstrVal));<br />
}
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
how can you make a listboxctrl show what line is selected without clicking on the line? a list of mp3's say i click the first one its hilited but when i click the next button i need it to hilite that one but i cant figure it out i tryed all the commands i could find.
|
|
|
|
|
Which control r u using ListCtrl or Listbox ?
nave
|
|
|
|
|
im using listctrl. sorry about that.
|
|
|
|
|
Use :
<br />
GetSelectionmark() <br />
SetSelectionMark()
Cheers
"Peace of mind through Technology"
|
|
|
|
|
ive tryed them everything works but it does not highlite the new line
|
|
|
|
|
locoone wrote: how can you make a listboxctrl show what line is selected without clicking on the line? a list of mp3's say i click the first one its hilited but when i click the next button i need it to hilite that one but i cant figure it out i tryed all the commands i could find.
See the following API's
SetItemState(...) in CListCtrl control
SetCurSel(...) in CListBox control
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
for SetitemState this is copied from msdn
nState
New values for the state bits.
nMask
Mask specifying which state bits to change
i dont know what they are asking for i cant find anything on what i should put in themi mean does nState mean CHECKED or WM_CHECKED i have no clue what they want.
|
|
|
|
|
If the fous is not current in the listctrl, set the Focus to listctrl using
SetFocus()
Then call
SetItemState( nItem, LVIS_SELECTED , LVIS_SELECTED );
nave
|
|
|
|
|
well that makes it highlite the next one but the firstone doesnt unhighlite im tired i might just be missing something will check tomorrow
|
|
|
|
|
Set the Single Selection style( LVS_SINGLESEL ) of the List ctlr. If this style is set only one item in the list ctrl will be selected at a time.
nave
|
|
|
|
|
that worked thanks dude
something is wrong somewhere my listctrl var is m_list but when i type m_list. it dont popup that windows with all the things i can do.
-- modified at 4:27 Saturday 17th June, 2006
|
|
|
|
|
hi,
if you know please tell me where i can get gSpan source code, it belongs to Data Mining to find out supgraph.
Thanks so much.
|
|
|
|
|
|
Thanks so much
-- modified at 0:37 Tuesday 20th June, 2006
|
|
|
|
|
Hi.
Do you still have the source code?
Thanks
|
|
|
|
|
Do we have any good effective WIN32 API which can tell whether my application is running on a system with a color v/s monochrome monitor attached.
A sample code snippet will be helpful.
Am using the following sample and apparently its not giving correct results always.
bool bColorMonitor = false;
// Get the display information
DEVMODE devmode;
if (::EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode))
{
//If dmDisplayFlags is set to zero then monitor is colored otherwise GrayScaled.
bColorMonitor = !(0x01 & devmode.dmDisplayFlags);
}
else
{
dirTrace.Error(_T("EnumDisplaySettings() failed"));
}
|
|
|
|
|
|
This is not giving what I want. It doesnt tell you whether the monitor attached to your system is a color or a monochrome monitor.
If some one tell me as to why EnumDisplaySettings doesnt work consistently with all types of monitors then that should be fine too.
|
|
|
|
|
If you want to consider a 'gray scale' monitor to be 'color' then you can just check the bits per pixel for the devmode.
If the BBP is 1, then it is monochrome. If it is more than that, then it is 'color' even if the color is shades of gray. You obviously need to do something else to distinguish color from gray scale, but at least this tells you 'basic' monochrome from 'everything else'.
I've seen better runs in my shorts! - Patches O'Houlihan
|
|
|
|
|
Ok, I've got a question about making modular applications. At least that what I call them. Basically, I have a bunch of classes, or rather just headers. Now for the implementations, I want to be able to create multiple implementaions of any class, and not have to recompile the whole program. So basically, say I have a class cWindowMaker. It has a Create_Window(x, y, width, height) function, and maybe some callbacks, but lets say it just has the Create_Window function. Now, I make an implementation that basically creates a window with all the bells and whistles, like the title bar, all the titlebar buttons, resizable, etc. And then I somehoe compile that implementation in a DLL file. Then, I load that DLL dynaically, create an instance of the class and call my Crete_Window function. Now, imagine I make another implementation, that basically makes a window without anything, no border etc. Make another DLL and now I want to use it. Well, obviously I jus have to replace the old DLL and restart my app and voila. The hard part? HOW do I make all that work?? Can't wrap my head around it. Can anybody please help? Im sure this kind of stuff has been done by somebody here before...
Thanks in advance.
rara avis in terris
|
|
|
|
|
A better approach would be to go through polymorphism: create a base class CWindowMaker that does nothing and create a class that inherits from it and implement its functionalities for a specific type of window (let's call it CWindowType1). You can create as many subclasses as you like and each of them implement a specific behavior.
Now, you can choose one or the other by using a pointer to the base class and create it the type you want:
CWindowMaker* pMyWindow = new CWindowType1;
Your pointer is still considered as a pointer to the bass class but in fact implements all the functionalitites defined in your CWindowType1 class. Using this mechanism, you can of course select your window at run-time (for example, ask the user to select the type of window and depending of his choice, create the correct instance, via a switch for example).
I suggest you read maybe some documentation about polymorphism, it could be helpfull.
Cédric Moonen
Software developer
Charting control
|
|
|
|